]> diplodocus.org Git - nmh/blobdiff - uip/dropsbr.c
showfile.c: Move interface to own file.
[nmh] / uip / dropsbr.c
index a36d145b8b279c7dc7d3a73c466ec8d5dc5bd6fc..733e6e6e4701681d4bdb5873b8e78e85cc2d0da5 100644 (file)
@@ -5,23 +5,16 @@
  * complete copyright information.
  */
 
-#include <h/nmh.h>
-#include <h/utils.h>
-
-#include <h/mh.h>
-#include <h/dropsbr.h>
-#include <h/mts.h>
-#include <h/tws.h>
-#include "../sbr/lock_file.h"
-#include "../sbr/m_mktemp.h"
-
-#ifdef NTOHLSWAP
-# include <netinet/in.h>
-#else
-# undef ntohl
-# define ntohl(n) (n)
-#endif
-
+#include "h/nmh.h"
+#include "h/mh.h"
+#include "sbr/strindex.h"
+#include "sbr/error.h"
+#include "h/utils.h"
+#include "h/dropsbr.h"
+#include "h/mts.h"
+#include "h/tws.h"
+#include "sbr/lock_file.h"
+#include "sbr/m_mktemp.h"
 #include <fcntl.h>
 
 /*
@@ -133,7 +126,7 @@ mbx_chk_mmdf (int fd)
     ssize_t count;
     char ldelim[BUFSIZ];
 
-    count = strlen (mmdlm2);
+    count = LEN(MMDF_DELIM);
 
     if (lseek (fd, -count, SEEK_END) == (off_t) NOTOK)
        return NOTOK;
@@ -142,9 +135,9 @@ mbx_chk_mmdf (int fd)
 
     ldelim[count] = 0;
 
-    if (strcmp (ldelim, mmdlm2)
+    if (strcmp (ldelim, MMDF_DELIM)
            && write (fd, "\n", 1) != 1
-           && write (fd, mmdlm2, count) != count)
+           && write (fd, MMDF_DELIM, count) != count)
        return NOTOK;
 
     return OK;
@@ -168,8 +161,8 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd,
     switch (mbx_style) {
        case MMDF_FORMAT: 
        default: 
-           j = strlen (mmdlm1);
-           if (write (md, mmdlm1, j) != j)
+           j = LEN(MMDF_DELIM);
+           if (write (md, MMDF_DELIM, j) != j)
                return NOTOK;
 
            if (text) {
@@ -184,19 +177,19 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd,
            while ((i = read (fd, buffer, sizeof buffer - 1)) > 0) {
                 buffer[i] = '\0';   /* Terminate for stringdex(). */
 
-               for ( ; (j = stringdex (mmdlm1, buffer)) >= 0; buffer[j]++)
+               for ( ; (j = stringdex (MMDF_DELIM, buffer)) >= 0; buffer[j]++)
                    continue;
-               for ( ; (j = stringdex (mmdlm2, buffer)) >= 0; buffer[j]++)
+               for ( ; (j = stringdex (MMDF_DELIM, buffer)) >= 0; buffer[j]++)
                    continue;
                if (write (md, buffer, i) != i)
                    return NOTOK;
            }
 
-           j = strlen (mmdlm2);
-           if (write (md, mmdlm2, j) != j)
+           j = LEN(MMDF_DELIM);
+           if (write (md, MMDF_DELIM, j) != j)
                return NOTOK;
 
-           return (i != NOTOK ? OK : NOTOK);
+            return i == NOTOK ? NOTOK : OK;
 
        case MBOX_FORMAT:
            if ((j = dup (fd)) == NOTOK)