diff options
Diffstat (limited to 'main/cli.c')
-rw-r--r-- | main/cli.c | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/main/cli.c b/main/cli.c index ef86e256a..0896181b0 100644 --- a/main/cli.c +++ b/main/cli.c @@ -45,7 +45,6 @@ #include <regex.h> #include <pwd.h> #include <grp.h> -#include <editline/readline.h> #include "asterisk/cli.h" #include "asterisk/linkedlists.h" @@ -224,28 +223,6 @@ static int cli_has_permissions(int uid, int gid, const char *command) static AST_RWLIST_HEAD_STATIC(helpers, ast_cli_entry); -static char *complete_fn(const char *word, int state) -{ - char *c, *d; - char filename[PATH_MAX]; - - if (word[0] == '/') - ast_copy_string(filename, word, sizeof(filename)); - else - snprintf(filename, sizeof(filename), "%s/%s", ast_config_AST_MODULE_DIR, word); - - c = d = filename_completion_function(filename, state); - - if (c && word[0] != '/') - c += (strlen(ast_config_AST_MODULE_DIR) + 1); - if (c) - c = ast_strdup(c); - - ast_std_free(d); - - return c; -} - static char *handle_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { /* "module load <mod>" */ @@ -258,12 +235,14 @@ static char *handle_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args * return NULL; case CLI_GENERATE: - if (a->pos != e->args) + if (a->pos != e->args) { return NULL; - return complete_fn(a->word, a->n); + } + return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, AST_MODULE_HELPER_LOAD); } - if (a->argc != e->args + 1) + if (a->argc != e->args + 1) { return CLI_SHOWUSAGE; + } if (ast_load_resource(a->argv[e->args])) { ast_cli(a->fd, "Unable to load module %s\n", a->argv[e->args]); return CLI_FAILURE; @@ -286,7 +265,7 @@ static char *handle_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args return NULL; case CLI_GENERATE: - return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, 1); + return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, AST_MODULE_HELPER_RELOAD); } if (a->argc == e->args) { ast_module_reload(NULL); @@ -482,7 +461,7 @@ static char *handle_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args } } else if ((a->pos == 4 && !atleast && strcasecmp(argv3, "off") && strcasecmp(argv3, "channel")) || (a->pos == 5 && atleast)) { - return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, 0); + return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, AST_MODULE_HELPER_RUNNING); } return NULL; } @@ -733,7 +712,7 @@ static char *handle_unload(struct ast_cli_entry *e, int cmd, struct ast_cli_args return NULL; case CLI_GENERATE: - return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, 0); + return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, AST_MODULE_HELPER_UNLOAD); } if (a->argc < e->args + 1) return CLI_SHOWUSAGE; @@ -889,10 +868,11 @@ static char *handle_modlist(struct ast_cli_entry *e, int cmd, struct ast_cli_arg return NULL; case CLI_GENERATE: - if (a->pos == e->args) - return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, 0); - else + if (a->pos == e->args) { + return ast_module_helper(a->line, a->word, a->pos, a->n, a->pos, AST_MODULE_HELPER_LOADED); + } else { return NULL; + } } /* all the above return, so we proceed with the handler. * we are guaranteed to have argc >= e->args @@ -1690,10 +1670,12 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar "Name: %s\n" " Type: %s\n" " State: %s\n" + " Group: %d\n" " Formats: %s\n", ast_stream_get_name(stream), ast_codec_media_type2str(ast_stream_get_type(stream)), ast_stream_state2str(ast_stream_get_state(stream)), + ast_stream_get_group(stream), ast_format_cap_get_names(ast_stream_get_formats(stream), &codec_buf) ); } |