[asterisk-commits] russell: branch 11 r377340 - /branches/11/main/named_acl.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 6 11:28:40 CST 2012


Author: russell
Date: Thu Dec  6 11:28:35 2012
New Revision: 377340

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377340
Log:
Add CLI tab completion to 'acl show'.

The 'acl show' CLI command allows you to show the details about a specific
named ACL in acl.conf.  This patch adds tab completion to the command.

Review: https://reviewboard.asterisk.org/r/2230/


Modified:
    branches/11/main/named_acl.c

Modified: branches/11/main/named_acl.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/named_acl.c?view=diff&rev=377340&r1=377339&r2=377340
==============================================================================
--- branches/11/main/named_acl.c (original)
+++ branches/11/main/named_acl.c Thu Dec  6 11:28:35 2012
@@ -503,6 +503,13 @@
 /* \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);
+	int length;
+	int which;
+	struct ao2_iterator i;
+	struct named_acl *named_acl;
+	char *match = NULL;
+
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = "acl show";
@@ -511,7 +518,23 @@
 			"   Shows a list of named ACLs or lists all entries in a given named ACL.\n";
 		return NULL;
 	case CLI_GENERATE:
-		return NULL;
+		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;
+			}
+			ao2_ref(named_acl, -1);
+		}
+		ao2_iterator_destroy(&i);
+		return match;
+
 	}
 
 	if (a->argc == 2) {




More information about the asterisk-commits mailing list