--- lmtp2nntp.c 2001/09/05 15:01:57 1.41
+++ lmtp2nntp.c 2001/09/07 13:53:16 1.42
@@ -37,9 +37,10 @@
#include "str.h"
#include "argz.h"
#include "shpat_match.h"
-#include "l2/l2.h" //FIXME
+#include "l2.h"
/* own headers */
+#include "lmtp2nntp.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -105,8 +106,8 @@
};
typedef struct {
- int option_verbose;
- int option_tracing;
+ char *progname;
+ char *option_logfile;
int option_groupmode;
int option_deliverymode;
char *option_deliverymodefakestatus;
@@ -172,6 +173,26 @@
return;
}
+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;
+
+ sprintf(bufptr, "%s[%ld]", ctx->progname, (long)getpid());
+ *buflen = strlen(bufptr);
+ 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;
+}
+
int main(int argc, char **argv)
{
lmtp_t *lmtp;
@@ -179,7 +200,6 @@
lmtp2nntp_t *ctx;
int i; /* general purpose scratch int, index ... */
char *cp; /* general purpose character pointer */
- char *progname;
char *azHosts;
size_t asHosts;
char *cpHost;
@@ -189,13 +209,11 @@
l2_channel_t *chBuf;
l2_channel_t *chFile;
- progname = argv[0];
-
/* create application context */
if ((ctx = (lmtp2nntp_t *)malloc(sizeof(lmtp2nntp_t))) == NULL)
exit(ERR_EXECUTION);
- ctx->option_verbose = FALSE;
- ctx->option_tracing = FALSE;
+ ctx->progname = strdup(argv[0]);
+ ctx->option_logfile = NULL;
ctx->option_groupmode = GROUPMODE_ARG;
ctx->option_deliverymode = DELIVERYMODE_FAKE;
ctx->option_deliverymodefakestatus = "553"; /* Requested action not taken: mailbox name not allowed */
@@ -203,7 +221,7 @@
ctx->option_maxmessagesize = 8 * 1024 * 1024;
ctx->option_waittime = -1;
ctx->option_mailfrom = NULL;
- ctx->option_levelmask = L2_LEVEL_UPTO(L2_LEVEL_ERROR);
+ ctx->option_levelmask = L2_LEVEL_UPTO(L2_LEVEL_WARNING);
ctx->l2 = NULL;
ctx->cpBindh = NULL;
ctx->cpBindp = NULL;
@@ -222,7 +240,7 @@
initsession(&ctx->session);
ctx->msg = NULL;
if (uname(&ctx->uname) == -1) {
- fprintf(stderr, "%s:Error: uname failed \"%s\"\n", progname, strerror(errno));
+ fprintf(stderr, "%s:Error: uname failed \"%s\"\n", ctx->progname, strerror(errno));
exit(ERR_EXECUTION);
}
@@ -241,57 +259,6 @@
}
#endif
- if ((ctx->l2 = l2_stream_create()) == NULL) {
- fprintf(stderr, "%s:Error: logging failed to create stream\n", progname);
- exit(ERR_EXECUTION);
- }
-
- if ((chPrefix = l2_channel_create(&l2_handler_prefix)) == NULL) {
- fprintf(stderr, "%s:Error: logging failed to create prefix channel\n", progname);
- exit(ERR_EXECUTION);
- }
- if (l2_channel_configure(chPrefix, "timefmt,timezone", "[%d-%m-%Y/%H:%M:%S] ", "local") != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to configure prefix channel\n", progname);
- exit(ERR_EXECUTION);
- }
-
- if ((chBuf = l2_channel_create(&l2_handler_buffer)) == NULL) {
- fprintf(stderr, "%s:Error: logging failed to create buffer channel\n", progname);
- exit(ERR_EXECUTION);
- }
- if (l2_channel_configure(chBuf, "size", 4096) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to configure buffer channel\n", progname);
- exit(ERR_EXECUTION);
- }
-
- if ((chFile = l2_channel_create(&l2_handler_file)) == NULL) {
- fprintf(stderr, "%s:Error: logging failed to create file channel\n", progname);
- exit(ERR_EXECUTION);
- }
- if (l2_channel_configure(chFile, "path,append,perm", "logtest", TRUE, 0644) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to configure file channel\n", progname);
- exit(ERR_EXECUTION);
- }
-
- if (l2_channel_stack(chFile, chBuf) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to stack buffer channel on top of file channel\n", progname);
- exit(ERR_EXECUTION);
- }
- if (l2_channel_stack(chBuf, chPrefix) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to stack prefix channel on top of buffer channel\n", progname);
- exit(ERR_EXECUTION);
- }
-
- if (l2_channel_open(chPrefix) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to open buffer channel\n", progname);
- exit(ERR_EXECUTION);
- }
-
- if (l2_stream_channel(ctx->l2, chPrefix, L2_LEVEL_UPTO(L2_LEVEL_DEBUG)) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to attach channel into stream\n", progname);
- exit(ERR_EXECUTION);
- }
-
/*POD B<lmtp2nntp> */
/* use
@@ -300,19 +267,8 @@
*/
/* read in the arguments */
- while ((i = getopt(argc, argv, "L:Vb:d:g:h:l:m:n:s:t:vw:")) != -1) {
+ while ((i = getopt(argc, argv, "b:d:g:h:l:m:n:s:vw:")) != -1) {
switch (i) {
- case 'L': /*POD B<-L> I<level>*/
- if (l2_util_s2l(optarg, strlen(optarg), ',', &ctx->option_levelmask) != L2_OK) {
- fprintf(stderr, "%s:Error: Invalid format \"%s\" to option -L\n", progname, optarg);
- exit(ERR_EXECUTION);
- }
- //FIXME
- break;
- case 'V': /*POD [B<-V>] (version)*/
- fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu);
- exit(0);
- break;
case 'b': /*POD [B<-b> I<bindaddr>[I<:port>] */
/* parse host[:port] string into host and port */
ctx->cpBindh = strdup(optarg);
@@ -326,23 +282,12 @@
fprintf(stderr, "DEBUG: creating TCP socket address for \"%s:%s\"\n", ctx->cpBindh, ctx->cpBindp);
if ((ctx->saBind = sa_create(SA_IP, "tcp", ctx->cpBindh, ctx->cpBindp)) == NULL) {
fprintf(stderr, "%s:Error: creating TCP socket address failed for \"%s:%s\": %s\n",
- progname,
+ ctx->progname,
ctx->cpBindh,
ctx->cpBindp,
strerror(errno));
exit(ERR_EXECUTION);
}
- fprintf(stderr, "DEBUG: saBind->sa_len=%d\n",
- ctx->saBind->sa_buf->sa_len);
- fprintf(stderr, "DEBUG: saBind->sa_family=%d\n", (int)ctx->saBind->sa_buf->sa_family);
- for (i=0; i<14; i++)
- fprintf(stderr, "DEBUG: saBind->sa_data[%2d]=%2x %d\n", i,
- (unsigned int)(unsigned char)ctx->saBind->sa_buf->sa_data[i],
- (unsigned int)(unsigned char)ctx->saBind->sa_buf->sa_data[i]);
- ctx->saBind->sa_buf->sa_data[ 7]='0'; //DEBUG
- ctx->saBind->sa_buf->sa_data[ 8]='0'; //DEBUG
- ctx->saBind->sa_buf->sa_data[ 9]='0'; //DEBUG
- ctx->saBind->sa_buf->sa_data[10]='0'; //DEBUG
break;
case 'd': /*POD [B<-d> I<deliverymode>] */
if (strcasecmp(optarg, "post") == 0)
@@ -351,12 +296,12 @@
ctx->option_deliverymode = DELIVERYMODE_FEED;
else {
if (strlen(optarg) != 9) {
- fprintf(stderr, "%s:Error: Invalid format or length \"%s\" to option -d\n", progname, optarg);
+ fprintf(stderr, "%s:Error: Invalid format or length \"%s\" to option -d\n", ctx->progname, optarg);
exit(ERR_EXECUTION);
}
if (optarg[3] != '/') {
- fprintf(stderr, "%s:Error: Invalid format or missing slash \"%s\" to option -d\n", progname, optarg);
+ fprintf(stderr, "%s:Error: Invalid format or missing slash \"%s\" to option -d\n", ctx->progname, optarg);
exit(ERR_EXECUTION);
}
@@ -368,7 +313,7 @@
|| !isdigit((int)ctx->option_deliverymodefakestatus[0])
|| !isdigit((int)ctx->option_deliverymodefakestatus[1])
|| !isdigit((int)ctx->option_deliverymodefakestatus[2])) {
- fprintf(stderr, "%s:Error: Invalid status in format \"%s\" to option -d\n", progname, optarg);
+ fprintf(stderr, "%s:Error: Invalid status in format \"%s\" to option -d\n", ctx->progname, optarg);
exit(ERR_EXECUTION);
}
@@ -379,7 +324,7 @@
|| (ctx->option_deliverymodefakedsn[3] != '.')
|| !isdigit((int)ctx->option_deliverymodefakedsn[4])
|| (ctx->option_deliverymodefakedsn[0] != ctx->option_deliverymodefakestatus[0])) {
- fprintf(stderr, "%s:Error: Invalid dsn in format \"%s\" to option -d\n", progname, optarg);
+ fprintf(stderr, "%s:Error: Invalid dsn in format \"%s\" to option -d\n", ctx->progname, optarg);
exit(ERR_EXECUTION);
}
}
@@ -392,7 +337,7 @@
else if (strcasecmp(optarg, "header") == 0)
ctx->option_groupmode = GROUPMODE_HEADER;
else {
- fprintf(stderr, "%s:Error: Invalid mode \"%s\" to option -g\n", progname, optarg);
+ fprintf(stderr, "%s:Error: Invalid mode \"%s\" to option -g\n", ctx->progname, optarg);
exit(ERR_EXECUTION);
}
break;
@@ -402,7 +347,7 @@
cp = NULL;
while ((cp = argz_next(azHosts, asHosts, cp)) != NULL) {
if (ctx->nsc >= MAXNEWSSERVICES) {
- fprintf(stderr, "%s:Error: Too many services (%d) using option -h\n", progname, ctx->nsc);
+ fprintf(stderr, "%s:Error: Too many services (%d) using option -h\n", ctx->progname, ctx->nsc);
exit(ERR_EXECUTION);
}
@@ -421,7 +366,7 @@
ctx->ns[ctx->nsc].h,
ctx->ns[ctx->nsc].p)) == NULL) {
fprintf(stderr, "%s:Error: creating TCP socket address failed for \"%s:%s\": %s\n",
- progname,
+ ctx->progname,
ctx->ns[ctx->nsc].h,
ctx->ns[ctx->nsc].p,
strerror(errno));
@@ -431,7 +376,7 @@
if ((ctx->ns[ctx->nsc].s =
socket(sa->sa_buf->sa_family, SOCK_STREAM, sa->sa_proto)) == -1) {
fprintf(stderr, "%s:Error: Creating TCP socket failed for \"%s:%s\": %s\n",
- progname,
+ ctx->progname,
ctx->ns[ctx->nsc].h,
ctx->ns[ctx->nsc].p,
strerror(errno));
@@ -447,7 +392,7 @@
break;
case 'n': /*POD [B<-n> I<nodename>] */
if (strlen(optarg) > sizeof(ctx->uname.nodename)-1) {
- fprintf(stderr, "%s:Error: nodename \"%s\" to long to option -n.\n", progname, optarg);
+ fprintf(stderr, "%s:Error: nodename \"%s\" to long to option -n.\n", ctx->progname, optarg);
exit(ERR_EXECUTION);
}
strcpy(ctx->uname.nodename, optarg);
@@ -455,28 +400,42 @@
case 's': /*POD [B<-s> I<size>] */
ctx->option_maxmessagesize = atoi(optarg);
if(ctx->option_maxmessagesize < 64) {
- fprintf(stderr, "%s:Error: maximum message size is unacceptable small.\n", progname);
+ fprintf(stderr, "%s:Error: maximum message size is unacceptable small.\n", ctx->progname);
exit(ERR_EXECUTION);
}
- case 't': /*POD [B<-t> I<tracefile>] */
- ctx->option_tracing = TRUE;
- trace_read (-1, optarg, 0);
- trace_write(-1, optarg, 0);
+ 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);
+ exit(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);
+ exit(ERR_EXECUTION);
+ }
+ ctx->option_levelmask = L2_LEVEL_UPTO(ctx->option_levelmask);
break;
- case 'v': /*POD [B<-v>] (verbose)*/
- ctx->option_verbose = TRUE;
+ case 'v': /*POD [B<-v>] (version)*/
+ fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu);
+ exit(0);
break;
case 'w': /*POD [B<-w> I<waittime>] */
ctx->option_waittime = atoi(optarg);
if(ctx->option_waittime < 1) {
- fprintf(stderr, "%s:Error: waittime %d to option -w must be greater 1 second.\n",
- progname, ctx->option_waittime);
+ fprintf(stderr, "%s:Error: waittime %d to option -w must be greater 1 second.\n", ctx->progname, ctx->option_waittime);
exit(ERR_EXECUTION);
}
break;
case '?':
default:
- usage(progname);
+ usage(ctx->progname);
exit(ERR_EXECUTION);
}
}
@@ -485,32 +444,94 @@
argz_add(&ctx->azGroupargs, &ctx->asGroupargs, argv[i]);
}
- /* initialize L2 logging context */
- fprintf(stderr, "DEBUG: ctx->option_levelmask=0x%x\n", ctx->option_levelmask);
- if (l2_stream_levels(ctx->l2, ctx->option_levelmask) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to set global logging level\n", progname);
+ if ((ctx->l2 = l2_stream_create()) == NULL) {
+ fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname);
exit(ERR_EXECUTION);
}
- if (l2_stream_log(ctx->l2, L2_LEVEL_INFO, "%s: Startup", progname) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to log \"Startup\" message to stream\n", progname);
+ if (l2_stream_formatter(ctx->l2, 'P', formatter_prefix, (l2_context_t *)&ctx) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to register formatter\n", ctx->progname);
exit(ERR_EXECUTION);
}
- if (l2_stream_log(ctx->l2, L2_LEVEL_DEBUG, "%s: Startup DEBUG-test", progname) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to log \"Startup\" message to stream\n", progname);
+ if (l2_stream_formatter(ctx->l2, 'D', l2_util_fmt_dump, NULL) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to register dump formatter\n", ctx->progname);
exit(ERR_EXECUTION);
}
- if (l2_stream_log(ctx->l2, L2_LEVEL_PANIC, "%s: Startup PANIC-test", progname) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to log \"Startup\" message to stream\n", progname);
+ if (l2_stream_formatter(ctx->l2, 'm', formatter_errno, NULL) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to register dump formatter\n", ctx->progname);
exit(ERR_EXECUTION);
}
+ if ((chPrefix = l2_channel_create(&l2_handler_prefix)) == NULL) {
+ fprintf(stderr, "%s:Error: logging failed to create prefix channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+ if (l2_channel_configure(chPrefix, "timefmt,timezone", "[%d-%m-%Y/%H:%M:%S] ", "local") != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to configure prefix channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+ if ((chBuf = l2_channel_create(&l2_handler_buffer)) == NULL) {
+ fprintf(stderr, "%s:Error: logging failed to create buffer channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+ if (l2_channel_configure(chBuf, "size", 4) != L2_OK) { //FIXME 4096
+ fprintf(stderr, "%s:Error: logging failed to configure buffer channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+ if ((chFile = l2_channel_create(&l2_handler_file)) == NULL) {
+ fprintf(stderr, "%s:Error: logging failed to create file channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+ if (l2_channel_configure(chFile, "path,append,perm", ctx->option_logfile, TRUE, 0644) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to configure file channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+ if (l2_channel_stack(chFile, chBuf) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to stack buffer channel on top of file channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+ if (l2_channel_stack(chBuf, chPrefix) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to stack prefix channel on top of buffer channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+ if (l2_channel_open(chPrefix) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to open buffer channel\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+ if (l2_stream_channel(ctx->l2, chPrefix, L2_LEVEL_UPTO(L2_LEVEL_DEBUG)) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to attach channel into stream\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+fprintf(stderr, "DEBUG: ctx->option_levelmask=0x%x\n", ctx->option_levelmask);
+ if (l2_stream_levels(ctx->l2, ctx->option_levelmask) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to set global logging level\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+ if (l2_stream_log(ctx->l2, L2_LEVEL_INFO, "%P: startup, version %s", lmtp2nntp_version.v_gnu) != L2_OK) {
+ fprintf(stderr, "%s:Error: logging failed to log startup message to stream\n", ctx->progname);
+ exit(ERR_EXECUTION);
+ }
+
+ if (ctx->option_logfile && (ctx->option_levelmask >= L2_LEVEL_TRACE)) {
+ trace_read (-1, ctx->option_logfile, 0);
+ trace_write(-1, ctx->option_logfile, 0);
+ }
+
/* initialize LMTP context */
lmtp_io.select = NULL;
lmtp_io.read = trace_read;
lmtp_io.write = trace_write;
- if ((lmtp = lmtp_create(STDIN_FILENO, STDOUT_FILENO, ctx->option_tracing ? &lmtp_io : NULL)) == NULL) {
- fprintf(stderr, "%s:Error: Unable to initialize LMTP library\n", progname);
+ if ((lmtp = lmtp_create(STDIN_FILENO, STDOUT_FILENO,
+ (ctx->option_logfile && (ctx->option_levelmask >= L2_LEVEL_TRACE)) ?
+ &lmtp_io : NULL )) == NULL) {
+ fprintf(stderr, "%s:Error: Unable to initialize LMTP library\n", ctx->progname);
exit(ERR_EXECUTION);
}
/* RFC0821, 4.5.1. MINIMUM IMPLEMENTATION
@@ -540,19 +561,20 @@
lmtp_loop(lmtp);
/* graceful shutdown */
+ log0(ctx, INFO, "%P: graceful shutdown, no more logging until exit");
lmtp_gfs_quit(ctx);
lmtp_gfs_lhlo(ctx);
lmtp_destroy(lmtp);
+ if (ctx->option_logfile != NULL)
+ free(ctx->option_logfile);
+ if (ctx->progname != NULL)
+ free(ctx->progname);
if (ctx->azGroupargs != NULL)
free(ctx->azGroupargs);
if (ctx != NULL)
free(ctx);
str_parse(NULL, NULL);
-
- if (l2_stream_destroy(ctx->l2) != L2_OK) {
- fprintf(stderr, "%s:Error: logging failed to destroy stream\n", progname);
- exit(ERR_EXECUTION);
- }
+ l2_stream_destroy(ctx->l2);
return 0;
}
@@ -657,6 +679,8 @@
int i;
nntp_io_t nntp_io;
+ log0(ctx, INFO, "lmtp_cb_lhlo");
+
nntp_io.select = NULL;
nntp_io.read = trace_read;
nntp_io.write = trace_write;
@@ -701,35 +725,56 @@
i = 0;
do {
bOk = TRUE;
- if (bOk && (ctx->saBind != NULL) &&
- bind(ctx->ns[i].s, ctx->saBind->sa_buf, ctx->saBind->sa_len) < 0) {
- bOk = FALSE;
- fprintf(stderr, "DEBUG: errno=%d\n", errno);
- }
- if (ctx->option_waittime > 0) {
- if (connect_nonb(ctx->ns[i].s, ctx->ns[i].sa->sa_buf, ctx->ns[i].sa->sa_len,
- ctx->option_waittime) < 0) {
+ if (bOk && (ctx->saBind != NULL)) {
+ log0(ctx, DEBUG, "bind");
+ if (bind(ctx->ns[i].s, ctx->saBind->sa_buf, ctx->saBind->sa_len) < 0) {
bOk = FALSE;
+ log0(ctx, ERROR, "bind=%m");
}
}
- else {
- if (connect(ctx->ns[i].s, ctx->ns[i].sa->sa_buf, ctx->ns[i].sa->sa_len) < 0) {
- bOk = FALSE;
+ if (bOk) {
+ if(ctx->option_waittime > 0) {
+ log0(ctx, DEBUG, "connect_nonb");
+ if (connect_nonb(ctx->ns[i].s, ctx->ns[i].sa->sa_buf, ctx->ns[i].sa->sa_len,
+ ctx->option_waittime) < 0) {
+ bOk = FALSE;
+ log0(ctx, ERROR, "connect_nonb=%m");
+ }
+ }
+ else {
+ log0(ctx, DEBUG, "connect");
+ if (connect(ctx->ns[i].s, ctx->ns[i].sa->sa_buf, ctx->ns[i].sa->sa_len) < 0) {
+ bOk = FALSE;
+ log0(ctx, ERROR, "connect=%m");
+ }
}
}
- if (bOk && ((ctx->ns[i].nntp = nntp_create(ctx->ns[i].s, ctx->ns[i].s,
- ctx->option_tracing ? &nntp_io : NULL)) == NULL)) {
- bOk = FALSE;
+ if (bOk) {
+ log0(ctx, DEBUG, "nntp_create");
+ if ((ctx->ns[i].nntp = nntp_create(ctx->ns[i].s, ctx->ns[i].s,
+ (ctx->option_logfile && (ctx->option_levelmask >= L2_LEVEL_TRACE)) ?
+ &nntp_io : NULL)) == NULL) {
+ bOk = FALSE;
+ log0(ctx, ERROR, "nntp_create failed");
+ }
}
if (bOk && ctx->option_waittime >= 0) {
+ log1(ctx, DEBUG, "nntp_timeout(%d)", ctx->option_waittime);
nntp_timeout(ctx->ns[i].nntp, ctx->option_waittime);
}
- if (bOk && ((rc = nntp_init(ctx->ns[i].nntp)) != NNTP_OK)) {
- bOk = FALSE;
+ if (bOk) {
+ log0(ctx, DEBUG, "nntp_init");
+ if ((rc = nntp_init(ctx->ns[i].nntp)) != NNTP_OK) {
+ bOk = FALSE;
+ log2(ctx, ERROR, "nntp_init=(%m) %s", rc, nntp_error(rc));
+ }
}
- if (bOk)
+ if (bOk) {
+ log0(ctx, INFO, "nntp connection successfully established");
i++;
+ }
else {
+ log0(ctx, INFO, "nntp connection establishment failed");
if (i < --ctx->nsc) {
memcpy(&ctx->ns[i], &ctx->ns[i+1], (ctx->nsc - i ) * sizeof(struct ns));
}
@@ -915,6 +960,8 @@
lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx;
lmtp_res_t res;
+ log0(ctx, INFO, "lmtp_cb_mail");
+
/* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 553 Requested action not taken: mailbox name not allowed
* RFC1893 2. Status Codes 5.X.X Permanent Failure
* RFC1893 3.5 Network and Routing Status X.1.8 Bad sender's system address
@@ -1011,6 +1058,8 @@
char *cp;
char *group;
+ log0(ctx, INFO, "lmtp_cb_rcpt");
+
/* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 503 Bad sequence of commands
* RFC1893 2. Status Codes 5.X.X Permanent Failure
* RFC1893 3.5 Network and Routing Status X.5.0 Other or undefined protocol status
@@ -1114,6 +1163,8 @@
int bSuccess;
char *cp;
+ log0(ctx, INFO, "lmtp_cb_data");
+
/* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 503 Bad sequence of commands
* RFC1893 2. Status Codes 5.X.X Permanent Failure
* RFC1893 3.5 Network and Routing Status X.5.0 Other or undefined protocol status
@@ -1371,11 +1422,14 @@
return LMTP_OK;
}
-static lmtp_rc_t lmtp_cb_noop(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *ctx)
+static lmtp_rc_t lmtp_cb_noop(lmtp_t *lmtp, lmtp_io_t *io, lmtp_req_t *req, void *_ctx)
{
+ lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx;
lmtp_res_t res;
lmtp_rc_t rc = LMTP_OK;
+ log0(ctx, INFO, "lmtp_cb_noop");
+
/* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 250 Requested mail action okay, completed
* RFC1893 2. Status Codes 2.X.X Success
* RFC1893 3.5 Network and Routing Status X.0.0 Other undefined Status
@@ -1393,6 +1447,8 @@
lmtp_res_t res;
lmtp_rc_t rc = LMTP_OK;
+ log0(ctx, INFO, "lmtp_cb_rset");
+
lmtp_gfs_rset(ctx);
/* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 250 Requested mail action okay, completed
@@ -1421,6 +1477,8 @@
lmtp_res_t res;
lmtp_rc_t rc = LMTP_EOF;
+ log0(ctx, INFO, "lmtp_cb_quit");
+
lmtp_gfs_quit(ctx);
/* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 221 <domain> Service closing transmission channel
|