move functions to strip commas and non-numeric chars to switch_utils

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16936 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2010-03-08 08:12:12 +00:00
parent 8b20d78f8d
commit f8974f03f9
12 changed files with 66 additions and 454 deletions

View File

@@ -742,6 +742,49 @@ SWITCH_DECLARE(char *) switch_strip_spaces(const char *str)
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;