]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Thu Jan 8 14:56:49 CST 2009 Pekka Pessi <first.last@nokia.com>
authorMichael Jerris <mike@jerris.com>
Wed, 11 Feb 2009 16:50:29 +0000 (16:50 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 11 Feb 2009 16:50:29 +0000 (16:50 +0000)
  * msg: using <sofia-sip/su_string.h> functions

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11802 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/msg/msg_date.c
libs/sofia-sip/libsofia-sip-ua/msg/msg_mclass.c
libs/sofia-sip/libsofia-sip-ua/msg/msg_mime.c
libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c

index 7cfe75543e890eda1b58957be761354ace2fd6d6..0d8f1e33d10db0326b19a9227a8285725879d629 100644 (file)
@@ -1 +1 @@
-Wed Feb 11 10:49:44 CST 2009
+Wed Feb 11 10:50:12 CST 2009
index d5886b229856f18abf006183f57e47d3936707e4..a665e9d495252363784f7e7f568fddfee9e18f52 100644 (file)
@@ -42,6 +42,7 @@
 #include <string.h>
 #include <assert.h>
 
+#include <sofia-sip/su_string.h>
 #include <sofia-sip/msg_date.h>
 #include <sofia-sip/bnf.h>
 
@@ -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;
     }
   }
index e049f872a94b34a17ce65496bfe1c44d4a8bdeac..58c859615b2174ca02d14a4b6d990faf3a52c395 100644 (file)
@@ -47,6 +47,7 @@
 
 #include <sofia-sip/su.h>
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
 
 #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;
       }
index 109a7ab8fda9737b8371c9b5b8d408b9bc042cb5..860e939eb1a06006986ceaeffb81e1981a0d6a24 100644 (file)
 
 #define _GNU_SOURCE 1
 
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-#include <assert.h>
-
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
 
 #include "msg_internal.h"
 #include "sofia-sip/msg.h"
 #include <sofia-sip/su_uniqueid.h>
 #include <sofia-sip/su_errno.h>
 
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+#include <assert.h>
+
 #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;
index d14b553b18fd33fc08eb006ce8789f7f60281412..5d8e9df8e9c317e8ad765a66eabfeb8b9877c3c4 100644 (file)
@@ -47,6 +47,7 @@
 
 #include <sofia-sip/su.h>
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
 
 #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;