Index: main/say.c =================================================================== --- main/say.c (revision 49053) +++ main/say.c (working copy) @@ -274,6 +274,7 @@ \arg \b se - Swedish \arg \b tw - Taiwanese / Chinese \arg \b ru - Russian + \arg \b lt - Lithuanian \par Gender: For Some languages the numbers differ for gender and plural. @@ -328,6 +329,7 @@ static int ast_say_number_full_tw(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); static int ast_say_number_full_gr(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd); +static int ast_say_number_full_lt(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); /* Forward declarations of language specific variants of ast_say_enumeration_full */ static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); @@ -426,7 +428,9 @@ return(ast_say_number_full_gr(chan, num, ints, language, audiofd, ctrlfd)); } else if (!strcasecmp(language, "ru") ) { /* Russian syntax */ return(ast_say_number_full_ru(chan, num, ints, language, options, audiofd, ctrlfd)); - } + } else if (!strcasecmp(language, "lt") ) { /* Lithuanian syntax */ + return(ast_say_number_full_lt(chan, num, ints, language, audiofd, ctrlfd)); + } /* Default to english */ return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd)); @@ -2264,6 +2268,130 @@ } +/*! \brief get_lastdigits_lt: determine last digits for thousands/millions (lt) */ +static int get_lastdigits_lt(int num); +static int get_lastdigits_lt(int num) +{ + if (num < 20) + { + return num; + } else if (num < 100) { + return get_lastdigits_lt(num - ((num / 10) * 10)); + } else if (num < 1000) { + return get_lastdigits_lt(num - ((num / 100) * 100)); + } + return 0; /* number too big */ +} + +/*! \brief ast_say_number_full_lt: Lithuanian syntax + Required sound files in digits: + thousand.gsm + thousands.gsm + i-thousand.gsm where 'i' from 1 to 19 + hundred.gsm + million.gsm + mln.gsm + mln-u.gsm + mln-ai.gsm + i.gsm where 'i' from 1 to 19 + 100.gsm + 100-ai.gsm + 100-u.gsm + 1000.gsm + 1000-ai.gsm + 1000-u.gsm + i0.gsm where 'i' from 2 to 9 + i00.gsm where 'i' from 2 to 9 +*/ +static int ast_say_number_full_lt(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd) +{ + int res = 0; + int lastdigits = 0; + char fn[256] = ""; + if (!num) + return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); + + while(!res && (num)) + { + if (num < 0) + { + snprintf(fn, sizeof(fn), "digits/minus"); + if ( num > INT_MIN ) + { + num = -num; + } + else + { + num = 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) + { + snprintf(fn, sizeof(fn), "digits/%d", ((num/100) * 100)); + num -= ((num / 100) * 100); + } + else + { + if (num < 1000000) + { /* 1,000,000 */ + lastdigits = get_lastdigits_lt(num / 1000); + if (lastdigits > 9) + { /* from 10 to 19 */ + res = ast_say_number_full_lt(chan, lastdigits, ints, language, audiofd, ctrlfd); + if (res) + return res; + snprintf(fn, sizeof(fn), "digits/thousands"); + } + else if (lastdigits < 10 && lastdigits != 0) + { /* from 1 to 9, actual numbers more than 19 */ + if (((num / 1000) - lastdigits) > 19) + { + res = ast_say_number_full_lt(chan, (num / 1000) - lastdigits, ints, language, audiofd, ctrlfd); + if (res) + return res; + } + snprintf(fn, sizeof(fn), "digits/%d-thousand", lastdigits); + } + else if (lastdigits == 0) + { + snprintf(fn, sizeof(fn), "digits/thousands"); + } + num -= ((num / 1000) * 1000); + } + 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 > -1) && (ctrlfd > -1)) + res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); + else + res = ast_waitstream(chan, ints); + } + ast_stopstream(chan); + } + } + return res; +} + + /*! \brief ast_say_enumeration_full: call language-specific functions */ /* Called from AGI */ static int say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)