DEAD added, mbox changed to MBOX
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 10 Aug 1988 08:57:54 +0000 (00:57 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 10 Aug 1988 08:57:54 +0000 (00:57 -0800)
SCCS-vsn: usr.bin/mail/collect.c 5.15
SCCS-vsn: usr.bin/mail/send.c 5.17
SCCS-vsn: usr.bin/mail/glob.h 5.16
SCCS-vsn: usr.bin/mail/temp.c 5.10
SCCS-vsn: usr.bin/mail/fio.c 5.18
SCCS-vsn: usr.bin/mail/def.h 5.17

usr/src/usr.bin/mail/collect.c
usr/src/usr.bin/mail/def.h
usr/src/usr.bin/mail/fio.c
usr/src/usr.bin/mail/glob.h
usr/src/usr.bin/mail/send.c
usr/src/usr.bin/mail/temp.c

index 2d847c7..9afbe13 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)collect.c  5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c  5.15 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -230,7 +230,7 @@ cont:
                        hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC));
                        break;
                case 'd':
                        hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC));
                        break;
                case 'd':
-                       strcpy(linebuf + 2, deadletter);
+                       strcpy(linebuf + 2, getdeadletter());
                        /* fall into . . . */
                case 'r':
                        /*
                        /* fall into . . . */
                case 'r':
                        /*
@@ -542,23 +542,14 @@ collcont(s)
  */
 collrub(s)
 {
  */
 collrub(s)
 {
-       register FILE *dbuf;
-       register int c;
 
        if (s == SIGINT && hadintr == 0) {
                hadintr = 1;
                longjmp(coljmp, 1);
        }
        rewind(collf);
 
        if (s == SIGINT && hadintr == 0) {
                hadintr = 1;
                longjmp(coljmp, 1);
        }
        rewind(collf);
-       if (s == SIGINT && value("nosave") != NOSTR || fsize(collf) == 0)
-               goto done;
-       if ((dbuf = fopen(deadletter, "w")) == NULL)
-               goto done;
-       chmod(deadletter, 0600);
-       while ((c = getc(collf)) != EOF)
-               putc(c, dbuf);
-       fclose(dbuf);
-done:
+       if (s != SIGINT || value("nosave") == NOSTR)
+               savedeadletter(collf);
        fclose(collf);
        signal(SIGINT, saveint);
        signal(SIGHUP, savehup);
        fclose(collf);
        signal(SIGINT, saveint);
        signal(SIGHUP, savehup);
@@ -572,6 +563,27 @@ done:
                exit(1);
 }
 
                exit(1);
 }
 
+savedeadletter(fp)
+       register FILE *fp;
+{
+       register FILE *dbuf;
+       register int c;
+       char *cp;
+
+       if (fsize(fp) == 0)
+               return;
+       cp = getdeadletter();
+       c = umask(077);
+       dbuf = fopen(cp, "a");
+       umask(c);
+       if (dbuf == NULL)
+               return;
+       while ((c = getc(fp)) != EOF)
+               putc(c, dbuf);
+       fclose(dbuf);
+       rewind(fp);
+}
+
 /*
  * Acknowledge an interrupt signal from the tty by typing an @
  */
 /*
  * Acknowledge an interrupt signal from the tty by typing an @
  */
index 1579998..6627ccc 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)def.h       5.16 (Berkeley) %G%
+ *     @(#)def.h       5.17 (Berkeley) %G%
  */
 
 #include <sys/param.h>         /* includes <sys/types.h> */
  */
 
 #include <sys/param.h>         /* includes <sys/types.h> */
@@ -266,6 +266,7 @@ char        *copy();
 char   *copyin();
 char   *detract();
 char   *expand();
 char   *copyin();
 char   *detract();
 char   *expand();
+char   *getdeadletter();
 char   *gets();
 char   *hfield();
 char   *name1();
 char   *gets();
 char   *hfield();
 char   *name1();
index ef8e67a..c40efe9 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)fio.c      5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)fio.c      5.18 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
@@ -432,7 +432,7 @@ expand(name)
                }
                return savestr(prevfile);
        case '&':
                }
                return savestr(prevfile);
        case '&':
-               if (name[1] == 0 && (name = value("mbox")) == NOSTR)
+               if (name[1] == 0 && (name = value("MBOX")) == NOSTR)
                        name = "~/mbox";
                /* fall through */
        }
                        name = "~/mbox";
                /* fall through */
        }
