OSSP CVS Repository

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

Check-in Number: 1617
Date: 2002-Jan-23 16:55:21 (local)
2002-Jan-23 15:55:21 (UTC)
User:thl
Branch:
Comment: flag options no longer have an optarg
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/example.conf      1.5 -> 1.6     3 inserted, 3 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.12 -> 1.13     60 inserted, 22 deleted

ossp-pkg/lmtp2nntp/example.conf 1.5 -> 1.6

--- example.conf 2002/01/23 14:12:52     1.5
+++ example.conf 2002/01/23 15:55:21     1.6
@@ -6,8 +6,8 @@
         ### DAEMON ###
 
 childsmax       10                              #see -C aka --childsmax
-daemonize       yes                             #see -D aka --daemonize
-kill            4711                            #see -K aka --kill
+daemonize                                       #see -D aka --daemonize
+kill                                            #see -K aka --kill
 pidfile         "/tmp/pid"                      #see -P aka --pidfile
 veryverbose                                     #see -V aka --veryverbose
                                                 #           obsolete since v1.2
@@ -25,7 +25,7 @@
 destination     news.example.com                #see -d aka --destination
 groupmode       envelope                        #see -g aka --groupmode
 headervalue     X-gateway "lmtp2nntp gateway"   #see -h aka --headervalue
-include         "sampleconfig.two"              #    -i aka --include
+#include         "sampleconfig.two"             #    -i aka --include
                                                 #    -l is obsolete since v1.2, see l2spec
 
 l2spec          prefix(prefix="%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: ",timezone=local) \


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.12 -> 1.13

--- lmtp2nntp_config.c   2002/01/23 14:12:52     1.12
+++ lmtp2nntp_config.c   2002/01/23 15:55:21     1.13
@@ -342,8 +342,36 @@
     }
     //printf("DEBUG: current popt error is \"%s\"(%d)\n", popt_strerror(i), i);
     //printf("DEBUG: ----\n");
