[Freeswitch-svn] [commit] r5887 - in freeswitch/trunk/src: . include mod/applications/mod_dptools
Freeswitch SVN
anthm at freeswitch.org
Tue Oct 16 10:24:03 EDT 2007
Author: anthm
Date: Tue Oct 16 10:24:02 2007
New Revision: 5887
Modified:
freeswitch/trunk/src/include/switch_utils.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/switch_utils.c
Log:
add switch_stristr and use it in dptools
Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h (original)
+++ freeswitch/trunk/src/include/switch_utils.h Tue Oct 16 10:24:02 2007
@@ -298,6 +298,8 @@
*/
SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen);
+SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr);
+
/*!
\brief Escape a string by prefixing a list of characters with an escape character
\param pool a memory pool to use
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Oct 16 10:24:02 2007
@@ -1223,7 +1223,7 @@
cause_str = switch_channel_cause2str(cause);
snprintf(cause_num, sizeof(cause_num), "%u", cause);
- if (switch_true(continue_on_fail) || strstr(cause_str, continue_on_fail) || strstr(cause_str, cause_num)) {
+ if (switch_true(continue_on_fail) || switch_stristr(cause_str, continue_on_fail) || strstr(cause_str, cause_num)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
return;
}
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Tue Oct 16 10:24:02 2007
@@ -197,6 +197,27 @@
}
+SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr)
+{
+ size_t score = strlen(str), x = 0;
+ const char *a = str, *b = instr, *p = NULL;
+
+ while(*a && *b) {
+ if (tolower(*b) == tolower(*a)) {
+ if (++x == score) {
+ return p;
+ }
+ a++;
+ } else {
+ a = str;
+ p = b+1;
+ x = 0;
+ }
+ b++;
+ }
+ return NULL;
+}
+
SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int family)
{
switch_status_t status = SWITCH_STATUS_FALSE;
More information about the Freeswitch-svn
mailing list