OSSP CVS Repository

ossp - Check-in [1189]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1189
Date: 2001-Oct-15 14:48:57 (local)
2001-Oct-15 12:48:57 (UTC)
User:thl
Branch:
Comment: Remember text from last NNTP error message and pass it back to LMTP
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/00TODO      1.42 -> 1.43     0 inserted, 2 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.92 -> 1.93     3 inserted, 1 deleted
ossp-pkg/lmtp2nntp/nntp.c      1.26 -> 1.27     31 inserted, 9 deleted
ossp-pkg/lmtp2nntp/nntp.h      1.12 -> 1.13     1 inserted, 0 deleted

ossp-pkg/lmtp2nntp/00TODO 1.42 -> 1.43

--- 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)


ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.92 -> 1.93

--- 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);
             }
         }


ossp-pkg/lmtp2nntp/nntp.c 1.26 -> 1.27

--- 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 <message-id>
@@ -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)


ossp-pkg/lmtp2nntp/nntp.h 1.12 -> 1.13

--- 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);

CVSTrac 2.0.1