]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
another batch of cli simplifications
authorLuigi Rizzo <rizzo@icir.org>
Tue, 28 Mar 2006 23:33:02 +0000 (23:33 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Tue, 28 Mar 2006 23:33:02 +0000 (23:33 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@15857 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
channels/chan_oss.c
channels/iax2-provision.c

index ab5954129b152c448bacd430a157749b4c125f84..409fab52a1c6e6a4157a275d9cee5a2465663457 100644 (file)
@@ -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);
index f318cd63162487ba5e4da554d9fe430fb0d247ba..89c3e3e3686d45183a536f2baa0a023018e90a0e 100644 (file)
@@ -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[] =
index 794804251e92c41bc1a03cfbbfb28c9431f0333f..d5e0061f9bcc50ed1dfea19e347f1cf6cbbb07be 100644 (file)
@@ -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);