[asterisk-commits] tilghman: trunk r44231 - /trunk/apps/app_stack.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Oct 2 15:02:46 MST 2006


Author: tilghman
Date: Mon Oct  2 17:02:45 2006
New Revision: 44231

URL: http://svn.digium.com/view/asterisk?rev=44231&view=rev
Log:
Use the standard parsing routines

Modified:
    trunk/apps/app_stack.c

Modified: trunk/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_stack.c?rev=44231&r1=44230&r2=44231&view=diff
==============================================================================
--- trunk/apps/app_stack.c (original)
+++ trunk/apps/app_stack.c Mon Oct  2 17:02:45 2006
@@ -182,27 +182,39 @@
 static int gosubif_exec(struct ast_channel *chan, void *data)
 {
 	struct ast_module_user *u;
-	char *condition = "", *label1, *label2, *args;
+	char *args;
 	int res=0;
+	AST_DECLARE_APP_ARGS(cond,
+		AST_APP_ARG(ition);
+		AST_APP_ARG(labels);
+	);
+	AST_DECLARE_APP_ARGS(label,
+		AST_APP_ARG(iftrue);
+		AST_APP_ARG(iffalse);
+	);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "GosubIf requires an argument: GosubIf(cond?label1(args):label2(args)\n");
 		return 0;
 	}
 
+	u = ast_module_user_add(chan);
+
 	args = ast_strdupa(data);
-
-	u = ast_module_user_add(chan);
-
-	condition = strsep(&args, "?");
-	label1 = strsep(&args, ":");
-	label2 = args;
-
-	if (pbx_checkcondition(condition)) {
-		if (label1)
-			res = gosub_exec(chan, label1);
-	} else if (label2) {
-		res = gosub_exec(chan, label2);
+	AST_NONSTANDARD_APP_ARGS(cond, args, '?');
+	if (cond.argc != 2) {
+		ast_log(LOG_WARNING, "GosubIf requires an argument: GosubIf(cond?label1(args):label2(args)\n");
+		ast_module_user_remove(u);
+		return 0;
+	}
+
+	AST_NONSTANDARD_APP_ARGS(label, cond.labels, ':');
+
+	if (pbx_checkcondition(cond.ition)) {
+		if (!ast_strlen_zero(label.iftrue))
+			res = gosub_exec(chan, label.iftrue);
+	} else if (!ast_strlen_zero(label.iffalse)) {
+		res = gosub_exec(chan, label.iffalse);
 	}
 
 	ast_module_user_remove(u);



More information about the asterisk-commits mailing list