Module: sip-router Branch: master Commit: af8bbc2e13ed2831a88acf65fd7cf7e2b18eec78 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=af8bbc2e...
Author: Ovidiu Sas osas@voipembedded.com Committer: Ovidiu Sas osas@voipembedded.com Date: Fri Oct 3 20:56:28 2014 -0400
re.c: logging: convert LOG to LM_*
---
re.c | 48 +++++++++++++++++++++--------------------------- 1 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/re.c b/re.c index 9c4c4b3..e1fe37d 100644 --- a/re.c +++ b/re.c @@ -231,16 +231,14 @@ struct subst_expr* subst_parser(str* subst) cflags=REG_EXTENDED | REG_NEWLINE; /* don't match newline */ replace_all=0; if (subst->len<3){ - LOG(L_ERR, "ERROR: subst_parser: expression is too short: %.*s\n", - subst->len, subst->s); + LM_ERR("expression is too short: %.*s\n", subst->len, subst->s); goto error; } p=subst->s; c=*p; if (c=='\'){ - LOG(L_ERR, "ERROR: subst_parser: invalid separator char <%c>" - " in %.*s\n", c, subst->len, subst->s); + LM_ERR("invalid separator char <%c> in %.*s\n", c, subst->len, subst->s); goto error; } p++; @@ -251,13 +249,12 @@ struct subst_expr* subst_parser(str* subst) /* if unescaped sep. char */ if ((*p==c) && (*(p-1)!='\')) goto found_re; } - LOG(L_ERR, "ERROR: subst_parser: no separator found: %.*s\n", subst->len, - subst->s); + LM_ERR("no separator found: %.*s\n", subst->len, subst->s); goto error; found_re: re_end=p; if (end < (p + 2)) { - ERR("subst_parser: String too short\n"); + LM_ERR("String too short\n"); goto error; } repl=p+1; @@ -279,15 +276,14 @@ found_re: replace_all=1; break; default: - LOG(L_ERR, "ERROR: subst_parser: unknown flag %c in %.*s\n", - *p, subst->len, subst->s); + LM_ERR("unknown flag %c in %.*s\n", *p, subst->len, subst->s); goto error; } }
/* compile the re */ if ((regex=pkg_malloc(sizeof(regex_t)))==0){ - LOG(L_ERR, "ERROR: subst_parser: out of memory (re)\n"); + LM_ERR("out of memory\n"); goto error; } c=*re_end; /* regcomp expects null terminated strings -- save */ @@ -296,8 +292,8 @@ found_re: pkg_free(regex); regex=0; *re_end=c; /* restore */ - LOG(L_ERR, "ERROR: subst_parser: bad regular expression %.*s in " - "%.*s\n", (int)(re_end-re), re, subst->len, subst->s); + LM_ERR("bad regular expression %.*s in %.*s\n", + (int)(re_end-re), re, subst->len, subst->s); goto error; } *re_end=c; /* restore */ @@ -306,7 +302,7 @@ found_re: ((rw_no)?(rw_no-1)*sizeof(struct replace_with):0)); /* 1 replace_with structure is already included in subst_expr */ if (se==0){ - LOG(L_ERR, "ERROR: subst_parser: out of memory (subst_expr)\n"); + LM_ERR("out of memory\n"); goto error; } memset((void*)se, 0, sizeof(struct subst_expr)); @@ -314,7 +310,7 @@ found_re: se->replacement.len=repl_end-repl; if (se->replacement.len > 0) { if ((se->replacement.s=pkg_malloc(se->replacement.len))==0){ - LOG(L_ERR, "ERROR: subst_parser: out of memory (replacement)\n"); + LM_ERR("out of memory\n"); goto error; } /* start copying */ @@ -351,7 +347,7 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
#define RBUF_APPEND(dst, src, size) \ if ((dst) - rbuf + (size) >= REPLACE_BUFFER_SIZE - 1) { \ - ERR("replace_build: Buffer too small\n"); \ + LM_ERR("Buffer too small\n"); \ goto error; \ } \ memcpy((dst), (src), (size)); \ @@ -383,8 +379,7 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch, break; case REPLACE_URI: if (msg->first_line.type!=SIP_REQUEST){ - LOG(L_CRIT, "BUG: replace_build: uri substitution on" - " a reply\n"); + LM_CRIT("uri substitution on a reply\n"); break; /* ignore, we can continue */ } uri= (msg->new_uri.s)?(&msg->new_uri): @@ -393,21 +388,20 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch, break; case REPLACE_SPEC: if(pv_get_spec_value(msg, &se->replace[r].u.spec, &sv)!=0) { - ERR("replace_build: item substitution returned error\n"); + LM_ERR("item substitution returned error\n"); break; /* ignore, we can continue */ } RBUF_APPEND(dest, sv.rs.s, sv.rs.len); break; default: - LOG(L_CRIT, "BUG: replace_build: unknown type %d\n", - se->replace[r].type); + LM_CRIT("unknown type %d\n", se->replace[r].type); /* ignore it */ } } RBUF_APPEND(dest, p, end-p); rpl->len = dest - rbuf; if ((rpl->s = pkg_malloc(rpl->len)) == NULL) { - ERR("replace_build: Out of pkg memory\n"); + LM_ERR("Out of pkg memory\n"); goto error; } memcpy(rpl->s, rbuf, rpl->len); @@ -445,7 +439,7 @@ struct replace_lst* subst_run(struct subst_expr* se, const char* input, /* no of () referenced + 1 for the whole string: pmatch[0] */ pmatch=pkg_malloc(nmatch*sizeof(regmatch_t)); if (pmatch==0){ - LOG(L_ERR, "ERROR: subst_run_ out of mem. (pmatch)\n"); + LM_ERR("out of mem\n"); goto error; } eflags=0; @@ -455,16 +449,16 @@ struct replace_lst* subst_run(struct subst_expr* se, const char* input, /* subst */ if (r==0){ /* != REG_NOMATCH */ if (pmatch[0].rm_so==-1) { - ERR("subst_run: Unknown offset?\n"); + LM_ERR("Unknown offset?\n"); goto error; } if (pmatch[0].rm_so==pmatch[0].rm_eo) { - ERR("subst_run: Matched string is empty, invalid regexp?\n"); + LM_ERR("Matched string is empty, invalid regexp?\n"); goto error; } *crt=pkg_malloc(sizeof(struct replace_lst)); if (*crt==0){ - LOG(L_ERR, "ERROR: subst_run: out of mem (crt)\n"); + LM_ERR("out of mem\n"); goto error; } memset(*crt, 0, sizeof(struct replace_lst)); @@ -527,12 +521,12 @@ str* subst_str(const char *input, struct sip_msg* msg, struct subst_expr* se, len+=(int)(l->rpl.len)-l->size; res=pkg_malloc(sizeof(str)); if (res==0){ - LOG(L_ERR, "ERROR: subst_str: mem. allocation error\n"); + LM_ERR("mem. allocation error\n"); goto error; } res->s=pkg_malloc(len+1); /* space for null termination */ if (res->s==0){ - LOG(L_ERR, "ERROR: subst_str: mem. allocation error (res->s)\n"); + LM_ERR("mem. allocation error (res->s)\n"); goto error; } res->s[len]=0;