From 2fa6c7435d1c776ab17301ed5ba36bee9fb4de91 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 11 Feb 2009 16:50:29 +0000 Subject: [PATCH] Thu Jan 8 14:56:49 CST 2009 Pekka Pessi * msg: using functions git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11802 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/libsofia-sip-ua/msg/msg_date.c | 3 +- .../libsofia-sip-ua/msg/msg_mclass.c | 3 +- libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c | 36 +++++++++---------- .../libsofia-sip-ua/msg/msg_parser_util.c | 17 ++++----- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 7cfe75543e..0d8f1e33d1 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Wed Feb 11 10:49:44 CST 2009 +Wed Feb 11 10:50:12 CST 2009 diff --git a/libs/sofia-sip/libsofia-sip-ua/msg/msg_date.c b/libs/sofia-sip/libsofia-sip-ua/msg/msg_date.c index d5886b2298..a665e9d495 100644 --- a/libs/sofia-sip/libsofia-sip-ua/msg/msg_date.c +++ b/libs/sofia-sip/libsofia-sip-ua/msg/msg_date.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -238,7 +239,7 @@ issize_t msg_date_d(char const **ss, msg_time_t *date) if (time_d(&s, &hour, &min, &sec) < 0) return -1; if (*s) { tz = s; skip_token(&s); skip_lws(&s); - if (strncasecmp(tz, "GMT", 3) && strncasecmp(tz, "UCT", 3)) + if (!su_casenmatch(tz, "GMT", 3) && !su_casenmatch(tz, "UCT", 3)) return -1; } } diff --git a/libs/sofia-sip/libsofia-sip-ua/msg/msg_mclass.c b/libs/sofia-sip/libsofia-sip-ua/msg/msg_mclass.c index e049f872a9..58c859615b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/msg/msg_mclass.c +++ b/libs/sofia-sip/libsofia-sip-ua/msg/msg_mclass.c @@ -47,6 +47,7 @@ #include #include +#include #include "msg_internal.h" #include "sofia-sip/msg_parser.h" @@ -351,7 +352,7 @@ msg_href_t const *msg_find_hclass(msg_mclass_t const *mc, /* long form */ for (hr = NULL; (hc = mc->mc_hash[i].hr_class); i = (i + 1) % N) { - if (m == hc->hc_len && strncasecmp(s, hc->hc_name, m) == 0) { + if (m == hc->hc_len && su_casenmatch(s, hc->hc_name, m)) { hr = &mc->mc_hash[i]; break; } diff --git a/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c b/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c index 109a7ab8fd..860e939eb1 100644 --- a/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c +++ b/libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c @@ -38,14 +38,8 @@ #define _GNU_SOURCE 1 -#include -#include -#include -#include -#include -#include - #include +#include #include "msg_internal.h" #include "sofia-sip/msg.h" @@ -54,16 +48,18 @@ #include #include +#include +#include +#include +#include +#include +#include + #if !HAVE_MEMMEM void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen); #endif -size_t memspn(const void *mem, size_t memlen, - const void *accept, size_t acceptlen); -size_t memcspn(const void *mem, size_t memlen, - const void *reject, size_t rejectlen); - /** Protocol version of MIME */ char const msg_mime_version_1_0[] = "MIME/1.0"; @@ -154,7 +150,7 @@ char const msg_mime_version_1_0[] = "MIME/1.0"; * argument to msg_multipart_parse() function: * @code * if (sip->sip_content_type && - * strncasecmp(sip->sip_content_type, "multipart/", 10) == 0) { + * su_casenmatch(sip->sip_content_type, "multipart/", 10)) { * msg_multipart_t *mp; * * if (sip->sip_multipart) @@ -316,7 +312,7 @@ msg_multipart_search_boundary(su_home_t *home, char const *p, size_t len) /* Boundary looks like LF -- string SP* [CR] LF */ if (memcmp("--", p, 2) == 0) { /* We can be at boundary beginning, there is no CR LF */ - m = 2 + memspn(p + 2, len - 2, bchars, bchars_len); + m = 2 + su_memspn(p + 2, len - 2, bchars, bchars_len); if (m + 2 >= len) return NULL; crlf = p[m] == '\r' ? 1 + (p[m + 1] == '\n') : (p[m] == '\n'); @@ -336,7 +332,7 @@ msg_multipart_search_boundary(su_home_t *home, char const *p, size_t len) /* Look for LF -- */ for (;(p = memmem(p, end - p, LF "--", 3)); p += 3) { len = end - p; - m = 3 + memspn(p + 3, len - 3, bchars, bchars_len); + m = 3 + su_memspn(p + 3, len - 3, bchars, bchars_len); if (m + 2 >= len) return NULL; crlf = p[m] == '\r' ? 1 + (p[m + 1] == '\n') : (p[m] == '\n'); @@ -1146,7 +1142,7 @@ int msg_accept_update(msg_common_t *h, if (name == NULL) { ac->ac_q = NULL; } - else if (namelen == 1 && strncasecmp(name, "q", 1) == 0) { + else if (namelen == 1 && su_casenmatch(name, "q", 1)) { /* XXX - check for invalid value? */ ac->ac_q = value; } @@ -1233,7 +1229,7 @@ int msg_accept_any_update(msg_common_t *h, if (name == NULL) { aa->aa_q = NULL; } - else if (namelen == 1 && strncasecmp(name, "q", 1) == 0) { + else if (namelen == 1 && su_casenmatch(name, "q", 1)) { aa->aa_q = value; } @@ -1523,10 +1519,10 @@ int msg_content_disposition_update(msg_common_t *h, cd->cd_handling = NULL, cd->cd_required = 0, cd->cd_optional = 0; } else if (namelen == strlen("handling") && - strncasecmp(name, "handling", namelen) == 0) { + su_casenmatch(name, "handling", namelen)) { cd->cd_handling = value; - cd->cd_required = strcasecmp(value, "required") == 0; - cd->cd_optional = strcasecmp(value, "optional") == 0; + cd->cd_required = su_casematch(value, "required"); + cd->cd_optional = su_casematch(value, "optional"); } return 0; diff --git a/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c b/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c index d14b553b18..5d8e9df8e9 100644 --- a/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c +++ b/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c @@ -47,6 +47,7 @@ #include #include +#include #include "msg_internal.h" #include "sofia-sip/msg_parser.h" @@ -871,7 +872,7 @@ int msg_header_param_modify(su_home_t *home, msg_common_t *h, } } else { - if (strncasecmp(maybe, param, plen) == 0 && + if (su_casenmatch(maybe, param, plen) && (maybe[plen] == '=' || maybe[plen] == 0)) break; } @@ -1212,7 +1213,7 @@ msg_param_t msg_params_find(msg_param_t const params[], msg_param_t token) for (i = 0; params[i]; i++) { msg_param_t param = params[i]; - if (strncasecmp(param, token, n) == 0) { + if (su_casenmatch(param, token, n)) { if (param[n] == '=') return param + n + 1; else if (param[n] == 0) @@ -1246,7 +1247,7 @@ msg_param_t *msg_params_find_slot(msg_param_t params[], msg_param_t token) for (i = 0; params[i]; i++) { msg_param_t param = params[i]; - if (strncasecmp(param, token, n) == 0) { + if (su_casenmatch(param, token, n)) { if (param[n] == '=') return params + i; else if (param[n] == 0 || token[n - 1] == '=') @@ -1295,7 +1296,7 @@ int msg_params_replace(su_home_t *home, for (i = 0; params[i]; i++) { msg_param_t maybe = params[i]; - if (!(strncasecmp(maybe, param, n))) { + if (su_casenmatch(maybe, param, n)) { if (maybe[n] == '=' || maybe[n] == 0) { params[i] = param; return 1; @@ -1327,7 +1328,7 @@ int msg_params_remove(msg_param_t *params, msg_param_t param) for (i = 0; params[i]; i++) { msg_param_t maybe = params[i]; - if (strncasecmp(maybe, param, n) == 0) { + if (su_casenmatch(maybe, param, n)) { if (maybe[n] == '=' || maybe[n] == 0) { /* Remove */ do { @@ -1415,10 +1416,10 @@ int msg_param_prune(msg_param_t const d[], msg_param_t p, unsigned prune) for (i = 0; d[i]; i++) { if ((prune == 1 && - strncasecmp(p, d[i], nlen) == 0 + su_casenmatch(p, d[i], nlen) && (d[i][nlen] == '=' || d[i][nlen] == '\0')) || - (prune == 2 && strcasecmp(p, d[i]) == 0) + (prune == 2 && su_casematch(p, d[i])) || (prune == 3 && strcmp(p, d[i]) == 0)) return 1; @@ -1649,7 +1650,7 @@ int msg_params_cmp(char const * const a[], char const * const b[]) if (*a == NULL || *b == NULL) return (*a != NULL) - (*b != NULL); nlen = strcspn(*a, "="); - if ((c = strncasecmp(*a, *b, nlen))) + if ((c = su_strncasecmp(*a, *b, nlen))) return c; if ((c = strcmp(*a + nlen, *b + nlen))) return c;