[asterisk-commits] mmichelson: branch mmichelson/queue-reset r166955 - /team/mmichelson/queue-re...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 31 13:35:58 CST 2008


Author: mmichelson
Date: Wed Dec 31 13:35:58 2008
New Revision: 166955

URL: http://svn.digium.com/view/asterisk?view=rev&rev=166955
Log:
More changes to the tab completion code for reloading queues

This is really close, but the problem is that I can still tab-
complete multiple queue names in a single command.

I also fixed an off-by-one error in the queue reload CLI handler
which I discovered while testing


Modified:
    team/mmichelson/queue-reset/apps/app_queue.c

Modified: team/mmichelson/queue-reset/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_queue.c?view=diff&rev=166955&r1=166954&r2=166955
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Wed Dec 31 13:35:58 2008
@@ -6727,22 +6727,36 @@
 	int wordlen;
 	int which = 0;
 	static int localstate = 0;
+	int rules = strstr(line, "rules") != NULL;
+	int stats = strstr(line, "stats") != NULL;
+	int parameters = strstr(line, "parameters") != NULL;
+	int members = strstr(line, "members") != NULL;
+
+	if (pos > 7) {
+		return NULL;
+	}
 
 	if (ast_strlen_zero(word)) {
 		switch (state) {
 			case 0:
-				return ast_strdup("rules");
+				if (!rules)
+					return ast_strdup("rules");
 			case 1:
-				return ast_strdup("stats");
+				if (!stats)
+					return ast_strdup("stats");
 			case 2:
-				return ast_strdup("parameters");
+				if (!parameters)
+					return ast_strdup("parameters");
 			case 3:
-				return ast_strdup("members");
-			case 4:
+				if (!members)
+					return ast_strdup("members");
+			default:
 				{
-					char *ret = complete_queue(line, word, pos, localstate);
+					char *ret = complete_queue(line, word, pos, localstate++);
 					if (!ret) {
 						localstate = 0;
+					} else if (strstr(line, ret)) {
+						ret = NULL;
 					}
 					return ret;
 				}
@@ -6751,18 +6765,20 @@
 
 	wordlen = strlen(word);
 
-	if (!strncasecmp(word, "rules", wordlen) && (++which > state)) {
+	if (!rules && !strncasecmp(word, "rules", wordlen) && (++which > state)) {
 		return ast_strdup("rules");
-	} else if (!strncasecmp(word, "stats", wordlen) && (++which > state)) {
+	} else if (!stats && !strncasecmp(word, "stats", wordlen) && (++which > state)) {
 		return ast_strdup("stats");
-	} else if (!strncasecmp(word, "parameters", wordlen) && (++which > state)) {
+	} else if (!parameters && !strncasecmp(word, "parameters", wordlen) && (++which > state)) {
 		return ast_strdup("parameters");
-	} else if (!strncasecmp(word, "members", wordlen) && (++which > state)) {
+	} else if (!members && !strncasecmp(word, "members", wordlen) && (++which > state)) {
 		return ast_strdup("members");
 	} else {
 		char *ret = complete_queue(line, word, pos, localstate++);
 		if (!ret) {
 			localstate = 0;
+		} else if (strstr(line, ret)) {
+			return NULL;
 		}
 		return ret;
 	}
@@ -6801,7 +6817,7 @@
 			return complete_queue_reload(a->line, a->word, a->pos, a->n);
 	}
 
-	if (a->argc < 2 || a->argc > 6)
+	if (a->argc < 2 || a->argc > 7)
 		return CLI_SHOWUSAGE;
 
 	if (a->argc == 2) {




More information about the asterisk-commits mailing list