head 1.8; access; symbols LMTP2NNTP_1_4_1:1.8 LMTP2NNTP_1_4_0:1.8 LMTP2NNTP_1_3_0:1.8 LMTP2NNTP_1_3b2:1.8 LMTP2NNTP_1_3b1:1.8 LMTP2NNTP_1_3a3:1.8 LMTP2NNTP_1_3a2:1.8 LMTP2NNTP_1_3a1:1.8 LMTP2NNTP_1_2_0:1.8 LMTP2NNTP_1_2b4:1.8 LMTP2NNTP_1_2b3:1.8 LMTP2NNTP_1_2b2:1.8 LMTP2NNTP_1_2b1:1.8 LMTP2NNTP_1_2a8:1.8 LMTP2NNTP_1_2a7:1.8 LMTP2NNTP_1_2a6:1.7 LMTP2NNTP_1_2a5:1.7 LMTP2NNTP_1_2a4:1.7 LMTP2NNTP_1_2a3:1.5; locks; strict; comment @ * @; 1.8 date 2003.01.30.19.42.13; author rse; state Exp; branches; next 1.7; 1.7 date 2002.03.07.16.03.56; author thl; state Exp; branches; next 1.6; 1.6 date 2002.03.06.14.25.39; author thl; state Exp; branches; next 1.5; 1.5 date 2002.02.14.10.47.20; author thl; state Exp; branches; next 1.4; 1.4 date 2002.02.04.13.52.15; author thl; state Exp; branches; next 1.3; 1.3 date 2002.01.30.16.41.02; author thl; state Exp; branches; next 1.2; 1.2 date 2002.01.24.16.25.54; author thl; state Exp; branches; next 1.1; 1.1 date 2002.01.24.12.04.46; author thl; state Exp; branches; next ; desc @@ 1.8 log @Apply the standard OSSP copyright header, document ASCII art and fix URL to lmtp2nntp homepage. @ text @/* ** OSSP lmtp2nntp - Mail to News Gateway ** Copyright (c) 2002-2003 Ralf S. Engelschall ** Copyright (c) 2002-2003 The OSSP Project ** Copyright (c) 2002-2003 Cable & Wireless Germany ** ** This file is part of OSSP lmtp2nntp, an LMTP speaking local ** mailer which forwards mails as Usenet news articles via NNTP. ** It can be found at http://www.ossp.org/pkg/tool/lmtp2nntp/. ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License ** as published by the Free Software Foundation; either version ** 2.0 of the License, or (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this file; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ** USA, or contact the OSSP project . ** ** lmtp2nntp_option.h: option parsing */ #ifndef __LMTP2NNTP_OPTION_H__ #define __LMTP2NNTP_OPTION_H__ #include "lmtp2nntp_global.h" #include "val.h" struct optionval_s; typedef struct optionval_s optionval_t; typedef struct { 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 */ struct popt_option *pt; /* popt table */ } 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_TRY, /* caught an exception from a underlying codeblock */ OPTION_ERR_USE, /* invalid usage, bad data passed into function */ OPTION_ERR_MEM, /* out of memory */ OPTION_ERR_VAL, /* libval failed */ OPTION_ERR_NUM /* option_find not successful */ } lmtp2nntp_option_rc_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 */ union { /* option data as read from configuration */ int f; /* OPT_FLAG */ char *s; /* OPT_SINGLE */ char **m; /* OPT_MULTI */ } data; int ndata; }; /* these public functions catch all underlying exceptions and properly return a code */ lmtp2nntp_option_rc_t option_create (lmtp2nntp_option_t **, val_t *); lmtp2nntp_option_rc_t option_parse (lmtp2nntp_option_t *, int, char **); lmtp2nntp_option_rc_t option_destroy(lmtp2nntp_option_t *); #endif /* __LMTP2NNTP_OPTION_H__ */ @ 1.7 log @cleanup; better use of lib_ex; fight fixmes and resource leakage; cosmetics; flush; @ text @d2 4 a5 2 ** Copyright (c) 2001-2002 The OSSP Project ** Copyright (c) 2001-2002 Cable & Wireless Deutschland d9 1 a9 1 ** It can be found at http://www.ossp.org/pkg/lmtp2nntp/. @ 1.6 log @Syntax and argument checking does no longer ignore errors silently. It properly prints error messages for unknown options or invalid arguments. The message printed includes what it got and what it expected. Processing is continued to check for more errors but finally it aborts before the main program starts. @ text @d55 1 d86 4 a89 4 lmtp2nntp_option_rc_t option_create (lmtp2nntp_option_t **, val_t *); 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 *); @ 1.5 log @add outermost ifndef headers @ text @d37 2 a38 28 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; /*FIXME above*/ optionval_t *first; optionval_t *last; d57 2 a58 1 OPTION_ERR_VAL /* libval failed */ @ 1.4 log @application defaults now set through option_register() @ text @d27 3 d114 2 @ 1.3 log @flush. first options moved. introduced exception handling. @ text @d108 1 a108 1 lmtp2nntp_option_rc_t option_register(lmtp2nntp_option_t *, char *, char, optiontype_t, optionloop_cb_t *, char *, char *, char *); @ 1.2 log @option works and data can be read by config @ text @d99 1 a99 1 struct { /* option data as read from configuration */ a100 1 void *foo1, *foo2, *foo3, *foo4, *foo5, *foo6, *foo7, *foo8, *foo9; a101 1 void *bar1, *bar2, *bar3, *bar4, *bar5, *bar6, *bar7, *bar8, *bar9; @ 1.1 log @moved config to option, created a new config @ text @d30 2 a31 2 struct optionconfig_s; typedef struct optionconfig_s optionconfig_t; d60 2 a61 2 optionconfig_t *first; optionconfig_t *last; d70 6 d83 25 a107 5 typedef enum { OPT_FLAG, OPT_SINGLE, OPT_MULTI } optiontype_t; a108 1 typedef lmtp2nntp_option_rc_t (optionloop_cb_t)(optionconfig_t *oc, char *arg, char *cbctx); @