]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add switch_stristr and use it in dptools
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 16 Oct 2007 14:24:02 +0000 (14:24 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 16 Oct 2007 14:24:02 +0000 (14:24 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5887 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_utils.h
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_utils.c

index 1f93b89085af7d9f07a68455013e38b84463722f..de811dd83b08c1bba9893612dd277dd54760b4c9 100644 (file)
@@ -298,6 +298,8 @@ if (vname) {free(vname); vname = NULL;}vname = strdup(string);}
 */
 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
index 775a27dd4b01d571b99431c42d9fc21dd7c872bb..97813137dc03de4b95cac1a713c8037197837cb3 100644 (file)
@@ -1223,7 +1223,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
                        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;
                        }
index ce2683c3f09d54a1871fd8608c95208c73150e9d..ddd9cb6e309220717ef922289b0139c87c8ba229 100644 (file)
@@ -197,6 +197,27 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(char *to, char *from, char *he
 }
 
 
+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;