[asterisk-commits] trunk r21879 - /trunk/pbx.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 21 05:58:41 MST 2006


Author: rizzo
Date: Fri Apr 21 07:58:39 2006
New Revision: 21879

URL: http://svn.digium.com/view/asterisk?rev=21879&view=rev
Log:
simplify a function


Modified:
    trunk/pbx.c

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=21879&r1=21878&r2=21879&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Fri Apr 21 07:58:39 2006
@@ -5240,7 +5240,6 @@
 static int pbx_builtin_background(struct ast_channel *chan, void *data)
 {
 	int res = 0;
-	char *front = NULL, *back = NULL;
 	struct ast_flags flags = {0};
 	char *parse;
 	AST_DECLARE_APP_ARGS(args,
@@ -5283,43 +5282,33 @@
 	}
 
 	if (!res) {
-		/* Stop anything playing */
-		ast_stopstream(chan);
-		/* Stream a file */
-		front = args.filename;
-		while(!res && front) {
-			if((back = strchr(front, '&'))) {
-				*back = '\0';
-				back++;
-			}
-			res = ast_streamfile(chan, front, args.lang);
-			if (!res) {
-				if (ast_test_flag(&flags, BACKGROUND_PLAYBACK)) {
-					res = ast_waitstream(chan, "");
-				} else {
-					if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) {
-						res = ast_waitstream_exten(chan, args.context);
-					} else {
-						res = ast_waitstream(chan, AST_DIGIT_ANY);
-					}
-				}
-				ast_stopstream(chan);
-			} else {
+		char *back = args.filename;
+		char *front;
+		ast_stopstream(chan);		/* Stop anything playing */
+		/* Stream the list of files */
+		while (!res && (front = strsep(&back, "&")) ) {
+			if ( (res = ast_streamfile(chan, front, args.lang)) ) {
 				ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data);
 				res = 0;
 				break;
 			}
-			front = back;
+			if (ast_test_flag(&flags, BACKGROUND_PLAYBACK)) {
+				res = ast_waitstream(chan, "");
+			} else if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) {
+				res = ast_waitstream_exten(chan, args.context);
+			} else {
+				res = ast_waitstream(chan, AST_DIGIT_ANY);
+			}
+			ast_stopstream(chan);
 		}
 	}
 	if (args.context != chan->context && res) {
 		snprintf(chan->exten, sizeof(chan->exten), "%c", res);
 		ast_copy_string(chan->context, args.context, sizeof(chan->context));
 		chan->priority = 0;
-		return 0;
-	} else {
-		return res;
-	}
+		res = 0;
+	}
+	return res;
 }
 
 /*! Goto



More information about the asterisk-commits mailing list