Skip to content
Snippets Groups Projects
Commit dc2ce3ce authored by Joshua Colp's avatar Joshua Colp Committed by Gerrit Code Review
Browse files

Merge "named_acl: Use ast_cli_completion_add."

parents 1a2f12e2 201762f1
No related branches found
No related tags found
No related merge requests found
...@@ -475,12 +475,10 @@ static void cli_display_named_acl_list(int fd) ...@@ -475,12 +475,10 @@ static void cli_display_named_acl_list(int fd)
/* \brief ACL command show <name> */ /* \brief ACL command show <name> */
static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) 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 length;
int which;
struct ao2_iterator i; struct ao2_iterator i;
struct named_acl *named_acl; struct named_acl *named_acl;
char *match = NULL;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
...@@ -490,23 +488,29 @@ static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ...@@ -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"; " Shows a list of named ACLs or lists all entries in a given named ACL.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
if (a->pos != 2) {
return NULL;
}
cfg = ao2_global_obj_ref(globals);
if (!cfg) { if (!cfg) {
return NULL; return NULL;
} }
length = strlen(a->word); length = strlen(a->word);
which = 0;
i = ao2_iterator_init(cfg->named_acl_list, 0); i = ao2_iterator_init(cfg->named_acl_list, 0);
while ((named_acl = ao2_iterator_next(&i))) { while ((named_acl = ao2_iterator_next(&i))) {
if (!strncasecmp(a->word, named_acl->name, length) && ++which > a->n) { if (!strncasecmp(a->word, named_acl->name, length)) {
match = ast_strdup(named_acl->name); if (ast_cli_completion_add(ast_strdup(named_acl->name))) {
ao2_ref(named_acl, -1); ao2_ref(named_acl, -1);
break; break;
}
} }
ao2_ref(named_acl, -1); ao2_ref(named_acl, -1);
} }
ao2_iterator_destroy(&i); ao2_iterator_destroy(&i);
return match; ao2_ref(cfg, -1);
return NULL;
} }
if (a->argc == 2) { if (a->argc == 2) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment