Merge tony's ampersand patch (bug #2934)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4330 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Mark Spencer 21 years ago
parent 7ea9bd7b83
commit 8c42a49ec8

@ -1,7 +1,7 @@
/* /*
* Asterisk -- A telephony toolkit for Linux. * Asterisk -- A telephony toolkit for Linux.
* *
* Voicemail System (did you ever think it could be so easy?) * Voicemail System
* *
* Copyright (C) 2003-2004, Digium Inc. * Copyright (C) 2003-2004, Digium Inc.
* *

44
pbx.c

@ -216,19 +216,19 @@ static struct pbx_builtin {
{ "BackGround", pbx_builtin_background, { "BackGround", pbx_builtin_background,
"Play a file while awaiting extension", "Play a file while awaiting extension",
" Background(filename[|options[|langoverride]]): Plays a given file, while simultaneously\n" " Background(filename1[&filename2...][|options[|langoverride]]): Plays\n"
"waiting for the user to begin typing an extension. The timeouts do not\n" "given files, while simultaneously waiting for the user to begin typing\n"
"count until the last BackGround application has ended.\n" "an extension. The timeouts do not count until the last BackGround\n"
"Options may also be included following a pipe symbol. The 'skip'\n" "application has ended. Options may also be included following a pipe \n"
"option causes the playback of the message to be skipped if the channel\n" "symbol. The 'skip' option causes the playback of the message to be \n"
"is not in the 'up' state (i.e. it hasn't been answered yet. If 'skip' is \n" "skipped if the channel is not in the 'up' state (i.e. it hasn't been\n"
"specified, the application will return immediately should the channel not be\n" "answered yet. If 'skip' is specified, the application will return\n"
"off hook. Otherwise, unless 'noanswer' is specified, the channel channel will\n" "immediately should the channel not be off hook. Otherwise, unless \n"
"be answered before the sound is played. Not all channels support playing\n" "'noanswer' is specified, the channel channel will be answered before the\n"
"messages while still hook. The 'langoverride' may be a language to use for\n" "sound is played. Not all channels support playing messages while still\n"
"playing the prompt which differs from the current language of the channel\n" "hook. The 'langoverride' may be a language to use for playing the prompt\n"
"Returns -1 if the channel was hung up, or if the file does not exist. \n" "which differs from the current language of the channel. Returns -1 if \n"
"Returns 0 otherwise.\n" "the channel was hung up, or if the file does not exist. Returns 0 otherwise.\n"
}, },
{ "Busy", pbx_builtin_busy, { "Busy", pbx_builtin_busy,
@ -4857,17 +4857,17 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data)
int res = 0; int res = 0;
int option_skip = 0; int option_skip = 0;
int option_noanswer = 0; int option_noanswer = 0;
char filename[256] = ""; char *filename = NULL;
char* stringp; char* stringp;
char* options; char* options;
char *lang = NULL; char *lang = NULL;
char *front = NULL, *back = NULL;
if (!data || ast_strlen_zero(data)) { if (!data || ast_strlen_zero(data) || !(filename = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Background requires an argument(filename)\n"); ast_log(LOG_WARNING, "Background requires an argument(filename)\n");
return -1; return -1;
} }
strncpy(filename, (char*)data, sizeof(filename) - 1);
stringp = filename; stringp = filename;
strsep(&stringp, "|"); strsep(&stringp, "|");
options = strsep(&stringp, "|"); options = strsep(&stringp, "|");
@ -4894,16 +4894,24 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data)
/* Stop anything playing */ /* Stop anything playing */
ast_stopstream(chan); ast_stopstream(chan);
/* Stream a file */ /* Stream a file */
res = ast_streamfile(chan, filename, lang); front = filename;
while(!res && front) {
if((back = strchr(front, '&'))) {
*back = '\0';
back++;
}
res = ast_streamfile(chan, front, lang);
if (!res) { if (!res) {
res = ast_waitstream(chan, AST_DIGIT_ANY); res = ast_waitstream(chan, AST_DIGIT_ANY);
ast_stopstream(chan); ast_stopstream(chan);
} else { } else {
ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data); ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data);
res = 0; res = 0;
break;
}
front = back;
} }
} }
return res; return res;
} }

Loading…
Cancel
Save