- if (!res) {
- /* Stop anything playing */
- ast_stopstream(chan);
- /* Stream a file */
- res = ast_streamfile(chan, filename, lang);
- if (!res) {
- res = ast_waitstream(chan, AST_DIGIT_ANY);
- ast_stopstream(chan);
- } else {
- ast_log(LOG_WARNING, "ast_streamfile failed on %s fro %s\n", chan->name, (char*)data);
- res = 0;
- }
- }
+ strncpy(filename, (char*)data, sizeof(filename) - 1);
+ stringp = filename;
+ strsep(&stringp, "|");
+ options = strsep(&stringp, "|");
+ if (options)
+ lang = strsep(&stringp, "|");
+ if (!lang)
+ lang = chan->language;
+
+ if (options && !strcasecmp(options, "skip"))
+ option_skip = 1;
+ if (options && !strcasecmp(options, "noanswer"))
+ option_noanswer = 1;
+
+ /* Answer if need be */
+ if (chan->_state != AST_STATE_UP) {
+ if (option_skip) {
+ return 0;
+ } else if (!option_noanswer) {
+ res = ast_answer(chan);
+ }
+ }
+
+ if (!res) {
+ /* Stop anything playing */
+ ast_stopstream(chan);
+ /* Stream a file */
+ res = ast_streamfile(chan, filename, lang);
+ if (!res) {
+ res = ast_waitstream(chan, AST_DIGIT_ANY);
+ ast_stopstream(chan);
+ } else {
+ ast_log(LOG_WARNING, "ast_streamfile failed on %s fro %s\n", chan->name, (char*)data);
+ res = 0;
+ }
+ }