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
-static char sccsid[] = "@(#)collect.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c 5.15 (Berkeley) %G%";
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':
/*
- 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);
+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 @
*/
* 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> */
char *copyin();
char *detract();
char *expand();
char *copyin();
char *detract();
char *expand();
char *gets();
char *hfield();
char *name1();
char *gets();
char *hfield();
char *name1();
-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"
}
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 */
}
}
/* 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, "~{[*?$`'\"\\"))
+/*
+ * 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.
* 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%
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 */
-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"
* 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;
pid = fork();
if (pid == -1) {
perror("fork");
pid = fork();
if (pid == -1) {
perror("fork");
- (void) remove(deadletter);
- (void) exwrite(deadletter, mtf, 1);
goto out;
}
if (pid == 0) {
goto out;
}
if (pid == 0) {
-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"
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);
- printf("user = %s, deadletter = %s, mailrc = %s\n",
- myname, deadletter, mailrc);
+ printf("user = %s, mailrc = %s\n", myname, mailrc);