OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp2nntp_option.c 1.1 -> 1.2

--- lmtp2nntp_option.c   2002/01/24 12:04:46     1.1
+++ lmtp2nntp_option.c   2002/01/24 16:25:54     1.2
@@ -79,39 +79,15 @@
     exit(-1);
 }
 
-struct optionconfig_s {
-    optionconfig_t *next;               /* cleanup chain for destroy */
-    lmtp2nntp_option_t *parent;         /* include needs access to parent */
-                    /**/
-    char               *longname;       /* the long name (optional if shortname given) */
-    char                shortname;      /* the short name (optional if longname given) */
-    char               *descrip;        /* description for autohelp */
-    char               *argdescrip;     /* argument description for autohelp */
-    optiontype_t        type;           /* OPT_FLAG, OPT_SINGLE, OPT_MULTI */
-    optionloop_cb_t    *cb;             /* callback for first iteration - syntax check and include */
-    void               *cbctx;          /* context for pass1 */
-    val_t              *val;            /* val we are registered under */
-                    /**/
-    int                 number;         /* number of this option for popt */
-    struct {                             /* option data as read from configuration */
-        int f;                          /* OPT_FLAG */
-        void *foo1, *foo2, *foo3, *foo4, *foo5, *foo6, *foo7, *foo8, *foo9; 
-        char *s;                        /* OPT_SINGLE */
-        void *bar1, *bar2, *bar3, *bar4, *bar5, *bar6, *bar7, *bar8, *bar9; 
-        char **m;                       /* OPT_MULTI */
-    } data;
-    int ndata;
-};
-
 static val_rc_t dumper(void *ctx, const char *name, int type, const char *desc, void *data)
 {
-    optionconfig_t *oc;
+    optionval_t *oc;
     int i;
 
     if (type != VAL_TYPE_PTR)
         return VAL_OK;
 
-    oc = (optionconfig_t *)data;
+    oc = *(optionval_t **)data;
 
     switch (oc->type) {
         case OPT_FLAG:
@@ -140,8 +116,8 @@
     }
     return VAL_OK;
 }
-//lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionconfig_t **ocp);
-static lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionconfig_t **ocp)
+//lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionval_t **ocp);
+static lmtp2nntp_option_rc_t option_find(lmtp2nntp_option_t *o, int number, optionval_t **ocp)
 {
     lmtp2nntp_option_rc_t rc = VAL_OK;
 
@@ -159,17 +135,17 @@
 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 rc = VAL_OK;
-    optionconfig_t *oc;
+    optionval_t *oc;
     
     //printf("DEBUG: enter option_register(%.8lx, \"%s\", '%c', %d, %.8lx, %.8lx, \"%s\", \"%s\")\n", (long)o, longname, shortname, type, (long)cb, (long)cbctx, descrip, argdescrip);
 
     if (o == NULL || longname == NULL)
         return OPTION_ERR_ARG;
 
-    /* create a optionconfig_t structure */
-    if ((oc = (optionconfig_t *)malloc(sizeof(optionconfig_t))) == NULL)
+    /* create a optionval_t structure */
+    if ((oc = (optionval_t *)malloc(sizeof(optionval_t))) == NULL)
         return OPTION_ERR_MEM;
-    //printf("DEBUG: optionconfig_t structure malloc'ed\n");
+    //printf("DEBUG: optionval_t structure malloc'ed\n");
     oc->next         = NULL;
     oc->parent       = o;
     oc->longname     = strdup(longname);
@@ -191,14 +167,27 @@
           )
         CU(OPTION_ERR_MEM);
 
-    //printf("DEBUG: optionconfig_t structure created\n");
+    //printf("DEBUG: optionval_t structure created, oc at %.8lx is %.8lx\n", (long)&oc, (long)oc);
 
     /* feed lib_val */
-    if (val_reg(oc->val, oc->longname, VAL_TYPE_PTR, oc->descrip, oc) != VAL_OK)
+    if (val_reg(oc->val, oc->longname, VAL_TYPE_PTR, oc->descrip, NULL) != VAL_OK)
+        CU(OPTION_ERR_USE);
+    if (val_set(oc->val, oc->longname, oc) != VAL_OK)
         CU(OPTION_ERR_USE);
-
     //printf("DEBUG: val_reg'ed\n");
 
