Index: ossp-pkg/lmtp2nntp/00TODO RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/00TODO,v rcsdiff -q -kk '-r1.42' '-r1.43' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/00TODO,v' 2>/dev/null --- 00TODO 2001/10/15 11:32:07 1.42 +++ 00TODO 2001/10/15 12:48:57 1.43 @@ -11,8 +11,6 @@ Proper cleanup when exiting through signals. - Remember text from last NNTP error message and pass it back to LMTP. - move code out of getopt()-loop split already too large lmtp2nntp.c source into smaller pieces (~ 10-30KB each only) Index: ossp-pkg/lmtp2nntp/lmtp2nntp.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v rcsdiff -q -kk '-r1.92' '-r1.93' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/lmtp2nntp.c,v' 2>/dev/null --- lmtp2nntp.c 2001/10/15 11:26:15 1.92 +++ lmtp2nntp.c 2001/10/15 12:48:57 1.93 @@ -2163,7 +2163,9 @@ argz_add(&azErr, &asErr, errorstring); for (i = 0; i < ctx->nsc; i++) { if (ctx->ns[i].rc != NNTP_OK) { - str_format(errorstring, sizeof(errorstring), "%s:%s returned %s", ctx->ns[i].h, ctx->ns[i].p, nntp_error(ctx->ns[i].rc)); + str_format(errorstring, sizeof(errorstring), + "%s:%s returned %s\nwith last response \"%s\"", + ctx->ns[i].h, ctx->ns[i].p, nntp_error(ctx->ns[i].rc), nntp_lastresp(ctx->ns[i].nntp)); argz_add(&azErr, &asErr, errorstring); } } Index: ossp-pkg/lmtp2nntp/nntp.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/nntp.c,v rcsdiff -q -kk '-r1.26' '-r1.27' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/nntp.c,v' 2>/dev/null --- nntp.c 2001/10/09 12:08:59 1.26 +++ nntp.c 2001/10/15 12:48:57 1.27 @@ -67,6 +67,7 @@ nntp_readline_t rl; struct timeval tv; int kludgeinn441dup; + char *lastresp; }; ssize_t nntp_fd_read(void *_ctx, void *buf, size_t buflen) @@ -97,6 +98,7 @@ nntp->rl.rl_bufptr = NULL; nntp->rl.rl_buf[0] = NUL; nntp->kludgeinn441dup = FALSE; + nntp->lastresp = NULL; return nntp; } @@ -149,11 +151,23 @@ void nntp_destroy(nntp_t *nntp) { - if (nntp != NULL) + if (nntp != NULL) { + if (nntp->lastresp != NULL) + free(nntp->lastresp); free(nntp); + } return; } +char *nntp_lastresp(nntp_t *nntp) +{ + if (nntp == NULL) + return ""; + if(nntp->lastresp == NULL) + return ""; + return nntp->lastresp; +} + nntp_rc_t nntp_readline(nntp_t *nntp, char *buf, size_t buflen) { /* read a line (characters until NL) from input stream */ @@ -254,11 +268,11 @@ * expected and we treat this as an error. */ if (strncmp(line, "201", 3) == 0) - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); if ( strncmp(line, "200", 3) != 0 && strncmp(line, "5" , 1) != 0 ) - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); /* check if this server already knows that artice * > STAT @@ -275,7 +289,7 @@ if (strncmp(line, "223", 3) == 0) return NNTP_OK; if (strncmp(line, "430", 3) != 0) - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); /* post the article * > POST @@ -313,7 +327,7 @@ if ((rc = nntp_readline(nntp, line, sizeof(line))) != NNTP_OK) return rc; if (strncmp(line, "340", 3) != 0) - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); do { rc = nntp->io.write(nntp->io.ctx, msg->cpMsg, strlen(msg->cpMsg)); @@ -336,7 +350,11 @@ return NNTP_OK; } - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); + + CUS: + nntp->lastresp = strdup(line); + return rc; } nntp_rc_t nntp_feed(nntp_t *nntp, msg_t *msg) @@ -377,10 +395,10 @@ if ( (strncmp(line, "437", 3) == 0) || (strncmp(line, "480", 3) == 0)) - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); if (strncmp(line, "335", 3) != 0) - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); do { rc = nntp->io.write(nntp->io.ctx, msg->cpMsg, strlen(msg->cpMsg)); @@ -397,7 +415,11 @@ if (strncmp(line, "436", 3) == 0) return NNTP_DEFER; - return NNTP_ERR_DELIVERY; + CU(NNTP_ERR_DELIVERY); + + CUS: + nntp->lastresp = strdup(line); + return rc; } char *nntp_error(nntp_rc_t rc) Index: ossp-pkg/lmtp2nntp/nntp.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/nntp.h,v rcsdiff -q -kk '-r1.12' '-r1.13' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/nntp.h,v' 2>/dev/null --- nntp.h 2001/10/09 12:08:59 1.12 +++ nntp.h 2001/10/15 12:48:57 1.13 @@ -66,6 +66,7 @@ nntp_rc_t nntp_writeline(nntp_t *, char *); nntp_rc_t nntp_post (nntp_t *, msg_t *msg); nntp_rc_t nntp_feed (nntp_t *, msg_t *msg); +char *nntp_lastresp (nntp_t *nntp); char *nntp_error (nntp_rc_t); ssize_t nntp_fd_read (void *, void *, size_t); ssize_t nntp_fd_write (void *, const void *, size_t);