SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
SWITCH_DECLARE(char *) switch_strip_spaces(const char *str);
+SWITCH_DECLARE(char *) switch_strip_commas(char *in, char *out, switch_size_t len);
+SWITCH_DECLARE(char *) switch_strip_nonnumerics(char *in, char *out, switch_size_t len);
SWITCH_DECLARE(char *) switch_separate_paren_args(char *str);
SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str);
SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip);
return SWITCH_STATUS_SUCCESS;
}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- // valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t de_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
char sbuf[13] = "";
switch_status_t status;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_SUCCESS;
}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- // valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t en_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
switch_status_t status;
if (say_args->method == SSM_ITERATED) {
- if ((tosay = strip_commas(tosay, sbuf, sizeof(sbuf)))) {
+ if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)))) {
char *p;
for (p = tosay; p && *p; p++) {
say_file("digits/%c.wav", *p);
return SWITCH_STATUS_SUCCESS;
}
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_SUCCESS;
}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- // valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t es_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
char sbuf[13] = "";
switch_status_t status;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_SUCCESS;
}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- /* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t fr_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
char sbuf[13] = "";
switch_status_t status;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_SUCCESS;
}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- // valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t hu_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
int number;
switch_status_t status;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char sbuf[16] = "";
char *forint;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_SUCCESS;
}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- /* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t it_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
char sbuf[13] = "";
switch_status_t status;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_SUCCESS;
}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- // valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t nl_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
char sbuf[13] = "";
switch_status_t status;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_FALSE;\
}}
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58)) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in, *q = out;
- char *ret = out;
- switch_size_t x = 0;
- /* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
- for (; p && *p; p++) {
- if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
- return ret;
-}
-
static switch_status_t play_group(say_type_t say_type, casus_t casus, int a, int b, int c,
unit_t what, switch_core_session_t *session, switch_input_args_t *args)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say_count %s!\n", tosay);
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
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)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_FALSE; \
}} \
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in;
- char *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p >= '0' && *p <= '9')) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in;
- char *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- /* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
- for (; p && *p; p++) {
- if ((*p >= '0' && *p <= '9') || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t th_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
char digits[11];
int i;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_FALSE; \
}} \
-
-static char *strip_commas(char *in, char *out, switch_size_t len)
-{
- char *p = in;
- char *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- for (; p && *p; p++) {
- if ((*p >= '0' && *p <= '9')) {
- *q++ = *p;
- } else if (*p != ',') {
- ret = NULL;
- break;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
-static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
-{
- char *p = in;
- char *q = out;
- char *ret = out;
- switch_size_t x = 0;
-
- /* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
- for (; p && *p; p++) {
- if ((*p >= '0' && *p <= '9') || *p == '.' || *p == '-' || *p == '+') {
- *q++ = *p;
- }
-
- if (++x > len) {
- ret = NULL;
- break;
- }
- }
-
- return ret;
-}
-
static switch_status_t zh_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
int in;
char digits[11];
int i;
- if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
char *dollars = NULL;
char *cents = NULL;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ if (strlen(tosay) > 15 || !(tosay = switch_strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
return s;
}
+SWITCH_DECLARE(char *) switch_strip_commas(char *in, char *out, switch_size_t len)
+{
+ char *p = in, *q = out;
+ char *ret = out;
+ switch_size_t x = 0;
+
+ for (; p && *p; p++) {
+ if ((*p > 47 && *p < 58)) {
+ *q++ = *p;
+ } else if (*p != ',') {
+ ret = NULL;
+ break;
+ }
+
+ if (++x > len) {
+ ret = NULL;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+SWITCH_DECLARE(char *) switch_strip_nonnumerics(char *in, char *out, switch_size_t len)
+{
+ char *p = in, *q = out;
+ char *ret = out;
+ switch_size_t x = 0;
+ /* valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others */
+ for (; p && *p; p++) {
+ if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
+ *q++ = *p;
+ }
+
+ if (++x > len) {
+ ret = NULL;
+ break;
+ }
+ }
+
+ return ret;
+}
+
SWITCH_DECLARE(char *) switch_separate_paren_args(char *str)
{
char *e, *args;