mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-01 03:04:19 +00:00
Formatting cleanups
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3741 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
88
pbx.c
88
pbx.c
@@ -4508,55 +4508,55 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
static int pbx_builtin_background(struct ast_channel *chan, void *data)
|
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[256] = "";
|
||||||
char* stringp;
|
char* stringp;
|
||||||
char* options;
|
char* options;
|
||||||
char *lang = NULL;
|
char *lang = NULL;
|
||||||
|
|
||||||
if (!data || ast_strlen_zero(data)) {
|
if (!data || ast_strlen_zero(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);
|
strncpy(filename, (char*)data, sizeof(filename) - 1);
|
||||||
stringp = filename;
|
stringp = filename;
|
||||||
strsep(&stringp, "|");
|
strsep(&stringp, "|");
|
||||||
options = strsep(&stringp, "|");
|
options = strsep(&stringp, "|");
|
||||||
if (options)
|
if (options)
|
||||||
lang = strsep(&stringp, "|");
|
lang = strsep(&stringp, "|");
|
||||||
if (!lang)
|
if (!lang)
|
||||||
lang = chan->language;
|
lang = chan->language;
|
||||||
|
|
||||||
if (options && !strcasecmp(options, "skip"))
|
if (options && !strcasecmp(options, "skip"))
|
||||||
option_skip = 1;
|
option_skip = 1;
|
||||||
if (options && !strcasecmp(options, "noanswer"))
|
if (options && !strcasecmp(options, "noanswer"))
|
||||||
option_noanswer = 1;
|
option_noanswer = 1;
|
||||||
|
|
||||||
/* Answer if need be */
|
/* Answer if need be */
|
||||||
if (chan->_state != AST_STATE_UP) {
|
if (chan->_state != AST_STATE_UP) {
|
||||||
if (option_skip) {
|
if (option_skip) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!option_noanswer) {
|
} else if (!option_noanswer) {
|
||||||
res = ast_answer(chan);
|
res = ast_answer(chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
/* Stop anything playing */
|
/* Stop anything playing */
|
||||||
ast_stopstream(chan);
|
ast_stopstream(chan);
|
||||||
/* Stream a file */
|
/* Stream a file */
|
||||||
res = ast_streamfile(chan, filename, lang);
|
res = ast_streamfile(chan, filename, 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 fro %s\n", chan->name, (char*)data);
|
ast_log(LOG_WARNING, "ast_streamfile failed on %s fro %s\n", chan->name, (char*)data);
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user