[svn-commits] tilghman: branch 1.4 r47436 - in /branches/1.4: channels/ main/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Nov 10 09:51:59 MST 2006


Author: tilghman
Date: Fri Nov 10 10:51:55 2006
New Revision: 47436

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47436
Log:
Discussion of these CLI changes resulted in more consistency (Bug 8236)

Modified:
    branches/1.4/channels/chan_h323.c
    branches/1.4/channels/chan_iax2.c
    branches/1.4/channels/chan_mgcp.c
    branches/1.4/channels/chan_sip.c
    branches/1.4/channels/chan_skinny.c
    branches/1.4/main/cli.c

Modified: branches/1.4/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_h323.c?view=diff&rev=47436&r1=47435&r2=47436
==============================================================================
--- branches/1.4/channels/chan_h323.c (original)
+++ branches/1.4/channels/chan_h323.c Fri Nov 10 10:51:55 2006
@@ -2533,17 +2533,17 @@
 
 static int h323_do_trace(int fd, int argc, char *argv[])
 {
-	if (argc != 3) {
+	if (argc != 4) {
 		return RESULT_SHOWUSAGE;
 	}
-	h323_debug(1, atoi(argv[2]));
+	h323_debug(1, atoi(argv[3]));
 	ast_cli(fd, "H.323 trace set to level %s\n", argv[2]);
 	return RESULT_SUCCESS;
 }
 
 static int h323_no_trace(int fd, int argc, char *argv[])
 {
-	if (argc != 3) {
+	if (argc < 3 || argc > 4) {
 		return RESULT_SHOWUSAGE;
 	}
 	h323_debug(0,0);
@@ -2553,7 +2553,7 @@
 
 static int h323_do_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 2) {
+	if (argc < 2 || argc > 3) {
 		return RESULT_SHOWUSAGE;
 	}
 	h323debug = 1;
@@ -2563,7 +2563,7 @@
 
 static int h323_no_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 3) {
+	if (argc < 3 || argc > 4) {
 		return RESULT_SHOWUSAGE;
 	}
 	h323debug = 0;
@@ -2642,43 +2642,58 @@
 "       Reloads H.323 configuration from h323.conf\n";
 
 static struct ast_cli_entry cli_h323_no_trace_deprecated = {
-	{ { "h.323", "no", "trace", NULL },
+	{ "h.323", "no", "trace", NULL },
 	  h323_no_trace, "Disable H.323 Stack Tracing",
 	  no_trace_usage };
 };
 
 static struct ast_cli_entry cli_h323_no_debug_deprecated = {
-	{ { "h.323", "no", "debug", NULL },
+	{ "h.323", "no", "debug", NULL },
 	  h323_no_debug, "Disable H.323 debug",
 	  no_debug_usage };
 };
 
+static struct ast_cli_entry cli_h323_debug_deprecated = {
+	{ "h.323", "debug", NULL },
+	h323_do_debug, "Enable H.323 debug",
+	debug_usage };
+
+static struct ast_cli_entry cli_h323_trace_deprecated = {
+	{ "h.323", "trace", NULL },
+	h323_do_trace, "Enable H.323 Stack Tracing",
+	trace_usage };
+
+static struct ast_cli_entry cli_h323_gk_cycle_deprecated = {
+	{ "h323", "cycle", "gk", NULL },
+	h323_gk_cycle, "Manually re-register with the Gatekeper",
+	show_cycle_usage };
+
 static struct ast_cli_entry cli_h323[] = {
-	{ { "h.323", "trace", NULL },
+	{ { "h323", "set", "trace", NULL },
 	h323_do_trace, "Enable H.323 Stack Tracing",
-	trace_usage },
-
-	{ { "h.323", "trace", "off", NULL },
+	trace_usage, NULL, cli_h323_trace_deprecated },
+
+	{ { "h323", "set", "trace", "off", NULL },
 	h323_no_trace, "Disable H.323 Stack Tracing",
 	no_trace_usage, NULL, cli_h323_no_trace_deprecated },
 
-	{ { "h.323", "debug", NULL },
+	{ { "h323", "set", "debug", NULL },
 	h323_do_debug, "Enable H.323 debug",
-	debug_usage },
-
-	{ { "h.323", "debug", "off", NULL },
+	debug_usage, NULL, cli_h323_debug_deprecated },
+
+	{ { "h323", "set", "debug", "off", NULL },
 	h323_no_debug, "Disable H.323 debug",
 	no_debug_usage, NULL, cli_h323_no_debug_deprecated },
 
-	{ { "h.323", "gk", "cycle", NULL },
+	{ { "h323", "cycle", "gk", NULL },
 	h323_gk_cycle, "Manually re-register with the Gatekeper",
-	show_cycle_usage },
-
-	{ { "h.323", "hangup", NULL },
+	show_cycle_usage, NULL, cli_h323_gk_cycle_deprecated },
+
+	{ { "h323", "hangup", NULL },
 	h323_ep_hangup, "Manually try to hang up a call",
 	show_hangup_usage },
 
-	{ { "h.323", "show", "tokens", NULL },
+	{ { "h323", "show", "tokens", NULL },
 	h323_tokens_show, "Show all active call tokens",
 	show_tokens_usage },
 };

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=47436&r1=47435&r2=47436
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Fri Nov 10 10:51:55 2006
@@ -4397,7 +4397,7 @@
 
 static int iax2_do_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 2)
+	if (argc < 2 || argc > 3)
 		return RESULT_SHOWUSAGE;
 	iaxdebug = 1;
 	ast_cli(fd, "IAX2 Debugging Enabled\n");
@@ -4406,7 +4406,7 @@
 
 static int iax2_do_trunk_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 3)
+	if (argc < 3 || argc > 4)
 		return RESULT_SHOWUSAGE;
 	iaxtrunkdebug = 1;
 	ast_cli(fd, "IAX2 Trunk Debug Requested\n");
@@ -4415,7 +4415,7 @@
 
 static int iax2_do_jb_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 3)
+	if (argc < 3 || argc > 4)
 		return RESULT_SHOWUSAGE;
 	jb_setoutput(jb_error_output, jb_warning_output, jb_debug_output);
 	ast_cli(fd, "IAX2 Jitterbuffer Debugging Enabled\n");
@@ -4424,7 +4424,7 @@
 
 static int iax2_no_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 3)
+	if (argc < 3 || argc > 4)
 		return RESULT_SHOWUSAGE;
 	iaxdebug = 0;
 	ast_cli(fd, "IAX2 Debugging Disabled\n");
@@ -4433,7 +4433,7 @@
 
 static int iax2_no_trunk_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 4)
+	if (argc < 4 || argc > 5)
 		return RESULT_SHOWUSAGE;
 	iaxtrunkdebug = 0;
 	ast_cli(fd, "IAX2 Trunk Debugging Disabled\n");
@@ -4442,7 +4442,7 @@
 
 static int iax2_no_jb_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 4)
+	if (argc < 4 || argc > 5)
 		return RESULT_SHOWUSAGE;
 	jb_setoutput(jb_error_output, jb_warning_output, NULL);
 	jb_debug_output("\n");
@@ -9663,27 +9663,27 @@
 "       Lists all registration requests and status.\n";
 
 static char debug_usage[] = 
-"Usage: iax2 debug\n"
+"Usage: iax2 set debug\n"
 "       Enables dumping of IAX packets for debugging purposes\n";
 
 static char no_debug_usage[] = 
-"Usage: iax2 nodebug\n"
+"Usage: iax2 set debug off\n"
 "       Disables dumping of IAX packets for debugging purposes\n";
 
 static char debug_trunk_usage[] =
-"Usage: iax2 debug trunk\n"
+"Usage: iax2 set debug trunk\n"
 "       Requests current status of IAX trunking\n";
 
 static char no_debug_trunk_usage[] =
-"Usage: iax2 nodebug trunk\n"
+"Usage: iax2 set debug trunk off\n"
 "       Requests current status of IAX trunking\n";
 
 static char debug_jb_usage[] =
-"Usage: iax2 debug jb\n"
+"Usage: iax2 set debug jb\n"
 "       Enables jitterbuffer debugging information\n";
 
 static char no_debug_jb_usage[] =
-"Usage: iax2 nodebug jb\n"
+"Usage: iax2 set debug jb off\n"
 "       Disables jitterbuffer debugging information\n";
 
 static char iax2_test_losspct_usage[] =
@@ -9822,27 +9822,27 @@
 	iax2_show_peer, "Show details on specific IAX peer",
 	show_peer_usage, complete_iax2_show_peer },
 
