Index: ossp-pkg/lmtp2nntp/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Makefile.in,v rcsdiff -q -kk '-r1.39' '-r1.40' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Makefile.in,v' 2>/dev/null --- Makefile.in 2002/01/16 14:22:14 1.39 +++ Makefile.in 2002/01/17 17:01:55 1.40 @@ -44,9 +44,9 @@ POD2MAN = pod2man PROG = lmtp2nntp -HDRS = lmtp2nntp_global.h lmtp2nntp_daemon.h lmtp2nntp_lmtp.h lmtp2nntp_nntp.h lmtp2nntp_argz.h lmtp2nntp_shpat.h lmtp2nntp_msg.h lmtp2nntp_popt.h lmtp2nntp_config.h lmtp2nntp_lh.h -SRCS = lmtp2nntp_main.c lmtp2nntp_daemon.c lmtp2nntp_lmtp.c lmtp2nntp_nntp.c lmtp2nntp_argz.c lmtp2nntp_shpat.c lmtp2nntp_msg.c lmtp2nntp_popt.c lmtp2nntp_config.c lmtp2nntp_lh.c lmtp2nntp_version.c -OBJS = lmtp2nntp_main.o lmtp2nntp_daemon.o lmtp2nntp_lmtp.o lmtp2nntp_nntp.o lmtp2nntp_argz.o lmtp2nntp_shpat.o lmtp2nntp_msg.o lmtp2nntp_popt.o lmtp2nntp_config.o lmtp2nntp_lh.o lmtp2nntp_version.o +HDRS = lmtp2nntp_global.h lmtp2nntp_daemon.h lmtp2nntp_lmtp.h lmtp2nntp_nntp.h lmtp2nntp_argz.h lmtp2nntp_shpat.h lmtp2nntp_msg.h lmtp2nntp_popt.h lmtp2nntp_config.h +SRCS = lmtp2nntp_main.c lmtp2nntp_daemon.c lmtp2nntp_lmtp.c lmtp2nntp_nntp.c lmtp2nntp_argz.c lmtp2nntp_shpat.c lmtp2nntp_msg.c lmtp2nntp_popt.c lmtp2nntp_config.c lmtp2nntp_version.c +OBJS = lmtp2nntp_main.o lmtp2nntp_daemon.o lmtp2nntp_lmtp.o lmtp2nntp_nntp.o lmtp2nntp_argz.o lmtp2nntp_shpat.o lmtp2nntp_msg.o lmtp2nntp_popt.o lmtp2nntp_config.o lmtp2nntp_version.o SUBDIRS = @SUBDIR_STR@ @SUBDIR_L2@ @SUBDIR_SA@ @SUBDIR_VAR@ @SUBDIR_VAL@ @@ -128,3 +128,12 @@ $(OBJS): Makefile # AUTOMATICALLY GENERATED DEPENDENCY LIST - DO NOT EDIT +lmtp2nntp_main.o: lmtp2nntp_main.c lmtp2nntp_argz.h lmtp2nntp_shpat.h lmtp2nntp_daemon.h lmtp2nntp_popt.h lmtp2nntp_global.h config.h lmtp2nntp_config.h lmtp2nntp_lmtp.h lmtp2nntp_nntp.h lmtp2nntp_msg.h lmtp2nntp_version.c +lmtp2nntp_daemon.o: lmtp2nntp_daemon.c config.h lmtp2nntp_daemon.h +lmtp2nntp_lmtp.o: lmtp2nntp_lmtp.c lmtp2nntp_lmtp.h config.h +lmtp2nntp_nntp.o: lmtp2nntp_nntp.c lmtp2nntp_nntp.h lmtp2nntp_msg.h lmtp2nntp_global.h config.h +lmtp2nntp_argz.o: lmtp2nntp_argz.c lmtp2nntp_argz.h config.h +lmtp2nntp_shpat.o: lmtp2nntp_shpat.c config.h lmtp2nntp_shpat.h +lmtp2nntp_msg.o: lmtp2nntp_msg.c lmtp2nntp_msg.h lmtp2nntp_global.h config.h lmtp2nntp_argz.h lmtp2nntp_popt.o: lmtp2nntp_popt.c config.h lmtp2nntp_popt.h +lmtp2nntp_config.o: lmtp2nntp_config.c lmtp2nntp_popt.h lmtp2nntp_global.h config.h lmtp2nntp_config.h lmtp2nntp_lmtp.h lmtp2nntp_nntp.h lmtp2nntp_msg.h lmtp2nntp_version.c +lmtp2nntp_version.o: lmtp2nntp_version.c lmtp2nntp_version.c Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v rcsdiff -q -kk '-r1.8' '-r1.9' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.c,v' 2>/dev/null --- lmtp2nntp_config.c 2002/01/16 14:22:14 1.8 +++ lmtp2nntp_config.c 2002/01/17 17:01:55 1.9 @@ -21,35 +21,41 @@ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ** USA, or contact the OSSP project . ** -** lmtp2nntp.c: LMTP to NNTP configuration parsing +** FIXME lmtp2nntp_config.c: LMTP to NNTP configuration parsing */ #include #include #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include +#if 0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* third party (included) */ -// #include "lmtp2nntp_argz.h" -// #include "lmtp2nntp_shpat.h" -// #include "lmtp2nntp_daemon.h" +#if 0 +#include "lmtp2nntp_argz.h" +#include "lmtp2nntp_shpat.h" +#include "lmtp2nntp_daemon.h" +#endif #include "lmtp2nntp_popt.h" #include "val.h" /* third party (linked in) */ #include "str.h" -// #include "l2.h" -// #include "var.h" +#if 0 +#include "l2.h" +#include "var.h" +#endif /* library version check (compile-time) */ #define L2_VERSION_HEX_REQ 0x001200 @@ -95,13 +101,14 @@ #define NUL '\0' #endif -void die(char *); //FIXME +void die(char *); /* FIXME */ void die(char *msg) { printf("ERROR: %s\n", msg); exit(-1); } +#if 0 static val_rc_t dumper(void *ctx, const char *name, int type, const char *desc, void *data) { switch (type) { @@ -145,6 +152,12 @@ return VAL_OK; } + + + + FIXME pass(optionconfig_t *o, int pass); + /* pass=0 for preinitialization !? */ + void dotconftest(int argc, char **argv) /*FIXME*/ { popt_context poptCon; /* context for parsing command-line options */ @@ -210,10 +223,8 @@ if ((rc = val_create(&v2)) != VAL_OK) die("val_create 2"); -#if 0 if ((rc = val_reg(v, "bar", VAL_TYPE_VAL, "bar variable", (void *)&v2)) != VAL_OK) die("val_reg 2"); -#endif val_reg(v, "bar", VAL_TYPE_VAL, "bar variable", NULL); val_set(v, "bar", v2); if ((rc = val_get(v, "bar", &v3)) != VAL_OK) @@ -266,15 +277,15 @@ if ((rc = val_set(v, "bar.double", 3.14159265358979)) != VAL_OK) die("val_set for bar.double using inline data"); - // OK val_apply(v, "", 9, dumper, "v" ); - // OK val_apply(v2, "", 9, dumper, "v2"); - // OK val_apply(v, "", 0, dumper, "v" ); - // OK val_apply(v, "bar", 1, dumper, "v" ); - // OK val_apply(v2, "", 0, dumper, "v" ); - // OK val_apply(v, "", 1, dumper, "v" ); - // OK val_apply(v, "foo", 0, dumper, "v" ); - // OK val_apply(v2, "char", 2, dumper, "v" ); - // OK val_apply(v, "bar.char", 2, dumper, "v" ); + OK val_apply(v, "", 9, dumper, "v" ); + OK val_apply(v2, "", 9, dumper, "v2"); + OK val_apply(v, "", 0, dumper, "v" ); + OK val_apply(v, "bar", 1, dumper, "v" ); + OK val_apply(v2, "", 0, dumper, "v" ); + OK val_apply(v, "", 1, dumper, "v" ); + OK val_apply(v, "foo", 0, dumper, "v" ); + OK val_apply(v2, "char", 2, dumper, "v" ); + OK val_apply(v, "bar.char", 2, dumper, "v" ); if ((rc = val_destroy(v2)) != VAL_OK) die("val_destroy 2"); @@ -318,27 +329,6 @@ human-readable format. Dazu informationen fuer help. */ -/* Braindump - - fuer var - -ich brauche eine struktur, aus der man ersehen kann, welche variablen es gibt. - { - struct "system.uname.sysname", varstring, - struct "system.uname.nodename", - struct "system.uname.release", - struct "system.uname.version", - struct "system.uname.machine", - - <<< ctx->progname = strdup(argv[0]); - <<< foo = ctx->progname; - - >>> rc = varreg("main.progname", &ctx->progname); - >>> rc = varset("main.progname", strdup(argv[0])); //equivalent to ctx->progname = strdup(argv[0]); - >>> rc = varget("main.progname", &foo); //equivalent to foo = ctx->progname - } - */ - { const char *filename = "example.conf"; struct stat sb; @@ -356,7 +346,7 @@ if (close(fd) == -1) die("close"); } - //FIXME printf("DEBUG: *** 1 *** file as it was just read in ***\n%s***\n", cpBuf); + printf("DEBUG: *** 1 *** file as it was just read in ***\n%s***\n", cpBuf); { char *cpI; /* pointer to next character to be read */ @@ -396,22 +386,22 @@ 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 *command; char *value; if ((command = str_token(&cp, " \t", "\"'", "#", STR_STRIPQUOTES|STR_BACKSLASHESC)) == NULL) - ;//printf("DEBUG: no command - comment only\n"); + printf("DEBUG: no command - comment only\n"); else { printf("DEBUG: command = ***%s***\n", command); if ((value = str_token(&cp, " \t", "\"'", "#", STR_STRIPQUOTES|STR_BACKSLASHESC)) == NULL) printf("DEBUG: no value - section\n"); else { - ;//while(isspace((int)*value)) value++; + while(isspace((int)*value)) value++; printf("DEBUG: value = ***%s***\n", value); } } @@ -426,4 +416,145 @@ } } } +#endif + +typedef enum { + OPT_FLAG, + OPT_SINGLE, + OPT_MULTI +} optiontype_t; + +typedef void (*optionloop_cb_t)(void); + +struct optionconfig_s; +typedef struct optionconfig_s optionconfig_t; +struct optionconfig_s { + optionconfig_t *next; /* cleanup chain for destroy */ + /**/ + 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 */ + void *pass1default; /* default for pass1 */ + val_t *val; /* val we are registered under */ + /**/ + int number; /* number of this option for popt */ + union { /* option data as read from configuration */ + int f; /* OPT_FLAG */ + char *s; /* OPT_SINGLE */ + char **m; /* OPT_MULTI */ + } data; +}; +static void stdsyntax(void) +{ + return; +} + +static void includeit(void) +{ + return; +} + +static void option_register(lmtp2nntp_option_t *o, char *longname, char shortname, optiontype_t type, optionloop_cb_t cb, char *cbctx, char *descrip, char *argdescrip) +{ + return; +} + +lmtp2nntp_option_rc_t option_create(lmtp2nntp_option_t **op) +{ + if (op == NULL) + return OPTION_ERR_ARG; + + if ((*op = (lmtp2nntp_option_t *)malloc(sizeof(lmtp2nntp_option_t))) == NULL) + return OPTION_ERR_MEM; + (*op)->childsmax = 0; + (*op)->daemonize = 0; + (*op)->kill = 0; + (*op)->pidfile = 0; + (*op)->acl.as = 0; + (*op)->acl.az = NULL; + (*op)->bind = NULL; + (*op)->client = NULL; + (*op)->destination.as = 0; + (*op)->destination.az = NULL; + (*op)->groupmode = NULL; + (*op)->headervalue.as = 0; + (*op)->headervalue.az = NULL; + (*op)->include.as = 0; + (*op)->include.az = NULL; + (*op)->size = 0; + (*op)->timeoutlmtpaccept = 0; + (*op)->timeoutlmtpread = 0; + (*op)->timeoutlmtpwrite = 0; + (*op)->timeoutnntpconnect = 0; + (*op)->timeoutnntpread = 0; + (*op)->timeoutnntpwrite = 0; + (*op)->mailfrom = NULL; + (*op)->nodename = NULL; + (*op)->operationmode = NULL; + (*op)->l2spec = NULL; + (*op)->uid = NULL; + (*op)->restrictheader.as = 0; + (*op)->restrictheader.az = NULL; + (*op)->newsgroup.as = 0; + (*op)->newsgroup.az = NULL; + /**/ + (*op)->vo = NULL; + if (val_create(&((*op)->vo)) != VAL_OK) { + free(*op); + return OPTION_ERR_VAL; + } + return OPTION_OK; +} + +lmtp2nntp_option_rc_t option_parse(lmtp2nntp_option_t *o, int argc, char **argv) +{ + if (o == NULL) + return OPTION_ERR_ARG; + + option_register(o, "childsmax", 'C', OPT_SINGLE, stdsyntax, "[0-9]{,5}", "foo", "childsmax" ); + option_register(o, "daemonize", 'D', OPT_FLAG, NULL, NULL, "foo", NULL ); + option_register(o, "kill", 'K', OPT_FLAG, NULL, NULL, "foo", NULL ); + option_register(o, "pidfile", 'P', OPT_SINGLE, stdsyntax, ".{,255}", "foo", "pidfile" ); + option_register(o, "veryverbose", 'V', OPT_FLAG, NULL, NULL, "foo", NULL ); + option_register(o, "acl", 'a', OPT_MULTI, stdsyntax, "[0-9.](/[0-9]2)?", "foo", "addr[/mask]" ); + option_register(o, "bind", 'b', OPT_SINGLE, stdsyntax, ".*", "foo", "addr[:port]|-|path[:perms]" ); + option_register(o, "client", 'c', OPT_SINGLE, stdsyntax, ".*", "foo", "addr[:port]" ); + option_register(o, "destination", 'd', OPT_MULTI, stdsyntax, ".*", "foo", "addr[:port]" ); + option_register(o, "groupmode", 'g', OPT_SINGLE, stdsyntax, ".*", "foo", "groupmode" ); + option_register(o, "headervalue", 'h', OPT_MULTI, stdsyntax, ".*", "foo", "header: value" ); + option_register(o, "include", 'i', OPT_MULTI, includeit, ".*", "foo", "configfile" ); + option_register(o, "size", 's', OPT_SINGLE, stdsyntax, ".*", "foo", "bytes" ); + option_register(o, "timeoutlmtpaccept", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" ); + option_register(o, "timeoutlmtpread", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" ); + option_register(o, "timeoutlmtpwrite", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" ); + option_register(o, "timeoutnntpconnect", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" ); + option_register(o, "timeoutnntpread", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" ); + option_register(o, "timeoutnntpwrite", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "sec" ); + option_register(o, "mailfrom", 'm', OPT_SINGLE, stdsyntax, ".*", "foo", "regex" ); + option_register(o, "nodename", 'n', OPT_SINGLE, stdsyntax, ".*", "foo", "nodename" ); + option_register(o, "operationmode", 'o', OPT_SINGLE, stdsyntax, ".*", "foo", "post|feed" ); + option_register(o, "l2spec", 'l', OPT_SINGLE, stdsyntax, ".*", "foo", "spec" ); + option_register(o, "uid", 'u', OPT_SINGLE, stdsyntax, ".*", "foo", "number|name" ); + option_register(o, "restrictheader", 'r', OPT_MULTI, stdsyntax, ".*", "foo", "regex" ); + option_register(o, "newsgroup", NUL, OPT_MULTI, stdsyntax, ".*", "foo", "newsgroup"); + + return OPTION_OK; +} + +lmtp2nntp_option_rc_t option_destroy(lmtp2nntp_option_t *o) +{ + if (o == NULL) + return OPTION_ERR_ARG; + + if (o->vo != NULL) + val_destroy(o->vo); + + free(o); + + return OPTION_OK; +} Index: ossp-pkg/lmtp2nntp/lmtp2nntp_config.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.h,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_config.h,v' 2>/dev/null --- lmtp2nntp_config.h 2002/01/14 12:23:21 1.2 +++ lmtp2nntp_config.h 2002/01/17 17:01:55 1.3 @@ -21,38 +21,50 @@ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ** USA, or contact the OSSP project . ** -** lmtp2nntp.c: LMTP to NNTP configuration parsing +** FIXME lmtp2nntp_option.h: LMTP to NNTP configuration parsing */ #include "lmtp2nntp_global.h" -void dotconftest(int, char **); //FIXME +#include "val.h" typedef struct { - int option_childsmax; + int childsmax; + int daemonize; + int kill; + char *pidfile; + argz_t acl; + char *bind; + char *client; + argz_t destination; + char *groupmode; + argz_t headervalue; + argz_t include; + char *size; + int *timeoutlmtpaccept; + int *timeoutlmtpread; + int *timeoutlmtpwrite; + int *timeoutnntpconnect; + int *timeoutnntpread; + int *timeoutnntpwrite; + char *mailfrom; + char *nodename; + char *operationmode; + char *l2spec; + char *uid; + argz_t restrictheader; + argz_t newsgroup; + /**/ + val_t *vo; - 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; +} lmtp2nntp_option_t; +typedef enum { + OPTION_OK, + OPTION_ERR_ARG, /* invalid args passed into function */ + OPTION_ERR_MEM, /* out of memory */ + OPTION_ERR_VAL /* libval failed */ +} lmtp2nntp_option_rc_t; + +lmtp2nntp_option_rc_t option_create (lmtp2nntp_option_t **); +lmtp2nntp_option_rc_t option_parse (lmtp2nntp_option_t *, int, char **); +lmtp2nntp_option_rc_t option_destroy(lmtp2nntp_option_t *); Index: ossp-pkg/lmtp2nntp/lmtp2nntp_global.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_global.h,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_global.h,v' 2>/dev/null --- lmtp2nntp_global.h 2001/12/31 15:15:36 1.2 +++ lmtp2nntp_global.h 2002/01/17 17:01:55 1.3 @@ -49,4 +49,9 @@ #define CU(returncode) STMT( rc = returncode; goto CUS; ) #define VCU STMT( goto CUS; ) +typedef struct { + size_t as; + char *az; +} argz_t; + #endif /* __LMTP2NNTP_H__ */ Index: ossp-pkg/lmtp2nntp/lmtp2nntp_main.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/lmtp2nntp_main.c,v' 2>/dev/null --- lmtp2nntp_main.c 2002/01/14 12:23:21 1.5 +++ lmtp2nntp_main.c 2002/01/17 17:01:55 1.6 @@ -559,7 +559,12 @@ fprintf(stderr, "%s:Error: uname failed \"%s\"\n", ctx->progname, strerror(errno)); CU(ERR_EXECUTION); } -dotconftest(argc, argv); return 0; //FIXME + +{ +lmtp2nntp_option_t *o; +(void)option_create(&o); /* FIXME */ +(void)option_parse(o, argc, argv); return 0; +} /*POD B */ @@ -1338,6 +1343,7 @@ if (ctx != NULL) free(ctx); str_parse(NULL, NULL); + /*FIXME option_destroy(o); */ return rc; }