<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8590">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">manager: Use ast_cli_completion_add for completion generators.<br><br>Change-Id: I658141c6ec490a3e866b02d2afea757928ceaabf<br>---<br>M main/manager.c<br>1 file changed, 24 insertions(+), 22 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/manager.c b/main/manager.c<br>index b698702..4303c9f 100644<br>--- a/main/manager.c<br>+++ b/main/manager.c<br>@@ -2325,9 +2325,9 @@<br> {<br>    struct manager_action *cur;<br>   struct ast_str *authority;<br>-   int num, l, which;<br>+   int num;<br>+     int l;<br>        const char *auth_str;<br>-        char *ret = NULL;<br> #ifdef AST_XML_DOCS<br>       char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64];<br>  char arguments_title[64], privilege_title[64], final_response_title[64], list_responses_title[64];<br>@@ -2342,16 +2342,16 @@<br>           return NULL;<br>  case CLI_GENERATE:<br>            l = strlen(a->word);<br>-              which = 0;<br>            AST_RWLIST_RDLOCK(&actions);<br>              AST_RWLIST_TRAVERSE(&actions, cur, list) {<br>-                       if (!strncasecmp(a->word, cur->action, l) && ++which > a->n) {<br>-                           ret = ast_strdup(cur->action);<br>-                            break;  /* make sure we exit even if ast_strdup() returns NULL */<br>+                    if (!strncasecmp(a->word, cur->action, l)) {<br>+                           if (ast_cli_completion_add(ast_strdup(cur->action))) {<br>+                                    break;<br>+                               }<br>                     }<br>             }<br>             AST_RWLIST_UNLOCK(&actions);<br>-             return ret;<br>+          return NULL;<br>  }<br>     if (a->argc < 4) {<br>              return CLI_SHOWUSAGE;<br>@@ -2481,8 +2481,7 @@<br> static char *handle_showmanager(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br> {<br>  struct ast_manager_user *user = NULL;<br>-        int l, which;<br>-        char *ret = NULL;<br>+    int l;<br>        struct ast_str *rauthority = ast_str_alloca(MAX_AUTH_PERM_STRING);<br>    struct ast_str *wauthority = ast_str_alloca(MAX_AUTH_PERM_STRING);<br>    struct ast_variable *v;<br>@@ -2496,19 +2495,19 @@<br>              return NULL;<br>  case CLI_GENERATE:<br>            l = strlen(a->word);<br>-              which = 0;<br>            if (a->pos != 3) {<br>                         return NULL;<br>          }<br>             AST_RWLIST_RDLOCK(&users);<br>                AST_RWLIST_TRAVERSE(&users, user, list) {<br>-                        if ( !strncasecmp(a->word, user->username, l) && ++which > a->n ) {<br>-                              ret = ast_strdup(user->username);<br>-                         break;<br>+                       if (!strncasecmp(a->word, user->username, l)) {<br>+                                if (ast_cli_completion_add(ast_strdup(user->username))) {<br>+                                 break;<br>+                               }<br>                     }<br>             }<br>             AST_RWLIST_UNLOCK(&users);<br>-               return ret;<br>+          return NULL;<br>  }<br> <br>  if (a->argc != 4) {<br>@@ -8643,8 +8642,6 @@<br>         struct ao2_iterator it_events;<br>        struct ast_xml_doc_item *item, *temp;<br>         int length;<br>-  int which;<br>-   char *match = NULL;<br> <br>        if (cmd == CLI_INIT) {<br>                e->command = "manager show event";<br>@@ -8661,19 +8658,24 @@<br>      }<br> <br>  if (cmd == CLI_GENERATE) {<br>+           if (a->pos != 3) {<br>+                        return NULL;<br>+         }<br>+<br>          length = strlen(a->word);<br>-         which = 0;<br>            it_events = ao2_iterator_init(events, 0);<br>             while ((item = ao2_iterator_next(&it_events))) {<br>-                 if (!strncasecmp(a->word, item->name, length) && ++which > a->n) {<br>-                               match = ast_strdup(item->name);<br>-                           ao2_ref(item, -1);<br>-                           break;<br>+                       if (!strncasecmp(a->word, item->name, length)) {<br>+                               if (ast_cli_completion_add(ast_strdup(item->name))) {<br>+                                     ao2_ref(item, -1);<br>+                                   break;<br>+                               }<br>                     }<br>                     ao2_ref(item, -1);<br>            }<br>             ao2_iterator_destroy(&it_events);<br>-                return match;<br>+<br>+             return NULL;<br>  }<br> <br>  if (a->argc != 4) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8590">change 8590</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8590"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I658141c6ec490a3e866b02d2afea757928ceaabf </div>
<div style="display:none"> Gerrit-Change-Number: 8590 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>