<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8591">View Change</a></p><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, 19 insertions(+), 22 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/91/8591/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/manager.c b/main/manager.c<br>index 31465f6..1343823 100644<br>--- a/main/manager.c<br>+++ b/main/manager.c<br>@@ -2325,9 +2325,8 @@<br> {<br> struct manager_action *cur;<br> struct ast_str *authority;<br>- int num, l, which;<br>+ int num, 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 +2341,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 +2480,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 +2494,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>@@ -8636,8 +8634,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>@@ -8655,18 +8651,19 @@<br> <br> if (cmd == CLI_GENERATE) {<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/8591">change 8591</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/8591"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I658141c6ec490a3e866b02d2afea757928ceaabf </div>
<div style="display:none"> Gerrit-Change-Number: 8591 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>