[asterisk-commits] russell: branch russell/data_retrieval r111946 - /team/russell/data_retrieval...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 29 00:43:47 CDT 2008


Author: russell
Date: Sat Mar 29 00:43:45 2008
New Revision: 111946

URL: http://svn.digium.com/view/asterisk?view=rev&rev=111946
Log:
add tab completion

Modified:
    team/russell/data_retrieval/main/data.c

Modified: team/russell/data_retrieval/main/data.c
URL: http://svn.digium.com/view/asterisk/team/russell/data_retrieval/main/data.c?view=diff&rev=111946&r1=111945&r2=111946
==============================================================================
--- team/russell/data_retrieval/main/data.c (original)
+++ team/russell/data_retrieval/main/data.c Sat Mar 29 00:43:45 2008
@@ -453,6 +453,31 @@
 		cli_print_node(a, buf, next, level);
 }
 
+static char *data_providers_complete(struct ast_cli_args *a, int req_pos)
+{
+	struct ao2_iterator i;
+	int wordlen = strlen(a->word);
+	struct ast_data_prov_holder *holder;
+	char *res = NULL;
+	int which = 0;
+
+	if (a->pos != req_pos) {
+		return NULL;
+	}
+
+	i = ao2_iterator_init(data_providers, 0);
+	while ((holder = ao2_iterator_next(&i))) {
+		if (!strncasecmp(holder->data_prov->name, a->word, wordlen) && ++which > a->n) {
+			res = ast_strdup(holder->data_prov->name);
+			ao2_ref(holder, -1);
+			holder = NULL;
+			break;
+		}
+	}
+
+	return res;
+}
+
 static char *cli_data_get(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	const char *provider_name;
@@ -469,7 +494,7 @@
 		"";
 		return NULL;
 	} else if (cmd == CLI_GENERATE) {
-		return NULL;
+		return data_providers_complete(a, 2);
 	}
 
 	if (a->argc == e->args) {




More information about the asterisk-commits mailing list