OSSP CVS Repository

ossp - Check-in [1745]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1745
Date: 2002-Jan-31 15:20:09 (local)
2002-Jan-31 14:20:09 (UTC)
User:thl
Branch:
Comment: moved --headervalue option
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/example.conf      1.10 -> 1.11     1 inserted, 1 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.24 -> 1.25     43 inserted, 0 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.18 -> 1.19     0 inserted, 24 deleted

ossp-pkg/lmtp2nntp/example.conf 1.10 -> 1.11

--- example.conf 2002/01/31 13:44:05     1.10
+++ example.conf 2002/01/31 14:20:09     1.11
@@ -24,7 +24,7 @@
 client          127.0.0.1:45678                 #see -c aka --client
 destination     127.0.0.1:nntp                  #see -d aka --destination
 groupmode       envelope                        #see -g aka --groupmode
-headervalue     X-gateway "lmtp2nntp gateway"   #see -h aka --headervalue
+headervalue     'X-gateway: lmtp2nntp gateway'  #see -h aka --headervalue
 #include         "sampleconfig.two"             #    -i aka --include
                                                 #    -l is obsolete since v1.2, see l2spec
 


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.24 -> 1.25

--- lmtp2nntp_config.c   2002/01/31 13:54:21     1.24
+++ lmtp2nntp_config.c   2002/01/31 14:20:09     1.25
@@ -426,6 +426,49 @@
     }
     catch (ex)
         rethrow;
+
+    /* --headervalue MULTI */
+    try {
+        char *cp;
+        int i;
+        char *cpHeader;
+        char *cpValue;
+
+        if (   (val_get(ctx->val, "option.headervalue", &ov) != VAL_OK)
+            || ((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]);
+
+        if ((ctx->pacl = (struct acl *)malloc(ov->ndata * sizeof(struct acl))) == NULL) throw(0,0,0);
+        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]);
+                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]);
+                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);
+        }
+    }
+    catch (ex)
+        rethrow;
+
 CUS:
     return;
 }


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.18 -> 1.19

--- lmtp2nntp_main.c     2002/01/31 13:54:21     1.18
+++ lmtp2nntp_main.c     2002/01/31 14:20:09     1.19
@@ -370,8 +370,6 @@
     char         *cpValue;
     int           nValue;
     struct passwd *sPasswd;
-    char         *cpHeadername;
-    char         *cpHeadervalue;
 
     /* drop effective uid/gid priviledges */
     seteuid(getuid());
@@ -458,28 +456,6 @@
     /* read in the arguments */
     while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:h:l:m:n:o:r:s:t:u:v")) != -1) {
         switch (i) {
-            case 'h': /*POD [B<-h> I<header>:<value>] */
-                cpHeadername = strdup(optarg);
-                if ((cp = strchr(cpHeadername, ':')) == NULL) {
-                    free(cpHeadername);
-                    fprintf(stderr, "%s:Error: header \"%s\" for -h option not terminated with colon\n", 
-                            ctx->progname, cpHeadername);
-                    CU(ERR_EXECUTION);
-                }
-                cp++;
-                if (*cp == NUL) {
-                    free(cpHeadername);
-                    fprintf(stderr, "%s:Error: header \"%s\" for -h option has no value\n", 
-                            ctx->progname, cpHeadername);
-                    CU(ERR_EXECUTION);
-                }
-                cpHeadervalue = strdup(cp);
-                *cp = NUL;
-                argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadername);
-                argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadervalue);
-                free(cpHeadervalue);
-                free(cpHeadername);
-                break;
             case 'm': /*POD [B<-m> I<mailfrom>] */
                 ctx->option_mailfrom = strdup(optarg);
                 /* protect ourselfs from the substitution of backreferences.

CVSTrac 2.0.1