run indent on the whole tree and update copyright dates in prep for 1.0.5

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16579 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2010-02-06 03:38:24 +00:00
1 parent 7b347417e5
commit 886e1ddb4d
229 files changed
+20252 -20192

No files matched your search

+10 -10
View File
@@ -101,11 +101,11 @@ static switch_status_t play_group(switch_say_method_t method, int a, int b, int
if (b) {
if (b > 1) {
if ((c==0) && (method == SSM_COUNTED)) {
say_file("digits/h-%d0.wav", b);
} else {
say_file("digits/%d0.wav", b);
}
if ((c == 0) && (method == SSM_COUNTED)) {
say_file("digits/h-%d0.wav", b);
} else {
say_file("digits/%d0.wav", b);
}
} else {
say_file("digits/%d%d.wav", b, c);
c = 0;
@@ -277,7 +277,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *tz = switch_channel_get_variable(channel, "timezone");
if (type == SST_TIME_MEASUREMENT) {
int64_t hours = 0;
int64_t minutes = 0;
@@ -365,7 +365,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
target = switch_micro_time_now();
target_now = switch_micro_time_now();
}
if (tz) {
int check = atoi(tz);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
@@ -415,7 +415,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
}
say_month = say_day = say_dow = 1;
break;
default:
break;
@@ -449,9 +449,9 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
if (say_time) {
int32_t hour = tm.tm_hour, pm = 0;
if (say_date || say_today || say_yesterday || say_dow) {
if (say_date || say_today || say_yesterday || say_dow) {
say_file("time/at.wav");
}
}
if (hour > 12) {
hour -= 12;
+60 -60
View File
@@ -91,67 +91,67 @@ static switch_status_t es_spell(switch_core_session_t *session, char *tosay, swi
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, switch_core_session_t *session,switch_input_args_t *args)
{
if (a) {
switch(a) {
case 1:
if (b || c) {
say_file("digits/hundred.wav");
} else {
say_file("digits/100.wav");
}
break;
case 5:
say_file("digits/500.wav");
break;
case 7:
say_file("digits/700.wav");
break;
case 9:
say_file("digits/900.wav");
break;
default:
say_file("digits/%d.wav", a);
say_file("digits/hundred.wav");
break;
}
}
static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, switch_core_session_t *session, switch_input_args_t *args)
{
if (a) {
switch (a) {
case 1:
if (b || c) {
say_file("digits/hundred.wav");
} else {
say_file("digits/100.wav");
}
break;
case 5:
say_file("digits/500.wav");
break;
case 7:
say_file("digits/700.wav");
break;
case 9:
say_file("digits/900.wav");
break;
default:
say_file("digits/%d.wav", a);
say_file("digits/hundred.wav");
break;
}
}
if (b) {
if (b > 1) {
switch (b) {
case 2: if (c) {
say_file("digits/veinti.wav");
} else {
say_file("digits/20.wav");
}
break;
default:
say_file("digits/%d0.wav", b);
if (c)
{
say_file("currency/and.wav");
}
break;
}
} else {
say_file("digits/%d%d.wav", b, c);
c = 0;
}
}
if (c) {
if (method == SSM_COUNTED) {
say_file("digits/h-%d.wav", c);
} else {
say_file("digits/%d.wav", c);
}
}
if (what && (a || b || c)) {
say_file(what);
}
return SWITCH_STATUS_SUCCESS;
}
if (b) {
if (b > 1) {
switch (b) {
case 2:
if (c) {
say_file("digits/veinti.wav");
} else {
say_file("digits/20.wav");
}
break;
default:
say_file("digits/%d0.wav", b);
if (c) {
say_file("currency/and.wav");
}
break;
}
} else {
say_file("digits/%d%d.wav", b, c);
c = 0;
}
}
if (c) {
if (method == SSM_COUNTED) {
say_file("digits/h-%d.wav", c);
} else {
say_file("digits/%d.wav", c);
}
}
if (what && (a || b || c)) {
say_file(what);
}
return SWITCH_STATUS_SUCCESS;
}
static char *strip_commas(char *in, char *out, switch_size_t len)
{
+14 -11
View File
@@ -91,7 +91,8 @@ static switch_status_t hu_spell(switch_core_session_t *session, char *tosay, swi
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, int tosay, switch_core_session_t *session, switch_input_args_t *args)
static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, int tosay, switch_core_session_t *session,
switch_input_args_t *args)
{
if (a) {
say_file("digits/%d.wav", a);
@@ -100,11 +101,11 @@ static switch_status_t play_group(switch_say_method_t method, int a, int b, int
if (b) {
if (b > 2) {
if ((c==0) && (method == SSM_COUNTED)) {
say_file("digits/h-%d0.wav", b);
} else {
say_file("digits/%d0.wav", b);
}
if ((c == 0) && (method == SSM_COUNTED)) {
say_file("digits/h-%d0.wav", b);
} else {
say_file("digits/%d0.wav", b);
}
} else {
say_file("digits/%d%d.wav", b, c);
c = 0;
@@ -198,10 +199,12 @@ static switch_status_t hu_say_general_count(switch_core_session_t *session,
switch (method) {
case SSM_COUNTED:
case SSM_PRONOUNCED:
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
if ((status =
play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
return status;
}
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
if ((status =
play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
return status;
}
if ((status = play_group(method, places[2], places[1], places[0], NULL, number, session, args)) != SWITCH_STATUS_SUCCESS) {
@@ -273,7 +276,7 @@ static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay,
uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *tz = switch_channel_get_variable(channel, "timezone");
if (type == SST_TIME_MEASUREMENT) {
int64_t hours = 0;
int64_t minutes = 0;
@@ -349,7 +352,7 @@ static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay,
target = switch_micro_time_now();
target_now = switch_micro_time_now();
}
if (tz) {
int check = atoi(tz);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
@@ -399,7 +402,7 @@ static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay,
}
say_month = say_day = say_dow = 1;
break;
default:
break;
+56 -55
View File
@@ -181,65 +181,66 @@ static switch_status_t it_say_general_count(switch_core_session_t *session,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
/* Get in */
in = atoi(tosay);
/* Check if number too big */
if (in > 999999999) {
/* Fail */
return SWITCH_STATUS_FALSE;
}
/* Check if number isin't zero */
/* Get in */
in = atoi(tosay);
/* Check if number too big */
if (in > 999999999) {
/* Fail */
return SWITCH_STATUS_FALSE;
}
/* Check if number isin't zero */
if (in != 0) {
/* Init x to 0 */
places_count = 0;
/* Loop until in is greater than zero */
do {
/* Get last digit */
places[places_count] = in % 10;
/* Drop last digit */
in = in / 10;
}
while(in > 0 && ++places_count > 0 /* fake check to put in while */);
/* Init x to 0 */
places_count = 0;
/* Loop until in is greater than zero */
do {
/* Get last digit */
places[places_count] = in % 10;
/* Drop last digit */
in = in / 10;
}
while (in > 0 && ++places_count > 0 /* fake check to put in while */ );
switch (method) {
case SSM_COUNTED:
case SSM_PRONOUNCED:
/* Check for milions */
if (places_count > 5) {
/* Check if the millions digit is one (digit 6 = 1, digit 7 and 8 = 0) */
if (places[6] == 1 && places[7] == 0 && places[8] == 0) {
say_file("digits/un.wav");
say_file("digits/million.wav");
} else {
/* Play millions group (digits/million.wav should be digits/millions.wav) */
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
return status;
}
}
}
/* Check for thousands */
if (places_count > 2) {
if (places[3] == 1 && places[4] == 0 && places[5] == 0) {
say_file("digits/thousand.wav");
} else {
/* Play thousand group */
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3],
/* Check for milions */
if (places_count > 5) {
/* Check if the millions digit is one (digit 6 = 1, digit 7 and 8 = 0) */
if (places[6] == 1 && places[7] == 0 && places[8] == 0) {
say_file("digits/un.wav");
say_file("digits/million.wav");
} else {
/* Play millions group (digits/million.wav should be digits/millions.wav) */
if ((status =
play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
return status;
}
}
}
/* Check for thousands */
if (places_count > 2) {
if (places[3] == 1 && places[4] == 0 && places[5] == 0) {
say_file("digits/thousand.wav");
} else {
/* Play thousand group */
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3],
"digits/thousands.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
return status;
}
}
}
/* Play last group */
return status;
}
}
}
/* Play last group */
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
return status;
}
@@ -417,11 +418,11 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay,
}
if (say_time) {
say_file("time/hours.wav");
say_file("time/hours.wav");
say_num(tm.tm_hour, SSM_PRONOUNCED);
if (tm.tm_min) {
say_file("time/and.wav");
say_file("time/and.wav");
say_num(tm.tm_min, SSM_PRONOUNCED);
}
}
+184 -181
View File
@@ -49,13 +49,14 @@
#include "mod_say_ru.h"
/* инициализируем массив вариантов произношения цифр описано в define mod_say_ru.h */
struct say_t matrix[7][8]= {{m_00, m_01, m_02, m_03, m_04, m_05, m_06, m_07},
{m_10, m_11, m_12, m_13, m_14, m_15, m_16, m_17},
{m_20, m_21, m_22, m_23, m_24, m_25, m_26, m_27},
{m_30, m_31, m_32, m_33, m_34, m_35, m_36, m_37},
{m_40, m_41, m_42, m_43, m_44, m_45, m_46, m_47},
{m_50, m_51, m_52, m_53, m_54, m_55, m_56, m_57},
{m_60, m_61, m_62, m_63, m_64, m_65, m_66, m_67}};
struct say_t matrix[7][8] = { {m_00, m_01, m_02, m_03, m_04, m_05, m_06, m_07},
{m_10, m_11, m_12, m_13, m_14, m_15, m_16, m_17},
{m_20, m_21, m_22, m_23, m_24, m_25, m_26, m_27},
{m_30, m_31, m_32, m_33, m_34, m_35, m_36, m_37},
{m_40, m_41, m_42, m_43, m_44, m_45, m_46, m_47},
{m_50, m_51, m_52, m_53, m_54, m_55, m_56, m_57},
{m_60, m_61, m_62, m_63, m_64, m_65, m_66, m_67}
};
SWITCH_MODULE_LOAD_FUNCTION(mod_say_ru_load);
SWITCH_MODULE_DEFINITION(mod_say_ru, mod_say_ru_load, NULL, NULL);
@@ -108,8 +109,8 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
}
}
return ret;
}
}
static switch_status_t ru_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
char *p;
@@ -133,83 +134,83 @@ static switch_status_t play_group(say_type_t say_type, casus_t casus, int a, int
unit_t what, switch_core_session_t *session, switch_input_args_t *args)
{
if (a) {
if (((b==0)&&(c==0))||(matrix[casus][say_type].all==1)) { //если b и с равны 0 то сказать шестьсот, сестисотый, шестисотая
if (what==million) { //префикс число окончание
if (((b == 0) && (c == 0)) || (matrix[casus][say_type].all == 1)) { //если b и с равны 0 то сказать шестьсот, сестисотый, шестисотая
if (what == million) { //префикс число окончание
say_file("digits/%s%d00%s.wav", matrix[casus][say_type].million[12], a, matrix[casus][say_type].million[13]);
say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
} else if (what==thousand) {
} else if (what == thousand) {
say_file("digits/%s%d00%s.wav", matrix[casus][say_type].thousand[12], a, matrix[casus][say_type].thousand[13]);
say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
} else {
say_file("digits/%s%d00%s.wav", matrix[casus][say_type].num[6], a, matrix[casus][say_type].num[7]);
}
} else { //если дальше есть цифры то тысячи и миллионы не прозносить пока
say_file("digits/%d00.wav",a);
} else { //если дальше есть цифры то тысячи и миллионы не прозносить пока
say_file("digits/%d00.wav", a);
}
}
if (b) {
if (b>1) { //если 20 и больше
if ((c==0)||(matrix[casus][say_type].all==1)) { //если с равны 0 то сказать 20, двадцати, двадцатая
if (what==million) { //префикс число окончание
if (b > 1) { //если 20 и больше
if ((c == 0) || (matrix[casus][say_type].all == 1)) { //если с равны 0 то сказать 20, двадцати, двадцатая
if (what == million) { //префикс число окончание
say_file("digits/%s%d0%s.wav", matrix[casus][say_type].million[12], b, matrix[casus][say_type].million[13]);
say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
} else if (what==thousand) {
} else if (what == thousand) {
say_file("digits/%s%d0%s.wav", matrix[casus][say_type].thousand[12], b, matrix[casus][say_type].thousand[13]);
say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
} else {
say_file("digits/%s%d0%s.wav", matrix[casus][say_type].num[6], b, matrix[casus][say_type].num[7]);
}
} else { //если есть дальше цифры
say_file("digits/%d0.wav",b);
} else { //если есть дальше цифры
say_file("digits/%d0.wav", b);
}
} else { //от 10 до 19
if (what==million) {
} else { //от 10 до 19
if (what == million) {
say_file("digits/%s%d%d%s.wav", matrix[casus][say_type].million[12], b, c, matrix[casus][say_type].million[13]);
say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
} else if (what==thousand) {
} else if (what == thousand) {
say_file("digits/%s%d%d%s.wav", matrix[casus][say_type].thousand[12], b, c, matrix[casus][say_type].thousand[13]);
say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
} else { //просто произнести цифры с префиксом и окончанием
} else { //просто произнести цифры с префиксом и окончанием
say_file("digits/%s%d%d%s.wav", matrix[casus][say_type].num[6], b, c, matrix[casus][say_type].num[7]);
}
c=0;
c = 0;
}
}
if (c||what==zero) {
if (c<=5) {
if (what==million) {
if ((strlen(matrix[casus][say_type].million[c*2])) > 0) { // не произносить если не заданно например 1 миллион а просто миллион
say_file("digits/%s.wav", matrix[casus][say_type].million[c*2])
if (c || what == zero) {
if (c <= 5) {
if (what == million) {
if ((strlen(matrix[casus][say_type].million[c * 2])) > 0) { // не произносить если не заданно например 1 миллион а просто миллион
say_file("digits/%s.wav", matrix[casus][say_type].million[c * 2])
}
say_file("digits/%s.wav", matrix[casus][say_type].million[c*2+1]);
} else if (what==thousand) {
if ((strlen(matrix[casus][say_type].thousand[c*2])) > 0) { // не произносить если не заданно например одна тысячас а просто тысяча
say_file("digits/%s.wav", matrix[casus][say_type].thousand[c*2])
say_file("digits/%s.wav", matrix[casus][say_type].million[c * 2 + 1]);
} else if (what == thousand) {
if ((strlen(matrix[casus][say_type].thousand[c * 2])) > 0) { // не произносить если не заданно например одна тысячас а просто тысяча
say_file("digits/%s.wav", matrix[casus][say_type].thousand[c * 2])
}
say_file("digits/%s.wav", matrix[casus][say_type].thousand[c*2+1]);
} else { //просто произнести цифры с префиксом и окончанием
say_file("digits/%s.wav", matrix[casus][say_type].thousand[c * 2 + 1]);
} else { //просто произнести цифры с префиксом и окончанием
say_file("digits/%s.wav", matrix[casus][say_type].num[c]);
}
} else /* больше 5 */ {
if (what==million) {
} else { /* больше 5 */
if (what == million) {
say_file("digits/%s%d%s.wav", matrix[casus][say_type].million[12], c, matrix[casus][say_type].million[13]);
say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
} else if (what==thousand) {
} else if (what == thousand) {
say_file("digits/%s%d%s.wav", matrix[casus][say_type].thousand[12], c, matrix[casus][say_type].thousand[13]);
say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
} else { //просто произнести цифры с префиксом и окончанием
} else { //просто произнести цифры с префиксом и окончанием
say_file("digits/%s%d%s.wav", matrix[casus][say_type].num[6], c, matrix[casus][say_type].num[7]);
}
}
}
return SWITCH_STATUS_SUCCESS;
}
}
static switch_status_t ru_say_count(switch_core_session_t *session,
char *tosay, say_type_t say_type, casus_t casus, switch_input_args_t *args)
static switch_status_t ru_say_count(switch_core_session_t *session, char *tosay, say_type_t say_type, casus_t casus, switch_input_args_t *args)
{
int in;
int x = 0;
@@ -237,41 +238,45 @@ static switch_status_t ru_say_count(switch_core_session_t *session,
}
}
//миллионы
if (places[8] || places[7] || places[6]) {
if ((in_%1000000>0)&&(matrix[casus][say_type].all != 1)) {// если поле миллионов есть цифры поизнести как числительое именительного падежа
//миллионы
if (places[8] || places[7] || places[6]) {
if ((in_ % 1000000 > 0) && (matrix[casus][say_type].all != 1)) { // если поле миллионов есть цифры поизнести как числительое именительного падежа
if ((status = play_group(male_c, nominativus, places[8], places[7], places[6], million, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],status);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],
status);
return status;
}
} else {// иначе произнести в нужном падеже
if ((status = play_group(say_type,casus, places[8], places[7], places[6],million, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],status);
} else { // иначе произнести в нужном падеже
if ((status = play_group(say_type, casus, places[8], places[7], places[6], million, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],
status);
return status;
}
}
}
//тысячи
if (places[5]||places[4]||places[3]) {
if ((in_%1000>0)&&(matrix[casus][say_type].all != 1)) {// если поле миллионов есть цифры поизнести как числительое именительного падежа
if ((status = play_group(male_c, nominativus, places[5], places[4], places[3],thousand, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],status);
//тысячи
if (places[5] || places[4] || places[3]) {
if ((in_ % 1000 > 0) && (matrix[casus][say_type].all != 1)) { // если поле миллионов есть цифры поизнести как числительое именительного падежа
if ((status = play_group(male_c, nominativus, places[5], places[4], places[3], thousand, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],
status);
return status;
}
} else {// иначе произнести в нужном падеже
if ((status = play_group(say_type, casus, places[5], places[4], places[3], thousand,session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],status);
} else { // иначе произнести в нужном падеже
if ((status = play_group(say_type, casus, places[5], places[4], places[3], thousand, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],
status);
return status;
}
}
}
// сотни
if ((status = play_group(say_type, casus, places[2], places[1], places[0], empty, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],status);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3], status);
return status;
}
} else {
if ((status = play_group(say_type, casus, places[2], places[1], places[0], zero, session, args)) != SWITCH_STATUS_SUCCESS) {
} else {
if ((status = play_group(say_type, casus, places[2], places[1], places[0], zero, session, args)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d other!\n", places[2], places[1], places[0]);
return status;
}
@@ -285,26 +290,26 @@ static switch_status_t ru_say_general_count(switch_core_session_t *session,
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
switch_status_t status;
casus_t casus; //падеж
say_type_t say_type;//тип произношения
casus_t casus; //падеж
say_type_t say_type; //тип произношения
switch (type) {
case SST_MESSAGES:
say_type=it_c;
casus=nominativus;
break;
default:
say_type=male_c;
casus=nominativus;
break;
case SST_MESSAGES:
say_type = it_c;
casus = nominativus;
break;
default:
say_type = male_c;
casus = nominativus;
break;
};
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " type=%d casus=%d\n", say_type,casus);
status=ru_say_count(session,tosay,say_type,casus,args);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " type=%d casus=%d\n", say_type, casus);
status = ru_say_count(session, tosay, say_type, casus, args);
return status;
}
static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type,
switch_say_method_t method,switch_input_args_t *args)
switch_say_method_t method, switch_input_args_t *args)
{
char sbuf[16] = "";
char *rubles = NULL;
@@ -314,7 +319,7 @@ static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay,
int ikopecks = 0;
int ikopeck = 0;
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)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
@@ -338,24 +343,24 @@ static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay,
rubles++;
}
ru_say_count(session,rubles ,male_c,nominativus ,args);
ru_say_count(session, rubles, male_c, nominativus, args);
if (rubles) {
irubles = atoi(rubles)%100;
iruble = atoi(rubles)%10;
irubles = atoi(rubles) % 100;
iruble = atoi(rubles) % 10;
}
if (irubles == 1 || (irubles > 20 && iruble == 1)) {/* рубль */
if (irubles == 1 || (irubles > 20 && iruble == 1)) { /* рубль */
say_file("currency/ruble.wav");
} else if ((irubles > 1 && irubles < 5) || (irubles > 20 && iruble > 1 && iruble < 5)) { /*рубля */
} else if ((irubles > 1 && irubles < 5) || (irubles > 20 && iruble > 1 && iruble < 5)) { /*рубля */
say_file("currency/ruble-a.wav");
} else { /*рублей */
} else { /*рублей */
say_file("currency/rubles.wav");
}
/* Say kopecks */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " %s\n",kopecks );
ru_say_count(session, kopecks ,female_c, nominativus, args);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " %s\n", kopecks);
ru_say_count(session, kopecks, female_c, nominativus, args);
if (kopecks) {
ikopecks = atoi(kopecks) % 100;
@@ -386,7 +391,7 @@ static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay,
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *tz = switch_channel_get_variable(channel, "timezone");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n",tosay, type,method );
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n", tosay, type, method);
if (type == SST_TIME_MEASUREMENT) {
int64_t hours = 0;
@@ -428,38 +433,38 @@ static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay,
}
}
switch_snprintf(buf, sizeof(buf), "%u", (unsigned)hours);
ru_say_count(session,buf ,male_c,nominativus,args);
switch_snprintf(buf, sizeof(buf), "%u", (unsigned) hours);
ru_say_count(session, buf, male_c, nominativus, args);
if (((hours%10) == 1) && (hours!=11)) {
if (((hours % 10) == 1) && (hours != 11)) {
/* час */
say_file("time/hour.wav");
} else if (((hours%10>1)&&(hours%10<5)) &&((hours<12)||(hours>14))) {
say_file("time/hours-a.wav"); /* часа */
} else if (((hours % 10 > 1) && (hours % 10 < 5)) && ((hours < 12) || (hours > 14))) {
say_file("time/hours-a.wav"); /* часа */
} else {
say_file("time/hours.wav"); /* часов*/
say_file("time/hours.wav"); /* часов */
}
switch_snprintf(buf, sizeof(buf), "%u", (unsigned)minutes); //перевести минуты в *char
ru_say_count(session,buf ,female_c,nominativus,args);
switch_snprintf(buf, sizeof(buf), "%u", (unsigned) minutes); //перевести минуты в *char
ru_say_count(session, buf, female_c, nominativus, args);
if (((minutes%10) == 1) && (minutes!=11)) {
say_file("time/minute.wav"); //минута
} else if (((minutes%10>1)&&(minutes%10<5))&&((minutes<12)||(minutes>14))){
say_file("time/minutes-i.wav"); // минуты
if (((minutes % 10) == 1) && (minutes != 11)) {
say_file("time/minute.wav"); //минута
} else if (((minutes % 10 > 1) && (minutes % 10 < 5)) && ((minutes < 12) || (minutes > 14))) {
say_file("time/minutes-i.wav"); // минуты
} else {
say_file("time/minutes.wav"); //минут
say_file("time/minutes.wav"); //минут
}
if (seconds!=0) {
switch_snprintf(buf, sizeof(buf), "%u", (unsigned)seconds);
ru_say_count(session,buf ,female_c,nominativus,args);
if (((seconds%10) == 1) && (seconds!=11)) {
say_file("time/second.wav"); // секунда
} else if (((seconds%10>1)&&(seconds%10<5))&&((seconds<12)||(seconds>14))) {
say_file("time/seconds-i.wav"); // секуны
if (seconds != 0) {
switch_snprintf(buf, sizeof(buf), "%u", (unsigned) seconds);
ru_say_count(session, buf, female_c, nominativus, args);
if (((seconds % 10) == 1) && (seconds != 11)) {
say_file("time/second.wav"); // секунда
} else if (((seconds % 10 > 1) && (seconds % 10 < 5)) && ((seconds < 12) || (seconds > 14))) {
say_file("time/seconds-i.wav"); // секуны
} else {
say_file("time/seconds.wav"); //секунд
say_file("time/seconds.wav"); //секунд
}
}
return SWITCH_STATUS_SUCCESS;
@@ -488,43 +493,43 @@ static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay,
}
switch (type) {
case SST_CURRENT_DATE_TIME:
say_date = say_time = 1;
break;
case SST_CURRENT_DATE:
case SST_CURRENT_DATE_TIME:
say_date = say_time = 1;
break;
case SST_CURRENT_DATE:
say_date = 1;
break;
case SST_CURRENT_TIME:
say_time = 1;
break;
case SST_SHORT_DATE_TIME:
say_time = 1;
if (tm.tm_year != tm_now.tm_year) {
say_date = 1;
break;
case SST_CURRENT_TIME:
say_time = 1;
}
if (tm.tm_yday == tm_now.tm_yday) {
say_today = 1;
break;
case SST_SHORT_DATE_TIME:
say_time = 1;
if (tm.tm_year != tm_now.tm_year) {
say_date = 1;
break;
}
if (tm.tm_yday == tm_now.tm_yday) {
say_today = 1;
break;
}
if (tm.tm_yday == tm_now.tm_yday - 1) {
say_yesterday = 1;
break;
}
if (tm.tm_yday >= tm_now.tm_yday - 5) {
say_dow = 1;
break;
}
if (tm.tm_mon != tm_now.tm_mon) {
say_month = say_day = say_dow = 1;
break;
}
}
if (tm.tm_yday == tm_now.tm_yday - 1) {
say_yesterday = 1;
break;
}
if (tm.tm_yday >= tm_now.tm_yday - 5) {
say_dow = 1;
break;
}
if (tm.tm_mon != tm_now.tm_mon) {
say_month = say_day = say_dow = 1;
break;
}
break;
default:
break;
say_month = say_day = say_dow = 1;
break;
default:
break;
}
if (say_today) {
@@ -541,30 +546,28 @@ static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay,
say_today = say_yesterday = 0;
}
if (say_day) {
switch_snprintf(buf, sizeof(buf), "%u", (unsigned)tm.tm_mday);
ru_say_count(session,buf ,male_h,genitivus,args);
switch_snprintf(buf, sizeof(buf), "%u", (unsigned) tm.tm_mday);
ru_say_count(session, buf, male_h, genitivus, args);
}
if (say_month) {
say_file("time/mon-%d.wav", tm.tm_mon);
}
if (say_year) {
switch_snprintf(buf, sizeof(buf), "%u", (unsigned)(tm.tm_year + 1900));
ru_say_count(session,buf ,male_h,genitivus,args);
switch_snprintf(buf, sizeof(buf), "%u", (unsigned) (tm.tm_year + 1900));
ru_say_count(session, buf, male_h, genitivus, args);
say_file("time/h-year.wav");
}
if (say_month||say_year||say_date||say_dow)
{
if (say_month || say_year || say_date || say_dow) {
say_file("time/at.wav");
}
if (say_time) {
switch_snprintf(buf, sizeof(buf), "%d:%d:%d",tm.tm_hour+1,tm.tm_min,tm.tm_sec);
switch_snprintf(buf, sizeof(buf), "%d:%d:%d", tm.tm_hour + 1, tm.tm_min, tm.tm_sec);
ru_say_time(session, buf, SST_TIME_MEASUREMENT, method, args);
}
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
switch_input_args_t *args)
static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
char *a, *b, *c, *d;
if (!(a = switch_core_session_strdup(session, tosay))) {
@@ -589,16 +592,16 @@ static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch
*d++ = '\0';
ru_say_count(session,a ,male_c,nominativus,args);
ru_say_count(session, a, male_c, nominativus, args);
say_file("digits/dot.wav");
ru_say_count(session,b ,male_c,nominativus,args);
ru_say_count(session, b, male_c, nominativus, args);
say_file("digits/dot.wav");
ru_say_count(session,c ,male_c,nominativus,args);
ru_say_count(session, c, male_c, nominativus, args);
say_file("digits/dot.wav");
ru_say_count(session,d ,male_c,nominativus,args);
ru_say_count(session, d, male_c, nominativus, args);
return SWITCH_STATUS_SUCCESS;
}
@@ -607,40 +610,40 @@ static switch_status_t ru_say(switch_core_session_t *session, char *tosay, switc
switch_say_callback_t say_cb = NULL;
switch (type) {
case SST_NUMBER:
case SST_ITEMS:
case SST_PERSONS:
case SST_MESSAGES:
say_cb = ru_say_general_count;
break;
case SST_TIME_MEASUREMENT:
say_cb = ru_say_time;
break;
case SST_NUMBER:
case SST_ITEMS:
case SST_PERSONS:
case SST_MESSAGES:
say_cb = ru_say_general_count;
break;
case SST_TIME_MEASUREMENT:
say_cb = ru_say_time;
break;
case SST_CURRENT_DATE:
say_cb = ru_say_time;
break;
case SST_CURRENT_DATE:
say_cb = ru_say_time;
break;
case SST_CURRENT_TIME:
say_cb = ru_say_time;
break;
case SST_CURRENT_TIME:
say_cb = ru_say_time;
break;
case SST_CURRENT_DATE_TIME:
say_cb = ru_say_time;
break;
case SST_IP_ADDRESS:
say_cb = ru_ip;
break;
case SST_NAME_SPELLED:
case SST_NAME_PHONETIC:
say_cb = ru_spell;
break;
case SST_CURRENCY:
say_cb = ru_say_money;
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
break;
case SST_CURRENT_DATE_TIME:
say_cb = ru_say_time;
break;
case SST_IP_ADDRESS:
say_cb = ru_ip;
break;
case SST_NAME_SPELLED:
case SST_NAME_PHONETIC:
say_cb = ru_spell;
break;
case SST_CURRENCY:
say_cb = ru_say_money;
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
break;
}
if (say_cb) {
+54 -56
View File
@@ -5,7 +5,7 @@
* mod_say_ru.c -- Say for Russian
*
*/
//слишком много падежей поэтому пришлось сделать массив значений
//пример таблицы склонений для 1 ниже по ссылкам
@@ -13,44 +13,44 @@
//http://ru.wiktionary.org/wiki/%D0%BF%D0%B5%D1%80%D0%B2%D1%8B%D0%B9
typedef enum {
million,
thousand,
zero,
empty
million,
thousand,
zero,
empty
} unit_t;
//тип числа порядковое или количественное
typedef enum{
nominativus, // именительный Кто? Что?
genitivus, // Родительный Кого? Чего?
dativus, // дательный Кого? Что?
accusativus_a, // Винительный Кого? animate - одушевлённый
accusativus_i, // Винительный Что? inanimate - неодушевлённый
instrumentalis, // Творительный Кем? Чем?
prepositive // Предложный О ком? О чём?
typedef enum {
nominativus, // именительный Кто? Что?
genitivus, // Родительный Кого? Чего?
dativus, // дательный Кого? Что?
accusativus_a, // Винительный Кого? animate - одушевлённый
accusativus_i, // Винительный Что? inanimate - неодушевлённый
instrumentalis, // Творительный Кем? Чем?
prepositive // Предложный О ком? О чём?
} casus_t;
typedef enum {
//количественный
male_c, //мужского пола
it_c, //среднего
female_c, //женского
plural_c, //множественное число
//порядковый
male_h, //порядковое мужского пола
it_h, //порядковое среднего
female_h, //порядковое женского
plural_h //порядковое множественное число
//количественный
male_c, //мужского пола
it_c, //среднего
female_c, //женского
plural_c, //множественное число
//порядковый
male_h, //порядковое мужского пола
it_h, //порядковое среднего
female_h, //порядковое женского
plural_h //порядковое множественное число
} say_type_t;
struct say_t{
char *num[8];
char *thousand[14];
char *million[14];
int all;
struct say_t {
char *num[8];
char *thousand[14];
char *million[14];
int all;
};
@@ -69,7 +69,7 @@ struct say_t{
{"","","1","million","2","million-a","3","million-a","4","million-a","5","millions","",""},\
0,\
}\
//средний род именительный падеж
//средний род именительный падеж
#define m_01 {\
{"0","1n","2","3","4","5","",""},\
{"","","1f","thousand","2f","thousands-i","3","thousands-i","4","thousands-i","5","thousands","",""},\
@@ -101,14 +101,14 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_05 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_06 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -135,7 +135,7 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_11 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -168,14 +168,14 @@ struct say_t{
{"","","","h-millionx","h-2xx","h-millionx","h-3xx","h-millionx","h-4xx","h-millionx","h-5xx","h-millionx","h-","xx"},\
0,\
}\
//средний
//средний
#define m_15 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_16 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -202,7 +202,7 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_21 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -234,14 +234,14 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_25 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_26 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -268,7 +268,7 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_31 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -300,14 +300,14 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_35 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_36 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -334,7 +334,7 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_41 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -366,14 +366,14 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_45 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_46 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -400,7 +400,7 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_51 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -432,14 +432,14 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_55 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_56 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -466,7 +466,7 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_61 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -498,14 +498,14 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_65 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_66 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -532,7 +532,7 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_61 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -564,14 +564,14 @@ struct say_t{
{"","","","","","","","","","","","","",""},\
0,\
}\
//средний
//средний
#define m_65 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
0,\
}\
//женский
//женский
#define m_66 {\
{"","","","","","","",""},\
{"","","","","","","","","","","","","",""},\
@@ -587,5 +587,3 @@ struct say_t{
0,\
}\
+145 -177
View File
@@ -103,11 +103,11 @@ static switch_status_t th_spell(switch_core_session_t *session, char *tosay, swi
static char *strip_commas(char *in, char *out, switch_size_t len)
{
char *p = in;
char *q = out;
char *q = out;
char *ret = out;
switch_size_t x = 0;
for ( ; p && *p; p++) {
for (; p && *p; p++) {
if ((*p >= '0' && *p <= '9')) {
*q++ = *p;
} else if (*p != ',') {
@@ -127,7 +127,7 @@ static char *strip_commas(char *in, char *out, switch_size_t len)
static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
{
char *p = in;
char *q = out;
char *q = out;
char *ret = out;
switch_size_t x = 0;
@@ -151,8 +151,8 @@ static switch_status_t th_say_general_count(switch_core_session_t *session,
{
int in;
char sbuf[13] = "";
char digits[11];
int i;
char digits[11];
int i;
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
@@ -163,123 +163,108 @@ static switch_status_t th_say_general_count(switch_core_session_t *session,
if (in != 0) {
snprintf(digits, sizeof(digits), "%10.10d", in);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Say: %s \n",digits);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Say: %s \n", digits);
switch (method) {
case SSM_COUNTED:
say_file("digits/ordinal.wav");
/* Fall through */
case SSM_PRONOUNCED:
for (i = 0; i <= 9; i++)
{
switch (i)
{
case 0:
/* Billions column */
if (digits[i] != '0')
{
if (digits[i] != '1')
say_file("digits/%c.wav", digits[i]);
say_file("digits/10.wav");
}
break;
case 1:
/* Hundred millions columns */
if (digits[i] != '0')
say_file("digits/%c.wav", digits[i]);
if (memcmp (digits, "00", 2) != 0)
say_file("digits/100000000.wav");
break;
case 2:
/* ten Millions column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
say_file("digits/10000000.wav");
}
break;
case 3:
/* Millions column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
say_file("digits/1000000.wav");
}
break;
case 4:
/* Hundred thousands column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
if (memcmp (digits + 2, "00000", 4) != 0)
say_file("digits/100000.wav");
}
for (i = 0; i <= 9; i++) {
switch (i) {
case 0:
/* Billions column */
if (digits[i] != '0') {
if (digits[i] != '1')
say_file("digits/%c.wav", digits[i]);
say_file("digits/10.wav");
}
break;
case 1:
/* Hundred millions columns */
if (digits[i] != '0')
say_file("digits/%c.wav", digits[i]);
if (memcmp(digits, "00", 2) != 0)
say_file("digits/100000000.wav");
break;
case 2:
/* ten Millions column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
say_file("digits/10000000.wav");
}
break;
case 3:
/* Millions column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
say_file("digits/1000000.wav");
}
break;
case 4:
/* Hundred thousands column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
if (memcmp(digits + 2, "00000", 4) != 0)
say_file("digits/100000.wav");
}
break;
case 5:
/* Ten thousands column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
if (memcmp (digits + 2, "0000", 4) != 0)
say_file("digits/10000.wav");
}
break;
case 6:
/* Ten millions or thousands column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
say_file("digits/1000.wav");
}
break;
case 7:
/* hundreds column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
say_file("digits/100.wav");
}
break;
case 8:
/* Tens column */
if (digits[i] != '0')
{
if (digits[i] == '2')
{
say_file("digits/20.wav");
break;
}
if (digits[i] == '1')
{
say_file("digits/10.wav");
break;
}
if (digits[i] != '1'
||
memcmp (digits, "00000000", 8) != 0)
{
say_file("digits/%c.wav", digits[i]);
}
}
if (digits[8] != '0')
say_file("digits/10.wav");
break;
case 9:
/* Units column */
if (digits[9] == '1'){
if (digits[8] != '0'){
say_file("digits/ed.wav", digits[i]);
}else{
say_file("digits/%c.wav", digits[i]);
}
break;
}
if (digits[9] != '0')
say_file("digits/%c.wav", digits[i]);
break;
}
}
break;
case 5:
/* Ten thousands column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
if (memcmp(digits + 2, "0000", 4) != 0)
say_file("digits/10000.wav");
}
break;
case 6:
/* Ten millions or thousands column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
say_file("digits/1000.wav");
}
break;
case 7:
/* hundreds column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
say_file("digits/100.wav");
}
break;
case 8:
/* Tens column */
if (digits[i] != '0') {
if (digits[i] == '2') {
say_file("digits/20.wav");
break;
}
if (digits[i] == '1') {
say_file("digits/10.wav");
break;
}
if (digits[i] != '1' || memcmp(digits, "00000000", 8) != 0) {
say_file("digits/%c.wav", digits[i]);
}
}
if (digits[8] != '0')
say_file("digits/10.wav");
break;
case 9:
/* Units column */
if (digits[9] == '1') {
if (digits[8] != '0') {
say_file("digits/ed.wav", digits[i]);
} else {
say_file("digits/%c.wav", digits[i]);
}
break;
}
if (digits[9] != '0')
say_file("digits/%c.wav", digits[i]);
break;
}
}
break;
case SSM_ITERATED:
{
@@ -338,10 +323,7 @@ static switch_status_t th_ip(switch_core_session_t *session, char *tosay, switch
}
static switch_status_t th_say_time(switch_core_session_t *session,
char *tosay,
switch_say_type_t type,
switch_say_method_t method,
switch_input_args_t *args)
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
int32_t t;
switch_time_t target = 0;
@@ -351,7 +333,7 @@ static switch_status_t th_say_time(switch_core_session_t *session,
switch_time_exp_t tm2;
#endif
uint8_t say_date = 0;
uint8_t say_time = 0;
uint8_t say_time = 0;
if (type == SST_TIME_MEASUREMENT) {
int64_t hours = 0;
@@ -397,16 +379,16 @@ static switch_status_t th_say_time(switch_core_session_t *session,
if (hours) {
if (hours == 2) {
say_file("time/2s.wav");
} else {
say_num(hours, SSM_PRONOUNCED);
} else {
say_num(hours, SSM_PRONOUNCED);
}
say_file("time/hours.wav");
}
if (minutes) {
if (minutes == 2) {
say_file("time/2s.wav");
} else {
say_num(minutes, SSM_PRONOUNCED);
} else {
say_num(minutes, SSM_PRONOUNCED);
}
say_file("time/minute.wav");
} else {
@@ -419,12 +401,12 @@ static switch_status_t th_say_time(switch_core_session_t *session,
if (seconds) {
if (seconds == 2) {
say_file("time/2s.wav");
} else {
say_num(hours, SSM_PRONOUNCED);
} else {
say_num(hours, SSM_PRONOUNCED);
}
say_file("time/seconds.wav");
} else {
if (hours || minutes) {
if (hours || minutes) {
say_file("digits/0.wav");
say_file("time/second.wav");
}
@@ -441,8 +423,7 @@ static switch_status_t th_say_time(switch_core_session_t *session,
switch (type) {
case SST_CURRENT_DATE_TIME:
say_date =
say_time = 1;
say_date = say_time = 1;
break;
case SST_CURRENT_DATE:
say_date = 1;
@@ -455,7 +436,7 @@ static switch_status_t th_say_time(switch_core_session_t *session,
}
if (say_date) {
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_file("time/year.wav");
say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
say_file("time/month.wav");
@@ -464,52 +445,39 @@ static switch_status_t th_say_time(switch_core_session_t *session,
say_file("time/day-%d.wav", tm.tm_wday);
#if 0
tm = *localtime(&then);
tm = *localtime(&then);
this_morning = switch_micro_time_now();
switch_time_exp_lt(&tm2, this_morning);
tm2->tm_hour = 0;
tm2->tm_min = 0;
tm2->tm_sec = 0;
this_morning = mktime(tm2);
this_morning = switch_micro_time_now();
switch_time_exp_lt(&tm2, this_morning);
tm2->tm_hour = 0;
tm2->tm_min = 0;
tm2->tm_sec = 0;
this_morning = mktime(tm2);
if (this_morning <= then && then < (this_morning + 86400L))
{
if (this_morning <= then && then < (this_morning + 86400L)) {
say_file("time/today.wav");
}
else if ((this_morning - 86400L) <= then && then < this_morning)
{
} else if ((this_morning - 86400L) <= then && then < this_morning) {
say_file("time/yesterday.wav");
}
else if ((this_morning + 86400L) <= then && then < (this_morning + 2*86400L))
{
} else if ((this_morning + 86400L) <= then && then < (this_morning + 2 * 86400L)) {
say_file("time/tomorrow.wav");
}
else if ((this_morning - 7*86400L) <= then && then < this_morning)
{
say_file("time/day-%d.wav", tm.tm_wday);
}
else
{
if (tm2->tm_year != tm.tm_year)
{
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_file("time/year.wav");
}
/*endif*/
if (tm2->tm_year != tm.tm_year
||
tm2->tm_mon != tm.tm_mon)
{
say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
say_file("time/month.wav");
}
/*endif*/
/* Always say the day and the day of the week */
say_num(tm.tm_mday, SSM_PRONOUNCED);
say_file("time/day.wav");
say_file("time/day-%d.wav", tm.tm_wday);
}
} else if ((this_morning - 7 * 86400L) <= then && then < this_morning) {
say_file("time/day-%d.wav", tm.tm_wday);
} else {
if (tm2->tm_year != tm.tm_year) {
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_file("time/year.wav");
}
/*endif */
if (tm2->tm_year != tm.tm_year || tm2->tm_mon != tm.tm_mon) {
say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
say_file("time/month.wav");
}
/*endif */
/* Always say the day and the day of the week */
say_num(tm.tm_mday, SSM_PRONOUNCED);
say_file("time/day.wav");
say_file("time/day-%d.wav", tm.tm_wday);
}
#endif
}
@@ -517,13 +485,13 @@ static switch_status_t th_say_time(switch_core_session_t *session,
int32_t hour = tm.tm_hour;
if (hour < 6) {
say_file("time/morning.wav");
say_file("time/morning.wav");
} else if (hour < 12) {
say_file("time/am.wav");
say_file("time/am.wav");
} else if (tm.tm_hour < 18) {
say_file("time/pm.wav");
say_file("time/pm.wav");
} else {
say_file("time/evening.wav");
say_file("time/evening.wav");
}
if (hour > 12)
hour -= 12;
@@ -541,7 +509,7 @@ static switch_status_t th_say_time(switch_core_session_t *session,
} else {
say_num(tm.tm_min, SSM_PRONOUNCED);
}
say_file("time/minute.wav");
say_file("time/minute.wav");
}
return SWITCH_STATUS_SUCCESS;
}
+126 -167
View File
@@ -103,11 +103,11 @@ static switch_status_t zh_spell(switch_core_session_t *session, char *tosay, swi
static char *strip_commas(char *in, char *out, switch_size_t len)
{
char *p = in;
char *q = out;
char *q = out;
char *ret = out;
switch_size_t x = 0;
for ( ; p && *p; p++) {
for (; p && *p; p++) {
if ((*p >= '0' && *p <= '9')) {
*q++ = *p;
} else if (*p != ',') {
@@ -127,7 +127,7 @@ static char *strip_commas(char *in, char *out, switch_size_t len)
static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
{
char *p = in;
char *q = out;
char *q = out;
char *ret = out;
switch_size_t x = 0;
@@ -151,8 +151,8 @@ static switch_status_t zh_say_general_count(switch_core_session_t *session,
{
int in;
char sbuf[13] = "";
char digits[11];
int i;
char digits[11];
int i;
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
@@ -168,107 +168,83 @@ static switch_status_t zh_say_general_count(switch_core_session_t *session,
say_file("digits/ordinal.wav");
/* Fall through */
case SSM_PRONOUNCED:
for (i = 0; i <= 9; i++)
{
switch (i)
{
case 0:
/* Billions column */
if (digits[i] != '0')
{
if (digits[i] != '1')
say_file("digits/%c.wav", digits[i]);
say_file("digits/10.wav");
}
break;
case 1:
/* Hundred millions columns */
if (digits[i] != '0')
say_file("digits/%c.wav", digits[i]);
if (memcmp (digits, "00", 2) != 0)
say_file("digits/100000000.wav");
break;
case 2:
case 6:
/* Ten millions or thousands column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
say_file("digits/1000.wav");
}
break;
case 3:
case 7:
/* Millions or hundreds column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
say_file("digits/100.wav");
}
break;
case 4:
/* Hundred thousands column */
if (digits[i] != '0')
{
if (digits[i] != '1'
||
memcmp (digits, "0000", 4) != 0)
{
say_file("digits/%c.wav", digits[i]);
}
}
else
{
if (digits[i + 1] != '0'
&&
memcmp (digits, "0000", 4) != 0)
{
say_file("digits/%c.wav", digits[i]);
}
}
if (digits[i] != '0')
say_file("digits/10.wav");
break;
case 5:
/* Ten thousands column */
if (digits[i] != '0')
{
say_file("digits/%c.wav", digits[i]);
if (memcmp (digits + 2, "0000", 4) != 0)
say_file("digits/10000.wav");
}
break;
case 8:
/* Tens column */
if (digits[i] != '0')
{
if (digits[i] != '1'
||
memcmp (digits, "00000000", 8) != 0)
{
say_file("digits/%c.wav", digits[i]);
}
}
else
{
if (digits[9] != '0'
&&
memcmp (digits, "00000000", 8) != 0)
{
say_file("digits/%c.wav", digits[i]);
}
}
if (digits[8] != '0')
say_file("digits/10.wav");
break;
case 9:
/* Units column */
if (digits[9] != '0')
say_file("digits/%c.wav", digits[i]);
break;
}
}
for (i = 0; i <= 9; i++) {
switch (i) {
case 0:
/* Billions column */
if (digits[i] != '0') {
if (digits[i] != '1')
say_file("digits/%c.wav", digits[i]);
say_file("digits/10.wav");
}
break;
case 1:
/* Hundred millions columns */
if (digits[i] != '0')
say_file("digits/%c.wav", digits[i]);
if (memcmp(digits, "00", 2) != 0)
say_file("digits/100000000.wav");
break;
case 2:
case 6:
/* Ten millions or thousands column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
say_file("digits/1000.wav");
}
break;
case 3:
case 7:
/* Millions or hundreds column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
say_file("digits/100.wav");
}
break;
case 4:
/* Hundred thousands column */
if (digits[i] != '0') {
if (digits[i] != '1' || memcmp(digits, "0000", 4) != 0) {
say_file("digits/%c.wav", digits[i]);
}
} else {
if (digits[i + 1] != '0' && memcmp(digits, "0000", 4) != 0) {
say_file("digits/%c.wav", digits[i]);
}
}
if (digits[i] != '0')
say_file("digits/10.wav");
break;
case 5:
/* Ten thousands column */
if (digits[i] != '0') {
say_file("digits/%c.wav", digits[i]);
if (memcmp(digits + 2, "0000", 4) != 0)
say_file("digits/10000.wav");
}
break;
case 8:
/* Tens column */
if (digits[i] != '0') {
if (digits[i] != '1' || memcmp(digits, "00000000", 8) != 0) {
say_file("digits/%c.wav", digits[i]);
}
} else {
if (digits[9] != '0' && memcmp(digits, "00000000", 8) != 0) {
say_file("digits/%c.wav", digits[i]);
}
}
if (digits[8] != '0')
say_file("digits/10.wav");
break;
case 9:
/* Units column */
if (digits[9] != '0')
say_file("digits/%c.wav", digits[i]);
break;
}
}
break;
case SSM_ITERATED:
{
@@ -327,10 +303,7 @@ static switch_status_t zh_ip(switch_core_session_t *session, char *tosay, switch
}
static switch_status_t zh_say_time(switch_core_session_t *session,
char *tosay,
switch_say_type_t type,
switch_say_method_t method,
switch_input_args_t *args)
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
int32_t t;
switch_time_t target = 0;
@@ -340,7 +313,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
switch_time_exp_t tm2;
#endif
uint8_t say_date = 0;
uint8_t say_time = 0;
uint8_t say_time = 0;
if (type == SST_TIME_MEASUREMENT) {
int64_t hours = 0;
@@ -386,16 +359,16 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
if (hours) {
if (hours == 2) {
say_file("time/2s.wav");
} else {
say_num(hours, SSM_PRONOUNCED);
} else {
say_num(hours, SSM_PRONOUNCED);
}
say_file("time/hours.wav");
}
if (minutes) {
if (minutes == 2) {
say_file("time/2s.wav");
} else {
say_num(minutes, SSM_PRONOUNCED);
} else {
say_num(minutes, SSM_PRONOUNCED);
}
say_file("time/minute.wav");
} else {
@@ -408,12 +381,12 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
if (seconds) {
if (seconds == 2) {
say_file("time/2s.wav");
} else {
say_num(hours, SSM_PRONOUNCED);
} else {
say_num(hours, SSM_PRONOUNCED);
}
say_file("time/seconds.wav");
} else {
if (hours || minutes) {
if (hours || minutes) {
say_file("digits/0.wav");
say_file("time/second.wav");
}
@@ -430,8 +403,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
switch (type) {
case SST_CURRENT_DATE_TIME:
say_date =
say_time = 1;
say_date = say_time = 1;
break;
case SST_CURRENT_DATE:
say_date = 1;
@@ -444,7 +416,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
}
if (say_date) {
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_file("time/year.wav");
say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
say_file("time/month.wav");
@@ -453,52 +425,39 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
say_file("time/day-%d.wav", tm.tm_wday);
#if 0
tm = *localtime(&then);
tm = *localtime(&then);
this_morning = switch_micro_time_now();
switch_time_exp_lt(&tm2, this_morning);
tm2->tm_hour = 0;
tm2->tm_min = 0;
tm2->tm_sec = 0;
this_morning = mktime(tm2);
this_morning = switch_micro_time_now();
switch_time_exp_lt(&tm2, this_morning);
tm2->tm_hour = 0;
tm2->tm_min = 0;
tm2->tm_sec = 0;
this_morning = mktime(tm2);
if (this_morning <= then && then < (this_morning + 86400L))
{
if (this_morning <= then && then < (this_morning + 86400L)) {
say_file("time/today.wav");
}
else if ((this_morning - 86400L) <= then && then < this_morning)
{
} else if ((this_morning - 86400L) <= then && then < this_morning) {
say_file("time/yesterday.wav");
}
else if ((this_morning + 86400L) <= then && then < (this_morning + 2*86400L))
{
} else if ((this_morning + 86400L) <= then && then < (this_morning + 2 * 86400L)) {
say_file("time/tomorrow.wav");
}
else if ((this_morning - 7*86400L) <= then && then < this_morning)
{
say_file("time/day-%d.wav", tm.tm_wday);
}
else
{
if (tm2->tm_year != tm.tm_year)
{
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_file("time/year.wav");
}
/*endif*/
if (tm2->tm_year != tm.tm_year
||
tm2->tm_mon != tm.tm_mon)
{
say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
say_file("time/month.wav");
}
/*endif*/
/* Always say the day and the day of the week */
say_num(tm.tm_mday, SSM_PRONOUNCED);
say_file("time/day.wav");
say_file("time/day-%d.wav", tm.tm_wday);
}
} else if ((this_morning - 7 * 86400L) <= then && then < this_morning) {
say_file("time/day-%d.wav", tm.tm_wday);
} else {
if (tm2->tm_year != tm.tm_year) {
say_num(tm.tm_year + 1900, SSM_ITERATED);
say_file("time/year.wav");
}
/*endif */
if (tm2->tm_year != tm.tm_year || tm2->tm_mon != tm.tm_mon) {
say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
say_file("time/month.wav");
}
/*endif */
/* Always say the day and the day of the week */
say_num(tm.tm_mday, SSM_PRONOUNCED);
say_file("time/day.wav");
say_file("time/day-%d.wav", tm.tm_wday);
}
#endif
}
@@ -506,13 +465,13 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
int32_t hour = tm.tm_hour;
if (hour < 6) {
say_file("time/morning.wav");
say_file("time/morning.wav");
} else if (hour < 12) {
say_file("time/am.wav");
say_file("time/am.wav");
} else if (tm.tm_hour < 18) {
say_file("time/pm.wav");
say_file("time/pm.wav");
} else {
say_file("time/evening.wav");
say_file("time/evening.wav");
}
if (hour > 12)
hour -= 12;
@@ -530,7 +489,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
} else {
say_num(tm.tm_min, SSM_PRONOUNCED);
}
say_file("time/minute.wav");
say_file("time/minute.wav");
}
return SWITCH_STATUS_SUCCESS;
}