X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/3e689d3a593ccc2747ff69718a5988690806e16d..0c5f72fb504e8431228d1e650246d87870d236bb:/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 932a400251..51a4973e36 100644 --- a/usr/src/usr.bin/mail/cmd3.c +++ b/usr/src/usr.bin/mail/cmd3.c @@ -1,7 +1,22 @@ -# +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +#ifdef notdef +static char sccsid[] = "@(#)cmd3.c 5.5 (Berkeley) %G%"; +#endif /* notdef */ #include "rcv.h" #include +#include /* * Mail -- a mail program @@ -9,8 +24,6 @@ * Still more user commands. */ -static char *SccsId = "@(#)cmd3.c 2.13 %G%"; - /* * Process a shell escape by saving signals, ignoring signals, * and forking a sh -c @@ -19,7 +32,8 @@ static char *SccsId = "@(#)cmd3.c 2.13 %G%"; shell(str) char *str; { - int (*sig[2])(), stat[1]; + int (*sigint)(), (*sigquit)(); + union wait stat; register int t; char *Shell; char cmd[BUFSIZ]; @@ -29,24 +43,24 @@ shell(str) return(-1); if ((Shell = value("SHELL")) == NOSTR) Shell = SHELL; - for (t = 2; t < 4; t++) - sig[t-2] = sigset(t, SIG_IGN); + sigint = signal(SIGINT, SIG_IGN); + sigquit = signal(SIGQUIT, SIG_IGN); t = vfork(); if (t == 0) { - sigchild(); - for (t = 2; t < 4; t++) - if (sig[t-2] != SIG_IGN) - sigsys(t, SIG_DFL); - execl(Shell, Shell, "-c", cmd, 0); + if (sigint != SIG_IGN) + signal(SIGINT, SIG_DFL); + if (sigquit != SIG_IGN) + signal(SIGQUIT, SIG_DFL); + execl(Shell, Shell, "-c", cmd, (char *)0); perror(Shell); _exit(1); } - while (wait(stat) != t) + while (wait(&stat) != t) ; if (t == -1) perror("fork"); - for (t = 2; t < 4; t++) - sigset(t, sig[t-2]); + signal(SIGINT, sigint); + signal(SIGQUIT, sigquit); printf("!\n"); return(0); } @@ -55,32 +69,35 @@ shell(str) * Fork an interactive shell. */ +/*ARGSUSED*/ dosh(str) char *str; { - int (*sig[2])(), stat[1]; + int (*sigint)(), (*sigquit)(); + union wait stat; register int t; char *Shell; + if ((Shell = value("SHELL")) == NOSTR) Shell = SHELL; - for (t = 2; t < 4; t++) - sig[t-2] = sigset(t, SIG_IGN); + sigint = signal(SIGINT, SIG_IGN); + sigquit = signal(SIGQUIT, SIG_IGN); t = vfork(); if (t == 0) { - sigchild(); - for (t = 2; t < 4; t++) - if (sig[t-2] != SIG_IGN) - sigsys(t, SIG_DFL); - execl(Shell, Shell, 0); + if (sigint != SIG_IGN) + signal(SIGINT, SIG_DFL); + if (sigquit != SIG_IGN) + signal(SIGQUIT, SIG_DFL); + execl(Shell, Shell, (char *)0); perror(Shell); _exit(1); } - while (wait(stat) != t) + while (wait(&stat) != t) ; if (t == -1) perror("fork"); - for (t = 2; t < 4; t++) - sigsys(t, sig[t-2]); + signal(SIGINT, sigint); + signal(SIGQUIT, sigquit); putchar('\n'); return(0); } @@ -181,16 +198,25 @@ schdir(str) return(0); } +respond(msgvec) + int *msgvec; +{ + if (value("Replyall") == NOSTR) + return (_respond(msgvec)); + else + return (_Respond(msgvec)); +} + /* * Reply to a list of messages. Extract each name from the * message header and send them off to mail1() */ -respond(msgvec) +_respond(msgvec) int *msgvec; { struct message *mp; - char *cp, *cp2, *cp3, *rcv, *replyto; + char *cp, *rcv, *replyto; char buf[2 * LINESIZE], **ap; struct name *np; struct header head; @@ -202,10 +228,10 @@ respond(msgvec) mp = &message[msgvec[0] - 1]; dot = mp; rcv = NOSTR; - cp = nameof(mp, 1); + cp = skin(nameof(mp, 1)); if (cp != NOSTR) rcv = cp; - cp = hfield("from", mp); + cp = skin(hfield("from", mp)); if (cp != NOSTR) rcv = cp; replyto = skin(hfield("reply-to", mp)); @@ -213,12 +239,11 @@ respond(msgvec) if (replyto != NOSTR) strcpy(buf, replyto); else { - cp = hfield("to", mp); + cp = skin(hfield("to", mp)); if (cp != NOSTR) strcpy(buf, cp); } np = elide(extract(buf, GTO)); - /* rcv = rename(rcv); */ mapf(np, rcv); /* * Delete my name from the reply list, @@ -229,10 +254,10 @@ respond(msgvec) for (ap = altnames; *ap; ap++) np = delname(np, *ap, icequal); head.h_seq = 1; - cp = detract(np, GCOMMA); /* do it with commas */ + cp = detract(np, 0); if (cp != NOSTR && replyto == NOSTR) { strcpy(buf, cp); - strcat(buf, ", "); + strcat(buf, " "); strcat(buf, rcv); } else { @@ -250,7 +275,7 @@ respond(msgvec) head.h_subject = reedit(head.h_subject); head.h_cc = NOSTR; if (replyto == NOSTR) { - cp = hfield("cc", mp); + cp = skin(hfield("cc", mp)); if (cp != NOSTR) { np = elide(extract(cp, GCC)); mapf(np, rcv); @@ -285,7 +310,7 @@ reedit(subj) if (icequal(sbuf, "re:")) return(subj); newsubj = salloc(strlen(subj) + 6); - sprintf(newsubj, "Re: %s", subj); + sprintf(newsubj, "Re: %s", subj); return(newsubj); } @@ -314,6 +339,22 @@ preserve(msgvec) return(0); } +/* + * Mark all given messages as unread. + */ +unread(msgvec) + int msgvec[]; +{ + register int *ip; + + for (ip = msgvec; *ip != NULL; ip++) { + dot = &message[*ip-1]; + dot->m_flag &= ~(MREAD|MTOUCH); + dot->m_flag |= MSTATUS; + } + return(0); +} + /* * Print the size of each message. */ @@ -327,7 +368,7 @@ messize(msgvec) for (ip = msgvec; *ip != NULL; ip++) { mesg = *ip; mp = &message[mesg-1]; - printf("%d: %ld\n", mesg, mp->m_size); + printf("%d: %d/%ld\n", mesg, mp->m_lines, mp->m_size); } return(0); } @@ -344,6 +385,7 @@ rexit(e) if (Tflag != NOSTR) close(creat(Tflag, 0600)); exit(e); + /*NOTREACHED*/ } /* @@ -402,7 +444,6 @@ unset(arglist) char **arglist; { register struct var *vp, *vp2; - register char *cp; int errs, h; char **ap; @@ -420,7 +461,7 @@ unset(arglist) variables[h] = variables[h]->v_link; vfree(vp2->v_name); vfree(vp2->v_value); - cfree(vp2); + cfree((char *)vp2); continue; } for (vp = variables[h]; vp->v_link != vp2; vp = vp->v_link) @@ -428,7 +469,7 @@ unset(arglist) vp->v_link = vp2->v_link; vfree(vp2->v_name); vfree(vp2->v_value); - cfree(vp2); + cfree((char *) vp2); } return(errs); } @@ -504,7 +545,7 @@ sort(list) ; if (ap-list < 2) return; - qsort(list, ap-list, sizeof *list, diction); + qsort((char *)list, ap-list, sizeof *list, diction); } /* @@ -522,9 +563,10 @@ diction(a, b) * The do nothing command for comments. */ +/*ARGSUSED*/ null(e) { - return(0); + return 0; } /* @@ -537,7 +579,6 @@ file(argv) char **argv; { register char *cp; - char fname[BUFSIZ]; int edit; if (argv[0] == NOSTR) { @@ -562,7 +603,8 @@ file(argv) perror(cp); return(-1); } - newfileinfo(); + announce(0); + return 0; } /* @@ -656,27 +698,36 @@ echo(argv) return(0); } +Respond(msgvec) + int *msgvec; +{ + if (value("Replyall") == NOSTR) + return (_Respond(msgvec)); + else + return (_respond(msgvec)); +} + /* * Reply to a series of messages by simply mailing to the senders * and not messing around with the To: and Cc: lists as in normal * reply. */ -Respond(msgvec) +_Respond(msgvec) int msgvec[]; { struct header head; struct message *mp; - register int i, s, *ap; + register int s, *ap; register char *cp, *cp2, *subject; for (s = 0, ap = msgvec; *ap != 0; ap++) { mp = &message[*ap - 1]; dot = mp; - if ((cp = hfield("from", mp)) != NOSTR) + if ((cp = skin(hfield("from", mp))) != NOSTR) s+= strlen(cp) + 1; else - s += strlen(nameof(mp, 2)) + 1; + s += strlen(skin(nameof(mp, 2))) + 1; } if (s == 0) return(0); @@ -684,8 +735,8 @@ Respond(msgvec) head.h_to = cp; for (ap = msgvec; *ap != 0; ap++) { mp = &message[*ap - 1]; - if ((cp2 = hfield("from", mp)) == NOSTR) - cp2 = nameof(mp, 2); + if ((cp2 = skin(hfield("from", mp))) == NOSTR) + cp2 = skin(nameof(mp, 2)); cp = copy(cp2, cp); *cp++ = ' '; } @@ -800,9 +851,9 @@ alternates(namelist) } if (altnames != 0) cfree((char *) altnames); - altnames = (char **) calloc(c, sizeof (char *)); + altnames = (char **) calloc((unsigned) c, sizeof (char *)); for (ap = namelist, ap2 = altnames; *ap; ap++, ap2++) { - cp = (char *) calloc(strlen(*ap) + 1, sizeof (char)); + cp = (char *) calloc((unsigned) strlen(*ap) + 1, sizeof (char)); strcpy(cp, *ap); *ap2 = cp; }