OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/nntp.c versions 1.26 and 1.27
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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)

CVSTrac 2.0.1