-    while ((cp = (char *)popt_getarg(poptCon)) != NULL) {
-        printf("DEBUG: popt_getarg returned \"%s\"\n", cp);
+
+    {
+        int largc;
+        char **largv;
+        char *cpNew;
+
+        if ((largv = (char **)malloc((1 + 1) * sizeof(char **))) == NULL)
+            return OPTION_ERR_MEM;
+        largc = 0;
+        largv[largc++] = "leftover";
+        largv[largc] = NULL;
+        while ((cp = (char *)popt_getarg(poptCon)) != NULL) {
+            //printf("DEBUG: popt_getarg returned \"%s\"\n", cp);
+            if ((largv = (char **)realloc(largv, (largc + 2) * sizeof(char **))) == NULL)
+                return OPTION_ERR_MEM;
+            largv[largc++] = "--newsgroup";
+            largv[largc] = NULL;
+            if ((cpNew = strdup(cp)) == NULL)
+                return OPTION_ERR_MEM;
+            //printf("DEBUG: cpNew = \"%s\"\n", cpNew);
+            largv[largc++] = cpNew;
+            largv[largc] = NULL;
+            //printf("DEBUG: largc = \"%d\"\n", largc);
+#if 0
+            for (i=0; i<largc; i++)
+                printf("DEBUG: largv[%d] = \"%s\"\n", i, largv[i]);
+#endif
+        }
+        if (largc > 1)
+            option_parse_internal(o, largc, largv);
     }
     //printf("DEBUG: current popt error is \"%s\"(%d)\n", popt_strerror(i), i);
     popt_freecontext(poptCon);
@@ -373,12 +401,14 @@
              *  if (oc->ndata >= 1 || oc->data.s != NULL)
              *      return OPTION_ERR_USE;
              */
+#if 0
             if (cbctx != NULL)
                 if (str_parse(arg, cbctx) <= 0) {
                     //printf("DEBUG: \"%s\" does NOT match \"%s\"\n", arg, cbctx);
                     return OPTION_ERR_USE;
                 }
             //printf("DEBUG: \"%s\" does match \"%s\"\n", arg, cbctx);
+#endif
             if ((oc->data.s = strdup(arg)) == NULL)
                     return OPTION_ERR_MEM;
             oc->ndata = 1;
@@ -389,12 +419,14 @@
                 return OPTION_ERR_ARG;
             if (oc->ndata >= 1 && oc->data.m == NULL)
                     return OPTION_ERR_USE;
+#if 0
             if (cbctx != NULL)
                 if (str_parse(arg, cbctx) <= 0) {
                     //printf("DEBUG: \"%s\" does NOT match \"%s\"\n", arg, cbctx);
                     return OPTION_ERR_USE;
                 }
             //printf("DEBUG: \"%s\" does match \"%s\"\n", arg, cbctx);
+#endif
             if (oc->data.m == NULL) {
                 if ((oc->data.m = (char **)malloc(             (        1 + 1) * sizeof(char **))) == NULL)
                     return OPTION_ERR_MEM;
@@ -407,6 +439,14 @@
                     return OPTION_ERR_MEM;
             oc->ndata++;
             oc->data.m[oc->ndata] = NULL;
+#if 1
+            {
+                int i;
+                printf("DEBUG: oc->ndata=%d\n", oc->ndata);
+                for (i=0; i<oc->ndata; i++)
+                    printf("DEBUG: oc->data[%3d] = %s\n", i, oc->data.m[i]);
+            }
+#endif
             break;
         default:
             return OPTION_ERR_ARG;
@@ -499,30 +539,29 @@
                                 ;/* don't care about comments */
                             else {
                                 //printf("DEBUG:    option = ***%s***\n", option);
+                                if (argv == NULL) {
+                                    if ((argv = (char **)malloc(   (   1 + 1) * sizeof(char **))) == NULL)
+                                        return OPTION_ERR_MEM;
+                                    argc = 0;
+                                    argv[argc++] = "include";
+                                    argv[argc] = NULL;
+                                }
+
+                                if ((cpNew = (char *)malloc(2 + strlen(option) + 1)) == NULL)
+                                    return OPTION_ERR_MEM;
+                                cpNew[0]=NUL;
+                                strcat(cpNew, "--");
+                                strcat(cpNew, option);
+                                if ((argv = (char **)realloc(argv, (argc + 1) * sizeof(char **))) == NULL)
+                                    return OPTION_ERR_MEM;
+                                argv[argc++] = cpNew;
+                                argv[argc] = NULL;
+
                                 if ((value = str_token(&cp, " \t", "\"'", "#", STR_STRIPQUOTES|STR_BACKSLASHESC)) == NULL)
                                     ;//printf("DEBUG: no value - section\n");
                                 else {
                                     while(isspace((int)*value)) value++;
                                     //printf("DEBUG:     value = ***%s***\n", value);
-
-                                    if (argv == NULL) {
-                                        if ((argv = (char **)malloc(   (   1 + 1) * sizeof(char **))) == NULL)
-                                            return OPTION_ERR_MEM;
-                                        argc = 0;
-                                        argv[argc++] = "include";
-                                        argv[argc] = NULL;
-                                    }
-
-                                    if ((cpNew = (char *)malloc(2 + strlen(option) + 1)) == NULL)
-                                        return OPTION_ERR_MEM;
-                                    cpNew[0]=NUL;
-                                    strcat(cpNew, "--");
-                                    strcat(cpNew, option);
-                                    if ((argv = (char **)realloc(argv, (argc + 1) * sizeof(char **))) == NULL)
-                                        return OPTION_ERR_MEM;
-                                    argv[argc++] = cpNew;
-                                    argv[argc] = NULL;
-
                                     if ((cpNew = strdup(value)) == NULL)
                                         return OPTION_ERR_MEM;
                                     if ((argv = (char **)realloc(argv, (argc + 1) * sizeof(char **))) == NULL)
@@ -541,7 +580,6 @@
             p = c;
         }
     }
-    
     return option_parse_internal(o, argc, argv);
 }
 

CVSTrac 2.0.1