--- say.c 2009-03-23 12:28:18.000000000 -0400 +++ say_relativepath.c 2009-03-25 08:52:51.000000000 -0400 @@ -29,6 +29,8 @@ * Next Generation Networks (NGN). * \note 2007-03-20 : Support for Thai added by Dome C. , * IP Crossing Co., Ltd. + * \note 2009-03-25 : Added support to play files from a relative directory in support of multiple voices + * NicChap */ #include "asterisk.h" @@ -51,15 +53,137 @@ #include "asterisk/localtime.h" #include "asterisk/utils.h" #include "asterisk/app.h" +#include "asterisk/pbx.h" /* Forward declaration */ static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang); +static int ast_say_streamfile (struct ast_channel *chan, const char *file, const char *lang) ; +static void getrelative_path(struct ast_channel *chan, char *relpathbuf, size_t pathbufsize); +static int makerelative_fn(const char *relpath, const char *fn, char *buf, size_t bufsize); + +/*! \fn static int getrelative_path(ast_channel *chan, char *relpathbuf) +* \brief get the VOCAB_RELATIVE_PATH channel variable and saves it to a buffer +* \param struct ast_channel *chan asterisk channel +* \param char * relpathbuf buffer to store the relative path +* \param size_t pathbufsize max size for path buffer +* +* Gets the VOCAB_RELATIVE_PATH channel variable. +*/ +static void getrelative_path(struct ast_channel *chan, char *relpathbuf, size_t pathbufsize) +{ + const char *relpath; + + ast_channel_lock(chan); + if ((relpath = pbx_builtin_getvar_helper(chan, "VOCAB_RELATIVE_PATH"))) { + relpath = ast_strdupa(relpath); + } + ast_channel_unlock(chan); + + /* we have to copy this string since we are using stack memory */ + if (relpath) + ast_copy_string(relpathbuf, relpath, pathbufsize); + else + relpathbuf[0] = '\0'; + + ast_verb(5, "Allocating relpath %s\n", relpathbuf); +} + +/*! \fn static int makerelative_fn(const char *relpath, const char *fn, char *buf, size_t bufsize) +* \brief prefix fn with relative path if one is defined +* \param relpath relative path to use if any is defined +* \param fn filename to prefix relpath to +* \param buf space for newly created fn with relpath +* \param bufsize max length of buf +* \return 0 on success, -1 on failure or if relpath is NULL +* +* Used to verify if user wishes to use a relative path for all digits, letters and phonetics files. +* This is used when the VOCAB_RELATIVE_PATH channel variable is set. If no such variable exists the function does not +* change the fn to play, otherwise it prefixes it with the relative path. Supports all languages. If a +* relative path is specified, the file will play from the directories. +*/ +static int makerelative_fn(const char *relpath, const char *fn, char *buf, size_t bufsize) +{ + char *fnrel; + size_t bufspace; + + if (!buf || !relpath) + return -1; + + /* relpath empty? simply play from default path, no relative path was requested */ + if (ast_strlen_zero(relpath)) { + ast_copy_string(buf, fn, bufsize); + return 0; + } + + ast_verb(5, "prefixing relpath %s\n", relpath); + + /* prefix relpath */ + buf[0] = '\0'; + bufspace = bufsize; + fnrel = buf; + if (ast_build_string(&fnrel, &bufspace, "%s/%s", relpath, fn)) + return -1; + + return 0; +} + +/*! \fn static int ast_say_streamfile (struct ast_channel *chan, const char *file, const char *lang) +* \brief stream a file prefixed with a relative path if one is found +* \param struct ast_channel *chan +* \param const char *file +* \param const char *lang +* \return 0 on success, -1 on failure +* +* Instead of adding this code to each SAY function, it's much cleaner to do it this way +* despite adding a few extra cycles to get the channel variable on each call. If there's +* a way to avoid a channel lock here, by all means let's do it! +*/ +static int ast_say_streamfile (struct ast_channel *chan, const char *file, const char *lang) +{ + char fnbufrel[256]; + char relative_path[256]; + int res = -1; + + getrelative_path(chan, relative_path, sizeof(relative_path)); + if (makerelative_fn(relative_path, file, fnbufrel, sizeof(fnbufrel))) { + ast_log(LOG_WARNING, "Relative path error. Reverting to default path\n"); + ast_copy_string(fnbufrel, file, sizeof(fnbufrel)); + } + + /* check if file exists with relative path, if not revert to default path */ + if (ast_fileexists(fnbufrel, NULL, lang) > 0) { + if ((res = ast_streamfile(chan, fnbufrel, lang))) { + ast_log(LOG_WARNING, "Unable to play message %s\n", fnbufrel); + } + } + else { + ast_log(LOG_WARNING, "File missing in relative path %s, using default path\n", relative_path); + if (ast_fileexists(file, NULL, lang) > 0) { + if ((res = ast_streamfile(chan, file, lang))) { + ast_log(LOG_WARNING, "Unable to play message %s\n", file); + } + } + } + + return res; +} + +static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang) +{ + int res; + + if ((res = ast_say_streamfile(chan, file, lang))) + ast_log(LOG_WARNING, "Unable to play message %s\n", file); + if (!res) + res = ast_waitstream(chan, ints); + return res; +} static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd) { const char *fn; - char fnbuf[10], asciibuf[20] = "letters/ascii"; + char fnbuf[10]; char ltr; int num = 0; int res = 0; @@ -121,9 +245,9 @@ fnbuf[8] = ltr; fn = fnbuf; } - if ((fn && ast_fileexists(fn, NULL, lang) > 0) || - (snprintf(asciibuf + 13, sizeof(asciibuf) - 13, "%d", str[num]) > 0 && ast_fileexists(asciibuf, NULL, lang) > 0 && (fn = asciibuf))) { - res = ast_streamfile(chan, fn, lang); + /* no longer checking if file exists since streamfile will check for us */ + if (fn) { + res = ast_say_streamfile(chan, fn, lang); if (!res) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); @@ -202,8 +326,8 @@ fnbuf[9] = ltr; fn = fnbuf; } - if (fn && ast_fileexists(fn, NULL, lang) > 0) { - res = ast_streamfile(chan, fn, lang); + if (fn) { + res = ast_say_streamfile(chan, fn, lang); if (!res) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); @@ -252,8 +376,8 @@ fn = fnbuf; break; } - if (fn && ast_fileexists(fn, NULL, lang) > 0) { - res = ast_streamfile(chan, fn, lang); + if (fn) { + res = ast_say_streamfile(chan, fn, lang); if (!res) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); @@ -415,16 +539,6 @@ static int ast_say_datetime_from_now_ge(struct ast_channel *chan, time_t t, const char *ints, const char *lang); static int ast_say_datetime_from_now_he(struct ast_channel *chan, time_t t, const char *ints, const char *lang); -static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang) -{ - int res; - if ((res = ast_streamfile(chan, file, lang))) - ast_log(LOG_WARNING, "Unable to play message %s\n", file); - if (!res) - res = ast_waitstream(chan, ints); - return res; -} - /*! \brief ast_say_number_full: call language-specific functions */ /* Called from AGI */ static int say_number_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) @@ -529,7 +643,7 @@ } } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -651,7 +765,7 @@ num -= left * (exp10_int(length-1)); } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) { res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); } else { @@ -760,7 +874,7 @@ } } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -890,7 +1004,7 @@ res = -1; } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -898,7 +1012,7 @@ } ast_stopstream(chan); if (!res) { - if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) { + if (strlen(fna) != 0 && !ast_say_streamfile(chan, fna, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -976,7 +1090,7 @@ } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -1080,7 +1194,7 @@ } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -1172,7 +1286,7 @@ res = -1; } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -1343,7 +1457,7 @@ } tmpnum = 0; if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) { res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); } else { @@ -1425,7 +1539,7 @@ } } if (!res) { - if(!ast_streamfile(chan, fn, language)) { + if(!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -1578,7 +1692,7 @@ } } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -1669,7 +1783,7 @@ } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -1761,7 +1875,7 @@ } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -1808,7 +1922,7 @@ char file_name[255] = "digits/"; strcat(file_name, fn); ast_debug(1, "Trying to play: %s\n", file_name); - if (!ast_streamfile(chan, file_name, language)) { + if (!ast_say_streamfile(chan, file_name, language)) { if ((audiofd > -1) && (ctrlfd > -1)) ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2150,7 +2264,7 @@ res = -1; } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2227,7 +2341,7 @@ } } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2340,7 +2454,7 @@ } } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2446,7 +2560,7 @@ res = -1; } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2515,7 +2629,7 @@ ast_copy_string(fn, "digits/larn", sizeof(fn)); } if (!res) { - if(!ast_streamfile(chan, fn, language)) { + if(!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2631,7 +2745,7 @@ } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) { res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); } else { @@ -2784,7 +2898,7 @@ } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2792,7 +2906,7 @@ } ast_stopstream(chan); if (!res) { - if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) { + if (strlen(fna) != 0 && !ast_say_streamfile(chan, fna, language)) { if ((audiofd > -1) && (ctrlfd > -1)) { res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); } else { @@ -2947,7 +3061,7 @@ } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -2955,7 +3069,7 @@ } ast_stopstream(chan); if (!res) { - if (strlen(fna) != 0 && !ast_streamfile(chan, fna, language)) { + if (strlen(fna) != 0 && !ast_say_streamfile(chan, fna, language)) { if ((audiofd > -1) && (ctrlfd > -1)) { res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); } else { @@ -3045,7 +3159,7 @@ res = -1; } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) { res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); } else { @@ -3098,13 +3212,13 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3127,7 +3241,7 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3137,7 +3251,7 @@ res = ast_waitstream(chan, ints); if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3176,7 +3290,7 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3186,7 +3300,7 @@ res = ast_waitstream(chan, ints); if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3231,7 +3345,7 @@ res = ast_waitstream(chan, ints); if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3241,7 +3355,7 @@ res = ast_waitstream(chan, ints); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3258,7 +3372,7 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3268,7 +3382,7 @@ res = ast_waitstream(chan, ints); if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3287,7 +3401,7 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3295,7 +3409,7 @@ res = ast_say_number(chan, tm.tm_mday, ints, lang, (char * ) NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3316,9 +3430,9 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); ast_copy_string(fn, "digits/tee", sizeof(fn)); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -3328,15 +3442,15 @@ res = ast_waitstream(chan, ints); if (!res) { ast_copy_string(fn, "digits/duan", sizeof(fn)); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } if (!res){ ast_copy_string(fn, "digits/posor", sizeof(fn)); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); } return res; @@ -3379,14 +3493,14 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) { res = ast_waitstream(chan, ints); } } if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) { res = ast_waitstream(chan, ints); } @@ -6067,23 +6181,23 @@ res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); } else if (tm.tm_min) { if (!res) - res = ast_streamfile(chan, "digits/oh", lang); + res = ast_say_streamfile(chan, "digits/oh", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); } else { if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); } if (pm) { if (!res) - res = ast_streamfile(chan, "digits/p-m", lang); + res = ast_say_streamfile(chan, "digits/p-m", lang); } else { if (!res) - res = ast_streamfile(chan, "digits/a-m", lang); + res = ast_say_streamfile(chan, "digits/a-m", lang); } if (!res) res = ast_waitstream(chan, ints); @@ -6101,7 +6215,7 @@ if (!res) res = ast_say_number(chan, tm.tm_hour, ints, lang, "n"); if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) @@ -6121,14 +6235,14 @@ if (!res) res = ast_say_number(chan, tm.tm_hour, ints, lang, "n"); if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) if (tm.tm_min > 0) { res = ast_say_number(chan, tm.tm_min, ints, lang, "f"); if (!res) - res = ast_streamfile(chan, "digits/minute", lang); + res = ast_say_streamfile(chan, "digits/minute", lang); } return res; } @@ -6144,7 +6258,7 @@ res = ast_say_number(chan, tm.tm_hour, ints, lang, "f"); if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (tm.tm_min) { if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); @@ -6163,7 +6277,7 @@ if (!res) res = ast_say_number(chan, tm.tm_hour, ints, lang, (char *) NULL); if (!res) - res = ast_streamfile(chan, "digits/nl-uur", lang); + res = ast_say_streamfile(chan, "digits/nl-uur", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) @@ -6269,23 +6383,23 @@ } if (pm) { if (!res) - res = ast_streamfile(chan, "digits/p-m", lang); + res = ast_say_streamfile(chan, "digits/p-m", lang); } else { if (!res) - res = ast_streamfile(chan, "digits/a-m", lang); + res = ast_say_streamfile(chan, "digits/a-m", lang); } if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, hour, ints, lang, (char *) NULL); if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); if (!res) - res = ast_streamfile(chan, "digits/minute", lang); + res = ast_say_streamfile(chan, "digits/minute", lang); if (!res) res = ast_waitstream(chan, ints); return res; @@ -6370,13 +6484,13 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6400,23 +6514,23 @@ res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); } else if (tm.tm_min) { if (!res) - res = ast_streamfile(chan, "digits/oh", lang); + res = ast_say_streamfile(chan, "digits/oh", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); } else { if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); } if (pm) { if (!res) - res = ast_streamfile(chan, "digits/p-m", lang); + res = ast_say_streamfile(chan, "digits/p-m", lang); } else { if (!res) - res = ast_streamfile(chan, "digits/a-m", lang); + res = ast_say_streamfile(chan, "digits/a-m", lang); } if (!res) res = ast_waitstream(chan, ints); @@ -6469,13 +6583,13 @@ if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6483,7 +6597,7 @@ if (!res) res = ast_say_number(chan, tm.tm_hour, ints, lang, "f"); if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (tm.tm_min > 0) { if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); @@ -6505,7 +6619,7 @@ ast_localtime(&tv, &tm, NULL); res = ast_say_date(chan, t, ints, lang); if (!res) { - res = ast_streamfile(chan, "digits/nl-om", lang); + res = ast_say_streamfile(chan, "digits/nl-om", lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6526,13 +6640,13 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6556,23 +6670,23 @@ res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); } else if (tm.tm_min) { if (!res) - res = ast_streamfile(chan, "digits/oh", lang); + res = ast_say_streamfile(chan, "digits/oh", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); } else { if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); } if (pm) { if (!res) - res = ast_streamfile(chan, "digits/p-m", lang); + res = ast_say_streamfile(chan, "digits/p-m", lang); } else { if (!res) - res = ast_streamfile(chan, "digits/a-m", lang); + res = ast_say_streamfile(chan, "digits/a-m", lang); } if (!res) res = ast_waitstream(chan, ints); @@ -6606,19 +6720,19 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } if (!res){ ast_copy_string(fn, "digits/posor", sizeof(fn)); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); res = ast_say_number(chan, tm.tm_year + 1900 + 543, ints, lang, (char *) NULL); } if (!res) @@ -6629,7 +6743,7 @@ hour = 24; if (!res){ ast_copy_string(fn, "digits/wela", sizeof(fn)); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); } if (!res) res = ast_say_number(chan, hour, ints, lang, (char *) NULL); @@ -6652,7 +6766,7 @@ res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6660,7 +6774,7 @@ res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6676,23 +6790,23 @@ } if (pm) { if (!res) - res = ast_streamfile(chan, "digits/p-m", lang); + res = ast_say_streamfile(chan, "digits/p-m", lang); } else { if (!res) - res = ast_streamfile(chan, "digits/a-m", lang); + res = ast_say_streamfile(chan, "digits/a-m", lang); } if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, hour, ints, lang, (char *) NULL); if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); if (!res) - res = ast_streamfile(chan, "digits/minute", lang); + res = ast_say_streamfile(chan, "digits/minute", lang); if (!res) res = ast_waitstream(chan, ints); return res; @@ -6710,14 +6824,14 @@ ast_localtime(&tv, &tm, NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) { res = ast_waitstream(chan, ints); } } if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) { res = ast_waitstream(chan, ints); } @@ -6798,7 +6912,7 @@ /* Day of month and month */ if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6809,7 +6923,7 @@ /* Just what day of the week */ if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6836,7 +6950,7 @@ /* Day of month and month */ if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6847,7 +6961,7 @@ /* Just what day of the week */ if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6924,7 +7038,7 @@ /* Day of month and month */ if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -6935,7 +7049,7 @@ /* Just what day of the week */ if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) { res = ast_waitstream(chan, ints); } @@ -6969,7 +7083,7 @@ tmp = (num/10) * 10; left = num - tmp; snprintf(fn, sizeof(fn), "digits/%d", tmp); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); if (left) @@ -7008,7 +7122,7 @@ if (!num) { ast_copy_string(fn, "digits/0", sizeof(fn)); - res = ast_streamfile(chan, fn, chan->language); + res = ast_say_streamfile(chan, fn, chan->language); if (!res) return ast_waitstream(chan, ints); } @@ -7055,7 +7169,7 @@ } } if (!res) { - if (!ast_streamfile(chan, fn, language)) { + if (!ast_say_streamfile(chan, fn, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -7092,7 +7206,7 @@ /* W E E K - D A Y */ if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7103,7 +7217,7 @@ /* M O N T H */ if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7146,23 +7260,23 @@ res = gr_say_number_female(hour, chan, ints, lang); if (tm.tm_min) { if (!res) - res = ast_streamfile(chan, "digits/kai", lang); + res = ast_say_streamfile(chan, "digits/kai", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL); } else { if (!res) - res = ast_streamfile(chan, "digits/hwra", lang); + res = ast_say_streamfile(chan, "digits/hwra", lang); if (!res) res = ast_waitstream(chan, ints); } if (pm) { if (!res) - res = ast_streamfile(chan, "digits/p-m", lang); + res = ast_say_streamfile(chan, "digits/p-m", lang); } else { if (!res) - res = ast_streamfile(chan, "digits/a-m", lang); + res = ast_say_streamfile(chan, "digits/a-m", lang); } if (!res) res = ast_waitstream(chan, ints); @@ -7183,7 +7297,7 @@ /* W E E K - D A Y */ if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7194,7 +7308,7 @@ /* M O N T H */ if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7269,14 +7383,14 @@ /* Minute */ if (tm.tm_min) { if (!res) - res = ast_streamfile(chan, "digits/kai", lang); + res = ast_say_streamfile(chan, "digits/kai", lang); if (!res) res = ast_waitstream(chan, ints); if (!res) res = ast_say_number_full_gr(chan, tm.tm_min, ints, lang, -1, -1); } else { if (!res) - res = ast_streamfile(chan, "digits/oclock", lang); + res = ast_say_streamfile(chan, "digits/oclock", lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7565,7 +7679,7 @@ strncat(new_string, remainder, len); /* we can't sprintf() it, it's not null-terminated. */ /* new_string[len + strlen("digits/")] = '\0'; */ - if (!ast_streamfile(chan, new_string, language)) { + if (!ast_say_streamfile(chan, new_string, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -7587,7 +7701,7 @@ char* new_string = ast_malloc(strlen(remainder) + 1 + strlen("digits/")); sprintf(new_string, "digits/%s", remainder); - if (!ast_streamfile(chan, new_string, language)) { + if (!ast_say_streamfile(chan, new_string, language)) { if ((audiofd > -1) && (ctrlfd > -1)) res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); else @@ -7632,7 +7746,7 @@ if (!res) { snprintf(fn, sizeof(fn), "digits/tslis %d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7646,7 +7760,7 @@ if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7669,7 +7783,7 @@ res = ast_say_number(chan, tm.tm_hour, ints, lang, (char*)NULL); if (!res) { - res = ast_streamfile(chan, "digits/saati_da", lang); + res = ast_say_streamfile(chan, "digits/saati_da", lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7679,7 +7793,7 @@ res = ast_say_number(chan, tm.tm_min, ints, lang, (char*)NULL); if (!res) { - res = ast_streamfile(chan, "digits/tsuti", lang); + res = ast_say_streamfile(chan, "digits/tsuti", lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7727,7 +7841,7 @@ res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL); if (!res) { snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); } @@ -7736,7 +7850,7 @@ /* Just what day of the week */ if (!res) { snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday); - res = ast_streamfile(chan, fn, lang); + res = ast_say_streamfile(chan, fn, lang); if (!res) res = ast_waitstream(chan, ints); }