OSSP CVS Repository

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

Check-in Number: 1547
Date: 2002-Jan-14 13:23:21 (local)
2002-Jan-14 12:23:21 (UTC)
User:thl
Branch:
Comment: first steps toward popt
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/example.conf      1.3 -> 1.4     2 inserted, 2 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.2 -> 1.3     78 inserted, 61 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.h      1.1 -> 1.2     31 inserted, 1 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.4 -> 1.5     3 inserted, 5 deleted

ossp-pkg/lmtp2nntp/example.conf 1.3 -> 1.4

--- example.conf 2002/01/10 10:37:38     1.3
+++ example.conf 2002/01/14 12:23:21     1.4
@@ -41,9 +41,9 @@
 
                                                     #    -l is obsolete since v1.2, see l2spec
                                                     #    -V is obsolete since v1.2; remove the "buffer" channel from l2spec
-    l2spec          "prefix(prefix="%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: ",timezone=local) \
+    l2spec          'prefix(prefix="%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: ",timezone=local) \
                        -> buffer(size=65536) \
-                       -> file(path=%s,append=1,perm=%d)" \
+                       -> file(path=%s,append=1,perm=%d)' \
                                                     #    -l aka --l2spec
 
     uid             gate                            #see -u aka --uid


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


ossp-pkg/lmtp2nntp/lmtp2nntp_config.h 1.1 -> 1.2

--- lmtp2nntp_config.h   2002/01/09 13:54:25     1.1
+++ lmtp2nntp_config.h   2002/01/14 12:23:21     1.2
@@ -24,5 +24,35 @@
 **  lmtp2nntp.c: LMTP to NNTP configuration parsing
 */
 
-void dotconftest(void);
+#include "lmtp2nntp_global.h"
+void dotconftest(int, char **); //FIXME
+
+typedef struct {
+    int             option_childsmax;
+
+    char           *option_logfile;
+    int             option_groupmode;
+    int             option_operationmode;
+    char           *option_operationmodefakestatus;
+    char           *option_operationmodefakedsn;
+    int             option_maxmessagesize;
+    char           *option_azHeaderValuePairs;
+    size_t          option_asHeaderValuePairs;
+    int             option_timeout_lmtp_accept;
+    int             option_timeout_lmtp_read;
+    int             option_timeout_lmtp_write;
+    int             option_timeout_nntp_connect;
+    int             option_timeout_nntp_read;
+    int             option_timeout_nntp_write;
+    char           *option_mailfrom;
+    char           *option_restrictheader;
+    unsigned int    option_levelmask;
+    char           *option_pidfile;
+    int             option_killflag;
+    uid_t           option_uid;
+    int             option_daemon;
+    int             option_aclc;
+    //struct acl      option_acl[MAXACLS];
+    int             option_veryverbose;
+} lmtp2nntp_config_t;
 


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.4 -> 1.5

--- lmtp2nntp_main.c     2002/01/09 13:54:25     1.4
+++ lmtp2nntp_main.c     2002/01/14 12:23:21     1.5
@@ -43,7 +43,6 @@
 #include "lmtp2nntp_shpat.h"
 #include "lmtp2nntp_daemon.h"
 #include "lmtp2nntp_popt.h"
-#include "lmtp2nntp_config.h"
 
 /* third party (linked in) */
 #include "str.h"
@@ -74,6 +73,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"
@@ -207,7 +207,6 @@
     lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx;
     const char *name;
     size_t len;
-    size_t n;
     char *cp;
     var_rc_t rc;
 
@@ -484,8 +483,6 @@
     char         *cpHeadername;
     char         *cpHeadervalue;
 
-dotconftest(); return 0; /*FIXME*/
-
     /* drop effective uid/gid priviledges */
     seteuid(getuid());
     setegid(getgid());
@@ -505,6 +502,7 @@
         CU(ERR_EXECUTION);
     ctx->ctx.vp = ctx;
     ctx->progname = strdup(argv[0]);
+    ctx->option_childsmax = 10;
     ctx->option_logfile = NULL;
     ctx->option_groupmode = GROUPMODE_ARG;
     ctx->option_operationmode = OPERATIONMODE_FAKE;
@@ -527,7 +525,6 @@
     ctx->option_uid = getuid();
     ctx->option_daemon = FALSE;
     ctx->option_veryverbose = FALSE;
-    ctx->option_childsmax = 10;
     ctx->active_childs = 0;
     ctx->l2_env = NULL;
     ctx->l2 = NULL;
@@ -562,6 +559,7 @@
         fprintf(stderr, "%s:Error: uname failed \"%s\"\n", ctx->progname, strerror(errno));
         CU(ERR_EXECUTION);
     }
+dotconftest(argc, argv); return 0; //FIXME
 
     /*POD B<lmtp2nntp> */
 

CVSTrac 2.0.1