aboutsummaryrefslogtreecommitdiffstats
path: root/main/cli.c
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-18 18:42:00 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-18 18:42:00 +0000
commit8be2579ceff14bd1cef90915475f5069bf921b73 (patch)
tree3160052a74927393e58b3ea56c618a5320a2e3ad /main/cli.c
parentb9726ddf8c1b1f05934bf960ef770fef39598d52 (diff)
Fix an issue with file name completion in "module load" and "load".
Issue 8846 git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@51245 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/cli.c')
-rw-r--r--main/cli.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/main/cli.c b/main/cli.c
index 023ca4bc8..bce55e1a2 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1243,7 +1243,7 @@ static char *complete_mod_4(const char *line, const char *word, int pos, int sta
return ast_module_helper(line, word, pos, state, 3, 0);
}
-static char *complete_fn(const char *line, const char *word, int pos, int state)
+static char *complete_fn_2(const char *line, const char *word, int pos, int state)
{
char *c;
char filename[256];
@@ -1264,6 +1264,27 @@ static char *complete_fn(const char *line, const char *word, int pos, int state)
return c ? strdup(c) : c;
}
+static char *complete_fn_3(const char *line, const char *word, int pos, int state)
+{
+ char *c;
+ char filename[256];
+
+ if (pos != 2)
+ return NULL;
+
+ if (word[0] == '/')
+ ast_copy_string(filename, word, sizeof(filename));
+ else
+ snprintf(filename, sizeof(filename), "%s/%s", ast_config_AST_MODULE_DIR, word);
+
+ c = filename_completion_function(filename, state);
+
+ if (c && word[0] != '/')
+ c += (strlen(ast_config_AST_MODULE_DIR) + 1);
+
+ return c ? strdup(c) : c;
+}
+
static int group_show_channels(int fd, int argc, char *argv[])
{
#define FORMAT_STRING "%-25s %-20s %-20s\n"
@@ -1391,7 +1412,7 @@ static struct ast_cli_entry cli_show_modules_like_deprecated = {
static struct ast_cli_entry cli_module_load_deprecated = {
{ "load", NULL },
handle_load_deprecated, NULL,
- NULL, complete_fn };
+ NULL, complete_fn_2 };
static struct ast_cli_entry cli_module_reload_deprecated = {
{ "reload", NULL },
@@ -1460,7 +1481,7 @@ static struct ast_cli_entry cli_cli[] = {
{ { "module", "load", NULL },
handle_load, "Load a module by name",
- load_help, complete_fn, &cli_module_load_deprecated },
+ load_help, complete_fn_3, &cli_module_load_deprecated },
{ { "module", "reload", NULL },
handle_reload, "Reload configuration",