Newer
Older
return __ast_cli_generator(text, word, state, 1);
}
int ast_cli_command(int fd, char *s)
{
char *argv[AST_MAX_ARGS];
struct ast_cli_entry *e;
int x;
char *dup;
x = AST_MAX_ARGS;
if ((dup = parse_args(s, &x, argv))) {
/* We need at least one entry, or ignore */
if (x > 0) {
ast_mutex_lock(&clilock);
ast_mutex_unlock(&clilock);
if (e) {
switch(e->handler(fd, x, argv)) {
case RESULT_SHOWUSAGE:
ast_cli(fd, e->usage);
break;
}
} else
ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
ast_mutex_lock(&clilock);
ast_mutex_unlock(&clilock);
}
free(dup);
} else {
ast_log(LOG_WARNING, "Out of memory\n");
return -1;
}
return 0;
}