X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/e6c917710e4318949cb4174cabca51a8d1822dbd..1e03ea3338cc5ccd9ddf4feaaacfeda1998689cc:/uip/dropsbr.c diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 7c8fe246..733e6e6e 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -5,23 +5,16 @@ * complete copyright information. */ -#include -#include - -#include -#include -#include -#include -#include "../sbr/lock_file.h" -#include "../sbr/m_mktemp.h" - -#ifdef NTOHLSWAP -# include -#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 /* @@ -82,7 +75,7 @@ mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode) if (chmod (file, mode) < 0) { advise (file, "chmod"); } - } else if (st.st_size > (off_t) 0) { + } else if (st.st_size > 0) { int status; /* check the maildrop */ @@ -116,7 +109,7 @@ static int mbx_chk_mbox (int fd) { /* just seek to the end */ - if (lseek (fd, (off_t) 0, SEEK_END) == (off_t) NOTOK) + if (lseek(fd, 0, SEEK_END) == (off_t) NOTOK) return NOTOK; return OK; @@ -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) @@ -285,7 +278,7 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, } fclose (fp); - lseek (fd, (off_t) 0, SEEK_END); + lseek(fd, 0, SEEK_END); return OK; }