[asterisk-commits] rizzo: trunk r126311 - /trunk/channels/chan_oss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jun 29 08:02:54 CDT 2008


Author: rizzo
Date: Sun Jun 29 08:02:54 2008
New Revision: 126311

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126311
Log:
implement a 'toggle' option for 'console mute' and 'console unmute'


Modified:
    trunk/channels/chan_oss.c

Modified: trunk/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_oss.c?view=diff&rev=126311&r1=126310&r2=126311
==============================================================================
--- trunk/channels/chan_oss.c (original)
+++ trunk/channels/chan_oss.c Sun Jun 29 08:02:54 2008
@@ -1125,25 +1125,32 @@
 {
 	struct chan_oss_pvt *o = find_desc(oss_active);
 	char *s;
+	int toggle = 0;
 	
 	if (cmd == CLI_INIT) {
-		e->command = "console {mute|unmute}";
+		e->command = "console {mute|unmute} [toggle]";
 		e->usage =
-			"Usage: console {mute|unmute}\n"
+			"Usage: console {mute|unmute} [toggle]\n"
 			"       Mute/unmute the microphone.\n";
 		return NULL;
 	} else if (cmd == CLI_GENERATE)
 		return NULL;
 
-	if (a->argc != e->args)
+	if (a->argc > e->args)
 		return CLI_SHOWUSAGE;
-	s = a->argv[e->args-1];
+	if (a->argc == e->args) {
+		if (strcasecmp(a->argv[e->args-1], "toggle"))
+			return CLI_SHOWUSAGE;
+		toggle = 1;
+	}
+	s = a->argv[e->args-2];
 	if (!strcasecmp(s, "mute"))
-		o->mute = 1;
+		o->mute = toggle ? ~o->mute : 1;
 	else if (!strcasecmp(s, "unmute"))
-		o->mute = 0;
+		o->mute = toggle ? ~o->mute : 0;
 	else
 		return CLI_SHOWUSAGE;
+	ast_cli(a->fd, "Console mic is %s\n", o->mute ? "off" : "on");
 	return CLI_SUCCESS;
 }
 




More information about the asterisk-commits mailing list