[Asterisk-code-review] main/test: Use ast cli completion add. (asterisk[15])
Corey Farrell
asteriskteam at digium.com
Sun Mar 18 17:35:10 CDT 2018
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8579
Change subject: main/test: Use ast_cli_completion_add.
......................................................................
main/test: Use ast_cli_completion_add.
Change-Id: I5133ff2ba4e030f9733fb3d050c863d72a22ae6b
---
M main/test.c
1 file changed, 24 insertions(+), 24 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/79/8579/1
diff --git a/main/test.c b/main/test.c
index f45ad9b..0528baf 100644
--- a/main/test.c
+++ b/main/test.c
@@ -691,40 +691,40 @@
return test;
}
-static char *complete_test_category(const char *line, const char *word, int pos, int state)
+static char *complete_test_category(const char *word, int pos)
{
- int which = 0;
int wordlen = strlen(word);
- char *ret = NULL;
struct ast_test *test;
AST_LIST_LOCK(&tests);
AST_LIST_TRAVERSE(&tests, test, entry) {
- if (!strncasecmp(word, test->info.category, wordlen) && ++which > state) {
- ret = ast_strdup(test->info.category);
- break;
+ if (!strncasecmp(word, test->info.category, wordlen)) {
+ if (ast_cli_completion_add(ast_strdup(test->info.category))) {
+ break;
+ }
}
}
AST_LIST_UNLOCK(&tests);
- return ret;
+
+ return NULL;
}
-static char *complete_test_name(const char *line, const char *word, int pos, int state, const char *category)
+static char *complete_test_name(const char *word, const char *category)
{
- int which = 0;
int wordlen = strlen(word);
- char *ret = NULL;
struct ast_test *test;
AST_LIST_LOCK(&tests);
AST_LIST_TRAVERSE(&tests, test, entry) {
- if (!test_cat_cmp(test->info.category, category) && (!strncasecmp(word, test->info.name, wordlen) && ++which > state)) {
- ret = ast_strdup(test->info.name);
- break;
+ if (!test_cat_cmp(test->info.category, category) && !strncasecmp(word, test->info.name, wordlen)) {
+ if (ast_cli_completion_add(ast_strdup(test->info.name))) {
+ break;
+ }
}
}
AST_LIST_UNLOCK(&tests);
- return ret;
+
+ return NULL;
}
/* CLI commands */
@@ -749,16 +749,16 @@
return NULL;
case CLI_GENERATE:
if (a->pos == 3) {
- return ast_cli_complete(a->word, option1, a->n);
+ return ast_cli_complete(a->word, option1, -1);
}
if (a->pos == 4) {
- return complete_test_category(a->line, a->word, a->pos, a->n);
+ return complete_test_category(a->word, a->pos);
}
if (a->pos == 5) {
- return ast_cli_complete(a->word, option2, a->n);
+ return ast_cli_complete(a->word, option2, -1);
}
if (a->pos == 6) {
- return complete_test_name(a->line, a->word, a->pos, a->n, a->argv[3]);
+ return complete_test_name(a->word, a->argv[3]);
}
return NULL;
case CLI_HANDLER:
@@ -808,16 +808,16 @@
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
- return ast_cli_complete(a->word, option1, a->n);
+ return ast_cli_complete(a->word, option1, -1);
}
if (a->pos == 3) {
- return complete_test_category(a->line, a->word, a->pos, a->n);
+ return complete_test_category(a->word, a->pos);
}
if (a->pos == 4) {
- return ast_cli_complete(a->word, option2, a->n);
+ return ast_cli_complete(a->word, option2, -1);
}
if (a->pos == 5) {
- return complete_test_name(a->line, a->word, a->pos, a->n, a->argv[3]);
+ return complete_test_name(a->word, a->argv[3]);
}
return NULL;
case CLI_HANDLER:
@@ -877,7 +877,7 @@
return NULL;
case CLI_GENERATE:
if (a->pos == 3) {
- return ast_cli_complete(a->word, option1, a->n);
+ return ast_cli_complete(a->word, option1, -1);
}
return NULL;
case CLI_HANDLER:
@@ -950,7 +950,7 @@
return NULL;
case CLI_GENERATE:
if (a->pos == 3) {
- return ast_cli_complete(a->word, option, a->n);
+ return ast_cli_complete(a->word, option, -1);
}
return NULL;
case CLI_HANDLER:
--
To view, visit https://gerrit.asterisk.org/8579
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5133ff2ba4e030f9733fb3d050c863d72a22ae6b
Gerrit-Change-Number: 8579
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180318/35323958/attachment-0001.html>
More information about the asterisk-code-review
mailing list