[Asterisk-code-review] named acl: Use ast cli completion add. (asterisk[13])
Jenkins2
asteriskteam at digium.com
Tue Mar 20 09:37:17 CDT 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8595 )
Change subject: named_acl: Use ast_cli_completion_add.
......................................................................
named_acl: Use ast_cli_completion_add.
Change-Id: I317a82de976bbdbfe4352c243e32a7bb8f66c377
---
M main/named_acl.c
1 file changed, 13 insertions(+), 9 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/named_acl.c b/main/named_acl.c
index 9ea8990..826313d 100644
--- a/main/named_acl.c
+++ b/main/named_acl.c
@@ -502,12 +502,10 @@
/* \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:
@@ -517,23 +515,29 @@
" 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) {
--
To view, visit https://gerrit.asterisk.org/8595
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I317a82de976bbdbfe4352c243e32a7bb8f66c377
Gerrit-Change-Number: 8595
Gerrit-PatchSet: 2
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180320/8790cb0c/attachment.html>
More information about the asterisk-code-review
mailing list