[svn-commits] mvanbaak: branch mvanbaak/cli-command-audit r102140 - /team/mvanbaak/cli-comm...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Feb 3 07:36:21 CST 2008


Author: mvanbaak
Date: Sun Feb  3 07:36:20 2008
New Revision: 102140

URL: http://svn.digium.com/view/asterisk?view=rev&rev=102140
Log:
cleanup dundi CLI commands

Modified:
    team/mvanbaak/cli-command-audit/pbx/pbx_dundi.c

Modified: team/mvanbaak/cli-command-audit/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/mvanbaak/cli-command-audit/pbx/pbx_dundi.c?view=diff&rev=102140&r1=102139&r2=102140
==============================================================================
--- team/mvanbaak/cli-command-audit/pbx/pbx_dundi.c (original)
+++ team/mvanbaak/cli-command-audit/pbx/pbx_dundi.c Sun Feb  3 07:36:20 2008
@@ -2179,42 +2179,106 @@
 	return 0;
 }
 
-static char *dundi_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *dundi_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "dundi debug";
+		e->command = "dundi [no] debug";
 		e->usage = 
-			"Usage: dundi debug\n"
-			"       Enables dumping of DUNDi packets for debugging purposes\n";
+			"Usage: dundi [no] debug\n"
+			"       Enables/Disables dumping of DUNDi packets for debugging purposes\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
 	}
-	if (a->argc != 2)
+	if (a->argc < 2 || a->argc > 3)
 		return CLI_SHOWUSAGE;
-	dundidebug = 1;
-	ast_cli(a->fd, "DUNDi Debugging Enabled\n");
+	if (a->argc == 2) {
+		dundidebug = 1;
+		ast_cli(a->fd, "DUNDi Debugging Enabled\n");
+	} else {
+		dundidebug = 0;
+		ast_cli(a->fd, "DUNDi Debugging Disabled\n");
+	}
 	return CLI_SUCCESS;
 }
 
-static char *dundi_do_store_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *dundi_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "dundi store history";
+		e->command = "dundi set debug {on|off}";
 		e->usage = 
-			"Usage: dundi store history\n"
-			"       Enables storing of DUNDi requests and times for debugging\n"
+			"Usage: dundi set debug {on|off}\n"
+			"       Enables/Disables dumping of DUNDi packets for debugging purposes\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	if (a->argc != e->args)
+		return CLI_SHOWUSAGE;
+
+	if (!strncasecmp(a->argv[e->args -1], "on", 2)) {
+		dundidebug = 1;
+		ast_cli(a->fd, "DUNDi Debugging Enabled\n");
+	} else {
+		dundidebug = 0;
+		ast_cli(a->fd, "DUNDi Debugging Disabled\n");
+	}
+	return CLI_SUCCESS;
+}
+
+static char *dundi_do_store_history_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "dundi [no] store history";
+		e->usage = 
+			"Usage: dundi [no] store history\n"
+			"       Enables/Disables storing of DUNDi requests and times for debugging\n"
 			"purposes\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
 	}
-	if (a->argc != 3)
+	if (a->argc < 3 || a->argc > 4)
 		return CLI_SHOWUSAGE;
-	global_storehistory = 1;
-	ast_cli(a->fd, "DUNDi History Storage Enabled\n");
+	
+	if (a->argc == 3) {
+		global_storehistory = 1;
+		ast_cli(a->fd, "DUNDi History Storage Enabled\n");
+	} else {
+		global_storehistory = 0;
+		ast_cli(a->fd, "DUNDi History Storage Disabled\n");
+	}
+	return CLI_SUCCESS;
+}
+
+static char *dundi_store_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "dundi store history {on|off}";
+		e->usage = 
+			"Usage: dundi store history {on|off}\n"
+			"       Enables/Disables storing of DUNDi requests and times for debugging\n"
+			"purposes\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	if (a->argc != e->args)
+		return CLI_SHOWUSAGE;
+	
+	if (!strncasecmp(a->argv[e->args -1], "on", 2)) {
+		global_storehistory = 1;
+		ast_cli(a->fd, "DUNDi History Storage Enabled\n");
+	} else {
+		global_storehistory = 0;
+		ast_cli(a->fd, "DUNDi History Storage Disabled\n");
+	}
 	return CLI_SUCCESS;
 }
 
@@ -2260,45 +2324,6 @@
 		ast_db_deltree("dundi/cache", NULL);
 		ast_cli(a->fd, "DUNDi Cache Flushed\n");
 	}
-	return CLI_SUCCESS;
-}
-
-static char *dundi_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "dundi no debug";
-		e->usage = 
-			"Usage: dundi no debug\n"
-			"       Disables dumping of DUNDi packets for debugging purposes\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-	if (a->argc != 3)
-		return CLI_SHOWUSAGE;
-	dundidebug = 0;
-	ast_cli(a->fd, "DUNDi Debugging Disabled\n");
-	return CLI_SUCCESS;
-}
-
-static char *dundi_no_store_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "dundi no store history";
-		e->usage =
-			"Usage: dundi no store history\n"
-			"       Disables storing of DUNDi requests and times for debugging\n"
-			"purposes\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-	if (a->argc != 4)
-		return CLI_SHOWUSAGE;
-	global_storehistory = 0;
-	ast_cli(a->fd, "DUNDi History Storage Disabled\n");
 	return CLI_SUCCESS;
 }
 
@@ -2817,11 +2842,11 @@
 #undef FORMAT2
 }
 
+static struct ast_cli_entry cli_dundi_do_debug_deprecated = AST_CLI_DEFINE(dundi_do_debug_deprecated, "Enable/Disable DUNDi debugging");
+static struct ast_cli_entry cli_dundi_do_store_history_deprecated = AST_CLI_DEFINE(dundi_do_store_history_deprecated, "Enable/Disable DUNDi historic records");
 static struct ast_cli_entry cli_dundi[] = {
-	AST_CLI_DEFINE(dundi_do_debug, "Enable DUNDi debugging"),
-	AST_CLI_DEFINE(dundi_no_debug, "Disable DUNDi debugging"),
-	AST_CLI_DEFINE(dundi_do_store_history, "Enable DUNDi historic records"),
-	AST_CLI_DEFINE(dundi_no_store_history, "Disable DUNDi historic records"),
+	AST_CLI_DEFINE(dundi_set_debug, "Enable/Disable DUNDi debugging", .deprecate_cmd = &cli_dundi_do_debug_deprecated),
+	AST_CLI_DEFINE(dundi_store_history, "Enable/Disable DUNDi historic records", .deprecate_cmd = &cli_dundi_do_store_history_deprecated),
 	AST_CLI_DEFINE(dundi_flush, "Flush DUNDi cache"),
 	AST_CLI_DEFINE(dundi_show_peers, "Show defined DUNDi peers"),
 	AST_CLI_DEFINE(dundi_show_trans, "Show active DUNDi transactions"),




More information about the svn-commits mailing list