OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.47 -> 1.48

--- lmtp2nntp_config.c   2002/02/07 13:36:16     1.47
+++ lmtp2nntp_config.c   2002/02/13 16:25:38     1.48
@@ -526,45 +526,78 @@
     catch (ex)
         rethrow;
 
-    /* --headervalue MULTI */
+    /* --headerrule MULTI */
     try {
         char *cp;
         int i;
+        char *cpPri;
+        char *cpRegex;
         char *cpHeader;
-        char *cpValue;
+        char *cpVal;
+        headerrule_t *hrNew;
+        headerrule_t *hrI;
+        headerrule_t *hrP;
 
-        if (   (val_get(ctx->val, "option.headervalue", &ov) != VAL_OK)
+        if (   (val_get(ctx->val, "option.headerrule", &ov) != VAL_OK)
             || (ov->ndata <  0)
             || (ov->ndata >= 1 && ov->data.m == NULL)
               ) throw(0,0,0);
         log1(ctx, DEBUG, "ov->ndata = %d", ov->ndata);
         for (i = 0; i < ov->ndata; i++)
-            log2(ctx, TRACE, "--headervalue[%d] = \"%s\"", i, (ov->data.m)[i]);
+            log2(ctx, TRACE, "--headerule[%d] = \"%s\"", i, (ov->data.m)[i]);
 
         if (ov->ndata >= 1) {
             for (i = 0; i < ov->ndata; i++) {
                 cp = (ov->data.m)[i];
                 log2(ctx, DEBUG, "cp = (data.m)[%d] = \"%s\"", i, cp);
-                cpHeader = strdup(cp);
-                if ((cp = strchr(cpHeader, ':')) == NULL) {
-                    log1(ctx, ERROR, "option --headervalue, header (%s) terminating colon missing", (ov->data.m)[i]);
+                cp = strdup(cp); //FIXME
+                /* priority */
+                cpPri = 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;
                 cp++;
+                /* regex */
+                cpRegex = 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;
-                log2(ctx, DEBUG, "header[%d] = \"%s\"", i, cpHeader);
                 cp++;
-                while (*cp == ' ') cp++; //FIXME note this in NEWS
-                if (*cp == NUL) {
-                    log1(ctx, ERROR, "option --headervalue, value (%s) missing", (ov->data.m)[i]);
+                /* header */
+                cpHeader = cp;
+                if ((cp = strchr(cp, ':')) == NULL) {
+                    log1(ctx, ERROR, "option --headerrule, header (%s) terminating colon missing", (ov->data.m)[i]);
                     throw(0,0,0);
                 }
-                cpValue = strdup(cp);
-                log2(ctx, DEBUG, " value[%d] = \"%s\"", i, cpValue);
-                argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeader);
-                argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpValue);
-                free(cpHeader);
-                free(cpValue);
+                *cp = NUL;
+                cp++;
+                /* value */
+                cpVal = cp;
+
+                if ((hrNew = (headerrule_t *)malloc(sizeof(headerrule_t))) == NULL) throw(0,0,0);
+                hrNew->next   = NULL;
+                hrNew->pri    = atoi(cpPri);
+                hrNew->regex  = cpRegex;
+                hrNew->header = cpHeader;
+                hrNew->val    = cpVal;
+
+                if (ctx->option_firstheaderrule == NULL)
+                    ctx->option_firstheaderrule = hrNew;
+                else {
+                    for (hrP = NULL, hrI = ctx->option_firstheaderrule;
+                         hrI != NULL && hrI->pri <= hrNew->pri;
+                         hrP = hrI, hrI = hrI->next);
+                    if (hrI != NULL)
+                        hrNew->next = hrI; /* insert */
+                    if (hrP != NULL)
+                        hrP->next = hrNew; /* append */
+                    else
+                        ctx->option_firstheaderrule = hrNew; /* newfirst */
+                }
             }
         }
     }

CVSTrac 2.0.1