Index: say.c =================================================================== RCS file: /usr/cvsroot/asterisk/say.c,v retrieving revision 1.38 diff -u -r1.38 say.c --- say.c 24 Sep 2004 22:15:43 -0000 1.38 +++ say.c 19 Oct 2004 21:43:06 -0000 @@ -444,6 +444,7 @@ /* Forward declarations of language specific variants of ast_say_number_full */ static int ast_say_number_full_en(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd); +static int ast_say_number_full_en_GB(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd); static int ast_say_number_full_da(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd); static int ast_say_number_full_de(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd); static int ast_say_number_full_es(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd); @@ -501,6 +502,10 @@ return(ast_say_number_full_da(chan, num, ints, language, options, audiofd, ctrlfd)); } else if (!strcasecmp(language, "de") ) { /* German syntax */ return(ast_say_number_full_de(chan, num, ints, language, options, audiofd, ctrlfd)); + } else if (!strcasecmp(language, "en_GB") ) { /* British syntax */ + return(ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd)); + } else if (!strcasecmp(language, "no") ) { /* Norwegian == British syntax */ + return(ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd)); } else if (!strcasecmp(language, "es") || !strcasecmp(language, "mx")) { /* Spanish syntax */ return(ast_say_number_full_es(chan, num, ints, language, options, audiofd, ctrlfd)); } else if (!strcasecmp(language, "fr") ) { /* French syntax */ @@ -693,6 +698,7 @@ return res; } + /*--- ast_say_number_full_de: German syntax */ /* New files: In addition to English, the following sounds are required: @@ -810,6 +816,86 @@ return res; } +/*--- ast_say_number_full_en_GB: British and Norwegian syntax */ +/* New files: + In addition to American English, the following sounds are required: "and" + */ +static int ast_say_number_full_en_GB(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd) +{ + int res = 0; + int playh = 0; + int playa = 0; + char fn[256] = ""; + if (!num) + return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); + + while(!res && (num || playh || playa )) { + /* The grammar for Danish numbers is the same as for English except + * for the following: + * - 1 exists in both commune ("en", file "1N") and neutrum ("et", file "1") + * - numbers 20 through 99 are said in reverse order, i.e. 21 is + * "one-and twenty" and 68 is "eight-and sixty". + * - "million" is different in singular and plural form + * - numbers > 1000 with zero as the third digit from last have an + * "and" before the last two digits, i.e. 2034 is "two thousand and + * four-and thirty" and 1000012 is "one million and twelve". + */ + if (playh) { + snprintf(fn, sizeof(fn), "digits/hundred"); + playh = 0; + } else if (playa) { + snprintf(fn, sizeof(fn), "digits/and"); + playa = 0; + } else if (num < 20) { + snprintf(fn, sizeof(fn), "digits/%d", num); + num = 0; + } else if (num < 100) { + snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); + num -= ((num / 10) * 10); + } else if (num < 1000) { + int hundreds = num / 100; + snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); + + playh++; + num -= 100 * hundreds; + if (num) + playa++; + } else if (num < 1000000) { + res = ast_say_number_full_en_GB(chan, num / 1000, ints, language, audiofd, ctrlfd); + if (res) + return res; + snprintf(fn, sizeof(fn), "digits/thousand"); + num = num % 1000; + if (num && num < 100) + playa++; + } else if (num < 1000000000) { + int millions = num / 1000000; + res = ast_say_number_full_en_GB(chan, millions, ints, language, audiofd, ctrlfd); + if (res) + return res; + snprintf(fn, sizeof(fn), "digits/million"); + num = num % 1000000; + if (num && num < 100) + playa++; + } else { + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + res = -1; + } + + if (!res) { + if(!ast_streamfile(chan, fn, language)) { + if (audiofd && ctrlfd) + res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); + else + res = ast_waitstream(chan, ints); + } + ast_stopstream(chan); + } + } + return res; +} + + /*--- ast_say_number_full_es: Spanish syntax */ /* New files: Requires a few new audios: @@ -1995,17 +2081,7 @@ case 'Y': /* Year */ if (tm.tm_year > 99) { - res = wait_file(chan,ints, "digits/2",lang); - if (!res) { - res = wait_file(chan,ints, "digits/thousand",lang); - } - if (tm.tm_year > 100) { - if (!res) { - /* This works until the end of 2020 */ - snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year - 100); - res = wait_file(chan,ints,nextmsg,lang); - } - } + res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); } else { if (tm.tm_year < 1) { /* I'm not going to handle 1900 and prior */ @@ -2276,17 +2352,7 @@ case 'Y': /* Year */ if (tm.tm_year > 99) { - res = wait_file(chan,ints, "digits/2",lang); - if (!res) { - res = wait_file(chan,ints, "digits/thousand",lang); - } - if (tm.tm_year > 100) { - if (!res) { - /* This works until the end of 2020 */ - snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year - 100); - res = wait_file(chan,ints,nextmsg,lang); - } - } + res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL); } else { if (tm.tm_year < 1) { /* I'm not going to handle 1900 and prior */