mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Fix a couple minor command line completion issues
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3593 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -7790,10 +7790,12 @@ static int start_pri(struct zt_pri *pri)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *complete_span(char *line, char *word, int pos, int state)
|
static char *complete_span_helper(char *line, char *word, int pos, int state, int rpos)
|
||||||
{
|
{
|
||||||
int span=1;
|
int span=1;
|
||||||
char tmp[50];
|
char tmp[50];
|
||||||
|
if (pos != rpos)
|
||||||
|
return 0;
|
||||||
while(span <= NUM_SPANS) {
|
while(span <= NUM_SPANS) {
|
||||||
if (span > state && pris[span-1].pri)
|
if (span > state && pris[span-1].pri)
|
||||||
break;
|
break;
|
||||||
@@ -7806,6 +7808,16 @@ static char *complete_span(char *line, char *word, int pos, int state)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *complete_span_4(char *line, char *word, int pos, int state)
|
||||||
|
{
|
||||||
|
return complete_span_helper(line,word,pos,state,3);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *complete_span_5(char *line, char *word, int pos, int state)
|
||||||
|
{
|
||||||
|
return complete_span_helper(line,word,pos,state,4);
|
||||||
|
}
|
||||||
|
|
||||||
static int handle_pri_debug(int fd, int argc, char *argv[])
|
static int handle_pri_debug(int fd, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int span;
|
int span;
|
||||||
@@ -7944,16 +7956,16 @@ static char pri_show_span_help[] =
|
|||||||
" Displays PRI Information\n";
|
" Displays PRI Information\n";
|
||||||
|
|
||||||
static struct ast_cli_entry pri_debug = {
|
static struct ast_cli_entry pri_debug = {
|
||||||
{ "pri", "debug", "span", NULL }, handle_pri_debug, "Enables PRI debugging on a span", pri_debug_help, complete_span };
|
{ "pri", "debug", "span", NULL }, handle_pri_debug, "Enables PRI debugging on a span", pri_debug_help, complete_span_4 };
|
||||||
|
|
||||||
static struct ast_cli_entry pri_no_debug = {
|
static struct ast_cli_entry pri_no_debug = {
|
||||||
{ "pri", "no", "debug", "span", NULL }, handle_pri_no_debug, "Disables PRI debugging on a span", pri_no_debug_help, complete_span };
|
{ "pri", "no", "debug", "span", NULL }, handle_pri_no_debug, "Disables PRI debugging on a span", pri_no_debug_help, complete_span_5 };
|
||||||
|
|
||||||
static struct ast_cli_entry pri_really_debug = {
|
static struct ast_cli_entry pri_really_debug = {
|
||||||
{ "pri", "intense", "debug", "span", NULL }, handle_pri_really_debug, "Enables REALLY INTENSE PRI debugging", pri_really_debug_help, complete_span };
|
{ "pri", "intense", "debug", "span", NULL }, handle_pri_really_debug, "Enables REALLY INTENSE PRI debugging", pri_really_debug_help, complete_span_5 };
|
||||||
|
|
||||||
static struct ast_cli_entry pri_show_span = {
|
static struct ast_cli_entry pri_show_span = {
|
||||||
{ "pri", "show", "span", NULL }, handle_pri_show_span, "Displays PRI Information", pri_show_span_help, complete_span };
|
{ "pri", "show", "span", NULL }, handle_pri_show_span, "Displays PRI Information", pri_show_span_help, complete_span_4 };
|
||||||
|
|
||||||
#endif /* ZAPATA_PRI */
|
#endif /* ZAPATA_PRI */
|
||||||
|
|
||||||
|
26
cli.c
26
cli.c
@@ -581,11 +581,13 @@ static int handle_showchan(int fd, int argc, char *argv[])
|
|||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *complete_ch(char *line, char *word, int pos, int state)
|
static char *complete_ch_helper(char *line, char *word, int pos, int state, int rpos)
|
||||||
{
|
{
|
||||||
struct ast_channel *c;
|
struct ast_channel *c;
|
||||||
int which=0;
|
int which=0;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
if (pos != rpos)
|
||||||
|
return NULL;
|
||||||
c = ast_channel_walk_locked(NULL);
|
c = ast_channel_walk_locked(NULL);
|
||||||
while(c) {
|
while(c) {
|
||||||
if (!strncasecmp(word, c->name, strlen(word))) {
|
if (!strncasecmp(word, c->name, strlen(word))) {
|
||||||
@@ -603,6 +605,16 @@ static char *complete_ch(char *line, char *word, int pos, int state)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *complete_ch_3(char *line, char *word, int pos, int state)
|
||||||
|
{
|
||||||
|
return complete_ch_helper(line, word, pos, state, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *complete_ch_4(char *line, char *word, int pos, int state)
|
||||||
|
{
|
||||||
|
return complete_ch_helper(line, word, pos, state, 3);
|
||||||
|
}
|
||||||
|
|
||||||
static char *complete_fn(char *line, char *word, int pos, int state)
|
static char *complete_fn(char *line, char *word, int pos, int state)
|
||||||
{
|
{
|
||||||
char *c;
|
char *c;
|
||||||
@@ -626,18 +638,18 @@ static struct ast_cli_entry builtins[] = {
|
|||||||
{ { "_command", "complete", NULL }, handle_commandcomplete, "Command complete", commandcomplete_help },
|
{ { "_command", "complete", NULL }, handle_commandcomplete, "Command complete", commandcomplete_help },
|
||||||
{ { "_command", "nummatches", NULL }, handle_commandnummatches, "Returns number of command matches", commandnummatches_help },
|
{ { "_command", "nummatches", NULL }, handle_commandnummatches, "Returns number of command matches", commandnummatches_help },
|
||||||
{ { "_command", "matchesarray", NULL }, handle_commandmatchesarray, "Returns command matches array", commandmatchesarray_help },
|
{ { "_command", "matchesarray", NULL }, handle_commandmatchesarray, "Returns command matches array", commandmatchesarray_help },
|
||||||
{ { "debug", "channel", NULL }, handle_debugchan, "Enable debugging on a channel", debugchan_help, complete_ch },
|
{ { "debug", "channel", NULL }, handle_debugchan, "Enable debugging on a channel", debugchan_help, complete_ch_3 },
|
||||||
{ { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help },
|
{ { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help },
|
||||||
{ { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
|
{ { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
|
||||||
{ { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch },
|
{ { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch_4 },
|
||||||
{ { "reload", NULL }, handle_reload, "Reload configuration", reload_help },
|
{ { "reload", NULL }, handle_reload, "Reload configuration", reload_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", "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 },
|
{ { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 },
|
||||||
{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
|
{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
|
||||||
{ { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
|
{ { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
|
||||||
{ { "show", "version", NULL }, handle_version, "Display version info", version_help },
|
{ { "show", "version", NULL }, handle_version, "Display version info", version_help },
|
||||||
{ { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch },
|
{ { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch_3 },
|
||||||
{ { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn },
|
{ { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn },
|
||||||
{ { NULL }, NULL, NULL, NULL }
|
{ { NULL }, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
@@ -1025,7 +1037,7 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
|
|||||||
fullcmd = fullcmd1;
|
fullcmd = fullcmd1;
|
||||||
e1++;
|
e1++;
|
||||||
}
|
}
|
||||||
if ((fullcmd[0] != '_') && !strncasecmp(text, fullcmd, strlen(text))) {
|
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++;
|
matchnum++;
|
||||||
if (matchnum > state) {
|
if (matchnum > state) {
|
||||||
@@ -1046,7 +1058,7 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
|
|||||||
if (e->generator && !strncasecmp(matchstr, fullcmd, strlen(fullcmd))) {
|
if (e->generator && !strncasecmp(matchstr, fullcmd, strlen(fullcmd))) {
|
||||||
/* 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(text, 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 (lock)
|
||||||
ast_mutex_unlock(&clilock);
|
ast_mutex_unlock(&clilock);
|
||||||
free(dup);
|
free(dup);
|
||||||
|
Reference in New Issue
Block a user