From a702e1f001560158a889ff8fec00ba4d3fe72b96 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo <rizzo@icir.org> Date: Fri, 21 Apr 2006 12:58:39 +0000 Subject: [PATCH] simplify a function git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@21879 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- pbx.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/pbx.c b/pbx.c index 004900e82f..b4066207ac 100644 --- a/pbx.c +++ b/pbx.c @@ -5240,7 +5240,6 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, void *data) 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 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data) } 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 -- GitLab