aboutsummaryrefslogtreecommitdiffstats
path: root/pbx.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-21 12:58:39 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-21 12:58:39 +0000
commit00c76157427174182422bbca743c09a817c5cec4 (patch)
tree9ce8a5a9783b733c68be847f70d1bdf5f740c235 /pbx.c
parentd8d540470f8f38d5e54ec729a4e7321c4475d59f (diff)
simplify a function
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@21879 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rw-r--r--pbx.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/pbx.c b/pbx.c
index 004900e82..b4066207a 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