[svn-commits] rmudgett: branch rmudgett/ast_verb r405159 - /team/rmudgett/ast_verb/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jan 8 20:56:52 CST 2014


Author: rmudgett
Date: Wed Jan  8 20:56:47 2014
New Revision: 405159

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405159
Log:
* Change "core set verbose" to take a silent option.  Previous released
versions had non-functional verbose module level boost support code that
is now the silent option.  If rasterisk now connects to a previous version
it will try to set the verbose option silently.  However, it winds up
being a non-silent noop that boosts the verbosity on a non-existent silent
module.

* Tighten up "core set debug" tab completion.

Modified:
    team/rmudgett/ast_verb/main/asterisk.c
    team/rmudgett/ast_verb/main/cli.c

Modified: team/rmudgett/ast_verb/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ast_verb/main/asterisk.c?view=diff&rev=405159&r1=405158&r2=405159
==============================================================================
--- team/rmudgett/ast_verb/main/asterisk.c (original)
+++ team/rmudgett/ast_verb/main/asterisk.c Wed Jan  8 20:56:47 2014
@@ -2138,16 +2138,13 @@
 			} else {
 				int verbose_new;
 				int atleast;
-				int is_silent;
 
 				atleast = 8;
 				if (strncasecmp(shrunk + 17, "atleast ", atleast)) {
 					atleast = 0;
 				}
 
-				is_silent = (tolower(shrunk[17 + atleast]) == 's') ? 1 : 0;
-
-				if (sscanf(shrunk + 17 + atleast + is_silent, "%30d", &verbose_new) == 1) {
+				if (sscanf(shrunk + 17 + atleast, "%30d", &verbose_new) == 1) {
 					if (!atleast || ast_verb_console_get() < verbose_new) {
 						ast_verb_console_set(verbose_new);
 					}
@@ -2484,12 +2481,7 @@
 	 * initially desired.
 	 */
 	if (option_verbose) {
-		/*
-		 * The 's' prefixed to the level indicates to silence
-		 * the confirmation message.  Older Asterisk versions
-		 * will generate an error and not set the level.
-		 */
-		snprintf(buf, sizeof(buf), "core set verbose s%d", option_verbose);
+		snprintf(buf, sizeof(buf), "core set verbose %d silent", option_verbose);
 		fdsend(ast_consock, buf);
 	}
 

Modified: team/rmudgett/ast_verb/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ast_verb/main/cli.c?view=diff&rev=405159&r1=405158&r2=405159
==============================================================================
--- team/rmudgett/ast_verb/main/cli.c (original)
+++ team/rmudgett/ast_verb/main/cli.c Wed Jan  8 20:56:47 2014
@@ -440,7 +440,10 @@
 		return NULL;
 
 	case CLI_GENERATE:
-		if (a->pos == 3 || (a->pos == 4 && !strcasecmp(a->argv[3], "atleast"))) {
+		if (!strcasecmp(argv3, "atleast")) {
+			atleast = 1;
+		}
+		if (a->pos == 3 || (a->pos == 4 && atleast)) {
 			const char *pos = a->pos == 3 ? argv3 : S_OR(a->argv[4], "");
 			int numbermatch = (ast_strlen_zero(pos) || strchr("123456789", pos[0])) ? 0 : 21;
 
@@ -449,8 +452,6 @@
 			} else if (pos[0] == '0') {
 				if (a->n == 0) {
 					return ast_strdup("0");
-				} else {
-					return NULL;
 				}
 			} else if (a->n == (21 - numbermatch)) {
 				if (a->pos == 3 && !strncasecmp(argv3, "off", strlen(argv3))) {
@@ -462,8 +463,11 @@
 				return ast_strdup("atleast");
 			}
 #if !defined(LOW_MEMORY)
-		} else if (a->pos == 4 || (a->pos == 5 && !strcasecmp(argv3, "atleast"))) {
-			return ast_complete_source_filename(a->pos == 4 ? S_OR(a->argv[4], "") : S_OR(a->argv[5], ""), a->n);
+		} else if ((a->pos == 4 && !atleast && strcasecmp(argv3, "off"))
+			|| (a->pos == 5 && atleast)) {
+			const char *pos = S_OR(a->argv[a->pos], "");
+
+			return ast_complete_source_filename(pos, a->n);
 #endif
 		}
 		return NULL;
@@ -575,14 +579,14 @@
 	int oldval;
 	int newlevel;
 	int atleast = 0;
-	int is_silent = 0;
+	int silent = 0;
 	const char *argv3 = a->argv ? S_OR(a->argv[3], "") : "";
 
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = "core set verbose";
 		e->usage =
-			"Usage: core set verbose [atleast] <level>\n"
+			"Usage: core set verbose [atleast] <level> [silent]\n"
 			"       core set verbose off\n"
 			"\n"
 			"       Sets level of verbose messages to be displayed.\n"
@@ -591,7 +595,10 @@
 		return NULL;
 
 	case CLI_GENERATE:
-		if (a->pos == 3 || (a->pos == 4 && !strcasecmp(a->argv[3], "atleast"))) {
+		if (!strcasecmp(argv3, "atleast")) {
+			atleast = 1;
+		}
+		if (a->pos == 3 || (a->pos == 4 && atleast)) {
 			const char *pos = a->pos == 3 ? argv3 : S_OR(a->argv[4], "");
 			int numbermatch = (ast_strlen_zero(pos) || strchr("123456789", pos[0])) ? 0 : 21;
 
@@ -600,8 +607,6 @@
 			} else if (pos[0] == '0') {
 				if (a->n == 0) {
 					return ast_strdup("0");
-				} else {
-					return NULL;
 				}
 			} else if (a->n == (21 - numbermatch)) {
 				if (a->pos == 3 && !strncasecmp(argv3, "off", strlen(argv3))) {
@@ -612,6 +617,13 @@
 			} else if (a->n == (22 - numbermatch) && a->pos == 3 && ast_strlen_zero(argv3)) {
 				return ast_strdup("atleast");
 			}
+		} else if ((a->pos == 4 && !atleast && strcasecmp(argv3, "off"))
+			|| (a->pos == 5 && atleast)) {
+			const char *pos = S_OR(a->argv[a->pos], "");
+
+			if (a->n == 0 && !strncasecmp(pos, "silent", strlen(pos))) {
+				return ast_strdup("silent");
+			}
 		}
 		return NULL;
 	}
@@ -629,19 +641,14 @@
 		if (!strcasecmp(a->argv[e->args], "atleast")) {
 			atleast = 1;
 		}
-		if (a->argc != e->args + atleast + 1) {
+		if (a->argc == e->args + atleast + 2
+			&& !strcasecmp(a->argv[e->args + atleast + 1], "silent")) {
+			silent = 1;
+		}
+		if (a->argc != e->args + atleast + silent + 1) {
 			return CLI_SHOWUSAGE;
 		}
-
-		/*
-		 * If the <level> is prefixed with a 's' then we want to
-		 * set the new level silently.
-		 */
-		if (tolower(a->argv[e->args + atleast][0]) == 's') {
-			is_silent = 1;
-		}
-
-		if (sscanf(a->argv[e->args + atleast] + is_silent, "%30d", &newlevel) != 1) {
+		if (sscanf(a->argv[e->args + atleast], "%30d", &newlevel) != 1) {
 			return CLI_SHOWUSAGE;
 		}
 	}
@@ -654,7 +661,7 @@
 		newlevel = oldval;
 	}
 
-	if (is_silent) {
+	if (silent) {
 		/* Be silent after setting the level. */
 		return CLI_SUCCESS;
 	}




More information about the svn-commits mailing list