-	{ { "iax2", "debug", NULL },
+	{ { "iax2", "set", "debug", NULL },
 	iax2_do_debug, "Enable IAX debugging",
 	debug_usage },
 
-	{ { "iax2", "debug", "trunk", NULL },
+	{ { "iax2", "set", "debug", "trunk", NULL },
 	iax2_do_trunk_debug, "Enable IAX trunk debugging",
 	debug_trunk_usage, NULL, &cli_iax2_trunk_debug_deprecated },
 
-	{ { "iax2", "debug", "jb", NULL },
+	{ { "iax2", "set", "debug", "jb", NULL },
 	iax2_do_jb_debug, "Enable IAX jitterbuffer debugging",
 	debug_jb_usage, NULL, &cli_iax2_jb_debug_deprecated },
 
-	{ { "iax2", "debug", "off", NULL },
+	{ { "iax2", "set", "debug", "off", NULL },
 	iax2_no_debug, "Disable IAX debugging",
 	no_debug_usage, NULL, &cli_iax2_no_debug_deprecated },
 
-	{ { "iax2", "debug", "trunk", "off", NULL },
+	{ { "iax2", "set", "debug", "trunk", "off", NULL },
 	iax2_no_trunk_debug, "Disable IAX trunk debugging",
 	no_debug_trunk_usage, NULL, &cli_iax2_no_trunk_debug_deprecated },
 
-	{ { "iax2", "debug", "jb", "off", NULL },
+	{ { "iax2", "set", "debug", "jb", "off", NULL },
 	iax2_no_jb_debug, "Disable IAX jitterbuffer debugging",
 	no_debug_jb_usage, NULL, &cli_iax2_no_jb_debug_deprecated },
 

Modified: branches/1.4/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_mgcp.c?view=diff&rev=47436&r1=47435&r2=47436
==============================================================================
--- branches/1.4/channels/chan_mgcp.c (original)
+++ branches/1.4/channels/chan_mgcp.c Fri Nov 10 10:51:55 2006
@@ -1049,11 +1049,11 @@
 "       mgcp debug MUST be on to see the results of this command.\n";
 
 static char debug_usage[] = 
-"Usage: mgcp debug\n"
+"Usage: mgcp set debug\n"
 "       Enables dumping of MGCP packets for debugging purposes\n";
 
 static char no_debug_usage[] = 
-"Usage: mgcp debug off\n"
+"Usage: mgcp set debug off\n"
 "       Disables dumping of MGCP packets for debugging purposes\n";
 
 static char mgcp_reload_usage[] =
@@ -1116,7 +1116,7 @@
 
 static int mgcp_do_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 2)
+	if (argc != 3)
 		return RESULT_SHOWUSAGE;
 	mgcpdebug = 1;
 	ast_cli(fd, "MGCP Debugging Enabled\n");
@@ -1125,7 +1125,7 @@
 
 static int mgcp_no_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 3)
+	if (argc != 4)
 		return RESULT_SHOWUSAGE;
 	mgcpdebug = 0;
 	ast_cli(fd, "MGCP Debugging Disabled\n");
@@ -1141,11 +1141,11 @@
 	mgcp_show_endpoints, "List defined MGCP endpoints",
 	show_endpoints_usage },
 
-	{ { "mgcp", "debug", NULL },
+	{ { "mgcp", "set", "debug", NULL },
 	mgcp_do_debug, "Enable MGCP debugging",
 	debug_usage },
 
-	{ { "mgcp", "debug", "off", NULL },
+	{ { "mgcp", "set", "debug", "off", NULL },
 	mgcp_no_debug, "Disable MGCP debugging",
 	no_debug_usage },
 

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=47436&r1=47435&r2=47436
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Fri Nov 10 10:51:55 2006
@@ -10644,9 +10644,10 @@
 	int port = 0;
 	char *p, *arg;
 
-	if (argc != 4)
+	/* sip set debug ip <ip> */
+	if (argc != 5)
 		return RESULT_SHOWUSAGE;
-	p = arg = argv[3];
+	p = arg = argv[4];
 	strsep(&p, ":");
 	if (p)
 		port = atoi(p);
@@ -10671,9 +10672,9 @@
 static int sip_do_debug_peer(int fd, int argc, char *argv[])
 {
 	struct sip_peer *peer;
-	if (argc != 4)
+	if (argc != 5)
 		return RESULT_SHOWUSAGE;
-	peer = find_peer(argv[3], NULL, 1);
+	peer = find_peer(argv[4], NULL, 1);
 	if (peer) {
 		if (peer->addr.sin_addr.s_addr) {
 			debugaddr.sin_family = AF_INET;
@@ -10682,10 +10683,10 @@
 			ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(debugaddr.sin_addr), ntohs(debugaddr.sin_port));
 			ast_set_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE);
 		} else
-			ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[3]);
+			ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[4]);
 		ASTOBJ_UNREF(peer,sip_destroy_peer);
 	} else
-		ast_cli(fd, "No such peer '%s'\n", argv[3]);
+		ast_cli(fd, "No such peer '%s'\n", argv[4]);
 	return RESULT_SUCCESS;
 }
 
@@ -10693,12 +10694,12 @@
 static int sip_do_debug(int fd, int argc, char *argv[])
 {
 	int oldsipdebug = sipdebug_console;
-	if (argc != 2) {
-		if (argc != 4) 
+	if (argc != 4) {
+		if (argc != 5) 
 			return RESULT_SHOWUSAGE;
-		else if (strcmp(argv[2], "ip") == 0)
+		else if (strcmp(argv[3], "ip") == 0)
 			return sip_do_debug_ip(fd, argc, argv);
-		else if (strcmp(argv[2], "peer") == 0)
+		else if (strcmp(argv[3], "peer") == 0)
 			return sip_do_debug_peer(fd, argc, argv);
 		else
 			return RESULT_SHOWUSAGE;
@@ -10768,7 +10769,7 @@
 /*! \brief Disable SIP Debugging in CLI */
 static int sip_no_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 3)
+	if (argc != 4)
 		return RESULT_SHOWUSAGE;
 	ast_clear_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE);
 	ast_cli(fd, "SIP Debugging Disabled\n");
@@ -11064,8 +11065,7 @@
 
 static char sip_reload_usage[] =
 "Usage: sip reload\n"
-"       Reloads SIP configuration from sip.conf\n"
-"       Deprecated:  please use 'reload chan_sip.so'\n";
+"       Reloads SIP configuration from sip.conf\n";
 
 static char show_subscriptions_usage[] =
 "Usage: sip show subscriptions\n" 
@@ -16784,12 +16784,6 @@
 /*! \brief Force reload of module from cli */
 static int sip_reload(int fd, int argc, char *argv[])
 {
-	static int deprecated = 0;
-	if (!deprecated && argc > 0) {
-		ast_log(LOG_WARNING, "\"sip reload\" is deprecated.  Please use 'reload chan_sip.so' instead.\n");
-		deprecated = 1;
-	}
-
 	ast_mutex_lock(&sip_reload_lock);
 	if (sip_reloading) 
 		ast_verbose("Previous SIP reload not yet done\n");
@@ -16881,19 +16875,19 @@
 	sip_prune_realtime, "Prune cached Realtime user(s)",
 	prune_realtime_usage, complete_sip_prune_realtime_user },
 
-	{ { "sip", "debug", NULL },
+	{ { "sip", "set", "debug", NULL },
 	sip_do_debug, "Enable SIP debugging",
 	debug_usage },
 
-	{ { "sip", "debug", "ip", NULL },
+	{ { "sip", "set", "debug", "ip", NULL },
 	sip_do_debug, "Enable SIP debugging on IP",
 	debug_usage },
 
-	{ { "sip", "debug", "peer", NULL },
+	{ { "sip", "set", "debug", "peer", NULL },
 	sip_do_debug, "Enable SIP debugging on Peername",
 	debug_usage, complete_sip_debug_peer },
 
-	{ { "sip", "debug", "off", NULL },
+	{ { "sip", "set", "debug", "off", NULL },
 	sip_no_debug, "Disable SIP debugging",
 	no_debug_usage },
 

Modified: branches/1.4/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_skinny.c?view=diff&rev=47436&r1=47435&r2=47436
==============================================================================
--- branches/1.4/channels/chan_skinny.c (original)
+++ branches/1.4/channels/chan_skinny.c Fri Nov 10 10:51:55 2006
@@ -1753,7 +1753,7 @@
 
 static int skinny_do_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 2) {
+	if (argc != 3) {
 		return RESULT_SHOWUSAGE;
 	}
 	skinnydebug = 1;
@@ -1763,7 +1763,7 @@
 
 static int skinny_no_debug(int fd, int argc, char *argv[])
 {
-	if (argc != 3) {
+	if (argc != 4) {
 		return RESULT_SHOWUSAGE;
 	}
 	skinnydebug = 0;
@@ -1960,11 +1960,11 @@
 "       Lists all lines known to the Skinny subsystem.\n";
 
 static char debug_usage[] =
-"Usage: skinny debug\n"
+"Usage: skinny set debug\n"
 "       Enables dumping of Skinny packets for debugging purposes\n";
 
 static char no_debug_usage[] =
-"Usage: skinny no debug\n"
+"Usage: skinny set debug off\n"
 "       Disables dumping of Skinny packets for debugging purposes\n";
 
 static char reset_usage[] =
@@ -1980,11 +1980,11 @@
 	skinny_show_lines, "List defined Skinny lines per device",
 	show_lines_usage },
 
-	{ { "skinny", "debug", NULL },
+	{ { "skinny", "set", "debug", NULL },
 	skinny_do_debug, "Enable Skinny debugging",
 	debug_usage },
 
-	{ { "skinny", "debug", "off", NULL },
+	{ { "skinny", "set", "debug", "off", NULL },
 	skinny_no_debug, "Disable Skinny debugging",
 	no_debug_usage },
 

Modified: branches/1.4/main/cli.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/cli.c?view=diff&rev=47436&r1=47435&r2=47436
==============================================================================
--- branches/1.4/main/cli.c (original)
+++ branches/1.4/main/cli.c Fri Nov 10 10:51:55 2006
@@ -76,11 +76,11 @@
 static AST_LIST_HEAD_STATIC(helpers, ast_cli_entry);
 
 static char load_help[] = 
-"Usage: load <module name>\n"
+"Usage: module load <module name>\n"
 "       Loads the specified module into Asterisk.\n";
 
 static char unload_help[] = 
-"Usage: unload [-f|-h] <module name>\n"
+"Usage: module unload [-f|-h] <module name>\n"
 "       Unloads the specified module from Asterisk. The -f\n"
 "       option causes the module to be unloaded even if it is\n"
 "       in use (may cause a crash) and the -h module causes the\n"
@@ -101,7 +101,7 @@
 "       more and longer fields.\n";
 
 static char reload_help[] = 
-"Usage: reload [module ...]\n"
+"Usage: module reload [module ...]\n"
 "       Reloads configuration files for all listed modules which support\n"
 "       reloading, or for all supported modules if none are listed.\n";
 
@@ -119,7 +119,7 @@
 "       limited to just that file.\n";
 
 static char nodebug_help[] = 
-"Usage: core set no debug\n"
+"Usage: core set debug off\n"
 "       Turns off core debug messages.\n";
 
 static char logger_mute_help[] = 
@@ -138,7 +138,7 @@
 "       Optional regular expression pattern is matched to group names for each\n"
 "       channel.\n";
 
-static int handle_load(int fd, int argc, char *argv[])
+static int handle_load_deprecated(int fd, int argc, char *argv[])
 {
 	if (argc != 2)
 		return RESULT_SHOWUSAGE;
@@ -149,14 +149,48 @@
 	return RESULT_SUCCESS;
 }
 
-static int handle_reload(int fd, int argc, char *argv[])
+static int handle_load(int fd, int argc, char *argv[])
+{
+	if (argc != 3)
+		return RESULT_SHOWUSAGE;
+	if (ast_load_resource(argv[2])) {
+		ast_cli(fd, "Unable to load module %s\n", argv[2]);
+		return RESULT_FAILURE;
+	}
+	return RESULT_SUCCESS;
+}
+
+static int handle_reload_deprecated(int fd, int argc, char *argv[])
 {
 	int x;
 	int res;
 	if (argc < 1)
 		return RESULT_SHOWUSAGE;
 	if (argc > 1) { 
-		for (x=1;x<argc;x++) {
+		for (x = 1; x < argc; x++) {
+			res = ast_module_reload(argv[x]);
+			switch(res) {
+			case 0:
+				ast_cli(fd, "No such module '%s'\n", argv[x]);
+				break;
+			case 1:
+				ast_cli(fd, "Module '%s' does not support reload\n", argv[x]);
+				break;
+			}
+		}
+	} else
+		ast_module_reload(NULL);
+	return RESULT_SUCCESS;
+}
+
+static int handle_reload(int fd, int argc, char *argv[])
+{
+	int x;
+	int res;
+	if (argc < 2)
+		return RESULT_SHOWUSAGE;
+	if (argc > 2) { 
+		for (x = 2; x < argc; x++) {
 			res = ast_module_reload(argv[x]);
 			switch(res) {
 			case 0:
@@ -263,13 +297,18 @@
 	return RESULT_SUCCESS;
 }
 
-static int handle_debug(int fd, int argc, char *argv[])
+static int handle_set_debug(int fd, int argc, char *argv[])
 {
 	int oldval = option_debug;
 	int newlevel;
 	int atleast = 0;
 	char *filename = '\0';
 
+	/* 'core set debug <level>'
+	 * 'core set debug <level> <fn>'
+	 * 'core set debug atleast <level>'
+	 * 'core set debug atleast <level> <fn>'
+	 */
 	if ((argc < 4) || (argc > 6))
 		return RESULT_SHOWUSAGE;
 
@@ -298,10 +337,10 @@
 		if (sscanf(argv[4], "%d", &newlevel) != 1)
 			return RESULT_SHOWUSAGE;
 
-		if (argc == 6) {
+		if (argc == 5) {
 			debug_filename[0] = '\0';
 		} else {
-			filename = argv[4];
+			filename = argv[5];
 			ast_copy_string(debug_filename, filename, sizeof(debug_filename));
 		}
 
@@ -331,7 +370,7 @@
 static int handle_nodebug(int fd, int argc, char *argv[])
 {
 	int oldval = option_debug;
-	if (argc != 2)
+	if (argc != 4)
 		return RESULT_SHOWUSAGE;
 
 	option_debug = 0;
@@ -369,13 +408,13 @@
 	return RESULT_SUCCESS;
 }
 
-static int handle_unload(int fd, int argc, char *argv[])
+static int handle_unload_deprecated(int fd, int argc, char *argv[])
 {
 	int x;
-	int force=AST_FORCE_SOFT;
+	int force = AST_FORCE_SOFT;
 	if (argc < 2)
 		return RESULT_SHOWUSAGE;
-	for (x=1;x<argc;x++) {
+	for (x = 1; x < argc; x++) {
 		if (argv[x][0] == '-') {
 			switch(argv[x][1]) {
 			case 'f':
@@ -387,7 +426,35 @@
 			default:
 				return RESULT_SHOWUSAGE;
 			}
-		} else if (x !=  argc - 1) 
+		} else if (x != argc - 1) 
+			return RESULT_SHOWUSAGE;
+		else if (ast_unload_resource(argv[x], force)) {
+			ast_cli(fd, "Unable to unload resource %s\n", argv[x]);
+			return RESULT_FAILURE;
+		}
+	}
+	return RESULT_SUCCESS;
+}
+
+static int handle_unload(int fd, int argc, char *argv[])
+{
+	int x;
+	int force = AST_FORCE_SOFT;
+	if (argc < 3)
+		return RESULT_SHOWUSAGE;
+	for (x = 2; x < argc; x++) {
+		if (argv[x][0] == '-') {
+			switch(argv[x][1]) {
+			case 'f':
+				force = AST_FORCE_FIRM;
+				break;
+			case 'h':
+				force = AST_FORCE_HARD;
+				break;
+			default:
+				return RESULT_SHOWUSAGE;
+			}
+		} else if (x != argc - 1) 
 			return RESULT_SHOWUSAGE;
 		else if (ast_unload_resource(argv[x], force)) {
 			ast_cli(fd, "Unable to unload resource %s\n", argv[x]);
@@ -527,10 +594,10 @@
 	int durh, durm, durs;
 	int numchans = 0, concise = 0, verbose = 0;
 
-	concise = (argc == 3 && (!strcasecmp(argv[2],"concise")));
-	verbose = (argc == 3 && (!strcasecmp(argv[2],"verbose")));
-
-	if (argc < 2 || argc > 3 || (argc == 3 && !concise && !verbose))
+	concise = (argc == 4 && (!strcasecmp(argv[3],"concise")));
+	verbose = (argc == 4 && (!strcasecmp(argv[3],"verbose")));
+
+	if (argc < 3 || argc > 4 || (argc == 4 && !concise && !verbose))
 		return RESULT_SHOWUSAGE;
 
 	if (!concise && !verbose)
@@ -604,16 +671,12 @@
 }
 
 static char showchan_help[] = 
-"Usage: channel show <channel>\n"
+"Usage: core show channel <channel>\n"
 "       Shows lots of information about the specified channel.\n";
 
 static char debugchan_help[] = 
-"Usage: channel debug <channel>\n"
-"       Enables debugging on a specific channel.\n";
-
-static char nodebugchan_help[] = 
-"Usage: channel nodebug <channel>\n"
-"       Disables debugging on a specific channel.\n";
+"Usage: core set debug channel <channel> [off]\n"
+"       Enables/disables debugging on a specific channel.\n";
 
 static char commandcomplete_help[] = 
 "Usage: _command complete \"<line>\" text state\n"
@@ -719,8 +782,7 @@
 	return RESULT_SUCCESS;
 }
 
-/* XXX todo: merge next two functions!!! */
-static int handle_debugchan(int fd, int argc, char *argv[])
+static int handle_debugchan_deprecated(int fd, int argc, char *argv[])
 {
 	struct ast_channel *c=NULL;
 	int is_all;
@@ -754,6 +816,52 @@
 	return RESULT_SUCCESS;
 }
 
+static int handle_core_set_debug_channel(int fd, int argc, char *argv[])
+{
+	struct ast_channel *c = NULL;
+	int is_all, is_off = 0;
+
+	/* 'core set debug channel {all|chan_id}' */
+	if (argc == 6 && strcmp(argv[5], "off") == 0)
+		is_off = 1;
+	else if (argc != 5)
+		return RESULT_SHOWUSAGE;
+
+	is_all = !strcasecmp("all", argv[4]);
+	if (is_all) {
+		if (is_off) {
+			global_fin &= ~DEBUGCHAN_FLAG;
+			global_fout &= ~DEBUGCHAN_FLAG;
+		} else {
+			global_fin |= DEBUGCHAN_FLAG;
+			global_fout |= DEBUGCHAN_FLAG;
+		}
+		c = ast_channel_walk_locked(NULL);
+	} else {
+		c = ast_get_channel_by_name_locked(argv[4]);
+		if (c == NULL)
+			ast_cli(fd, "No such channel %s\n", argv[4]);
+	}
+	while (c) {
+		if (!(c->fin & DEBUGCHAN_FLAG) || !(c->fout & DEBUGCHAN_FLAG)) {
+			if (is_off) {
+				c->fin &= ~DEBUGCHAN_FLAG;
+				c->fout &= ~DEBUGCHAN_FLAG;
+			} else {
+				c->fin |= DEBUGCHAN_FLAG;
+				c->fout |= DEBUGCHAN_FLAG;
+			}
+			ast_cli(fd, "Debugging %s on channel %s\n", is_off ? "disabled" : "enabled", c->name);
+		}
+		ast_channel_unlock(c);
+		if (!is_all)
+			break;
+		c = ast_channel_walk_locked(c);
+	}
+	ast_cli(fd, "Debugging on new channels is %s\n", is_off ? "disabled" : "enabled");
+	return RESULT_SUCCESS;
+}
+
 static int handle_nodebugchan_deprecated(int fd, int argc, char *argv[])
 {
 	struct ast_channel *c=NULL;
@@ -770,38 +878,6 @@
 		c = ast_get_channel_by_name_locked(argv[3]);
 		if (c == NULL)
 			ast_cli(fd, "No such channel %s\n", argv[3]);
-	}
-	while(c) {
-		if ((c->fin & DEBUGCHAN_FLAG) || (c->fout & DEBUGCHAN_FLAG)) {
-			c->fin &= ~DEBUGCHAN_FLAG;
-			c->fout &= ~DEBUGCHAN_FLAG;
-			ast_cli(fd, "Debugging disabled on channel %s\n", c->name);
-		}
-		ast_channel_unlock(c);
-		if (!is_all)
-			break;
-		c = ast_channel_walk_locked(c);
-	}
-	ast_cli(fd, "Debugging on new channels is disabled\n");
-	return RESULT_SUCCESS;
-}
-		
-static int handle_nodebugchan(int fd, int argc, char *argv[])
-{
-	struct ast_channel *c=NULL;
-	int is_all;
-	/* 'no debug channel {all|chan_id}' */
-	if (argc != 3)
-		return RESULT_SHOWUSAGE;
-	is_all = !strcasecmp("all", argv[2]);
-	if (is_all) {
-		global_fin &= ~DEBUGCHAN_FLAG;
-		global_fout &= ~DEBUGCHAN_FLAG;
-		c = ast_channel_walk_locked(NULL);
-	} else {
-		c = ast_get_channel_by_name_locked(argv[2]);
-		if (c == NULL)
-			ast_cli(fd, "No such channel %s\n", argv[2]);
 	}
 	while(c) {
 		if ((c->fin & DEBUGCHAN_FLAG) || (c->fout & DEBUGCHAN_FLAG)) {
@@ -961,6 +1037,11 @@
 	return ast_complete_channels(line, word, pos, state, 4);
 }
 
+static char *complete_mod_2(const char *line, const char *word, int pos, int state)
+{
+	return ast_module_helper(line, word, pos, state, 1, 1);
+}
+
 static char *complete_mod_3_nr(const char *line, const char *word, int pos, int state)
 {
 	return ast_module_helper(line, word, pos, state, 2, 0);
@@ -1083,7 +1164,7 @@
 
 static struct ast_cli_entry cli_debug_channel_deprecated = {
 	{ "debug", "channel", NULL },
-	handle_debugchan, NULL,
+	handle_debugchan_deprecated, NULL,
 	NULL, complete_ch_3 };
 
 static struct ast_cli_entry cli_debug_level_deprecated = {
@@ -1091,11 +1172,6 @@
 	handle_debuglevel_deprecated, NULL,
 	NULL };
 
-static struct ast_cli_entry cli_no_debug_channel_deprecated = {
-	{ "no", "debug", "channel", NULL },
-	handle_nodebugchan_deprecated, NULL,
-	NULL, complete_ch_4 };
-
 static struct ast_cli_entry cli_set_debug_deprecated = {
 	{ "set", "debug", NULL },
 	handle_set_debug_deprecated, NULL,
@@ -1126,28 +1202,44 @@
 	handle_modlist, NULL,
 	NULL, complete_mod_4 };
 
+static struct ast_cli_entry cli_module_load_deprecated = {
+	{ "load", NULL },
+	handle_load_deprecated, NULL,
+	NULL, complete_fn };
+
+static struct ast_cli_entry cli_module_reload_deprecated = {
+	{ "reload", NULL },
+	handle_reload_deprecated, NULL,
+	NULL, complete_mod_2 };
+
+static struct ast_cli_entry cli_module_unload_deprecated = {
+	{ "unload", NULL },
+	handle_unload_deprecated, NULL,
+	NULL, complete_mod_2 };
+
 static struct ast_cli_entry cli_cli[] = {
+	/* Deprecated, but preferred command is now consolidated (and already has a deprecated command for it). */
+	{ { "no", "debug", "channel", NULL },
+	handle_nodebugchan_deprecated, NULL,
+	NULL, complete_ch_4 },
+
 	{ { "core", "show", "channels", NULL },
 	handle_chanlist, "Display information on channels",
 	chanlist_help, complete_show_channels, &cli_show_channels_deprecated },
 
-	{ { "core", "show" "channel", NULL },
+	{ { "core", "show", "channel", NULL },
 	handle_showchan, "Display information on a specific channel",
 	showchan_help, complete_ch_4, &cli_show_channel_deprecated },
 
-	{ { "core", "debug", "channel", NULL },
-	handle_debugchan, "Enable debugging on a channel",
-	debugchan_help, complete_ch_4, &cli_debug_channel_deprecated },
-
-	{ { "core", "no", "debug", "channel", NULL },
-	handle_nodebugchan, "Disable debugging on a channel",
-	nodebugchan_help, complete_ch_5, &cli_no_debug_channel_deprecated },
+	{ { "core", "set", "debug", "channel", NULL },
+	handle_core_set_debug_channel, "Enable/disable debugging on a channel",
+	debugchan_help, complete_ch_5, &cli_debug_channel_deprecated },
 
 	{ { "core", "set", "debug", NULL },
-	handle_debug, "Set level of debug chattiness",
+	handle_set_debug, "Set level of debug chattiness",
 	debug_help, NULL, &cli_set_debug_deprecated },
 
-	{ { "core", "set", "no", "debug", NULL },
+	{ { "core", "set", "debug", "off", NULL },
 	handle_nodebug, "Turns off debug chattiness",
 	nodebug_help },
 
@@ -1167,25 +1259,25 @@
 	handle_logger_mute, "Toggle logging output to a console",
 	logger_mute_help },
 
-	{ { "core", "show", "modules", NULL },
+	{ { "module", "show", NULL },
 	handle_modlist, "List modules and info",
 	modlist_help, NULL, &cli_show_modules_deprecated },
 
-	{ { "core", "show", "modules", "like", NULL },
+	{ { "module", "show", "like", NULL },
 	handle_modlist, "List modules and info",
 	modlist_help, complete_mod_4, &cli_show_modules_like_deprecated },
 
-	{ { "load", NULL },
+	{ { "module", "load", NULL },
 	handle_load, "Load a module by name",
-	load_help, complete_fn },
-
-	{ { "reload", NULL },
+	load_help, complete_fn, &cli_module_load_deprecated },
+
+	{ { "module", "reload", NULL },
 	handle_reload, "Reload configuration",
-	reload_help, complete_mod_3 },
-
-	{ { "unload", NULL },
+	reload_help, complete_mod_3, &cli_module_reload_deprecated },
+
+	{ { "module", "unload", NULL },
 	handle_unload, "Unload a module by name",
-	unload_help, complete_mod_3_nr },
+	unload_help, complete_mod_3_nr, &cli_module_unload_deprecated },
 
  	{ { "core", "show", "uptime", NULL },
 	handle_showuptime, "Show uptime information",



More information about the svn-commits mailing list