diff options
author | Michiel van Baak <michiel@vanbaak.info> | 2008-09-06 12:03:11 +0000 |
---|---|---|
committer | Michiel van Baak <michiel@vanbaak.info> | 2008-09-06 12:03:11 +0000 |
commit | 28764dd1f6c34888009baeb6a64334f6182bb007 (patch) | |
tree | ca4cc6ba18e876ee69cbdfd12b5c25bba6d9702b /channels/chan_sip.c | |
parent | 57c056b5aa044f0d5aea1d64aaad4f90f7ea1d63 (diff) |
Some fixes to autocompletion in some commands.
Changes applied by this patch:
- Fix autocompletion in 'sip prune realtime', sip peers where never auto completed. Now we complete this command with:
'sip prune realtime peer' -> all | like | sip peers
Also I have modified the syntax in the usage, was wrong...
- Pass ast_cli_args->argv and ast_cli_args->argc while running autocompletion on CLI commands (CLI_GENERATE).
With this we avoid comparisons on ast_cli_args->line like this:
strcasestr(a->line, " description")
strcasestr(a->line, "descriptions ")
strcasestr(a->line, "realtime peer"), and so on..
Making the code more confusing (check the spaces in description!).
The only thing we must be sure is to first check a->pos or a->argc.
- Fix 'iax2 prune realtime' autocompletion, now we autocomplete this command with 'all' & 'iax2 peers', check a look that iax2 peers where all the peers, now only the ones in the cache..
(closes issue #13133)
Reported by: eliel
Patches:
clichanges.patch uploaded by eliel (license 64)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@141464 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index c1e21d4e3..4f122e351 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -12740,19 +12740,25 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli char *name = NULL; regex_t regexbuf; struct ao2_iterator i; + static char *choices[] = { "all", "like", NULL }; + char *cmplt; if (cmd == CLI_INIT) { - e->command = "sip prune realtime [peer|all] [all|like]"; + e->command = "sip prune realtime [peer|all]"; e->usage = - "Usage: sip prune realtime [peer] [<name>|all|like <pattern>]\n" + "Usage: sip prune realtime [peer [<name>|all|like <pattern>]|all]\n" " Prunes object(s) from the cache.\n" " Optional regular expression pattern is used to filter the objects.\n"; return NULL; } else if (cmd == CLI_GENERATE) { - if (a->pos == 4) { - if (strcasestr(a->line, "realtime peer")) - return complete_sip_peer(a->word, a->n, SIP_PAGE2_RTCACHEFRIENDS); - } + if (a->pos == 4 && !strcasecmp(a->argv[3], "peer")) { + cmplt = ast_cli_complete(a->word, choices, a->n); + if (!cmplt) + cmplt = complete_sip_peer(a->word, a->n - sizeof(choices), SIP_PAGE2_RTCACHEFRIENDS); + return cmplt; + } + if (a->pos == 5 && !strcasecmp(a->argv[4], "like")) + return complete_sip_peer(a->word, a->n, SIP_PAGE2_RTCACHEFRIENDS); return NULL; } switch (a->argc) { @@ -12778,9 +12784,9 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli multi = TRUE; } else return CLI_SHOWUSAGE; - if (!strcasecmp(a->argv[4], "like")) + if (!strcasecmp(name, "like")) return CLI_SHOWUSAGE; - if (!multi && !strcasecmp(a->argv[4], "all")) { + if (!multi && !strcasecmp(name, "all")) { multi = TRUE; name = NULL; } @@ -14384,7 +14390,7 @@ static char *sip_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args " IP address or registered peer.\n"; return NULL; } else if (cmd == CLI_GENERATE) { - if (a->pos == 4 && strcasestr(a->line, " peer")) /* XXX should check on argv too */ + if (a->pos == 4 && !strcasecmp(a->argv[3], "peer")) return complete_sip_peer(a->word, a->n, 0); return NULL; } |