diff options
author | Luigi Rizzo <rizzo@icir.org> | 2006-03-28 23:33:02 +0000 |
---|---|---|
committer | Luigi Rizzo <rizzo@icir.org> | 2006-03-28 23:33:02 +0000 |
commit | 096bf1511fe1e53b3ca10ffcd4e1b994ade7bca8 (patch) | |
tree | 365efb88bff7bdab308366abfe1e55ac65907974 /channels | |
parent | b94f6a6df415836923a7d7abf377021cc9903e03 (diff) |
another batch of cli simplifications
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@15857 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_iax2.c | 8 | ||||
-rw-r--r-- | channels/chan_oss.c | 16 | ||||
-rw-r--r-- | channels/iax2-provision.c | 8 |
3 files changed, 9 insertions, 23 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index ab5954129..409fab52a 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -2116,11 +2116,9 @@ static char *complete_iax2_show_peer(const char *line, const char *word, int pos if (pos == 3) { ast_mutex_lock(&peerl.lock); for (p = peerl.peers ; p ; p = p->next) { - if (!strncasecmp(p->name, word, wordlen)) { - if (++which > state) { - res = ast_strdup(p->name); - break; - } + if (!strncasecmp(p->name, word, wordlen) && ++which > state) { + res = ast_strdup(p->name); + break; } } ast_mutex_unlock(&peerl.lock); diff --git a/channels/chan_oss.c b/channels/chan_oss.c index f318cd631..89c3e3e36 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -1035,19 +1035,9 @@ static int console_autoanswer(int fd, int argc, char *argv[]) static char *autoanswer_complete(const char *line, const char *word, int pos, int state) { - int l = strlen(word); - - switch(state) { - case 0: - if (l && !strncasecmp(word, "on", MIN(l, 2))) - return ast_strdup("on"); - case 1: - if (l && !strncasecmp(word, "off", MIN(l, 3))) - return ast_strdup("off"); - default: - return NULL; - } - return NULL; + static char *choices[] = { "on", "off", NULL }; + + return (pos != 1) ? NULL : ast_cli_complete(word, choices, state); } static char autoanswer_usage[] = diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c index 794804251..d5e0061f9 100644 --- a/channels/iax2-provision.c +++ b/channels/iax2-provision.c @@ -164,11 +164,9 @@ char *iax_prov_complete_template(const char *line, const char *word, int pos, in ast_mutex_lock(&provlock); for (c = templates; c; c = c->next) { - if (!strncasecmp(word, c->name, wordlen)) { - if (++which > state) { - ret = strdup(c->name); - break; - } + if (!strncasecmp(word, c->name, wordlen) && ++which > state) { + ret = strdup(c->name); + break; } } ast_mutex_unlock(&provlock); |