--- lmtp2nntp_main.c 2002/01/22 16:09:47 1.7
+++ lmtp2nntp_main.c 2002/01/24 12:07:13 1.8
@@ -73,10 +73,12 @@
#if defined(HAVE_DMALLOC_H) && defined(DMALLOC)
#include "dmalloc.h"
#endif
+#include "lmtp2nntp_option.h"
#include "lmtp2nntp_config.h"
#include "lmtp2nntp_lmtp.h"
#include "lmtp2nntp_nntp.h"
#include "lmtp2nntp_msg.h"
+#include "fixme.h"
#include "sa.h"
#define _LMTP2NNTP_VERSION_C_AS_HEADER_
#include "lmtp2nntp_version.c"
@@ -97,8 +99,6 @@
#define ERR_DELIVERY -2
#define STDSTRLEN 512
-#define MAXNEWSSERVICES 16
-#define MAXACLS 32
static lmtp_rc_t lmtp_cb_lhlo(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
static lmtp_rc_t lmtp_cb_mail(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
@@ -111,83 +111,11 @@
static int helo_rfc0821domain(char *msg, char **domain);
static int helo_rfc1035domain(char *msg, char **domain);
-struct session {
- int lhlo_seen;
- char *lhlo_domain;
-};
-
static void catchsignal(int sig, ...);
static void initsession(struct session *session);
static void resetsession(struct session *session);
int groupmatch(char *, size_t, char *);
-struct ns {
- char *h; /* host */
- char *p; /* port */
- sa_addr_t *saa; /* socket address abstraction */
- sa_t *sa; /* socket abstraction */
- nntp_t *nntp;
- nntp_rc_t rc;
- l2_channel_t *l2;
-};
-
-struct acl {
- char *acl;
- int not;
- sa_addr_t *saa;
- size_t prefixlen;
-};
-
-typedef struct {
- l2_context_t ctx;
- char *progname;
- char *option_logfile;
- int option_groupmode;
- int option_operationmode;
- char *option_operationmodefakestatus;
- char *option_operationmodefakedsn;
- int option_maxmessagesize;
- char *azHeaderValuePairs;
- size_t 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;
- int option_childsmax;
- int active_childs;
- l2_env_t *l2_env;
- l2_channel_t *l2;
- sa_addr_t *saaAltio;
- sa_t *saAltio;
- char *cpBindh;
- char *cpBindp;
- sa_addr_t *saaBind;
- sa_t *saBind;
- sa_addr_t *saaIO;
- sa_t *saIO;
- int fdIOi;
- int fdIOo;
- int nsc;
- struct ns ns[MAXNEWSSERVICES];
- char *azGroupargs;
- size_t asGroupargs;
- struct session session;
- msg_t *msg;
- struct utsname uname;
-} lmtp2nntp_t;
-
static var_config_t ctx_lookup_cfg = {
'$', /* varinit */
'{', /* startdelim */
@@ -501,7 +429,8 @@
if ((ctx = (lmtp2nntp_t *)malloc(sizeof(lmtp2nntp_t))) == NULL)
CU(ERR_EXECUTION);
ctx->ctx.vp = ctx;
- ctx->progname = strdup(argv[0]);
+ ctx->val = NULL;
+ ctx->progname = NULL;
ctx->option_childsmax = 10;
ctx->option_logfile = NULL;
ctx->option_groupmode = GROUPMODE_ARG;
@@ -555,15 +484,21 @@
ctx->asGroupargs = 0;
initsession(&ctx->session);
ctx->msg = NULL;
+
+ /* fill in application context */
+ if (val_create(&ctx->val) != VAL_OK)
+ CU(ERR_EXECUTION);
if (uname(&ctx->uname) == -1) {
fprintf(stderr, "%s:Error: uname failed \"%s\"\n", ctx->progname, strerror(errno));
CU(ERR_EXECUTION);
}
+ ctx->progname = strdup(argv[0]);
{
lmtp2nntp_option_t *o;
-(void)option_create(&o); /* FIXME */
+(void)option_create(&o, ctx->val); /* FIXME */
(void)option_parse(o, argc, argv);
+(void)config_context(ctx);
(void)option_destroy(o);
return 0;
}
|