OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.74 -> 1.75

--- lmtp2nntp.c  2001/10/09 10:34:10     1.74
+++ lmtp2nntp.c  2001/10/09 12:08:58     1.75
@@ -120,6 +120,7 @@
     sa_t           *sa;   /* socket abstraction */
     nntp_t         *nntp;
     nntp_rc_t       rc;
+    l2_stream_t    *l2;
 };
 
 typedef struct {
@@ -230,7 +231,7 @@
         log0(ctx, TRACE, "LMTP read error: %m");
     else
         log3(ctx, TRACE, "LMTP %5d << \"%{text}D\"", rc, buf, rc);
-    log1(ctx, DEBUG, "trace_lmtp_read() return, rc=%d", rc);
+    log1(ctx, DEBUG, "hook_lmtp_read() return, rc=%d", rc);
     return rc;
 }
 
@@ -255,12 +256,17 @@
     return rc;
 }
 
-static ssize_t trace_nntp_read(void *_ctx, int d, void *buf, size_t nbytes)
+static ssize_t hook_nntp_read(void *_ctx, void *buf, size_t nbytes)
 {
-    lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx;
+    struct ns *ctx = (struct ns *)_ctx;
     ssize_t rc;
+    size_t n;
+    sa_rc_t rv;
 
-    rc = read(d, buf, nbytes);
+    if ((rv = sa_read(ctx->sa, buf, nbytes, &n)) != SA_OK)
+        rc = -1;
+    else
+        rc = (ssize_t)n;
     if (rc == -1)
         log0(ctx, TRACE, "NNTP read error: %m");
     else
@@ -268,13 +274,18 @@
     return rc;
 }
 
-static ssize_t trace_nntp_write(void *_ctx, int d, const void *buf, size_t nbytes)
+static ssize_t hook_nntp_write(void *_ctx, const void *buf, size_t nbytes)
 {
-    lmtp2nntp_t *ctx = (lmtp2nntp_t *)_ctx;
+    struct ns *ctx = (struct ns *)_ctx;
     ssize_t rc;
+    size_t n;
+    sa_rc_t rv;
 
     log3(ctx, TRACE, "NNTP %5d >> \"%{text}D\"", nbytes, buf, nbytes);
-    rc = write(d, buf, nbytes);
+    if ((rv = sa_write(ctx->sa, buf, nbytes, &n)) != SA_OK)
+        rc = -1;
+    else
+        rc = (ssize_t)n;
     if (rc == -1)
         log0(ctx, TRACE, "NNTP write error: %m");
     return rc;
@@ -405,6 +416,7 @@
         ctx->ns[i].sa = NULL;
         ctx->ns[i].nntp = NULL;
         ctx->ns[i].rc = LMTP_ERR_UNKNOWN;
+        ctx->ns[i].l2 = NULL;
     }
     ctx->azGroupargs = NULL;
     ctx->asGroupargs = 0;
@@ -981,15 +993,9 @@
     int          bOk;
     int          i;
     nntp_io_t    nntp_io;
-    int          s;
 
     log1(ctx, INFO, "LMTP service executing LHLO command < %s", req->msg);
 
-    nntp_io.ctx    = ctx;
-    nntp_io.select = NULL;
-    nntp_io.read   = trace_nntp_read;
-    nntp_io.write  = trace_nntp_write;
-
     /*  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.0.0   Other undefined Status
@@ -1038,6 +1044,8 @@
         bOk = TRUE;
         log2(ctx, TRACE, "try %s:%s", ctx->ns[i].h, ctx->ns[i].p);
 
+        ctx->ns[i].l2 = ctx->l2;
+
         if (bOk && (ctx->saaBind != NULL)) {
             log2(ctx, DEBUG, "bind local socket to %s:%s", ctx->cpBindh, ctx->cpBindp);
             if (sa_bind(ctx->ns[i].sa, ctx->saaBind) != SA_OK) {
@@ -1062,20 +1070,15 @@
 
         if (bOk) {
             log0(ctx, DEBUG, "nntp_create");
-            sa_getfd(ctx->ns[i].sa, &s);
-            if ((ctx->ns[i].nntp = nntp_create(s, s, 
-                                               (ctx->option_logfile && (ctx->option_levelmask >= L2_LEVEL_TRACE)) ?
-                                                &nntp_io : NULL)) == NULL) {
+            nntp_io.ctx    = &ctx->ns[i];
+            nntp_io.read   = hook_nntp_read;
+            nntp_io.write  = hook_nntp_write;
+            if ((ctx->ns[i].nntp = nntp_create(&nntp_io)) == NULL) {
                 bOk = FALSE;
                 log0(ctx, ERROR, "creation of NNTP context failed");
             }
         }
 
-        if (bOk && ctx->option_timeout_nntp_connect >= 0) {
-            log1(ctx, DEBUG, "nntp_timeout with %d", ctx->option_timeout_nntp_connect);
-            nntp_timeout(ctx->ns[i].nntp, ctx->option_timeout_nntp_connect);
-        }
-
         if (bOk) {
             log0(ctx, DEBUG, "nntp_init");
             if ((rc = nntp_init(ctx->ns[i].nntp)) != NNTP_OK) {
@@ -1730,8 +1733,7 @@
             bSuccess = NNTP_OK;
         if (   bSuccess != NNTP_OK
             && (
-                   (ctx->ns[i].rc == NNTP_TIMEOUT)
-                || (ctx->ns[i].rc == NNTP_ERR_SYSTEM)
+                   (ctx->ns[i].rc == NNTP_ERR_SYSTEM)
                 || (ctx->ns[i].rc == NNTP_DEFER)
                   )
               )

CVSTrac 2.0.1