--- lmtp2nntp_main.c 2002/01/30 14:22:23 1.11
+++ lmtp2nntp_main.c 2002/01/30 16:41:02 1.12
@@ -98,9 +98,6 @@
#define NUL '\0'
#endif
-#define ERR_EXECUTION 1
-#define ERR_DELIVERY -2
-
#define STDSTRLEN 512
static lmtp_rc_t lmtp_cb_lhlo(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx);
@@ -321,30 +318,6 @@
return rc;
}
-static l2_result_t
-formatter_prefix(l2_context_t *_ctx, const char id, const char *param,
- char *bufptr, size_t bufsize, size_t *buflen, va_list *ap)
-{
- lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx->vp;
-
- if ((ctx->msg != NULL) && (ctx->msg->cpFid != NULL)) {
- sprintf(bufptr, "%s: ", ctx->msg->cpFid);
- *buflen = strlen(bufptr);
- }
- else
- *buflen = 0;
- return L2_OK;
-}
-
-static l2_result_t
-formatter_errno(l2_context_t *_ctx, const char id, const char *param,
- char *bufptr, size_t bufsize, size_t *buflen, va_list *ap)
-{
- sprintf(bufptr, "(%d) %s", errno, strerror(errno));
- *buflen = strlen(bufptr);
- return L2_OK;
-}
-
static void catchsignal(int sig, ...)
{
va_list ap;
@@ -435,7 +408,6 @@
ctx->val = NULL;
ctx->progname = NULL;
ctx->option_childsmax = 10;
- ctx->option_logfile = NULL;
ctx->option_groupmode = GROUPMODE_ARG;
ctx->option_operationmode = OPERATIONMODE_FAKE;
ctx->option_operationmodefakestatus = "553"; /* Requested action not taken: mailbox name not allowed */
@@ -451,7 +423,6 @@
ctx->option_timeout_nntp_write = 60;
ctx->option_mailfrom = NULL;
ctx->option_restrictheader = NULL;
- ctx->option_levelmask = L2_LEVEL_NONE;
ctx->option_pidfile = NULL;
ctx->option_killflag = FALSE;
ctx->option_uid = getuid();
@@ -516,54 +487,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 'D': /*POD [B<-D>] */
- ctx->option_daemon = TRUE;
- break;
- case 'K': /*POD [B<-K>] */
- ctx->option_killflag = TRUE;
- break;
- case 'P': /*POD [B<-P> I<pidfile>] */
- ctx->option_pidfile = strdup(optarg);
- break;
- case 'V': /*POD [B<-V>] */
- ctx->option_veryverbose = TRUE;
- break;
- case 'a': /*POD [B<-a> I<addr>/I<mask>[,I<addr>/I<mask>[,...]] */
- if (argz_create_sep(optarg, ',', &azACL, &asACL) != 0)
- CU(ERR_EXECUTION);
- cp = NULL;
- while ((cp = argz_next(azACL, asACL, cp)) != NULL) {
- if (ctx->option_aclc >= MAXACLS) {
- fprintf(stderr, "%s:Error: Too many ACL (%d) using option -a\n", ctx->progname, ctx->option_aclc);
- CU(ERR_EXECUTION);
- }
- ctx->option_acl[ctx->option_aclc].acl = strdup(cp);
- if (cp[0] == '!') {
- ctx->option_acl[ctx->option_aclc].not = TRUE;
- cpAddr = strdup(cp+1);
- }
- else {
- cpAddr = strdup(cp);
- }
- if ((cpPrefixLen = strrchr(cpAddr, '/')) != NULL)
- *cpPrefixLen++ = NUL;
- else
- cpPrefixLen = "-1";
- ctx->option_acl[ctx->option_aclc].prefixlen = atoi(cpPrefixLen);
- if ((rc = sa_addr_create(&ctx->option_acl[ctx->option_aclc].saa)) != SA_OK) {
- fprintf(stderr, "%s:Error: Creating address failed for -a option (%d)\n",
- ctx->progname, rc);
- }
- if ((rc = sa_addr_u2a(ctx->option_acl[ctx->option_aclc].saa, "inet://%s:0", cpAddr)) != SA_OK) {
- fprintf(stderr, "%s:Error: Parsing host address failed for \"%s:0\" (%d)\n",
- ctx->progname, cpAddr, rc);
- CU(ERR_EXECUTION);
- }
- ctx->option_aclc++;
- free(cpAddr);
- }
- free(azACL);
- break;
case 'b': /*POD [B<-b> I<addr>[I<:port>]|C<->|I<path>[:perms]] */
if (strcmp(optarg, "-") != 0) {
if ((rc = sa_create(&ctx->saAltio)) != SA_OK) {
@@ -737,25 +660,6 @@
free(cpHeadervalue);
free(cpHeadername);
break;
- case 'l': /*POD [B<-l> I<level>[:I<logfile>]] */
- if ((cp = strrchr(optarg, ':')) != NULL) {
- *cp++ = NUL;
- if (*cp == NUL) {
- fprintf(stderr, "%s:Error: empty logfile to option -l\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
- else
- ctx->option_logfile = strdup(cp);
- }
- else
- ctx->option_logfile = strdup("logfile");
-
- if (l2_util_s2l(optarg, strlen(optarg), ',', &ctx->option_levelmask) != L2_OK) {
- fprintf(stderr, "%s:Error: invalid level \"%s\" to option -l\n", ctx->progname, optarg);
- CU(ERR_EXECUTION);
- }
- ctx->option_levelmask = L2_LEVEL_UPTO(ctx->option_levelmask);
- break;
case 'm': /*POD [B<-m> I<mailfrom>] */
ctx->option_mailfrom = strdup(optarg);
/* protect ourselfs from the substitution of backreferences.
@@ -975,65 +879,6 @@
}
}
- /* create L2 environment */
- if (l2_env_create(&ctx->l2_env) != L2_OK) {
- fprintf(stderr, "%s:Error: failed to create L2 environment\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
-
- /* register custom L2 formatters */
- if (l2_env_formatter(ctx->l2_env, 'P', formatter_prefix, &ctx->ctx) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to register prefix formatter\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
- if (l2_env_formatter(ctx->l2_env, 'D', l2_util_fmt_dump, NULL) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to register dump formatter\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
- if (l2_env_formatter(ctx->l2_env, 'S', l2_util_fmt_string, NULL) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to register string formatter\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
- if (l2_env_formatter(ctx->l2_env, 'm', formatter_errno, NULL) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to register errno formatter\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
-
- /* create channel stream */
- if (ctx->option_levelmask != L2_LEVEL_NONE && ctx->option_logfile != NULL) {
- if (ctx->option_veryverbose)
- rc = l2_spec(&ctx->l2, ctx->l2_env,
- "prefix(prefix=\"%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: \",timezone=local)"
- " -> buffer(size=65536)"
- " -> file(path=%s,append=1,perm=%d)",
- ctx->option_logfile, 0644);
- else
- rc = l2_spec(&ctx->l2, ctx->l2_env,
- "prefix(prefix=\"%%b %%d %%H:%%M:%%S <%%L> lmtp2nntp[%%P]: \",timezone=local)"
- " -> file(path=%s,append=1,perm=%d)",
- ctx->option_logfile, 0644);
- if (rc != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
- if (l2_channel_levels(ctx->l2, ctx->option_levelmask, L2_LEVEL_NONE) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to set global logging level\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
- if (l2_channel_open(ctx->l2) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to open channel stream\n", ctx->progname);
- CU(ERR_EXECUTION);
- }
- }
-
- /* from this point on logging is up and running and fprintf(stderr, ...)
- * should not be used in the remainder of the code
- */
-
- log1(ctx, NOTICE, "startup, version %s", lmtp2nntp_version.v_gnu);
- if (ctx->option_veryverbose)
- log0(ctx, NOTICE, "logging very verbose (unbuffered)");
-
if ((ctx->option_pidfile != NULL) && ctx->option_killflag) {
if ((fd = fopen(ctx->option_pidfile, "r")) == NULL)
log1(ctx, ERROR, "cannot open pidfile \"%s\" for reading %m", ctx->option_pidfile);
@@ -1267,8 +1112,6 @@
free(ctx->azHeaderValuePairs);
if (ctx->option_pidfile != NULL)
free(ctx->option_pidfile);
- if (ctx->option_logfile != NULL)
- free(ctx->option_logfile);
if (ctx->progname != NULL)
free(ctx->progname);
if (ctx->azGroupargs != NULL)
|