diff options
author | Corey Farrell <git@cfware.com> | 2018-03-14 13:38:01 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-03-15 07:25:28 -0400 |
commit | b45bb476bb985909d7d891ceb1a9cccfb7763ec6 (patch) | |
tree | 9d359f888c468a01fc2fbb552bcb783e9c5c5be6 /main/pbx_app.c | |
parent | 1a9ed413a104a6390d5088fe5c5a1ebb0dea55a3 (diff) |
cli: Enable ast_cli_completion_add on public completion generators.
* ast_cli_complete
* ast_complete_channels
* ast_complete_applications
These generators will now use ast_cli_completion_add if state == -1.
Change-Id: I7ff311f0873099be0e43a3dc5415c0cd06d15756
Diffstat (limited to 'main/pbx_app.c')
-rw-r--r-- | main/pbx_app.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/main/pbx_app.c b/main/pbx_app.c index ec6bc7589..df8126c7f 100644 --- a/main/pbx_app.c +++ b/main/pbx_app.c @@ -275,7 +275,7 @@ static char *handle_show_application(struct ast_cli_entry *e, int cmd, struct as * application at one time. You can type 'show application Dial Echo' and * you will see informations about these two applications ... */ - return ast_complete_applications(a->line, a->word, a->n); + return ast_complete_applications(a->line, a->word, -1); } if (a->argc < 4) { @@ -437,20 +437,23 @@ char *ast_complete_applications(const char *line, const char *word, int state) AST_RWLIST_RDLOCK(&apps); AST_RWLIST_TRAVERSE(&apps, app, list) { cmp = strncasecmp(word, app->name, wordlen); - if (cmp > 0) { - continue; - } - if (!cmp) { + if (cmp < 0) { + /* No more matches. */ + break; + } else if (!cmp) { /* Found match. */ - if (++which <= state) { - /* Not enough matches. */ - continue; + if (state != -1) { + if (++which <= state) { + /* Not enough matches. */ + continue; + } + ret = ast_strdup(app->name); + break; + } + if (ast_cli_completion_add(ast_strdup(app->name))) { + break; } - ret = ast_strdup(app->name); - break; } - /* Not in container. */ - break; } AST_RWLIST_UNLOCK(&apps); |