X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/6c85fa2a4274975d27581c240a80c94c244756d5..e7dd39cf11ddd130ef548aab393859699ba8717b:/usr/src/usr.bin/mail/cmd1.c?ds=inline diff --git a/usr/src/usr.bin/mail/cmd1.c b/usr/src/usr.bin/mail/cmd1.c index fa3a55e713..50379b0a87 100644 --- a/usr/src/usr.bin/mail/cmd1.c +++ b/usr/src/usr.bin/mail/cmd1.c @@ -1,4 +1,13 @@ -# +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char *sccsid = "@(#)cmd1.c 5.3 (Berkeley) %G%"; +#endif not lint + #include "rcv.h" #include @@ -8,8 +17,6 @@ * User commands. */ -static char *SccsId = "@(#)cmd1.c 2.6 %G%"; - /* * Print the current active headings. * Don't change dot if invoker didn't give an argument. @@ -55,6 +62,36 @@ headers(msgvec) return(0); } +/* + * Set the list of alternate names for out host. + */ +local(namelist) + char **namelist; +{ + register int c; + register char **ap, **ap2, *cp; + + c = argcount(namelist) + 1; + if (c == 1) { + if (localnames == 0) + return(0); + for (ap = localnames; *ap; ap++) + printf("%s ", *ap); + printf("\n"); + return(0); + } + if (localnames != 0) + cfree((char *) localnames); + localnames = (char **) calloc(c, sizeof (char *)); + for (ap = namelist, ap2 = localnames; *ap; ap++, ap2++) { + cp = (char *) calloc(strlen(*ap) + 1, sizeof (char)); + strcpy(cp, *ap); + *ap2 = cp; + } + *ap2 = 0; + return(0); +} + /* * Scroll to the next/previous screen */ @@ -106,6 +143,9 @@ screensize() { register char *cp; register int s; +#ifdef TIOCGWINSZ + struct winsize ws; +#endif if ((cp = value("screen")) != NOSTR) { s = atoi(cp); @@ -116,6 +156,10 @@ screensize() s = 5; else if (baud == B1200) s = 10; +#ifdef TIOCGWINSZ + else if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) == 0 && ws.ws_row != 0) + s = ws.ws_row - 4; +#endif else s = 20; return(s); @@ -149,7 +193,7 @@ printhead(mesg) { struct message *mp; FILE *ibuf; - char headline[LINESIZE], wcount[10], *subjline, dispc, curind; + char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind; char pbuf[BUFSIZ]; int s; struct headline hl; @@ -181,7 +225,7 @@ printhead(mesg) if (mp->m_flag & MBOX) dispc = 'M'; parse(headline, &hl, pbuf); - sprintf(wcount, " %d/%d", mp->m_lines, mp->m_size); + sprintf(wcount, " %d/%ld", mp->m_lines, mp->m_size); s = strlen(wcount); cp = wcount + s; while (s < 7) @@ -231,14 +275,52 @@ pcmdlist() } /* - * Type out the messages requested. + * Paginate messages, honor ignored fields. */ +more(msgvec) + int *msgvec; +{ + return (type1(msgvec, 1, 1)); +} -jmp_buf pipestop; +/* + * Paginate messages, even printing ignored fields. + */ +More(msgvec) + int *msgvec; +{ + + return (type1(msgvec, 0, 1)); +} +/* + * Type out messages, honor ignored fields. + */ type(msgvec) int *msgvec; { + + return(type1(msgvec, 1, 0)); +} + +/* + * Type out messages, even printing ignored fields. + */ +Type(msgvec) + int *msgvec; +{ + + return(type1(msgvec, 0, 0)); +} + +/* + * Type out the messages requested. + */ +jmp_buf pipestop; + +type1(msgvec, doign, page) + int *msgvec; +{ register *ip; register struct message *mp; register int mesg; @@ -256,13 +338,19 @@ type(msgvec) sigset(SIGPIPE, SIG_DFL); return(0); } - if (intty && outtty && (cp = value("crt")) != NOSTR) { - for (ip = msgvec, nlines = 0; *ip && ip-msgvec < msgCount; ip++) - nlines += message[*ip - 1].m_lines; - if (nlines > atoi(cp)) { - obuf = popen(MORE, "w"); + if (intty && outtty && (page || (cp = value("crt")) != NOSTR)) { + nlines = 0; + if (!page) { + for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) + nlines += message[*ip - 1].m_lines; + } + if (page || nlines > atoi(cp)) { + cp = value("PAGER"); + if (cp == NULL || *cp == '\0') + cp = MORE; + obuf = popen(cp, "w"); if (obuf == NULL) { - perror(MORE); + perror(cp); obuf = stdout; } else { @@ -276,7 +364,7 @@ type(msgvec) touch(mesg); mp = &message[mesg-1]; dot = mp; - print(mp, obuf); + print(mp, obuf, doign); } if (obuf != stdout) { pipef = NULL; @@ -293,9 +381,7 @@ type(msgvec) brokpipe() { -# ifdef VMUNIX - sigrelse(SIGPIPE); -# else +# ifndef VMUNIX signal(SIGPIPE, brokpipe); # endif longjmp(pipestop, 1); @@ -305,7 +391,7 @@ brokpipe() * Print the indicated message on standard output. */ -print(mp, obuf) +print(mp, obuf, doign) register struct message *mp; FILE *obuf; { @@ -313,7 +399,7 @@ print(mp, obuf) if (value("quiet") == NOSTR) fprintf(obuf, "Message %2d:\n", mp - &message[0] + 1); touch(mp - &message[0] + 1); - send(mp, obuf); + send(mp, obuf, doign); } /* @@ -410,9 +496,9 @@ folders() } switch ((pid = fork())) { case 0: + sigchild(); execlp("ls", "ls", dirname, 0); - clrbuf(stdout); - exit(1); + _exit(1); case -1: perror("fork");