Removed support for MMDF-style mail drops.
authormarkus schnalke <meillo@marmaro.de>
Sat, 28 Jan 2012 19:40:31 +0000 (20:40 +0100)
committermarkus schnalke <meillo@marmaro.de>
Sat, 28 Jan 2012 19:40:31 +0000 (20:40 +0100)
I'm not sure yet if I've removed all of it but it should be most of it.

acconfig.h
h/dropsbr.h
man/mh-chart.man1
man/packf.man1
man/rcvpack.man1
man/slocal.man1
uip/dropsbr.c
uip/inc.c
uip/packf.c
uip/rcvpack.c
uip/slocal.c

index e4361e0..43e4ad8 100644 (file)
 #define RPATHS  1
 
 /*
- * If defined, slocal will use `mbox' format when saving to
- * your standard mail spool.  If not defined, it will use
- * mmdf format.
- */
-#define SLOCAL_MBOX  1
-
-/*
  * Compile simple ftp client into mhshow/mhstore.  This will be used by
  * mhshow/mhstore for ftp access unless you have specified another access
  * method in your .mh_profile or mhn.defaults.  Use the "nmh-access-ftp"
index b32d316..2349dbb 100644 (file)
@@ -3,53 +3,8 @@
 */
 
 /*
-** A file which is formatted like a maildrop may have a corresponding map
-** file which is an index to the bounds of each message.  The first record
-** of such an map is special, it contains:
-**
-**      d_id    = number of messages in file
-**      d_size  = version number of map
-**      d_start = last message read
-**      d_stop  = size of file
-**
-**  Each record after that contains:
-**
-**      d_id    = BBoard-ID: of message, or similar info
-**      d_size  = size of message in ARPA Internet octets (\n == 2 octets)
-**      d_start = starting position of message in file
-**      d_stop  = stopping position of message in file
-**
-** Note that d_start/d_stop do NOT include the message delimiters, so
-** programs using the map can simply fseek to d_start and keep reading
-** until the position is at d_stop.
-*/
-
-/*
-** various formats for maildrop files
-*/
-#define OTHER_FORMAT 0
-#define MBOX_FORMAT  1
-#define MMDF_FORMAT  2
-
-#define DRVRSN 3
-
-struct drop {
-       int   d_id;
-       int   d_size;
-       off_t d_start;
-       off_t d_stop;
-};
-
-/*
 ** prototypes
 */
-int mbx_open(char *, int, uid_t, gid_t, mode_t);
-int mbx_read(FILE *, long, struct drop **, int);
-int mbx_write(char *, int, FILE *, int, long, long, off_t, int, int);
-int mbx_copy(char *, int, int, int, int, char *, int);
-int mbx_size(int, off_t, off_t);
+int mbx_open(char *, uid_t, gid_t, mode_t);
+int mbx_copy(char *, int, int, char *, int);
 int mbx_close(char *, int);
-char *map_name(char *);
-int map_read(char *, long, struct drop **, int);
-int map_write(char *, int, int, long, off_t, off_t, long, int, int);
-int map_chk(char *, int, struct drop *, long, int);
index 8eac96f..d4e5501 100644 (file)
@@ -394,8 +394,6 @@ or
 .RI [ msgs ]
 .RB [ \-file
 .IR name ]
-.RB [ \-mbox ]
-.RB [ \-mmdf ]
 .RB [ \-version ]
 .RB [ \-help ]
 
@@ -487,8 +485,6 @@ or
 .HP 5
 .B %libdir%/rcvpack
 .I file
-.RB [ \-mbox ]
-.RB [ \-mmdf ]
 .RB [ \-version ]
 .RB [ \-help ]
 
index f0e6a3d..79dccac 100644 (file)
@@ -12,8 +12,6 @@ packf \- pack messages in nmh folder into a single file
 .RI [ msgs ]
 .RB [ \-file
 .IR name ]
-.RB [ \-mbox ]
-.RB [ \-mmdf ]
 .RB [ \-version ]
 .RB [ \-help ]
 .ad
@@ -21,18 +19,8 @@ packf \- pack messages in nmh folder into a single file
 .B Packf
 will pack copies of messages from a folder, into a single
 file.
-.PP
-If the
-.B \-mbox
-switch is given (the default), then the messages are
-separated using mbox (uucp) style delimiters.  This is the format used
-by most mail clients (elm, mailx, etc.).
-.PP
-If the
-.B \-mmdf
-switch is given, then the messages are separated by
-mmdf style delimiters.  Each message in the file is separated by four
-CTRL\-A's and a newline.
+The messages are separated using mbox (uucp) style delimiters.
+This is the format used by most mail clients (elm, mailx, etc.).
 .PP
 You may specify the name of the file in which to use with the
 .B \-file
@@ -63,7 +51,6 @@ can be unpacked using
 .nf
 .ta \w'%etcdir%/ExtraBigFileName  'u
 ^$HOME/.mmh/profile~^The user profile
