OSSP CVS Repository

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

Check-in Number: 1787
Date: 2002-Feb-04 14:52:14 (local)
2002-Feb-04 13:52:14 (UTC)
User:thl
Branch:
Comment: application defaults now set through option_register()
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/fixme.h      1.8 -> 1.9     2 inserted, 0 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.36 -> 1.37     2 inserted, 0 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.31 -> 1.32     17 inserted, 13 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_option.c      1.8 -> 1.9     37 inserted, 35 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_option.h      1.3 -> 1.4     1 inserted, 1 deleted

ossp-pkg/lmtp2nntp/fixme.h 1.8 -> 1.9

--- fixme.h      2002/01/31 15:03:23     1.8
+++ fixme.h      2002/02/04 13:52:14     1.9
@@ -108,12 +108,14 @@
 #define ERR_DELIVERY -2
 
 enum {
+    GROUPMODE_UNDEF = 0,
     GROUPMODE_ARG,
     GROUPMODE_ENVELOPE,
     GROUPMODE_HEADER
 };
 
 enum {
+    OPERATIONMODE_UNDEF = 0,
     OPERATIONMODE_FAKE,
     OPERATIONMODE_POST,
     OPERATIONMODE_FEED


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.36 -> 1.37

--- lmtp2nntp_config.c   2002/01/31 15:59:12     1.36
+++ lmtp2nntp_config.c   2002/02/04 13:52:14     1.37
@@ -109,6 +109,8 @@
     //char *cp;
     int rc;
 
+    fprintf(stderr, "Hello, World!\n"); //FIXME
+
     /* create L2 environment */
     if (l2_env_create(&ctx->l2_env) != L2_OK) {
         fprintf(stderr, "%s:Error: failed to create L2 environment\n", ctx->progname);


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.31 -> 1.32

--- lmtp2nntp_main.c     2002/01/31 16:04:51     1.31
+++ lmtp2nntp_main.c     2002/02/04 13:52:15     1.32
@@ -334,26 +334,30 @@
         CU(ERR_EXECUTION);
     }
 
-    /* create application context */
+    /* create application context. fields are initialized to values that allow
+     * detection of dynamic allocated resources which must be freed up for
+     * graceful cleanup. These values are not necessarily useful application
+     * defaults. Those defaults must be configured in lmtp2nntp_option.c
+     * through option_register() calls */
     if ((ctx = (lmtp2nntp_t *)malloc(sizeof(lmtp2nntp_t))) == NULL)
         CU(ERR_EXECUTION);
     ctx->ctx.vp = ctx;
     ctx->val = NULL;
     ctx->progname = NULL;
-    ctx->option_childsmax = 10;
-    ctx->option_groupmode = GROUPMODE_ARG;
-    ctx->option_operationmode = OPERATIONMODE_FAKE;
-    ctx->option_operationmodefakestatus = "553";   /* Requested action not taken: mailbox name not allowed */
-    ctx->option_operationmodefakedsn    = "5.7.1"; /* Delivery not authorized, message refused */
-    ctx->option_maxmessagesize = 8 * 1024 * 1024;
+    ctx->option_childsmax = 0;
+    ctx->option_groupmode = GROUPMODE_UNDEF;
+    ctx->option_operationmode = OPERATIONMODE_UNDEF;
+    ctx->option_operationmodefakestatus = NULL;
+    ctx->option_operationmodefakedsn    = NULL;
+    ctx->option_maxmessagesize = 0;
     ctx->azHeaderValuePairs = NULL;
     ctx->asHeaderValuePairs = 0;
-    ctx->option_timeout_lmtp_accept = 0;
-    ctx->option_timeout_lmtp_read = 10;
-    ctx->option_timeout_lmtp_write = 10;
-    ctx->option_timeout_nntp_connect = 360;
-    ctx->option_timeout_nntp_read = 60;
-    ctx->option_timeout_nntp_write = 60;
+    ctx->option_timeout_lmtp_accept  = 0;
+    ctx->option_timeout_lmtp_read    = 0;
+    ctx->option_timeout_lmtp_write   = 0;
+    ctx->option_timeout_nntp_connect = 0;
+    ctx->option_timeout_nntp_read    = 0;
+    ctx->option_timeout_nntp_write   = 0;
     ctx->option_mailfrom = NULL;
     ctx->option_restrictheader = NULL;
     ctx->option_pidfile = NULL;


ossp-pkg/lmtp2nntp/lmtp2nntp_option.c 1.8 -> 1.9

--- lmtp2nntp_option.c   2002/01/31 15:53:43     1.8
+++ lmtp2nntp_option.c   2002/02/04 13:52:15     1.9
@@ -126,7 +126,7 @@
 }
 
 
