X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/8fe588923dae8ee40639793c90b42c0b4bf396b7..61fec9fc73ce1a323a68f4bd6c6d96e3e73a5433:/usr/src/usr.bin/mail/cmd3.c diff --git a/usr/src/usr.bin/mail/cmd3.c b/usr/src/usr.bin/mail/cmd3.c index 6e27f66648..e027207cee 100644 --- a/usr/src/usr.bin/mail/cmd3.c +++ b/usr/src/usr.bin/mail/cmd3.c @@ -9,7 +9,7 @@ * Still more user commands. */ -static char *SccsId = "@(#)cmd3.c 1.12 %G%"; +static char *SccsId = "@(#)cmd3.c 2.10 %G%"; /* * Process a shell escape by saving signals, ignoring signals, @@ -30,12 +30,13 @@ shell(str) if ((Shell = value("SHELL")) == NOSTR) Shell = SHELL; for (t = 2; t < 4; t++) - sig[t-2] = signal(t, SIG_IGN); + sig[t-2] = sigset(t, SIG_IGN); t = vfork(); if (t == 0) { + sigchild(); for (t = 2; t < 4; t++) if (sig[t-2] != SIG_IGN) - signal(t, SIG_DFL); + sigsys(t, SIG_DFL); execl(Shell, Shell, "-c", cmd, 0); perror(Shell); _exit(1); @@ -45,7 +46,7 @@ shell(str) if (t == -1) perror("fork"); for (t = 2; t < 4; t++) - signal(t, sig[t-2]); + sigset(t, sig[t-2]); printf("!\n"); return(0); } @@ -63,12 +64,13 @@ dosh(str) if ((Shell = value("SHELL")) == NOSTR) Shell = SHELL; for (t = 2; t < 4; t++) - sig[t-2] = signal(t, SIG_IGN); + sig[t-2] = sigset(t, SIG_IGN); t = vfork(); if (t == 0) { + sigchild(); for (t = 2; t < 4; t++) if (sig[t-2] != SIG_IGN) - signal(t, SIG_DFL); + sigsys(t, SIG_DFL); execl(Shell, Shell, 0); perror(Shell); _exit(1); @@ -78,7 +80,7 @@ dosh(str) if (t == -1) perror("fork"); for (t = 2; t < 4; t++) - signal(t, sig[t-2]); + sigsys(t, sig[t-2]); putchar('\n'); return(0); } @@ -147,7 +149,7 @@ help() register FILE *f; if ((f = fopen(HELPFILE, "r")) == NULL) { - printf("No help just now.\n"); + perror(HELPFILE); return(1); } while ((c = getc(f)) != EOF) @@ -188,10 +190,10 @@ respond(msgvec) int *msgvec; { struct message *mp; - char *cp, buf[2 * LINESIZE], *rcv, *replyto; + char *cp, *cp2, *cp3, *rcv, *replyto; + char buf[2 * LINESIZE], **ap; struct name *np; struct header head; - char *netmap(); if (msgvec[1] != 0) { printf("Sorry, can't reply to multiple messages at once\n"); @@ -212,7 +214,14 @@ respond(msgvec) np = elide(extract(buf, GTO)); /* rcv = rename(rcv); */ mapf(np, rcv); - np = delname(np, myname); + /* + * Delete my name from the reply list, + * and with it, all my alternate names. + */ + np = delname(np, myname, icequal); + if (altnames) + for (ap = altnames; *ap; ap++) + np = delname(np, *ap, icequal); head.h_seq = 1; cp = detract(np, 0); if (cp != NOSTR && replyto == NOSTR) { @@ -239,7 +248,10 @@ respond(msgvec) if (cp != NOSTR) { np = elide(extract(cp, GCC)); mapf(np, rcv); - np = delname(np, myname); + np = delname(np, myname, icequal); + if (altnames != 0) + for (ap = altnames; *ap; ap++) + np = delname(np, *ap, icequal); head.h_cc = detract(np, 0); } } @@ -309,7 +321,7 @@ messize(msgvec) for (ip = msgvec; *ip != NULL; ip++) { mesg = *ip; mp = &message[mesg-1]; - printf("%d: %d\n", mesg, msize(mp)); + printf("%d: %ld\n", mesg, mp->m_size); } return(0); } @@ -323,6 +335,8 @@ rexit(e) { if (sourcing) return(1); + if (Tflag != NOSTR) + close(creat(Tflag, 0600)); exit(e); } @@ -518,6 +532,7 @@ file(argv) { register char *cp; char fname[BUFSIZ]; + int edit; if (argv[0] == NOSTR) { newfileinfo(); @@ -534,10 +549,14 @@ file(argv) * string -- reads the given file */ - cp = getfilename(argv[0]); + cp = getfilename(argv[0], &edit); if (cp == NOSTR) return(-1); - return(setfile(cp, 1)); + if (setfile(cp, edit)) { + perror(cp); + return(-1); + } + newfileinfo(); } /* @@ -554,15 +573,22 @@ file(argv) char prevfile[PATHSIZE]; char * -getfilename(name) +getfilename(name, aedit) char *name; + int *aedit; { register char *cp; char savename[BUFSIZ]; char oldmailname[BUFSIZ]; + /* + * Assume we will be in "edit file" mode, until + * proven wrong. + */ + *aedit = 1; switch (*name) { case '%': + *aedit = 0; strcpy(prevfile, mailname); if (name[1] != 0) { strcpy(savename, myname); @@ -742,3 +768,33 @@ endifcmd() cond = CANY; return(0); } + +/* + * Set the list of alternate names. + */ +alternates(namelist) + char **namelist; +{ + register int c; + register char **ap, **ap2, *cp; + + c = argcount(namelist) + 1; + if (c == 1) { + if (altnames == 0) + return(0); + for (ap = altnames; *ap; ap++) + printf("%s ", *ap); + printf("\n"); + return(0); + } + if (altnames != 0) + cfree((char *) altnames); + altnames = (char **) calloc(c, sizeof (char *)); + for (ap = namelist, ap2 = altnames; *ap; ap++, ap2++) { + cp = (char *) calloc(strlen(*ap) + 1, sizeof (char)); + strcpy(cp, *ap); + *ap2 = cp; + } + *ap2 = 0; + return(0); +}