Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
February 2009
- 20 participants
- 764 discussions
[commit] r11796 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/iptsec
by FreeSWITCH SVN 11 Feb '09
by FreeSWITCH SVN 11 Feb '09
11 Feb '09
Author: mikej
Date: Wed Feb 11 10:47:44 2009
New Revision: 11796
Log:
Thu Jan 8 13:50:53 CST 2009 Pekka Pessi <first.last(a)nokia.com>
* iptsec: using <sofia-sip/su_string.h> functions
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Wed Feb 11 10:47:44 2009
@@ -1 +1 @@
-Wed Feb 11 10:47:06 CST 2009
+Wed Feb 11 10:47:34 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c Wed Feb 11 10:47:44 2009
@@ -47,7 +47,7 @@
#include <sofia-sip/base64.h>
#include <sofia-sip/su_uniqueid.h>
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/su_debug.h>
@@ -166,9 +166,9 @@
if (!ca || !ch)
return -1;
- if (strcasecmp(ca->ca_scheme, scheme))
+ if (!su_casematch(ca->ca_scheme, scheme))
return 0;
- if (strcmp(ca->ca_realm, realm))
+ if (!su_strmatch(ca->ca_realm, realm))
return 0;
if (ca->ca_credential_class &&
@@ -390,13 +390,13 @@
if (!ca || !ca->ca_scheme || !ca->ca_realm)
return -1;
- if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
- (realm != NULL && strcmp(realm, ca->ca_realm)))
+ if ((scheme != NULL && !su_casematch(scheme, ca->ca_scheme)) ||
+ (realm != NULL && !su_strmatch(realm, ca->ca_realm)))
return 0;
old_user = ca->ca_user, old_pass = ca->ca_pass;
- if (str0cmp(user, old_user) == 0 && str0cmp(pass, old_pass) == 0)
+ if (su_strmatch(user, old_user) && su_strmatch(pass, old_pass))
return 0;
new_user = su_strdup(ca->ca_home, user);
@@ -440,14 +440,14 @@
continue;
if (AUTH_CLIENT_IS_EXTENDED(ca) && ca->ca_clear)
continue;
- if (!ca->ca_scheme[0] || strcasecmp(ca->ca_scheme, d->ca_scheme))
+ if (!ca->ca_scheme[0] || !su_casematch(ca->ca_scheme, d->ca_scheme))
continue;
- if (!ca->ca_realm[0] || strcmp(ca->ca_realm, d->ca_realm))
+ if (!ca->ca_realm || !su_strmatch(ca->ca_realm, d->ca_realm))
continue;
if (!(AUTH_CLIENT_IS_EXTENDED(d) && d->ca_clear) &&
- d->ca_user && strcmp(d->ca_user, ca->ca_user) == 0 &&
- d->ca_pass && strcmp(d->ca_pass, ca->ca_pass) == 0) {
+ su_strmatch(d->ca_user, ca->ca_user) &&
+ su_strmatch(d->ca_pass, ca->ca_pass)) {
retval++;
break;
}
@@ -497,8 +497,8 @@
if (!AUTH_CLIENT_IS_EXTENDED(ca))
continue;
- if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
- (realm != NULL && strcmp(realm, ca->ca_realm)))
+ if ((scheme != NULL && !su_casematch(scheme, ca->ca_scheme)) ||
+ (realm != NULL && !su_strmatch(realm, ca->ca_realm)))
continue;
match = ca->ca_auc->auc_clear(*auc_list);
@@ -990,7 +990,7 @@
for (i = 0; i < MAX_AUC; i++) {
if (ca_plugins[i] == NULL ||
- strcmp(plugin->auc_name, ca_plugins[i]->auc_name) == 0) {
+ su_strmatch(plugin->auc_name, ca_plugins[i]->auc_name) == 0) {
ca_plugins[i] = plugin;
return 0;
}
@@ -1018,7 +1018,7 @@
for (i = 0; i < MAX_AUC; i++) {
auc = ca_plugins[i];
- if (!auc || strcasecmp(auc->auc_name, scheme) == 0)
+ if (!auc || su_casematch(auc->auc_name, scheme))
break;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c Wed Feb 11 10:47:44 2009
@@ -44,7 +44,7 @@
#include <sofia-sip/base64.h>
#include <sofia-sip/su_uniqueid.h>
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/su_debug.h>
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c Wed Feb 11 10:47:44 2009
@@ -36,16 +36,13 @@
#include "sofia-sip/auth_common.h"
#include "sofia-sip/msg_header.h"
+#include <sofia-sip/su_string.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
-#if !HAVE_STRCASESTR
-char *strcasestr(char const *haystack, char const *needle);
-#endif
-
su_inline int has_token(char const *qstring, char const *token);
/**
@@ -92,12 +89,12 @@
if expected is found in parameter value,
return non-NULL pointer in *return_value */
for (j = 0; (p = params[j++]);) {
- if (strcasecmp(p, fmt) == 0) {
+ if (su_casematch(p, fmt)) {
/* Matched the whole parameter with fmt name=expected */
value = p;
break;
}
- else if (strncasecmp(p, fmt, namelen) ||
+ else if (!su_casenmatch(p, fmt, namelen) ||
p[namelen] != '=')
continue;
@@ -109,7 +106,7 @@
value = p;
break;
}
- else if (strcasecmp(p, expected) == 0) {
+ else if (su_casematch(p, expected)) {
/* Parameter value matches with extected value
* e.g., qop=auth matches qop=auth */
value = p;
@@ -120,7 +117,7 @@
else {
/* format is name= , return unquoted parameter value after = */
for (j = 0; (p = params[j++]);) {
- if (strncasecmp(p, fmt, len))
+ if (!su_casenmatch(p, fmt, len))
continue;
if (p[len] == '"')
@@ -169,7 +166,8 @@
size_t n = strlen(token);
char const *q;
- q = strcasestr(qstring, token);
+ q = su_strcasestr(qstring, token);
+
return (q &&
(q[n] == 0 || strchr("\", \t", q[n])) &&
(q == qstring || strchr("\", \t", q[-1])));
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c Wed Feb 11 10:47:44 2009
@@ -61,6 +61,7 @@
#include <sofia-sip/su_wait.h>
#include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/su_tagarg.h>
#include <sofia-sip/base64.h>
@@ -181,7 +182,7 @@
am->am_fake = fake;
am->am_remote = url_hdup(am->am_home, (url_t *)remote);
am->am_algorithm = algorithm ? su_strdup(am->am_home, algorithm) : "MD5";
- am->am_nextnonce = !algorithm || strcasecmp(algorithm, "MD5") == 0;
+ am->am_nextnonce = !algorithm || su_casematch(algorithm, "MD5");
if (next_expires == 0)
am->am_nextnonce = 0;
am->am_qop = su_strdup(am->am_home, qop);
@@ -694,11 +695,11 @@
/* Check for qop */
(ar->ar_qop &&
((ar->ar_auth &&
- strcasecmp(ar->ar_qop, "auth") &&
- strcasecmp(ar->ar_qop, "\"auth\"")) ||
+ !su_casematch(ar->ar_qop, "auth") &&
+ !su_casematch(ar->ar_qop, "\"auth\"")) ||
(ar->ar_auth_int &&
- strcasecmp(ar->ar_qop, "auth-int") &&
- strcasecmp(ar->ar_qop, "\"auth-int\"")))
+ !su_casematch(ar->ar_qop, "auth-int") &&
+ !su_casematch(ar->ar_qop, "\"auth-int\"")))
&& (phrase = PA "has invalid qop"))) {
assert(phrase);
SU_DEBUG_5(("auth_method_digest: 400 %s\n", phrase));
@@ -1249,7 +1250,7 @@
char const *arealm;
for (;auth; auth = auth->au_next) {
- if (strcasecmp(auth->au_scheme, scheme))
+ if (!su_casematch(auth->au_scheme, scheme))
continue;
if (!realm)
@@ -1290,7 +1291,7 @@
char const *arealm, *aopaque;
for (;auth; auth = auth->au_next) {
- if (strcasecmp(auth->au_scheme, "Digest"))
+ if (!su_casematch(auth->au_scheme, "Digest"))
continue;
if (realm) {
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c Wed Feb 11 10:47:44 2009
@@ -91,7 +91,7 @@
if (n < 0)
return n;
- if (ac->ac_stale && strcasecmp(ac->ac_stale, "true") != 0)
+ if (ac->ac_stale && !su_casematch(ac->ac_stale, "true"))
ac->ac_stale = NULL;
ac->ac_md5 = md5 != NULL || ac->ac_algorithm == NULL;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c Wed Feb 11 10:47:44 2009
@@ -52,6 +52,7 @@
#include <sofia-sip/su_wait.h>
#include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/su_tagarg.h>
#include "sofia-sip/auth_module.h"
@@ -130,16 +131,16 @@
if (base == NULL)
;
- else if (strcasecmp(base, "Basic") == 0)
+ else if (su_casematch(base, "Basic"))
bscheme = auth_scheme_basic;
- else if (strcasecmp(base, "Digest") == 0)
+ else if (su_casematch(base, "Digest"))
bscheme = auth_scheme_digest;
if (base == NULL || bscheme) {
int i;
for (i = 0; schemes[i] && i < N; i++) {
- if (strncasecmp(schemes[i]->asch_method, method, len) == 0 &&
+ if (su_casenmatch(schemes[i]->asch_method, method, len) &&
schemes[i]->asch_method[len] == 0) {
am = auth_mod_alloc(schemes[i], ta_tags(ta));
if (schemes[i]->asch_init(am, bscheme, root, ta_tags(ta)) == -1) {
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c Wed Feb 11 10:47:44 2009
@@ -170,7 +170,7 @@
char const *agssapidata, *atargetname;
for (;auth; auth = auth_mod_credentials(auth->au_next)) {
- if (strcasecmp(auth->au_scheme, "NTLM"))
+ if (!su_casematch(auth->au_scheme, "NTLM"))
continue;
if (gssapidata) {
@@ -224,11 +224,11 @@
/* Check for qop */
(ar->ar_qop &&
((ar->ar_auth &&
- strcasecmp(ar->ar_qop, "auth") &&
- strcasecmp(ar->ar_qop, "\"auth\"")) ||
+ !su_casematch(ar->ar_qop, "auth") &&
+ !su_casematch(ar->ar_qop, "\"auth\"")) ||
(ar->ar_auth_int &&
- strcasecmp(ar->ar_qop, "auth-int") &&
- strcasecmp(ar->ar_qop, "\"auth-int\"")))
+ !su_casematch(ar->ar_qop, "auth-int") &&
+ !su_casematch(ar->ar_qop, "\"auth-int\"")))
&& (phrase = PA "has invalid qop"))) {
assert(phrase);
SU_DEBUG_5(("auth_method_ntlm: 400 %s\n", phrase));
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c Wed Feb 11 10:47:44 2009
@@ -73,6 +73,7 @@
#include <sofia-sip/auth_client.h>
#include <sofia-sip/msg_header.h>
#include <sofia-sip/su_wait.h>
+#include <sofia-sip/su_string.h>
int tstflags;
char *argv0;
@@ -349,8 +350,11 @@
TEST_SIZE(auth_digest_challenge_get(home, ac, pa->au_params), 6);
TEST0(pz = sip_proxy_authorization_make(home, cred));
- TEST_SIZE(auth_digest_response_get(home, ar, pz->au_params), 8);
+ {
+ size_t n = auth_digest_response_get(home, ar, pz->au_params);
+ TEST_SIZE(n, 8);
+ }
ar->ar_md5 = ac->ac_md5 || ac->ac_algorithm == NULL;
TEST(auth_digest_sessionkey(ar, sessionkey, "test1"), 0);
@@ -702,7 +706,7 @@
if (au->au_params)
for (i = 0; au->au_params[i]; i++) {
- if (strncasecmp(au->au_params[i], "realm=", 6) == 0)
+ if (su_casenmatch(au->au_params[i], "realm=", 6))
continue;
equal = strchr(au->au_params[i], '=');
if (equal)
1
0
[commit] r11795 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/sdp
by FreeSWITCH SVN 11 Feb '09
by FreeSWITCH SVN 11 Feb '09
11 Feb '09
Author: mikej
Date: Wed Feb 11 10:47:14 2009
New Revision: 11795
Log:
Thu Jan 8 13:00:38 CST 2009 Pekka Pessi <first.last(a)nokia.com>
* sdp: using <sofia-sip/su_string.h> functions
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Wed Feb 11 10:47:14 2009
@@ -1 +1 @@
-Wed Feb 11 10:46:42 CST 2009
+Wed Feb 11 10:47:06 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp.c Wed Feb 11 10:47:14 2009
@@ -41,6 +41,7 @@
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/su_types.h>
+#include <sofia-sip/su_string.h>
#include "sofia-sip/sdp.h"
@@ -1156,24 +1157,6 @@
/* ---------------------------------------------------------------------- */
-/* Compare two string pointers */
-su_inline
-int str0cmp(char const *a, char const *b)
-{
- if (a == NULL) a = "";
- if (b == NULL) b = "";
- return strcmp(a, b);
-}
-
-/* Compare two string pointers ignoring case. */
-su_inline
-int str0casecmp(char const *a, char const *b)
-{
- if (a == NULL) a = "";
- if (b == NULL) b = "";
- return strcasecmp(a, b);
-}
-
/** Compare two session descriptions
*/
int sdp_session_cmp(sdp_session_t const *a, sdp_session_t const *b)
@@ -1191,11 +1174,11 @@
return rv;
if ((rv = sdp_origin_cmp(a->sdp_origin, b->sdp_origin)))
return rv;
- if ((rv = str0cmp(a->sdp_subject, b->sdp_subject)))
+ if ((rv = su_strcmp(a->sdp_subject, b->sdp_subject)))
return rv;
- if ((rv = str0cmp(a->sdp_information, b->sdp_information)))
+ if ((rv = su_strcmp(a->sdp_information, b->sdp_information)))
return rv;
- if ((rv = str0cmp(a->sdp_uri, b->sdp_uri)))
+ if ((rv = su_strcmp(a->sdp_uri, b->sdp_uri)))
return rv;
if ((rv = sdp_list_cmp(a->sdp_emails, b->sdp_emails)))
return rv;
@@ -1244,9 +1227,9 @@
return a->o_version < b->o_version ? -1 : 1;
if (a->o_id != b->o_id)
return a->o_id < b->o_id ? -1 : 1;
- if ((rv = strcasecmp(a->o_username, b->o_username)))
+ if ((rv = su_strcasecmp(a->o_username, b->o_username)))
return rv;
- if ((rv = strcasecmp(a->o_address->c_address, b->o_address->c_address)))
+ if ((rv = su_strcasecmp(a->o_address->c_address, b->o_address->c_address)))
return rv;
return 0;
@@ -1380,9 +1363,9 @@
if (a->k_method != b->k_method)
return a->k_method < b->k_method ? -1 : 1;
if (a->k_method == sdp_key_x &&
- (rv = str0cmp(a->k_method_name, b->k_method_name)))
+ (rv = su_strcmp(a->k_method_name, b->k_method_name)))
return rv;
- return str0cmp(a->k_material, b->k_material);
+ return su_strcmp(a->k_material, b->k_material);
}
/** Compare two attribute (a=) fields */
@@ -1395,9 +1378,9 @@
if ((a != NULL) != (b != NULL))
return (a != NULL) < (b != NULL) ? -1 : 1;
- if ((rv = str0cmp(a->a_name, b->a_name)))
+ if ((rv = su_strcmp(a->a_name, b->a_name)))
return rv;
- return str0cmp(a->a_value, b->a_value);
+ return su_strcmp(a->a_value, b->a_value);
}
/** Compare two rtpmap structures. */
@@ -1414,7 +1397,7 @@
return a->rm_pt < b->rm_pt ? -1 : 1;
/* Case insensitive encoding */
- if ((rv = str0cmp(a->rm_encoding, b->rm_encoding)))
+ if ((rv = su_strcmp(a->rm_encoding, b->rm_encoding)))
return rv;
/* Rate */
if (a->rm_rate != b->rm_rate)
@@ -1428,13 +1411,13 @@
if (b->rm_params)
b_param = b->rm_params;
- rv = strcasecmp(a_param, b_param);
+ rv = su_strcasecmp(a_param, b_param);
if (rv)
return rv;
}
- return str0casecmp(a->rm_fmtp, b->rm_fmtp);
+ return su_strcasecmp(a->rm_fmtp, b->rm_fmtp);
}
/** Compare two lists. */
@@ -1447,7 +1430,7 @@
return 0;
if ((a != NULL) != (b != NULL))
return (a != NULL) < (b != NULL) ? -1 : 1;
- if ((rv = str0cmp(a->l_text, b->l_text)))
+ if ((rv = su_strcmp(a->l_text, b->l_text)))
return rv;
}
@@ -1472,7 +1455,7 @@
if (a->m_type != b->m_type)
return a->m_type < b->m_type ? -1 : 1;
if (a->m_type == sdp_media_x)
- if ((rv = str0cmp(a->m_type_name, b->m_type_name)))
+ if ((rv = su_strcmp(a->m_type_name, b->m_type_name)))
return rv;
if (a->m_port != b->m_port)
return a->m_port < b->m_port ? -1 : 1;
@@ -1487,7 +1470,7 @@
if (a->m_proto != b->m_proto)
return a->m_proto < b->m_proto ? -1 : 1;
if (a->m_proto == sdp_media_x)
- if ((rv = str0cmp(a->m_proto_name, b->m_proto_name)))
+ if ((rv = su_strcmp(a->m_proto_name, b->m_proto_name)))
return rv;
if (a->m_mode != b->m_mode)
@@ -1502,7 +1485,7 @@
if ((rv = sdp_list_cmp(a->m_format, b->m_format)))
return rv;
- if ((rv = str0cmp(a->m_information, b->m_information)))
+ if ((rv = su_strcmp(a->m_information, b->m_information)))
return rv;
for (ac = a->m_connections, bc = b->m_connections;
@@ -1548,7 +1531,7 @@
sdp_attribute_t *sdp_attribute_find(sdp_attribute_t const *a, char const *name)
{
for (; a; a = a->a_next) {
- if (strcasecmp(a->a_name, name) == 0)
+ if (su_casematch(a->a_name, name))
break;
}
@@ -1561,13 +1544,13 @@
char const *name)
{
for (; a; a = a->a_next) {
- if (strcasecmp(a->a_name, name) == 0)
+ if (su_casematch(a->a_name, name))
break;
}
if (a == 0)
for (a = a2; a; a = a->a_next) {
- if (strcasecmp(a->a_name, name) == 0)
+ if (su_casematch(a->a_name, name))
break;
}
@@ -1578,13 +1561,13 @@
sdp_mode_t sdp_attribute_mode(sdp_attribute_t const *a, sdp_mode_t defmode)
{
for (; a; a = a->a_next) {
- if (strcasecmp(a->a_name, "sendrecv") == 0)
+ if (su_casematch(a->a_name, "sendrecv"))
return sdp_sendrecv;
- if (strcasecmp(a->a_name, "inactive") == 0)
+ if (su_casematch(a->a_name, "inactive"))
return sdp_inactive;
- if (strcasecmp(a->a_name, "recvonly") == 0)
+ if (su_casematch(a->a_name, "recvonly"))
return sdp_recvonly;
- if (strcasecmp(a->a_name, "sendonly") == 0)
+ if (su_casematch(a->a_name, "sendonly"))
return sdp_sendonly;
}
@@ -1707,7 +1690,7 @@
assert(a->a_name != NULL); assert(a->a_next == NULL);
for (; *list; list = &(*list)->a_next) {
- if (strcasecmp((*list)->a_name, a->a_name) == 0)
+ if (su_casematch((*list)->a_name, a->a_name))
break;
}
@@ -1740,7 +1723,7 @@
return NULL;
for (a = *list; a; list = &a->a_next, a = *list) {
- if (strcasecmp(name, a->a_name) == 0)
+ if (su_casematch(name, a->a_name))
break;
}
@@ -1769,7 +1752,7 @@
type_name = "";
if (type != m->m_type ||
- (type == sdp_media_x && strcasecmp(m->m_type_name, type_name)))
+ (type == sdp_media_x && !su_casematch(m->m_type_name, type_name)))
return 0;
if (proto == sdp_proto_any || m->m_proto == sdp_proto_any)
@@ -1779,7 +1762,7 @@
proto_name = "";
if (proto != m->m_proto ||
- (proto == sdp_proto_x && strcasecmp(m->m_proto_name, proto_name)))
+ (proto == sdp_proto_x && !su_casematch(m->m_proto_name, proto_name)))
return 0;
return 1;
@@ -1796,16 +1779,16 @@
return 1;
if (a->m_type != b->m_type ||
- (a->m_type == sdp_media_x &&
- strcasecmp(b->m_type_name, a->m_type_name)))
+ (a->m_type == sdp_media_x
+ && !su_casematch(b->m_type_name, a->m_type_name)))
return 0;
if (a->m_proto == sdp_proto_any || b->m_proto == sdp_proto_any)
return 1;
if (a->m_proto != b->m_proto ||
- (a->m_proto == sdp_proto_x &&
- strcasecmp(b->m_proto_name, a->m_proto_name)))
+ (a->m_proto == sdp_proto_x
+ && !su_casematch(b->m_proto_name, a->m_proto_name)))
return 0;
return 1;
@@ -1850,7 +1833,7 @@
(m->m_proto == sdp_proto_rtp ||
m->m_proto == sdp_proto_srtp ||
(m->m_proto == sdp_proto_x && m->m_proto_name &&
- strncasecmp(m->m_proto_name, "RTP/", 4) == 0));
+ su_casenmatch(m->m_proto_name, "RTP/", 4)));
}
/** Check if payload type, rtp rate and parameters match in rtpmaps*/
@@ -1867,7 +1850,7 @@
if (a->rm_rate != b->rm_rate)
return 0;
- if (strcasecmp(a->rm_encoding, b->rm_encoding))
+ if (!su_casematch(a->rm_encoding, b->rm_encoding))
return 0;
aparam = a->rm_params; bparam = b->rm_params;
@@ -1877,7 +1860,7 @@
if (!aparam) aparam = "1"; if (!bparam) bparam = "1";
- if (strcasecmp(aparam, bparam))
+ if (!su_casematch(aparam, bparam))
return 0;
return 1;
@@ -1900,7 +1883,7 @@
if (rm->rm_rate != list->rm_rate)
continue;
- if (strcasecmp(rm->rm_encoding, list->rm_encoding) != 0)
+ if (!su_casematch(rm->rm_encoding, list->rm_encoding))
continue;
lparam = rm->rm_params; rparam = list->rm_params;
@@ -1909,7 +1892,7 @@
break;
if (!lparam) lparam = "1"; if (!rparam) rparam = "1";
- if (strcasecmp(lparam, rparam))
+ if (!su_casematch(lparam, rparam))
continue;
break;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_parse.c Wed Feb 11 10:47:14 2009
@@ -30,11 +30,14 @@
* @author Kai Vehmanen <kai.vehmanen(a)nokia.com>
*
* @date Created: Fri Feb 18 10:25:08 2000 ppessi
+ *
+ * @sa @RFC4566, @RFC2327.
*/
#include "config.h"
#include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
#include "sofia-sip/sdp.h"
@@ -50,12 +53,13 @@
*
* SDP parser handle.
*
- * The SDP parser handle is returned by sdp_parse(). It contains either
- * successfully parse SDP session #sdp_session_t or an error message.
+ * The SDP parser handle returned by sdp_parse() contains either
+ * a successfully parsed SDP session #sdp_session_t or an error message.
* If sdp_session() returns non-NULL, parsing was successful.
*
* @sa #sdp_session_t, sdp_parse(), sdp_session(), sdp_parsing_error(),
- * sdp_sanity_check(), sdp_parser_home(), sdp_parser_free().
+ * sdp_sanity_check(), sdp_parser_home(), sdp_parser_free(), @RFC4566,
+ * @RFC2327.
*/
struct sdp_parser_s {
@@ -129,6 +133,9 @@
* Always a valid parser handle.
*
* @todo Parser accepts some non-conforming SDP even with #sdp_f_strict.
+ *
+ * @sa sdp_session(), sdp_parsing_error(), sdp_sanity_check(),
+ * sdp_parser_home(), sdp_parser_free(), @RFC4566, @RFC2327.
*/
sdp_parser_t *
sdp_parse(su_home_t *home, char const msg[], issize_t msgsize, int flags)
@@ -366,7 +373,7 @@
/* Require that version comes first */
record = next(&message, CRLF, strip);
- if (!record || strcmp(record, "v=0")) {
+ if (!su_strmatch(record, "v=0")) {
if (!p->pr_config || !record || record[1] != '=') {
parsing_error(p, "bad SDP message");
return;
@@ -479,14 +486,14 @@
return
c &&
c->c_nettype == sdp_net_in &&
- ((c->c_addrtype == sdp_addr_ip4 && strcmp(c->c_address, "0.0.0.0")) ||
- (c->c_addrtype == sdp_addr_ip6 && strcmp(c->c_address, "::")));
+ ((c->c_addrtype == sdp_addr_ip4 && su_strmatch(c->c_address, "0.0.0.0")) ||
+ (c->c_addrtype == sdp_addr_ip6 && su_strmatch(c->c_address, "::")));
}
/**Postprocess session description.
*
- * The function post_session() postprocesses the session description. The
- * postprocessing includes setting the session backpointer for each media.
+ * Postprocessing includes setting the session backpointer for each media,
+ * doing sanity checks and setting rejected and mode flags.
*/
static void post_session(sdp_parser_t *p, sdp_session_t *sdp)
{
@@ -517,12 +524,9 @@
c = sdp_media_connections(m);
- if (p->pr_mode_0000 && c) {
- if (c->c_nettype == sdp_net_in &&
- c->c_addrtype == sdp_addr_ip4 &&
- strcmp(c->c_address, "0.0.0.0") == 0)
- /* Reset recvonly flag */
- m->m_mode &= ~sdp_recvonly;
+ if (p->pr_mode_0000 && sdp_connection_is_inaddr_any(c)) {
+ /* Reset recvonly flag */
+ m->m_mode &= ~sdp_recvonly;
}
}
@@ -815,7 +819,7 @@
*result = c;
- if (strncasecmp(r, "IN", 2) == 0) {
+ if (su_casenmatch(r, "IN", 2)) {
char *s;
/* nettype is internet */
@@ -824,9 +828,9 @@
/* addrtype */
s = token(&r, SPACE TAB, NULL, NULL);
- if (s && strcasecmp(s, "IP4") == 0)
+ if (su_casematch(s, "IP4"))
c->c_addrtype = sdp_addr_ip4;
- else if (s && strcasecmp(s, "IP6") == 0)
+ else if (su_casematch(s, "IP6"))
c->c_addrtype = sdp_addr_ip6;
else {
parsing_error(p, "unknown IN address type: %s", s);
@@ -907,9 +911,9 @@
return;
}
- if (strcmp(name, "CT") == 0)
+ if (su_casematch(name, "CT"))
modifier = sdp_bw_ct, name = NULL;
- else if (strcmp(name, "AS") == 0)
+ else if (su_casematch(name, "AS") == 0)
modifier = sdp_bw_as, name = NULL;
else
modifier = sdp_bw_x;
@@ -993,16 +997,17 @@
int n, N;
char *s;
sdp_repeat_t *r;
+ int strict = STRICT(p);
/** Count number of intervals */
for (N = 0, s = d; *s; ) {
- if (!(is_posdigit(*s) || (!STRICT(p) && (*s) == '0')))
+ if (!(is_posdigit(*s) || (!strict && (*s) == '0')))
break;
do { s++; } while (is_digit(*s));
- if (*s && strchr("dhms", *s))
+ if (*s && strchr(strict ? "dhms" : "dhmsDHMS", *s))
s++;
N++;
- if (!(i = STRICT(p) ? is_space(*s) : strspn(s, SPACE TAB)))
+ if (!(i = strict ? is_space(*s) : strspn(s, SPACE TAB)))
break;
s += i;
}
@@ -1024,10 +1029,10 @@
tt = strtoul(d, &d, 10);
switch (*d) {
- case 'd': tt *= 24;
- case 'h': tt *= 60;
- case 'm': tt *= 60;
- case 's': d++;
+ case 'd': case 'D': tt *= 24;
+ case 'h': case 'H': tt *= 60;
+ case 'm': case 'M': tt *= 60;
+ case 's': case 'S': d++;
break;
}
@@ -1152,7 +1157,7 @@
/* These are defined as key-sensitive in RFC 4566 */
#define MATCH(s, tok) \
- (STRICT(p) ? strcmp((s), (tok)) == 0 : strcasecmp((s), (tok)) == 0)
+ (STRICT(p) ? su_strmatch((s), (tok)) : su_casematch((s), (tok)))
if (MATCH(s, "clear"))
k->k_method = sdp_key_clear, k->k_method_name = "clear";
@@ -1208,20 +1213,20 @@
else
PARSE_CHECK_REST(p, r, "a");
- if (strcasecmp(name, "charset") == 0) {
+ if (su_casematch(name, "charset")) {
p->pr_session->sdp_charset = value;
return;
}
if (p->pr_mode_manual)
;
- else if (strcasecmp(name, "inactive") == 0)
+ else if (su_casematch(name, "inactive"))
p->pr_session_mode = sdp_inactive;
- else if (strcasecmp(name, "sendonly") == 0)
+ else if (su_casematch(name, "sendonly"))
p->pr_session_mode = sdp_sendonly;
- else if (strcasecmp(name, "recvonly") == 0)
+ else if (su_casematch(name, "recvonly"))
p->pr_session_mode = sdp_recvonly;
- else if (strcasecmp(name, "sendrecv") == 0)
+ else if (su_casematch(name, "sendrecv"))
p->pr_session_mode = sdp_sendrecv;
{
@@ -1317,7 +1322,7 @@
return;
}
- if (!STRICT(p) && strcasecmp(s, "RTP") == 0)
+ if (!STRICT(p) && su_casematch(s, "RTP"))
m->m_proto = sdp_proto_rtp, m->m_proto_name = "RTP/AVP";
else
sdp_media_transport(m, s);
@@ -1344,44 +1349,51 @@
/** Set media type */
void sdp_media_type(sdp_media_t *m, char const *s)
{
- if (strcmp(s, "*") == 0)
+ if (su_strmatch(s, "*"))
m->m_type = sdp_media_any, m->m_type_name = "*";
- else if (strcasecmp(s, "audio") == 0)
+ else if (su_casematch(s, "audio"))
m->m_type = sdp_media_audio, m->m_type_name = "audio";
- else if (strcasecmp(s, "video") == 0)
+ else if (su_casematch(s, "video"))
m->m_type = sdp_media_video, m->m_type_name = "video";
- else if (strcasecmp(s, "application") == 0)
+ else if (su_casematch(s, "application"))
m->m_type = sdp_media_application, m->m_type_name = "application";
- else if (strcasecmp(s, "data") == 0)
+ else if (su_casematch(s, "data"))
m->m_type = sdp_media_data, m->m_type_name = "data";
- else if (strcasecmp(s, "control") == 0)
+ else if (su_casematch(s, "control"))
m->m_type = sdp_media_control, m->m_type_name = "control";
- else if (strcasecmp(s, "message") == 0)
+ else if (su_casematch(s, "message"))
m->m_type = sdp_media_message, m->m_type_name = "message";
- else if (strcasecmp(s, "image") == 0)
+ else if (su_casematch(s, "image"))
m->m_type = sdp_media_image, m->m_type_name = "image";
- else if (strcasecmp(s, "red") == 0)
+ else if (su_casematch(s, "red"))
m->m_type = sdp_media_red, m->m_type_name = "red";
else
m->m_type = sdp_media_x, m->m_type_name = s;
}
+/** Set transport protocol.
+ *
+ * Set the @m->m_proto to a well-known protocol type as
+ * well as canonize case of @a m_proto_name.
+ */
void sdp_media_transport(sdp_media_t *m, char const *s)
{
- if (strcasecmp(s, "*") == 0)
+ if (m == NULL || s == NULL)
+ ;
+ else if (su_strmatch(s, "*"))
m->m_proto = sdp_proto_any, m->m_proto_name = "*";
- else if (strcasecmp(s, "RTP/AVP") == 0)
+ else if (su_casematch(s, "RTP/AVP"))
m->m_proto = sdp_proto_rtp, m->m_proto_name = "RTP/AVP";
- else if (strcasecmp(s, "RTP/SAVP") == 0)
+ else if (su_casematch(s, "RTP/SAVP"))
m->m_proto = sdp_proto_srtp, m->m_proto_name = "RTP/SAVP";
- else if (strcasecmp(s, "udptl") == 0)
+ else if (su_casematch(s, "udptl"))
/* Lower case - be compatible with people living by T.38 examples */
m->m_proto = sdp_proto_udptl, m->m_proto_name = "udptl";
- else if (strcasecmp(s, "UDP") == 0)
+ else if (su_casematch(s, "UDP"))
m->m_proto = sdp_proto_udp, m->m_proto_name = "UDP";
- else if (strcasecmp(s, "TCP") == 0)
+ else if (su_casematch(s, "TCP"))
m->m_proto = sdp_proto_tcp, m->m_proto_name = "TCP";
- else if (strcasecmp(s, "TLS") == 0)
+ else if (su_casematch(s, "TLS"))
m->m_proto = sdp_proto_tls, m->m_proto_name = "TLS";
else
m->m_proto = sdp_proto_x, m->m_proto_name = s;
@@ -1566,28 +1578,28 @@
if (p->pr_mode_manual)
;
- else if (strcasecmp(name, "inactive") == 0) {
+ else if (su_casematch(name, "inactive")) {
m->m_mode = sdp_inactive;
return;
}
- else if (strcasecmp(name, "sendonly") == 0) {
+ else if (su_casematch(name, "sendonly")) {
m->m_mode = sdp_sendonly;
return;
}
- else if (strcasecmp(name, "recvonly") == 0) {
+ else if (su_casematch(name, "recvonly")) {
m->m_mode = sdp_recvonly;
return;
}
- else if (strcasecmp(name, "sendrecv") == 0) {
+ else if (su_casematch(name, "sendrecv")) {
m->m_mode = sdp_sendrecv;
return;
}
- if (rtp && strcasecmp(name, "rtpmap") == 0) {
+ if (rtp && su_casematch(name, "rtpmap")) {
if ((n = parse_rtpmap(p, r, m)) == 0 || n < -1)
return;
}
- else if (rtp && strcasecmp(name, "fmtp") == 0) {
+ else if (rtp && su_casematch(name, "fmtp")) {
if ((n = parse_fmtp(p, r, m)) == 0 || n < -1)
return;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/sdp_print.c Wed Feb 11 10:47:14 2009
@@ -34,6 +34,7 @@
#include "config.h"
#include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
#include "sofia-sip/sdp.h"
@@ -544,10 +545,10 @@
char const *name = a->a_name;
char const *value = a->a_value;
- if (strcasecmp(name, "inactive") == 0 ||
- strcasecmp(name, "sendonly") == 0 ||
- strcasecmp(name, "recvonly") == 0 ||
- strcasecmp(name, "sendrecv") == 0)
+ if (su_casematch(name, "inactive") ||
+ su_casematch(name, "sendonly") ||
+ su_casematch(name, "recvonly") ||
+ su_casematch(name, "sendrecv"))
continue;
sdp_printf(p, "a=%s%s%s" CRLF, name, value ? ":" : "", value ? value : "");
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c Wed Feb 11 10:47:14 2009
@@ -42,6 +42,7 @@
#include <stdlib.h>
#include <sofia-sip/su_types.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/sdp.h>
@@ -913,9 +914,9 @@
int i;
for (i = 1; argv[i]; i++) {
- if (strcmp(argv[i], "-v") == 0)
+ if (su_strmatch(argv[i], "-v"))
tstflags |= tst_verbatim;
- else if (strcmp(argv[i], "-a") == 0)
+ else if (su_strmatch(argv[i], "-a"))
tstflags |= tst_abort;
else
usage(1);
1
0
[commit] r11794 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta libsofia-sip-ua/nta/sofia-sip
by FreeSWITCH SVN 11 Feb '09
by FreeSWITCH SVN 11 Feb '09
11 Feb '09
Author: mikej
Date: Wed Feb 11 10:46:50 2009
New Revision: 11794
Log:
Thu Jan 8 12:38:05 CST 2009 Pekka Pessi <first.last(a)nokia.com>
* nta: use <sofia-sip/su_string.h> functions
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/sl_utils.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Wed Feb 11 10:46:50 2009
@@ -1 +1 @@
-Wed Feb 11 10:46:12 CST 2009
+Wed Feb 11 10:46:42 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Wed Feb 11 10:46:50 2009
@@ -41,11 +41,14 @@
* @author Pekka Pessi <Pekka.Pessi(a)nokia.com>
*
* @date Created: Tue Jun 13 02:57:51 2000 ppessi
+ *
+ * @sa
+ * @RFC3261, @RFC4320
*/
#include "config.h"
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
/** @internal SU message argument structure type */
#define SU_MSG_ARG_T union sm_arg_u
@@ -315,7 +318,7 @@
outgoing_queue_t delayed[1];
outgoing_queue_t resolving[1];
- outgoing_queue_t trying[1]; /* Timer F/E */
+ outgoing_queue_t trying[1]; /* Timer F / Timer E */
outgoing_queue_t completed[1]; /* Timer K */
outgoing_queue_t terminated[1];
@@ -1126,21 +1129,21 @@
sip_via_t const *v;
for (v = agent->sa_public_vias; v; v = v->v_next) {
- if (strcasecmp(via->v_host, v->v_host))
+ if (!su_casematch(via->v_host, v->v_host))
continue;
- if (str0cmp(via->v_port, v->v_port))
+ if (!su_strmatch(via->v_port, v->v_port))
continue;
- if (strcasecmp(via->v_protocol, v->v_protocol))
+ if (!su_casematch(via->v_protocol, v->v_protocol))
continue;
return (sip_via_t *)v;
}
for (v = agent->sa_vias; v; v = v->v_next) {
- if (strcasecmp(via->v_host, v->v_host))
+ if (!su_casematch(via->v_host, v->v_host))
continue;
- if (str0cmp(via->v_port, v->v_port))
+ if (!su_strmatch(via->v_port, v->v_port))
continue;
- if (strcasecmp(via->v_protocol, v->v_protocol))
+ if (!su_casematch(via->v_protocol, v->v_protocol))
continue;
return (sip_via_t *)v;
}
@@ -1570,7 +1573,7 @@
if (algorithm != NONE)
agent->sa_algorithm = su_strdup(home, algorithm);
- if (str0cmp(sigcomp, agent->sa_sigcomp_options)) {
+ if (!su_strmatch(sigcomp, agent->sa_sigcomp_options)) {
msg_param_t const *l = NULL;
char *s = su_strdup(home, sigcomp);
char *s1 = su_strdup(home, s), *s2 = s1;
@@ -2181,7 +2184,7 @@
if (tpn->tpn_comp &&
(nta_compressor_vtable == NULL ||
- strcasecmp(tpn->tpn_comp, nta_compressor_vtable->ncv_name) != 0)) {
+ !su_casematch(tpn->tpn_comp, nta_compressor_vtable->ncv_name))) {
SU_DEBUG_1(("nta(%p): comp=%s not supported for " URL_PRINT_FORMAT "\n",
(void *)self, tpn->tpn_comp, URL_PRINT_ARGS(url)));
}
@@ -2308,11 +2311,11 @@
if (tport_has_ip6(tp)) self->sa_tport_ip6 = 1;
#endif
- if (strcasecmp(tpn->tpn_proto, "udp") == 0)
+ if (su_casematch(tpn->tpn_proto, "udp"))
self->sa_tport_udp = 1;
- else if (strcasecmp(tpn->tpn_proto, "tcp") == 0)
+ else if (su_casematch(tpn->tpn_proto, "tcp"))
self->sa_tport_tcp = 1;
- else if (strcasecmp(tpn->tpn_proto, "sctp") == 0)
+ else if (su_casematch(tpn->tpn_proto, "sctp"))
self->sa_tport_sctp = 1;
if (tport_has_tls(tp)) self->sa_tport_tls = 1;
@@ -2330,7 +2333,7 @@
if (su) {
su_inet_ntop(su->su_family, SU_ADDR(su), host, sizeof host);
- maddr = use_maddr && strcasecmp(canon, host) != 0;
+ maddr = use_maddr && !su_casematch(canon, host);
port = ntohs(su->su_port);
}
else {
@@ -2340,9 +2343,9 @@
port = 0;
}
- if (strncasecmp(tpn->tpn_proto, "tls", 3)
- ? port == SIP_DEFAULT_PORT
- : port == SIPS_DEFAULT_PORT)
+ if (su_casenmatch(tpn->tpn_proto, "tls", 3)
+ ? port == SIPS_DEFAULT_PORT
+ : port == SIP_DEFAULT_PORT)
port = 0;
snprintf(sport, sizeof sport, ":%u", port);
@@ -2471,15 +2474,15 @@
v2 = v1->v_next;
if (v2 &&
- strcasecmp(v1->v_host, v2->v_host) == 0 &&
- str0casecmp(v1->v_port, v2->v_port) == 0) {
+ su_casematch(v1->v_host, v2->v_host) &&
+ su_casematch(v1->v_port, v2->v_port)) {
char const *p1 = v1->v_protocol, *p2 = v2->v_protocol;
- if (strcasecmp(p1, sip_transport_udp))
+ if (!su_casematch(p1, sip_transport_udp))
p1 = v2->v_protocol, p2 = v1->v_protocol;
- if (strcasecmp(p1, sip_transport_udp) == 0 &&
- strcasecmp(p2, sip_transport_tcp) == 0)
+ if (su_casematch(p1, sip_transport_udp) &&
+ su_casematch(p2, sip_transport_tcp))
/* Do not include transport if we have both UDP and TCP */
tp = NULL;
}
@@ -2541,26 +2544,23 @@
if (branch && branch != v->v_branch) {
char const *bvalue = branch + strcspn(branch, "=");
if (*bvalue) bvalue++;
- if (!v->v_branch || strcasecmp(bvalue, v->v_branch))
+ if (!v->v_branch || !su_casematch(bvalue, v->v_branch))
msg_header_replace_param(msg_home(msg), v->v_common, branch);
}
- if (via->v_protocol != v->v_protocol &&
- strcasecmp(via->v_protocol, v->v_protocol))
+ if (!su_casematch(via->v_protocol, v->v_protocol))
clear = 1, v->v_protocol = via->v_protocol;
/* XXX - should we do this? */
if ((!user_via || !v->v_host) &&
- via->v_host != v->v_host &&
- str0cmp(via->v_host, v->v_host))
+ !su_strmatch(via->v_host, v->v_host))
clear = 1, v->v_host = via->v_host;
if ((!user_via || !v->v_port ||
/* Replace port in user Via only if we use udp and no rport */
(v->v_protocol == sip_transport_udp && !v->v_rport &&
!orq->orq_stateless)) &&
- via->v_port != v->v_port &&
- str0cmp(via->v_port, v->v_port))
+ !su_strmatch(via->v_port, v->v_port))
clear = 1, v->v_port = via->v_port;
if (clear)
@@ -2628,7 +2628,7 @@
SU_DEBUG_7(("nta: selecting scheme %s\n", url->url_scheme));
*scheme = url->url_scheme;
- if (strcasecmp(url->url_scheme, "sips") == 0)
+ if (su_casematch(url->url_scheme, "sips"))
tpn->tpn_proto = "tls";
else
tpn->tpn_proto = "*";
@@ -2639,11 +2639,11 @@
for (b = (char *)url->url_params; b[0]; b += n) {
n = strcspn(b, ";");
- if (n > 10 && strncasecmp(b, "transport=", 10) == 0)
+ if (n > 10 && su_casenmatch(b, "transport=", 10))
tpn->tpn_proto = b + 10;
- else if (n > 5 && strncasecmp(b, "comp=", 5) == 0)
+ else if (n > 5 && su_casenmatch(b, "comp=", 5))
tpn->tpn_comp = b + 5;
- else if (n > 6 && strncasecmp(b, "maddr=", 6) == 0)
+ else if (n > 6 && su_casenmatch(b, "maddr=", 6))
tpn->tpn_host = b + 6;
if (b[n])
@@ -2845,7 +2845,7 @@
return;
}
- if (str0casecmp(sip->sip_request->rq_version, sip_version_2_0) != 0) {
+ if (!su_casematch(sip->sip_request->rq_version, sip_version_2_0)) {
agent->sa_stats->as_bad_request++;
agent->sa_stats->as_bad_message++;
@@ -3008,7 +3008,7 @@
return v ? 0 : -1;
}
- if (str0casecmp(v->v_protocol, tpv->v_protocol)) {
+ if (!su_strmatch(v->v_protocol, tpv->v_protocol)) {
tport_hostport(hostport, TPORT_HOSTPORTSIZE, from, 1);
SU_DEBUG_1(("nta: Via check: invalid transport \"%s\" from %s\n",
v->v_protocol, hostport));
@@ -3026,7 +3026,7 @@
if (!tport_hostport(hostport, TPORT_HOSTPORTSIZE, from, 0))
return -1;
- if (strcasecmp(hostport, v->v_host)) {
+ if (!su_casematch(hostport, v->v_host)) {
size_t rlen;
/* Add the "received" field */
memcpy(received, "received=", receivedlen);
@@ -3127,9 +3127,9 @@
url->url_port = lv->v_port;
return 1;
}
- if (url->url_port &&
- strcmp(url->url_port, url_port_default(url->url_type)) == 0)
- /* Remove default port */
+ if (su_strmatch(url->url_port, url_port_default(url->url_type)) ||
+ su_strmatch(url->url_port, ""))
+ /* Remove default or empty port */
url->url_port = NULL;
return 0;
@@ -3196,7 +3196,7 @@
return;
}
- if (str0casecmp(sip->sip_status->st_version, sip_version_2_0) != 0) {
+ if (!su_casematch(sip->sip_status->st_version, sip_version_2_0)) {
agent->sa_stats->as_bad_response++;
agent->sa_stats->as_bad_message++;
@@ -3807,7 +3807,6 @@
su_home_t *home = msg_home(msg);
sip_t *sip = sip_object(msg);
sip_to_t const *to;
- sip_cseq_t *cseq;
uint32_t seq;
url_t reg_url[1];
url_string_t const *original = request_uri;
@@ -3865,7 +3864,7 @@
if (!rq
|| request_uri != (url_string_t *)rq->rq_url
|| method != rq->rq_method
- || str0cmp(method_name, rq->rq_method_name))
+ || !su_strmatch(method_name, rq->rq_method_name))
rq = NULL;
if (rq == NULL) {
@@ -3905,7 +3904,7 @@
sip->sip_from = sip_from_dup(home, leg->leg_local);
else if (leg->leg_local && leg->leg_local->a_tag &&
(!sip->sip_from->a_tag ||
- strcasecmp(sip->sip_from->a_tag, leg->leg_local->a_tag)))
+ !su_casematch(sip->sip_from->a_tag, leg->leg_local->a_tag)))
sip_from_tag(home, sip->sip_from, leg->leg_local->a_tag);
if (sip->sip_from && !sip->sip_from->a_tag) {
@@ -3952,14 +3951,14 @@
sip->sip_call_id = sip_call_id_create(home, NULL);
}
- if ((!sip->sip_cseq ||
- seq != sip->sip_cseq->cs_seq ||
- method != sip->sip_cseq->cs_method ||
- (method == sip_method_unknown &&
- strcmp(method_name, sip->sip_cseq->cs_method_name) != 0)) &&
- (!(cseq = sip_cseq_create(home, seq, method, method_name)) ||
- msg_header_insert(msg, (msg_pub_t *)sip, (msg_header_t *)cseq) < 0))
- return -1;
+ if (!sip->sip_cseq ||
+ seq != sip->sip_cseq->cs_seq ||
+ method != sip->sip_cseq->cs_method ||
+ !su_strmatch(method_name, sip->sip_cseq->cs_method_name)) {
+ sip_cseq_t *cseq = sip_cseq_create(home, seq, method, method_name);
+ if (msg_header_insert(msg, (msg_pub_t *)sip, (msg_header_t *)cseq) < 0)
+ return -1;
+ }
return 0;
}
@@ -4391,10 +4390,10 @@
/* If there already is a tag,
return NULL if it does not match with new one */
if (leg->leg_local->a_tag) {
- if (!tag && str0casecmp(tag, leg->leg_local->a_tag))
- return NULL;
- else
+ if (su_casematch(tag, leg->leg_local->a_tag))
return leg->leg_local->a_tag;
+ else
+ return NULL;
}
if (tag) {
@@ -4711,9 +4710,9 @@
return 0;
else
return
- host_cmp(a->url_host, b->url_host)
- || str0cmp(a->url_port, b->url_port)
- || str0cmp(a->url_user, b->url_user);
+ host_cmp(a->url_host, b->url_host) ||
+ su_strcmp(a->url_port, b->url_port) ||
+ su_strcmp(a->url_user, b->url_user);
}
/** Get a leg by dialog.
@@ -4836,14 +4835,14 @@
if (!remote_tag != !from_tag && !local_tag != !to_tag)
continue;
- if (local_tag && to_tag && strcasecmp(local_tag, to_tag) && to_tag[0])
+ if (local_tag && to_tag && !su_casematch(local_tag, to_tag) && to_tag[0])
continue;
- if (remote_tag && from_tag && strcasecmp(remote_tag, from_tag) && from_tag[0])
+ if (remote_tag && from_tag && !su_casematch(remote_tag, from_tag) && from_tag[0])
continue;
if (leg_url && request_uri && url_cmp(leg_url, request_uri))
continue;
- if (leg_method && method_name && strcasecmp(method_name, leg_method))
+ if (leg_method && method_name && !su_casematch(method_name, leg_method))
continue;
/* Perfect match if both local and To have tag
@@ -4916,7 +4915,7 @@
return leg;
}
else if (leg->leg_method) {
- if (strcasecmp(method_name, leg->leg_method))
+ if (!su_casematch(method_name, leg->leg_method))
continue;
return leg;
}
@@ -5657,7 +5656,7 @@
if (tag && strchr(tag, '='))
tag = strchr(tag, '=') + 1;
- if (tag && irq->irq_tag && strcasecmp(tag, irq->irq_tag))
+ if (tag && irq->irq_tag && !su_casematch(tag, irq->irq_tag))
return NULL;
if (!irq->irq_tag) {
@@ -5845,7 +5844,7 @@
int is_uas_ack = return_ack && agent->sa_is_a_uas;
- if (v->v_branch && strncasecmp(v->v_branch, "z9hG4bK", 7) == 0)
+ if (v->v_branch && su_casenmatch(v->v_branch, "z9hG4bK", 7))
magic_branch = v->v_branch + 7;
else
magic_branch = NULL;
@@ -5859,13 +5858,13 @@
continue;
if (irq->irq_cseq->cs_seq != cseq->cs_seq)
continue;
- if (str0casecmp(irq->irq_from->a_tag, from->a_tag))
+ if (su_strcasecmp(irq->irq_from->a_tag, from->a_tag))
continue;
if (is_uas_ack &&
irq->irq_method == sip_method_invite &&
200 <= irq->irq_status && irq->irq_status < 300 &&
- str0casecmp(irq->irq_tag, to->a_tag) == 0) {
+ su_casematch(irq->irq_tag, to->a_tag)) {
*return_ack = irq;
return NULL;
}
@@ -5878,11 +5877,10 @@
* transaction, except for ACK, where the method of the request
* that created the transaction is INVITE.
*/
-
if (irq->irq_via->v_branch &&
- strcasecmp(irq->irq_via->v_branch + 7, magic_branch) == 0 &&
- strcasecmp(irq->irq_via->v_host, v->v_host) == 0 &&
- str0cmp(irq->irq_via->v_port, v->v_port) == 0) {
+ su_casematch(irq->irq_via->v_branch + 7, magic_branch) &&
+ su_casematch(irq->irq_via->v_host, v->v_host) &&
+ su_strmatch(irq->irq_via->v_port, v->v_port)) {
if (irq->irq_method == cseq->cs_method &&
strcmp(irq->irq_cseq->cs_method_name,
cseq->cs_method_name) == 0)
@@ -5903,9 +5901,9 @@
/* From tag, Call-ID, and CSeq number has been matched above */
/* Match top Via header field */
- if (str0casecmp(irq->irq_via->v_branch, v->v_branch) != 0 ||
- strcasecmp(irq->irq_via->v_host, v->v_host) != 0 ||
- str0cmp(irq->irq_via->v_port, v->v_port) != 0)
+ if (!su_casematch(irq->irq_via->v_branch, v->v_branch) ||
+ !su_casematch(irq->irq_via->v_host, v->v_host) ||
+ !su_strmatch(irq->irq_via->v_port, v->v_port))
;
/* Match Request-URI */
else if (url_cmp(irq->irq_rq->rq_url, rq->rq_url))
@@ -5913,17 +5911,16 @@
else {
/* Match CSeq */
if (irq->irq_method == cseq->cs_method &&
- strcmp(irq->irq_cseq->cs_method_name,
- cseq->cs_method_name) == 0) {
+ su_strmatch(irq->irq_cseq->cs_method_name, cseq->cs_method_name)) {
/* Match To tag */
- if (!str0casecmp(irq->irq_to->a_tag, to->a_tag))
+ if (!su_strcasecmp(irq->irq_to->a_tag, to->a_tag))
return irq; /* found */
}
else if (
/* Tag set by UAS */
- str0casecmp(irq->irq_tag, to->a_tag) &&
+ su_strcasecmp(irq->irq_tag, to->a_tag) &&
/* Original tag */
- str0casecmp(irq->irq_to->a_tag, to->a_tag))
+ su_strcasecmp(irq->irq_to->a_tag, to->a_tag))
;
else if (return_ack && irq->irq_method == sip_method_invite)
return *return_ack = irq, NULL;
@@ -7684,13 +7681,13 @@
if (comp == NULL)
orq->orq_tpn->tpn_comp = comp;
- if (orq->orq_user_via && str0cmp(orq->orq_tpn->tpn_proto, "*") == 0) {
+ if (orq->orq_user_via && su_strmatch(orq->orq_tpn->tpn_proto, "*")) {
char const *proto = sip_via_transport(sip->sip_via);
if (proto) orq->orq_tpn->tpn_proto = proto;
}
if (branch && branch != NONE) {
- if (strncasecmp(branch, "branch=", 7) == 0)
+ if (su_casenmatch(branch, "branch=", 7))
branch = su_strdup(home, branch);
else
branch = su_sprintf(home, "branch=%s", branch);
@@ -7708,7 +7705,7 @@
if (orq->orq_method == sip_method_ack) {
/* Find the original INVITE which we are ACKing */
if (ack_branch != NULL && ack_branch != NONE) {
- if (strncasecmp(ack_branch, "branch=", 7) == 0)
+ if (su_casenmatch(ack_branch, "branch=", 7))
orq->orq_branch = su_strdup(home, ack_branch);
else
orq->orq_branch = su_sprintf(home, "branch=%s", ack_branch);
@@ -7803,7 +7800,7 @@
nta_agent_t *sa = orq->orq_agent;
tport_t *tp;
tp_name_t *tpn = orq->orq_tpn;
- int sips = strcasecmp(orq->orq_scheme, "sips") == 0;
+ int sips = su_casematch(orq->orq_scheme, "sips");
/* Select transport by scheme */
if (sips && strcmp(tpn->tpn_proto, "*") == 0)
@@ -7968,14 +7965,14 @@
/* No retries */;
/* RFC3261, 18.1.1 */
else if (err == EMSGSIZE && !orq->orq_try_tcp_instead) {
- if (strcasecmp(tpn->tpn_proto, "udp") == 0 ||
- strcasecmp(tpn->tpn_proto, "*") == 0) {
+ if (su_casematch(tpn->tpn_proto, "udp") ||
+ su_casematch(tpn->tpn_proto, "*")) {
outgoing_try_tcp_instead(orq);
continue;
}
}
else if (err == ECONNREFUSED && orq->orq_try_tcp_instead) {
- if (strcasecmp(tpn->tpn_proto, "tcp") == 0 && msg_size(msg) <= 65535) {
+ if (su_casematch(tpn->tpn_proto, "tcp") && msg_size(msg) <= 65535) {
outgoing_try_udp_instead(orq);
continue;
}
@@ -8145,7 +8142,7 @@
}
else if (error == ECONNREFUSED && orq->orq_try_tcp_instead) {
/* RFC3261, 18.1.1 */
- if (strcasecmp(tpn->tpn_proto, "tcp") == 0 && msg_size(msg) <= 65535) {
+ if (su_casematch(tpn->tpn_proto, "tcp") && msg_size(msg) <= 65535) {
outgoing_print_tport_error(orq, 5, "retrying with UDP after ",
tpn, msg, error);
outgoing_try_udp_instead(orq);
@@ -8723,7 +8720,7 @@
{
orq->orq_completed = 1;
- outgoing_reset_timer(orq); /* Timer A/E */
+ outgoing_reset_timer(orq); /* Timer A / Timer E */
if (orq->orq_stateless || orq->orq_reliable)
return outgoing_terminate(orq);
@@ -8890,10 +8887,10 @@
continue;
if (orq->orq_method != method && orq->orq_method != method2)
continue;
- if (str0casecmp(orq->orq_from->a_tag, sip->sip_from->a_tag))
+ if (su_strcasecmp(orq->orq_from->a_tag, sip->sip_from->a_tag))
continue;
if (orq->orq_to->a_tag &&
- str0casecmp(orq->orq_to->a_tag, sip->sip_to->a_tag))
+ su_strcasecmp(orq->orq_to->a_tag, sip->sip_to->a_tag))
continue;
if (orq->orq_method == sip_method_ack) {
@@ -8901,7 +8898,7 @@
continue;
}
- if (v && str0casecmp(orq->orq_branch + strlen("branch="), v->v_branch))
+ if (v && !su_casematch(orq->orq_branch + strlen("branch="), v->v_branch))
continue;
break; /* match */
@@ -9012,7 +9009,7 @@
return outgoing_duplicate(orq, msg, sip);
if (sa->sa_is_a_uas) {
- if (str0cmp(sip->sip_to->a_tag, orq->orq_tag) == 0)
+ if (su_strcasecmp(sip->sip_to->a_tag, orq->orq_tag) == 0)
/* Catch retransmission */
return outgoing_duplicate(orq, msg, sip);
}
@@ -9333,7 +9330,7 @@
if (orq->orq_destroyed) {
if (orq->orq_status < 200)
orq->orq_status = status;
- outgoing_complete(orq); /* Timer D/K */
+ outgoing_complete(orq); /* Timer D / Timer K */
return 0;
}
@@ -9589,13 +9586,13 @@
tport;
tport = tport_next(tport)) {
tp_name_t const *tpn = tport_name(tport);
- if (strcmp(tpname, "*") && strcasecmp(tpn->tpn_proto, tpname))
+ if (strcmp(tpname, "*") && !su_casematch(tpn->tpn_proto, tpname))
continue;
if (ident && (tpn->tpn_ident == NULL || strcmp(ident, tpn->tpn_ident)))
continue;
for (j = 0; j < SIPDNS_TRANSPORTS; j++)
- if (strcasecmp(tpn->tpn_proto, sipdns_tports[j].name) == 0)
+ if (su_casematch(tpn->tpn_proto, sipdns_tports[j].name))
break;
assert(j < SIPDNS_TRANSPORTS);
@@ -10021,8 +10018,8 @@
break;
/* Check if NAPTR matches our target */
- if (strncasecmp(na->na_services, "SIP+", 4) &&
- strncasecmp(na->na_services, "SIPS+", 5))
+ if (!su_casenmatch(na->na_services, "SIP+", 4) &&
+ !su_casenmatch(na->na_services, "SIPS+", 5))
/* Not a SIP/SIPS service */
continue;
@@ -10036,7 +10033,7 @@
* but comparing the values in the transport list
* match with those values that make any sense
*/
- if (strcasecmp(na->na_services, sr->sr_tports[j]->service) != 0)
+ if (!su_casematch(na->na_services, sr->sr_tports[j]->service))
continue;
tpn->tpn_proto = sr->sr_tports[j]->name;
@@ -10721,8 +10718,8 @@
irq->irq_method == sip_method_invite &&
strcmp(irq->irq_call_id->i_id, i->i_id) == 0 &&
(irq->irq_to->a_tag == NULL ||
- str0casecmp(irq->irq_to->a_tag, sip->sip_to->a_tag) == 0) &&
- str0casecmp(irq->irq_from->a_tag, sip->sip_from->a_tag) == 0) {
+ su_casematch(irq->irq_to->a_tag, sip->sip_to->a_tag)) &&
+ su_casematch(irq->irq_from->a_tag, sip->sip_from->a_tag)) {
nta_reliable_t const *rel;
@@ -11146,8 +11143,8 @@
__func__, resp->sip_status->st_status));
return NULL;
}
- if (str0casecmp(resp->sip_to->a_tag, leg->leg_remote->a_tag) ||
- str0casecmp(resp->sip_to->a_tag, oorq->orq_to->a_tag)) {
+ if (su_strcasecmp(resp->sip_to->a_tag, leg->leg_remote->a_tag) ||
+ su_strcasecmp(resp->sip_to->a_tag, oorq->orq_to->a_tag)) {
SU_DEBUG_1(("%s: %u response To tag does not agree with dialog tag\n",
__func__, resp->sip_status->st_status));
return NULL;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_check.c Wed Feb 11 10:46:50 2009
@@ -219,14 +219,14 @@
if (sip->sip_payload == NULL)
return 0;
- if (cd == NULL || strcasecmp(cd->cd_type, "session") == 0) {
+ if (cd == NULL || su_casematch(cd->cd_type, "session")) {
sip_accept_t const *ab = session_accepts;
char const *c_type;
if (c)
c_type = c->c_type;
else if (sip->sip_payload->pl_len > 3 &&
- strncasecmp(sip->sip_payload->pl_data, "v=0", 3) == 0)
+ su_casenmatch(sip->sip_payload->pl_data, "v=0", 3))
/* Missing Content-Type, but it looks like SDP */
c_type = application_sdp;
else
@@ -234,7 +234,7 @@
ab = NULL, c_type = NULL;
for (; ab; ab = ab->ac_next) {
- if (strcasecmp(c_type, ab->ac_type) == 0)
+ if (su_casematch(c_type, ab->ac_type))
break;
}
@@ -311,7 +311,7 @@
method == sip_method_prack ||
method == sip_method_update)) {
for (ab = acceptable; ab; ab = ab->ac_next)
- if (strcasecmp(application_sdp, ab->ac_type) == 0) {
+ if (su_casematch(application_sdp, ab->ac_type)) {
if (return_acceptable) *return_acceptable = ab;
return 0;
}
@@ -322,7 +322,7 @@
continue;
for (ab = acceptable; ab; ab = ab->ac_next)
- if (strcasecmp(ac->ac_type, ab->ac_type) == 0) {
+ if (su_casematch(ac->ac_type, ab->ac_type)) {
if (return_acceptable) *return_acceptable = ab;
return 0;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_log.c Wed Feb 11 10:46:50 2009
@@ -237,8 +237,8 @@
log = su_log_default;
while (s < end && *s != '\0') {
- size_t n = strncspn(s, end - s, "\r\n");
- size_t crlf = strnspn(s + n, end - s - n, "\r\n");
+ size_t n = su_strncspn(s, end - s, "\r\n");
+ size_t crlf = su_strnspn(s + n, end - s - n, "\r\n");
if (n < 70) {
memcpy(line, s, n);
line[n] = '\0';
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sl_utils_print.c Wed Feb 11 10:46:50 2009
@@ -214,8 +214,8 @@
size_t n, total = 0, crlf = 1, actual;
while (s < end && *s != '\0') {
- n = strncspn(s, end - s, "\r\n");
- crlf = strnspn(s + n, end - s - n, "\r\n");
+ n = su_strncspn(s, end - s, "\r\n");
+ crlf = su_strnspn(s + n, end - s - n, "\r\n");
if (prefix)
fputs(prefix, stream), total += strlen(prefix);
actual = fwrite(s, 1, n + crlf, stream) ;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/sl_utils.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/sl_utils.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/sl_utils.h Wed Feb 11 10:46:50 2009
@@ -38,7 +38,7 @@
#include <stdio.h>
#ifndef STRING0_H
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
#endif
#ifndef SIP_H
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c Wed Feb 11 10:46:50 2009
@@ -62,7 +62,7 @@
#include <sofia-sip/hostdomain.h>
#include <sofia-sip/tport.h>
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
#include <stddef.h>
#include <stdlib.h>
@@ -564,7 +564,7 @@
TEST_1(ag->ag_mclass);
#if SU_HAVE_IN6
- if (str0cmp(getenv("ipv6"), "true") == 0) {
+ if (su_strmatch(getenv("ipv6"), "true")) {
contact = "sip:[::]:*;comp=sigcomp";
af = AF_INET6, sulen0 = sizeof (struct sockaddr_in6);
}
@@ -1075,22 +1075,22 @@
TEST_1(v = nta_agent_via(ag->ag_agent));
for (; v; v = v->v_next) {
- if (strcasecmp(v->v_protocol, sip_transport_udp) == 0) {
+ if (su_casematch(v->v_protocol, sip_transport_udp)) {
if (udp)
v_udp_only = v;
udp = 1;
if (udp_comp == NULL)
udp_comp = v->v_comp;
}
- else if (strcasecmp(v->v_protocol, sip_transport_tcp) == 0) {
+ else if (su_casematch(v->v_protocol, sip_transport_tcp)) {
tcp = 1;
if (tcp_comp == NULL)
tcp_comp = v->v_comp;
}
- else if (strcasecmp(v->v_protocol, sip_transport_sctp) == 0) {
+ else if (su_casematch(v->v_protocol, sip_transport_sctp)) {
sctp = 1;
}
- else if (strcasecmp(v->v_protocol, sip_transport_tls) == 0) {
+ else if (su_casematch(v->v_protocol, sip_transport_tls)) {
tls = 1;
}
}
@@ -1454,7 +1454,7 @@
TEST_P(ag->ag_latest_leg, ag->ag_default_leg);
TEST_1(ag->ag_in_via);
- TEST_1(strcasecmp(ag->ag_in_via->v_protocol, "SIP/2.0/UDP") == 0);
+ TEST_1(su_casematch(ag->ag_in_via->v_protocol, "SIP/2.0/UDP"));
su_free(ag->ag_home, ag->ag_in_via), ag->ag_in_via = NULL;
}
@@ -1787,13 +1787,13 @@
TEST_1(v = nta_agent_via(ag->ag_agent));
for (; v; v = v->v_next) {
- if (strcasecmp(v->v_protocol, sip_transport_udp) == 0)
+ if (su_casematch(v->v_protocol, sip_transport_udp))
udp = 1;
- else if (strcasecmp(v->v_protocol, sip_transport_tcp) == 0)
+ else if (su_casematch(v->v_protocol, sip_transport_tcp))
tcp = 1;
- else if (strcasecmp(v->v_protocol, sip_transport_sctp) == 0)
+ else if (su_casematch(v->v_protocol, sip_transport_sctp))
sctp = 1;
- else if (strcasecmp(v->v_protocol, sip_transport_tls) == 0)
+ else if (su_casematch(v->v_protocol, sip_transport_tls))
tls = 1;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c Wed Feb 11 10:46:50 2009
@@ -59,6 +59,7 @@
#include <sofia-sip/msg_mclass.h>
#include <sofia-sip/sofia_features.h>
#include <sofia-sip/hostdomain.h>
+#include <sofia-sip/su_string.h>
#include <stddef.h>
#include <stdlib.h>
@@ -67,7 +68,6 @@
#include <stdio.h>
#include <assert.h>
#include <time.h>
-#include "sofia-sip/string0.h"
extern su_log_t nta_log[];
extern su_log_t tport_log[];
@@ -763,14 +763,14 @@
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(!v->v_next);
- TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(m = nta_agent_contact(agent));
TEST_S(m->m_url->url_params, "transport=tcp");
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url,
TPTAG_SERVER(0), TAG_END()) == 0);
TEST_1(v = nta_agent_public_via(agent)); TEST_1(!v->v_next);
- TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(host_has_domain_invalid(v->v_host));
TEST_1(m = nta_agent_contact(agent));
TEST_S(m->m_url->url_params, "transport=tcp");
@@ -778,14 +778,14 @@
url->url_params = "transport=udp";
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(v = v->v_next);
- TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_VOID(nta_agent_destroy(agent));
TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END()));
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(!v->v_next);
- TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_1(m = nta_agent_contact(agent));
TEST_S(m->m_url->url_params, "transport=udp");
TEST_VOID(nta_agent_destroy(agent));
@@ -795,9 +795,9 @@
TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END()));
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent));
- TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(v = v->v_next);
- TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_1(m = nta_agent_contact(agent));
TEST_1(!m->m_url->url_params);
TEST_VOID(nta_agent_destroy(agent));
@@ -807,9 +807,9 @@
TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END()));
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent));
- TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_1(v = v->v_next);
- TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0);
+ TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(m = nta_agent_contact(agent));
TEST_1(!m->m_url->url_params);
TEST_VOID(nta_agent_destroy(agent));
@@ -866,7 +866,7 @@
/* Test that NULL host and/or port fields of user supplied Via header are
- filled in automaticaly */
+ filled in automatically */
int api_test_user_via_fillin(agent_t *ag)
{
su_home_t home[1];
@@ -879,7 +879,7 @@
sip_via_t *via0, *via1;
sip_via_t via[1];
static char *via_params[] = { "param1=value1", "param2=value2" };
- int i;
+ size_t i;
BEGIN();
@@ -912,30 +912,30 @@
/* create user Via template to be filled in by NTA */
sip_via_init(via);
via->v_protocol = "*";
- for (i = 0; i < sizeof(via_params)/sizeof(via_params[0]); i++)
- sip_via_add_param(home,via,via_params[i]); /* add param to the template */
+ for (i = 0; i < sizeof(via_params) / sizeof(via_params[0]); i++)
+ sip_via_add_param(home, via, via_params[i]); /* add param to the template */
/* This creates a delayed response message */
orq1 = nta_outgoing_tcreate(leg, outgoing_callback, ag, NULL,
- SIP_METHOD_MESSAGE,
- URL_STRING_MAKE("sip:foo.bar;transport=none"),
- SIPTAG_FROM_STR("<sip:bar.foo>"),
- SIPTAG_TO_STR("<sip:foo.bar>"),
- NTATAG_USER_VIA(1),
- SIPTAG_VIA(via),
- TAG_END());
+ SIP_METHOD_MESSAGE,
+ URL_STRING_MAKE("sip:foo.bar;transport=none"),
+ SIPTAG_FROM_STR("<sip:bar.foo>"),
+ SIPTAG_TO_STR("<sip:foo.bar>"),
+ NTATAG_USER_VIA(1),
+ SIPTAG_VIA(via),
+ TAG_END());
TEST_1(orq1);
TEST_1(msg1 = nta_outgoing_getrequest(orq1));
TEST_1(sip1 = sip_object(msg1));
TEST_1(via1 = sip1->sip_via);
/* check that template has been filled correctly */
- TEST_S(via0->v_protocol,via1->v_protocol);
- TEST_S(via0->v_host,via1->v_host);
- TEST_S(via0->v_port,via1->v_port);
+ TEST_S(via0->v_protocol, via1->v_protocol);
+ TEST_S(via0->v_host, via1->v_host);
+ TEST_S(via0->v_port, via1->v_port);
/* check that the parameter has been preserved */
for (i = 0; i < sizeof(via_params)/sizeof(via_params[0]); i++)
- TEST_S(via1->v_params[i],via_params[i]);
+ TEST_S(via1->v_params[i], via_params[i]);
TEST_VOID(nta_outgoing_destroy(orq0));
TEST_VOID(nta_outgoing_destroy(orq1));
1
0
[commit] r11793 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/http
by FreeSWITCH SVN 11 Feb '09
by FreeSWITCH SVN 11 Feb '09
11 Feb '09
Author: mikej
Date: Wed Feb 11 10:46:25 2009
New Revision: 11793
Log:
Thu Jan 8 12:14:14 CST 2009 Pekka Pessi <first.last(a)nokia.com>
* http: use <sofia-sip/su_string.h> functions
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_basic.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_extra.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Wed Feb 11 10:46:25 2009
@@ -1 +1 @@
-Wed Feb 11 10:45:40 CST 2009
+Wed Feb 11 10:46:12 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_basic.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_basic.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_basic.c Wed Feb 11 10:46:25 2009
@@ -42,6 +42,7 @@
#define MSG_HDR_T union http_header_u
#include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/http_parser.h>
#include <sofia-sip/http_header.h>
@@ -52,7 +53,6 @@
#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <limits.h>
@@ -446,7 +446,7 @@
{
http_content_range_t *cr = h->sh_content_range;
- if (strncasecmp(s, "bytes", 5))
+ if (!su_casenmatch(s, "bytes", 5))
return -1;
s += 5; skip_lws(&s);
if (s[0] == '*') {
@@ -820,7 +820,7 @@
{
http_if_range_t *ifr = (http_if_range_t *)h;
- if (s[0] == '"' || strncasecmp(s, "W/\"", 3) == 0) {
+ if (s[0] == '"' || su_casenmatch(s, "W/\"", 3)) {
ifr->ifr_tag = s;
return 0;
} else {
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_extra.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_extra.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_extra.c Wed Feb 11 10:46:25 2009
@@ -33,12 +33,7 @@
#include "config.h"
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <assert.h>
+#include <sofia-sip/su_string.h>
/* Avoid casting http_t to msg_pub_t and http_header_t to msg_header_t */
#define MSG_PUB_T struct http_s
@@ -46,6 +41,12 @@
#include "sofia-sip/http_parser.h"
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <assert.h>
+
/* ========================================================================== */
/**@HTTP_HEADER http_proxy_connection Proxy-Connection extension header. */
@@ -348,7 +349,7 @@
char *rest;
#define LOOKING_AT(s, what) \
- (strncasecmp((s), what, strlen(what)) == 0 && (rest = s + strlen(what)))
+ (su_casenmatch((s), what, strlen(what)) && (rest = s + strlen(what)))
/* Special cases from Netscape spec */
if (LOOKING_AT(s, "expires=")) {
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/http/http_parser.c Wed Feb 11 10:46:25 2009
@@ -38,6 +38,7 @@
#define MSG_HDR_T union http_header_u
#include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
#include "sofia-sip/http_parser.h"
#include <sofia-sip/msg_parser.h>
#include <sofia-sip/http_header.h>
@@ -48,7 +49,6 @@
#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <limits.h>
@@ -143,8 +143,7 @@
*/
http->http_transfer_encoding->k_items &&
http->http_transfer_encoding->k_items[0] &&
- strcasecmp(http->http_transfer_encoding->k_items[0],
- "identity") != 0) {
+ !su_casematch(http->http_transfer_encoding->k_items[0], "identity")) {
http->http_flags |= MSG_FLG_CHUNKS;
if (http->http_flags & MSG_FLG_STREAMING)
@@ -162,8 +161,7 @@
body_len = http->http_content_length->l_length;
/* We cannot parse multipart/byteranges ... */
else if (http->http_content_type && http->http_content_type->c_type &&
- strcasecmp(http->http_content_type->c_type, "multipart/byteranges")
- == 0)
+ su_casematch(http->http_content_type->c_type, "multipart/byteranges"))
return -1;
else if (MSG_IS_MAILBOX(flags)) /* message fragments */
body_len = 0;
@@ -312,12 +310,12 @@
char const *result;
int const version_size = sizeof(http_version_1_1) - 1;
- if (strncasecmp(s, http_version_1_1, version_size) == 0 &&
+ if (su_casenmatch(s, http_version_1_1, version_size) &&
!IS_TOKEN(s[version_size])) {
result = http_version_1_1;
s += version_size;
}
- else if (strncasecmp(s, http_version_1_0, version_size) == 0 &&
+ else if (su_casenmatch(s, http_version_1_0, version_size) &&
!IS_TOKEN(s[version_size])) {
result = http_version_1_0;
s += version_size;
@@ -349,9 +347,9 @@
s[l1 + 1 + l2] = 0;
/* Compare again with compacted version */
- if (strcasecmp(s, http_version_1_1) == 0)
+ if (su_casematch(s, http_version_1_1))
result = http_version_1_1;
- else if (strcasecmp(s, http_version_1_0) == 0)
+ else if (su_casematch(s, http_version_1_0))
result = http_version_1_0;
}
@@ -452,7 +450,7 @@
int code = http_method_unknown;
size_t n = 0;
-#define MATCH(s, m) (strncasecmp(s, m, n = sizeof(m) - 1) == 0)
+#define MATCH(s, m) (su_casenmatch(s, m, n = sizeof(m) - 1))
if (c >= 'a' && c <= 'z')
c += 'A' - 'a';
1
0
[commit] r11792 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/su
by FreeSWITCH SVN 11 Feb '09
by FreeSWITCH SVN 11 Feb '09
11 Feb '09
Author: mikej
Date: Wed Feb 11 10:45:51 2009
New Revision: 11792
Log:
Thu Jan 8 12:13:38 CST 2009 Pekka Pessi <first.last(a)nokia.com>
* su: using <sofia-sip/su_string.h>
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Wed Feb 11 10:45:51 2009
@@ -1 +1 @@
-Wed Feb 11 10:27:42 CST 2009
+Wed Feb 11 10:45:40 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c Wed Feb 11 10:45:51 2009
@@ -41,6 +41,7 @@
#include <sofia-sip/su.h>
#include <sofia-sip/su_localinfo.h>
+#include <sofia-sip/su_string.h>
#include "su_module_debug.h"
#include <stdio.h>
@@ -1600,7 +1601,7 @@
return ELI_RESOLVER;
}
- if (hints->li_canonname && strcasecmp(name, hints->li_canonname))
+ if (hints->li_canonname && !su_casematch(name, hints->li_canonname))
return 1;
if (!(flags & LI_CANONNAME))
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_port.c Wed Feb 11 10:45:51 2009
@@ -139,7 +139,7 @@
}
#endif
#if HAVE_WIN32
- else if (strcasecmp(name, "wsaevent") == 0) {
+ else if (su_casematch(name, "wsaevent")) {
create = su_wsaevent_port_create;
start = su_wsaevent_clone_start;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_taglist.c Wed Feb 11 10:45:51 2009
@@ -57,6 +57,7 @@
#include <sofia-sip/su_tag_class.h>
#include <sofia-sip/su_tag_inline.h>
#include <sofia-sip/su_tagarg.h>
+#include <sofia-sip/su_string.h>
#ifndef HAVE_STRTOULL
unsigned longlong strtoull(const char *, char **, int);
@@ -1399,10 +1400,10 @@
int retval;
int value = 0;
- if (strncasecmp(s, "true", 4) == 0
+ if (su_casenmatch(s, "true", 4)
&& strlen(s + 4) == strspn(s + 4, " \t\r\n")) {
value = 1, retval = 1;
- } else if (strncasecmp(s, "false", 5) == 0
+ } else if (su_casenmatch(s, "false", 5)
&& strlen(s + 5) == strspn(s + 5, " \t\r\n")) {
value = 0, retval = 1;
} else {
1
0
Author: mikej
Date: Wed Feb 11 10:45:24 2009
New Revision: 11791
Log:
Thu Jan 8 12:13:05 CST 2009 Pekka Pessi <first.last(a)nokia.com>
* tests: using <sofia-sip/su_string.h> functions
Modified:
freeswitch/trunk/libs/sofia-sip/tests/test_call_reject.c
freeswitch/trunk/libs/sofia-sip/tests/test_cancel_bye.c
freeswitch/trunk/libs/sofia-sip/tests/test_nua.h
freeswitch/trunk/libs/sofia-sip/tests/test_proxy.c
Modified: freeswitch/trunk/libs/sofia-sip/tests/test_call_reject.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/tests/test_call_reject.c (original)
+++ freeswitch/trunk/libs/sofia-sip/tests/test_call_reject.c Wed Feb 11 10:45:24 2009
@@ -1254,7 +1254,7 @@
{
(void)arg;
- if (len >= 11 && strncasecmp(message, "SIP/2.0 200", 11) == 0)
+ if (len >= 11 && su_casenmatch(message, "SIP/2.0 200", 11))
return 0;
return len;
}
@@ -1263,7 +1263,7 @@
{
(void)arg;
- if (len >= 7 && strncasecmp(message, "ACK sip", 7) == 0)
+ if (len >= 7 && su_casenmatch(message, "ACK sip", 7))
return 0;
return len;
}
Modified: freeswitch/trunk/libs/sofia-sip/tests/test_cancel_bye.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/tests/test_cancel_bye.c (original)
+++ freeswitch/trunk/libs/sofia-sip/tests/test_cancel_bye.c Wed Feb 11 10:45:24 2009
@@ -945,7 +945,7 @@
{
(void)arg;
- if (strncasecmp(message, "ACK sip:", 8) == 0)
+ if (su_casenmatch(message, "ACK sip:", 8))
ack_sent++;
return len;
Modified: freeswitch/trunk/libs/sofia-sip/tests/test_nua.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/tests/test_nua.h (original)
+++ freeswitch/trunk/libs/sofia-sip/tests/test_nua.h Wed Feb 11 10:45:24 2009
@@ -50,6 +50,7 @@
#include <sofia-sip/su_log.h>
#include <sofia-sip/su_tagarg.h>
#include <sofia-sip/su_tag_io.h>
+#include <sofia-sip/su_string.h>
#include <sofia-sip/nua_tag.h>
#if __APPLE_CC__
Modified: freeswitch/trunk/libs/sofia-sip/tests/test_proxy.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/tests/test_proxy.c (original)
+++ freeswitch/trunk/libs/sofia-sip/tests/test_proxy.c Wed Feb 11 10:45:24 2009
@@ -688,7 +688,7 @@
char const *proto = v->v_protocol;
if (v->v_next &&
- strcasecmp(v->v_host, v->v_next->v_host) == 0 &&
+ su_casematch(v->v_host, v->v_next->v_host) &&
str0cmp(v->v_port, v->v_next->v_port) == 0 &&
((proto == sip_transport_udp &&
v->v_next->v_protocol == sip_transport_tcp) ||
@@ -861,7 +861,7 @@
return 0;
for (o = t->proxy->domains; o; o = o->next)
- if (strcasecmp(host, o->uri->url_host) == 0)
+ if (su_casematch(host, o->uri->url_host))
break;
t->origin = o;
@@ -1286,7 +1286,7 @@
sip_via_t *v = sip->sip_via;
if (m && v && v->v_received && m->m_url->url_host
- && strcasecmp(v->v_received, m->m_url->url_host)
+ && !su_casematch(v->v_received, m->m_url->url_host)
&& host_is_ip_address(m->m_url->url_host))
return respond_transaction(t, 406, "Unacceptable Contact", TAG_END());
1
0
11 Feb '09
Author: mikej
Date: Wed Feb 11 10:44:58 2009
New Revision: 11790
Log:
Thu Jan 8 12:12:55 CST 2009 Pekka Pessi <first.last(a)nokia.com>
* sofia-sip/su_string.h, su_string:c: added to open_c
Modified:
freeswitch/trunk/libs/sofia-sip/open_c/group/bld.inf
freeswitch/trunk/libs/sofia-sip/open_c/group/libsofia-sip-ua.mmp
Modified: freeswitch/trunk/libs/sofia-sip/open_c/group/bld.inf
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/open_c/group/bld.inf (original)
+++ freeswitch/trunk/libs/sofia-sip/open_c/group/bld.inf Wed Feb 11 10:44:58 2009
@@ -87,6 +87,7 @@
../../libsofia-sip-ua/su/sofia-sip/htable2.h \epoc32\include\osextensions\sofia-sip\htable2.h
../../libsofia-sip-ua/su/sofia-sip/rbtree.h \epoc32\include\osextensions\sofia-sip\rbtree.h
../../libsofia-sip-ua/su/sofia-sip/string0.h \epoc32\include\osextensions\sofia-sip\string0.h
+../../libsofia-sip-ua/su/sofia-sip/su_string.h \epoc32\include\osextensions\sofia-sip\su_string.h
../../libsofia-sip-ua/su/sofia-sip/su.h \epoc32\include\osextensions\sofia-sip\su.h
../../libsofia-sip-ua/su/sofia-sip/su_addrinfo.h \epoc32\include\osextensions\sofia-sip\su_addrinfo.h
../../libsofia-sip-ua/su/sofia-sip/su_alloc.h \epoc32\include\osextensions\sofia-sip\su_alloc.h
Modified: freeswitch/trunk/libs/sofia-sip/open_c/group/libsofia-sip-ua.mmp
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/open_c/group/libsofia-sip-ua.mmp (original)
+++ freeswitch/trunk/libs/sofia-sip/open_c/group/libsofia-sip-ua.mmp Wed Feb 11 10:44:58 2009
@@ -64,7 +64,7 @@
SOURCE memcspn.c
SOURCE string0.c
SOURCE strtoull.c
-SOURCE strcasestr.c
+SOURCE su_string.c
SOURCE getopt.c
SOURCE poll.c
1
0
Author: mikej
Date: Wed Feb 11 10:44:14 2009
New Revision: 11789
Log:
add new files to msvc build
Modified:
freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.2008.vcproj
freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj
Modified: freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.2008.vcproj
==============================================================================
--- freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.2008.vcproj (original)
+++ freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.2008.vcproj Wed Feb 11 10:44:14 2009
@@ -274,6 +274,10 @@
>
</File>
<File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_string.c"
+ >
+ </File>
+ <File
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_strlst.c"
>
</File>
@@ -1024,6 +1028,10 @@
>
</File>
<File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_string.h"
+ >
+ </File>
+ <File
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_strlst.h"
>
</File>
Modified: freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj
==============================================================================
--- freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj (original)
+++ freeswitch/trunk/libs/win32/sofia/libsofia_sip_ua_static.vcproj Wed Feb 11 10:44:14 2009
@@ -275,6 +275,10 @@
>
</File>
<File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_string.c"
+ >
+ </File>
+ <File
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_strlst.c"
>
</File>
@@ -1025,6 +1029,10 @@
>
</File>
<File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_string.h"
+ >
+ </File>
+ <File
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\sofia-sip\su_strlst.h"
>
</File>
1
0
11 Feb '09
Author: anthm
Date: Wed Feb 11 10:36:55 2009
New Revision: 11788
Log:
clarify warning
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Feb 11 10:36:55 2009
@@ -736,10 +736,16 @@
int rtp_hold_timeout_sec = 0;
tech_pvt->read_frame.datalen = 0;
- tech_pvt->codec_ms = codec_ms;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
- "Changing codec ptime to %d. I bet you have a linksys/sipura =D\n", tech_pvt->codec_ms);
-
+ "We were told to use ptime %d but what they meant to say was %d\n"
+ "This issue has so far been identified to happen on the following broken platforms/devices:\n"
+ "Linksys/Sipura aka Cisco\n"
+ "ShoreTel\n"
+ "Sonus/L3\n"
+ "We will try to fix it but some of the devices on this list are so broken who knows what will happen..\n"
+ ,
+ (int)tech_pvt->codec_ms, (int)codec_ms);
+ tech_pvt->codec_ms = codec_ms;
switch_core_session_lock_codec_write(session);
switch_core_session_lock_codec_read(session);
@@ -791,7 +797,8 @@
}
tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
-
+ /* inform them of the codec they are actually sending */
+ sofia_glue_do_invite(session);
switch_core_session_unlock_codec_write(session);
switch_core_session_unlock_codec_read(session);
1
0
[commit] r11787 - in freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su: . sofia-sip
by FreeSWITCH SVN 11 Feb '09
by FreeSWITCH SVN 11 Feb '09
11 Feb '09
Author: mikej
Date: Wed Feb 11 10:33:51 2009
New Revision: 11787
Log:
add missing files
Added:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_string.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_string.c
Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_string.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_string.h Wed Feb 11 10:33:51 2009
@@ -0,0 +1,86 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2005 Nokia Corporation.
+ *
+ * Contact: Pekka Pessi <pekka.pessi(a)nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef SOFIA_SIP_SU_STRING_H
+/** Defined when <sofia-sip/su_string.h> is included. */
+#define SOFIA_SIP_SU_STRING_H
+
+/**@file sofia-sip/su_string.h
+ *
+ * @brief String functions for Sofia-SIP.
+ *
+ * Various string comparison functions also accepting NULL pointer as empty
+ * string:
+ * - su_strcmp(),
+ * - su_strncmp(),
+ * - su_strcasecmp() (comparison with US-ASCII case folding to lower case),
+ * - su_strncasecmp() (comparison with US-ASCII case folding to lower case)
+ * - su_casematch() (match token with US-ASCII case folding to lower case)
+ * - su_casenmatch() (match token with US-ASCII case folding to lower case)
+ *
+ * Also includes span functions testing at most @a n bytes:
+ * - su_strncspn()
+ * - su_strnspn().
+ */
+
+#ifndef SU_CONFIG_H
+#include <sofia-sip/su_config.h>
+#endif
+
+#include <string.h>
+
+SOFIA_BEGIN_DECLS
+
+su_inline int su_strcmp(char const *a, char const *b)
+{
+ return strcmp(a ? a : "", b ? b : "");
+}
+
+su_inline int su_strncmp(char const *a, char const *b, size_t n)
+{
+ return strncmp(a ? a : "", b ? b : "", n);
+}
+
+SOFIAPUBFUN char *su_strcasestr(const char *haystack, const char *needle);
+
+SOFIAPUBFUN int su_strcasecmp(char const *s1, char const *s2);
+SOFIAPUBFUN int su_strncasecmp(char const *s1, char const *s2, size_t n);
+
+SOFIAPUBFUN int su_strmatch(char const *str, char const *with);
+SOFIAPUBFUN int su_strnmatch(char const *str, char const *with, size_t n);
+
+SOFIAPUBFUN int su_casematch(char const *s1, char const *with);
+SOFIAPUBFUN int su_casenmatch(char const *s1, char const *with, size_t n);
+
+SOFIAPUBFUN size_t su_strnspn(char const *s, size_t size, char const *term);
+SOFIAPUBFUN size_t su_strncspn(char const *s, size_t ssize, char const *reject);
+
+SOFIAPUBFUN size_t su_memspn(const void *mem, size_t memlen,
+ const void *accept, size_t acceptlen);
+SOFIAPUBFUN size_t su_memcspn(const void *mem, size_t memlen,
+ const void *reject, size_t rejectlen);
+
+SOFIA_END_DECLS
+
+#endif /* !SOFIA_SIP_SU_STRING_H */
Added: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_string.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_string.c Wed Feb 11 10:33:51 2009
@@ -0,0 +1,518 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2005 Nokia Corporation.
+ *
+ * Contact: Pekka Pessi <pekka.pessi(a)nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+/**@internal @file su_string.c
+ * @brief Various string utility functions.
+ *
+ * @author Pekka Pessi <Pekka.Pessi(a)nokia.com>
+ */
+
+#include "config.h"
+
+#include <sofia-sip/su_string.h>
+
+#include <ctype.h>
+#include <string.h>
+#include <stddef.h>
+#include <limits.h>
+
+/** ASCII-case-insensitive substring search.
+ *
+ * Search for substring ASCII-case-insensitively.
+ *
+ */
+char *
+su_strcasestr(const char *haystack,
+ const char *needle)
+{
+ unsigned char lcn, ucn;
+ size_t i;
+
+ if (haystack == NULL || needle == NULL)
+ return NULL;
+
+ lcn = ucn = needle[0];
+ if ('A' <= lcn && lcn <= 'Z')
+ lcn += 'a' - 'A';
+ else if ('a' <= ucn && ucn <= 'z')
+ ucn -= 'a' - 'Z';
+
+ if (lcn == 0)
+ return (char *)haystack;
+
+ while (haystack[0] != 0) {
+ if (lcn == haystack[0] || ucn == haystack[0]) {
+ for (i = 1; ; i++) {
+ char n = needle[i], h = haystack[i];
+ if (n == 0)
+ return (char *)haystack;
+ if (h == 0)
+ return NULL;
+ if (n == h)
+ continue;
+ if ((n ^ h) != ('A' ^ 'a'))
+ break;
+ if ('A' <= n && n <= 'Z')
+ n += 'a' - 'A';
+ else if ('A' <= h && h <= 'Z')
+ h += 'a' - 'A';
+ if (n != h)
+ break;
+ }
+ }
+ haystack++;
+ }
+
+ return NULL; /* Not found */
+}
+
+/** ASCII-case-insensitive comparison.
+ *
+ * Compare two strings colliding upper case and lower case ASCII chars.
+ * Avoid using locale-dependent strcasecmp(). A NULL pointer compares as an
+ * empty string.
+ *
+ * @retval An int less than zero if @a s1 is less than @a s2
+ * @retval Zero if @a s1 matches @a s2
+ * @retval An int greater than zero if @a s1 is greater than @a s2
+ */
+int
+su_strcasecmp(char const *s1,
+ char const *s2)
+{
+ unsigned char const *A = (unsigned char const *)(s1 ? s1 : "");
+ unsigned char const *B = (unsigned char const *)(s2 ? s2 : "");
+
+ for (;;) {
+ unsigned char a = *A++, b = *B++;
+
+ int value = (int)a - (int)b;
+
+ if (a == 0)
+ return value;
+
+ if (value == 0)
+ continue;
+
+ if ('A' <= a && a <= 'Z')
+ a += 'a' - 'A';
+
+ if ('A' <= b && b <= 'Z')
+ b += 'a' - 'A';
+
+ value = (int)a - (int)b;
+
+ if (value)
+ return value;
+ }
+}
+
+/** ASCII-case-insensitive comparison.
+ *
+ * Compare first @a n bytes of two strings colliding upper case and lower
+ * case ASCII chars. Avoid using locale-dependent strncasecmp(). A NULL
+ * pointer compares as an empty string.
+ *
+ * @retval An int less than zero if first @a n bytes of @a s1 is less than @a s2
+ * @retval Zero if first @a n bytes of @a s1 matches @a s2
+ * @retval An int greater than zero if first @a n bytes of @a s1 is greater than @a s2
+ */
+int
+su_strncasecmp(char const *s1,
+ char const *s2,
+ size_t n)
+{
+ unsigned char const *A = (unsigned char const *)(s1 ? s1 : "");
+ unsigned char const *B = (unsigned char const *)(s2 ? s2 : "");
+
+ if (n == 0 || A == B || memcmp(A, B, n) == 0)
+ return 0;
+
+ for (;;) {
+ unsigned char a, b;
+ int value;
+
+ if (n-- == 0)
+ return 0;
+
+ a = *A++, b = *B++;
+
+ value = a - b;
+
+ if (a == 0)
+ return value;
+ if (value == 0)
+ continue;
+
+ if ('A' <= a && a <= 'Z')
+ a += 'a' - 'A';
+
+ if ('A' <= b && b <= 'Z')
+ b += 'a' - 'A';
+
+ value = a - b;
+
+ if (value)
+ return value;
+ }
+}
+
+/** Check if two strings match.
+ *
+ * Compare two strings. Accept NULL arguments: two NULL pointers match each
+ * other, but otherwise NULL pointer does not match anything else, not even
+ * empty string.
+ *
+ * @param s1
+ *
+ * @retval One if @a s1 matches @a s2
+ * @retval Zero if @a s1 does not match @a s2
+ */
+int
+su_strmatch(char const *s1, char const *s2)
+{
+ if (s1 == s2)
+ return 1;
+
+ if (s1 == NULL || s2 == NULL)
+ return 0;
+
+ return strcmp(s1, s2) == 0;
+}
+
+/** ASCII-case-insensitive string match.
+ *
+ * Match two strings colliding upper case and lower case ASCII characters.
+ * Avoid using locale-dependent strncasecmp(). Accept NULL arguments: two
+ * NULL pointers match each other, but otherwise NULL pointer does not match
+ * anything else, not even empty string.
+ *
+ * @retval One if first @a n bytes of @a s1 matches @a s2
+ * @retval Zero if first @a n bytes of @a s1 do not match @a s2
+ */
+int
+su_casematch(char const *s1, char const *s2)
+{
+ if (s1 == s2)
+ return 1;
+
+ if (s1 == NULL || s2 == NULL)
+ return 0;
+
+ for (;;) {
+ unsigned char a = *s1++, b = *s2++;
+
+ if (b == 0)
+ return a == b;
+
+ if (a == b)
+ continue;
+
+ if ('A' <= a && a <= 'Z') {
+ if (a + 'a' - 'A' != b)
+ return 0;
+ }
+ else if ('A' <= b && b <= 'Z') {
+ if (a != b + 'a' - 'A')
+ return 0;
+ }
+ else
+ return 0;
+ }
+}
+
+/** String prefix match.
+ *
+ * Match first @a n bytes of two strings. If @a n is 0, match always, even
+ * if arguments are NULL. Otherwise, accept NULL arguments: two NULL
+ * pointers match each other. NULL pointer does not match
+ * anything else, not even empty string.
+ *
+ * @retval One if first @a n bytes of @a s1 matches @a s2
+ * @retval Zero if first @a n bytes of @a s1 do not match @a s2
+ */
+int
+su_strnmatch(char const *s1,
+ char const *s2,
+ size_t n)
+{
+ if (n == 0)
+ return 1;
+
+ if (s1 == s2)
+ return 1;
+
+ if (s1 == NULL || s2 == NULL)
+ return 0;
+
+ return strncmp(s1, s2, n) == 0;
+}
+
+/** ASCII-case-insensitive string match.
+ *
+ * Compare two strings colliding upper case and lower case ASCII characters.
+ * Avoid using locale-dependent strncasecmp().
+ *
+ * @retval One if first @a n bytes of @a s1 matches @a s2
+ * @retval Zero if first @a n bytes of @a s1 do not match @a s2
+ */
+int
+su_casenmatch(char const *s1,
+ char const *s2,
+ size_t n)
+{
+ if (n == 0)
+ return 1;
+
+ if (s1 == s2)
+ return 1;
+
+ if (s1 == NULL || s2 == NULL)
+ return 0;
+
+ if (strncmp(s1, s2, n) == 0)
+ return 1;
+
+ while (n-- > 0) {
+ unsigned char a = *s1++, b = *s2++;
+
+ if (a == 0 || b == 0)
+ return a == b;
+
+ if (a == b)
+ continue;
+
+ if ('A' <= a && a <= 'Z') {
+ if (a + 'a' - 'A' != b)
+ return 0;
+ }
+ else if ('A' <= b && b <= 'Z') {
+ if (a != b + 'a' - 'A')
+ return 0;
+ }
+ else
+ return 0;
+ }
+
+ return 1;
+}
+
+/** Search a string for a set of characters.
+ *
+ * Calculate the length of the initial segment of first @a n bytes of @a s
+ * which consists entirely of characters in @a accept.
+ *
+ * @param s string to search for characters
+ * @param n limit of search length
+ * @param accept set of characters to accept
+ *
+ * @return
+ * Number of characters in the prefix of @a s which consists only of
+ * characters from @a accept.
+ */
+size_t
+su_strnspn(char const *s, size_t n, char const *accept)
+{
+ size_t len;
+ size_t asize;
+
+ if (accept == NULL || s == NULL)
+ return 0;
+
+ asize = strlen(accept);
+
+ if (asize == 0) {
+ return 0;
+ }
+ else if (asize == 1) {
+ char c, a = accept[0];
+ for (len = 0; len < n && (c = s[len]) && c == a; len++)
+ ;
+ }
+ else if (asize == 2) {
+ char c, a1 = accept[0], a2 = accept[1];
+ for (len = 0; len < n && (c = s[len]) && (c == a1 || c == a2); len++)
+ ;
+ }
+ else {
+ size_t i;
+ char c, a1 = accept[0], a2 = accept[1];
+
+ for (len = 0; len < n && (c = s[len]); len++) {
+
+ if (c == a1 || c == a2)
+ continue;
+
+ for (i = 2; i < asize; i++) {
+ if (c == accept[i])
+ break;
+ }
+
+ if (i == asize)
+ break;
+ }
+ }
+
+ return len;
+}
+
+/** Search a string for a set of characters.
+ *
+ * Calculate the length of the initial segment of first @a n bytes of @a s
+ * which does not constists of characters in @a reject.
+ *
+ * @param s string to search for characters
+ * @param n limit of search length
+ * @param reject set of characters to reject
+ *
+ * @return
+ * Number of characters in the prefix of @a s which are not in @a reject.
+ */
+size_t
+su_strncspn(char const *s, size_t n, char const *reject)
+{
+ size_t len;
+ size_t rsize;
+
+ if (s == NULL)
+ return 0;
+
+ if (reject == NULL)
+ rsize = 0;
+ else
+ rsize = strlen(reject);
+
+ if (rsize == 0) {
+#if HAVE_STRNLEN
+ len = strnlen(s, n);
+#else
+ for (len = 0; len < n && s[len]; len++)
+ ;
+#endif
+ }
+ else if (rsize == 1) {
+ char c, rej = reject[0];
+ for (len = 0; len < n && (c = s[len]) && c != rej; len++)
+ ;
+ }
+ else if (rsize == 2) {
+ char c, rej1 = reject[0], rej2 = reject[1];
+ for (len = 0; len < n && (c = s[len]) && c != rej1 && c != rej2; len++)
+ ;
+ }
+ else {
+ size_t i;
+ char c, rej1 = reject[0], rej2 = reject[1];
+ for (len = 0; len < n && (c = s[len]) && c != rej1 && c != rej2; len++) {
+ for (i = 2; i < rsize; i++)
+ if (c == reject[i])
+ return len;
+ }
+ }
+
+ return len;
+}
+
+/**Scan memory for a set of bytes.
+ *
+ * Calculates the length of the memory area @a mem which consists entirely
+o * of bytes in @a accept.
+ *
+ * @param mem pointer to memory area
+ * @param memlen size of @a mem in bytes
+ * @param accept pointer to table containing bytes to accept
+ * @param acceptlen size of @a accept table
+ *
+ * @return
+ * The number of consequtive bytes in the memory area @a which consists
+ * entirely of bytes in @a accept.
+ */
+size_t su_memspn(const void *mem, size_t memlen,
+ const void *accept, size_t acceptlen)
+{
+ size_t i;
+
+ unsigned char const *m = mem, *a = accept;
+
+ char accepted[UCHAR_MAX + 1];
+
+ if (mem == NULL || memlen == 0 || acceptlen == 0 || accept == NULL)
+ return 0;
+
+ memset(accepted, 0, sizeof accepted);
+
+ for (i = 0; i < acceptlen; i++)
+ accepted[a[i]] = 1;
+
+ for (i = 0; i < memlen; i++)
+ if (!accepted[m[i]])
+ break;
+
+ return i;
+}
+
+/**Search memory for bytes not in a given set.
+ *
+ * Calculates the length of the memory area @a mem which consists entirely
+ * of bytes not in @a reject.
+ *
+ * @param mem pointer to memory area
+ * @param memlen size of @a mem in bytes
+ * @param reject pointer to table containing bytes to reject
+ * @param rejectlen size of @a reject table
+ *
+ * @return
+ * The number of consequtive bytes in the memory area @a which are not in @a
+ * reject.
+ * @par
+ * If @a rejectlen is 0, or @a reject is NULL, it returns @a memlen, size of
+ * the memory area.
+ */
+size_t
+su_memcspn(const void *mem, size_t memlen,
+ const void *reject, size_t rejectlen)
+{
+ size_t i;
+
+ unsigned char const *m = mem, *r = reject;
+
+ char rejected[UCHAR_MAX + 1];
+
+ if (mem == NULL || memlen == 0)
+ return 0;
+
+ if (rejectlen == 0 || reject == 0)
+ return memlen;
+
+ memset(rejected, 0, sizeof rejected);
+
+ for (i = 0; i < rejectlen; i++)
+ rejected[r[i]] = 1;
+
+ for (i = 0; i < memlen; i++)
+ if (rejected[m[i]])
+ break;
+
+ return i;
+}
1
0