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);
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;
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:
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;
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:
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;
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:
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;
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:
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;
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:
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;
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:
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;
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:
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;
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:
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;
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:
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;
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: