Index: ossp-pkg/lmtp2nntp/fixme.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v rcsdiff -q -kk '-r1.17' '-r1.18' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/fixme.h,v' 2>/dev/null --- fixme.h 2002/02/20 15:42:26 1.17 +++ fixme.h 2002/02/27 09:34:41 1.18 @@ -34,7 +34,6 @@ #include struct headerrule_st { headerrule_t *next; - char *carve; /* pri, regex, header, val carved out here, so free up only this */ int pri; char *regex; char *header; Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v rcsdiff -q -kk '-r1.53' '-r1.54' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null --- lmtp2nntp_config.c 2002/02/26 15:56:08 1.53 +++ lmtp2nntp_config.c 2002/02/27 09:34:41 1.54 @@ -557,12 +557,9 @@ { volatile headerrule_t *hrNew = NULL; // declare and initialize variables which might have resources allocated that need to be cleaned up when an exception is caught try { - char *cp; + char *cp, *cpP; + int n; int i; - char *cpPri; - char *cpRegex; - char *cpHeader; - char *cpVal; headerrule_t *hrI; headerrule_t *hrP; const char *cpError; @@ -583,57 +580,57 @@ hrNew = (headerrule_t *)mallocex(sizeof(headerrule_t)); hrNew->next = NULL; - hrNew->carve = NULL; + hrNew->pri = 500; /* default priority */ + hrNew->regex = NULL; + hrNew->header = NULL; + hrNew->val = NULL; hrNew->pcreRegex = NULL; hrNew->pcreExtra = NULL; - cp = hrNew->carve = strdupex(cp); + //FIXME cp = hrNew->carve = strdupex(cp); /* priority */ - cpPri = cp; + cpP = cp; if ((cp = strchr(cp, ':')) == NULL) { log1(ctx, ERROR, "option --headerrule, priority (%s) terminating colon missing", (ov->data.m)[i]); throw(0,0,0); } - *cp = NUL; - if (strlen(cpPri) == 0) - cpPri = "0"; cp++; + n = cp - cpP; + if (n >= 2) /* mandatory colon and at least one more char */ + hrNew->pri = atoi(cpP); /* regex */ - cpRegex = cp; + cpP = cp; if ((cp = strchr(cp, ':')) == NULL) { log1(ctx, ERROR, "option --headerrule, regex (%s) terminating colon missing", (ov->data.m)[i]); throw(0,0,0); } - *cp = NUL; - if (strlen(cpRegex) == 0) - cpRegex = NULL; cp++; + n = cp - cpP; + if (n >= 2) /* mandatory colon and at least one more char */ + hrNew->regex = str_dupex(cpP, n); /* header */ - cpHeader = cp; + cpP = cp; if ((cp = strchr(cp, ':')) == NULL) { log1(ctx, ERROR, "option --headerrule, header (%s) terminating colon missing", (ov->data.m)[i]); throw(0,0,0); } - *cp = NUL; - if (strlen(cpHeader) == 0) { + cp++; + n = cp - cpP; + if (n == 0) { log1(ctx, ERROR, "option --headerrule, header (%s) missing", (ov->data.m)[i]); throw(0,0,0); } - cp++; + hrNew->header = str_dupex(cpP, n); /* value */ - cpVal = cp; - if (strlen(cpVal) == 0) - cpVal = NULL; - - hrNew->pri = atoi(cpPri); - hrNew->regex = cpRegex; - hrNew->header = cpHeader; - hrNew->val = cpVal; + cpP = cp; + n = strlen(cpP); + if (n >= 1) + hrNew->val = str_dupex(cpP, n); - if (cpRegex != NULL) { + if (hrNew->regex != NULL) { /* compile regular expression into finite state machine and optimize */ - if ((hrNew->pcreRegex = pcre_compile(cpRegex, PCRE_CASELESS, &cpError, &iError, NULL)) == NULL) { - log3(ctx, ERROR, "option --headerrule, regex (%s) failed at pos %d with %s", cpRegex, iError, cpError); + if ((hrNew->pcreRegex = pcre_compile(hrNew->regex, PCRE_CASELESS, &cpError, &iError, NULL)) == NULL) { + log3(ctx, ERROR, "option --headerrule, regex (%s) failed at pos %d with %s", hrNew->regex, iError, cpError); throw(0,0,0); } hrNew->pcreExtra = pcre_study(hrNew->pcreRegex, 0, &cpError); @@ -662,12 +659,16 @@ } cleanup { if (hrNew != NULL) { - if (hrNew->carve != NULL) - freeex(hrNew->carve); - if (hrNew->pcreRegex != NULL) - free(hrNew->pcreRegex); if (hrNew->pcreExtra != NULL) free(hrNew->pcreExtra); + if (hrNew->pcreRegex != NULL) + free(hrNew->pcreRegex); + if (hrNew->val != NULL) + freeex(hrNew->val); + if (hrNew->header != NULL) + freeex(hrNew->header); + if (hrNew->regex != NULL) + freeex(hrNew->regex); freeex((headerrule_t *)hrNew); } } @@ -1392,11 +1393,11 @@ cp = NULL; while ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) != NULL) { /* for each message header */ - log2(msg, DEBUG, "FIXME trace loop cp=%.8lx, cp=\"%s\"", cp, cp); + //log2(msg, DEBUG, "FIXME trace loop cp=%.8lx, cp=\"%s\"", cp, cp); /*FIXME we want O(1) here */ for (hdP = NULL, hdI = msg->hdFirst; hdI != NULL; hdP = hdI, hdI = hdI->next) { /* for each matrix header */ - log2(msg, DEBUG, "FIXME trace loop hdI=%.8lx, hI->name=\"%s\"", hdI, hdI->name); + //log2(msg, DEBUG, "FIXME trace loop hdI=%.8lx, hI->name=\"%s\"", hdI, hdI->name); if (hdI->name == NULL || strlen(hdI->name) == 0 || hdI->ndata == 0) continue; if (strcmp(cp, hdI->name) == 0) @@ -1447,10 +1448,10 @@ if (hdD->ndata == 0) log1(msg, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(msg, DEBUG, "hdD->name:hdD->data.s %s: %s", hdD->name, hdD->data.s); + log2(msg, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(msg, DEBUG, "hdD->name:hdD->data.m[%d] %s: %s", i, hdD->name, hdD->data.m[i]); + log3(msg, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } #endif @@ -1506,10 +1507,10 @@ if (hdD->ndata == 0) log1(msg, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(msg, DEBUG, "hdD->name:hdD->data.s %s: %s", hdD->name, hdD->data.s); + log2(msg, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(msg, DEBUG, "hdD->name:hdD->data.m[%d] %s: %s", i, hdD->name, hdD->data.m[i]); + log3(msg, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } #endif @@ -1563,10 +1564,10 @@ if (hdD->ndata == 0) log1(ctx, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(ctx, DEBUG, "hdD->name:hdD->data.s %s: %s", hdD->name, hdD->data.s); + log2(ctx, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s: %s", i, hdD->name, hdD->data.m[i]); + log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } @@ -1590,10 +1591,10 @@ if (hdD->ndata == 0) log1(ctx, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(ctx, DEBUG, "hdD->name:hdD->data.s %s: %s", hdD->name, hdD->data.s); + log2(ctx, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s: %s", i, hdD->name, hdD->data.m[i]); + log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } if (hrI->regex != NULL) { @@ -1713,10 +1714,10 @@ if (hdD->ndata == 0) log1(ctx, DEBUG, "hdD->name=%s: (NO DATA)", hdD->name); if (hdD->ndata == 1) - log2(ctx, DEBUG, "hdD->name:hdD->data.s %s: %s", hdD->name, hdD->data.s); + log2(ctx, DEBUG, "hdD->name:hdD->data.s %s %s", hdD->name, hdD->data.s); if (hdD->ndata > 1) for (i = 0; i < hdD->ndata; i++) - log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s: %s", i, hdD->name, hdD->data.m[i]); + log3(ctx, DEBUG, "hdD->name:hdD->data.m[%d] %s %s", i, hdD->name, hdD->data.m[i]); } } } Index: ossp-pkg/lmtp2nntp/lmtp2nntp_exwrap.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_exwrap.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_exwrap.c,v' 2>/dev/null --- lmtp2nntp_exwrap.c 2002/02/14 10:51:50 1.1 +++ lmtp2nntp_exwrap.c 2002/02/27 09:34:41 1.2 @@ -40,6 +40,15 @@ return rc; } +char *str_dupex(const char *s, str_size_t n) +{ + char *rc; + + if ((rc = str_dup(s, n)) == NULL) + throw(0,0,0); + return rc; +} + void *mallocex(size_t size) { void *rc; Index: ossp-pkg/lmtp2nntp/lmtp2nntp_exwrap.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_exwrap.h,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_exwrap.h,v' 2>/dev/null --- lmtp2nntp_exwrap.h 2002/02/14 10:51:50 1.1 +++ lmtp2nntp_exwrap.h 2002/02/27 09:34:41 1.2 @@ -29,11 +29,12 @@ #define __LMTP2NNTP_EXWRAP_H__ #include +#include char *strdupex(const char *); +char *str_dupex(const char *, str_size_t); void *mallocex(size_t); void *reallocex(void *, size_t); void freeex(void *); - #endif /* __LMTP2NNTP_EXWRAP_H__ */