OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.2 -> 1.3

--- lmtp2nntp_config.c   2002/01/10 10:37:38     1.2
+++ lmtp2nntp_config.c   2002/01/14 12:23:21     1.3
@@ -43,7 +43,7 @@
 // #include "lmtp2nntp_argz.h"
 // #include "lmtp2nntp_shpat.h"
 // #include "lmtp2nntp_daemon.h"
-// #include "lmtp2nntp_popt.h"
+#include "lmtp2nntp_popt.h"
 
 /* third party (linked in) */
 #include "str.h"
@@ -74,6 +74,7 @@
 #if defined(HAVE_DMALLOC_H) && defined(DMALLOC)
 #include "dmalloc.h"
 #endif
+#include "lmtp2nntp_config.h"
 #include "lmtp2nntp_lmtp.h"
 #include "lmtp2nntp_nntp.h"
 #include "lmtp2nntp_msg.h"
@@ -100,51 +101,66 @@
             exit(-1);
 }
 
-void dotconftest(void)
+void dotconftest(int argc, char **argv) /*FIXME*/
 {
-#if 0
-    static const configoption_t options[] = {
-        { "<daemon>",       ARG_NONE, foo, NULL, CTX_ALL     },
-        { "childsmax",      ARG_STR,  foo, NULL, CTX_DAEMON  },
-        { "daemonize",      ARG_STR,  foo, NULL, CTX_DAEMON  },
-        { "pidfile",        ARG_STR,  foo, NULL, CTX_DAEMON  },
-        { "acl",            ARG_STR,  foo, NULL, CTX_DAEMON  },
-        { "bind",           ARG_STR,  foo, NULL, CTX_DAEMON  },
-        { "</daemon>",      ARG_NONE, foo, NULL, CTX_DAEMON  },
-        { "<server>",       ARG_NONE, foo, NULL, CTX_ALL     },
-        { "timeoutaccept",  ARG_STR,  foo, NULL, CTX_SERVER  },
-        { "timeoutread",    ARG_STR,  foo, NULL, CTX_SERVER  },
-        { "timeoutwrite",   ARG_STR,  foo, NULL, CTX_SERVER  },
-        { "size",           ARG_STR,  foo, NULL, CTX_SERVER  },
-        { "mailfrom",       ARG_STR,  foo, NULL, CTX_SERVER  },
-        { "nodename",       ARG_STR,  foo, NULL, CTX_SERVER  },
-        { "</server>",      ARG_NONE, foo, NULL, CTX_SERVER  },
-        { "<client>",       ARG_NONE, foo, NULL, CTX_ALL     },
-        { "client",         ARG_STR,  foo, NULL, CTX_CLIENT  },
-        { "destination",    ARG_STR,  foo, NULL, CTX_CLIENT  },
-        { "operationmode",  ARG_STR,  foo, NULL, CTX_CLIENT  },
-        { "timeoutconnect", ARG_STR,  foo, NULL, CTX_CLIENT  },
-        { "timeoutread",    ARG_STR,  foo, NULL, CTX_CLIENT  },
-        { "timeoutwrite",   ARG_STR,  foo, NULL, CTX_CLIENT  },
-        { "</client>",      ARG_NONE, foo, NULL, CTX_CLIENT  },
-        { "<gateway>",      ARG_NONE, foo, NULL, CTX_ALL     },
-        { "groupmode",      ARG_STR,  foo, NULL, CTX_GATEWAY },
-        { "l2spec",         ARG_STR,  foo, NULL, CTX_GATEWAY },
-        { "uid",            ARG_STR,  foo, NULL, CTX_GATEWAY },
-        { "newsgroup",      ARG_STR,  foo, NULL, CTX_GATEWAY },
-        { "</gateway>",     ARG_NONE, foo, NULL, CTX_GATEWAY },
-        { "<message>",      ARG_NONE, foo, NULL, CTX_ALL     },
-        { "headervalue",    ARG_STR,  foo, NULL, CTX_MESSAGE },
-        { "restrictheader", ARG_STR,  foo, NULL, CTX_MESSAGE },
-        { "</message>",     ARG_NONE, foo, NULL, CTX_MESSAGE },
-        LAST_OPTION
+    popt_context poptCon;   /* context for parsing command-line options */
+    lmtp2nntp_config_t *ctx;
+    char *cpBuf;
+    struct popt_option poptTable[] = {
+        { "childsmax",      'C', POPT_ARG_STRING, NULL, 'C', "foo", "childsmax" },
+        { "daemonize",      'D', POPT_ARG_NONE,   NULL, 'D', "foo", NULL },
+        { "kill",           'K', POPT_ARG_NONE,   NULL, 'K', "foo", NULL },
+        { "pidfile",        'P', POPT_ARG_STRING, NULL, 'P', "foo", "pidfile" },
+        { "veryverbose",    'V', POPT_ARG_NONE,   NULL, 'V', "foo", NULL },
+        { "acl",            'a', POPT_ARG_STRING, NULL, 'a', "foo", "addr[/mask]" },
+        { "bind",           'b', POPT_ARG_STRING, NULL, 'b', "foo", "addr[:port]|-|path[:perms]" },
+        { "client",         'c', POPT_ARG_STRING, NULL, 'c', "foo", "addr[:port]" },
+        { "destination",    'd', POPT_ARG_STRING, NULL, 'd', "foo", "addr[:port]" },
+        { "groupmode",      'g', POPT_ARG_STRING, NULL, 'g', "foo", "groupmode" },
+        { "headervalue",    'h', POPT_ARG_STRING, NULL, 'h', "foo", "header: value" },
+        { "include",        'i', POPT_ARG_STRING, NULL, 'i', "foo", "configfile" },
+        { "size",           's', POPT_ARG_STRING, NULL, 's', "foo", "bytes" },
+        { "timeout",        't', POPT_ARG_STRING, NULL, 't', "foo", "name=sec" },
+        { "mailfrom",       'm', POPT_ARG_STRING, NULL, 'm', "foo", "regex" },
+        { "nodename",       'n', POPT_ARG_STRING, NULL, 'n', "foo", "nodename" },
+        { "operationmode",  'o', POPT_ARG_STRING, NULL, 'o', "foo", "post|feed" },
+        { "l2spec",         'l', POPT_ARG_STRING, NULL, 'l', "foo", "spec" },
+        { "uid",            'u', POPT_ARG_STRING, NULL, 'u', "foo", "number|name" },
+        { "restrictheader", 'r', POPT_ARG_STRING, NULL, 'r', "foo", "regex" },
+        { "newsgroup",      NUL, POPT_ARG_STRING
+                        |POPT_ARGFLAG_DOC_HIDDEN, NULL, 1,   NULL,  NULL },
+        POPT_AUTOHELP
+        { NULL,               0, 0,               NULL, 0 }
     };
-#endif
+ 
+    ctx = malloc(sizeof(lmtp2nntp_config_t));
+    ctx->option_childsmax = 10;
 
-    const char *filename = "example.conf";
-    char *cpBuf;
+    {
+        char c;
+        char *cp;
+
+        poptCon = popt_getcontext(NULL, argc, (const char **)argv, poptTable, 0);
+        popt_setotheroptionhelp(poptCon, "[OPTIONS]* [newsgroup ...]");
+        printf("DEBUG: argc=%d\n", argc);
+        if (argc < 2) {
+            popt_printusage(poptCon, stderr, 0);
+            exit(1);
+        }
+        while ((c = popt_getnextopt(poptCon)) >= 0) {
+            printf("DEBUG: popt_getnextopt returned %d='%c'\n", (int)c, c);
+        }
+        while ((cp = popt_getarg(poptCon)) != NULL) {
+            printf("DEBUG: popt_getarg returned \"%s\"\n", cp);
+        }
+
+        printf("DEBUG: popt_getnextopt ended with \"%s\"(%d)\n", popt_strerror((int)c), (int)c);
+        popt_freecontext(poptCon);
+        return;
+    }
 
     {
+        const char *filename = "example.conf";
         struct stat sb;
         int fd;
 
@@ -163,23 +179,22 @@
     //FIXME printf("DEBUG: *** 1 *** file as it was just read in ***\n%s***\n", cpBuf);
 
     {
-        char *cpI; /* pointer to next character to be read */
-        char *cpO; /* pointer to next character to be written when eliminating backslash+newline at a line continuation */
-        char *cpL; /* pointer to start of line */
-        int pline; /* current physical (disregarding line continuation) line number */
-        int lline; /* current logical lines first physical line number */
-        int eline; /* flag signaling empty or just whitespace-filled line */
-        char c; /* current character */
-        char p; /* previous character */
-        int eof; /* flag signaling end of file detected */
+        char *cpI;  /* pointer to next character to be read */
+        char *cpO;  /* pointer to next character to be written. Used for eliminating
+                       backslash+newline at a line continuation */
+        char *cpL;  /* pointer to start of line */
+        int pline;  /* current physical (disregarding line continuation) line number */
+        int lline;  /* current logical lines first physical line number */
+        int eline;  /* flag signaling empty or just whitespace-filled line */
+        char c;     /* current character */
+        char p;     /* previous character */
+        int eof;    /* flag signaling end of file detected */
 
         cpI = cpBuf;
         cpO = cpBuf;
         eof = FALSE;
         pline = 1;
-        p = NUL; /* prefill previous character with fake value to avoid false
-        line continuation detection when a newline is seen as the first
-        character in the buffer */
+        p = NUL;
 
         cpL = cpO;
         lline = pline;
@@ -201,22 +216,24 @@
                     if (!eline) { /* process logical line unless it's empty */
                         *(cpO-1) = NUL;
                         if (lline == (pline-1))
-                            printf("DEBUG: line[%3d] = ***%s***\n", lline, cpL);
+                            ;//printf("DEBUG: line[%3d] = ***%s***\n", lline, cpL);
                         else
-                            printf("DEBUG: [%3d-%3d] = ***%s***\n", lline, pline-1, cpL);
+                            ;//printf("DEBUG: [%3d-%3d] = ***%s***\n", lline, pline-1, cpL);
                         {
                             char *cp = cpL;
-                            char *token;
+                            char *command;
                             char *value;
 
-                            if ((token = str_token(&cp, " ", "\"'", "#", STR_STRIPQUOTES|STR_BACKSLASHESC)) == NULL)
-                                printf("DEBUG: no token - comment only\n");
+                            if ((command = str_token(&cp, " \t", "\"'", "#", STR_STRIPQUOTES|STR_BACKSLASHESC)) == NULL)
+                                ;//printf("DEBUG: no command - comment only\n");
                             else {
-                                printf("DEBUG:     token = ***%s***\n", token);
-                                if ((value = str_token(&cp, "", "\"'", "#", STR_STRIPQUOTES|STR_BACKSLASHESC)) == NULL)
+                                printf("DEBUG:   command = ***%s***\n", command);
+                                if ((value = str_token(&cp, " \t", "\"'", "#", STR_STRIPQUOTES|STR_BACKSLASHESC)) == NULL)
                                     printf("DEBUG: no value - section\n");
-                                else
+                                else {
+                                    ;//while(isspace((int)*value)) value++;
                                     printf("DEBUG:     value = ***%s***\n", value);
+                                }
                             }
                         }
                     }

CVSTrac 2.0.1