-Wed Feb 11 10:48:54 CST 2009
+Wed Feb 11 10:49:17 CST 2009
#include <sofia-sip/su_wait.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/su_strlst.h>
#include "sofia-sip/nua.h"
{
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;
}
#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>
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;
}
}
#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 <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 <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 <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>
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);
}
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);
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
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;
}
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
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);
#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 "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>
#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. */
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);
}
/* ====================================================================== */
/* 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) */
#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>
#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>
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";
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;
}
}
if (transport) {
- if (strncasecmp(transport, "SIP/2.0/", 8) == 0)
+ if (su_casenmatch(transport, "SIP/2.0/", 8))
transport += 8;
/* Make transport parameter lowercase */
#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>
#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>
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) {
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;
}
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;
}
#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>
/* 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);
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;
}
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);
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)
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] = '_';
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)
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;
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 */
#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>
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,