]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
use common code to say ip when possible
authorMichael Jerris <mike@jerris.com>
Mon, 8 Mar 2010 08:38:50 +0000 (08:38 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 8 Mar 2010 08:38:50 +0000 (08:38 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16937 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_ivr.h
src/mod/say/mod_say_de/mod_say_de.c
src/mod/say/mod_say_en/mod_say_en.c
src/mod/say/mod_say_es/mod_say_es.c
src/mod/say/mod_say_fr/mod_say_fr.c
src/mod/say/mod_say_hu/mod_say_hu.c
src/mod/say/mod_say_it/mod_say_it.c
src/mod/say/mod_say_nl/mod_say_nl.c
src/mod/say/mod_say_th/mod_say_th.c
src/mod/say/mod_say_zh/mod_say_zh.c
src/switch_ivr_say.c

index 1e9ad9797fc0481e893a5513cfd5131f8a68aaa9..3affb6c0ade500f7bf8cbd7a8a945ba2fbd9ad45 100644 (file)
@@ -822,6 +822,11 @@ SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char
 SWITCH_DECLARE(switch_say_gender_t) switch_ivr_get_say_gender_by_name(const char *name);
 SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name);
 SWITCH_DECLARE(switch_status_t) switch_ivr_say_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args);
+SWITCH_DECLARE(switch_status_t) switch_ivr_say_ip(switch_core_session_t *session,
+                                                                                                 char *tosay,
+                                                                                                 switch_say_callback_t number_func,
+                                                                                                 switch_say_args_t *say_args,
+                                                                                                 switch_input_args_t *args);
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *session, const char *data);
 SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session);
