OSSP CVS Repository

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

ossp-pkg/lmtp2nntp/lmtp.c 1.4 -> 1.5

--- lmtp.c       2001/07/25 11:29:38     1.4
+++ lmtp.c       2001/07/25 15:02:57     1.5
@@ -22,7 +22,6 @@
     int i;
 
     printf("lmtp         = %ld   \n", (long)lmtp);
-    printf("io.select    = %ld   \n", (long)lmtp->io.select);       
     printf("io.read      = %ld   \n", (long)lmtp->io.read);       
     printf("io.write     = %ld   \n", (long)lmtp->io.write);       
     printf("rl.cnt       = %d   \n", lmtp->rl.rl_cnt);
@@ -98,8 +97,8 @@
 {
     /*  create a lmtp structure allocating memory for it and initializing it.
      *  A lmtp_cb_default() callback is registered for the default "" verb.
-     *  The _rfd_ and _wfd_ args are passed to the read(), write() and
-     *  select() functions and must have meaning for them. If _io_ is NULL,
+     *  The _rfd_ and _wfd_ args are passed to the read(), write() 
+     *  functions and must have meaning for them. If _io_ is NULL,
      *  the system io functions are used. You can provide an _io_ structure
      *  and specify alternate functions. Ommiting one or more functions inside
      *  the _io_ structure by NULLing it causes use of the system default
@@ -111,11 +110,9 @@
         return NULL;
 
     if(io == NULL) {
-        lmtp->io.select = select;
         lmtp->io.read   = read;
         lmtp->io.write  = write;
     } else {
-        lmtp->io.select = io->select ? io->select : select;
         lmtp->io.read   = io->read   ? io->read   : read;
         lmtp->io.write  = io->write  ? io->write  : write;
     }
@@ -138,18 +135,8 @@
 void lmtp_destroy(lmtp_t *lmtp)
 {
     int i;
-    lmtp_msg_t *msg;
-    lmtp_msg_t *next;
-
-    //_readmsg : if ((cpBuf = (char *)malloc(nBuf)) == NULL)
 
     for (i = 0; (i < LMTP_MAXVERBS) && (lmtp->dispatch[i] != NULL); i++) {
-        msg  = lmtp->dispatch[i]->msg;
-        do {
-            next = lmtp->dispatch[i]->msg->next;
-            free(msg);              /* linked messages */
-            msg  = next;
-        } while(next != NULL);
         free(lmtp->dispatch[i]);    /* lmtp_register() */
     }
     free(lmtp->dispatch);           /* lmtp_create() */
@@ -175,7 +162,8 @@
 
 lmtp_rc_t lmtp_readmsg(lmtp_t *lmtp, char **cppBuf, size_t maxlen)
 {
-    /*  read lines until end of message, unescape dots
+    /*  read lines until end of message, unescape dots.
+     *  on success, returns a buffer which has to be free(3)d by the caller
      *
      *  NOTE: the lmtp_readline()'s underlying readline() already reduces any
      *        CR/LF combination to a string terminating zero. Callers of this
@@ -192,6 +180,7 @@
 
     lmtp_rc_t rc = LMTP_OK;
     char *cpBuf;       /* buffer as a whole */
+    char *cpBufrealloc;/* buffer before realloc */
     char *cpPtr;       /* write cursor */
     char *cpLine;      /* start of the current line (see offsetline) */
     size_t nBuf;       /* size of buffer, doubled through realloc until maximum reached */
@@ -211,10 +200,11 @@
             offsetline = cpLine - cpBuf;        /* remember start of line offset */
             nBuf *= 2;                          /* increase buffer */
             if (nBuf > maxlen) nBuf = maxlen;   /* but don't exceed maximum */
-            if ((cpBuf = (char *)realloc(cpBuf, nBuf)) == NULL) {
-                free(cpBuf); //FIXME double check isn't this a destroy() task?  */
+            if ((cpBufrealloc = (char *)realloc(cpBuf, nBuf)) == NULL) {
+                free(cpBuf);
                 return LMTP_ERR_MEM;
             }
+            cpBuf = cpBufrealloc;
             *cppBuf = cpBuf;                    /* tell caller about the new buffer */
             cpPtr = cpBuf + offset;             /* recover write cursor */
             cpLine = cpBuf + offsetline;        /* recover start of line */
@@ -334,23 +324,6 @@
     return rc;
 }
 
-lmtp_msg_t *lmtp_message(lmtp_t *lmtp, char *verb)
-{
-    /*  get the first message attached to a verb's dispatch structure. The
-     *  messages are fifo linked lists.
-     */
-    int i;
-
-    lmtp_msg_t *cpp = NULL;
-    if ((i = verbindex(lmtp, verb)) >= 0) cpp = lmtp->dispatch[i]->msg;
-    return cpp;
-}
-
-void lmtp_reset(lmtp_t *lmtp)
-{
-    return;
-}
-
 char *lmtp_error(lmtp_t *lmtp, lmtp_rc_t rc)
 {
     /*  get an error message matching the given lmtp_rc_t code usually
@@ -358,14 +331,14 @@
      */
     char *str;
 
-                                 str = "LMTP: errorcode has no description";
-    if (rc == LMTP_OK          ) str = "LMTP: no error";
-    if (rc == LMTP_EOF         ) str = "LMTP: eof";
-    if (rc == LMTP_ERR_SYSTEM  ) str = "LMTP: see errno";
-    if (rc == LMTP_ERR_MEM     ) str = "LMTP: dynamic memory allocation failed";
-    if (rc == LMTP_ERR_OVERFLOW) str = "LMTP: static allocated memory exhausted";
-    if (rc == LMTP_ERR_ARG     ) str = "LMTP: invalid arg was passed to function";
-    if (rc == LMTP_ERR_UNKNOWN ) str = "LMTP: guru meditation";
+                                      str = "LMTP: errorcode has no description";
+    if      (rc == LMTP_OK          ) str = "LMTP: no error";
+    else if (rc == LMTP_EOF         ) str = "LMTP: eof";
+    else if (rc == LMTP_ERR_SYSTEM  ) str = "LMTP: see errno";
+    else if (rc == LMTP_ERR_MEM     ) str = "LMTP: dynamic memory allocation failed";
+    else if (rc == LMTP_ERR_OVERFLOW) str = "LMTP: static allocated memory exhausted";
+    else if (rc == LMTP_ERR_ARG     ) str = "LMTP: invalid arg was passed to function";
+    else if (rc == LMTP_ERR_UNKNOWN ) str = "LMTP: guru meditation";
 
     return str;
 }
@@ -419,7 +392,6 @@
     lmtp->dispatch[i]->verb = strdup(verb);
     lmtp->dispatch[i]->cb   = cb;
     lmtp->dispatch[i]->ctx  = ctx;
-    lmtp->dispatch[i]->msg  = NULL;
 
     return rc;
 }

CVSTrac 2.0.1