From 31367efd3bf046baecb76075e00ca57239693d01 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 11 Feb 2009 16:49:25 +0000 Subject: [PATCH] Thu Jan 8 14:52:37 CST 2009 Pekka Pessi * nua: using functions git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11800 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/sofia-sip/.update | 2 +- .../libsofia-sip-ua/nua/nua_common.c | 7 ++++--- .../libsofia-sip-ua/nua/nua_dialog.c | 8 +++---- .../libsofia-sip-ua/nua/nua_event_server.c | 2 +- .../libsofia-sip-ua/nua/nua_extension.c | 2 +- .../libsofia-sip-ua/nua/nua_message.c | 2 +- .../libsofia-sip-ua/nua/nua_notifier.c | 18 ++++++++-------- .../libsofia-sip-ua/nua/nua_options.c | 2 +- .../libsofia-sip-ua/nua/nua_params.c | 10 +++------ .../libsofia-sip-ua/nua/nua_publish.c | 2 +- .../libsofia-sip-ua/nua/nua_register.c | 14 ++++++------- .../libsofia-sip-ua/nua/nua_registrar.c | 2 +- .../libsofia-sip-ua/nua/nua_session.c | 10 ++++----- .../libsofia-sip-ua/nua/nua_subnotref.c | 21 ++++++++++--------- libs/sofia-sip/libsofia-sip-ua/nua/outbound.c | 10 ++++----- libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c | 9 ++++---- 16 files changed, 60 insertions(+), 61 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 054c430330..5b56b738b6 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Wed Feb 11 10:48:54 CST 2009 +Wed Feb 11 10:49:17 CST 2009 diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c index c378ea1aa0..6ae94c0f72 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_common.c @@ -55,6 +55,7 @@ #include +#include #include #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; } diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c index eb6a273911..2b70646fec 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c @@ -39,7 +39,7 @@ #include -#include +#include #include #include @@ -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; } } diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c index df7faf2d0b..6467a952d7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_event_server.c @@ -39,7 +39,7 @@ #include -#include +#include #include #include diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c index f327d998e3..f32fabf4fb 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c @@ -39,7 +39,7 @@ #include -#include +#include #include #include diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c index fc9f5760b8..fb39f9ac1b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c @@ -39,7 +39,7 @@ #include -#include +#include #include #include diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c index f77cfb341b..62987b6e5e 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c @@ -42,7 +42,7 @@ #include -#include +#include #include #include #include @@ -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); diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c index 5c7ab9e6dc..0615d9c626 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c @@ -41,7 +41,7 @@ #include -#include +#include #include #include diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c index 73bbc84cf4..318a89124d 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c @@ -32,7 +32,7 @@ #include "config.h" -#include +#include #include #include #include @@ -54,10 +54,6 @@ #include -#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) */ diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c index 924fa7c730..dbe588cc8e 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c @@ -41,7 +41,7 @@ #include -#include +#include #include #include diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c index f3af088674..d06917d9cb 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c @@ -39,7 +39,7 @@ #define TP_CLIENT_T struct register_usage -#include +#include #include #include #include @@ -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 */ diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c index 3a38ae0f72..be58993868 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c @@ -39,7 +39,7 @@ #include -#include +#include #include #include #include diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c index ffa59b6482..aa38b0c998 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c @@ -39,7 +39,7 @@ #include -#include +#include #include #include #include @@ -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; } diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c index 6be3f8670b..768cf6d94b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c @@ -44,7 +44,7 @@ #include -#include +#include #include #include #include @@ -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) diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c b/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c index 8b906ddcfa..c6535c3e4b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c @@ -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 */ diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c b/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c index 366f38ee35..eaf9cc3f85 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -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, "", 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, "", tpn->tpn_host, tpn->tpn_port,