Module: sip-router
Branch: master
Commit: 402e44861c489d4246a0fe1f57bc2cc5fe7a70c9
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=402e44861c489d4246a0fe1f57bc2cc5fe7a70c9

Author: Marius Zbihlei <[email protected]>
Committer: Marius Zbihlei <[email protected]>
Date:   Sat Feb 23 14:58:07 2013 +0000

Added own _strnstr method as strnstr is BSD only

This cause the tm module to not be loaded on non-BSD (i.e. Linux) system
Problem reported by Joel Vandal.

---

 modules/tm/t_msgbuilder.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/modules/tm/t_msgbuilder.c b/modules/tm/t_msgbuilder.c
index ffdcb7b..60328b3 100644
--- a/modules/tm/t_msgbuilder.c
+++ b/modules/tm/t_msgbuilder.c
@@ -1475,11 +1475,34 @@ static inline char* print_callid(char* w, dlg_t* 
dialog, struct cell* t)
        memapp(w, CRLF, CRLF_LEN);
        t->callid.s = w;
        t->callid.len = CALLID_LEN + dialog->id.call_id.len + CRLF_LEN;
-
+       
        w = print_callid_mini(w, dialog->id.call_id);
        return w;
 }
 
+/*
+* Find the first occurrence of find in s, where the search is limited to the
+* first slen characters of s.
+*/
+static
+char * _strnstr(const char* s, const char* find, size_t slen) {
+       char c, sc;
+       size_t len;
+
+       if ((c = *find++) != '\0') {
+               len = strlen(find);
+               do {
+                       do {
+                               if (slen-- < 1 || (sc = *s++) == '\0')
+                                       return (NULL);
+                       } while (sc != c);
+                       if (len > slen)
+                               return (NULL);
+               } while (strncmp(s, find, len) != 0);
+               s--;
+       }
+       return ((char *)s);
+}
 
 /*
  * Create a request
@@ -1542,7 +1565,7 @@ char* build_uac_req(str* method, str* headers, str* body, 
dlg_t* dialog, int bra
        w = print_routeset(w, dialog);                        /* Route set */
 
        if(headers==NULL || headers->len<15
-                       || strnstr(headers->s, "Max-Forwards:", 
headers->len)==NULL)
+                       || _strnstr(headers->s, "Max-Forwards:", 
headers->len)==NULL)
                memapp(w, MAXFWD_HEADER, MAXFWD_HEADER_LEN);      /* 
Max-forwards */
 
      /* Content-Length */


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to