diff -Naur asterisk.org/say.c asterisk.new/say.c --- asterisk.org/say.c 2004-12-22 15:18:32.000000000 +0900 +++ asterisk.new/say.c 2005-05-29 22:09:45.000000000 +0900 @@ -455,6 +455,7 @@ static int ast_say_number_full_se(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd); static int ast_say_number_full_tw(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd); static int ast_say_number_full_cz(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd); +static int ast_say_number_full_jp(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd); /* Forward declarations of ast_say_date, ast_say_datetime and ast_say_time functions */ static int ast_say_date_en(struct ast_channel *chan, time_t t, char *ints, char *lang); @@ -519,6 +520,8 @@ return(ast_say_number_full_tw(chan, num, ints, language, audiofd, ctrlfd)); } else if (!strcasecmp(language, "cz") ) { /* Czech syntax */ return(ast_say_number_full_cz(chan, num, ints, language, options, audiofd, ctrlfd)); + } else if (!strcasecmp(language, "jp") ) { /* Japanese syntax */ + return(ast_say_number_full_jp(chan, num, ints, language, options, audiofd, ctrlfd)); } /* Default to english */ @@ -1820,6 +1823,89 @@ return res; } +/*--- ast_say_number_full_jp: Japanese syntax */ + +static int ast_say_number_full_jp(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd) +{ + int playh = 0 ; + int res = 0 ; + char fn[256] = ""; + + if (!num) + { + return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); + } + + while( !res && (num || playh) ) + { + if (playh > 0) + { + switch( playh ) + { + case 100: + snprintf(fn, sizeof(fn), "digits/100"); + break ; + case 1000: + snprintf(fn, sizeof(fn), "digits/1000"); + break ; + case 10000: + snprintf(fn, sizeof(fn), "digits/10000"); + break ; + case 100000000: + snprintf(fn, sizeof(fn), "digits/100000000"); + break ; + } + playh = 0; + } else if (num < 10) { + 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) { + if ( num / 100 != 1 ) + { + snprintf(fn, sizeof(fn), "digits/%d", (num/100)); + playh = 100 ; + num -= ((num / 100) * 100); + } else { + snprintf(fn, sizeof(fn), "digits/100"); + num -= 100 ; + } + } else if (num < 10000) { + if ( num / 1000 != 1 ) + { + snprintf(fn, sizeof(fn), "digits/%d", (num/1000)) ; + playh = 1000 ; + num -= ((num / 1000) * 1000); + } else { + snprintf(fn, sizeof(fn), "digits/1000") ; + num -= 1000 ; + } + } else if (num < 100000000) { + res = ast_say_number_full_jp(chan, num / 10000, ints, language, options, audiofd, ctrlfd); + if (res) + return res; + playh = 10000 ; + num -= ((num / 10000) * 10000); + } else { + ast_log(LOG_WARNING, "Number '%d' is too big for me\n", num); + res = -1; + } + if (!res) + { + if(!ast_streamfile(chan, fn, language)) + { + if ((audiofd > -1) && (ctrlfd > -1)) + res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); + else + res = ast_waitstream(chan, ints); + } + ast_stopstream(chan); + } + } + return res; +} int ast_say_date(struct ast_channel *chan, time_t t, char *ints, char *lang) {