+#if 0
+    {
+        optionval_t *ov = 0x12345678;
+
+        if (val_get(oc->val, oc->longname, &ov) == VAL_OK)
+            printf("DEBUG: oc->val %.8lx %s in %.8lx d = \"s\"\n", (long)oc->val, oc->longname, (long)(oc));
+        if (val_get(o->vo,   oc->longname, &ov) == VAL_OK)
+            printf("DEBUG: o->vo   %.8lx %s in %.8lx d = \"s\"\n", (long)o->vo,   oc->longname, (long)(ov));
+        printf("DEBUG: val_get'ed\n");
+    }
+#endif
+
     /* feed lib_popt */
     //printf("DEBUG: o->pi=%d, o->pn=%d\n", o->pi, o->pn);
     if (o->pi >= (o->pn-2)) { /* correction by two here, in malloc and realloc is for AUTOHELP and TABLEEND */
@@ -243,7 +232,7 @@
     o->pi++;
     //printf("DEBUG: popt'ed\n");
 
-    /* link in this new optionconfig_t structure */
+    /* link in this new optionval_t structure */
     if (o->first == NULL) {
         o->first = oc;
         o->last  = oc;
@@ -329,7 +318,7 @@
 {
     int i;
     char *cp;
-    optionconfig_t *ocp;
+    optionval_t *ocp;
     popt_context poptCon;   /* context for parsing command-line options */
 
 #if 0
@@ -394,9 +383,9 @@
     return OPTION_OK;
 }
 
-static lmtp2nntp_option_rc_t stdsyntax(optionconfig_t *oc, char *arg, char *cbctx)
+static lmtp2nntp_option_rc_t stdsyntax(optionval_t *oc, char *arg, char *cbctx)
 {
-    printf("DEBUG: enter stdsyntax %.8lx, \"%s\", \"%s\"\n", (long)oc, arg, cbctx);
+    //printf("DEBUG: enter stdsyntax %.8lx, \"%s\", \"%s\"\n", (long)oc, arg, cbctx);
 
     //printf("DEBUG: oc->type=%d\n", oc->type);
     switch (oc->type) {
@@ -474,7 +463,7 @@
     return OPTION_OK;
 }
 
-static lmtp2nntp_option_rc_t includeit(optionconfig_t *oc, char *arg, char *cbctx)
+static lmtp2nntp_option_rc_t includeit(optionval_t *oc, char *arg, char *cbctx)
 {
     lmtp2nntp_option_t *o;
     char *cpBuf = NULL;
@@ -610,32 +599,32 @@
     if (o == NULL)
         return OPTION_ERR_ARG;
 
-    (void)option_register(o, "childsmax",          'C', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "childsmax" );
-    (void)option_register(o, "daemonize",          'D', OPT_FLAG,   &stdsyntax, NULL,    "foo", NULL );
-    (void)option_register(o, "kill",               'K', OPT_FLAG,   &stdsyntax, NULL,    "foo", NULL );
-    (void)option_register(o, "pidfile",            'P', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "pidfile" );
-    (void)option_register(o, "veryverbose",        'V', OPT_FLAG,   &stdsyntax, NULL,    "foo", NULL );
-    (void)option_register(o, "acl",                'a', OPT_MULTI,  &stdsyntax, "m/.*/", "foo", "addr[/mask]" );
-    (void)option_register(o, "bind",               'b', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "addr[:port]|-|path[:perms]" );
-    (void)option_register(o, "client",             'c', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "addr[:port]" );
-    (void)option_register(o, "destination",        'd', OPT_MULTI,  &stdsyntax, "m/.*/", "foo", "addr[:port]" );
-    (void)option_register(o, "groupmode",          'g', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "groupmode" );
-    (void)option_register(o, "headervalue",        'h', OPT_MULTI,  &stdsyntax, "m/.*/", "foo", "header: value" );
-    (void)option_register(o, "include",            'i', OPT_MULTI,  &includeit, "m/.*/", "foo", "configfile" );
-    (void)option_register(o, "size",               's', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "bytes" );
-    (void)option_register(o, "timeoutlmtpaccept",  NUL, OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "sec" );
-    (void)option_register(o, "timeoutlmtpread",    NUL, OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "sec" );
-    (void)option_register(o, "timeoutlmtpwrite",   NUL, OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "sec" );
-    (void)option_register(o, "timeoutnntpconnect", NUL, OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "sec" );
-    (void)option_register(o, "timeoutnntpread",    NUL, OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "sec" );
-    (void)option_register(o, "timeoutnntpwrite",   NUL, OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "sec" );
-    (void)option_register(o, "mailfrom",           'm', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "regex" );
-    (void)option_register(o, "nodename",           'n', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "nodename" );
-    (void)option_register(o, "operationmode",      'o', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "post|feed" );
-    (void)option_register(o, "l2spec",             'l', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "spec" );
-    (void)option_register(o, "uid",                'u', OPT_SINGLE, &stdsyntax, "m/.*/", "foo", "number|name" );
-    (void)option_register(o, "restrictheader",     'r', OPT_MULTI,  &stdsyntax, "m/.*/", "foo", "regex" );
-    (void)option_register(o, "newsgroup",          NUL, OPT_MULTI,  &stdsyntax, "m/.*/", "foo", "newsgroup");
+    (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, "timeoutlmtpaccept",  NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo14", "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, "timeoutnntpconnect", NUL, OPT_SINGLE, &stdsyntax, "m/.*/",     "foo17", "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/.*/",     "foo23", "spec" );
+    (void)option_register(o, "uid",                'u', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo24", "number|name" );
+    (void)option_register(o, "restrictheader",     'r', OPT_MULTI,  &stdsyntax, "m/.*/",     "foo25", "regex" );
+    (void)option_register(o, "newsgroup",          NUL, OPT_MULTI,  &stdsyntax, "m/.*/",     "foo26", "newsgroup");
 
 #if 0
     {
@@ -653,15 +642,15 @@
     }
 #endif
 
-    //val_apply(o->vo, "", 9, dumper, "all" );
+    //val_apply(o->vo, "", 9, dumper, "vorher" );
     rc = option_parse_internal(o, argc, argv);
-    val_apply(o->vo, "", 9, dumper, "all" );
+    //val_apply(o->vo, "", 9, dumper, "nachher" );
     return rc;
 }
 
 lmtp2nntp_option_rc_t option_destroy(lmtp2nntp_option_t *o)
 {
-    optionconfig_t *oc;
+    optionval_t *oc;
     int i;
 
     //printf("DEBUG: option_destroy %.8lx\n", (long)o);

CVSTrac 2.0.1