SWITCH_DECLARE(switch_status_t) switch_frame_dup(switch_frame_t *orig, switch_frame_t **clone);
SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame);
SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
+SWITCH_DECLARE(char *) switch_find_parameter(const char *str, const char *param, switch_memory_pool_t *pool);
/*!
\brief Evaluate the truthfullness of a string expression
}
if (sip->sip_from && sip->sip_from->a_url) {
- char *tmp;
from_user = sip->sip_from->a_url->url_user;
from_host = sip->sip_from->a_url->url_host;
channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from);
- if (sip->sip_from->a_url->url_params && (tmp = sofia_glue_find_parameter(sip->sip_from->a_url->url_params, "isup-oli="))) {
- aniii = switch_core_session_strdup(session, tmp + 9);
- if ((tmp = strchr(aniii, ';'))) {
- tmp = '\0';
- }
+ if (sip->sip_from->a_url->url_params) {
+ aniii = switch_find_parameter(sip->sip_from->a_url->url_params, "isup-oli", switch_core_session_get_pool(session));
}
if (!zstr(from_user)) {
if (sip->sip_request->rq_url->url_params) {
- gw_param_name = sofia_glue_find_parameter_value(session, sip->sip_request->rq_url->url_params, "gw=");
+ gw_param_name = switch_find_parameter(sip->sip_request->rq_url->url_params, "gw", switch_core_session_get_pool(session));
}
if (strstr(destination_number, "gw+")) {
return SWITCH_STATUS_SUCCESS;
}
+
+SWITCH_DECLARE(char *) switch_find_parameter(const char *str, const char *param, switch_memory_pool_t *pool)
+{
+ char *e, *r = NULL, *ptr = NULL, *next = NULL;
+ size_t len;
+
+ ptr = (char *) str;
+
+ while (ptr) {
+ len = strlen(param);
+ e = ptr+len;
+ next = strchr(ptr, ';');
+
+ if (!strncasecmp(ptr, param, len) && *e == '=') {
+ int mlen;
+
+ ptr = ++e;
+
+ if (next) {
+ e = next;
+ } else {
+ e = ptr + strlen(ptr);
+ }
+
+ mlen = (e - ptr) + 1;
+
+ if (pool) {
+ r = switch_core_alloc(pool, mlen);
+ } else {
+ r = malloc(mlen);
+ }
+
+ *(r + mlen) = '\0';
+
+ switch_snprintf(r, mlen, "%s", ptr);
+
+ break;
+ }
+
+ if (next) {
+ ptr = next + 1;
+ }
+ }
+
+ return r;
+}
+
SWITCH_DECLARE(switch_status_t) switch_network_list_create(switch_network_list_t **list, const char *name, switch_bool_t default_type,
switch_memory_pool_t *pool)
{