-^\&.msgbox\&.map~^A binary index of the file
 .fi
 
 .SH "PROFILE COMPONENTS"
@@ -83,7 +70,6 @@ inc(1)
 .nf
 .RB ` +folder "' defaults to the current folder"
 .RB ` msgs "' defaults to all"
-.RB ` \-mbox '
 .RB ` "\-file ./msgbox" '
 .fi
 
index ca00d6b..8c9da9e 100644 (file)
@@ -9,8 +9,6 @@ rcvpack \- append message to file
 .na
 .B %libdir%/rcvpack
 .I file
-.RB [ \-mbox ]
-.RB [ \-mmdf ]
 .RB [ \-version ]
 .RB [ \-help ]
 .ad
@@ -20,17 +18,8 @@ The
 program will append a copy of the message to the file
 listed on its command line.
 .PP
-If the
-.B \-mbox
-switch is given (the default), then the messages are
-separated using mbox (uucp) style delimiters.  This is the format used
-by most mail clients (elm, mailx, etc.).
-.PP
-If the
-.B \-mmdf
-switch is given, then the messages are separated by
-mmdf style delimiters.  Each message in the file is separated by four
-CTRL\-A's and a newline.
+The messages are separated using mbox (uucp) style delimiters.
+This is the format used by most mail clients (elm, mailx, etc.).
 .PP
 .B rcvpack
 will correctly lock and unlock the file to serialize
index cc822f0..bf6c210 100644 (file)
@@ -202,11 +202,6 @@ appended to the file in mbox (uucp) format.  This is the format used by most
 other mail clients (such as mailx, elm).  If the message can be appended to
 the file, then this action succeeds.
 .TP 4
-.I mmdf
-Identical to
-.IR file ,
-but always appends the message using the MMDF mailbox format.
-.TP 4
 .IR pipe " or " |
 Pipe the message as the standard input to the command named by
 .IR string ,
index 8681277..007186e 100644 (file)
 # include <errno.h>
 #endif
 
-#ifdef NTOHLSWAP
-# include <netinet/in.h>
-#else
-# undef ntohl
-# define ntohl(n) (n)
-#endif
-
 #include <fcntl.h>
 
-/*
-** static prototypes
-*/
-static int mbx_chk_mbox(int);
-static int mbx_chk_mmdf(int);
-static int map_open(char *, int);
-
 
 /*
 ** Main entry point to open/create and lock
 ** a file or maildrop.
 */
-
 int
