[asterisk-commits] tilghman: trunk r44100 - /trunk/apps/app_zapateller.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Sep 30 22:37:47 MST 2006


Author: tilghman
Date: Sun Oct  1 00:37:46 2006
New Revision: 44100

URL: http://svn.digium.com/view/asterisk?rev=44100&view=rev
Log:
Janitor for Zapateller:  convert to use argument macros

Modified:
    trunk/apps/app_zapateller.c

Modified: trunk/apps/app_zapateller.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_zapateller.c?rev=44100&r1=44099&r2=44100&view=diff
==============================================================================
--- trunk/apps/app_zapateller.c (original)
+++ trunk/apps/app_zapateller.c Sun Oct  1 00:37:46 2006
@@ -40,6 +40,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
+#include "asterisk/app.h"
 
 static char *app = "Zapateller";
 
@@ -59,36 +60,36 @@
 {
 	int res = 0;
 	struct ast_module_user *u;
-	int answer = 0, nocallerid = 0;
-	char *c;
-	char *stringp=NULL;
-	
+	int i, answer = 0, nocallerid = 0;
+	char *parse = ast_strdupa((char *)data);
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(options)[2];
+	);
+
 	u = ast_module_user_add(chan);
 
-	stringp=data;
-        c = strsep(&stringp, "|");
-        while(!ast_strlen_zero(c)) {
-		if (!strcasecmp(c, "answer"))
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	for (i = 0; i < args.argc; i++) {
+		if (!strcasecmp(args.options[i], "answer"))
 			answer = 1;
-		else if (!strcasecmp(c, "nocallerid"))
+		else if (!strcasecmp(args.options[i], "nocallerid"))
 			nocallerid = 1;
-
-                c = strsep(&stringp, "|");
-        }
+	}
 
 	ast_stopstream(chan);
 	if (chan->_state != AST_STATE_UP) {
-
 		if (answer) 
 			res = ast_answer(chan);
-		if (!res) {
+		if (!res)
 			res = ast_safe_sleep(chan, 500);
-		}
 	}
-	if (chan->cid.cid_num && nocallerid) {
+
+	if (!ast_strlen_zero(chan->cid.cid_num) && nocallerid) {
 		ast_module_user_remove(u);
 		return res;
 	} 
+
 	if (!res) 
 		res = ast_tonepair(chan, 950, 0, 330, 0);
 	if (!res) 
@@ -97,6 +98,7 @@
 		res = ast_tonepair(chan, 1800, 0, 330, 0);
 	if (!res) 
 		res = ast_tonepair(chan, 0, 0, 1000, 0);
+
 	ast_module_user_remove(u);
 	return res;
 }



More information about the asterisk-commits mailing list