add sofia_glue_find_parameter_value function to get a specific value from a url params string

This commit is contained in:
Michael Jerris 2010-10-03 20:00:32 -04:00
parent e11550e761
commit c701d41c3c
2 changed files with 29 additions and 0 deletions

View 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);

View 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;