-lmtp2nntp_option_rc_t option_register(lmtp2nntp_option_t *o, char *longname, char shortname, optiontype_t type, optionloop_cb_t *cb, char *cbctx, char *descrip, char *argdescrip)
+lmtp2nntp_option_rc_t option_register(lmtp2nntp_option_t *o, char *longname, char shortname, optiontype_t type, char *def, char *descrip, char *argdescrip, optionloop_cb_t *cb, char *cbctx)
 {
     lmtp2nntp_option_rc_t rc = VAL_OK;
     optionval_t *oc;
@@ -151,10 +151,12 @@
     oc->cbctx        = cbctx;
     oc->val          = o->vo;
     oc->number       = o->pi + 1; /* 0 is a reserved val in popt, so offset 1 */
-    oc->data.f       = 0;
-    oc->data.s       = NULL; /* just in case a pointer is larger than int */
-    oc->data.m       = NULL;
-    oc->ndata        = 0;
+    switch (type) {
+        case OPT_FLAG:   oc->data.f       = 0;    break;
+        case OPT_SINGLE: oc->data.s       = def;  break;
+        case OPT_MULTI:  oc->data.m       = NULL; break;
+    }
+    oc->ndata        = (type == OPT_SINGLE && def != NULL) ? 1 : 0;
     if (   (                      oc->longname   == NULL)
         || (descrip    != NULL && oc->descrip    == NULL)
         || (argdescrip != NULL && oc->argdescrip == NULL)
@@ -601,41 +603,41 @@
     if (o == NULL)
         return OPTION_ERR_ARG;
 
-    (void)option_register(o, "childsmax",          'C', OPT_SINGLE, &stdsyntax, "m/[0-9]+/", "foo01", "childsmax" );
-    (void)option_register(o, "daemonize",          'D', OPT_FLAG,   &stdsyntax, NULL,        "foo02", NULL );
-    (void)option_register(o, "kill",               'K', OPT_FLAG,   &stdsyntax, NULL,        "foo03", NULL );
-    (void)option_register(o, "pidfile",            'P', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo04", "pidfile" );
-    (void)option_register(o, "veryverbose",        'V', OPT_FLAG,   &stdsyntax, NULL,        "foo05", NULL );
-    (void)option_register(o, "acl",                'a', OPT_MULTI,  &stdsyntax, "m/.*/",     "foo06", "addr[/mask]" );
-    (void)option_register(o, "bind",               'b', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo07", "addr[:port]|-|path[:perms]" );
-    (void)option_register(o, "client",             'c', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo08", "addr[:port]" );
-    (void)option_register(o, "destination",        'd', OPT_MULTI,  &stdsyntax, "m/.*/",     "foo09", "addr[:port]" );
-    (void)option_register(o, "groupmode",          'g', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo10", "groupmode" );
-    (void)option_register(o, "headervalue",        'h', OPT_MULTI,  &stdsyntax, "m/.*/",     "foo11", "header: value" );
-    (void)option_register(o, "include",            'i', OPT_MULTI,  &includeit, "m/.*/",     "foo12", "configfile" );
-    (void)option_register(o, "size",               's', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo13", "bytes" );
-    (void)option_register(o, "timeoutlmtp",        NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo14", "sec" );
-    (void)option_register(o, "timeoutlmtpaccept",  NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "fo14a", "sec" );
-    (void)option_register(o, "timeoutlmtpread",    NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo15", "sec" );
-    (void)option_register(o, "timeoutlmtpwrite",   NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo16", "sec" );
-    (void)option_register(o, "timeoutnntp",        NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo17", "sec" );
-    (void)option_register(o, "timeoutnntpconnect", NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "fo17a", "sec" );
-    (void)option_register(o, "timeoutnntpread",    NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo18", "sec" );
-    (void)option_register(o, "timeoutnntpwrite",   NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo19", "sec" );
-    (void)option_register(o, "mailfrom",           'm', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo20", "regex" );
-    (void)option_register(o, "nodename",           'n', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo21", "nodename" );
-    (void)option_register(o, "operationmode",      'o', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo22", "post|feed" );
-    (void)option_register(o, "l2spec",             'l', OPT_SINGLE, &stdsyntax, "m/.*/",     "L2 channel tree textual specification", "l2spec" );
-    (void)option_register(o, "user",               'u', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo24", "uid|name" );
-    (void)option_register(o, "version",            'v', OPT_FLAG,   &stdsyntax, NULL,        "fo24a", NULL );
-    (void)option_register(o, "restrictheader",     'r', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo25", "regex" );
-    (void)option_register(o, "newsgroup",          NUL, OPT_MULTI,  &stdsyntax, "m/.*/",     "foo26", "newsgroup");
+    (void)option_register(o, "childsmax",          'C', OPT_SINGLE,  "10",        "childs to spawn at max",            "childsmax",                  &stdsyntax, "m/.*/" ); //"m/[0-9]+/" );
+    (void)option_register(o, "daemonize",          'D', OPT_FLAG,    NULL,        "detach from terminal",              NULL,                         &stdsyntax, NULL );
+    (void)option_register(o, "kill",               'K', OPT_FLAG,    NULL,        "kill a previously run daemon",      NULL,                         &stdsyntax, NULL );
+    (void)option_register(o, "pidfile",            'P', OPT_SINGLE,  NULL,        "file containing pid",               "pidfile",                    &stdsyntax, "m/.*/" );
+    (void)option_register(o, "veryverbose",        'V', OPT_FLAG,    NULL,        "FIXME",                             NULL,                         &stdsyntax, NULL );
+    (void)option_register(o, "acl",                'a', OPT_MULTI,   NULL,        "LMTP server access control list",   "addr[/mask]",                &stdsyntax, "m/.*/" );
+    (void)option_register(o, "bind",               'b', OPT_SINGLE,  NULL,        "LMTP server bind",                  "addr[:port]|-|path[:perms]", &stdsyntax, "m/.*/" );
+    (void)option_register(o, "client",             'c', OPT_SINGLE,  NULL,        "NNTP client bind",                  "addr[:port]",                &stdsyntax, "m/.*/" );
+    (void)option_register(o, "destination",        'd', OPT_MULTI,   NULL,        "NNTP client destination",           "addr[:port]",                &stdsyntax, "m/.*/" );
+    (void)option_register(o, "groupmode",          'g', OPT_SINGLE,  "arg",       "arg|envelope|header",               "groupmode",                  &stdsyntax, "m/.*/" ); //"m/(arg|envelope|header)/" );
+    (void)option_register(o, "headervalue",        'h', OPT_MULTI,   NULL,        "header/ value added to message",    "header: value",              &stdsyntax, "m/.*/" );
+    (void)option_register(o, "include",            'i', OPT_MULTI,   NULL,        "configfile to include",             "configfile",                 &includeit, "m/.*/" );
+    (void)option_register(o, "size",               's', OPT_SINGLE,  "8388608",   "maximum message size",              "bytes",                      &stdsyntax, "m/.*/" ); //"m/[0-9]+/" );
+    (void)option_register(o, "timeoutlmtp",        NUL, OPT_SINGLE,  NULL,        "LMTP server default timeout",       "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "timeoutlmtpaccept",  NUL, OPT_SINGLE,  "0",         "LMTP server accept timeout",        "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "timeoutlmtpread",    NUL, OPT_SINGLE,  "10",        "LMTP server read timeout",          "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "timeoutlmtpwrite",   NUL, OPT_SINGLE,  "10",        "LMTP server write timeout",         "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "timeoutnntp",        NUL, OPT_SINGLE,  NULL,        "NNTP client default timeout",       "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "timeoutnntpconnect", NUL, OPT_SINGLE,  "360",       "NNTP client connect timeout",       "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "timeoutnntpread",    NUL, OPT_SINGLE,  "60",        "NNTP client read timeout",          "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "timeoutnntpwrite",   NUL, OPT_SINGLE,  "60",        "NNTP client write timeout",         "sec",                        &stdsyntax, "m/.*/" );
+    (void)option_register(o, "mailfrom",           'm', OPT_SINGLE,  NULL,        "mail from envelope restriction",    "regex",                      &stdsyntax, "m/.*/" );
+    (void)option_register(o, "nodename",           'n', OPT_SINGLE,  NULL,        "nodename",                          "name",                       &stdsyntax, "m/.*/" );
+    (void)option_register(o, "operationmode",      'o', OPT_SINGLE,  "553/5.7.1", "fakestatus or operationmode",       "abc/a.d.e|post|feed",        &stdsyntax, "m/.*/" ); //"m/([0-9]{3}\\/[0-9]\\.[0-9]\\.[0-9]|post|feed)/" ); /* 553 = Requested action not taken: mailbox name not allowed, 5.7.1 =  Delivery not authorized, message refused */
+    (void)option_register(o, "l2spec",             'l', OPT_SINGLE,  NULL,        "L2 channel tree specification",     "l2spec",                     &stdsyntax, "m/.*/" );
+    (void)option_register(o, "user",               'u', OPT_SINGLE,  NULL,        "user",                              "uid|name",                   &stdsyntax, "m/.*/" );
+    (void)option_register(o, "version",            'v', OPT_FLAG,    NULL,        "print version",                     NULL,                         &stdsyntax, NULL );
+    (void)option_register(o, "restrictheader",     'r', OPT_SINGLE,  NULL,        "header restriction",                "regex",                      &stdsyntax, "m/.*/" );
+    (void)option_register(o, "newsgroup",          NUL, OPT_MULTI,   NULL,        "article destination",               "newsgroup",                  &stdsyntax, "m/.*/" );
 
 #if 0
     {
         int i;
 
-        for (i=0; i<26; i++) {
+        for (i=0; i<29; i++) {
             printf("DEBUG: o->pt[%3d].longName   = %s   \n", i,       o->pt[i].longName  );
             printf("DEBUG: o->pt[%3d].shortName  = %c   \n", i,       o->pt[i].shortName );
             printf("DEBUG: o->pt[%3d].argInfo    = %d   \n", i,       o->pt[i].argInfo   );


ossp-pkg/lmtp2nntp/lmtp2nntp_option.h 1.3 -> 1.4

--- lmtp2nntp_option.h   2002/01/30 16:41:02     1.3
+++ lmtp2nntp_option.h   2002/02/04 13:52:15     1.4
@@ -105,6 +105,6 @@
 };
 
 lmtp2nntp_option_rc_t option_create  (lmtp2nntp_option_t **, val_t *);
-lmtp2nntp_option_rc_t option_register(lmtp2nntp_option_t *, char *, char, optiontype_t, optionloop_cb_t *, char *, char *, char *);
+lmtp2nntp_option_rc_t option_register(lmtp2nntp_option_t *, char *, char, optiontype_t, char *, char *, char *, optionloop_cb_t *, char *);
 lmtp2nntp_option_rc_t option_parse   (lmtp2nntp_option_t *, int, char **);
 lmtp2nntp_option_rc_t option_destroy (lmtp2nntp_option_t *);

CVSTrac 2.0.1