Thu Jan 8 14:52:37 CST 2009 Pekka Pessi <first.last@nokia.com>

* nua: using <sofia-sip/su_string.h> functions



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11800 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-02-11 16:49:25 +00:00
parent 371b3a6fa7
commit 31367efd3b
16 changed files with 60 additions and 61 deletions

View File

@ -1 +1 @@
Wed Feb 11 10:48:54 CST 2009
Wed Feb 11 10:49:17 CST 2009

View File

@ -55,6 +55,7 @@
#include <sofia-sip/su_wait.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/su_strlst.h>
#include "sofia-sip/nua.h"
@ -420,11 +421,11 @@ enum nua_substate nua_substate_make(char const *sip_substate)
{
if (sip_substate == NULL)
return nua_substate_active;
else if (strcasecmp(sip_substate, "terminated") == 0)
else if (su_casematch(sip_substate, "terminated"))
return nua_substate_terminated;
else if (strcasecmp(sip_substate, "pending") == 0)
else if (su_casematch(sip_substate, "pending"))
return nua_substate_pending;
else /* if (strcasecmp(sip_substate, "active") == 0) */
else /* if (su_casematch(sip_substate, "active")) */
return nua_substate_active;
}

View File

@ -39,7 +39,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/su_uniqueid.h>
#include <sofia-sip/sip_protos.h>
@ -241,10 +241,10 @@ nua_dialog_usage_at(nua_dialog_state_t const *ds,
if (event != o) {
if (event == NULL || o == NULL)
continue;
if (strcmp(event->o_type, o->o_type))
if (!su_strmatch(event->o_type, o->o_type))
continue;
if (str0casecmp(event->o_id, o->o_id)) {
if (event->o_id || strcmp(event->o_type, "refer"))
if (!su_casematch(event->o_id, o->o_id)) {
if (event->o_id || !su_strmatch(event->o_type, "refer"))
continue;
}
}

View File

@ -39,7 +39,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>

View File

@ -39,7 +39,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>

View File

@ -39,7 +39,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>

View File

@ -42,7 +42,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_extra.h>
#include <sofia-sip/sip_status.h>
@ -220,7 +220,7 @@ int nua_subscribe_server_init(nua_server_request_t *sr)
char const *event = o ? o->o_type : NULL;
if (sr->sr_initial || !nua_dialog_usage_get(ds, nua_notify_usage, o)) {
if (event && str0cmp(event, "refer") == 0)
if (su_strmatch(event, "refer"))
/* refer event subscription should be initiated with REFER */
return SR_STATUS1(sr, SIP_403_FORBIDDEN);
@ -257,7 +257,7 @@ int nua_subscribe_server_preprocess(nua_server_request_t *sr)
}
else {
/* Refresh existing subscription */
if (str0cmp(event, "refer") == 0)
if (su_strmatch(event, "refer"))
expires = NH_PGET(nh, refer_expires);
SR_STATUS1(sr, SIP_200_OK);
@ -360,9 +360,9 @@ int nua_subscribe_server_report(nua_server_request_t *sr, tagi_t const *tags)
if (!nu->nu_tag)
notify = 1;
else if (snim && !strcasecmp(snim->snim_tag, nu->nu_tag))
else if (snim && su_casematch(snim->snim_tag, nu->nu_tag))
notify = 0;
else if (sbim && !strcasecmp(snim->snim_tag, nu->nu_tag))
else if (sbim && su_casematch(snim->snim_tag, nu->nu_tag))
notify = 1, nu->nu_no_body = 1;
else
#endif
@ -621,7 +621,7 @@ static int nua_notify_client_init_etag(nua_client_request_t *cr,
if (cr->cr_usage->du_ready) {
snim = sip_suppress_notify_if_match(sip);
if (snim && !strcasecmp(snim->snim_tag, nu->nu_tag)) {
if (snim && su_casematch(snim->snim_tag, nu->nu_tag)) {
if (nu->nu_requested > nu->nu_expires)
nu->nu_expires = nu->nu_requested;
nu->nu_requested = 0;
@ -630,7 +630,7 @@ static int nua_notify_client_init_etag(nua_client_request_t *cr,
}
sbim = sip_suppress_body_if_match(sip);
if (sbim && !strcasecmp(sbim->sbim_tag, nu->nu_tag))
if (sbim && su_casematch(sbim->sbim_tag, nu->nu_tag))
nu->nu_no_body = 1;
}
#endif
@ -915,8 +915,8 @@ int nua_refer_server_respond(nua_server_request_t *sr, tagi_t const *tags)
if (sr->sr_status < 200 || nu == NULL) {
}
else if (sr->sr_status < 300 &&
/* Application included Refer-Sub: false in response */
(rs == NULL || str0casecmp("false", rs->rs_value))) {
/* No subscription if Refer-Sub: false in response */
(rs == NULL || !su_casematch(rs->rs_value, "false"))) {
sr->sr_usage->du_ready = 1;
nu->nu_expires = sip_now() + NH_PGET(nh, refer_expires);

View File

@ -41,7 +41,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>

View File

@ -32,7 +32,7 @@
#include "config.h"
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/su_strlst.h>
#include <sofia-sip/token64.h>
#include <sofia-sip/su_tagarg.h>
@ -54,10 +54,6 @@
#include <assert.h>
#if !HAVE_STRCASESTR
char *strcasestr(char const *haystack, char const *needle);
#endif
/* ====================================================================== */
/* Helper macros and functions for handling #nua_handle_preferences_t. */
@ -113,7 +109,7 @@ static int already_contains_package_name(char const *s)
char const pn[] = " " PACKAGE_NAME "/";
size_t pnlen = strlen(pn + 1);
return strncasecmp(s, pn + 1, pnlen) == 0 || strcasestr(s, pn);
return su_casenmatch(s, pn + 1, pnlen) || su_strcasestr(s, pn);
}
/* ====================================================================== */
@ -964,7 +960,7 @@ static int nhp_set_tags(su_home_t *home,
/* NUTAG_REGISTRAR(registrar) */
else if (tag == nutag_registrar) {
NHP_SET_STR_BY_URL(nhp, char, registrar, value);
if (NHP_ISSET(nhp, registrar) && !str0cmp(nhp->nhp_registrar, "*"))
if (NHP_ISSET(nhp, registrar) && su_strmatch(nhp->nhp_registrar, "*"))
NHP_SET_STR(nhp, registrar, 0);
}
/* NUTAG_INSTANCE(instance) */

View File

@ -41,7 +41,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>

View File

@ -39,7 +39,7 @@
#define TP_CLIENT_T struct register_usage
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/su_strlst.h>
#include <sofia-sip/su_uniqueid.h>
#include <sofia-sip/su_tagarg.h>
@ -1163,13 +1163,13 @@ nua_stack_init_transport(nua_t *nua, tagi_t const *tags)
if (contact1 &&
(url_is_string(contact1)
? strncasecmp(contact1->us_str, "sips:", 5) == 0
? su_casenmatch(contact1->us_str, "sips:", 5)
: contact1->us_url->url_type == url_sips))
name1 = "sips";
if (contact2 &&
(url_is_string(contact2)
? strncasecmp(contact2->us_str, "sips:", 5) == 0
? su_casenmatch(contact2->us_str, "sips:", 5)
: contact2->us_url->url_type == url_sips))
name2 = "sips";
@ -1379,11 +1379,11 @@ int nua_registration_from_via(nua_registration_t **list,
if (protocol) {
/* Try to pair vias if we have both udp and tcp */
for (prev = vv; *prev; prev = &(*prev)->v_next) {
if (strcasecmp(protocol, (*prev)->v_protocol))
if (!su_casematch(protocol, (*prev)->v_protocol))
continue;
if (strcasecmp(v->v_host, (*prev)->v_host))
if (!su_casematch(v->v_host, (*prev)->v_host))
continue;
if (str0cmp(v->v_port, (*prev)->v_port))
if (!su_strmatch(v->v_port, (*prev)->v_port))
continue;
break;
}
@ -2023,7 +2023,7 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
}
if (transport) {
if (strncasecmp(transport, "SIP/2.0/", 8) == 0)
if (su_casenmatch(transport, "SIP/2.0/", 8))
transport += 8;
/* Make transport parameter lowercase */

View File

@ -39,7 +39,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>
#include <sofia-sip/sip_util.h>

View File

@ -39,7 +39,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>
#include <sofia-sip/sip_util.h>
@ -4337,9 +4337,9 @@ void session_timer_store(struct session_timer *t,
if (x->x_refresher) {
int uas = sip->sip_request != NULL;
if (strcasecmp(x->x_refresher, "uac") == 0)
if (su_casenmatch(x->x_refresher, "uac", (sizeof "uac")))
t->remote.refresher = uas ? nua_remote_refresher : nua_local_refresher;
else if (strcasecmp(x->x_refresher, "uas") == 0)
else if (su_casenmatch(x->x_refresher, "uas", (sizeof "uas")))
t->remote.refresher = uas ? nua_local_refresher : nua_remote_refresher;
}
else if (t->remote.require) {
@ -4533,7 +4533,7 @@ int session_get_description(sip_t const *sip,
else if (ct->c_type == NULL)
SU_DEBUG_3(("nua: empty %s, assuming %s\n",
"Content-Type", SDP_MIME_TYPE));
else if (strcasecmp(ct->c_type, SDP_MIME_TYPE)) {
else if (!su_casematch(ct->c_type, SDP_MIME_TYPE)) {
SU_DEBUG_5(("nua: unknown %s: %s\n", "Content-Type", ct->c_type));
return 0;
}
@ -4545,7 +4545,7 @@ int session_get_description(sip_t const *sip,
if (!matching_content_type) {
/* Make sure we got SDP */
if (pl->pl_len < 3 || strncasecmp(pl->pl_data, "v=0", 3))
if (pl->pl_len < 3 || !su_casenmatch(pl->pl_data, "v=0", 3))
return 0;
}

View File

@ -44,7 +44,7 @@
#include <assert.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>
#include <sofia-sip/sip_extra.h>
@ -547,7 +547,8 @@ int nua_notify_server_init(nua_server_request_t *sr)
/* Check for forked subscription. */
if (ds->ds_remote_tag && ds->ds_remote_tag[0] &&
str0cmp(ds->ds_remote_tag, sr->sr_request.sip->sip_from->a_tag)) {
su_strcasecmp(ds->ds_remote_tag,
sr->sr_request.sip->sip_from->a_tag)) {
sip_contact_t const *m = NULL;
m = nua_stack_get_contact(sr->sr_owner->nh_nua->nua_registrations);
@ -611,18 +612,18 @@ int nua_notify_server_preprocess(nua_server_request_t *sr)
else
substate = nua_substate_active, what = "active";
}
else if (strcasecmp(subs->ss_substate, what = "terminated") == 0) {
else if (su_casematch(subs->ss_substate, what = "terminated")) {
substate = nua_substate_terminated;
reason = subs->ss_reason;
if (str0casecmp(reason, "deactivated") == 0 ||
str0casecmp(reason, "probation") == 0)
if (su_casematch(reason, "deactivated") ||
su_casematch(reason, "probation"))
substate = nua_substate_embryonic;
}
else if (strcasecmp(subs->ss_substate, what = "pending") == 0) {
else if (su_casematch(subs->ss_substate, what = "pending")) {
substate = nua_substate_pending;
}
else /* if (strcasecmp(subs->ss_substate, what = "active") == 0) */ {
else /* if (su_casematch(subs->ss_substate, what = "active")) */ {
/* Any extended state is considered as active */
what = subs->ss_substate;
substate = nua_substate_active;
@ -670,10 +671,10 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
}
else if (substate == nua_substate_embryonic) {
if (subs && subs->ss_reason) {
if (str0casecmp(subs->ss_reason, "deactivated") == 0) {
if (su_casematch(subs->ss_reason, "deactivated")) {
retry = 0; /* retry immediately */
}
else if (str0casecmp(subs->ss_reason, "probation") == 0) {
else if (su_casematch(subs->ss_reason, "probation")) {
retry = 30;
if (subs->ss_retry_after)
retry = strtoul(subs->ss_retry_after, NULL, 10);
@ -913,7 +914,7 @@ static int nua_refer_client_response(nua_client_request_t *cr,
else if (status < 300) {
sip_refer_sub_t const *rs = sip_refer_sub(sip);
if (rs && strcasecmp("false", rs->rs_value) == 0)
if (rs && su_casematch("false", rs->rs_value))
cr->cr_terminated = 1;
if (!cr->cr_terminated)

View File

@ -263,7 +263,7 @@ int outbound_set_options(outbound_t *ob,
prefs->interval = interval;
prefs->stream_interval = stream_interval;
#define MATCH(v) (len == sizeof(#v) - 1 && strncasecmp(#v, s, len) == 0)
#define MATCH(v) (len == sizeof(#v) - 1 && su_casenmatch(#v, s, len))
if (options) {
for (s = options; s[0]; s++) if (s[0] == '-') s[0] = '_';
@ -280,9 +280,9 @@ int outbound_set_options(outbound_t *ob,
size_t len = span_token(s);
int value = 1;
if (len > 3 && strncasecmp(s, "no_", 3) == 0)
if (len > 3 && su_casenmatch(s, "no_", 3))
value = 0, s += 3, len -= 3;
else if (len > 4 && strncasecmp(s, "not_", 4) == 0)
else if (len > 4 && su_casenmatch(s, "not_", 4))
value = 0, s += 4, len -= 4;
if (len == 0)
@ -527,7 +527,7 @@ int outbound_nat_detect(outbound_t *ob,
nat_port = ob->ob_nat_port;
if (nat_detected && host_cmp(received, nat_detected) == 0) {
if (nat_port && strcasecmp(rport, nat_port) == 0)
if (nat_port && su_casematch(rport, nat_port))
return 1;
if (!v->v_rport || !v->v_rport[0])
return 1;
@ -1030,7 +1030,7 @@ int outbound_targeted_request(sip_t const *sip)
sip->sip_request->rq_method == sip_method_options &&
sip->sip_accept &&
sip->sip_accept->ac_type &&
strcasecmp(sip->sip_accept->ac_type, outbound_content_type) == 0;
su_casematch(sip->sip_accept->ac_type, outbound_content_type);
}
/** Answer to the connectivity probe OPTIONS */

View File

@ -44,6 +44,7 @@
#include <sofia-sip/su_log.h>
#include <sofia-sip/su_tagarg.h>
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/su_string.h>
#include <stdlib.h>
#include <string.h>
@ -982,21 +983,21 @@ s2_setup_tport(char const * const *protocols,
tpn->tpn_host,
tpn->tpn_port);
assert(v != NULL);
if (strncasecmp(tpn->tpn_proto, "tls", 3)) {
if (!su_casenmatch(tpn->tpn_proto, "tls", 3)) {
m = sip_contact_format(s2->home, "<sip:%s:%s;transport=%s>",
tpn->tpn_host,
tpn->tpn_port,
tpn->tpn_proto);
if (s2->udp.contact == NULL && strcasecmp(tpn->tpn_proto, "udp") == 0) {
if (s2->udp.contact == NULL && su_casematch(tpn->tpn_proto, "udp")) {
s2->udp.tport = tport_ref(tp);
s2->udp.contact = m;
}
if (s2->tcp.contact == NULL && strcasecmp(tpn->tpn_proto, "tcp") == 0) {
if (s2->tcp.contact == NULL && su_casematch(tpn->tpn_proto, "tcp")) {
s2->tcp.tport = tport_ref(tp);
s2->tcp.contact = m;
}
}
else if (strcasecmp(tpn->tpn_proto, "tls")) {
else if (!su_casematch(tpn->tpn_proto, "tls")) {
m = sip_contact_format(s2->home, "<sips:%s:%s;transport=%s>",
tpn->tpn_host,
tpn->tpn_port,