提交 c788145f authored 作者: Michael Jerris's avatar Michael Jerris

use common code to say ip when possible

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16937 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 f8974f03
......@@ -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);
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论