Revision
16937
Author
mikej
Date
2010-03-08 02:38:50 -0600 (Mon, 08 Mar 2010)

Log Message

use common code to say ip when possible

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_ivr.h (16936 => 16937)


--- freeswitch/trunk/src/include/switch_ivr.h	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/include/switch_ivr.h	2010-03-08 08:38:50 UTC (rev 16937)
@@ -822,6 +822,11 @@
 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);

Modified: freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -176,44 +176,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -176,44 +176,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -196,44 +196,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -197,44 +197,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -175,44 +175,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -220,44 +220,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -167,44 +167,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -225,43 +225,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c (16936 => 16937)


--- freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -204,43 +204,6 @@
 	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 @@
 		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:

Modified: freeswitch/trunk/src/switch_ivr_say.c (16936 => 16937)


--- freeswitch/trunk/src/switch_ivr_say.c	2010-03-08 08:12:12 UTC (rev 16936)
+++ freeswitch/trunk/src/switch_ivr_say.c	2010-03-08 08:38:50 UTC (rev 16937)
@@ -128,6 +128,7 @@
 			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,8 +149,62 @@
 	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:
  * Local Variables:
  * mode:c