-#
+/*
+ * 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 <sys/stat.h>
* 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.
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
*/
{
register char *cp;
register int s;
+#ifdef TIOCGWINSZ
+ struct winsize ws;
+#endif
if ((cp = value("screen")) != NOSTR) {
s = atoi(cp);
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);
{
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;
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)
}
/*
- * 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;
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 {
touch(mesg);
mp = &message[mesg-1];
dot = mp;
- print(mp, obuf);
+ print(mp, obuf, doign);
}
if (obuf != stdout) {
pipef = NULL;
brokpipe()
{
-# ifdef VMUNIX
- sigrelse(SIGPIPE);
-# else
+# ifndef VMUNIX
signal(SIGPIPE, brokpipe);
# endif
longjmp(pipestop, 1);
* Print the indicated message on standard output.
*/
-print(mp, obuf)
+print(mp, obuf, doign)
register struct message *mp;
FILE *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);
}
/*
}
switch ((pid = fork())) {
case 0:
+ sigchild();
execlp("ls", "ls", dirname, 0);
- clrbuf(stdout);
- exit(1);
+ _exit(1);
case -1:
perror("fork");