change dollars and cents to rubles and kopecks

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13025 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Buklov Boris Vladimirovich 2009-04-15 09:40:10 +00:00
parent 3f92f624fd
commit 9b4328e231
1 changed files with 27 additions and 27 deletions

View File

@ -1188,60 +1188,60 @@ static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay,
switch_say_method_t method,switch_input_args_t *args) switch_say_method_t method,switch_input_args_t *args)
{ {
char sbuf[16] = ""; char sbuf[16] = "";
char *dollars = NULL; char *rubles = NULL;
char *cents = NULL; char *kopecks = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_money %s\n",tosay ); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_money %s\n",tosay );
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) { if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
dollars = sbuf; rubles = sbuf;
if ((cents = strchr(sbuf, '.'))) { if ((kopecks = strchr(sbuf, '.'))) {
*cents++ = '\0'; *kopecks++ = '\0';
if (strlen(cents) > 2) { if (strlen(kopecks) > 2) {
cents[2] = '\0'; kopecks[2] = '\0';
} }
} }
if (sbuf[0] == '+') { if (sbuf[0] == '+') {
dollars++; rubles++;
} }
if (sbuf[0] == '-') { if (sbuf[0] == '-') {
say_file("currency/minus.wav"); say_file("currency/minus.wav");
dollars++; rubles++;
} }
ru_say_count(session,dollars ,male,how_much,args); ru_say_count(session,rubles ,male,how_much,args);
int idollars = atoi(dollars)%100; int irubles = atoi(rubles)%100;
int idollar = atoi(dollars)%10; int iruble = atoi(rubles)%10;
if (idollars == 1 || (idollars > 20 && idollar == 1)) {/* рубль */ if (irubles == 1 || (irubles > 20 && iruble == 1)) {/* рубль */
say_file("currency/dollar.wav"); say_file("currency/ruble.wav");
} }
else if ((idollars > 1 && idollars < 5) || (idollars > 20 && idollar > 1 && idollar < 5)) { /*рубля */ else if ((irubles > 1 && irubles < 5) || (irubles > 20 && iruble > 1 && iruble < 5)) { /*рубля */
say_file("currency/dollar1.wav"); say_file("currency/ruble-a.wav");
} }
else { /*рублей */ else { /*рублей */
say_file("currency/dollar2.wav"); say_file("currency/rubles.wav");
} }
/* Say cents */ /* Say kopecks */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " %s\n",cents ); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " %s\n",kopecks );
ru_say_count(session,cents ,female,how_much,args); ru_say_count(session,kopecks ,female,how_much,args);
int icents = atoi(cents)%100; int ikopecks = atoi(kopecks)%100;
int icent = atoi(cents)%10; int ikopeck = atoi(kopecks)%10;
if (icents == 1 || (icents > 20 && icent == 1)) if (ikopecks == 1 || (ikopecks > 20 && ikopeck == 1))
{ {
/* копейка */ /* копейка */
say_file("currency/cent.wav"); say_file("currency/kopeck.wav");
} }
else if ((icents > 1 && icents < 5) || (icents > 20 && icent > 1 && icent < 5)) else if ((ikopecks > 1 && ikopecks < 5) || (ikopecks > 20 && ikopeck > 1 && ikopeck < 5))
{ {
/* копейки */ /* копейки */
say_file("currency/cent1.wav"); say_file("currency/kopeck-i.wav");
} }
else else
{ {
/* копеек */ /* копеек */
say_file("currency/cents.wav"); say_file("currency/kopecks.wav");
} }
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }