OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp.c 1.22 -> 1.23

--- lmtp.c       2001/09/07 15:02:08     1.22
+++ lmtp.c       2001/10/08 13:40:22     1.23
@@ -66,23 +66,18 @@
     lmtp_io_t         io;       /* select, read, write functions */
     lmtp_readline_t   rl;       /* a function to read in a single line */
     lmtp_dispatch_t **dispatch; /* LMTP commands to be dispatched */
-    int               rfd;      /* file descriptor for reading */
-    int               wfd;      /* file descriptor for writing */
 };
 
-static int lmtp_select(void *ctx, int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+ssize_t lmtp_fd_read(void *_ctx, void *buf, size_t buflen)
 {
-    return select(nfds, rfds, wfds, efds, tv);
+    lmtp_fd_t *ctx = (lmtp_fd_t *)_ctx;
+    return read(ctx->fd, buf, buflen);
 }
 
-static ssize_t lmtp_read(void *ctx, int fd, void *buf, size_t buflen)
+ssize_t lmtp_fd_write(void *_ctx, const void *buf, size_t buflen)
 {
-    return read(fd, buf, buflen);
-}
-
-static ssize_t lmtp_write(void *ctx, int fd, const void *buf, size_t buflen)
-{
-    return write(fd, buf, buflen);
+    lmtp_fd_t *ctx = (lmtp_fd_t *)_ctx;
+    return write(ctx->fd, buf, buflen);
 }
 
 static int verbindex(lmtp_t *lmtp, char *verb)
@@ -108,7 +103,7 @@
     return rc;
 }
 
-lmtp_t *lmtp_create(int rfd, int wfd, lmtp_io_t *io)
+lmtp_t *lmtp_create(lmtp_io_t *io)
 {
     /*  create a lmtp structure allocating memory for it and initializing it.
      *  A lmtp_cb_default() callback is registered for the default "" verb.
@@ -124,23 +119,17 @@
     if ((lmtp = (lmtp_t *)malloc(sizeof(lmtp_t))) == NULL) 
         return NULL;
 
-    if (io == NULL) {
-        lmtp->io.ctx    = NULL;
-        lmtp->io.select = lmtp_select;
-        lmtp->io.read   = lmtp_read;
-        lmtp->io.write  = lmtp_write;
-    } else {
-        lmtp->io.ctx    = io->ctx;
-        lmtp->io.select = io->select ? io->select : lmtp_select;
-        lmtp->io.read   = io->read   ? io->read   : lmtp_read;
-        lmtp->io.write  = io->write  ? io->write  : lmtp_write;
-    }
+    if (io == NULL) 
+        return NULL;
+
+    lmtp->io.ctx    = io->ctx;
+    lmtp->io.select = io->select;
+    lmtp->io.read   = io->read;
+    lmtp->io.write  = io->write;
 
     lmtp->rl.rl_cnt = 0;
     lmtp->rl.rl_bufptr = NULL;
     lmtp->rl.rl_buf[0] = NUL;
-    lmtp->rfd = rfd;
-    lmtp->wfd = wfd;
     
     if ((lmtp->dispatch = (lmtp_dispatch_t **)malloc(sizeof(void *)*LMTP_MAXVERBS)) == NULL)
         return NULL;
@@ -181,7 +170,7 @@
         /* fetch one character (but read more) */
         if (rl->rl_cnt <= 0) {
             do {
-                rl->rl_cnt = lmtp->io.read(lmtp->io.ctx, lmtp->rfd, rl->rl_buf, LMTP_LINE_MAXLEN);
+                rl->rl_cnt = lmtp->io.read(lmtp->io.ctx, rl->rl_buf, LMTP_LINE_MAXLEN);
             } while (rl->rl_cnt == -1 && errno == EINTR);
             if (rl->rl_cnt == -1)
                 return LMTP_ERR_SYSTEM;
@@ -370,7 +359,7 @@
         formatbuf[len++] = '\r';
         formatbuf[len++] = '\n';
         do {
-            rv = lmtp->io.write(lmtp->io.ctx, lmtp->wfd, formatbuf, len);
+            rv = lmtp->io.write(lmtp->io.ctx, formatbuf, len);
         } while (rv == -1 && errno == EINTR);
         if (rv == -1)
             return LMTP_ERR_SYSTEM;

CVSTrac 2.0.1