--- say.patch3 2004-04-24 23:09:56.000000000 +0200 +++ say.diff7 2004-04-25 01:46:07.000000000 +0200 @@ -4,7 +4,7 @@ retrieving revision 1.114 diff -u -r1.114 pbx.c --- pbx.c 22 Apr 2004 00:27:48 -0000 1.114 -+++ pbx.c 24 Apr 2004 21:04:01 -0000 ++++ pbx.c 24 Apr 2004 23:46:09 -0000 @@ -287,7 +287,7 @@ { "SayNumber", pbx_builtin_saynumber, @@ -14,7 +14,7 @@ { "SayDigits", pbx_builtin_saydigits, "Say Digits", -@@ -4568,9 +4568,28 @@ +@@ -4568,9 +4568,29 @@ static int pbx_builtin_saynumber(struct ast_channel *chan, void *data) { int res = 0; @@ -35,8 +35,9 @@ + strsep(&number, "|"); + options = strsep(&number, "|"); + if (options) { -+ if ( strcasecmp(options, "f") && strcasecmp(options,"m") ) { -+ ast_log(LOG_WARNING, "SayNumber gender option is either 'f' or 'm'\n"); ++ if ( strcasecmp(options, "f") && strcasecmp(options, "m") && ++ strcasecmp(options, "c") && strcasecmp(options, "n") ) { ++ ast_log(LOG_WARNING, "SayNumber gender option is either 'f', 'm', 'c' or 'n'\n"); + return -1; + } + } @@ -52,7 +53,7 @@ retrieving revision 1.16 diff -u -r1.16 say.c --- say.c 20 Feb 2004 17:43:46 -0000 1.16 -+++ say.c 24 Apr 2004 21:04:02 -0000 ++++ say.c 24 Apr 2004 23:46:09 -0000 @@ -27,6 +27,9 @@ #define DIGITS_DIR AST_SOUNDS "/digits/" @@ -88,7 +89,7 @@ +int ast_say_number_full_es(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd); + +int ast_say_number_fr(struct ast_channel *chan, int num, char *ints, char *language); -+int ast_say_number_da(struct ast_channel *chan, int num, char *ints, char *language); ++int ast_say_number_da(struct ast_channel *chan, int num, char *ints, char *language, char *options); +int ast_say_number_en(struct ast_channel *chan, int num, char *ints, char *language); +int ast_say_number_pt(struct ast_channel *chan, int num, char *ints, char *language, char *options); +int ast_say_number_it(struct ast_channel *chan, int num, char *ints, char *language); @@ -130,7 +131,7 @@ + return(ast_say_number_fr(chan, num, ints, language)); + } + if (!strcasecmp(language, "da")) { /* Danish syntax */ -+ return(ast_say_number_da(chan, num, ints, language)); ++ return(ast_say_number_da(chan, num, ints, language, options)); + } + if (!strcasecmp(language, "it")) { /* Italian syntax */ + return(ast_say_number_it(chan, num, ints, language)); @@ -230,7 +231,7 @@ if (res) return res; num = num % 1000000; -@@ -207,10 +277,988 @@ +@@ -207,10 +277,1024 @@ ast_stopstream(chan); } @@ -393,19 +394,30 @@ + +/* ast_say_number_full_da: Danish syntax */ +/* New files: -+ In addition to English, the following sounds are required: "millions", "and" and "1-and" through "9-and" ++ In addition to English, the following sounds are required: "1N", "millions", "and" and "1-and" through "9-and" + */ +int ast_say_number_full_da(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd) +{ + int res = 0; + int playh = 0; + int playa = 0; ++ int cn = 1; /* +1 = Commune; -1 = Neutrum */ + char fn[256] = ""; + if (!num) + return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); ++ ++ /* This hack will be removed and replaced with a new option to ast_say_number* functions */ ++ /* Use negative numbers to force neutrum */ ++ ++ if (num < 0) { /* Neutrum */ ++ cn = -1; ++ num = -num; ++ } ++ + while(!res && (num || playh || playa )) { + /* The grammer for Danish numbers is the same as for English except + * for the following: ++ * - 1 exists in both commune ("en") and neutrum ("et") + * - 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 @@ -421,6 +433,10 @@ + snprintf(fn, sizeof(fn), "digits/and"); + playa = 0; + } else ++ if (num == 1 && cn == -1) { ++ snprintf(fn, sizeof(fn), "digits/1N"); ++ num = 0; ++ } else + if (num < 20) { + snprintf(fn, sizeof(fn), "digits/%d", num); + num = 0; @@ -436,12 +452,18 @@ + } + } else { + if (num < 1000) { -+ snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); ++ int hundreds = num / 100; ++ if (hundreds == 1) ++ snprintf(fn, sizeof(fn), "digits/1N"); ++ else ++ snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); + playh++; -+ num -= ((num / 100) * 100); ++ num -= 100 * hundreds; ++ if (num) ++ playa++; + } else { + if (num < 1000000) { -+ res = ast_say_number_full_da(chan, num / 1000, ints, language, audiofd, ctrlfd); ++ res = ast_say_number_full_da(chan, num / 1000 * cn, ints, language, audiofd, ctrlfd); + if (res) + return res; + num = num % 1000; @@ -457,12 +479,12 @@ + else + snprintf(fn, sizeof(fn), "digits/millions"); + num = num % 1000000; -+ } else { ++ } else { + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + res = -1; + } + } -+ if (num < 100) ++ if (num && num < 100) + playa++; + } + } @@ -478,18 +500,23 @@ +} + +/* Danish */ -+int ast_say_number_da(struct ast_channel *chan, int num, char *ints, char *language) ++int ast_say_number_da(struct ast_channel *chan, int num, char *ints, char *language, char *options) +{ + /* XXX Should I be merged with ast_say_number_full XXX */ + int res = 0; + int playh = 0; + int playa = 0; ++ int cn = 1; /* +1 = Commune; -1 = Neutrum */ + char fn[256] = ""; ++ ++ if (options && !strncasecmp(options, "n", 1)) cn = -1; ++ + if (!num) + return ast_say_digits(chan, 0,ints, language); + while(!res && (num || playh || playa )) { + /* The grammer for Danish numbers is the same as for English except + * for the following: ++ * - 1 exists in both commune ("en") and neutrum ("et") + * - 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 @@ -505,6 +532,10 @@ + snprintf(fn, sizeof(fn), "digits/and"); + playa = 0; + } else ++ if (num == 1 && cn == -1) { ++ snprintf(fn, sizeof(fn), "digits/1N"); ++ num = 0; ++ } else + if (num < 20) { + snprintf(fn, sizeof(fn), "digits/%d", num); + num = 0; @@ -520,12 +551,18 @@ + } + } else { + if (num < 1000) { -+ snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); ++ int hundreds = num / 100; ++ if (hundreds == 1) ++ snprintf(fn, sizeof(fn), "digits/1N"); ++ else ++ snprintf(fn, sizeof(fn), "digits/%d", (num / 100)); + playh++; -+ num -= ((num / 100) * 100); ++ num -= 100 * hundreds; ++ if (num) ++ playa++; + } else { + if (num < 1000000) { -+ res = ast_say_number_da(chan, num / 1000, ints, language); ++ res = ast_say_number_da(chan, num / 1000, ints, language, "N"); + if (res) + return res; + num = num % 1000; @@ -533,7 +570,7 @@ + } else { + if (num < 1000000000) { + int millions = num / 1000000; -+ res = ast_say_number_da(chan, millions, ints, language); ++ res = ast_say_number_da(chan, millions, ints, language, "C"); + if (res) + return res; + if (millions == 1) @@ -546,7 +583,7 @@ + res = -1; + } + } -+ if (num < 100) ++ if (num && num < 100) + playa++; + } + } @@ -1220,7 +1257,7 @@ int ast_say_date(struct ast_channel *chan, time_t t, char *ints, char *lang) { struct tm tm; -@@ -230,12 +1278,13 @@ +@@ -230,12 +1314,13 @@ res = ast_waitstream(chan, ints); } if (!res) @@ -1236,7 +1273,7 @@ return res; } -@@ -545,21 +1594,21 @@ +@@ -545,21 +1630,21 @@ pm = 1; } if (!res) @@ -1263,7 +1300,7 @@ if (!res) res = ast_waitstream(chan, ints); } -@@ -595,7 +1644,7 @@ +@@ -595,7 +1680,7 @@ res = ast_waitstream(chan, ints); } if (!res) @@ -1272,7 +1309,7 @@ hour = tm.tm_hour; if (!hour) -@@ -607,18 +1656,18 @@ +@@ -607,18 +1692,18 @@ pm = 1; } if (!res) @@ -1294,7 +1331,7 @@ } else { if (!res) res = ast_streamfile(chan, "digits/oclock", lang); -@@ -635,7 +1684,7 @@ +@@ -635,7 +1720,7 @@ if (!res) res = ast_waitstream(chan, ints); if (!res) @@ -1303,7 +1340,7 @@ return res; } -@@ -662,7 +1711,7 @@ +@@ -662,7 +1747,7 @@ res = ast_waitstream(chan, ints); } if (!res) @@ -1312,105 +1349,3 @@ } else if (daydiff) { /* Just what day of the week */ -Index: include/asterisk/say.h -=================================================================== -RCS file: /usr/cvsroot/asterisk/include/asterisk/say.h,v -retrieving revision 1.7 -diff -u -r1.7 say.h ---- include/asterisk/say.h 13 Sep 2003 20:51:48 -0000 1.7 -+++ include/asterisk/say.h 24 Apr 2004 21:04:02 -0000 -@@ -29,10 +29,11 @@ - * \param num number to say on the channel - * \param ints which dtmf to interrupt on - * \param lang language to speak the number -+ * \param options set to 'f' for female, 'm' for masculine (used in portuguese) - * Vocally says a number on a given channel - * Returns 0 on success, DTMF digit on interrupt, -1 on failure - */ --int ast_say_number(struct ast_channel *chan, int num, char *ints, char *lang); -+int ast_say_number(struct ast_channel *chan, int num, char *ints, char *lang, char *options); - - /* Same as above with audiofd for received audio and returns 1 on ctrlfd being readable */ - int ast_say_number_full(struct ast_channel *chan, int num, char *ints, char *lang, int audiofd, int ctrlfd); -Index: apps/app_meetme.c -=================================================================== -RCS file: /usr/cvsroot/asterisk/apps/app_meetme.c,v -retrieving revision 1.23 -diff -u -r1.23 app_meetme.c ---- apps/app_meetme.c 8 Apr 2004 19:38:26 -0000 1.23 -+++ apps/app_meetme.c 24 Apr 2004 21:04:02 -0000 -@@ -621,7 +621,7 @@ - } else { - if (chan->_state != AST_STATE_UP) - ast_answer(chan); -- res = ast_say_number(chan, count, "", chan->language); -+ res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */ - } - LOCAL_USER_REMOVE(u); - return res; -Index: apps/app_queue.c -=================================================================== -RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v -retrieving revision 1.55 -diff -u -r1.55 app_queue.c ---- apps/app_queue.c 10 Apr 2004 21:10:22 -0000 1.55 -+++ apps/app_queue.c 24 Apr 2004 21:04:03 -0000 -@@ -365,7 +365,7 @@ - goto posout; - } else { - res += play_file(qe->chan, qe->parent->sound_thereare); -- res += ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language); -+ res += ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language, (char *) NULL); /* Needs gender */ - res += play_file(qe->chan, qe->parent->sound_calls); - } - -Index: apps/app_voicemail.c -=================================================================== -RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v -retrieving revision 1.76 -diff -u -r1.76 app_voicemail.c ---- apps/app_voicemail.c 19 Apr 2004 23:27:37 -0000 1.76 -+++ apps/app_voicemail.c 24 Apr 2004 21:04:04 -0000 -@@ -1627,7 +1627,7 @@ - static int say_and_wait(struct ast_channel *chan, int num) - { - int d; -- d = ast_say_number(chan, num, AST_DIGIT_ANY, chan->language); -+ d = ast_say_number(chan, num, AST_DIGIT_ANY, chan->language, (char *) NULL); - return d; - } - -@@ -2191,7 +2191,7 @@ - if (d) - return d; - for (x = start; x< 5; x++) { -- if ((d = ast_say_number(chan, x, AST_DIGIT_ANY, chan->language))) -+ if ((d = ast_say_number(chan, x, AST_DIGIT_ANY, chan->language, (char *) NULL))) - return d; - d = play_and_wait(chan, "vm-for"); - if (d) -@@ -2499,7 +2499,7 @@ - res = wait_file2(chan, vms, "vm-message"); - if (msg && (msg != vms->lastmsg)) { - if (!res) -- res = ast_say_number(chan, msg + 1, AST_DIGIT_ANY, chan->language); -+ res = ast_say_number(chan, msg + 1, AST_DIGIT_ANY, chan->language, (char *) NULL); - } - } - -Index: apps/app_zapscan.c -=================================================================== -RCS file: /usr/cvsroot/asterisk/apps/app_zapscan.c,v -retrieving revision 1.8 -diff -u -r1.8 app_zapscan.c ---- apps/app_zapscan.c 10 Apr 2004 02:49:06 -0000 1.8 -+++ apps/app_zapscan.c 24 Apr 2004 21:04:04 -0000 -@@ -322,7 +322,7 @@ - } - confno = atoi(strchr(confstr,'/') + 1); - ast_stopstream(chan); -- ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language); -+ ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language, (char *) NULL); - res = conf_run(chan, confno, confflags); - if (res<0) break; - input = res;