[svn-commits] mmichelson: branch group/CCSS r247907 - /team/group/CCSS/main/ccss.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Feb 19 11:08:14 CST 2010


Author: mmichelson
Date: Fri Feb 19 11:08:11 2010
New Revision: 247907

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=247907
Log:
Add tab-completion for core IDs to CLI command to cancel CC.


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=247907&r1=247906&r2=247907
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Feb 19 11:08:11 2010
@@ -3978,6 +3978,29 @@
 	return 0;
 }
 
+static char *complete_core_id(const char *line, const char *word, int pos, int state)
+{
+	int which = 0;
+	int wordlen = strlen(word);
+	char *ret = NULL;
+	struct ao2_iterator core_iter = ao2_iterator_init(cc_core_instances, 0);
+	struct cc_core_instance *core_instance;
+
+	for (; (core_instance = ao2_iterator_next(&core_iter)); cc_unref(core_instance,
+				"CLI tab completion iteration")) {
+		char core_id_str[20];
+		snprintf(core_id_str, sizeof(core_id_str), "%d", core_instance->core_id);
+		if (!strncmp(word, core_id_str, wordlen) && ++which > state) {
+			ret = ast_strdup(core_id_str);
+			cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
+			break;
+		}
+	}
+	ao2_iterator_destroy(&core_iter);
+
+	return ret;
+}
+
 static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	static const char * const option[] = { "core", "all", NULL };
@@ -3995,6 +4018,9 @@
 		if (a->pos == 2) {
 			return ast_cli_complete(a->word, option, a->n);
 		}
+		if (a->pos == 3) {
+			return complete_core_id(a->line, a->word, a->pos, a->n);
+		}
 		return NULL;
 	}
 




More information about the svn-commits mailing list