SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip);
SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup);
SWITCH_DECLARE(switch_bool_t) switch_ast2regex(const char *pat, char *rbuf, size_t len);
+SWITCH_DECLARE(char *) switch_pool_strip_whitespace(switch_memory_pool_t *pool, const char *str);
/*!
\brief Escape a string by prefixing a list of characters with an escape character
return p;
}
+SWITCH_DECLARE(char *) switch_pool_strip_whitespace(switch_memory_pool_t *pool, const char *str)
+{
+ const char *sp = str;
+ char *p, *s = NULL;
+ size_t len;
+
+ if (zstr(sp)) {
+ return switch_core_strdup(pool, SWITCH_BLANK_STRING);
+ }
+
+ while ((*sp == 13 ) || (*sp == 10 ) || (*sp == 9 ) || (*sp == 32) || (*sp == 11) ) {
+ sp++;
+ }
+
+ if (zstr(sp)) {
+ return switch_core_strdup(pool, SWITCH_BLANK_STRING);
+ }
+
+ s = switch_core_strdup(pool, sp);
+ switch_assert(s);
+
+ if ((len = strlen(s)) > 0) {
+ p = s + (len - 1);
+
+ while ((p >= s) && ((*p == 13 ) || (*p == 10 ) || (*p == 9 ) || (*p == 32) || (*p == 11))) {
+ *p-- = '\0';
+ }
+ }
+
+ return s;
+}
+
SWITCH_DECLARE(char *) switch_strip_whitespace(const char *str)
{
const char *sp = str;