-mbx_open(char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
+mbx_open(char *file, uid_t uid, gid_t gid, mode_t mode)
 {
        int j, count, fd;
        struct stat st;
@@ -82,12 +67,10 @@ mbx_open(char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
        ** Return if we still failed after 4 attempts,
        ** or we just want to skip the sanity checks.
        */
-       if (fd == NOTOK || mbx_style == OTHER_FORMAT)
+       if (fd == NOTOK)
                return fd;
 
-       /*
-       ** Do sanity checks on maildrop.
-       */
+       /* Do sanity checks on maildrop. */
        if (fstat(fd, &st) == NOTOK) {
                /*
                ** The stat failed.  So we make sure file
@@ -98,16 +81,11 @@ mbx_open(char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
        } else if (st.st_size > (off_t) 0) {
                int status;
 
-               /* check the maildrop */
-               switch (mbx_style) {
-               case MMDF_FORMAT:
-               default:
-                       status = mbx_chk_mmdf(fd);
-                       break;
-
-               case MBOX_FORMAT:
-                       status = mbx_chk_mbox(fd);
-                       break;
+               /* Check/prepare MBOX style maildrop for appending. */
+               if (lseek(fd, (off_t) 0, SEEK_END) == (off_t) NOTOK) {
+                       status = NOTOK;
+               } else {
+                       status = OK;
                }
 
                /* if error, attempt to close it */
@@ -121,355 +99,116 @@ mbx_open(char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
 }
 
 
-/*
-** Check/prepare MBOX style maildrop for appending.
-*/
-
-static int
-mbx_chk_mbox(int fd)
-{
-       /* just seek to the end */
-       if (lseek(fd, (off_t) 0, SEEK_END) == (off_t) NOTOK)
-               return NOTOK;
-
-       return OK;
-}
-
-
-/*
-** Check/prepare MMDF style maildrop for appending.
-*/
-
-static int
-mbx_chk_mmdf(int fd)
-{
-       size_t count;
-       char ldelim[BUFSIZ];
-
-       count = strlen(mmdlm2);
-
-       /* casting -count to off_t, seem to break FreeBSD 2.2.6 */
-       if (lseek(fd, (long) (-count), SEEK_END) == (off_t) NOTOK)
-               return NOTOK;
-       if (read(fd, ldelim, count) != count)
-               return NOTOK;
-
-       ldelim[count] = 0;
-
-       if (strcmp(ldelim, mmdlm2)!=0 && write(fd, "\n", 1) != 1
-                       && write(fd, mmdlm2, count) != count)
-               return NOTOK;
-
-       return OK;
-}
-
-
-int
-mbx_read(FILE *fp, long pos, struct drop **drops, int noisy)
-{
-       register int len, size;
-       register long ld1, ld2;
-       register char *bp;
-       char buffer[BUFSIZ];
-       register struct drop *cp, *dp, *ep, *pp;
-
-       pp = (struct drop *) calloc((size_t) (len = MAXFOLDER), sizeof(*dp));
-       if (pp == NULL) {
-               if (noisy)
-                       admonish(NULL, "unable to allocate drop storage");
-               return NOTOK;
-       }
-
-       ld1 = (long) strlen(mmdlm1);
-       ld2 = (long) strlen(mmdlm2);
-
-       fseek(fp, pos, SEEK_SET);
-       for (ep = (dp = pp) + len - 1; fgets(buffer, sizeof(buffer), fp);) {
-               size = 0;
-               if (strcmp(buffer, mmdlm1) == 0)
-                       pos += ld1, dp->d_start = (long) pos;
-               else {
-                       dp->d_start = (long)pos , pos += (long) strlen(buffer);
-                       for (bp = buffer; *bp; bp++, size++)
-                               if (*bp == '\n')
-                                       size++;
-               }
-
-               while (fgets(buffer, sizeof(buffer), fp) != NULL)
-                       if (strcmp(buffer, mmdlm2) == 0)
-                               break;
-                       else {
-                               pos += (long) strlen(buffer);
-                               for (bp = buffer; *bp; bp++, size++)
-                                       if (*bp == '\n')
-                                               size++;
-                       }
-
-               if (dp->d_start != (long) pos) {
-                       dp->d_id = 0;
-                       dp->d_size = (long) size;
-                       dp->d_stop = pos;
-                       dp++;
-               }
-               pos += ld2;
-
-               if (dp >= ep) {
-                       register int curlen = dp - pp;
-
-                       cp = (struct drop *) mh_xrealloc((char *) pp,
-                                       (size_t) (len += MAXFOLDER) *
-                                       sizeof(*pp));
-                       dp = cp + curlen, ep = (pp = cp) + len - 1;
-               }
-       }
-
-       if (dp == pp)
-               free((char *) pp);
-       else
-               *drops = pp;
-       return(dp - pp);
-}
-
-
-int
-mbx_write(char *mailbox, int md, FILE *fp, int id, long last,
-                  long pos, off_t stop, int mapping, int noisy)
-{
-       register int i, j, size;
-       off_t start;
-       long off;
-       register char *cp;
-       char buffer[BUFSIZ];
-
-       off = (long) lseek(md, (off_t) 0, SEEK_CUR);
-       j = strlen(mmdlm1);
-       if (write(md, mmdlm1, j) != j)
-               return NOTOK;
-       start = lseek(md, (off_t) 0, SEEK_CUR);
-       size = 0;
-
-       fseek(fp, pos, SEEK_SET);
-       while (fgets(buffer, sizeof(buffer), fp) && (pos < stop)) {
-               i = strlen(buffer);
-               for (j = 0; (j = stringdex(mmdlm1, buffer)) >= 0; buffer[j]++)
-                       continue;
-               for (j = 0; (j = stringdex(mmdlm2, buffer)) >= 0; buffer[j]++)
-                       continue;
-               if (write(md, buffer, i) != i)
-                       return NOTOK;
-               pos += (long) i;
-               if (mapping)
-                       for (cp = buffer; i-- > 0; size++)
-                               if (*cp++ == '\n')
-                                       size++;
-       }
-
-       stop = lseek(md, (off_t) 0, SEEK_CUR);
-       j = strlen(mmdlm2);
-       if (write(md, mmdlm2, j) != j)
-               return NOTOK;
-       if (mapping)
-               map_write(mailbox, md, id, last, start, stop, off, size,
-                               noisy);
-
-       return OK;
-}
-
 
 /*
 ** Append message to end of file or maildrop.
 */
-
 int
-mbx_copy(char *mailbox, int mbx_style, int md, int fd, int mapping,
-               char *text, int noisy)
+mbx_copy(char *mailbox, int md, int fd, char *text, int noisy)
 {
-       int i, j, size;
+       int i, j;
        off_t start, stop;
        long pos;
-       char *cp, buffer[BUFSIZ];
+       char buffer[BUFSIZ];
        FILE *fp;
 
        pos = (long) lseek(md, (off_t) 0, SEEK_CUR);
-       size = 0;
-
-       switch (mbx_style) {
-       case MMDF_FORMAT:
-       default:
-               j = strlen(mmdlm1);
-               if (write(md, mmdlm1, j) != j)
-                       return NOTOK;
-               start = lseek(md, (off_t) 0, SEEK_CUR);
-
-               if (text) {
-                       i = strlen(text);
-                       if (write(md, text, i) != i)
-                               return NOTOK;
-                       for (cp = text; *cp++; size++)
-                               if (*cp == '\n')
-                                       size++;
-               }
-
-               while ((i = read(fd, buffer, sizeof(buffer))) > 0) {
-                       for (j = 0; (j = stringdex(mmdlm1, buffer)) >= 0; buffer[j]++)
-                               continue;
-                       for (j = 0; (j = stringdex(mmdlm2, buffer)) >= 0; buffer[j]++)
-                               continue;
-                       if (write(md, buffer, i) != i)
-                               return NOTOK;
-                       if (mapping)
-                               for (cp = buffer; i-- > 0; size++)
-                                       if (*cp++ == '\n')
-                                               size++;
-               }
 
-               stop = lseek(md, (off_t) 0, SEEK_CUR);
-               j = strlen(mmdlm2);
-               if (write(md, mmdlm2, j) != j)
-                       return NOTOK;
-               if (mapping)
-                       map_write(mailbox, md, 0, (long) 0, start, stop, pos,
-                                       size, noisy);
-
-               return (i != NOTOK ? OK : NOTOK);
+       if ((j = dup(fd)) == NOTOK)
+               return NOTOK;
+       if ((fp = fdopen(j, "r")) == NULL) {
+               close(j);
+               return NOTOK;
+       }
+       start = lseek(md, (off_t) 0, SEEK_CUR);
 
-       case MBOX_FORMAT:
-               if ((j = dup(fd)) == NOTOK)
+       /* If text is given, we add it to top of message */
+       if (text) {
+               i = strlen(text);
+               if (write(md, text, i) != i)
                        return NOTOK;
-               if ((fp = fdopen(j, "r")) == NULL) {
-                       close(j);
-                       return NOTOK;
-               }
-               start = lseek(md, (off_t) 0, SEEK_CUR);
-
-               /* If text is given, we add it to top of message */
-               if (text) {
-                       i = strlen(text);
-                       if (write(md, text, i) != i)
-                               return NOTOK;
-                       for (cp = text; *cp++; size++)
-                               if (*cp == '\n')
-                                       size++;
-               }
+       }
 
-               for (j = 0; fgets(buffer, sizeof(buffer), fp) != NULL; j++) {
+       for (j = 0; fgets(buffer, sizeof(buffer), fp) != NULL; j++) {
+               /*
+               ** Check the first line, and make some changes.
+               */
+               if (j == 0 && !text) {
                        /*
-                       ** Check the first line, and make some changes.
+                       ** Change the "Return-Path:" field
+                       ** (if in first line) back to "From ".
                        */
-                       if (j == 0 && !text) {
+                       if (strncmp(buffer, "Return-Path:", 12)==0) {
+                               char tmpbuffer[BUFSIZ];
+                               char *tp, *ep, *fp;
+
+                               strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
+                               ep = tmpbuffer + 13;
+                               if (!(fp = strchr(ep + 1, ' ')))
+                                       fp = strchr(ep + 1, '\n');
+                               tp = dctime(dlocaltimenow());
+                                       snprintf(buffer, sizeof(buffer),
+                                                       "From %.*s  %s",
+                                                       (int)(fp-ep), ep, tp);
+                       } else if (strncmp(buffer, "X-Envelope-From:",
+                                       16)==0) {
                                /*
-                               ** Change the "Return-Path:" field
-                               ** (if in first line) back to "From ".
+                               ** Change the "X-Envelope-From:" field
+                               ** (if first line) back to "From ".
                                */
-                               if (strncmp(buffer, "Return-Path:", 12)==0) {
-                                       char tmpbuffer[BUFSIZ];
-                                       char *tp, *ep, *fp;
-
-                                       strncpy(tmpbuffer, buffer,
-                                                       sizeof(tmpbuffer));
-                                       ep = tmpbuffer + 13;
-                                       if (!(fp = strchr(ep + 1, ' ')))
-                                               fp = strchr(ep + 1, '\n');
-                                       tp = dctime(dlocaltimenow());
-                                               snprintf(buffer, sizeof(buffer), "From %.*s  %s", (int)(fp - ep), ep, tp);
-                               } else if (strncmp(buffer, "X-Envelope-From:",
-                                               16)==0) {
-                                       /*
-                                       ** Change the "X-Envelope-From:"
-                                       ** field (if first line) back
-                                       ** to "From ".
-                                       */
-                                       char tmpbuffer[BUFSIZ];
-                                       char *ep;
-
-                                       strncpy(tmpbuffer, buffer,
-                                                       sizeof(tmpbuffer));
-                                       ep = tmpbuffer + 17;
-                                       snprintf(buffer, sizeof(buffer),
-                                                       "From %s", ep);
-                               } else if (strncmp(buffer, "From ", 5)!=0) {
-                                       /*
-                                       ** If there is already a "From "
-                                       ** line, then leave it alone.
-                                       ** Else we add one.
-                                       */
-                                       char tmpbuffer[BUFSIZ];
-                                       char *tp, *ep;
-
-                                       strncpy(tmpbuffer, buffer,      
-                                                       sizeof(tmpbuffer));
-                                       ep = "nobody@nowhere";
-                                       tp = dctime(dlocaltimenow());
-                                       snprintf(buffer, sizeof(buffer),
-                                                       "From %s  %s%s",
-                                                       ep, tp, tmpbuffer);
-                               }
+                               char tmpbuffer[BUFSIZ];
+                               char *ep;
+
+                               strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
+                               ep = tmpbuffer + 17;
+                               snprintf(buffer, sizeof(buffer), "From %s",
+                                               ep);
+                       } else if (strncmp(buffer, "From ", 5)!=0) {
+                               /*
+                               ** If there is already a "From " line,
+                               ** then leave it alone.  Else we add one.
+                               */
+                               char tmpbuffer[BUFSIZ];
+                               char *tp, *ep;
+
+                               strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
+                               ep = "nobody@nowhere";
+                               tp = dctime(dlocaltimenow());
+                               snprintf(buffer, sizeof(buffer),
+                                               "From %s  %s%s", ep, tp,
+                                               tmpbuffer);
                        }
+               }
 
-                       /*
-                       ** If this is not first line, and begins with
-                       ** "From ", then prepend line with ">".
-                       */
-                       if (j != 0 && strncmp(buffer, "From ", 5) == 0) {
-                               write(md, ">", 1);
-                               size++;
-                       }
-                       i = strlen(buffer);
-                       if (write(md, buffer, i) != i) {
-                               fclose(fp);
-                               return NOTOK;
-                       }
-                       if (mapping)
-                               for (cp = buffer; i-- > 0; size++)
-                                       if (*cp++ == '\n')
-                                               size++;
+               /*
+               ** If this is not first line, and begins with "From ",
+               ** then prepend line with ">".
+               */
+               if (j != 0 && strncmp(buffer, "From ", 5) == 0) {
+                       write(md, ">", 1);
                }
-               if (write(md, "\n", 1) != 1) {
+               i = strlen(buffer);
+               if (write(md, buffer, i) != i) {
                        fclose(fp);
                        return NOTOK;
                }
-               if (mapping)
-                       size += 2;
-
-               fclose(fp);
-               lseek(fd, (off_t) 0, SEEK_END);
-               stop = lseek(md, (off_t) 0, SEEK_CUR);
-               if (mapping)
-                       map_write(mailbox, md, 0, (long) 0, start, stop, pos,
-                                       size, noisy);
-
-               return OK;
        }
-}
 
-
-int
-mbx_size(int md, off_t start, off_t stop)
-{
-       register int i, fd;
-       register long pos;
-       register FILE *fp;
-
-       if ((fd = dup(md)) == NOTOK || (fp = fdopen(fd, "r")) == NULL) {
-               if (fd != NOTOK)
-                       close(fd);
+       if (write(md, "\n", 1) != 1) {
+               fclose(fp);
                return NOTOK;
        }
-
-       fseek(fp, start, SEEK_SET);
-       for (i = 0, pos = stop - start; pos-- > 0; i++)
-               if (fgetc(fp) == '\n')
-                       i++;
-
        fclose(fp);
-       return i;
+       lseek(fd, (off_t) 0, SEEK_END);
+       stop = lseek(md, (off_t) 0, SEEK_CUR);
+
+       return OK;
 }
 
 
 /*
 ** Close and unlock file/maildrop.
 */
-
 int
 mbx_close(char *mailbox, int md)
 {
@@ -477,251 +216,3 @@ mbx_close(char *mailbox, int md)
                return OK;
        return NOTOK;
 }
-
-
-/*
-** This function is performed implicitly by getbbent.c:
-**     bb->bb_map = map_name(bb->bb_file);
-*/
-
-char *
-map_name(char *file)
-{
-       register char *cp, *dp;
-       static char buffer[BUFSIZ];
-
-       if ((dp = strchr(cp = mhbasename(file), '.')) == NULL)
-               dp = cp + strlen(cp);
-       if (cp == file)
-               snprintf(buffer, sizeof(buffer), ".%.*s%s",
-                               (int)(dp - cp), cp, ".map");
-       else
-               snprintf (buffer, sizeof(buffer), "%.*s.%.*s%s",
-                               (int)(cp - file), file, (int)(dp - cp),
-                               cp, ".map");
-
-       return buffer;
-}
-
-
-int
-map_read(char *file, long pos, struct drop **drops, int noisy)
-{
-       register int i, md, msgp;
-       register char *cp;
-       struct drop d;
-       register struct drop *mp, *dp;
-
-       if ((md = open(cp = map_name(file), O_RDONLY)) == NOTOK
-                       || map_chk(cp, md, mp = &d, pos, noisy)) {
-               if (md != NOTOK)
-                       close(md);
-               return 0;
-       }
-
-       msgp = mp->d_id;
-       dp = (struct drop *) calloc((size_t) (msgp + 1), sizeof(*dp));
-       if (dp == NULL) {
-               close(md);
-               return 0;
-       }
-
-       memcpy((char *) dp, (char *) mp, sizeof(*dp));
-
-       lseek(md, (off_t) sizeof(*mp), SEEK_SET);
-       if ((i = read(md, (char *) (dp + 1), msgp * sizeof(*dp))) <
-                       sizeof(*dp)) {
-               i = 0;
-               free((char *) dp);
-       } else {
-#ifdef NTOHLSWAP
-               register struct drop *tdp;
-               int j;
-
-               for (j = 0, tdp = dp; j < i / sizeof(*dp); j++, tdp++) {
-                       tdp->d_id = ntohl(tdp->d_id);
-                       tdp->d_size = ntohl(tdp->d_size);
-                       tdp->d_start = ntohl(tdp->d_start);
-                       tdp->d_stop = ntohl(tdp->d_stop);
-               }
-#endif
-               *drops = dp;
-       }
-
-       close(md);
-
-       return (i / sizeof(*dp));
-}
-
-
-int
-map_write(char *mailbox, int md, int id, long last, off_t start,
-                  off_t stop, long pos, int size, int noisy)
-{
-       register int i;
-       int clear, fd, td;
-       char *file;
-       register struct drop *dp;
-       struct drop d1, d2, *rp;
-       register FILE *fp;
-       struct stat st;
-
-       if ((fd = map_open(file = map_name(mailbox), md)) == NOTOK)
-               return NOTOK;
-
-       if ((fstat(fd, &st) == OK) && (st.st_size > 0))
-               clear = 0;
-       else
-               clear = 1;
-
-       if (!clear && map_chk(file, fd, &d1, pos, noisy)) {
-               unlink(file);
-               mbx_close(file, fd);
-               if ((fd = map_open(file, md)) == NOTOK)
-                       return NOTOK;
-               clear++;
-       }
-
-       if (clear) {
-               if ((td = dup(md)) == NOTOK ||
-                               (fp = fdopen(td, "r")) == NULL) {
-                       if (noisy)
-                               admonish(file, "unable to %s", td != NOTOK ?
-                                               "fdopen" : "dup");
-                       if (td != NOTOK)
-                               close(td);
-                       mbx_close(file, fd);
-                       return NOTOK;
-               }
-
-               switch (i = mbx_read(fp, 0, &rp, noisy)) {
-               case NOTOK:
-                       fclose(fp);
-                       mbx_close(file, fd);
-                       return NOTOK;
-
-               case OK:
-                       fclose(fp);
-                       break;
-
-               default:
-                       d1.d_id = 0;
-                       for (dp = rp; i-- >0; dp++) {
-                               if (dp->d_start == start)
-                                       dp->d_id = id;
-                               lseek(fd, (off_t) (++d1.d_id * sizeof(*dp)),
-                                               SEEK_SET);
-                               if (write(fd, (char *)dp, sizeof(*dp)) != sizeof(*dp)) {
-                                       if (noisy)
-                                               admonish(file, "write error");
-                                       mbx_close(file, fd);
-                                       fclose(fp);
-                                       return NOTOK;
-                               }
-                       }
-                       free((char *) rp);
-                       fclose(fp);
-                       break;
-               }
-       } else {
-               if (last == 0)
-                       last = d1.d_start;
-               dp = &d2;
-               dp->d_id = id;
-               dp->d_size = (long) (size ? size : mbx_size(fd, start, stop));
-               dp->d_start = start;
-               dp->d_stop = stop;
-               lseek(fd, (off_t) (++d1.d_id * sizeof(*dp)), SEEK_SET);
-               if (write(fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
-                       if (noisy)
-                               admonish(file, "write error");
-                       mbx_close(file, fd);
-                       return NOTOK;
-               }
-       }
-
-       dp = &d1;
-       dp->d_size = DRVRSN;
-       dp->d_start = (long) last;
-       dp->d_stop = lseek(md, (off_t) 0, SEEK_CUR);
-
-       lseek(fd, (off_t) 0, SEEK_SET);
-       if (write(fd, (char *) dp, sizeof(*dp)) != sizeof(*dp)) {
-               if (noisy)
-                       admonish(file, "write error");
-               mbx_close(file, fd);
-               return NOTOK;
-       }
-
-       mbx_close(file, fd);
-
-       return OK;
-}
-
-
-static int
-map_open(char *file, int md)
-{
-       mode_t mode;
-       struct stat st;
-
-       mode = fstat(md, &st) != NOTOK ?
-                       (mode_t) (st.st_mode & 0777) : m_gmprot();
-       return mbx_open(file, OTHER_FORMAT, st.st_uid, st.st_gid, mode);
-}
-
-
-int
-map_chk(char *file, int fd, struct drop *dp, long pos, int noisy)
-{
-       long count;
-       struct drop d, tmpd;
-       register struct drop *dl;
-
-       if (read(fd, (char *) &tmpd, sizeof(*dp)) != sizeof(*dp)) {
-#ifdef notdef
-               admonish(NULL, "%s: missing or partial index", file);
-#endif /* notdef */
-               return NOTOK;
-       }
-#ifndef NTOHLSWAP
-       *dp = tmpd;  /* if ntohl(n)=(n), can use struct assign */
-#else
-       dp->d_id = ntohl(tmpd.d_id);
-       dp->d_size  = ntohl(tmpd.d_size);
-       dp->d_start = ntohl(tmpd.d_start);
-       dp->d_stop  = ntohl(tmpd.d_stop);
-#endif
-
-       if (dp->d_size != DRVRSN) {
-               if (noisy)
-                       admonish(NULL, "%s: version mismatch (%d != %d)",
-                                       file, dp->d_size, DRVRSN);
-               return NOTOK;
-       }
-
-       if (dp->d_stop != pos) {
-               if (noisy && pos != (long) 0)
-                       admonish(NULL, "%s: pointer mismatch or incomplete index (%ld!=%ld)", file, dp->d_stop, (long) pos);
-               return NOTOK;
-       }
-
-       if ((long) ((dp->d_id + 1) * sizeof(*dp)) != (long) lseek(fd, (off_t) 0, SEEK_END)) {
-               if (noisy)
-                       admonish(NULL, "%s: corrupt index(1)", file);
-               return NOTOK;
-       }
-
-       dl = &d;
-       count = (long) strlen(mmdlm2);
-       lseek(fd, (off_t) (dp->d_id * sizeof(*dp)), SEEK_SET);
-       if (read(fd, (char *) dl, sizeof(*dl)) != sizeof(*dl)
-                       || (ntohl(dl->d_stop) != dp->d_stop
-                               && ntohl(dl->d_stop) + count != dp->d_stop)) {
-               if (noisy)
-                       admonish(NULL, "%s: corrupt index(2)", file);
-               return NOTOK;
-       }
-
-       return OK;
-}
index 6a756d9..e3199c0 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -121,8 +121,6 @@ static FILE *in;
 /*
 ** prototypes
 */
-char *map_name(char *);
-
 static void inc_done(int) NORETURN;
 
 
@@ -497,7 +495,6 @@ main(int argc, char **argv)
                                close(newfd);
                        else
                                admonish(newmail, "error zero'ing");
-                       unlink(map_name(newmail));
                }
        } else if (noisy) {
                printf("%s not zero'd\n", newmail);
index faf199c..071cc3d 100644 (file)
 static struct swit switches[] = {
 #define FILESW  0
        { "file name", 0 },
-#define MBOXSW  1
-       { "mbox", 0 },
-#define MMDFSW  2
-       { "mmdf", 0 },
-#define VERSIONSW  3
+#define VERSIONSW  1
        { "version", 0 },
-#define HELPSW  4
+#define HELPSW  2
        { "help", 0 },
        { NULL, 0 }
 };
 
 static int md = NOTOK;
-static int mbx_style = MBOX_FORMAT;
-static int mapping = 0;
 
 static void mbxclose_done(int) NORETURN;
 
@@ -85,15 +79,6 @@ main(int argc, char **argv)
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                continue;
-
-                       case MBOXSW:
-                               mbx_style = MBOX_FORMAT;
-                               mapping = 0;
-                               continue;
-                       case MMDFSW:
-                               mbx_style = MMDF_FORMAT;
-                               mapping = 1;
-                               continue;
                        }
                }
                if (*cp == '+' || *cp == '@') {
@@ -147,7 +132,7 @@ main(int argc, char **argv)
        seq_setprev(mp);  /* set the previous-sequence */
 
        /* open and lock new maildrop file */
-       if ((md = mbx_open(file, mbx_style, getuid(), getgid(), m_gmprot()))
+       if ((md = mbx_open(file, getuid(), getgid(), m_gmprot()))
                        == NOTOK)
                adios(file, "unable to open");
 
@@ -160,7 +145,7 @@ main(int argc, char **argv)
                                break;
                        }
 
-                       if (mbx_copy(file, mbx_style, md, fd, mapping, NULL, 1)
+                       if (mbx_copy(file, md, fd, NULL, 1)
                                        == NOTOK)
                                adios(file, "error writing to file");
 
index f9687d8..fd1c2aa 100644 (file)
 #include <h/mts.h>
 
 static struct swit switches[] = {
-#define MBOXSW  0
-       { "mbox", 0 },
-#define MMDFSW  1
-       { "mmdf", 0 },
-#define VERSIONSW  2
+#define VERSIONSW  0
        { "version", 0 },
-#define HELPSW  3
+#define HELPSW  1
        { "help", 0 },
        { NULL, 0 }
 };
 
-/*
-** default format in which to save messages
-*/
-static int mbx_style = MBOX_FORMAT;
-
 
 int
 main(int argc, char **argv)
@@ -68,13 +59,6 @@ main(int argc, char **argv)
                        case VERSIONSW:
                                print_version(invo_name);
                                done(1);
-
-                       case MBOXSW:
-                               mbx_style = MBOX_FORMAT;
-                               continue;
-                       case MMDFSW:
-                               mbx_style = MMDF_FORMAT;
-                               continue;
                        }
                }
                if (file)
@@ -89,13 +73,12 @@ main(int argc, char **argv)
        rewind(stdin);
 
        /* open and lock the file */
-       if ((md = mbx_open(file, mbx_style, getuid(), getgid(), m_gmprot()))
+       if ((md = mbx_open(file, getuid(), getgid(), m_gmprot()))
                        == NOTOK)
                done(RCV_MBX);
 
        /* append the message */
-       if (mbx_copy(file, mbx_style, md, fileno(stdin), 1, NULL, 0)
-                       == NOTOK) {
+       if (mbx_copy(file, md, fileno(stdin), NULL, 0) == NOTOK) {
                mbx_close(file, md);
                done(RCV_MBX);
        }
index 85bc52a..a81afa9 100644 (file)
@@ -189,7 +189,7 @@ static void glob(int);
 static struct pair *lookup(struct pair *, char *);
 static int logged_in(void);
 static int timely(char *, char *);
-static int usr_file(int, char *, int);
+static int usr_file(int, char *);
 static int usr_pipe(int, char *, char *, char **, int);
 static int usr_folder(int, char *);
 static RETSIGTYPE alrmser(int);
@@ -457,11 +457,7 @@ localmail(int fd, char *mdlvr)
                verbose_printf("(delivering to standard mail spool)\n");
 
        /* last resort - deliver to standard mail spool */
-#ifdef SLOCAL_MBOX
-       return usr_file(fd, mbox, MBOX_FORMAT);
-#else
-       return usr_file(fd, mbox, MMDF_FORMAT);
-#endif
+       return usr_file(fd, mbox);
 }
 
 
@@ -647,8 +643,7 @@ usr_delivery(int fd, char *delivery, int su)
                case 'f':
                        /* mbox format */
                        if (!mh_strcasecmp(action, "file")) {
-                               status = usr_file(fd, string,
-                                               MBOX_FORMAT);
+                               status = usr_file(fd, string);
                                break;
                        }
                        /* deliver to nmh folder */
@@ -659,19 +654,13 @@ usr_delivery(int fd, char *delivery, int su)
                        break;
 
                case 'm':
-                       /* mmdf format */
-                       if (!mh_strcasecmp(action, "mmdf")) {
-                               status = usr_file(fd, string,
-                                               MMDF_FORMAT);
-                               break;
-                       }
                        /* mbox format */
-                       else if (mh_strcasecmp(action, "mbox"))
+                       if (mh_strcasecmp(action, "mbox"))
                                continue;  /* else fall */
 
                case '>':
                        /* mbox format */
-                       status = usr_file(fd, string, MBOX_FORMAT);
+                       status = usr_file(fd, string);
                        break;
 
                case 'd':
@@ -1059,25 +1048,18 @@ timely(char *t1, char *t2)
 */
 
 static int
-usr_file(int fd, char *mailbox, int mbx_style)
+usr_file(int fd, char *mailbox)
 {
-       int md, mapping;
+       int md;
 
        if (verbose)
                verbose_printf("delivering to file \"%s\"", mailbox);
 
-       if (mbx_style == MBOX_FORMAT) {
-               if (verbose)
-                       verbose_printf(" (mbox style)");
-               mapping = 0;
-       } else {
-               if (verbose)
-                       verbose_printf(" (mmdf style)");
-               mapping = 1;
-       }
+       if (verbose)
+               verbose_printf(" (mbox style)");
 
        /* open and lock the file */
-       if ((md = mbx_open(mailbox, mbx_style, pw->pw_uid, pw->pw_gid,
+       if ((md = mbx_open(mailbox, pw->pw_uid, pw->pw_gid,
                        m_gmprot())) == -1) {
                if (verbose)
                        adorn("", "unable to open:");
@@ -1087,7 +1069,7 @@ usr_file(int fd, char *mailbox, int mbx_style)
        lseek(fd, (off_t) 0, SEEK_SET);
 
        /* append message to file */
-       if (mbx_copy(mailbox, mbx_style, md, fd, mapping, NULL, verbose)
+       if (mbx_copy(mailbox, md, fd, NULL, verbose)
                        == -1) {
                if (verbose)
                        adorn("", "error writing to:");