summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2018-03-17 02:39:41 -0400
committerCorey Farrell <git@cfware.com>2018-03-19 17:49:00 -0400
commit201762f16176f6559a61eacf4b11a3d3babae7b9 (patch)
tree2771ce7bdc89b0196356936ceb40c16b8d0ffd85
parent5843a197979d10b336a041c6cb8bef90dfa0484a (diff)
named_acl: Use ast_cli_completion_add.
Change-Id: I317a82de976bbdbfe4352c243e32a7bb8f66c377
-rw-r--r--main/named_acl.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/main/named_acl.c b/main/named_acl.c
index 4f2069a75..c4628216f 100644
--- a/main/named_acl.c
+++ b/main/named_acl.c
@@ -475,12 +475,10 @@ static void cli_display_named_acl_list(int fd)
/* \brief ACL command show <name> */
static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+ struct named_acl_config *cfg;
int length;
- int which;
struct ao2_iterator i;
struct named_acl *named_acl;
- char *match = NULL;
switch (cmd) {
case CLI_INIT:
@@ -490,23 +488,29 @@ static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct
" Shows a list of named ACLs or lists all entries in a given named ACL.\n";
return NULL;
case CLI_GENERATE:
+ if (a->pos != 2) {
+ return NULL;
+ }
+
+ cfg = ao2_global_obj_ref(globals);
if (!cfg) {
return NULL;
}
length = strlen(a->word);
- which = 0;
i = ao2_iterator_init(cfg->named_acl_list, 0);
while ((named_acl = ao2_iterator_next(&i))) {
- if (!strncasecmp(a->word, named_acl->name, length) && ++which > a->n) {
- match = ast_strdup(named_acl->name);
- ao2_ref(named_acl, -1);
- break;
+ if (!strncasecmp(a->word, named_acl->name, length)) {
+ if (ast_cli_completion_add(ast_strdup(named_acl->name))) {
+ ao2_ref(named_acl, -1);
+ break;
+ }
}
ao2_ref(named_acl, -1);
}
ao2_iterator_destroy(&i);
- return match;
+ ao2_ref(cfg, -1);
+ return NULL;
}
if (a->argc == 2) {