OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp_config.c versions 1.53 and 1.54
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.53 -> 1.54

--- 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]);
         }
     }
 }

CVSTrac 2.0.1