Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v rcsdiff -q -kk '-r1.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null --- lmtp2nntp_config.c 2002/01/24 12:04:46 1.15 +++ lmtp2nntp_config.c 2002/01/24 16:25:54 1.16 @@ -77,5 +77,18 @@ void config_context(lmtp2nntp_t *ctx) { + optionval_t *ov; + char *cp; + + printf("DEBUG: Hello, World!\n"); + //case 'C': /*POD [B<-C> I] */ + if (val_get(ctx->val, "option.childsmax", &ov) != VAL_OK) + fprintf(stderr, "%s:Error: (internal) config did not register 'childsmax' option\n", ctx->progname); + printf("DEBUG: option_childsmax %d = \"%s\"\n", ov->ndata, ov->data.s); + ctx->option_childsmax = atoi(ov->data.s); + if (ctx->option_childsmax <= 0) { + fprintf(stderr, "%s:Error: Invalid number (%d) to option -C\n", ctx->progname, ctx->option_childsmax); + return; //FIXME CU(ERR_EXECUTION); + } return; } Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.h,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.h,v' 2>/dev/null --- lmtp2nntp_config.h 2002/01/24 12:04:46 1.6 +++ lmtp2nntp_config.h 2002/01/24 16:25:54 1.7 @@ -26,6 +26,4 @@ #include "lmtp2nntp_global.h" #include "fixme.h" -//#include "val.h" -//void config_context(lmtp2nntp_t *); void config_context(lmtp2nntp_t *); Index: ossp-pkg/lmtp2nntp/lmtp2nntp_main.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v rcsdiff -q -kk '-r1.8' '-r1.9' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v' 2>/dev/null --- lmtp2nntp_main.c 2002/01/24 12:07:13 1.8 +++ lmtp2nntp_main.c 2002/01/24 16:25:54 1.9 @@ -513,13 +513,6 @@ /* read in the arguments */ while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:h:l:m:n:o:r:s:t:u:v")) != -1) { switch (i) { - case 'C': /*POD [B<-C> I] */ - ctx->option_childsmax = atoi(optarg); - if (ctx->option_childsmax <= 0) { - fprintf(stderr, "%s:Error: Invalid number (%d) to option -C\n", ctx->progname, ctx->option_childsmax); - CU(ERR_EXECUTION); - } - break; case 'D': /*POD [B<-D>] */ ctx->option_daemon = TRUE; break; Index: ossp-pkg/lmtp2nntp/lmtp2nntp_option.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_option.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_option.c,v' 2>/dev/null --- 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); Index: ossp-pkg/lmtp2nntp/lmtp2nntp_option.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_option.h,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_option.h,v' 2>/dev/null --- lmtp2nntp_option.h 2002/01/24 12:04:46 1.1 +++ lmtp2nntp_option.h 2002/01/24 16:25:54 1.2 @@ -27,8 +27,8 @@ #include "lmtp2nntp_global.h" #include "val.h" -struct optionconfig_s; -typedef struct optionconfig_s optionconfig_t; +struct optionval_s; +typedef struct optionval_s optionval_t; typedef struct { int childsmax; @@ -57,8 +57,8 @@ argz_t restrictheader; argz_t newsgroup; /*FIXME above*/ - optionconfig_t *first; - optionconfig_t *last; + optionval_t *first; + optionval_t *last; val_t *vo; /* val_t for all options */ int pi; /* popt index to next record */ int pn; /* popt number of available records */ @@ -67,6 +67,12 @@ } lmtp2nntp_option_t; typedef enum { + OPT_FLAG, + OPT_SINGLE, + OPT_MULTI +} optiontype_t; + +typedef enum { OPTION_OK, OPTION_ERR_ARG, /* invalid args passed into function */ OPTION_ERR_USE, /* invalid usage, bad data passed into function */ @@ -74,13 +80,32 @@ OPTION_ERR_VAL /* libval failed */ } lmtp2nntp_option_rc_t; -typedef enum { - OPT_FLAG, - OPT_SINGLE, - OPT_MULTI -} optiontype_t; +typedef lmtp2nntp_option_rc_t (optionloop_cb_t)(optionval_t *oc, char *arg, char *cbctx); + +struct optionval_s { + optionval_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; +}; -typedef lmtp2nntp_option_rc_t (optionloop_cb_t)(optionconfig_t *oc, char *arg, char *cbctx); 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_parse (lmtp2nntp_option_t *, int, char **);