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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Nov 17 04:15:54 MST 2006


Author: rizzo
Date: Fri Nov 17 05:15:54 2006
New Revision: 47788

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47788
Log:
use the regexp cli support on some of the command


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=47788&r1=47787&r2=47788
==============================================================================
--- trunk/channels/chan_oss.c (original)
+++ trunk/channels/chan_oss.c Fri Nov 17 05:15:54 2006
@@ -1065,11 +1065,10 @@
 static char *console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct chan_oss_pvt *o = find_desc(oss_active);
-	static char *choices[] = { "on", "off", NULL };
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "console autoanswer";
+		e->command = "console autoanswer [on|off]";
 		e->usage =
 			"Usage: console autoanswer [on|off]\n"
 			"       Enables or disables autoanswer feature.  If used without\n"
@@ -1078,23 +1077,23 @@
 		return NULL;
 
 	case CLI_GENERATE:
-		return (a->pos != e->args + 1) ? NULL : ast_cli_complete(a->word, choices, a->n);
-	}
-
-	if (a->argc == e->args) {
+		return NULL;
+	}
+
+	if (a->argc == e->args - 1) {
 		ast_cli(a->fd, "Auto answer is %s.\n", o->autoanswer ? "on" : "off");
 		return CLI_SUCCESS;
 	}
-	if (a->argc != e->args + 1)
+	if (a->argc != e->args)
 		return CLI_SHOWUSAGE;
 	if (o == NULL) {
 		ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
 		    oss_active);
 		return CLI_FAILURE;
 	}
-	if (!strcasecmp(a->argv[e->args], "on"))
+	if (!strcasecmp(a->argv[e->args-1], "on"))
 		o->autoanswer = 1;
-	else if (!strcasecmp(a->argv[e->args], "off"))
+	else if (!strcasecmp(a->argv[e->args - 1], "off"))
 		o->autoanswer = 0;
 	else
 		return CLI_SHOWUSAGE;
@@ -1287,21 +1286,20 @@
 static char *console_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct chan_oss_pvt *o = find_desc(oss_active);
-	static char *choices[] = { "mute", "unmute", NULL };
 	char *s;
 	
 	if (cmd == CLI_INIT) {
-		e->command = "console";
+		e->command = "console {mute|unmute}";
 		e->usage =
-			"Usage: console [mute|unmute]\n"
+			"Usage: console {mute|unmute}\n"
 			"       Mute/unmute the microphone.\n";
 		return NULL;
 	} else if (cmd == CLI_GENERATE)
-		return (a->pos != e->args) ? NULL : ast_cli_complete(a->word, choices, a->n);
-
-	if (a->argc != e->args+1)
+		return NULL;
+
+	if (a->argc != e->args)
 		return CLI_SHOWUSAGE;
-	s = a->argv[e->args];
+	s = a->argv[e->args-1];
 	if (!strcasecmp(s, "mute"))
 		o->mute = 1;
 	else if (!strcasecmp(s, "unmute"))



More information about the asterisk-commits mailing list