@@ -442,7 +442,7 @@ expand(name)
        }
        /* catch the most common shell meta character */
        if (name[0] == '~' && (name[1] == '/' || name[1] == '\0')) {
        }
        /* catch the most common shell meta character */
        if (name[0] == '~' && (name[1] == '/' || name[1] == '\0')) {
-               sprintf(xname, "%s/%s", homedir, name + 1);
+               sprintf(xname, "%s%s", homedir, name + 1);
                name = savestr(xname);
        }
        if (!anyof(name, "~{[*?$`'\"\\"))
                name = savestr(xname);
        }
        if (!anyof(name, "~{[*?$`'\"\\"))
@@ -507,6 +507,25 @@ getfold(name)
        return (0);
 }
 
        return (0);
 }
 
+/*
+ * Return the name of the dead.letter file.
+ */
+char *
+getdeadletter()
+{
+       register char *cp;
+
+       if ((cp = value("DEAD")) == NOSTR || (cp = expand(cp)) == NOSTR)
+               cp = expand("~/dead.letter");
+       else if (*cp != '/') {
+               char buf[PATHSIZE];
+
+               (void) sprintf(buf, "~/%s", cp);
+               cp = expand(buf);
+       }
+       return cp;
+}
+
 /*
  * A nicer version of Fdopen, which allows us to fclose
  * without losing the open file.
 /*
  * A nicer version of Fdopen, which allows us to fclose
  * without losing the open file.
index a4dc208..30f2f05 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)glob.h      5.15 (Berkeley) %G%
+ *     @(#)glob.h      5.16 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -41,7 +41,6 @@ FILE  *input;                         /* Current command input file */
 char   mailname[PATHSIZE];             /* Name of current file */
 char   prevfile[PATHSIZE];             /* Name of previous file */
 char   *mailrc;                        /* Name of startup file */
 char   mailname[PATHSIZE];             /* Name of current file */
 char   prevfile[PATHSIZE];             /* Name of previous file */
 char   *mailrc;                        /* Name of startup file */
-char   *deadletter;                    /* Name of #/dead.letter */
 char   *homedir;                       /* Path name of home directory */
 char   *myname;                        /* My login name */
 off_t  mailsize;                       /* Size of system mailbox */
 char   *homedir;                       /* Path name of home directory */
 char   *myname;                        /* My login name */
 off_t  mailsize;                       /* Size of system mailbox */
index e45792d..28b0c66 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)send.c     5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)send.c     5.17 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
@@ -286,13 +286,8 @@ mail1(hp, printheaders)
         * in them which we write to as files directly.
         */
        to = outof(to, mtf, hp);
         * in them which we write to as files directly.
         */
        to = outof(to, mtf, hp);
-       if (senderr) {
-               if (fsize(mtf) != 0) {
-                       (void) remove(deadletter);
-                       (void) exwrite(deadletter, mtf, 1);
-                       rewind(mtf);
-               }
-       }
+       if (senderr)
+               savedeadletter(mtf);
        to = elide(to);
        if (count(to) == 0)
                goto out;
        to = elide(to);
        if (count(to) == 0)
                goto out;
@@ -321,8 +316,7 @@ mail1(hp, printheaders)
        pid = fork();
        if (pid == -1) {
                perror("fork");
        pid = fork();
        if (pid == -1) {
                perror("fork");
-               (void) remove(deadletter);
-               (void) exwrite(deadletter, mtf, 1);
+               savedeadletter(mtf);
                goto out;
        }
        if (pid == 0) {
                goto out;
        }
        if (pid == 0) {
index 16316b7..aa6499f 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)temp.c     5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)temp.c     5.10 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
@@ -71,9 +71,6 @@ tinit()
        homedir = savestr(cp);
        sprintf(buf, "%s/.mailrc", homedir);
        mailrc = savestr(buf);
        homedir = savestr(cp);
        sprintf(buf, "%s/.mailrc", homedir);
        mailrc = savestr(buf);
-       sprintf(buf, "%s/dead.letter", homedir);
-       deadletter = savestr(buf);
        if (debug)
        if (debug)
-               printf("user = %s, deadletter = %s, mailrc = %s\n",
-                       myname, deadletter, mailrc);
+               printf("user = %s, mailrc = %s\n", myname, mailrc);
 }
 }