OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/nntp.c 1.20 -> 1.21

--- nntp.c       2001/09/04 09:46:06     1.20
+++ nntp.c       2001/09/07 15:02:08     1.21
@@ -72,6 +72,21 @@
     int             kludgeinn441dup;
 };
 
+static int nntp_select(void *ctx, int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+{
+    return select(nfds, rfds, wfds, efds, tv);
+}
+
+static ssize_t nntp_read(void *ctx, int fd, void *buf, size_t buflen)
+{
+    return read(fd, buf, buflen);
+}
+
+static ssize_t nntp_write(void *ctx, int fd, const void *buf, size_t buflen)
+{
+    return write(fd, buf, buflen);
+}
+
 nntp_t *nntp_create(int rfd, int wfd, nntp_io_t *io)
 {
     nntp_t *nntp;
@@ -80,13 +95,15 @@
         return NULL;
 
     if (io == NULL) {
-        nntp->io.select = select;
-        nntp->io.read   = read;
-        nntp->io.write  = write;
+        nntp->io.ctx    = NULL;
+        nntp->io.select = nntp_select;
+        nntp->io.read   = nntp_read;
+        nntp->io.write  = nntp_write;
     } else {
-        nntp->io.select = io->select ? io->select : select;
-        nntp->io.read   = io->read   ? io->read   : read;
-        nntp->io.write  = io->write  ? io->write  : write;
+        nntp->io.ctx    = io->ctx;
+        nntp->io.select = io->select ? io->select : nntp_select;
+        nntp->io.read   = io->read   ? io->read   : nntp_read;
+        nntp->io.write  = io->write  ? io->write  : nntp_write;
     }
 
     nntp->rfd = rfd;
@@ -180,13 +197,13 @@
             FD_SET(nntp->rfd, &fds);
             tv.tv_sec  = nntp->tv.tv_sec;
             tv.tv_usec = nntp->tv.tv_usec;
-            rc = nntp->io.select(nntp->rfd + 1, &fds, NULL, NULL, &tv);
+            rc = nntp->io.select(nntp->io.ctx, nntp->rfd + 1, &fds, NULL, NULL, &tv);
             if (rc == 0)
                 return NNTP_TIMEOUT;
             else if (rc == -1)
                 return NNTP_ERR_SYSTEM;
             do {
-                rl->rl_cnt = nntp->io.read(nntp->rfd, rl->rl_buf, NNTP_LINE_MAXLEN);
+                rl->rl_cnt = nntp->io.read(nntp->io.ctx, nntp->rfd, rl->rl_buf, NNTP_LINE_MAXLEN);
             } while (rl->rl_cnt == -1 && errno == EINTR);
             if (rl->rl_cnt == -1)
                 return NNTP_ERR_SYSTEM;
@@ -219,7 +236,7 @@
         return NNTP_ERR_ARG;
     strncpy(tmp, buf, NNTP_LINE_MAXLEN-3);
     strcat(tmp, "\r\n");
-    if (nntp->io.write(nntp->wfd, tmp, strlen(tmp)) < 0)
+    if (nntp->io.write(nntp->io.ctx, nntp->wfd, tmp, strlen(tmp)) < 0)
         return NNTP_ERR_SYSTEM;
     return NNTP_OK;
 }
@@ -334,7 +351,7 @@
         return NNTP_ERR_POST;
 
     do {
-        rc = nntp->io.write(nntp->wfd, msg->cpMsg, strlen(msg->cpMsg));
+        rc = nntp->io.write(nntp->io.ctx, nntp->wfd, msg->cpMsg, strlen(msg->cpMsg));
     } while (rc == -1 && errno == EINTR);
     if (rc == -1)
         return NNTP_ERR_SYSTEM;
@@ -410,7 +427,7 @@
         return NNTP_ERR_POST;
 
     do {
-        rc = nntp->io.write(nntp->wfd, msg->cpMsg, strlen(msg->cpMsg));
+        rc = nntp->io.write(nntp->io.ctx, nntp->wfd, msg->cpMsg, strlen(msg->cpMsg));
     } while (rc == -1 && errno == EINTR);
     if (rc == -1)
         return NNTP_ERR_SYSTEM;

CVSTrac 2.0.1