[Asterisk-code-review] main/ccss: Use ast cli completion add for core id. (asterisk[15])
Jenkins2
asteriskteam at digium.com
Fri Mar 16 19:14:57 CDT 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8537 )
Change subject: main/ccss: Use ast_cli_completion_add for core id.
......................................................................
main/ccss: Use ast_cli_completion_add for core id.
Change-Id: I44b25d6d24c7d9bc1bb38a50774b38883162f98f
---
M main/ccss.c
1 file changed, 8 insertions(+), 9 deletions(-)
Approvals:
George Joseph: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/ccss.c b/main/ccss.c
index ed0bba7..fa569aa 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -4547,11 +4547,9 @@
return 0;
}
-static char *complete_core_id(const char *line, const char *word, int pos, int state)
+static char *complete_core_id(const char *word)
{
- int which = 0;
int wordlen = strlen(word);
- char *ret = NULL;
struct ao2_iterator core_iter = ao2_iterator_init(cc_core_instances, 0);
struct cc_core_instance *core_instance;
@@ -4559,15 +4557,16 @@
cc_unref(core_instance, "CLI tab completion iteration")) {
char core_id_str[20];
snprintf(core_id_str, sizeof(core_id_str), "%d", core_instance->core_id);
- if (!strncmp(word, core_id_str, wordlen) && ++which > state) {
- ret = ast_strdup(core_id_str);
- cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
- break;
+ if (!strncmp(word, core_id_str, wordlen)) {
+ if (ast_cli_completion_add(ast_strdup(core_id_str))) {
+ cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
+ break;
+ }
}
}
ao2_iterator_destroy(&core_iter);
- return ret;
+ return NULL;
}
static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -4583,7 +4582,7 @@
return NULL;
case CLI_GENERATE:
if (a->pos == 3 && !strcasecmp(a->argv[2], "core")) {
- return complete_core_id(a->line, a->word, a->pos, a->n);
+ return complete_core_id(a->word);
}
return NULL;
}
--
To view, visit https://gerrit.asterisk.org/8537
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I44b25d6d24c7d9bc1bb38a50774b38883162f98f
Gerrit-Change-Number: 8537
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180316/2c549098/attachment.html>
More information about the asterisk-code-review
mailing list