]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add sofia_glue_find_parameter_value function to get a specific value from a url param...
authorMichael Jerris <mike@jerris.com>
Mon, 4 Oct 2010 00:00:32 +0000 (20:00 -0400)
committerMichael Jerris <mike@jerris.com>
Mon, 4 Oct 2010 00:00:32 +0000 (20:00 -0400)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c

index 567404607475631ed13f74c6e2bcc035e7ad8a03..f0ebb55a4637b9816b7620d81602c44b1e55699f 100644 (file)
@@ -928,6 +928,7 @@ sofia_transport_t sofia_glue_str2transport(const char *str);
 
 const char *sofia_glue_transport2str(const sofia_transport_t tp);
 char *sofia_glue_find_parameter(const char *str, const char *param);
+char *sofia_glue_find_parameter_value(switch_core_session_t *session, const char *str, const char *param);
 char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport);
 char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profile_t *profile, sofia_transport_t transport);
 char *sofia_glue_strip_uri(const char *str);
index 5e633e0d7910ca129375f38406772d03aa3e5626..9d6cff78e7b5af9a76af715eb68b7510f6a22d67 100644 (file)
@@ -990,6 +990,34 @@ sofia_transport_t sofia_glue_str2transport(const char *str)
        return SOFIA_TRANSPORT_UNKNOWN;
 }
 
+char *sofia_glue_find_parameter_value(switch_core_session_t *session, const char *str, const char *param)
+{
+       const char *param_ptr;
+       char *param_value;
+       char *tmp;
+       switch_size_t param_len;
+
+       if (zstr(str) || zstr(param) || !session) return NULL;
+
+       if (end_of(param) != '=') {
+               param = switch_core_session_sprintf(session, "%s=", param);
+               if (zstr(param)) return NULL;
+       }
+
+       param_len = strlen(param);
+       param_ptr = sofia_glue_find_parameter(str, param);
+
+       if (zstr(param_ptr)) return NULL;
+
+       param_value = switch_core_session_strdup(session, param_ptr + param_len);
+
+       if (zstr(param_value)) return NULL;
+
+       if ((tmp = strchr(param_value, ';'))) *tmp = '\0';
+
+       return param_value;
+}
+
 char *sofia_glue_find_parameter(const char *str, const char *param)
 {
        char *ptr = NULL;