core: parser - converted old log macros
authorDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 7 Aug 2017 07:16:15 +0000 (09:16 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 7 Aug 2017 07:16:15 +0000 (09:16 +0200)
- indentation adjustments

14 files changed:
src/core/parser/hf.c
src/core/parser/parse_allow.c
src/core/parser/parse_content.c
src/core/parser/parse_date.c
src/core/parser/parse_event.c
src/core/parser/parse_expires.c
src/core/parser/parse_identity.c
src/core/parser/parse_identityinfo.c
src/core/parser/parse_methods.c
src/core/parser/parse_refer_to.c
src/core/parser/parse_retry_after.c
src/core/parser/parse_rr.c
src/core/parser/parse_sipifmatch.c
src/core/parser/parse_via.c

index 5a78e76..71d1c61 100644 (file)
@@ -197,8 +197,7 @@ void clean_hdr_field(struct hdr_field* const hf)
                        break;
 
                default:
-                       LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
-                           hf->type);
+                       LM_CRIT("BUG: unknown header type %d\n", hf->type);
                        break;
                }
        }
@@ -223,7 +222,7 @@ void free_hdr_field_lst(struct hdr_field* hf)
 /* print the content of hdr_field */
 void dump_hdr_field(struct hdr_field const* const hf )
 {
-       LOG(L_ERR, "DEBUG: dump_hdr_field: type=%d, name=%.*s, "
+       LM_ERR("DEBUG: type=%d, name=%.*s, "
                "body=%.*s, parsed=%p, next=%p\n",
                hf->type, hf->name.len, ZSW(hf->name.s),
                hf->body.len, ZSW(hf->body.s),
index cbe5a1c..fe127be 100644 (file)
@@ -13,8 +13,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
@@ -33,7 +33,7 @@
 #include "parse_methods.h"
 #include "msg_parser.h"
 
+
 /*! \brief
  * This method is used to parse Allow header.
  *
@@ -45,30 +45,30 @@ int parse_allow_header(struct hdr_field* _hf)
        struct allow_body* ab = 0;
 
        if (!_hf) {
-               LOG(L_ERR, "parse_allow_header: Invalid parameter value\n");
+               LM_ERR("invalid parameter value\n");
                return -1;
        }
-       
+
        /* maybe the header is already parsed! */
-       if (_hf->parsed) {
-               return 0;
+       if (_hf->parsed) {
+               return 0;
        }
 
        ab = (struct allow_body*)pkg_malloc(sizeof(struct allow_body));
        if (ab == 0) {
-               LOG(L_ERR, "ERROR:parse_allow_header: out of pkg_memory\n");
+               LM_ERR("out of pkg_memory\n");
                return -1;
        }
        memset(ab,'\0', sizeof(struct allow_body));
-       
+
        if (parse_methods(&(_hf->body), &(ab->allow)) !=0 ) {
-               LOG(L_ERR, "ERROR:parse_allow_header: bad allow body header\n");                
+               LM_ERR("bad allow body header\n");
                goto error;
        }
-       
-       ab->allow_all = 0;      
+
+       ab->allow_all = 0;
        _hf->parsed = (void*)ab;
-       return 0;
+       return 0;
 
 error:
        if (ab) pkg_free(ab);
@@ -81,7 +81,7 @@ error:
  * \return 0 on success,-1 on failure.
  */
 int parse_allow(struct sip_msg *msg)
-{       
+{
        unsigned int allow;
        struct hdr_field  *hdr;
 
@@ -105,9 +105,9 @@ int parse_allow(struct sip_msg *msg)
 
                allow |= ((struct allow_body*)hdr->parsed)->allow;
        }
-       
+
        ((struct allow_body*)msg->allow->parsed)->allow_all = allow;
-    return 0;
+       return 0;
 }
 
 
@@ -116,8 +116,8 @@ int parse_allow(struct sip_msg *msg)
  */
 void free_allow_body(struct allow_body **ab)
 {
-       if (ab && *ab) {        
-               pkg_free(*ab);          
+       if (ab && *ab) {
+               pkg_free(*ab);
                *ab = 0;
        }
 }
index 6546b01..6528147 100644 (file)
@@ -51,7 +51,7 @@
 typedef struct type_node_s {
        char c;                      /*!< char contained by this node */
        unsigned char final;         /*!< says what mime type/subtype was detected
-                                     *!< if string ends at this node */
+                                                                       *!< if string ends at this node */
        unsigned char nr_sons;       /*!< the number of sub-nodes */
        int next;                    /*!< the next sibling node */
 }type_node_t;
@@ -211,7 +211,8 @@ static type_node_t subtype_tree[] = {
 
 
 
-char* parse_content_length(char* const buffer, const char* const end, int* const length)
+char* parse_content_length(char* const buffer, const char* const end,
+               int* const length)
 {
        int number;
        char *p;
@@ -247,14 +248,14 @@ char* parse_content_length(char* const buffer, const char* const end, int* const
        *length = number;
        return p;
 error:
-       LOG(L_ERR,"ERROR:parse_content_length: parse error near char [%d][%c]\n",
-               *p,*p);
+       LM_ERR("parse error near char [%d][%c]\n", *p, *p);
        return 0;
 }
 
 
 
-char* decode_mime_type(char* const start, const char* const end, unsigned int* const mime_type)
+char* decode_mime_type(char* const start, const char* const end,
+               unsigned int* const mime_type)
 {
        int node;
        char *mark;
@@ -279,7 +280,7 @@ char* decode_mime_type(char* const start, const char* const end, unsigned int* c
                mark = p;
                type_candidate = TYPE_UNKNOWN;
                while (p<end && is_mime_char(*p)  ) {
-                       while ( node!=-1 && !is_char_equal(*p,type_tree[node].c) ){
+                       while ( node!=-1 && !is_char_equal(*p,type_tree[node].c) ) {
                                node = type_tree[node].next;
                        }
                        if (node!=-1) {
@@ -361,14 +362,14 @@ char* decode_mime_type(char* const start, const char* const end, unsigned int* c
 
        /* check the format of the decoded mime */
        if ((*mime_type)>>16==TYPE_ALL && ((*mime_type)&0x00ff)!=SUBTYPE_ALL) {
-               LOG(L_ERR,"ERROR:decode_mime_type: invalid mime format found "
-                       " <*/submime> in [%.*s]!!\n", (int)(end-start),start);
+               LM_ERR("invalid mime format found "
+                       " <*/submime> in [%.*s]!!\n", (int)(end-start), start);
                return 0;
        }
 
        return p;
 error:
-       LOG(L_ERR,"ERROR:decode_mime_type: parse error near in [%.*s] char"
+       LM_ERR("parse error near in [%.*s] char"
                "[%d][%c] offset=%d\n", (int)(end-start),start,*p,*p,(int)(p-start));
        return 0;
 }
@@ -392,8 +393,7 @@ int parse_content_type_hdr(struct sip_msg* const msg)
                if ( parse_headers(msg, HDR_CONTENTTYPE_F, 0)==-1)
                        goto error;
                if ( msg->content_type==0 ) {
-                       DBG("DEBUG:parse_content_type_hdr: missing Content-Type"
-                               "header\n");
+                       LM_DBG("missing Content-Type header\n");
                        return 0;
                }
        }
@@ -408,13 +408,11 @@ int parse_content_type_hdr(struct sip_msg* const msg)
        if (ret==0)
                goto error;
        if (ret!=end) {
-               LOG(L_ERR,"ERROR:parse_content_type_hdr: CONTENT_TYPE hdr contains "
-                       "more then one mime type :-(!\n");
+               LM_ERR("Content-Type hdr contains more then one mime type!\n");
                goto error;
        }
        if ((mime&0x00ff)==SUBTYPE_ALL || (mime>>16)==TYPE_ALL) {
-               LOG(L_ERR,"ERROR:parse_content_type_hdr: invalid mime with wildcard "
-                       "'*' in Content-Type hdr!\n");
+               LM_ERR("invalid mime with wildcard '*' in Content-Type hdr!\n");
                goto error;
        }
 
@@ -448,8 +446,8 @@ int parse_accept_body(struct hdr_field* const hdr)
                        goto error;
                /* a new mime was found  -> put it into array */
                if (nr_mimes==MAX_MIMES_NR) {
-                       LOG(L_ERR,"ERROR:parse_accept_hdr: Accept hdr contains more than"
-                               " %d mime type -> buffer overflow!!\n",MAX_MIMES_NR);
+                       LM_ERR("Accept hdr contains more than %d mime type"
+                                       " -> buffer overflow!!\n", MAX_MIMES_NR);
                        goto error;
                }
                mimes[nr_mimes++] = mime;
@@ -458,7 +456,7 @@ int parse_accept_body(struct hdr_field* const hdr)
                        break;
                /* parse the mime separator ',' */
                if (*ret!=',' || ret+1==end) {
-                       LOG(L_ERR,"ERROR:parse_accept_hdr: parse error between mimes at "
+                       LM_ERR("parse error between mimes at "
                                "char <%x> (offset=%d) in <%.*s>!\n",
                                *ret, (int)(ret-hdr->body.s),
                                hdr->body.len, hdr->body.s);
@@ -471,7 +469,7 @@ int parse_accept_body(struct hdr_field* const hdr)
        /* copy and link the mime buffer into the message */
        hdr->parsed = (void*)pkg_malloc((nr_mimes+1)*sizeof(int));
        if (hdr->parsed==0) {
-               LOG(L_ERR,"ERROR:parse_accept: no more pkg memory\n");
+               LM_ERR("no more pkg memory\n");
                goto error;
        }
        memcpy(hdr->parsed,mimes,nr_mimes*sizeof(int));
@@ -501,7 +499,7 @@ int parse_accept_hdr(struct sip_msg* const msg)
                if ( parse_headers(msg, HDR_ACCEPT_F, 0)==-1)
                        goto error;
                if ( msg->accept==0 ) {
-                       DBG("DEBUG:parse_accept_hdr: missing Accept header\n");
+                       LM_DBG("missing Accept header\n");
                        return 0;
                }
        }
@@ -520,7 +518,7 @@ int parse_accept_hdr(struct sip_msg* const msg)
                        goto error;
                /* a new mime was found  -> put it into array */
                if (nr_mimes==MAX_MIMES_NR) {
-                       LOG(L_ERR,"ERROR:parse_accept_hdr: Accept hdr contains more than"
+                       LM_ERR("Accept hdr contains more than"
                                " %d mime type -> buffer overflow!!\n",MAX_MIMES_NR);
                        goto error;
                }
@@ -530,7 +528,7 @@ int parse_accept_hdr(struct sip_msg* const msg)
                        break;
                /* parse the mime separator ',' */
                if (*ret!=',' || ret+1==end) {
-                       LOG(L_ERR,"ERROR:parse_accept_hdr: parse error between mimes at "
+                       LM_ERR("parse error between mimes at "
                                "char <%x> (offset=%d) in <%.*s>!\n",
                                *ret, (int)(ret-msg->accept->body.s),
                                msg->accept->body.len, msg->accept->body.s);
@@ -543,7 +541,7 @@ int parse_accept_hdr(struct sip_msg* const msg)
        /* copy and link the mime buffer into the message */
        msg->accept->parsed = (void*)pkg_malloc((nr_mimes+1)*sizeof(int));
        if (msg->accept->parsed==0) {
-               LOG(L_ERR,"ERROR:parse_accept_hdr: no more pkg memory\n");
+               LM_ERR("no more pkg memory\n");
                goto error;
        }
        memcpy(msg->accept->parsed,mimes,nr_mimes*sizeof(int));
@@ -554,4 +552,3 @@ int parse_accept_hdr(struct sip_msg* const msg)
 error:
        return -1;
 }
-
index f4da798..aa93709 100644 (file)
@@ -154,7 +154,7 @@ void parse_date(char *buffer, char *end, struct date_body *db)
        db->error=PARSE_OK;
        return ;
 error:
-       LOG(L_ERR,"ERROR: parse_date: parse error\n");
+       LM_ERR("parse error\n");
        return ;
 }
 
@@ -164,7 +164,7 @@ int parse_date_header(struct sip_msg *msg)
 
 
        if ( !msg->date && (parse_headers(msg,HDR_DATE_F,0)==-1 || !msg->date) ) {
-               LOG(L_ERR,"ERROR:parse_date_header: bad msg or missing DATE header\n");
+               LM_ERR("bad msg or missing DATE header\n");
                goto error;
        }
 
@@ -174,7 +174,7 @@ int parse_date_header(struct sip_msg *msg)
 
        date_b=pkg_malloc(sizeof(*date_b));
        if (date_b==0){
-               LOG(L_ERR, "ERROR:parse_date_header: out of memory\n");
+               LM_ERR("out of pkg memory\n");
                goto error;
        }
        memset(date_b, 0, sizeof(*date_b));
index fbaf670..0d57762 100644 (file)
@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
@@ -43,7 +43,7 @@
 
 static struct {
        str name;
-       int type;       
+       int type;
 } events[] = {
        {STR_STATIC_INIT("presence"),        EVENT_PRESENCE},
        {STR_STATIC_INIT("presence.winfo"),  EVENT_PRESENCE_WINFO},
@@ -63,12 +63,12 @@ static inline char* skip_token(char* _b, int _l)
 
        for(i = 0; i < _l; i++) {
                switch(_b[i]) {
-               case ' ':
-               case '\r':
-               case '\n':
-               case '\t':
-               case ';':
-                       return _b + i;
+                       case ' ':
+                       case '\r':
+                       case '\n':
+                       case '\t':
+                       case ';':
+                               return _b + i;
                }
        }
 
@@ -85,7 +85,7 @@ int event_parser(char* s, int len, event_t* e)
        enum pclass pclass = CLASS_ANY;
 
        if (e == NULL) {
-               ERR("event_parser: Invalid parameter value\n");
+               LM_ERR("Invalid parameter value\n");
                return -1;
        }
 
@@ -94,7 +94,7 @@ int event_parser(char* s, int len, event_t* e)
        trim_leading(&tmp);
 
        if (tmp.len == 0) {
-               LOG(L_ERR, "event_parser: Empty body\n");
+               LM_ERR("Empty body\n");
                return -1;
        }
 
@@ -105,7 +105,7 @@ int event_parser(char* s, int len, event_t* e)
        e->type = EVENT_OTHER;
        for(i = 0; events[i].name.len; i++) {
                if (e->name.len == events[i].name.len &&
-                       !strncasecmp(e->name.s, events[i].name.s, e->name.len)) {
+                               !strncasecmp(e->name.s, events[i].name.s, e->name.len)) {
                        e->type = events[i].type;
                        break;
                }
@@ -116,7 +116,7 @@ int event_parser(char* s, int len, event_t* e)
        trim_leading(&tmp);
 
        e->params.list = NULL;
-       
+
        if (tmp.len && (tmp.s[0] == ';')) {
                /* Shift the semicolon and skip any leading whitespace, this is needed
                 * for parse_params to work correctly. */
@@ -131,7 +131,7 @@ int event_parser(char* s, int len, event_t* e)
                }
 
                if (parse_params(&tmp, pclass, phooks, &e->params.list) < 0) {
-                       ERR("event_parser: Error while parsing parameters parameters\n");
+                       LM_ERR("Error while parsing parameters parameters\n");
                        return -1;
                }
        }
@@ -152,14 +152,14 @@ int parse_event(struct hdr_field* _h)
 
        e = (event_t*)pkg_malloc(sizeof(event_t));
        if (e == 0) {
-               LOG(L_ERR, "parse_event(): No memory left\n");
+               LM_ERR("No memory left\n");
                return -1;
        }
 
        memset(e, 0, sizeof(event_t));
 
        if (event_parser(_h->body.s, _h->body.len, e) < 0) {
-               LOG(L_ERR, "parse_event(): Error in event_parser\n");
+               LM_ERR("Error in event_parser\n");
                pkg_free(e);
                return -2;
        }
index 1dcef71..0d505cb 100644 (file)
@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
@@ -43,14 +43,14 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
 {
        int i;
        str tmp;
-       
+
        tmp.s = _s;
        tmp.len = _l;
 
        trim(&tmp);
 
        if (tmp.len == 0) {
-               LOG(L_ERR, "expires_parser(): Empty body\n");
+               LM_ERR("Empty body\n");
                _e->valid = 0;
                return -1;
        }
@@ -70,24 +70,24 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
                        _e->val += tmp.s[i] - '0';
                } else {
                        switch(tmp.s[i]) {
-                       case ' ':
-                       case '\t':
-                       case '\r':
-                       case '\n':
-                               _e->text.len = i;
-                               _e->valid = 1;
-                               return 0;
-
-                       default:
-                                    /* Exit normally here, we want to be backwards compatible with
-                                     * RFC2543 entities that can put absolute time here
-                                     */
-                                    /*
-                               LOG(L_ERR, "expires_parser(): Invalid character\n");
-                               return -2;
-                                    */
-                               _e->valid = 0;
-                               return 0;
+                               case ' ':
+                               case '\t':
+                               case '\r':
+                               case '\n':
+                                       _e->text.len = i;
+                                       _e->valid = 1;
+                                       return 0;
+
+                               default:
+                                       /* Exit normally here, we want to be backwards compatible
+                                        * with RFC2543 entities that can put absolute time here
+                                        */
+                                       /*
+                                       LM_ERR("Invalid character\n");
+                                       return -2;
+                                       */
+                                       _e->valid = 0;
+                                       return 0;
                        }
                }
        }
@@ -110,18 +110,18 @@ int parse_expires(struct hdr_field* _h)
 
        e = (exp_body_t*)pkg_malloc(sizeof(exp_body_t));
        if (e == 0) {
-               LOG(L_ERR, "parse_expires(): No memory left\n");
+               LM_ERR("No pkg memory left\n");
                return -1;
        }
-       
+
        memset(e, 0, sizeof(exp_body_t));
 
        if (expires_parser(_h->body.s, _h->body.len, e) < 0) {
-               LOG(L_ERR, "parse_expires(): Error while parsing\n");
+               LM_ERR("Error while parsing\n");
                pkg_free(e);
                return -2;
        }
-       
+
        _h->parsed = (void*)e;
        return 0;
 }
index f92dc46..1813739 100644 (file)
@@ -41,8 +41,8 @@ inline static int isendofhash (char* p, char* end)
 {
        /* new header line */
        if ((p<end && *p=='"')
-               /* end of message */
-               || ((*p=='\n' || *p=='\r') && p+1==end))
+                       /* end of message */
+                       || ((*p=='\n' || *p=='\r') && p+1==end))
                return 1;
        else
                return 0;
@@ -54,16 +54,16 @@ inline static int isendofhash (char* p, char* end)
  * a new buffer and move there the LWSless part
  */
 int movetomybuffer (char *pstart,
-                                       char *pend,
-                                       char *pcur,
-                                       struct identity_body *ib)
+               char *pend,
+               char *pcur,
+               struct identity_body *ib)
 {
        char *phashend;
 
        for (phashend = pcur; !isendofhash(phashend, pend); phashend++);
 
        if (!(ib->hash.s=pkg_malloc(phashend-pstart))) {
-               LOG(L_ERR, "parse_identity: out of memory\n");
+               LM_ERR("out of pkg memory\n");
                return -2;
        }
        ib->ballocated=1;
@@ -92,9 +92,9 @@ void parse_identity(char *buffer, char* end, struct identity_body* ib)
        for (p = pstart; p < end; p++) {
                /* check the BASE64 alphabet */
                if (((*p >= 'a' && *p <='z')
-                       || (*p >= 'A' && *p <='Z')
-                       || (*p >= '0' && *p <='9')
-                       || (*p == '+' || *p == '/' || *p == '='))) {
+                                       || (*p >= 'A' && *p <='Z')
+                                       || (*p >= '0' && *p <='9')
+                                       || (*p == '+' || *p == '/' || *p == '='))) {
                        if (ib->ballocated)
                                ib->hash.s[ib->hash.len]=*p;
                        ib->hash.len++;
@@ -130,9 +130,8 @@ void parse_identity(char *buffer, char* end, struct identity_body* ib)
        return ;
 
 parseerror:
-       LOG( L_ERR , "ERROR: parse_identity: "
-               "unexpected char [0x%X]: <<%.*s>> .\n",
-               *p,(int)(p-buffer), ZSW(buffer));
+       LM_ERR("unexpected char [0x%X]: <<%.*s>> .\n",
+                       *p,(int)(p-buffer), ZSW(buffer));
 error:
        return ;
 }
@@ -143,9 +142,9 @@ int parse_identity_header(struct sip_msg *msg)
 
 
        if ( !msg->identity
-                && (parse_headers(msg,HDR_IDENTITY_F,0)==-1
-                || !msg->identity) ) {
-               LOG(L_ERR,"ERROR:parse_identity_header: bad msg or missing IDENTITY header\n");
+                       && (parse_headers(msg,HDR_IDENTITY_F,0)==-1
+                               || !msg->identity) ) {
+               LM_ERR("bad msg or missing IDENTITY header\n");
                goto error;
        }
 
@@ -155,14 +154,14 @@ int parse_identity_header(struct sip_msg *msg)
 
        identity_b=pkg_malloc(sizeof(*identity_b));
        if (identity_b==0){
-               LOG(L_ERR, "ERROR:parse_identity_header: out of memory\n");
+               LM_ERR("out of pkg memory\n");
                goto error;
        }
        memset(identity_b, 0, sizeof(*identity_b));
 
        parse_identity(msg->identity->body.s,
-                                  msg->identity->body.s + msg->identity->body.len+1,
-                                  identity_b);
+                       msg->identity->body.s + msg->identity->body.len+1,
+                       identity_b);
        if (identity_b->error==PARSE_ERROR){
                free_identity(identity_b);
                goto error;
index 32f95da..425b083 100644 (file)
@@ -333,7 +333,7 @@ int parse_identityinfo_header(struct sip_msg *msg)
 
        identityinfo_b=pkg_malloc(sizeof(*identityinfo_b));
        if (identityinfo_b==0){
-               LOG(L_ERR, "ERROR:parse_identityinfo_header: out of memory\n");
+               LM_ERR("out of pkg memory\n");
                goto error;
        }
        memset(identityinfo_b, 0, sizeof(*identityinfo_b));
index 8f23e6b..de36d60 100644 (file)
@@ -13,8 +13,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
  */
 static int token_char(char _c)
 {
-       return  (_c >= 65 && _c <= 90) ||        /* upper alpha */
-               (_c >= 97 && _c <= 122) ||       /* lower aplha */
-               (_c >= 48 && _c <= 57) ||        /* digits */
-               (_c == '-') || (_c == '.') || (_c == '!') || (_c == '%') ||
-               (_c == '*') || (_c == '_') || (_c == '+') || (_c == '`') ||
-               (_c == '\'') || (_c == '~');
- }
+       return  (_c >= 65 && _c <= 90) ||        /* upper alpha */
+               (_c >= 97 && _c <= 122) ||       /* lower aplha */
+               (_c >= 48 && _c <= 57) ||        /* digits */
+               (_c == '-') || (_c == '.') || (_c == '!') || (_c == '%') ||
+               (_c == '*') || (_c == '_') || (_c == '+') || (_c == '`') ||
+               (_c == '\'') || (_c == '~');
+}
 
 
 
@@ -52,24 +52,24 @@ static int token_char(char _c)
  * \return 0 on success, -1 on error
  */
 int parse_method_name(const str* const s, enum request_method* const method)
- {
+{
        if (unlikely(!s || !method)) {
-               LOG(L_ERR, "Invalid parameter value\n");
+               LM_ERR("Invalid parameter value\n");
                return -1;
        }
-       
+
        if (unlikely(!s->len || (s->s==0))) {
-               DBG("No input\n");
+               LM_DBG("No input\n");
                *method = METHOD_OTHER;
                return 0;
        }
-       
+
        switch ((s->s)[0]) {
                /* ordered after probability of aparition on a normal proxy */
                case 'R':
                case 'r':
                        if (likely((s->len == 8) &&
-                                       !strncasecmp(s->s + 1, "egister", 7))) {
+                                               !strncasecmp(s->s + 1, "egister", 7))) {
                                *method = METHOD_REGISTER;
                                return 0;
                        }
@@ -166,245 +166,245 @@ int parse_method_name(const str* const s, enum request_method* const method)
 
 
 
- /*! \brief
 * Parse a method pointed by _next, assign its enum bit to _method, and update
 * _next past the method. Returns 1 if parse succeeded and 0 otherwise.
 */
+/*! \brief
+ * Parse a method pointed by _next, assign its enum bit to _method, and update
+ * _next past the method. Returns 1 if parse succeeded and 0 otherwise.
+ */
 static int parse_method_advance(str* const _next, enum request_method* const _method)
- {
+{
        char* end;
-       
-        if (unlikely(!_next || !_method)) {
-                LOG(L_ERR, "Invalid parameter value\n");
-                return 0;
-        }
-        
-        if (unlikely(!_next->len || !_next->s)) {
-                DBG("No input\n");
-               *_method = METHOD_OTHER;
-                return 1;
-        }
+
+       if (unlikely(!_next || !_method)) {
+               LM_ERR("Invalid parameter value\n");
+               return 0;
+       }
+
+       if (unlikely(!_next->len || !_next->s)) {
+               DBG("No input\n");
+               *_method = METHOD_OTHER;
+               return 1;
+       }
        end=_next->s+_next->len;
-       
-        switch ((_next->s)[0]) {
-        case 'A':
-        case 'a':
-                if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ck", 2)) {
-                       *_method = METHOD_ACK;
-                       _next->len -= 3;
-                       _next->s += 3;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       case 'B':
-       case 'b':
-               if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ye", 2)) {
-                       *_method = METHOD_BYE;
-                       _next->len -= 3;
-                       _next->s += 3;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       case 'C':
-       case 'c':
-               if ((_next->len > 5) && !strncasecmp(_next->s + 1, "ancel", 5)) {
-                       *_method = METHOD_CANCEL;
-                       _next->len -= 6;
-                       _next->s += 6;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       case 'I':
-       case 'i':
-               if ((_next->len > 3) &&
-                   ((*(_next->s + 1) == 'N') || (*(_next->s + 1) == 'n'))) {
-                       if (!strncasecmp(_next->s + 2, "fo", 2)) {
-                               *_method = METHOD_INFO;
-                               _next->len -= 4;
-                               _next->s += 4;
+
+       switch ((_next->s)[0]) {
+               case 'A':
+               case 'a':
+                       if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ck", 2)) {
+                               *_method = METHOD_ACK;
+                               _next->len -= 3;
+                               _next->s += 3;
+                               goto found;
+                       } else {
+                               goto unknown;
+                       }
+
+               case 'B':
+               case 'b':
+                       if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ye", 2)) {
+                               *_method = METHOD_BYE;
+                               _next->len -= 3;
+                               _next->s += 3;
+                               goto found;
+                       } else {
+                               goto unknown;
+                       }
+
+               case 'C':
+               case 'c':
+                       if ((_next->len > 5) && !strncasecmp(_next->s + 1, "ancel", 5)) {
+                               *_method = METHOD_CANCEL;
+                               _next->len -= 6;
+                               _next->s += 6;
+                               goto found;
+                       } else {
+                               goto unknown;
+                       }
+
+               case 'I':
+               case 'i':
+                       if ((_next->len > 3) &&
+                                       ((*(_next->s + 1) == 'N') || (*(_next->s + 1) == 'n'))) {
+                               if (!strncasecmp(_next->s + 2, "fo", 2)) {
+                                       *_method = METHOD_INFO;
+                                       _next->len -= 4;
+                                       _next->s += 4;
+                                       goto found;
+                               }
+
+                               if ((_next->len > 5) && !strncasecmp(_next->s + 2, "vite", 4)) {
+                                       *_method = METHOD_INVITE;
+                                       _next->len -= 6;
+                                       _next->s += 6;
+                                       goto found;
+                               }
+                       }
+                       goto unknown;
+
+               case 'M':
+               case 'm':
+                       if ((_next->len > 6) && !strncasecmp(_next->s + 1, "essage", 6)) {
+                               *_method = METHOD_MESSAGE;
+                               _next->len -= 7;
+                               _next->s += 7;
+                               goto found;
+                       } else {
+                               goto unknown;
+                       }
+
+               case 'N':
+               case 'n':
+                       if ((_next->len > 5) && !strncasecmp(_next->s + 1, "otify", 5)) {
+                               *_method = METHOD_NOTIFY;
+                               _next->len -= 6;
+                               _next->s += 6;
+                               goto found;
+                       } else {
+                               goto unknown;
+                       }
+
+               case 'O':
+               case 'o':
+                       if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ptions", 6)) {
+                               *_method = METHOD_OPTIONS;
+                               _next->len -= 7;
+                               _next->s += 7;
                                goto found;
-                       }
+                       } else {
+                               goto unknown;
+                       }
 
-                       if ((_next->len > 5) && !strncasecmp(_next->s + 2, "vite", 4)) {
-                               *_method = METHOD_INVITE;
-                               _next->len -= 6;
-                               _next->s += 6;
+               case 'P':
+               case 'p':
+                       if ((_next->len > 4) && !strncasecmp(_next->s + 1, "rack", 4)) {
+                               *_method = METHOD_PRACK;
+                               _next->len -= 5;
+                               _next->s += 5;
                                goto found;
-                       }
-               }
-               goto unknown;
-
-       case 'M':
-       case 'm':
-               if ((_next->len > 6) && !strncasecmp(_next->s + 1, "essage", 6)) {
-                       *_method = METHOD_MESSAGE;
-                       _next->len -= 7;
-                       _next->s += 7;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       case 'N':
-       case 'n':
-               if ((_next->len > 5) && !strncasecmp(_next->s + 1, "otify", 5)) {
-                       *_method = METHOD_NOTIFY;
-                       _next->len -= 6;
-                       _next->s += 6;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       case 'O':
-       case 'o':
-               if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ptions", 6)) {
-                       *_method = METHOD_OPTIONS;
-                       _next->len -= 7;
-                       _next->s += 7;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       case 'P':
-       case 'p':
-               if ((_next->len > 4) && !strncasecmp(_next->s + 1, "rack", 4)) {
-                       *_method = METHOD_PRACK;
-                       _next->len -= 5;
-                       _next->s += 5;
-                       goto found;
-               }
-               if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ublish", 6)) {
-                       *_method = METHOD_PUBLISH;
-                       _next->len -= 7;
-                       _next->s += 7;
-                       goto found;
-               }
-               goto unknown;
-
-       case 'R':
-       case 'r':
-               if ((_next->len > 4) &&
-                   ((*(_next->s + 1) == 'E') || (*(_next->s + 1) == 'e'))) {
-                       if (!strncasecmp(_next->s + 2, "fer", 3)) {
-                               *_method = METHOD_REFER;
-                               _next->len -= 5;
-                               _next->s += 5;
+                       }
+                       if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ublish", 6)) {
+                               *_method = METHOD_PUBLISH;
+                               _next->len -= 7;
+                               _next->s += 7;
                                goto found;
-                       }
+                       }
+                       goto unknown;
 
-                       if ((_next->len > 7) && !strncasecmp(_next->s + 2, "gister", 6)) {
-                               *_method = METHOD_REGISTER;
-                               _next->len -= 8;
-                               _next->s += 8;
+               case 'R':
+               case 'r':
+                       if ((_next->len > 4) &&
+                                       ((*(_next->s + 1) == 'E') || (*(_next->s + 1) == 'e'))) {
+                               if (!strncasecmp(_next->s + 2, "fer", 3)) {
+                                       *_method = METHOD_REFER;
+                                       _next->len -= 5;
+                                       _next->s += 5;
+                                       goto found;
+                               }
+
+                               if ((_next->len > 7) && !strncasecmp(_next->s + 2, "gister", 6)) {
+                                       *_method = METHOD_REGISTER;
+                                       _next->len -= 8;
+                                       _next->s += 8;
+                                       goto found;
+                               }
+                       }
+                       goto unknown;
+
+               case 'S':
+               case 's':
+                       if ((_next->len > 8) && !strncasecmp(_next->s + 1, "ubscribe", 8)) {
+                               *_method = METHOD_SUBSCRIBE;
+                               _next->len -= 9;
+                               _next->s += 9;
+                               goto found;
+                       } else {
+                               goto unknown;
+                       }
+
+               case 'U':
+               case 'u':
+                       if ((_next->len > 5) && !strncasecmp(_next->s + 1, "pdate", 5)) {
+                               *_method = METHOD_UPDATE;
+                               _next->len -= 6;
+                               _next->s += 6;
                                goto found;
-                       }
-               }
-               goto unknown;
-
-       case 'S':
-       case 's':
-               if ((_next->len > 8) && !strncasecmp(_next->s + 1, "ubscribe", 8)) {
-                       *_method = METHOD_SUBSCRIBE;
-                       _next->len -= 9;
-                       _next->s += 9;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       case 'U':
-       case 'u':
-               if ((_next->len > 5) && !strncasecmp(_next->s + 1, "pdate", 5)) {
-                       *_method = METHOD_UPDATE;
-                       _next->len -= 6;
-                       _next->s += 6;
-                       goto found;
-               } else {
-                       goto unknown;
-               }
-
-       default:
-               goto unknown;
-       }
-
- unknown:
-       if (token_char(*(_next->s))) {
-               do { 
-                       _next->s++;
-                       _next->len--;
-               } while (_next->len && token_char(*(_next->s)));
-               *_method = METHOD_OTHER;
-               return 1;
-       } else {
-               return 0;
-       }
+                       } else {
+                               goto unknown;
+                       }
+
+               default:
+                       goto unknown;
+       }
+
+unknown:
+       if (token_char(*(_next->s))) {
+               do {
+                       _next->s++;
+                       _next->len--;
+               } while (_next->len && token_char(*(_next->s)));
+               *_method = METHOD_OTHER;
+               return 1;
+       } else {
+               return 0;
+       }
 found:
        /* check if the method really ends here (if not return 0) */
        return (_next->s>=end) || (!token_char(*(_next->s)));
- }
- /*! \brief
 * Parse comma separated list of methods pointed by _body and assign their
 * enum bits to _methods.  Returns 0 on success and -1 on failure.
 */
+}
+
+
+/*! \brief
+ * Parse comma separated list of methods pointed by _body and assign their
+ * enum bits to _methods.  Returns 0 on success and -1 on failure.
+ */
 int parse_methods(const str* const _body, unsigned int* const _methods)
- {
-       str next;
-       unsigned int method;
-       
+{
+       str next;
+       unsigned int method;
+
        method=0; /* fixes silly gcc 4.x warning */
+
        if (!_body || !_methods) {
-               LOG(L_ERR, "parse_methods: Invalid parameter value\n");
+               LM_ERR("Invalid parameter value\n");
                return -1;
        }
 
        next.len = _body->len;
        next.s = _body->s;
-       trim_leading(&next);
-       *_methods = 0;
-       if (next.len == 0) {
-               return 0;
-       }
-
-       while (1) {
-               if (parse_method_advance(&next, &method)) {
-                       *_methods |= method;
-               } else {
-                       LOG(L_ERR, "ERROR: parse_methods: Invalid method\n");
-                       return -1;
-               }
-               
-               trim_leading(&next);
-               if (next.len) {
-                       if (next.s[0] == ',') {
-                               next.len--;
-                               next.s++;
-                               trim_leading(&next);
-                               if (next.len == 0) {
-                                       LOG(L_ERR, "ERROR: parse_methods: Method expected\n");
-                                       return 0;
-                               }
-                       } else {
-                               LOG(L_ERR, "ERROR: parse_methods: Comma expected\n");
-                               return -1;
-                       }
-               } else {
-                       break;
-               }
-       }
-
-       return 0;
- }
+
+       trim_leading(&next);
+
+       *_methods = 0;
+
+       if (next.len == 0) {
+               return 0;
+       }
+
+       while (1) {
+               if (parse_method_advance(&next, &method)) {
+                       *_methods |= method;
+               } else {
+                       LM_ERR("Invalid method\n");
+                       return -1;
+               }
+
+               trim_leading(&next);
+               if (next.len) {
+                       if (next.s[0] == ',') {
+                               next.len--;
+                               next.s++;
+                               trim_leading(&next);
+                               if (next.len == 0) {
+                                       LM_ERR("Method expected\n");
+                                       return 0;
+                               }
+                       } else {
+                               LM_ERR("Comma expected\n");
+                               return -1;
+                       }
+               } else {
+                       break;
+               }
+       }
+
+       return 0;
+}
index 1be4e14..a8919e1 100644 (file)
@@ -13,8 +13,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
@@ -23,7 +23,7 @@
  *
  * \ingroup parser
  */
+
 #include "parse_from.h"
 #include "parse_to.h"
 #include <stdlib.h>
@@ -33,7 +33,7 @@
 #include "../ut.h"
 #include "../mem/mem.h"
 
+
 /*! \brief
  * This method is used to parse Refer-To header.
  *
 int parse_refer_to_header( struct sip_msg *msg )
 {
        struct to_body* refer_to_b;
-       
-       if ( !msg->refer_to &&
-            (parse_headers(msg, HDR_REFER_TO_F,0)==-1 || !msg->refer_to)) {
-               goto error;
-       }
-       /* maybe the header is already parsed! */
-       if (msg->refer_to->parsed)
-               return 0;
-       /* bad luck! :-( - we have to parse it */
-       /* first, get some memory */
-       refer_to_b = pkg_malloc(sizeof(struct to_body));
-       if (refer_to_b == 0) {
-               LOG(L_ERR, "ERROR:parse_refer_to_header: out of pkg_memory\n");
-               goto error;
-       }
-       /* now parse it!! */
-       memset(refer_to_b, 0, sizeof(struct to_body));
-       parse_to(msg->refer_to->body.s,
-                msg->refer_to->body.s + msg->refer_to->body.len+1,
-                refer_to_b);
-       if (refer_to_b->error == PARSE_ERROR) {
-               LOG(L_ERR, "ERROR:parse_refer_to_header: bad Refer-To header\n");
-               free_to(refer_to_b);
-               goto error;
-       }
-       msg->refer_to->parsed = refer_to_b;
-       return 0;
- error:
-       return -1;
+
+       if ( !msg->refer_to &&
+                       (parse_headers(msg, HDR_REFER_TO_F,0)==-1 || !msg->refer_to)) {
+               goto error;
+       }
+
+       /* maybe the header is already parsed! */
+       if (msg->refer_to->parsed)
+               return 0;
+
+       /* bad luck! :-( - we have to parse it */
+       /* first, get some memory */
+       refer_to_b = pkg_malloc(sizeof(struct to_body));
+       if (refer_to_b == 0) {
+               LM_ERR("out of pkg memory\n");
+               goto error;
+       }
+
+       /* now parse it!! */
+       memset(refer_to_b, 0, sizeof(struct to_body));
+       parse_to(msg->refer_to->body.s,
+                       msg->refer_to->body.s + msg->refer_to->body.len+1,
+                       refer_to_b);
+       if (refer_to_b->error == PARSE_ERROR) {
+               LM_ERR("bad Refer-To header\n");
+               free_to(refer_to_b);
+               goto error;
+       }
+       msg->refer_to->parsed = refer_to_b;
+
+       return 0;
+error:
+       return -1;
 }
index 59e52d7..ab80e4c 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2007 iptelorg GmbH
  *
  * This file is part of Kamailio, a free SIP server.
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 /*! \file
@@ -24,7 +24,7 @@
  *
  * \ingroup parser
  */
+
 
 #include "../comp_defs.h"
 #include "parse_retry_after.h"
 #include "../mem/mem.h"
 
 /*! \brief Parse the Retry-after header field */
-char* parse_retry_after(char* const buf, const char* const end, unsigned* const after, int* const err)
+char* parse_retry_after(char* const buf, const char* const end,
+               unsigned* const after, int* const err)
 {
        char *t;
        int i;
        unsigned val;
-       
+
        val=0;
        t=buf;
-       
+
        t=eat_lws_end(t, end);
        if (t>=end) goto error;
        for (i=0; t<end; i++,t++){
@@ -81,10 +82,10 @@ found:
                }
        }
 error_nocrlf:
-       LOG(L_ERR, "ERROR: parse_retry_after: strange EoHF\n");
+       LM_ERR("strange EoHF\n");
        goto error;
 error:
-       LOG(L_ERR, "ERROR: parse_retry_after: bad Retry-After header \n");
+       LM_ERR("bad Retry-After header \n");
        *err=1;
        return t;
 }
index 5740461..36dda0a 100644 (file)
@@ -46,7 +46,7 @@ static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
        /* Make a temporary copy of the string pointer */
        if(buf==0 || len<=0)
        {
-               DBG("No body for record-route\n");
+               LM_DBG("No body for record-route\n");
                *head = 0;
                return -2;
        }
@@ -67,14 +67,14 @@ static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
                /* Allocate and clear rr structure */
                r = (rr_t*)pkg_malloc(sizeof(rr_t));
                if (!r) {
-                       LOG(L_ERR, "No memory left\n");
+                       LM_ERR("No memory left\n");
                        goto error;
                }
                memset(r, 0, sizeof(rr_t));
 
                /* Parse name-addr part of the header */
                if (parse_nameaddr(&s, &r->nameaddr) < 0) {
-                       LOG(L_ERR, "Error while parsing name-addr (%.*s)\n",
+                       LM_ERR("Failed parsing name-addr (%.*s)\n",
                                        s.len, ZSW(s.s));
                        goto error;
                }
@@ -94,13 +94,13 @@ static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
                        trim_leading(&s);
 
                        if (s.len == 0) {
-                               LOG(L_ERR, "Error while parsing params\n");
+                               LM_ERR("Error while parsing params\n");
                                goto error;
                        }
 
                        /* Parse all parameters */
                        if (parse_params(&s, CLASS_ANY, &hooks, &r->params) < 0) {
-                               LOG(L_ERR, "Error while parsing params\n");
+                               LM_ERR("Error while parsing params\n");
                                goto error;
                        }
                        r->len = r->params->name.s + r->params->len - r->nameaddr.name.s;
@@ -113,7 +113,7 @@ static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
                }
 
                if (s.s[0] != ',') {
-                       LOG(L_ERR, "Invalid character '%c', comma expected\n", s.s[0]);
+                       LM_ERR("Invalid character '%c', comma expected\n", s.s[0]);
                        goto error;
                }
 
@@ -123,7 +123,7 @@ static inline int do_parse_rr_body(char *buf, int len, rr_t **head)
                trim_leading(&s);
 
                if (s.len == 0) {
-                       LOG(L_ERR, "Text after comma missing\n");
+                       LM_ERR("Text after comma missing\n");
                        goto error;
                }
 
@@ -162,7 +162,7 @@ int parse_rr(struct hdr_field* _h)
        rr_t* r = NULL;
 
        if (!_h) {
-               LOG(L_ERR, "Invalid parameter value\n");
+               LM_ERR("Invalid parameter value\n");
                return -1;
        }
 
@@ -250,13 +250,16 @@ void print_rr(FILE* _o, rr_t* _r)
 static inline void xlate_pointers(rr_t* _orig, rr_t* _r)
 {
        param_t* ptr;
-       _r->nameaddr.uri.s = translate_pointer(_r->nameaddr.name.s, _orig->nameaddr.name.s, _r->nameaddr.uri.s);
+       _r->nameaddr.uri.s = translate_pointer(_r->nameaddr.name.s,
+                       _orig->nameaddr.name.s, _r->nameaddr.uri.s);
 
        ptr = _r->params;
        while(ptr) {
                /*              if (ptr->type == P_R2) _r->r2 = ptr; */
-               ptr->name.s = translate_pointer(_r->nameaddr.name.s, _orig->nameaddr.name.s, ptr->name.s);
-               ptr->body.s = translate_pointer(_r->nameaddr.name.s, _orig->nameaddr.name.s, ptr->body.s);
+               ptr->name.s = translate_pointer(_r->nameaddr.name.s,
+                               _orig->nameaddr.name.s, ptr->name.s);
+               ptr->body.s = translate_pointer(_r->nameaddr.name.s,
+                               _orig->nameaddr.name.s, ptr->body.s);
                ptr = ptr->next;
        }
 }
@@ -271,7 +274,7 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
        rr_t* res, *prev, *it;
 
        if (!_new || !_r) {
-               LOG(L_ERR, "Invalid parameter value\n");
+               LM_ERR("Invalid parameter value\n");
                return -1;
        }
        prev  = NULL;
@@ -288,7 +291,7 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
                if (_shm) res = shm_malloc(sizeof(rr_t) + len);
                else res = pkg_malloc(sizeof(rr_t) + len);
                if (!res) {
-                       LOG(L_ERR, "No memory left\n");
+                       LM_ERR("No memory left\n");
                        return -2;
                }
                memcpy(res, it, sizeof(rr_t));
@@ -303,7 +306,7 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
                }
 
                if (ret < 0) {
-                       LOG(L_ERR, "Error while duplicating parameters\n");
+                       LM_ERR("Error while duplicating parameters\n");
                        if (_shm) shm_free(res);
                        else pkg_free(res);
                        return -3;
index 8009e1b..5b34713 100644 (file)
 
 static inline char* skip_token(char* _b, int _l)
 {
-        int i = 0;
-
-        for(i = 0; i < _l; i++) {
-                switch(_b[i]) {
-                case ' ':
-                case '\r':
-                case '\n':
-                case '\t':
-                case ';':
-                        return _b + i;
-                }
-        }
-
-        return _b + _l;
+       int i = 0;
+
+       for(i = 0; i < _l; i++) {
+               switch(_b[i]) {
+                       case ' ':
+                       case '\r':
+                       case '\n':
+                       case '\t':
+                       case ';':
+                               return _b + i;
+               }
+       }
+
+       return _b + _l;
 }
 
 
 int etag_parser(char *_s, int _l, str *_e)
 {
-        char* end;
+       char* end;
 
-        _e->s = _s;
-        _e->len = _l;
+       _e->s = _s;
+       _e->len = _l;
 
-        trim_leading(_e);
+       trim_leading(_e);
 
-        if (_e->len == 0) {
-                LOG(L_ERR, "etag_parser(): Empty body\n");
-                return -1;
-        }
+       if (_e->len == 0) {
+               LM_ERR("Empty body\n");
+               return -1;
+       }
 
-        end = skip_token(_e->s, _e->len);
-        _e->len = end - _e->s;
+       end = skip_token(_e->s, _e->len);
+       _e->len = end - _e->s;
 
        return 0;
 }
@@ -76,28 +76,28 @@ int parse_sipifmatch(struct hdr_field* _h)
 {
        str *e;
 
-       DBG("parse_sipifmatch() called\n");
+       LM_DBG("parse sip-if-match called\n");
 
-        if (_h->parsed != 0) {
-                return 0;
-        }
+       if (_h->parsed != 0) {
+               return 0;
+       }
 
-        e = (str*)pkg_malloc(sizeof(str));
-        if (e == 0) {
-                LOG(L_ERR, "parse_ifsipmatch(): No memory left\n");
-                return -1;
-        }
+       e = (str*)pkg_malloc(sizeof(str));
+       if (e == 0) {
+               LM_ERR("No memory left\n");
+               return -1;
+       }
 
-        memset(e, 0, sizeof(str));
+       memset(e, 0, sizeof(str));
 
-        if (etag_parser(_h->body.s, _h->body.len, e) < 0) {
-                LOG(L_ERR, "parse_sipifmatch(): Error in tag_parser\n");
-                pkg_free(e);
-                return -2;
-        }
+       if (etag_parser(_h->body.s, _h->body.len, e) < 0) {
+               LM_ERR("Error in etag parser\n");
+               pkg_free(e);
+               return -2;
+       }
 
-        _h->parsed = (void*)e;
-        return 0;
+       _h->parsed = (void*)e;
+       return 0;
 }
 
 
index eb4c84b..8c3d54e 100644 (file)
@@ -167,7 +167,7 @@ enum
        FIN_COMP
 #endif
        /*GEN_PARAM,
-              PARAM_ERROR*/ /* declared in msg_parser.h*/
+       PARAM_ERROR*/ /* declared in msg_parser.h*/
 };
 
 
@@ -238,7 +238,7 @@ static /*inline*/ char *parse_via_param(char *const p, const char *const end,
                                break;                                                        \
                        default:                                                          \
                                LM_ERR("invalid "                                             \
-                                          "char <%c> in state %d\n",                             \
+                                               "char <%c> in state %d\n",                            \
                                                *tmp, state);                                         \
                                goto error;                                                   \
                }
@@ -502,7 +502,7 @@ static /*inline*/ char *parse_via_param(char *const p, const char *const end,
                                        case FIN_COMP:
 #endif
                                                LM_ERR("new via found"
-                                                          "(',') when '=' expected (state %d=)\n",
+                                                               "(',') when '=' expected (state %d=)\n",
                                                                state);
                                                goto error; /* or we could ignore this bad param*/
                                        case F_CR:
@@ -1305,12 +1305,12 @@ normal_exit:
 
 end_via:
        /* if we are here we found an "unexpected" end of via
-             *  (cr/lf). This is valid only if the param type is GEN_PARAM or
-                 *  RPORT (the only ones which can miss the value; HIDDEN is a
-                 *  special case )*/
+        * (cr/lf). This is valid only if the param type is GEN_PARAM or
+        *  RPORT (the only ones which can miss the value; HIDDEN is a
+        *  special case )*/
        if((param->type == GEN_PARAM) || (param->type == PARAM_RPORT)) {
                saved_state = L_PARAM; /* change the saved_state, we have an unknown
-                                       param. w/o a value */
+                                                               * param. w/o a value */
                /* param->size should be computed before */
                goto normal_exit;
        }
@@ -1347,7 +1347,7 @@ char *parse_via(
        struct via_param *param;
 
        vb = vbody; /* keep orignal vbody value, needed to set the error member
-                                in case of multiple via bodies in the same header */
+                               * in case of multiple via bodies in the same header */
 parse_again:
        vb->error = PARSE_ERROR;
        /* parse start of via ( SIP/2.0/UDP    )*/
@@ -2527,11 +2527,11 @@ main_via:
                                                                break;
                                                        case F_VIA:
                                                                vb->params.len = param->start + param->size
-                                                                                                - vb->params.s;
+                                                                                                       - vb->params.s;
                                                                break;
                                                        case END_OF_HEADER:
                                                                vb->params.len = param->start + param->size
-                                                                                                - vb->params.s;
+                                                                                                       - vb->params.s;
                                                                break;
                                                        case PARAM_ERROR:
                                                                pkg_free(param);
@@ -2539,7 +2539,7 @@ main_via:
                                                        default:
                                                                pkg_free(param);
                                                                LM_ERR("parsing via after parse_via_param:"
-                                                                          " invalid char <%c> on state %d\n",
+                                                                               " invalid char <%c> on state %d\n",
                                                                                *tmp, state);
                                                                goto error;
                                                }
@@ -2581,7 +2581,7 @@ main_via:
                                                                                                        SERGZ_NAME_LEN)==0)){
                                                                        vb->comp_no=COMP_SERGZ;
                                                                }else{
-                                                                       LOG(L_ERR, "ERROR: parse_via: unrecognized"
+                                                                       LM_ERR("unrecognized"
                                                                                " compression method in comp=%.*s\n",
                                                                                param->value.len, param->value.s);
                                                                }
@@ -2624,7 +2624,7 @@ main_via:
                                                goto endofheader;
                                        default:
                                                LM_ERR("BUG: parsing via - invalid char <%c>"
-                                                          " in state %d\n",
+                                                               " in state %d\n",
                                                                *tmp, state);
                                                goto error;
                                }
@@ -2711,7 +2711,7 @@ error:
        }
        vb->error = PARSE_ERROR;
        vbody->error = PARSE_ERROR; /* make sure the first via body is marked
-                                                                as bad also */
+                                                                as bad also */
        return tmp;
 }
 
@@ -2749,7 +2749,7 @@ int parse_via_header(struct sip_msg *msg, int n, struct via_body **q)
                case 1:
                case 2:
                        if(!msg->h_via1 && (parse_headers(msg, HDR_VIA_F, 0) == -1
-                                                                          || !msg->h_via1)) {
+                                                                       || !msg->h_via1)) {
                                DBG("bad msg or missing VIA1 header \n");
                                return -1;
                        }
@@ -2761,7 +2761,7 @@ int parse_via_header(struct sip_msg *msg, int n, struct via_body **q)
                                break;
 
                        if(!msg->h_via2 && (parse_headers(msg, HDR_VIA2_F, 0) == -1
-                                                                          || !msg->h_via2)) {
+                                                                       || !msg->h_via2)) {
                                DBG("bad msg or missing VIA2 header \n");
                                return -1;
                        }