index e36abbdb39b6928463754c8a6583ce1bc1f389b5..ea0b380e4ee530232a8c531249e48237a2bd6c2d 100644 (file)
@@ -176,44 +176,6 @@ static switch_status_t de_say_general_count(switch_core_session_t *session, char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t de_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
-
 static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -438,7 +400,7 @@ static switch_status_t de_say(switch_core_session_t *session, char *tosay, switc
                say_cb = de_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = de_ip;
+               return switch_ivr_say_ip(session, tosay, de_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index 450047ad674c458c00542ec6a4ddbb89f1d0546f..03bea87bc172357992c4c01318e5c471c118d3e8 100644 (file)
@@ -176,44 +176,6 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,        char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t en_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
-
 static switch_status_t en_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -506,7 +468,7 @@ static switch_status_t en_say(switch_core_session_t *session, char *tosay, switc
                say_cb = en_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = en_ip;
+               return switch_ivr_say_ip(session, tosay, en_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index 3ab33496180de12bb0e967750eddd31b6a0098ff..e2786d940fd492fc81949d8d463e4c092f0687ee 100644 (file)
@@ -196,44 +196,6 @@ static switch_status_t es_say_general_count(switch_core_session_t *session, char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t es_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
-
 static switch_status_t es_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -459,7 +421,7 @@ static switch_status_t es_say(switch_core_session_t *session, char *tosay, switc
                say_cb = es_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = es_ip;
+               return switch_ivr_say_ip(session, tosay, es_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index 670746a8d3fea62771730fcb293de317fb886181..cf3ebabcdb3ad2c7cc48885652f1d3cdc8b751fb 100644 (file)
@@ -197,44 +197,6 @@ static switch_status_t fr_say_general_count(switch_core_session_t *session, char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t fr_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
-
 static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -510,7 +472,7 @@ static switch_status_t fr_say(switch_core_session_t *session, char *tosay, switc
                say_cb = fr_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = fr_ip;
+               return switch_ivr_say_ip(session, tosay, fr_say_general_count, say_args, args);
                break;
        case SST_TELEPHONE_NUMBER:
        case SST_TELEPHONE_EXTENSION:
index 5e92ff5cc8e9871d9c7ff7010fd8feaaf1c876b6..6a3dfdc65e979cd32b6ec22e9d7e025bce8d0655 100644 (file)
@@ -175,44 +175,6 @@ static switch_status_t hu_say_general_count(switch_core_session_t *session, char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t hu_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
-
 static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -438,7 +400,7 @@ static switch_status_t hu_say(switch_core_session_t *session, char *tosay, switc
                say_cb = hu_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = hu_ip;
+               return switch_ivr_say_ip(session, tosay, hu_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index b42d084e8de614cb646dc7255a54fedef1802025..7a3c7bc99c5a0cde9430fa7492e3f10706abb83f 100644 (file)
@@ -220,44 +220,6 @@ static switch_status_t it_say_general_count(switch_core_session_t *session,        char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t it_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
-
 static switch_status_t it_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -466,7 +428,7 @@ static switch_status_t it_say(switch_core_session_t *session, char *tosay, switc
                say_cb = it_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = it_ip;
+               return switch_ivr_say_ip(session, tosay, it_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index 2ee8b35473184db1ab6b26c2b99d99511be4dd97..4f4ec7edd0cee7815330333ed9487b85a6f21664 100644 (file)
@@ -167,44 +167,6 @@ static switch_status_t nl_say_general_count(switch_core_session_t *session, char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t nl_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
-
 static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -430,7 +392,7 @@ static switch_status_t nl_say(switch_core_session_t *session, char *tosay, switc
                say_cb = nl_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = nl_ip;
+               return switch_ivr_say_ip(session, tosay, nl_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index 95b2ff08336d80685b1f90f1ac95e10049898a9e..59b077a0fe965175763d2ed09cb9690fb10bcbdc 100644 (file)
@@ -225,43 +225,6 @@ static switch_status_t th_say_general_count(switch_core_session_t *session,        char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t th_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
 static switch_status_t th_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -517,7 +480,7 @@ static switch_status_t th_say(switch_core_session_t *session, char *tosay, switc
                say_cb = th_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = th_ip;
+               return switch_ivr_say_ip(session, tosay, th_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index 6432ded61cb6aa8029c802f6686d7940b5e8777b..69e2c73cf6793b33853ac232a89a7201f8e36024 100644 (file)
@@ -204,43 +204,6 @@ static switch_status_t zh_say_general_count(switch_core_session_t *session, char
        return SWITCH_STATUS_SUCCESS;
 }
 
-
-static switch_status_t zh_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
-{
-       char *a, *b, *c, *d;
-       if (!(a = switch_core_session_strdup(session, tosay))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       if (!(b = strchr(a, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *b++ = '\0';
-
-       if (!(c = strchr(b, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *c++ = '\0';
-
-       if (!(d = strchr(c, '.'))) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       *d++ = '\0';
-
-       say_num(atoi(a), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(b), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(c), say_args->method);
-       say_file("digits/dot.wav");
-       say_num(atoi(d), say_args->method);
-
-       return SWITCH_STATUS_SUCCESS;
-}
-
 static switch_status_t zh_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        int32_t t;
@@ -496,7 +459,7 @@ static switch_status_t zh_say(switch_core_session_t *session, char *tosay, switc
                say_cb = zh_say_time;
                break;
        case SST_IP_ADDRESS:
-               say_cb = zh_ip;
+               return switch_ivr_say_ip(session, tosay, zh_say_general_count, say_args, args);
                break;
        case SST_NAME_SPELLED:
        case SST_NAME_PHONETIC:
index cd4ea0d118d9c86c6eabc73fa06b97989c5c0aac..23be59edaa015a1d5776e29be6f6ed96279a2edc 100644 (file)
@@ -128,6 +128,7 @@ SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *na
                        return SWITCH_STATUS_FALSE;                                                                     \
                }}                                                                                                                              \
 
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_say_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
 {
        char *p;
@@ -148,6 +149,60 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say_spell(switch_core_session_t *sess
        return SWITCH_STATUS_SUCCESS;
 }
 
+#define say_num(num, meth) {                                                                                   \
+               char tmp[80];                                                                                                   \
+               switch_status_t tstatus;                                                                                \
+               switch_say_method_t smeth = say_args->method;                                   \
+               switch_say_type_t stype = say_args->type;                                               \
+               say_args->type = SST_ITEMS; say_args->method = meth;                    \
+               switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num);                 \
+               if ((tstatus =                                                                                                  \
+                        number_func(session, tmp, say_args, args))                                     \
+                       != SWITCH_STATUS_SUCCESS) {                                                                     \
+                       return tstatus;                                                                                         \
+               }                                                                                                                               \
+               say_args->method = smeth; say_args->type = stype;                               \
+       }                                                                                                                                       \
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_say_ip(switch_core_session_t *session,
+                                                                                                 char *tosay,
+                                                                                                 switch_say_callback_t number_func,
+                                                                                                 switch_say_args_t *say_args,
+                                                                                                 switch_input_args_t *args)
+{
+       char *a, *b, *c, *d;
+       if (!(a = switch_core_session_strdup(session, tosay))) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       if (!(b = strchr(a, '.'))) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       *b++ = '\0';
+
+       if (!(c = strchr(b, '.'))) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       *c++ = '\0';
+
+       if (!(d = strchr(c, '.'))) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       *d++ = '\0';
+
+       say_num(atoi(a), say_args->method);
+       say_file("digits/dot.wav");
+       say_num(atoi(b), say_args->method);
+       say_file("digits/dot.wav");
+       say_num(atoi(c), say_args->method);
+       say_file("digits/dot.wav");
+       say_num(atoi(d), say_args->method);
+
+       return SWITCH_STATUS_SUCCESS;
+}
 
 
 /* For Emacs: