mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
Fix command completion issue (bug #3257)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4694 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
32
cli.c
32
cli.c
@@ -776,8 +776,8 @@ static struct ast_cli_entry builtins[] = {
|
|||||||
{ { "reload", NULL }, handle_reload, "Reload configuration", reload_help, complete_mod_2 },
|
{ { "reload", NULL }, handle_reload, "Reload configuration", reload_help, complete_mod_2 },
|
||||||
{ { "set", "debug", NULL }, handle_set_debug, "Set level of debug chattiness", set_debug_help },
|
{ { "set", "debug", NULL }, handle_set_debug, "Set level of debug chattiness", set_debug_help },
|
||||||
{ { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
|
{ { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
|
||||||
{ { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help },
|
|
||||||
{ { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 },
|
{ { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 },
|
||||||
|
{ { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help },
|
||||||
{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
|
{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
|
||||||
{ { "show", "modules", "like", NULL }, handle_modlist, "List modules and info", modlist_help, complete_mod_4 },
|
{ { "show", "modules", "like", NULL }, handle_modlist, "List modules and info", modlist_help, complete_mod_4 },
|
||||||
{ { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
|
{ { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
|
||||||
@@ -1171,19 +1171,19 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
|
|||||||
}
|
}
|
||||||
if ((fullcmd[0] != '_') && !strncasecmp(matchstr, fullcmd, strlen(matchstr))) {
|
if ((fullcmd[0] != '_') && !strncasecmp(matchstr, fullcmd, strlen(matchstr))) {
|
||||||
/* We contain the first part of one or more commands */
|
/* We contain the first part of one or more commands */
|
||||||
matchnum++;
|
/* Now, what we're supposed to return is the next word... */
|
||||||
if (matchnum > state) {
|
if (!ast_strlen_zero(word) && x>0) {
|
||||||
/* Now, what we're supposed to return is the next word... */
|
res = e->cmda[x-1];
|
||||||
if (!ast_strlen_zero(word) && x>0) {
|
} else {
|
||||||
res = e->cmda[x-1];
|
res = e->cmda[x];
|
||||||
} else {
|
}
|
||||||
res = e->cmda[x];
|
if (res) {
|
||||||
}
|
matchnum++;
|
||||||
if (res) {
|
if (matchnum > state) {
|
||||||
if (lock)
|
if (lock)
|
||||||
ast_mutex_unlock(&clilock);
|
ast_mutex_unlock(&clilock);
|
||||||
free(dup);
|
free(dup);
|
||||||
return res ? strdup(res) : NULL;
|
return strdup(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1191,10 +1191,12 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
|
|||||||
/* We have a command in its entirity within us -- theoretically only one
|
/* We have a command in its entirity within us -- theoretically only one
|
||||||
command can have this occur */
|
command can have this occur */
|
||||||
fullcmd = e->generator(matchstr, word, (!ast_strlen_zero(word) ? (x - 1) : (x)), state);
|
fullcmd = e->generator(matchstr, word, (!ast_strlen_zero(word) ? (x - 1) : (x)), state);
|
||||||
if (lock)
|
if (fullcmd) {
|
||||||
ast_mutex_unlock(&clilock);
|
if (lock)
|
||||||
free(dup);
|
ast_mutex_unlock(&clilock);
|
||||||
return fullcmd;
|
free(dup);
|
||||||
|
return fullcmd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user