major rework: made faster, cleaned up, obsolete code removed,
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Tue, 19 May 1987 03:29:02 +0000 (19:29 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Tue, 19 May 1987 03:29:02 +0000 (19:29 -0800)
the whole thing should be chucked and written from scratch

SCCS-vsn: usr.bin/mail/list.c 5.5
SCCS-vsn: usr.bin/mail/lex.c 5.5
SCCS-vsn: usr.bin/mail/collect.c 5.3
SCCS-vsn: usr.bin/mail/main.c 5.4
SCCS-vsn: usr.bin/mail/names.c 5.4
SCCS-vsn: usr.bin/mail/cmd3.c 5.4
SCCS-vsn: usr.bin/mail/Makefile 5.4
SCCS-vsn: usr.bin/mail/cmdtab.c 5.4
SCCS-vsn: usr.bin/mail/def.h 5.3
SCCS-vsn: usr.bin/mail/glob.h 5.2
SCCS-vsn: usr.bin/mail/aux.c 5.6
SCCS-vsn: usr.bin/mail/pathnames.h 5.3
SCCS-vsn: usr.bin/mail/cmd1.c 5.4
SCCS-vsn: usr.bin/mail/popen.c 5.3
SCCS-vsn: usr.bin/mail/send.c 5.3
SCCS-vsn: usr.bin/mail/vars.c 5.3
SCCS-vsn: usr.bin/fmt/fmt.c 5.4
SCCS-vsn: usr.bin/mail/rcv.h 5.2
SCCS-vsn: usr.bin/mail/tty.c 5.3
SCCS-vsn: usr.bin/mail/getname.c 5.3
SCCS-vsn: usr.bin/mail/strings.c 5.4
SCCS-vsn: usr.bin/mail/temp.c 5.3
SCCS-vsn: usr.bin/mail/v7.local.c 5.3
SCCS-vsn: usr.bin/mail/cmd2.c 5.4
SCCS-vsn: usr.bin/mail/local.h 5.2
SCCS-vsn: usr.bin/mail/edit.c 5.3
SCCS-vsn: usr.bin/mail/fio.c 5.5
SCCS-vsn: usr.bin/mail/head.c 5.3
SCCS-vsn: usr.bin/mail/optim.c 5.7

29 files changed:
usr/src/usr.bin/fmt/fmt.c
usr/src/usr.bin/mail/Makefile
usr/src/usr.bin/mail/aux.c
usr/src/usr.bin/mail/cmd1.c
usr/src/usr.bin/mail/cmd2.c
usr/src/usr.bin/mail/cmd3.c
usr/src/usr.bin/mail/cmdtab.c
usr/src/usr.bin/mail/collect.c
usr/src/usr.bin/mail/def.h
usr/src/usr.bin/mail/edit.c
usr/src/usr.bin/mail/fio.c
usr/src/usr.bin/mail/getname.c
usr/src/usr.bin/mail/glob.h
usr/src/usr.bin/mail/head.c
usr/src/usr.bin/mail/lex.c
usr/src/usr.bin/mail/list.c
usr/src/usr.bin/mail/local.h
usr/src/usr.bin/mail/main.c
usr/src/usr.bin/mail/names.c
usr/src/usr.bin/mail/optim.c
usr/src/usr.bin/mail/pathnames.h
usr/src/usr.bin/mail/popen.c
usr/src/usr.bin/mail/rcv.h
usr/src/usr.bin/mail/send.c
usr/src/usr.bin/mail/strings.c
usr/src/usr.bin/mail/temp.c
usr/src/usr.bin/mail/tty.c
usr/src/usr.bin/mail/v7.local.c
usr/src/usr.bin/mail/vars.c

index f02338d..97442cc 100644 (file)
@@ -11,7 +11,7 @@ char *copyright =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char *sccsid = "@(#)fmt.c       5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)fmt.c       5.4 (Berkeley) %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -38,7 +38,7 @@ int   pfx;                    /* Current leading blank count */
 int    lineno;                 /* Current input line */
 int    mark;                   /* Last place we saw a head line */
 
 int    lineno;                 /* Current input line */
 int    mark;                   /* Last place we saw a head line */
 
-char   *calloc();              /* for lint . . . */
+char   *malloc();              /* for lint . . . */
 char   *headnames[] = {"To", "Subject", "Cc", 0};
 
 /*
 char   *headnames[] = {"To", "Subject", "Cc", 0};
 
 /*
@@ -412,12 +412,12 @@ savestr(str)
 {
        register char *top;
 
 {
        register char *top;
 
-       top = calloc(strlen(str) + 1, 1);
+       top = malloc(strlen(str) + 1);
        if (top == NOSTR) {
                fprintf(stderr, "fmt:  Ran out of memory\n");
                exit(1);
        }
        if (top == NOSTR) {
                fprintf(stderr, "fmt:  Ran out of memory\n");
                exit(1);
        }
-       copy(str, top);
+       strcpy(top, str);
        return (top);
 }
 
        return (top);
 }
 
index 50ba282..73f55f1 100644 (file)
@@ -3,7 +3,7 @@
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
-#      @(#)Makefile    5.3 (Berkeley) %G%
+#      @(#)Makefile    5.4 (Berkeley) %G%
 #
 # Berkeley Mail
 #
 #
 # Berkeley Mail
 #
index d9765ab..84cd7da 100644 (file)
@@ -5,13 +5,11 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)aux.c       5.5 (Berkeley) %G%";
+static char *sccsid = "@(#)aux.c       5.6 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
-#include <ctype.h>
-#include <strings.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -40,62 +38,20 @@ savestr(str)
        return(top);
 }
 
        return(top);
 }
 
-/*
- * Copy the name from the passed header line into the passed
- * name buffer.  Null pad the name buffer.
- */
-
-copyname(linebuf, nbuf)
-       char *linebuf, *nbuf;
-{
-       register char *cp, *cp2;
-
-       for (cp = linebuf + 5, cp2 = nbuf; *cp != ' ' && cp2-nbuf < 8; cp++)
-               *cp2++ = *cp;
-       while (cp2-nbuf < 8)
-               *cp2++ = 0;
-}
-
 /*
  * Announce a fatal error and die.
  */
 
 /*
  * Announce a fatal error and die.
  */
 
-panic(str)
-       char *str;
+/*VARARGS1*/
+panic(fmt, a, b)
+       char *fmt;
 {
 {
-       prs("panic: ");
-       prs(str);
-       prs("\n");
+       fprintf(stderr, "panic: ");
+       fprintf(stderr, fmt, a, b);
+       putc('\n', stderr);
        exit(1);
 }
 
        exit(1);
 }
 
-/*
- * Catch stdio errors and report them more nicely.
- */
-
-_error(str)
-       char *str;
-{
-       prs("Stdio Error: ");
-       prs(str);
-       prs("\n");
-       abort();
-}
-
-/*
- * Print a string on diagnostic output.
- */
-
-prs(str)
-       char *str;
-{
-       register char *s;
-
-       for (s = str; *s; s++)
-               ;
-       write(2, str, s-str);
-}
-
 /*
  * Touch the named message by setting its MTOUCH flag.
  * Touched messages have the effect of not being sent
 /*
  * Touch the named message by setting its MTOUCH flag.
  * Touched messages have the effect of not being sent
@@ -138,38 +94,9 @@ argcount(argv)
 {
        register char **ap;
 
 {
        register char **ap;
 
-       for (ap = argv; *ap != NOSTR; ap++)
+       for (ap = argv; *ap++ != NOSTR;)
                ;       
                ;       
-       return(ap-argv);
-}
-
-/*
- * Given a file address, determine the
- * block number it represents.
- */
-
-blockof(off)
-       off_t off;
-{
-       off_t a;
-
-       a = off >> 9;
-       a &= 077777;
-       return((int) a);
-}
-
-/*
- * Take a file address, and determine
- * its offset in the current block.
- */
-
-offsetof(off)
-       off_t off;
-{
-       off_t a;
-
-       a = off & 0777;
-       return((int) a);
+       return ap - argv - 1;
 }
 
 /*
 }
 
 /*
@@ -185,156 +112,104 @@ hfield(field, mp)
        register FILE *ibuf;
        char linebuf[LINESIZE];
        register int lc;
        register FILE *ibuf;
        char linebuf[LINESIZE];
        register int lc;
+       register char *hfield;
+       char *colon;
 
        ibuf = setinput(mp);
 
        ibuf = setinput(mp);
-       if ((lc = mp->m_lines) <= 0)
-               return(NOSTR);
+       if ((lc = mp->m_lines - 1) < 0)
+               return NOSTR;
        if (readline(ibuf, linebuf) < 0)
        if (readline(ibuf, linebuf) < 0)
-               return(NOSTR);
-       lc--;
-       do {
-               lc = gethfield(ibuf, linebuf, lc);
-               if (lc == -1)
-                       return(NOSTR);
-               if (ishfield(linebuf, field))
-                       return(savestr(hcontents(linebuf)));
-       } while (lc > 0);
-       return(NOSTR);
+               return NOSTR;
+       while (lc > 0) {
+               if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0)
+                       return NOSTR;
+               if (hfield = ishfield(linebuf, colon, field))
+                       return savestr(hfield);
+       }
+       return NOSTR;
 }
 
 /*
  * Return the next header field found in the given message.
 }
 
 /*
  * Return the next header field found in the given message.
- * Return > 0 if something found, <= 0 elsewise.
+ * Return >= 0 if something found, < 0 elsewise.
+ * "colon" is set to point to the colon in the header.
  * Must deal with \ continuations & other such fraud.
  */
 
  * Must deal with \ continuations & other such fraud.
  */
 
-gethfield(f, linebuf, rem)
+gethfield(f, linebuf, rem, colon)
        register FILE *f;
        char linebuf[];
        register int rem;
        register FILE *f;
        char linebuf[];
        register int rem;
+       char **colon;
 {
        char line2[LINESIZE];
 {
        char line2[LINESIZE];
-       long loc;
        register char *cp, *cp2;
        register int c;
 
        register char *cp, *cp2;
        register int c;
 
-
        for (;;) {
        for (;;) {
-               if (rem <= 0)
-                       return(-1);
-               if (readline(f, linebuf) < 0)
-                       return(-1);
-               rem--;
-               if (strlen(linebuf) == 0)
-                       return(-1);
-               if (isspace(linebuf[0]))
-                       continue;
-               if (linebuf[0] == '>')
-                       continue;
-               cp = index(linebuf, ':');
-               if (cp == NOSTR)
+               if (--rem < 0)
+                       return -1;
+               if ((c = readline(f, linebuf)) <= 0)
+                       return -1;
+               for (cp = linebuf; isprint(*cp) && *cp != ' ' && *cp != ':';
+                    cp++)
+                       ;
+               if (*cp != ':' || cp == linebuf)
                        continue;
                        continue;
-               for (cp2 = linebuf; cp2 < cp; cp2++)
-                       if (isdigit(*cp2))
-                               continue;
-               
                /*
                 * I guess we got a headline.
                 * Handle wraparounding
                 */
                /*
                 * I guess we got a headline.
                 * Handle wraparounding
                 */
-               
+               *colon = cp;
+               cp = linebuf + c;
                for (;;) {
                for (;;) {
+                       while (--cp >= linebuf && (*cp == ' ' || *cp == '\t'))
+                               ;
+                       cp++;
                        if (rem <= 0)
                                break;
                        if (rem <= 0)
                                break;
-#ifdef CANTELL
-                       loc = ftell(f);
-                       if (readline(f, line2) < 0)
-                               break;
-                       rem--;
-                       if (!isspace(line2[0])) {
-                               fseek(f, loc, 0);
-                               rem++;
-                               break;
-                       }
-#else
-                       c = getc(f);
-                       ungetc(c, f);
-                       if (!isspace(c) || c == '\n')
+                       ungetc(c = getc(f), f);
+                       if (c != ' ' && c != '\t')
                                break;
                                break;
-                       if (readline(f, line2) < 0)
+                       if ((c = readline(f, line2)) < 0)
                                break;
                        rem--;
                                break;
                        rem--;
-#endif
-                       cp2 = line2;
-                       for (cp2 = line2; *cp2 != 0 && isspace(*cp2); cp2++)
+                       for (cp2 = line2; *cp2 == ' ' || *cp2 == '\t'; cp2++)
                                ;
                                ;
-                       if (strlen(linebuf) + strlen(cp2) >= LINESIZE-2)
+                       c -= cp2 - line2;
+                       if (cp + c >= linebuf + LINESIZE - 2)
                                break;
                                break;
-                       cp = &linebuf[strlen(linebuf)];
-                       while (cp > linebuf &&
-                           (isspace(cp[-1]) || cp[-1] == '\\'))
-                               cp--;
                        *cp++ = ' ';
                        *cp++ = ' ';
-                       for (cp2 = line2; *cp2 != 0 && isspace(*cp2); cp2++)
-                               ;
-                       strcpy(cp, cp2);
-               }
-               if ((c = strlen(linebuf)) > 0) {
-                       cp = &linebuf[c-1];
-                       while (cp > linebuf && isspace(*cp))
-                               cp--;
-                       *++cp = 0;
+                       bcopy(cp2, cp, c);
+                       cp += c;
                }
                }
-               return(rem);
+               *cp = 0;
+               return rem;
        }
        /* NOTREACHED */
 }
 
 /*
  * Check whether the passed line is a header line of
        }
        /* NOTREACHED */
 }
 
 /*
  * Check whether the passed line is a header line of
- * the desired breed.
+ * the desired breed.  Return the field body, or 0.
  */
 
  */
 
-ishfield(linebuf, field)
+char*
+ishfield(linebuf, colon, field)
        char linebuf[], field[];
        char linebuf[], field[];
+       char *colon;
 {
 {
-       register char *cp;
-       register int c;
+       register char *cp = colon;
 
 
-       if ((cp = index(linebuf, ':')) == NOSTR)
-               return(0);
-       if (cp == linebuf)
-               return(0);
-       cp--;
-       while (cp > linebuf && isspace(*cp))
-               cp--;
-       c = *++cp;
        *cp = 0;
        *cp = 0;
-       if (icequal(linebuf ,field)) {
-               *cp = c;
-               return(1);
+       if (!icequal(linebuf, field)) {
+               *cp = ':';
+               return 0;
        }
        }
-       *cp = c;
-       return(0);
-}
-
-/*
- * Extract the non label information from the given header field
- * and return it.
- */
-
-char *
-hcontents(hfield)
-       char hfield[];
-{
-       register char *cp;
-
-       if ((cp = index(hfield, ':')) == NOSTR)
-               return(NOSTR);
-       cp++;
-       while (*cp && isspace(*cp))
-               cp++;
-       return(cp);
+       *cp = ':';
+       for (cp++; *cp == ' ' || *cp == '\t'; cp++)
+               ;
+       return cp;
 }
 
 /*
 }
 
 /*
@@ -344,26 +219,35 @@ hcontents(hfield)
 icequal(s1, s2)
        register char *s1, *s2;
 {
 icequal(s1, s2)
        register char *s1, *s2;
 {
+       register c1, c2;
 
 
-       while (raise(*s1++) == raise(*s2))
-               if (*s2++ == 0)
-                       return(1);
-       return(0);
+       for (;;) {
+               if ((c1 = (unsigned char)*s1++) !=
+                   (c2 = (unsigned char)*s2++)) {
+                       if (isupper(c1))
+                               c1 = tolower(c1);
+                       if (c1 != c2)
+                               return 0;
+               }
+               if (c1 == 0)
+                       return 1;
+       }
+       /*NOTREACHED*/
 }
 
 /*
  * Copy a string, lowercasing it as we go.
  */
 istrcpy(dest, src)
 }
 
 /*
  * Copy a string, lowercasing it as we go.
  */
 istrcpy(dest, src)
-       char *dest, *src;
+       register char *dest, *src;
 {
 {
-       register char *cp, *cp2;
 
 
-       cp2 = dest;
-       cp = src;
        do {
        do {
-               *cp2++ = little(*cp);
-       } while (*cp++ != 0);
+               if (isupper(*src))
+                       *dest++ = tolower(*src);
+               else
+                       *dest++ = *src;
+       } while (*src++ != 0);
 }
 
 /*
 }
 
 /*
@@ -412,21 +296,6 @@ source(name)
        return(0);
 }
 
        return(0);
 }
 
-/*
- * Source a file, but do nothing if the file cannot be opened.
- */
-
-source1(name)
-       char name[];
-{
-       register int f;
-
-       if ((f = open(name, 0)) < 0)
-               return(0);
-       close(f);
-       source(name);
-}
-
 /*
  * Pop the current input back to the previous level.
  * Update the "sourcing" flag as appropriate.
 /*
  * Pop the current input back to the previous level.
  * Update the "sourcing" flag as appropriate.
@@ -542,7 +411,7 @@ skin(name)
        if (name == NOSTR)
                return(NOSTR);
        if (index(name, '(') == NOSTR && index(name, '<') == NOSTR
        if (name == NOSTR)
                return(NOSTR);
        if (index(name, '(') == NOSTR && index(name, '<') == NOSTR
-       && index(name, ' ') == NOSTR)
+           && index(name, ' ') == NOSTR)
                return(name);
        gotlt = 0;
        lastsp = 0;
                return(name);
        gotlt = 0;
        lastsp = 0;
@@ -666,23 +535,23 @@ name1(mp, reptype)
        int first = 1;
 
        if ((cp = hfield("from", mp)) != NOSTR)
        int first = 1;
 
        if ((cp = hfield("from", mp)) != NOSTR)
-               return(cp);
+               return cp;
        if (reptype == 0 && (cp = hfield("sender", mp)) != NOSTR)
        if (reptype == 0 && (cp = hfield("sender", mp)) != NOSTR)
-               return(cp);
+               return cp;
        ibuf = setinput(mp);
        ibuf = setinput(mp);
-       copy("", namebuf);
-       if (readline(ibuf, linebuf) <= 0)
+       namebuf[0] = 0;
+       if (readline(ibuf, linebuf) < 0)
                return(savestr(namebuf));
 newname:
                return(savestr(namebuf));
 newname:
-       for (cp = linebuf; *cp != ' '; cp++)
+       for (cp = linebuf; *cp && *cp != ' '; cp++)
                ;
                ;
-       while (any(*cp, " \t"))
-               cp++;
-       for (cp2 = &namebuf[strlen(namebuf)]; *cp && !any(*cp, " \t") &&
-           cp2-namebuf < LINESIZE-1; *cp2++ = *cp++)
+       for (; *cp == ' ' || *cp == '\t'; cp++)
                ;
                ;
+       for (cp2 = &namebuf[strlen(namebuf)];
+            *cp && *cp != ' ' && *cp != '\t' && cp2 < namebuf + LINESIZE - 1;)
+               *cp2++ = *cp++;
        *cp2 = '\0';
        *cp2 = '\0';
-       if (readline(ibuf, linebuf) <= 0)
+       if (readline(ibuf, linebuf) < 0)
                return(savestr(namebuf));
        if ((cp = index(linebuf, 'F')) == NULL)
                return(savestr(namebuf));
                return(savestr(namebuf));
        if ((cp = index(linebuf, 'F')) == NULL)
                return(savestr(namebuf));
@@ -698,7 +567,7 @@ newname:
                                break;
                        cp++;
                        if (first) {
                                break;
                        cp++;
                        if (first) {
-                               copy(cp, namebuf);
+                               strcpy(namebuf, cp);
                                first = 0;
                        } else
                                strcpy(rindex(namebuf, '!')+1, cp);
                                first = 0;
                        } else
                                strcpy(rindex(namebuf, '!')+1, cp);
@@ -726,33 +595,58 @@ charcount(str, c)
 }
 
 /*
 }
 
 /*
- * See if the string is a number.
+ * Are any of the characters in the two strings the same?
  */
 
  */
 
-numeric(str)
-       char str[];
+anyof(s1, s2)
+       register char *s1, *s2;
 {
 {
-       register char *cp = str;
 
 
-       while (*cp)
-               if (!isdigit(*cp++))
-                       return(0);
-       return(1);
+       while (*s1)
+               if (index(s2, *s1++))
+                       return 1;
+       return 0;
 }
 
 /*
 }
 
 /*
- * Are any of the characters in the two strings the same?
+ * Convert c to upper case
  */
 
  */
 
-anyof(s1, s2)
+raise(c)
+       register c;
+{
+
+       if (islower(c))
+               return toupper(c);
+       return c;
+}
+
+/*
+ * Copy s1 to s2, return pointer to null in s2.
+ */
+
+char *
+copy(s1, s2)
        register char *s1, *s2;
 {
        register char *s1, *s2;
 {
-       register int c;
 
 
-       while (c = *s1++)
-               if (any(c, s2))
-                       return(1);
-       return(0);
+       while (*s2++ = *s1++)
+               ;
+       return s2 - 1;
+}
+
+/*
+ * Add a single character onto a string.
+ */
+
+stradd(str, c)
+       register char *str;
+{
+
+       while (*str++)
+               ;
+       str[-1] = c;
+       *str = 0;
 }
 
 /*
 }
 
 /*
@@ -768,7 +662,6 @@ isign(field)
         * will hash to the same place.
         */
        istrcpy(realfld, field);
         * will hash to the same place.
         */
        istrcpy(realfld, field);
-
        if (nretained > 0)
                return (!member(realfld, retain));
        else
        if (nretained > 0)
                return (!member(realfld, retain));
        else
@@ -777,13 +670,13 @@ isign(field)
 
 member(realfield, table)
        register char *realfield;
 
 member(realfield, table)
        register char *realfield;
-       register struct ignore **table;
+       struct ignore **table;
 {
        register struct ignore *igp;
 
        for (igp = table[hash(realfield)]; igp != 0; igp = igp->i_link)
 {
        register struct ignore *igp;
 
        for (igp = table[hash(realfield)]; igp != 0; igp = igp->i_link)
-               if (equal(igp->i_field, realfield))
+               if (*igp->i_field == *realfield &&
+                   equal(igp->i_field, realfield))
                        return (1);
                        return (1);
-
        return (0);
 }
        return (0);
 }
index 50379b0..efe4104 100644 (file)
@@ -5,11 +5,12 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)cmd1.c      5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)cmd1.c      5.4 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
+#include <sys/wait.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -82,9 +83,9 @@ local(namelist)
        }
        if (localnames != 0)
                cfree((char *) localnames);
        }
        if (localnames != 0)
                cfree((char *) localnames);
-       localnames = (char **) calloc(c, sizeof (char *));
+       localnames = (char **) calloc((unsigned) c, sizeof (char *));
        for (ap = namelist, ap2 = localnames; *ap; ap++, ap2++) {
        for (ap = namelist, ap2 = localnames; *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;
        }
                strcpy(cp, *ap);
                *ap2 = cp;
        }
@@ -132,37 +133,16 @@ scroll(arg)
 }
 
 /*
 }
 
 /*
- * Compute what the screen size should be.
- * We use the following algorithm:
- *     If user specifies with screen option, use that.
- *     If baud rate < 1200, use  5
- *     If baud rate = 1200, use 10
- *     If baud rate > 1200, use 20
+ * Compute screen size.
  */
 screensize()
 {
  */
 screensize()
 {
-       register char *cp;
-       register int s;
-#ifdef TIOCGWINSZ
-       struct winsize ws;
-#endif
-
-       if ((cp = value("screen")) != NOSTR) {
-               s = atoi(cp);
-               if (s > 0)
-                       return(s);
-       }
-       if (baud < B1200)
-               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);
+       int s;
+       char *cp;
+
+       if ((cp = value("screen")) != NOSTR && (s = atoi(cp)) > 0)
+               return s;
+       return screenheight - 4;
 }
 
 /*
 }
 
 /*
@@ -192,26 +172,18 @@ from(msgvec)
 printhead(mesg)
 {
        struct message *mp;
 printhead(mesg)
 {
        struct message *mp;
-       FILE *ibuf;
        char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind;
        char pbuf[BUFSIZ];
        char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind;
        char pbuf[BUFSIZ];
-       int s;
        struct headline hl;
        struct headline hl;
-       register char *cp;
+       int subjlen;
 
        mp = &message[mesg-1];
 
        mp = &message[mesg-1];
-       ibuf = setinput(mp);
-       readline(ibuf, headline);
-       subjline = hfield("subject", mp);
-       if (subjline == NOSTR)
+       readline(setinput(mp), headline);
+       if ((subjline = hfield("subject", mp)) == NOSTR)
                subjline = hfield("subj", mp);
                subjline = hfield("subj", mp);
-
        /*
         * Bletch!
         */
        /*
         * Bletch!
         */
-
-       if (subjline != NOSTR && strlen(subjline) > 28)
-               subjline[29] = '\0';
        curind = dot == mp ? '>' : ' ';
        dispc = ' ';
        if (mp->m_flag & MSAVED)
        curind = dot == mp ? '>' : ' ';
        dispc = ' ';
        if (mp->m_flag & MSAVED)
@@ -225,18 +197,15 @@ printhead(mesg)
        if (mp->m_flag & MBOX)
                dispc = 'M';
        parse(headline, &hl, pbuf);
        if (mp->m_flag & MBOX)
                dispc = 'M';
        parse(headline, &hl, pbuf);
-       sprintf(wcount, " %d/%ld", mp->m_lines, mp->m_size);
-       s = strlen(wcount);
-       cp = wcount + s;
-       while (s < 7)
-               s++, *cp++ = ' ';
-       *cp = '\0';
-       if (subjline != NOSTR)
-               printf("%c%c%3d %-8s %16.16s %s \"%s\"\n", curind, dispc, mesg,
-                   nameof(mp, 0), hl.l_date, wcount, subjline);
+       sprintf(wcount, "%3d/%-4ld", mp->m_lines, mp->m_size);
+       subjlen = screenwidth - 50 - strlen(wcount);
+       if (subjline == NOSTR || subjlen < 0)           /* pretty pathetic */
+               printf("%c%c%3d %-20.20s  %16.16s %s\n",
+                       curind, dispc, mesg, nameof(mp, 0), hl.l_date, wcount);
        else
        else
-               printf("%c%c%3d %-8s %16.16s %s\n", curind, dispc, mesg,
-                   nameof(mp, 0), hl.l_date, wcount);
+               printf("%c%c%3d %-20.20s  %16.16s %s \"%.*s\"\n",
+                       curind, dispc, mesg, nameof(mp, 0), hl.l_date, wcount,
+                       subjlen, subjline);
 }
 
 /*
 }
 
 /*
@@ -325,9 +294,9 @@ type1(msgvec, doign, page)
        register struct message *mp;
        register int mesg;
        register char *cp;
        register struct message *mp;
        register int mesg;
        register char *cp;
-       int c, nlines;
+       int nlines;
        int brokpipe();
        int brokpipe();
-       FILE *ibuf, *obuf;
+       FILE *obuf;
 
        obuf = stdout;
        if (setjmp(pipestop)) {
 
        obuf = stdout;
        if (setjmp(pipestop)) {
@@ -335,7 +304,7 @@ type1(msgvec, doign, page)
                        pipef = NULL;
                        pclose(obuf);
                }
                        pipef = NULL;
                        pclose(obuf);
                }
-               sigset(SIGPIPE, SIG_DFL);
+               signal(SIGPIPE, SIG_DFL);
                return(0);
        }
        if (intty && outtty && (page || (cp = value("crt")) != NOSTR)) {
                return(0);
        }
        if (intty && outtty && (page || (cp = value("crt")) != NOSTR)) {
@@ -352,25 +321,26 @@ type1(msgvec, doign, page)
                        if (obuf == NULL) {
                                perror(cp);
                                obuf = stdout;
                        if (obuf == NULL) {
                                perror(cp);
                                obuf = stdout;
-                       }
-                       else {
+                       } else {
                                pipef = obuf;
                                pipef = obuf;
-                               sigset(SIGPIPE, brokpipe);
+                               signal(SIGPIPE, brokpipe);
                        }
                }
        }
                        }
                }
        }
-       for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
+       for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) {
                mesg = *ip;
                touch(mesg);
                mp = &message[mesg-1];
                dot = mp;
                mesg = *ip;
                touch(mesg);
                mp = &message[mesg-1];
                dot = mp;
-               print(mp, obuf, doign);
+               if (value("quiet") == NOSTR)
+                       fprintf(obuf, "Message %d:\n", mesg);
+               send(mp, obuf, doign);
        }
        if (obuf != stdout) {
                pipef = NULL;
                pclose(obuf);
        }
        }
        if (obuf != stdout) {
                pipef = NULL;
                pclose(obuf);
        }
-       sigset(SIGPIPE, SIG_DFL);
+       signal(SIGPIPE, SIG_DFL);
        return(0);
 }
 
        return(0);
 }
 
@@ -381,27 +351,9 @@ type1(msgvec, doign, page)
 
 brokpipe()
 {
 
 brokpipe()
 {
-# ifndef VMUNIX
-       signal(SIGPIPE, brokpipe);
-# endif
        longjmp(pipestop, 1);
 }
 
        longjmp(pipestop, 1);
 }
 
-/*
- * Print the indicated message on standard output.
- */
-
-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, doign);
-}
-
 /*
  * Print the top so many lines of each desired message.
  * The number of lines is taken from the variable "toplines"
 /*
  * Print the top so many lines of each desired message.
  * The number of lines is taken from the variable "toplines"
@@ -438,7 +390,7 @@ top(msgvec)
                if (!lineb)
                        printf("\n");
                for (lines = 0; lines < c && lines <= topl; lines++) {
                if (!lineb)
                        printf("\n");
                for (lines = 0; lines < c && lines <= topl; lines++) {
-                       if (readline(ibuf, linebuf) <= 0)
+                       if (readline(ibuf, linebuf) < 0)
                                break;
                        puts(linebuf);
                        lineb = blankline(linebuf);
                                break;
                        puts(linebuf);
                        lineb = blankline(linebuf);
@@ -487,8 +439,9 @@ mboxit(msgvec)
  */
 folders()
 {
  */
 folders()
 {
-       char dirname[BUFSIZ], cmd[BUFSIZ];
-       int pid, s, e;
+       char dirname[BUFSIZ];
+       int pid, e;
+       union wait s;
 
        if (getfold(dirname) < 0) {
                printf("No value set for \"folder\"\n");
 
        if (getfold(dirname) < 0) {
                printf("No value set for \"folder\"\n");
@@ -496,7 +449,6 @@ folders()
        }
        switch ((pid = fork())) {
        case 0:
        }
        switch ((pid = fork())) {
        case 0:
-               sigchild();
                execlp("ls", "ls", dirname, 0);
                _exit(1);
 
                execlp("ls", "ls", dirname, 0);
                _exit(1);
 
index 6f99a87..1bf02e1 100644 (file)
@@ -5,11 +5,12 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)cmd2.c      5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)cmd2.c      5.4 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
+#include <sys/wait.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -275,7 +276,7 @@ snarf(linebuf, flag)
         * Strip away trailing blanks.
         */
 
         * Strip away trailing blanks.
         */
 
-       while (*cp == ' ' && cp > linebuf)
+       while (cp > linebuf && isspace(*cp))
                cp--;
        *++cp = 0;
 
                cp--;
        *++cp = 0;
 
@@ -283,13 +284,13 @@ snarf(linebuf, flag)
         * Now search for the beginning of the file name.
         */
 
         * Now search for the beginning of the file name.
         */
 
-       while (cp > linebuf && !any(*cp, "\t "))
+       while (cp > linebuf && !isspace(*cp))
                cp--;
        if (*cp == '\0') {
                printf("No file specified.\n");
                return(NOSTR);
        }
                cp--;
        if (*cp == '\0') {
                printf("No file specified.\n");
                return(NOSTR);
        }
-       if (any(*cp, " \t"))
+       if (isspace(*cp))
                *cp++ = 0;
        else
                *flag = 0;
                *cp++ = 0;
        else
                *flag = 0;
@@ -404,14 +405,13 @@ undelete(msgvec)
 core()
 {
        register int pid;
 core()
 {
        register int pid;
-       int status;
+       union wait status;
 
        if ((pid = vfork()) == -1) {
                perror("fork");
                return(1);
        }
        if (pid == 0) {
 
        if ((pid = vfork()) == -1) {
                perror("fork");
                return(1);
        }
        if (pid == 0) {
-               sigchild();
                abort();
                _exit(1);
        }
                abort();
                _exit(1);
        }
@@ -419,10 +419,11 @@ core()
        fflush(stdout);
        while (wait(&status) != pid)
                ;
        fflush(stdout);
        while (wait(&status) != pid)
                ;
-       if (status & 0200)
+       if (status.w_coredump)
                printf(" -- Core dumped\n");
        else
                printf("\n");
                printf(" -- Core dumped\n");
        else
                printf("\n");
+       return 0;
 }
 
 /*
 }
 
 /*
@@ -477,7 +478,8 @@ retfield(list)
 
                h = hash(field);
                igp = (struct ignore *) calloc(1, sizeof (struct ignore));
 
                h = hash(field);
                igp = (struct ignore *) calloc(1, sizeof (struct ignore));
-               igp->i_field = calloc(strlen(field) + 1, sizeof (char));
+               igp->i_field = calloc((unsigned) strlen(field) + 1,
+                       sizeof (char));
                strcpy(igp->i_field, field);
                igp->i_link = retain[h];
                retain[h] = igp;
                strcpy(igp->i_field, field);
                igp->i_link = retain[h];
                retain[h] = igp;
@@ -510,7 +512,7 @@ retshow()
                for (igp = retain[h]; igp != 0; igp = igp->i_link)
                        *ap++ = igp->i_field;
        *ap = 0;
                for (igp = retain[h]; igp != 0; igp = igp->i_link)
                        *ap++ = igp->i_field;
        *ap = 0;
-       qsort(ring, count, sizeof (char *), igcomp);
+       qsort((char *) ring, count, sizeof (char *), igcomp);
        for (ap = ring; *ap != 0; ap++)
                printf("%s\n", *ap);
        return(0);
        for (ap = ring; *ap != 0; ap++)
                printf("%s\n", *ap);
        return(0);
@@ -536,7 +538,8 @@ igfield(list)
                istrcpy(field, *ap);
                h = hash(field);
                igp = (struct ignore *) calloc(1, sizeof (struct ignore));
                istrcpy(field, *ap);
                h = hash(field);
                igp = (struct ignore *) calloc(1, sizeof (struct ignore));
-               igp->i_field = calloc(strlen(field) + 1, sizeof (char));
+               igp->i_field = calloc((unsigned) strlen(field) + 1,
+                       sizeof (char));
                strcpy(igp->i_field, field);
                igp->i_link = ignore[h];
                ignore[h] = igp;
                strcpy(igp->i_field, field);
                igp->i_link = ignore[h];
                ignore[h] = igp;
@@ -568,7 +571,7 @@ igshow()
                for (igp = ignore[h]; igp != 0; igp = igp->i_link)
                        *ap++ = igp->i_field;
        *ap = 0;
                for (igp = ignore[h]; igp != 0; igp = igp->i_link)
                        *ap++ = igp->i_field;
        *ap = 0;
-       qsort(ring, count, sizeof (char *), igcomp);
+       qsort((char *) ring, count, sizeof (char *), igcomp);
        for (ap = ring; *ap != 0; ap++)
                printf("%s\n", *ap);
        return(0);
        for (ap = ring; *ap != 0; ap++)
                printf("%s\n", *ap);
        return(0);
index 2aa78a6..47739a1 100644 (file)
@@ -5,11 +5,12 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)cmd3.c      5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)cmd3.c      5.4 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
+#include <sys/wait.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -25,7 +26,8 @@ static char *sccsid = "@(#)cmd3.c     5.3 (Berkeley) %G%";
 shell(str)
        char *str;
 {
 shell(str)
        char *str;
 {
-       int (*sig[2])(), stat[1];
+       int (*sigint)(), (*sigquit)();
+       union wait stat;
        register int t;
        char *Shell;
        char cmd[BUFSIZ];
        register int t;
        char *Shell;
        char cmd[BUFSIZ];
@@ -35,24 +37,24 @@ shell(str)
                return(-1);
        if ((Shell = value("SHELL")) == NOSTR)
                Shell = SHELL;
                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) {
        t = vfork();
        if (t == 0) {
-               sigchild();
-               for (t = 2; t < 4; t++)
-                       if (sig[t-2] != SIG_IGN)
-                               sigsys(t, SIG_DFL);
+               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);
        }
                execl(Shell, Shell, "-c", cmd, (char *)0);
                perror(Shell);
                _exit(1);
        }
-       while (wait(stat) != t)
+       while (wait(&stat) != t)
                ;
        if (t == -1)
                perror("fork");
                ;
        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);
 }
        printf("!\n");
        return(0);
 }
@@ -61,32 +63,35 @@ shell(str)
  * Fork an interactive shell.
  */
 
  * Fork an interactive shell.
  */
 
+/*ARGSUSED*/
 dosh(str)
        char *str;
 {
 dosh(str)
        char *str;
 {
-       int (*sig[2])(), stat[1];
+       int (*sigint)(), (*sigquit)();
+       union wait stat;
        register int t;
        char *Shell;
        register int t;
        char *Shell;
+
        if ((Shell = value("SHELL")) == NOSTR)
                Shell = 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) {
        t = vfork();
        if (t == 0) {
-               sigchild();
-               for (t = 2; t < 4; t++)
-                       if (sig[t-2] != SIG_IGN)
-                               sigsys(t, SIG_DFL);
+               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);
        }
                execl(Shell, Shell, (char *)0);
                perror(Shell);
                _exit(1);
        }
-       while (wait(stat) != t)
+       while (wait(&stat) != t)
                ;
        if (t == -1)
                perror("fork");
                ;
        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);
 }
        putchar('\n');
        return(0);
 }
@@ -205,7 +210,7 @@ _respond(msgvec)
        int *msgvec;
 {
        struct message *mp;
        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;
        char buf[2 * LINESIZE], **ap;
        struct name *np;
        struct header head;
@@ -233,7 +238,6 @@ _respond(msgvec)
                        strcpy(buf, cp);
        }
        np = elide(extract(buf, GTO));
                        strcpy(buf, cp);
        }
        np = elide(extract(buf, GTO));
-       /* rcv = rename(rcv); */
        mapf(np, rcv);
        /*
         * Delete my name from the reply list,
        mapf(np, rcv);
        /*
         * Delete my name from the reply list,
@@ -265,7 +269,7 @@ _respond(msgvec)
        head.h_subject = reedit(head.h_subject);
        head.h_cc = NOSTR;
        if (replyto == NOSTR) {
        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);
                if (cp != NOSTR) {
                        np = elide(extract(cp, GCC));
                        mapf(np, rcv);
@@ -300,7 +304,7 @@ reedit(subj)
        if (icequal(sbuf, "re:"))
                return(subj);
        newsubj = salloc(strlen(subj) + 6);
        if (icequal(sbuf, "re:"))
                return(subj);
        newsubj = salloc(strlen(subj) + 6);
-       sprintf(newsubj, "Re:  %s", subj);
+       sprintf(newsubj, "Re: %s", subj);
        return(newsubj);
 }
 
        return(newsubj);
 }
 
@@ -375,6 +379,7 @@ rexit(e)
        if (Tflag != NOSTR)
                close(creat(Tflag, 0600));
        exit(e);
        if (Tflag != NOSTR)
                close(creat(Tflag, 0600));
        exit(e);
+       /*NOTREACHED*/
 }
 
 /*
 }
 
 /*
@@ -433,7 +438,6 @@ unset(arglist)
        char **arglist;
 {
        register struct var *vp, *vp2;
        char **arglist;
 {
        register struct var *vp, *vp2;
-       register char *cp;
        int errs, h;
        char **ap;
 
        int errs, h;
        char **ap;
 
@@ -451,7 +455,7 @@ unset(arglist)
                        variables[h] = variables[h]->v_link;
                        vfree(vp2->v_name);
                        vfree(vp2->v_value);
                        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)
                        continue;
                }
                for (vp = variables[h]; vp->v_link != vp2; vp = vp->v_link)
@@ -459,7 +463,7 @@ unset(arglist)
                vp->v_link = vp2->v_link;
                vfree(vp2->v_name);
                vfree(vp2->v_value);
                vp->v_link = vp2->v_link;
                vfree(vp2->v_name);
                vfree(vp2->v_value);
-               cfree(vp2);
+               cfree((char *) vp2);
        }
        return(errs);
 }
        }
        return(errs);
 }
@@ -535,7 +539,7 @@ sort(list)
                ;
        if (ap-list < 2)
                return;
                ;
        if (ap-list < 2)
                return;
-       qsort(list, ap-list, sizeof *list, diction);
+       qsort((char *)list, ap-list, sizeof *list, diction);
 }
 
 /*
 }
 
 /*
@@ -553,9 +557,10 @@ diction(a, b)
  * The do nothing command for comments.
  */
 
  * The do nothing command for comments.
  */
 
+/*ARGSUSED*/
 null(e)
 {
 null(e)
 {
-       return(0);
+       return 0;
 }
 
 /*
 }
 
 /*
@@ -568,7 +573,6 @@ file(argv)
        char **argv;
 {
        register char *cp;
        char **argv;
 {
        register char *cp;
-       char fname[BUFSIZ];
        int edit;
 
        if (argv[0] == NOSTR) {
        int edit;
 
        if (argv[0] == NOSTR) {
@@ -594,6 +598,7 @@ file(argv)
                return(-1);
        }
        announce(0);
                return(-1);
        }
        announce(0);
+       return 0;
 }
 
 /*
 }
 
 /*
@@ -707,7 +712,7 @@ _Respond(msgvec)
 {
        struct header head;
        struct message *mp;
 {
        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++) {
        register char *cp, *cp2, *subject;
 
        for (s = 0, ap = msgvec; *ap != 0; ap++) {
@@ -840,9 +845,9 @@ alternates(namelist)
        }
        if (altnames != 0)
                cfree((char *) altnames);
        }
        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++) {
        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;
        }
                strcpy(cp, *ap);
                *ap2 = cp;
        }
index 9442858..10837a8 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)cmdtab.c    5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)cmdtab.c    5.4 (Berkeley) %G%";
 #endif not lint
 
 #include "def.h"
 #endif not lint
 
 #include "def.h"
@@ -17,7 +17,7 @@ static char *sccsid = "@(#)cmdtab.c   5.3 (Berkeley) %G%";
  */
 
 extern int type(), preserve(), delete(), undelete(), next(), shell(), schdir();
  */
 
 extern int type(), preserve(), delete(), undelete(), next(), shell(), schdir();
-extern int save(), help(), headers(), pdot(), strace(), respond(), editor();
+extern int save(), help(), headers(), pdot(), respond(), editor();
 extern int edstop(), rexit(), pcmdlist(), sendmail(), from(), copycmd();
 extern int messize(), psalloc(), deltype(), unset(), set(), source();
 extern int pversion(), group(), top(), core(), null(), stouch(), visual();
 extern int edstop(), rexit(), pcmdlist(), sendmail(), from(), copycmd();
 extern int messize(), psalloc(), deltype(), unset(), set(), source();
 extern int pversion(), group(), top(), core(), null(), stouch(), visual();
index 954e31c..574875e 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)collect.c   5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)collect.c   5.3 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -17,6 +17,7 @@ static char *sccsid = "@(#)collect.c  5.2 (Berkeley) %G%";
 
 #include "rcv.h"
 #include <sys/stat.h>
 
 #include "rcv.h"
 #include <sys/stat.h>
+#include <sys/wait.h>
 
 /*
  * Read a message from standard output and return a read file to it
 
 /*
  * Read a message from standard output and return a read file to it
@@ -26,19 +27,13 @@ static char *sccsid = "@(#)collect.c        5.2 (Berkeley) %G%";
 /*
  * The following hokiness with global variables is so that on
  * receipt of an interrupt signal, the partial message can be salted
 /*
  * The following hokiness with global variables is so that on
  * receipt of an interrupt signal, the partial message can be salted
- * away on dead.letter.  The output file must be available to flush,
- * and the input to read.  Several open files could be saved all through
- * Mail if stdio allowed simultaneous read/write access.
+ * away on dead.letter.
  */
 
  */
 
-static int     (*savesig)();           /* Previous SIGINT value */
+static int     (*saveint)();           /* Previous SIGINT value */
 static int     (*savehup)();           /* Previous SIGHUP value */
 static int     (*savehup)();           /* Previous SIGHUP value */
-# ifdef VMUNIX
 static int     (*savecont)();          /* Previous SIGCONT value */
 static int     (*savecont)();          /* Previous SIGCONT value */
-# endif VMUNIX
-static FILE    *newi;                  /* File for saving away */
-static FILE    *newo;                  /* Output side of same */
-static int     hf;                     /* Ignore interrups */
+static FILE    *collf;                 /* File for saving away */
 static int     hadintr;                /* Have seen one SIGINT so far */
 
 static jmp_buf coljmp;                 /* To get back to work */
 static int     hadintr;                /* Have seen one SIGINT so far */
 
 static jmp_buf coljmp;                 /* To get back to work */
@@ -47,46 +42,41 @@ FILE *
 collect(hp)
        struct header *hp;
 {
 collect(hp)
        struct header *hp;
 {
-       FILE *ibuf, *fbuf, *obuf;
-       int lc, cc, escape, collrub(), intack(), collhup, collcont(), eof;
+       FILE *fp, *fbuf;
+       int lc, cc, escape, eof;
+       int collrub(), intack(), collcont();
        register int c, t;
        char linebuf[LINESIZE], *cp;
        extern char tempMail[];
        int notify();
        register int c, t;
        char linebuf[LINESIZE], *cp;
        extern char tempMail[];
        int notify();
-       extern collintsig(), collhupsig();
        char getsub;
        char getsub;
+       int omask;
 
        noreset++;
 
        noreset++;
-       ibuf = obuf = NULL;
-       if (value("ignore") != NOSTR)
-               hf = 1;
-       else
-               hf = 0;
-       hadintr = 0;
-# ifdef VMUNIX
-       if ((savesig = sigset(SIGINT, SIG_IGN)) != SIG_IGN)
-               sigset(SIGINT, hf ? intack : collrub), sigblock(sigmask(SIGINT));
-       if ((savehup = sigset(SIGHUP, SIG_IGN)) != SIG_IGN)
-               sigset(SIGHUP, collrub), sigblock(sigmask(SIGHUP));
-       savecont = sigset(SIGCONT, collcont);
-# else VMUNIX
-       savesig = signal(SIGINT, SIG_IGN);
-       savehup = signal(SIGHUP, SIG_IGN);
-# endif VMUNIX
-       newi = NULL;
-       newo = NULL;
-       if ((obuf = fopen(tempMail, "w")) == NULL) {
-               perror(tempMail);
+       fp = NULL;
+       collf = NULL;
+
+       /*
+        * Start catching signals from here, but we're still die on interrupts
+        * until we're in the main loop.
+        */
+       omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
+       if ((saveint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
+               signal(SIGINT, value("ignore") != NOSTR ? intack : collrub);
+       if ((savehup = signal(SIGHUP, SIG_IGN)) != SIG_IGN)
+               signal(SIGHUP, collrub);
+       savecont = signal(SIGCONT, SIG_DFL);
+       if (setjmp(coljmp)) {
+               remove(tempMail);
                goto err;
        }
                goto err;
        }
-       newo = obuf;
-       if ((ibuf = fopen(tempMail, "r")) == NULL) {
+       sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
+
+       if ((fp = fopen(tempMail, "w+")) == NULL) {
                perror(tempMail);
                perror(tempMail);
-               newo = NULL;
-               fclose(obuf);
                goto err;
        }
                goto err;
        }
-       newi = ibuf;
+       collf = fp;
        remove(tempMail);
 
        /*
        remove(tempMail);
 
        /*
@@ -94,7 +84,6 @@ collect(hp)
         * refrain from printing a newline after
         * the headers (since some people mind).
         */
         * refrain from printing a newline after
         * the headers (since some people mind).
         */
-
        t = GTO|GSUBJECT|GCC|GNL;
        getsub = 0;
        if (intty && sflag == NOSTR && hp->h_subject == NOSTR && value("ask"))
        t = GTO|GSUBJECT|GCC|GNL;
        getsub = 0;
        if (intty && sflag == NOSTR && hp->h_subject == NOSTR && value("ask"))
@@ -107,30 +96,38 @@ collect(hp)
        if ((cp = value("escape")) != NOSTR)
                escape = *cp;
        eof = 0;
        if ((cp = value("escape")) != NOSTR)
                escape = *cp;
        eof = 0;
-       for (;;) {
-               int omask = sigblock(0) &~ (sigmask(SIGINT)|sigmask(SIGHUP));
-
-               setjmp(coljmp);
-# ifdef VMUNIX
-               sigsetmask(omask);
-# else VMUNIX
-               if (savesig != SIG_IGN)
-                       signal(SIGINT, hf ? intack : collintsig);
-               if (savehup != SIG_IGN)
-                       signal(SIGHUP, collhupsig);
-# endif VMUNIX
-               fflush(stdout);
-               if (getsub) {
+       hadintr = 0;
+
+       /*
+        * We can put the setjmp here because register variable
+        * needs to be saved in the loop.
+        */
+       if (!setjmp(coljmp)) {
+               signal(SIGCONT, collcont);
+               if (getsub)
                        grabh(hp, GSUBJECT);
                        grabh(hp, GSUBJECT);
-                       getsub = 0;
-                       continue;
+       } else {
+               /*
+                * Come here for printing the after-signal message.
+                * Duplicate messages won't be printed because
+                * the write is aborted if we get a SIGTTOU.
+                */
+cont:
+               if (hadintr) {
+                       fflush(stdout);
+                       fprintf(stderr,
+                       "\n(Interrupt -- one more to kill letter)\n");
+               } else {
+                       printf("(continue)\n");
+                       fflush(stdout);
                }
                }
-               if (readline(stdin, linebuf) <= 0) {
+       }
+       for (;;) {
+               if (readline(stdin, linebuf) < 0) {
                        if (intty && value("ignoreeof") != NOSTR) {
                                if (++eof > 35)
                                        break;
                        if (intty && value("ignoreeof") != NOSTR) {
                                if (++eof > 35)
                                        break;
-                               printf("Use \".\" to terminate letter\n",
-                                   escape);
+                               printf("Use \".\" to terminate letter\n");
                                continue;
                        }
                        break;
                                continue;
                        }
                        break;
@@ -141,7 +138,7 @@ collect(hp)
                    (value("dot") != NOSTR || value("ignoreeof") != NOSTR))
                        break;
                if (linebuf[0] != escape || rflag != NOSTR) {
                    (value("dot") != NOSTR || value("ignoreeof") != NOSTR))
                        break;
                if (linebuf[0] != escape || rflag != NOSTR) {
-                       if ((t = putline(obuf, linebuf)) < 0)
+                       if (putline(fp, linebuf) < 0)
                                goto err;
                        continue;
                }
                                goto err;
                        continue;
                }
@@ -154,7 +151,7 @@ collect(hp)
                         */
 
                        if (c == escape) {
                         */
 
                        if (c == escape) {
-                               if (putline(obuf, &linebuf[1]) < 0)
+                               if (putline(fp, &linebuf[1]) < 0)
                                        goto err;
                                else
                                        break;
                                        goto err;
                                else
                                        break;
@@ -186,14 +183,13 @@ collect(hp)
                         */
 
                        execute(&linebuf[2], 1);
                         */
 
                        execute(&linebuf[2], 1);
-                       printf("(continue)\n");
-                       break;
+                       goto cont;
 
                case '.':
                        /*
                         * Simulate end of file on input.
                         */
 
                case '.':
                        /*
                         * Simulate end of file on input.
                         */
-                       goto eofl;
+                       goto out;
 
                case 'q':
                case 'Q':
 
                case 'q':
                case 'Q':
@@ -215,8 +211,7 @@ collect(hp)
                                break;
                        }
                        grabh(hp, GTO|GSUBJECT|GCC|GBCC);
                                break;
                        }
                        grabh(hp, GTO|GSUBJECT|GCC|GBCC);
-                       printf("(continue)\n");
-                       break;
+                       goto cont;
 
                case 't':
                        /*
 
                case 't':
                        /*
@@ -233,7 +228,7 @@ collect(hp)
                         */
 
                        cp = &linebuf[2];
                         */
 
                        cp = &linebuf[2];
-                       while (any(*cp, " \t"))
+                       while (isspace(*cp))
                                cp++;
                        hp->h_subject = savestr(cp);
                        hp->h_seq++;
                                cp++;
                        hp->h_subject = savestr(cp);
                        hp->h_seq++;
@@ -257,18 +252,18 @@ collect(hp)
                        break;
 
                case 'd':
                        break;
 
                case 'd':
-                       copy(deadletter, &linebuf[2]);
+                       strcpy(linebuf + 2, deadletter);
                        /* fall into . . . */
 
                case 'r':
                        /*
                         * Invoke a file:
                         * Search for the file name,
                        /* fall into . . . */
 
                case 'r':
                        /*
                         * Invoke a file:
                         * Search for the file name,
-                        * then open it and copy the contents to obuf.
+                        * then open it and copy the contents to fp.
                         */
 
                        cp = &linebuf[2];
                         */
 
                        cp = &linebuf[2];
-                       while (any(*cp, " \t"))
+                       while (isspace(*cp))
                                cp++;
                        if (*cp == '\0') {
                                printf("Interpolate what file?\n");
                                cp++;
                        if (*cp == '\0') {
                                printf("Interpolate what file?\n");
@@ -278,7 +273,7 @@ collect(hp)
                        if (cp == NOSTR)
                                break;
                        if (isdir(cp)) {
                        if (cp == NOSTR)
                                break;
                        if (isdir(cp)) {
-                               printf("%s: directory\n");
+                               printf("%s: Directory\n", cp);
                                break;
                        }
                        if ((fbuf = fopen(cp, "r")) == NULL) {
                                break;
                        }
                        if ((fbuf = fopen(cp, "r")) == NULL) {
@@ -289,9 +284,9 @@ collect(hp)
                        fflush(stdout);
                        lc = 0;
                        cc = 0;
                        fflush(stdout);
                        lc = 0;
                        cc = 0;
-                       while (readline(fbuf, linebuf) > 0) {
+                       while (readline(fbuf, linebuf) >= 0) {
                                lc++;
                                lc++;
-                               if ((t = putline(obuf, linebuf)) < 0) {
+                               if ((t = putline(fp, linebuf)) < 0) {
                                        fclose(fbuf);
                                        goto err;
                                }
                                        fclose(fbuf);
                                        goto err;
                                }
@@ -315,9 +310,8 @@ collect(hp)
                        }
                        if ((cp = expand(cp)) == NOSTR)
                                break;
                        }
                        if ((cp = expand(cp)) == NOSTR)
                                break;
-                       fflush(obuf);
-                       rewind(ibuf);
-                       exwrite(cp, ibuf, 1);
+                       rewind(fp);
+                       exwrite(cp, fp, 1);
                        break;
 
                case 'm':
                        break;
 
                case 'm':
@@ -336,21 +330,17 @@ collect(hp)
                        cp = &linebuf[2];
                        while (any(*cp, " \t"))
                                cp++;
                        cp = &linebuf[2];
                        while (any(*cp, " \t"))
                                cp++;
-                       if (forward(cp, obuf, c) < 0)
+                       if (forward(cp, fp, c) < 0)
                                goto err;
                                goto err;
-                       printf("(continue)\n");
-                       break;
+                       goto cont;
 
                case '?':
                        if ((fbuf = fopen(THELPFILE, "r")) == NULL) {
                                perror(THELPFILE);
                                break;
                        }
 
                case '?':
                        if ((fbuf = fopen(THELPFILE, "r")) == NULL) {
                                perror(THELPFILE);
                                break;
                        }
-                       t = getc(fbuf);
-                       while (t != -1) {
+                       while ((t = getc(fp)) != EOF)
                                putchar(t);
                                putchar(t);
-                               t = getc(fbuf);
-                       }
                        fclose(fbuf);
                        break;
 
                        fclose(fbuf);
                        break;
 
@@ -360,17 +350,12 @@ collect(hp)
                         * message without altering anything.
                         */
 
                         * message without altering anything.
                         */
 
-                       fflush(obuf);
-                       rewind(ibuf);
+                       rewind(fp);
                        printf("-------\nMessage contains:\n");
                        puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL);
                        printf("-------\nMessage contains:\n");
                        puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL);
-                       t = getc(ibuf);
-                       while (t != EOF) {
+                       while ((t = getc(fp)) != EOF)
                                putchar(t);
                                putchar(t);
-                               t = getc(ibuf);
-                       }
-                       printf("(continue)\n");
-                       break;
+                       goto cont;
 
                case '^':
                case '|':
 
                case '^':
                case '|':
@@ -379,12 +364,9 @@ collect(hp)
                         * Collect output as new message.
                         */
 
                         * Collect output as new message.
                         */
 
-                       obuf = mespipe(ibuf, obuf, &linebuf[2]);
-                       newo = obuf;
-                       ibuf = newi;
-                       newi = ibuf;
-                       printf("(continue)\n");
-                       break;
+                       rewind(fp);
+                       fp = mespipe(fp, &linebuf[2]);
+                       goto cont;
 
                case 'v':
                case 'e':
 
                case 'v':
                case 'e':
@@ -394,61 +376,36 @@ collect(hp)
                         * 'v' means to use VISUAL
                         */
 
                         * 'v' means to use VISUAL
                         */
 
-                       if ((obuf = mesedit(ibuf, obuf, c)) == NULL)
+                       rewind(fp);
+                       if ((fp = mesedit(fp, c)) == NULL)
                                goto err;
                                goto err;
-                       newo = obuf;
-                       ibuf = newi;
-                       printf("(continue)\n");
-                       break;
+                       goto cont;
                }
        }
                }
        }
-eofl:
-       fclose(obuf);
-       rewind(ibuf);
-       sigset(SIGINT, savesig);
-       sigset(SIGHUP, savehup);
-# ifdef VMUNIX
-       sigset(SIGCONT, savecont);
-       sigsetmask(0);
-# endif VMUNIX
-       noreset = 0;
-       return(ibuf);
-
+       goto out;
 err:
 err:
-       if (ibuf != NULL)
-               fclose(ibuf);
-       if (obuf != NULL)
-               fclose(obuf);
-       sigset(SIGINT, savesig);
-       sigset(SIGHUP, savehup);
-# ifdef VMUNIX
-       sigset(SIGCONT, savecont);
-       sigsetmask(0);
-# endif VMUNIX
+       if (fp != NULL) {
+               fclose(fp);
+               fp = NULL;
+       }
+out:
+       if (fp != NULL)
+               rewind(fp);
+       signal(SIGINT, saveint);
+       signal(SIGHUP, savehup);
+       signal(SIGCONT, savecont);
+       sigsetmask(omask);
        noreset = 0;
        noreset = 0;
-       return(NULL);
-}
-
-/*
- * Non destructively interrogate the value of the given signal.
- */
-
-psig(n)
-{
-       register (*wassig)();
-
-       wassig = sigset(n, SIG_IGN);
-       sigset(n, wassig);
-       return((int) wassig);
+       return(fp);
 }
 
 /*
  * Write a file, ex-like if f set.
  */
 
 }
 
 /*
  * Write a file, ex-like if f set.
  */
 
-exwrite(name, ibuf, f)
+exwrite(name, fp, f)
        char name[];
        char name[];
-       FILE *ibuf;
+       FILE *fp;
 {
        register FILE *of;
        register int c;
 {
        register FILE *of;
        register int c;
@@ -463,7 +420,7 @@ exwrite(name, ibuf, f)
        if (stat(name, &junk) >= 0 && (junk.st_mode & S_IFMT) == S_IFREG) {
                if (!f)
                        fprintf(stderr, "%s: ", name);
        if (stat(name, &junk) >= 0 && (junk.st_mode & S_IFMT) == S_IFREG) {
                if (!f)
                        fprintf(stderr, "%s: ", name);
-               fprintf(stderr, "File exists\n", name);
+               fprintf(stderr, "File exists\n");
                return(-1);
        }
        if ((of = fopen(name, "w")) == NULL) {
                return(-1);
        }
        if ((of = fopen(name, "w")) == NULL) {
@@ -472,7 +429,7 @@ exwrite(name, ibuf, f)
        }
        lc = 0;
        cc = 0;
        }
        lc = 0;
        cc = 0;
-       while ((c = getc(ibuf)) != EOF) {
+       while ((c = getc(fp)) != EOF) {
                cc++;
                if (c == '\n')
                        lc++;
                cc++;
                if (c == '\n')
                        lc++;
@@ -490,7 +447,7 @@ exwrite(name, ibuf, f)
 }
 
 /*
 }
 
 /*
- * Edit the message being collected on ibuf and obuf.
+ * Edit the message being collected on fp.
  * Write the message out onto some poorly-named temp file
  * and point an editor at it.
  *
  * Write the message out onto some poorly-named temp file
  * and point an editor at it.
  *
@@ -498,21 +455,20 @@ exwrite(name, ibuf, f)
  */
 
 FILE *
  */
 
 FILE *
-mesedit(ibuf, obuf, c)
-       FILE *ibuf, *obuf;
+mesedit(fp, c)
+       FILE *fp;
 {
 {
-       int pid, s;
+       int pid;
+       union wait s;
        FILE *fbuf;
        register int t;
        FILE *fbuf;
        register int t;
-       int (*sig)(), (*scont)(), signull();
+       int (*sigint)(), (*sigcont)();
        struct stat sbuf;
        extern char tempMail[], tempEdit[];
        register char *edit;
 
        struct stat sbuf;
        extern char tempMail[], tempEdit[];
        register char *edit;
 
-       sig = sigset(SIGINT, SIG_IGN);
-# ifdef VMUNIX
-       scont = sigset(SIGCONT, signull);
-# endif VMUNIX
+       sigint = signal(SIGINT, SIG_IGN);
+       sigcont = signal(SIGCONT, SIG_DFL);
        if (stat(tempEdit, &sbuf) >= 0) {
                printf("%s: file exists\n", tempEdit);
                goto out;
        if (stat(tempEdit, &sbuf) >= 0) {
                printf("%s: file exists\n", tempEdit);
                goto out;
@@ -522,13 +478,8 @@ mesedit(ibuf, obuf, c)
                perror(tempEdit);
                goto out;
        }
                perror(tempEdit);
                goto out;
        }
-       fflush(obuf);
-       rewind(ibuf);
-       t = getc(ibuf);
-       while (t != EOF) {
+       while ((t = getc(fp)) != EOF)
                putc(t, fbuf);
                putc(t, fbuf);
-               t = getc(ibuf);
-       }
        fflush(fbuf);
        if (ferror(fbuf)) {
                perror(tempEdit);
        fflush(fbuf);
        if (ferror(fbuf)) {
                perror(tempEdit);
@@ -540,9 +491,8 @@ mesedit(ibuf, obuf, c)
                edit = c == 'e' ? EDITOR : VISUAL;
        pid = vfork();
        if (pid == 0) {
                edit = c == 'e' ? EDITOR : VISUAL;
        pid = vfork();
        if (pid == 0) {
-               sigchild();
-               if (sig != SIG_IGN)
-                       sigsys(SIGINT, SIG_DFL);
+               if (sigint != SIG_IGN)
+                       signal(SIGINT, SIG_DFL);
                execl(edit, edit, tempEdit, 0);
                perror(edit);
                _exit(1);
                execl(edit, edit, tempEdit, 0);
                perror(edit);
                _exit(1);
@@ -554,7 +504,7 @@ mesedit(ibuf, obuf, c)
        }
        while (wait(&s) != pid)
                ;
        }
        while (wait(&s) != pid)
                ;
-       if ((s & 0377) != 0) {
+       if (s.w_status != 0) {
                printf("Fatal error in \"%s\"\n", edit);
                remove(tempEdit);
                goto out;
                printf("Fatal error in \"%s\"\n", edit);
                remove(tempEdit);
                goto out;
@@ -564,31 +514,22 @@ mesedit(ibuf, obuf, c)
         * Now switch to new file.
         */
 
         * Now switch to new file.
         */
 
-       if ((fbuf = fopen(tempEdit, "a")) == NULL) {
+       if ((fbuf = fopen(tempEdit, "a+")) == NULL) {
                perror(tempEdit);
                remove(tempEdit);
                goto out;
        }
                perror(tempEdit);
                remove(tempEdit);
                goto out;
        }
-       if ((ibuf = fopen(tempEdit, "r")) == NULL) {
-               perror(tempEdit);
-               fclose(fbuf);
-               remove(tempEdit);
-               goto out;
-       }
        remove(tempEdit);
        remove(tempEdit);
-       fclose(obuf);
-       fclose(newi);
-       obuf = fbuf;
+       collf = fbuf;
+       fclose(fp);
+       fp = fbuf;
        goto out;
 fix:
        perror(tempEdit);
 out:
        goto out;
 fix:
        perror(tempEdit);
 out:
-# ifdef VMUNIX
-       sigset(SIGCONT, scont);
-# endif VMUNIX
-       sigset(SIGINT, sig);
-       newi = ibuf;
-       return(obuf);
+       signal(SIGCONT, sigcont);
+       signal(SIGINT, sigint);
+       return(fp);
 }
 
 /*
 }
 
 /*
@@ -599,30 +540,22 @@ out:
  */
 
 FILE *
  */
 
 FILE *
-mespipe(ibuf, obuf, cmd)
-       FILE *ibuf, *obuf;
+mespipe(fp, cmd)
+       FILE *fp;
        char cmd[];
 {
        char cmd[];
 {
-       register FILE *ni, *no;
-       int pid, s;
-       int (*savesig)();
+       register FILE *nf;
+       int pid;
+       union wait s;
+       int (*saveint)();
        char *Shell;
 
        char *Shell;
 
-       newi = ibuf;
-       if ((no = fopen(tempEdit, "w")) == NULL) {
+       if ((nf = fopen(tempEdit, "w+")) == NULL) {
                perror(tempEdit);
                perror(tempEdit);
-               return(obuf);
-       }
-       if ((ni = fopen(tempEdit, "r")) == NULL) {
-               perror(tempEdit);
-               fclose(no);
-               remove(tempEdit);
-               return(obuf);
+               return(fp);
        }
        remove(tempEdit);
        }
        remove(tempEdit);
-       savesig = sigset(SIGINT, SIG_IGN);
-       fflush(obuf);
-       rewind(ibuf);
+       saveint = signal(SIGINT, SIG_IGN);
        if ((Shell = value("SHELL")) == NULL)
                Shell = "/bin/sh";
        if ((pid = vfork()) == -1) {
        if ((Shell = value("SHELL")) == NULL)
                Shell = "/bin/sh";
        if ((pid = vfork()) == -1) {
@@ -630,29 +563,29 @@ mespipe(ibuf, obuf, cmd)
                goto err;
        }
        if (pid == 0) {
                goto err;
        }
        if (pid == 0) {
+               int fd;
                /*
                 * stdin = current message.
                 * stdout = new message.
                 */
 
                /*
                 * stdin = current message.
                 * stdout = new message.
                 */
 
-               sigchild();
                close(0);
                close(0);
-               dup(fileno(ibuf));
+               dup(fileno(fp));
                close(1);
                close(1);
-               dup(fileno(no));
-               for (s = 4; s < 15; s++)
-                       close(s);
+               dup(fileno(nf));
+               for (fd = getdtablesize(); --fd > 2;)
+                       close(fd);
                execl(Shell, Shell, "-c", cmd, 0);
                perror(Shell);
                _exit(1);
        }
        while (wait(&s) != pid)
                ;
                execl(Shell, Shell, "-c", cmd, 0);
                perror(Shell);
                _exit(1);
        }
        while (wait(&s) != pid)
                ;
-       if (s != 0 || pid == -1) {
+       if (s.w_status != 0 || pid == -1) {
                fprintf(stderr, "\"%s\" failed!?\n", cmd);
                goto err;
        }
                fprintf(stderr, "\"%s\" failed!?\n", cmd);
                goto err;
        }
-       if (fsize(ni) == 0) {
+       if (fsize(nf) == 0) {
                fprintf(stderr, "No bytes from \"%s\" !?\n", cmd);
                goto err;
        }
                fprintf(stderr, "No bytes from \"%s\" !?\n", cmd);
                goto err;
        }
@@ -661,17 +594,16 @@ mespipe(ibuf, obuf, cmd)
         * Take new files.
         */
 
         * Take new files.
         */
 
-       newi = ni;
-       fclose(ibuf);
-       fclose(obuf);
-       sigset(SIGINT, savesig);
-       return(no);
+       fseek(nf, 0L, 2);
+       collf = nf;
+       fclose(fp);
+       signal(SIGINT, saveint);
+       return(nf);
 
 err:
 
 err:
-       fclose(no);
-       fclose(ni);
-       sigset(SIGINT, savesig);
-       return(obuf);
+       fclose(nf);
+       signal(SIGINT, saveint);
+       return(fp);
 }
 
 /*
 }
 
 /*
@@ -682,9 +614,9 @@ err:
  * the message temporary.  The flag argument is 'm' if we
  * should shift over and 'f' if not.
  */
  * the message temporary.  The flag argument is 'm' if we
  * should shift over and 'f' if not.
  */
-forward(ms, obuf, f)
+forward(ms, fp, f)
        char ms[];
        char ms[];
-       FILE *obuf;
+       FILE *fp;
 {
        register int *msgvec, *ip;
        extern char tempMail[];
 {
        register int *msgvec, *ip;
        extern char tempMail[];
@@ -707,12 +639,12 @@ forward(ms, obuf, f)
                touch(*ip);
                printf(" %d", *ip);
                if (f == 'm') {
                touch(*ip);
                printf(" %d", *ip);
                if (f == 'm') {
-                       if (transmit(&message[*ip-1], obuf) < 0L) {
+                       if (transmit(&message[*ip-1], fp) < 0L) {
                                perror(tempMail);
                                return(-1);
                        }
                } else
                                perror(tempMail);
                                return(-1);
                        }
                } else
-                       if (send(&message[*ip-1], obuf, 0) < 0) {
+                       if (send(&message[*ip-1], fp, 0) < 0) {
                                perror(tempMail);
                                return(-1);
                        }
                                perror(tempMail);
                                return(-1);
                        }
@@ -729,9 +661,9 @@ forward(ms, obuf, f)
  */
 
 long
  */
 
 long
-transmit(mailp, obuf)
+transmit(mailp, fp)
        struct message *mailp;
        struct message *mailp;
-       FILE *obuf;
+       FILE *fp;
 {
        register struct message *mp;
        register int ch;
 {
        register struct message *mp;
        register int ch;
@@ -745,20 +677,16 @@ transmit(mailp, obuf)
        n = c;
        bol = 1;
        while (c-- > 0L) {
        n = c;
        bol = 1;
        while (c-- > 0L) {
-               if (bol) {
+               ch = getc(ibuf);
+               if (ch == '\n')
+                       bol = 1;
+               else if (bol) {
                        bol = 0;
                        bol = 0;
-                       putc('\t', obuf);
+                       putc('\t', fp);
                        n++;
                        n++;
-                       if (ferror(obuf)) {
-                               perror("/tmp");
-                               return(-1L);
-                       }
                }
                }
-               ch = getc(ibuf);
-               if (ch == '\n')
-                       bol++;
-               putc(ch, obuf);
-               if (ferror(obuf)) {
+               putc(ch, fp);
+               if (ferror(fp)) {
                        perror("/tmp");
                        return(-1L);
                }
                        perror("/tmp");
                        return(-1L);
                }
@@ -769,11 +697,12 @@ transmit(mailp, obuf)
 /*
  * Print (continue) when continued after ^Z.
  */
 /*
  * Print (continue) when continued after ^Z.
  */
+/*ARGSUSED*/
 collcont(s)
 {
 
 collcont(s)
 {
 
-       printf("(continue)\n");
-       fflush(stdout);
+       hadintr = 0;
+       longjmp(coljmp, 1);
 }
 
 /*
 }
 
 /*
@@ -784,56 +713,36 @@ collcont(s)
  * were previously set anyway.
  */
 
  * were previously set anyway.
  */
 
-# ifndef VMUNIX
-collintsig()
-{
-       signal(SIGINT, SIG_IGN);
-       collrub(SIGINT);
-}
-
-collhupsig()
-{
-       signal(SIGHUP, SIG_IGN);
-       collrub(SIGHUP);
-}
-# endif VMUNIX
-
 collrub(s)
 {
        register FILE *dbuf;
        register int c;
 
        if (s == SIGINT && hadintr == 0) {
 collrub(s)
 {
        register FILE *dbuf;
        register int c;
 
        if (s == SIGINT && hadintr == 0) {
-               hadintr++;
-               fflush(stdout);
-               fprintf(stderr, "\n(Interrupt -- one more to kill letter)\n");
+               hadintr = 1;
                longjmp(coljmp, 1);
        }
                longjmp(coljmp, 1);
        }
-       fclose(newo);
-       rewind(newi);
-       if (s == SIGINT && value("nosave") != NOSTR || fsize(newi) == 0)
+       rewind(collf);
+       if (s == SIGINT && value("nosave") != NOSTR || fsize(collf) == 0)
                goto done;
        if ((dbuf = fopen(deadletter, "w")) == NULL)
                goto done;
        chmod(deadletter, 0600);
                goto done;
        if ((dbuf = fopen(deadletter, "w")) == NULL)
                goto done;
        chmod(deadletter, 0600);
-       while ((c = getc(newi)) != EOF)
+       while ((c = getc(collf)) != EOF)
                putc(c, dbuf);
        fclose(dbuf);
 
 done:
                putc(c, dbuf);
        fclose(dbuf);
 
 done:
-       fclose(newi);
-       sigset(SIGINT, savesig);
-       sigset(SIGHUP, savehup);
-# ifdef VMUNIX
-       sigset(SIGCONT, savecont);
-# endif VMUNIX
+       fclose(collf);
+       signal(SIGINT, saveint);
+       signal(SIGHUP, savehup);
+       signal(SIGCONT, savecont);
        if (rcvmode) {
                if (s == SIGHUP)
                        hangup(SIGHUP);
                else
                        stop(s);
        if (rcvmode) {
                if (s == SIGHUP)
                        hangup(SIGHUP);
                else
                        stop(s);
-       }
-       else
+       } else
                exit(1);
 }
 
                exit(1);
 }
 
@@ -841,9 +750,10 @@ done:
  * Acknowledge an interrupt signal from the tty by typing an @
  */
 
  * Acknowledge an interrupt signal from the tty by typing an @
  */
 
+/*ARGSUSED*/
 intack(s)
 {
 intack(s)
 {
-       
+
        puts("@");
        fflush(stdout);
        clearerr(stdin);
        puts("@");
        fflush(stdout);
        clearerr(stdin);
index a597628..162c0bf 100644 (file)
@@ -3,34 +3,20 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)def.h       5.2 (Berkeley) %G%
+ *     @(#)def.h       5.3 (Berkeley) %G%
  */
 
 #include <sys/param.h>         /* includes <sys/types.h> */
  */
 
 #include <sys/param.h>         /* includes <sys/types.h> */
-#include <signal.h>
+#include <sys/signal.h>
 #include <stdio.h>
 #include <sgtty.h>
 #include <stdio.h>
 #include <sgtty.h>
+#include <ctype.h>
+#include <strings.h>
 #include "local.h"
 
 #include "local.h"
 
-#undef isalpha
-#undef isdigit
-
 /*
  * Mail -- a mail program
  *
 /*
  * Mail -- a mail program
  *
- * Commands are:
- *     t <message list>                print out these messages
- *     r <message list>                reply to messages
- *     m <user list>                   mail to users (analogous to send)
- *     e <message list>                edit messages
- *     c [directory]                   chdir to dir or home if none
- *     x                               exit quickly
- *     w <message list> file           save messages in file
- *     q                               quit, save remaining stuff in mbox
- *     d <message list>                delete messages
- *     u <message list>                undelete messages
- *     h                               print message headers
- *
  * Author: Kurt Shoens (UCB) March 25, 1978
  */
 
  * Author: Kurt Shoens (UCB) March 25, 1978
  */
 
@@ -46,6 +32,7 @@
 #define        MAXARGC         1024            /* Maximum list of raw strings */
 #define        NOSTR           ((char *) 0)    /* Null string pointer */
 #define        MAXEXP          25              /* Maximum expansion of aliases */
 #define        MAXARGC         1024            /* Maximum list of raw strings */
 #define        NOSTR           ((char *) 0)    /* Null string pointer */
 #define        MAXEXP          25              /* Maximum expansion of aliases */
+
 #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
 
 struct message {
 #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
 
 struct message {
@@ -72,6 +59,13 @@ struct message {
 #define        MSTATUS         (1<<9)          /* message status has changed */
 #define        MBOX            (1<<10)         /* Send this to mbox, regardless */
 
 #define        MSTATUS         (1<<9)          /* message status has changed */
 #define        MBOX            (1<<10)         /* Send this to mbox, regardless */
 
+/*
+ * Given a file address, determine the block number it represents.
+ */
+#define blockof(off)                   ((int) ((off) / 4096))
+#define offsetof(off)                  ((int) ((off) % 4096))
+#define positionof(block, offset)      ((off_t)(block) * 4096 + (offset))
+
 /*
  * Format of the command description table.
  * The actual table is declared and initialized
 /*
  * Format of the command description table.
  * The actual table is declared and initialized
@@ -237,26 +231,6 @@ struct ignore {
 #define        setexit()       setjmp(srbuf)
 #define        reset(x)        longjmp(srbuf, x)
 
 #define        setexit()       setjmp(srbuf)
 #define        reset(x)        longjmp(srbuf, x)
 
-/*
- * VM/UNIX has a vfork system call which is faster than forking.  If we
- * don't have it, fork(2) will do . . .
- */
-
-#ifndef VMUNIX
-#define        vfork() fork()
-#endif
-#ifndef        SIGRETRO
-#define        sigchild()
-#endif
-
-/*
- * 4.2bsd signal interface help...
- */
-#ifdef VMUNIX
-#define        sigset(s, a)    signal(s, a)
-#define        sigsys(s, a)    signal(s, a)
-#endif
-
 /*
  * Truncate a file to the last character written. This is
  * useful just before closing an old file that was opened
 /*
  * Truncate a file to the last character written. This is
  * useful just before closing an old file that was opened
@@ -285,34 +259,28 @@ char      *detract();
 char   *expand();
 char   *gets();
 char   *hfield();
 char   *expand();
 char   *gets();
 char   *hfield();
-char   *index();
 char   *name1();
 char   *nameof();
 char   *nextword();
 char   *getenv();
 char   *getfilename();
 char   *name1();
 char   *nameof();
 char   *nextword();
 char   *getenv();
 char   *getfilename();
-char   *hcontents();
+char   *ishfield();
+char   *malloc();
 char   *netmap();
 char   *netname();
 char   *readtty();
 char   *reedit();
 char   *netmap();
 char   *netname();
 char   *readtty();
 char   *reedit();
-char   *rename();
 char   *revarpa();
 char   *revarpa();
-char   *rindex();
 char   *rpair();
 char   *salloc();
 char   *savestr();
 char   *skin();
 char   *snarf();
 char   *rpair();
 char   *salloc();
 char   *savestr();
 char   *skin();
 char   *snarf();
-char   *strcat();
-char   *strcpy();
+char   *sprintf();
 char   *value();
 char   *vcopy();
 char   *yankword();
 off_t  fsize();
 char   *value();
 char   *vcopy();
 char   *yankword();
 off_t  fsize();
-#ifndef VMUNIX
-int    (*sigset())();
-#endif
 struct cmd     *lex();
 struct grouphead       *findgroup();
 struct name    *cat();
 struct cmd     *lex();
 struct grouphead       *findgroup();
 struct name    *cat();
@@ -328,4 +296,3 @@ struct      name    *verify();
 struct var     *lookup();
 long   transmit();
 int    icequal();
 struct var     *lookup();
 long   transmit();
 int    icequal();
-int    cmpdomain();
index 37ee008..ab9b8c5 100644 (file)
@@ -5,12 +5,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)edit.c      5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)edit.c      5.3 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #include <stdio.h>
 #include <sys/stat.h>
 #endif not lint
 
 #include "rcv.h"
 #include <stdio.h>
 #include <sys/stat.h>
+#include <sys/wait.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -56,25 +57,24 @@ edit1(msgvec, ed)
        int *msgvec;
        char *ed;
 {
        int *msgvec;
        char *ed;
 {
-       register char *cp, *cp2;
        register int c;
        register int c;
-       int *ip, pid, mesg, lines;
-       long ms;
+       int *ip, pid, mesg;
        int (*sigint)(), (*sigquit)();
        FILE *ibuf, *obuf;
        char edname[15], nbuf[10];
        int (*sigint)(), (*sigquit)();
        FILE *ibuf, *obuf;
        char edname[15], nbuf[10];
-       struct message *mp;
+       register struct message *mp;
        extern char tempEdit[];
        off_t fsize(), size;
        struct stat statb;
        long modtime;
        extern char tempEdit[];
        off_t fsize(), size;
        struct stat statb;
        long modtime;
+       union wait status;
 
        /*
         * Set signals; locate editor.
         */
 
 
        /*
         * Set signals; locate editor.
         */
 
-       sigint = sigset(SIGINT, SIG_IGN);
-       sigquit = sigset(SIGQUIT, SIG_IGN);
+       sigint = signal(SIGINT, SIG_IGN);
+       sigquit = signal(SIGQUIT, SIG_IGN);
 
        /*
         * Deal with each message to be edited . . .
 
        /*
         * Deal with each message to be edited . . .
@@ -84,22 +84,15 @@ edit1(msgvec, ed)
                mesg = *ip;
                mp = &message[mesg-1];
                mp->m_flag |= MODIFY;
                mesg = *ip;
                mp = &message[mesg-1];
                mp->m_flag |= MODIFY;
+               touch(mesg);
+               dot = mp;
 
                /*
                 * Make up a name for the edit file of the
                 * form "Message%d" and make sure it doesn't
                 * already exist.
                 */
 
                /*
                 * Make up a name for the edit file of the
                 * form "Message%d" and make sure it doesn't
                 * already exist.
                 */
-
-               cp = &nbuf[10];
-               *--cp = 0;
-               while (mesg) {
-                       *--cp = mesg % 10 + '0';
-                       mesg /= 10;
-               }
-               cp2 = copy("Message", edname);
-               while (*cp2++ = *cp++)
-                       ;
+               sprintf(edname, "Message%d", mesg);
                if (!access(edname, 2)) {
                        printf("%s: file exists\n", edname);
                        goto out;
                if (!access(edname, 2)) {
                        printf("%s: file exists\n", edname);
                        goto out;
@@ -108,7 +101,6 @@ edit1(msgvec, ed)
                /*
                 * Copy the message into the edit file.
                 */
                /*
                 * Copy the message into the edit file.
                 */
-
                close(creat(edname, 0600));
                if ((obuf = fopen(edname, "w")) == NULL) {
                        perror(edname);
                close(creat(edname, 0600));
                if ((obuf = fopen(edname, "w")) == NULL) {
                        perror(edname);
@@ -150,16 +142,15 @@ edit1(msgvec, ed)
                        goto out;
                }
                if (pid == 0) {
                        goto out;
                }
                if (pid == 0) {
-                       sigchild();
                        if (sigint != SIG_IGN)
                        if (sigint != SIG_IGN)
-                               sigsys(SIGINT, SIG_DFL);
+                               signal(SIGINT, SIG_DFL);
                        if (sigquit != SIG_IGN)
                        if (sigquit != SIG_IGN)
-                               sigsys(SIGQUIT, SIG_DFL);
+                               signal(SIGQUIT, SIG_DFL);
                        execl(ed, ed, edname, 0);
                        perror(ed);
                        _exit(1);
                }
                        execl(ed, ed, edname, 0);
                        perror(ed);
                        _exit(1);
                }
-               while (wait(&mesg) != pid)
+               while (wait(&status) != pid)
                        ;
 
                /*
                        ;
 
                /*
@@ -192,21 +183,18 @@ edit1(msgvec, ed)
                }
                remove(edname);
                fseek(otf, (long) 0, 2);
                }
                remove(edname);
                fseek(otf, (long) 0, 2);
-               size = fsize(otf);
+               size = ftell(otf);
                mp->m_block = blockof(size);
                mp->m_offset = offsetof(size);
                mp->m_block = blockof(size);
                mp->m_offset = offsetof(size);
-               ms = 0L;
-               lines = 0;
+               mp->m_size = fsize(ibuf);
+               mp->m_lines = 0;
                while ((c = getc(ibuf)) != EOF) {
                        if (c == '\n')
                while ((c = getc(ibuf)) != EOF) {
                        if (c == '\n')
-                               lines++;
+                               mp->m_lines++;
                        putc(c, otf);
                        if (ferror(otf))
                                break;
                        putc(c, otf);
                        if (ferror(otf))
                                break;
-                       ms++;
                }
                }
-               mp->m_size = ms;
-               mp->m_lines = lines;
                if (ferror(otf))
                        perror("/tmp");
                fclose(ibuf);
                if (ferror(otf))
                        perror("/tmp");
                fclose(ibuf);
@@ -217,6 +205,7 @@ edit1(msgvec, ed)
         */
 
 out:
         */
 
 out:
-       sigset(SIGINT, sigint);
-       sigset(SIGQUIT, sigquit);
+       signal(SIGINT, sigint);
+       signal(SIGQUIT, sigquit);
+       return 0;
 }
 }
index 7877464..c213cea 100644 (file)
@@ -5,13 +5,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)fio.c       5.4 (Berkeley) %G%";
+static char *sccsid = "@(#)fio.c       5.5 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
 #endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/wait.h>
 #include <errno.h>
 #include <errno.h>
-#include <strings.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -23,90 +24,86 @@ static char *sccsid = "@(#)fio.c    5.4 (Berkeley) %G%";
  * Set up the input pointers while copying the mail file into
  * /tmp.
  */
  * Set up the input pointers while copying the mail file into
  * /tmp.
  */
-
 setptr(ibuf)
 setptr(ibuf)
-       FILE *ibuf;
+       register FILE *ibuf;
 {
 {
-       register int c;
+       register c;
        register char *cp, *cp2;
        register char *cp, *cp2;
-       register int count, l;
-       long s;
-       off_t offset;
+       register count;
        char linebuf[LINESIZE];
        char linebuf[LINESIZE];
-       char wbuf[LINESIZE];
-       int maybe, mestmp, flag, inhead;
+       int maybe, inhead;
+       FILE *mestmp;
+       off_t offset;
        struct message this;
        extern char tempSet[];
 
        struct message this;
        extern char tempSet[];
 
-       if ((mestmp = opentemp(tempSet)) < 0)
+       if ((c = opentemp(tempSet)) < 0)
                exit(1);
                exit(1);
+       if ((mestmp = fdopen(c, "r+")) == NULL)
+               panic("Can't open temporary");
        msgCount = 0;
        msgCount = 0;
-       offset = 0;
-       s = 0L;
-       l = 0;
        maybe = 1;
        maybe = 1;
-       flag = MUSED|MNEW;
+       inhead = 0;
+       offset = 0;
+       this.m_flag = MUSED|MNEW;
+       this.m_size = 0;
+       this.m_lines = 0;
+       this.m_block = 0;
+       this.m_offset = 0;
        for (;;) {
                if (fgets(linebuf, LINESIZE, ibuf) == NULL) {
        for (;;) {
                if (fgets(linebuf, LINESIZE, ibuf) == NULL) {
-                       this.m_flag = flag;
-                       flag = MUSED|MNEW;
-                       this.m_offset = offsetof(offset);
-                       this.m_block = blockof(offset);
-                       this.m_size = s;
-                       this.m_lines = l;
                        if (append(&this, mestmp)) {
                                perror(tempSet);
                                exit(1);
                        }
                        fclose(ibuf);
                        makemessage(mestmp);
                        if (append(&this, mestmp)) {
                                perror(tempSet);
                                exit(1);
                        }
                        fclose(ibuf);
                        makemessage(mestmp);
-                       close(mestmp);
                        return;
                }
                count = strlen(linebuf);
                        return;
                }
                count = strlen(linebuf);
-               fputs(linebuf, otf);
-               cp = linebuf + (count - 1);
-               if (*cp == '\n')
-                       *cp = 0;
+               fwrite(linebuf, sizeof *linebuf, count, otf);
                if (ferror(otf)) {
                        perror("/tmp");
                        exit(1);
                }
                if (ferror(otf)) {
                        perror("/tmp");
                        exit(1);
                }
+               linebuf[count - 1] = 0;
                if (maybe && linebuf[0] == 'F' && ishead(linebuf)) {
                        msgCount++;
                if (maybe && linebuf[0] == 'F' && ishead(linebuf)) {
                        msgCount++;
-                       this.m_flag = flag;
-                       flag = MUSED|MNEW;
-                       inhead = 1;
-                       this.m_block = blockof(offset);
-                       this.m_offset = offsetof(offset);
-                       this.m_size = s;
-                       this.m_lines = l;
-                       s = 0L;
-                       l = 0;
                        if (append(&this, mestmp)) {
                                perror(tempSet);
                                exit(1);
                        }
                        if (append(&this, mestmp)) {
                                perror(tempSet);
                                exit(1);
                        }
-               }
-               if (linebuf[0] == 0)
+                       this.m_flag = MUSED|MNEW;
+                       this.m_size = 0;
+                       this.m_lines = 0;
+                       this.m_block = blockof(offset);
+                       this.m_offset = offsetof(offset);
+                       inhead = 1;
+               } else if (linebuf[0] == 0) {
                        inhead = 0;
                        inhead = 0;
-               if (inhead && (cp = index(linebuf, ':'))) {
-                       *cp = 0;
-                       if (icequal(linebuf, "status")) {
-                               ++cp;
-                               if (index(cp, 'R'))
-                                       flag |= MREAD;
-                               if (index(cp, 'O'))
-                                       flag &= ~MNEW;
-                               inhead = 0;
+               } else if (inhead) {
+                       for (cp = linebuf, cp2 = "status";; cp++) {
+                               if ((c = *cp2++) == 0) {
+                                       while (isspace(*cp++))
+                                               ;
+                                       if (cp[-1] != ':')
+                                               break;
+                                       while (c = *cp++)
+                                               if (c == 'R')
+                                                       this.m_flag |= MREAD;
+                                               else if (c == 'O')
+                                                       this.m_flag &= ~MNEW;
+                                       inhead = 0;
+                                       break;
+                               }
+                               if (*cp != c && *cp != toupper(c))
+                                       break;
                        }
                }
                offset += count;
                        }
                }
                offset += count;
-               s += (long) count;
-               l++;
-               maybe = 0;
-               if (linebuf[0] == 0)
-                       maybe = 1;
+               this.m_size += count;
+               this.m_lines++;
+               maybe = linebuf[0] == 0;
        }
 }
 
        }
 }
 
@@ -115,7 +112,6 @@ setptr(ibuf)
  * If a write error occurs, return -1, else the count of
  * characters written, including the newline.
  */
  * If a write error occurs, return -1, else the count of
  * characters written, including the newline.
  */
-
 putline(obuf, linebuf)
        FILE *obuf;
        char *linebuf;
 putline(obuf, linebuf)
        FILE *obuf;
        char *linebuf;
@@ -123,11 +119,11 @@ putline(obuf, linebuf)
        register int c;
 
        c = strlen(linebuf);
        register int c;
 
        c = strlen(linebuf);
-       fputs(linebuf, obuf);
+       fwrite(linebuf, sizeof *linebuf, c, obuf);
        putc('\n', obuf);
        if (ferror(obuf))
        putc('\n', obuf);
        if (ferror(obuf))
-               return(-1);
-       return(c+1);
+               return (-1);
+       return (c + 1);
 }
 
 /*
 }
 
 /*
@@ -135,7 +131,6 @@ putline(obuf, linebuf)
  * buffer.  Return the number of characters read.  Do not
  * include the newline at the end.
  */
  * buffer.  Return the number of characters read.  Do not
  * include the newline at the end.
  */
-
 readline(ibuf, linebuf)
        FILE *ibuf;
        char *linebuf;
 readline(ibuf, linebuf)
        FILE *ibuf;
        char *linebuf;
@@ -144,84 +139,69 @@ readline(ibuf, linebuf)
 
        clearerr(ibuf);
        if (fgets(linebuf, LINESIZE, ibuf) == NULL)
 
        clearerr(ibuf);
        if (fgets(linebuf, LINESIZE, ibuf) == NULL)
-               return(0);
+               return -1;
        n = strlen(linebuf);
        n = strlen(linebuf);
-       if (n >= 1 && linebuf[n-1] == '\n')
-               linebuf[n-1] = '\0';
-       return(n);
+       if (n > 0 && linebuf[n - 1] == '\n')
+               linebuf[--n] = '\0';
+       return n;
 }
 
 /*
  * Return a file buffer all ready to read up the
  * passed message pointer.
  */
 }
 
 /*
  * Return a file buffer all ready to read up the
  * passed message pointer.
  */
-
 FILE *
 setinput(mp)
        register struct message *mp;
 {
 FILE *
 setinput(mp)
        register struct message *mp;
 {
-       off_t off;
 
        fflush(otf);
 
        fflush(otf);
-       off = mp->m_block;
-       off <<= 9;
-       off += mp->m_offset;
-       if (fseek(itf, off, 0) < 0) {
+       if (fseek(itf, positionof(mp->m_block, mp->m_offset), 0) < 0) {
                perror("fseek");
                panic("temporary file seek");
        }
                perror("fseek");
                panic("temporary file seek");
        }
-       return(itf);
+       return (itf);
 }
 
 /*
  * Take the data out of the passed ghost file and toss it into
  * a dynamically allocated message structure.
  */
 }
 
 /*
  * Take the data out of the passed ghost file and toss it into
  * a dynamically allocated message structure.
  */
-
 makemessage(f)
 makemessage(f)
+       FILE *f;
 {
 {
-       register struct message *m;
-       register char *mp;
-       register count;
+       register size = (msgCount + 1) * sizeof (struct message);
+       off_t lseek();
 
 
-       mp = calloc((unsigned) (msgCount + 1), sizeof *m);
-       if (mp == NOSTR) {
-               printf("Insufficient memory for %d messages\n", msgCount);
-               exit(1);
-       }
-       if (message != (struct message *) 0)
-               cfree((char *) message);
-       message = (struct message *) mp;
+       if (message != 0)
+               free((char *) message);
+       if ((message = (struct message *) malloc((unsigned) size)) == 0)
+               panic("Insufficient memory for %d messages", msgCount);
        dot = message;
        dot = message;
-       lseek(f, 0L, 0);
-       while (count = read(f, mp, BUFSIZ))
-               mp += count;
-       for (m = &message[0]; m < &message[msgCount]; m++) {
-               m->m_size = (m+1)->m_size;
-               m->m_lines = (m+1)->m_lines;
-               m->m_flag = (m+1)->m_flag;
-       }
-       message[msgCount].m_size = 0L;
+       size -= sizeof (struct message);
+       fflush(f);
+       lseek(fileno(f), (long) sizeof *message, 0);
+       if (read(fileno(f), (char *) message, size) != size)
+               panic("Message temporary file corrupted");
+       message[msgCount].m_size = 0;
        message[msgCount].m_lines = 0;
        message[msgCount].m_lines = 0;
+       fclose(f);
 }
 
 /*
  * Append the passed message descriptor onto the temp file.
  * If the write fails, return 1, else 0
  */
 }
 
 /*
  * Append the passed message descriptor onto the temp file.
  * If the write fails, return 1, else 0
  */
-
 append(mp, f)
        struct message *mp;
 append(mp, f)
        struct message *mp;
+       FILE *f;
 {
 {
-       if (write(f, (char *) mp, sizeof *mp) != sizeof *mp)
-               return(1);
-       return(0);
+       return fwrite((char *) mp, sizeof *mp, 1, f) != 1;
 }
 
 /*
  * Delete a file, but only if the file is a plain file.
  */
 }
 
 /*
  * Delete a file, but only if the file is a plain file.
  */
-
 remove(name)
        char name[];
 {
 remove(name)
        char name[];
 {
@@ -234,7 +214,7 @@ remove(name)
                errno = EISDIR;
                return(-1);
        }
                errno = EISDIR;
                return(-1);
        }
-       return(unlink(name));
+       return unlink(name);
 }
 
 /*
 }
 
 /*
@@ -248,7 +228,7 @@ edstop()
        FILE *obuf, *ibuf, *readstat;
        struct stat statb;
        char tempname[30], *id;
        FILE *obuf, *ibuf, *readstat;
        struct stat statb;
        char tempname[30], *id;
-       int (*sigs[3])();
+       char *mktemp();
 
        if (readonly)
                return;
 
        if (readonly)
                return;
@@ -349,67 +329,53 @@ done:
 static int sigdepth = 0;               /* depth of holdsigs() */
 static int omask = 0;
 /*
 static int sigdepth = 0;               /* depth of holdsigs() */
 static int omask = 0;
 /*
- * Hold signals SIGHUP - SIGQUIT.
+ * Hold signals SIGHUP, SIGINT, and SIGQUIT.
  */
 holdsigs()
 {
  */
 holdsigs()
 {
-       register int i;
 
        if (sigdepth++ == 0)
                omask = sigblock(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT));
 }
 
 /*
 
        if (sigdepth++ == 0)
                omask = sigblock(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT));
 }
 
 /*
- * Release signals SIGHUP - SIGQUIT
+ * Release signals SIGHUP, SIGINT, and SIGQUIT.
  */
 relsesigs()
 {
  */
 relsesigs()
 {
-       register int i;
 
        if (--sigdepth == 0)
                sigsetmask(omask);
 }
 
 /*
 
        if (--sigdepth == 0)
                sigsetmask(omask);
 }
 
 /*
- * Open a temp file by creating, closing, unlinking, and
- * reopening.  Return the open file descriptor.
+ * Open a temp file by creating and unlinking.
+ * Return the open file descriptor.
  */
  */
-
 opentemp(file)
        char file[];
 {
 opentemp(file)
        char file[];
 {
-       register int f;
+       int f;
 
 
-       if ((f = creat(file, 0600)) < 0) {
+       if ((f = open(file, O_CREAT|O_EXCL|O_RDWR, 0600)) < 0)
                perror(file);
                perror(file);
-               return(-1);
-       }
-       close(f);
-       if ((f = open(file, 2)) < 0) {
-               perror(file);
-               remove(file);
-               return(-1);
-       }
        remove(file);
        remove(file);
-       return(f);
+       return (f);
 }
 
 /*
  * Determine the size of the file possessed by
  * the passed buffer.
  */
 }
 
 /*
  * Determine the size of the file possessed by
  * the passed buffer.
  */
-
 off_t
 fsize(iob)
        FILE *iob;
 {
 off_t
 fsize(iob)
        FILE *iob;
 {
-       register int f;
        struct stat sbuf;
 
        struct stat sbuf;
 
-       f = fileno(iob);
-       if (fstat(f, &sbuf) < 0)
-               return(0);
-       return(sbuf.st_size);
+       if (fstat(fileno(iob), &sbuf) < 0)
+               return 0;
+       return sbuf.st_size;
 }
 
 /*
 }
 
 /*
@@ -417,17 +383,17 @@ fsize(iob)
  * in it and expand it by using "sh -c echo filename"
  * Return the file name as a dynamic string.
  */
  * in it and expand it by using "sh -c echo filename"
  * Return the file name as a dynamic string.
  */
-
 char *
 expand(name)
        char name[];
 {
        char xname[BUFSIZ];
        char cmdbuf[BUFSIZ];
 char *
 expand(name)
        char name[];
 {
        char xname[BUFSIZ];
        char cmdbuf[BUFSIZ];
-       register int pid, l, rc;
+       register int pid, l;
        register char *cp, *Shell;
        register char *cp, *Shell;
-       int s, pivec[2], (*sigint)();
+       int pivec[2];
        struct stat sbuf;
        struct stat sbuf;
+       union wait s;
 
        if (name[0] == '+' && getfold(cmdbuf) >= 0) {
                sprintf(xname, "%s/%s", cmdbuf, name + 1);
 
        if (name[0] == '+' && getfold(cmdbuf) >= 0) {
                sprintf(xname, "%s/%s", cmdbuf, name + 1);
@@ -441,7 +407,6 @@ expand(name)
        }
        sprintf(cmdbuf, "echo %s", name);
        if ((pid = vfork()) == 0) {
        }
        sprintf(cmdbuf, "echo %s", name);
        if ((pid = vfork()) == 0) {
-               sigchild();
                Shell = value("SHELL");
                if (Shell == NOSTR)
                        Shell = SHELL;
                Shell = value("SHELL");
                if (Shell == NOSTR)
                        Shell = SHELL;
@@ -464,8 +429,7 @@ expand(name)
        close(pivec[0]);
        while (wait(&s) != pid);
                ;
        close(pivec[0]);
        while (wait(&s) != pid);
                ;
-       s &= 0377;
-       if (s != 0 && s != SIGPIPE) {
+       if (s.w_status != 0 && s.w_termsig != SIGPIPE) {
                fprintf(stderr, "\"Echo\" failed\n");
                goto err;
        }
                fprintf(stderr, "\"Echo\" failed\n");
                goto err;
        }
@@ -504,30 +468,27 @@ getfold(name)
        char *folder;
 
        if ((folder = value("folder")) == NOSTR)
        char *folder;
 
        if ((folder = value("folder")) == NOSTR)
-               return(-1);
+               return (-1);
        if (*folder == '/')
                strcpy(name, folder);
        else
                sprintf(name, "%s/%s", homedir, folder);
        if (*folder == '/')
                strcpy(name, folder);
        else
                sprintf(name, "%s/%s", homedir, folder);
-       return(0);
+       return (0);
 }
 
 /*
  * 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.
  */
-
 FILE *
 Fdopen(fildes, mode)
        char *mode;
 {
 FILE *
 Fdopen(fildes, mode)
        char *mode;
 {
-       register int f;
-       FILE *fdopen();
+       int f;
 
 
-       f = dup(fildes);
-       if (f < 0) {
+       if ((f = dup(fildes)) < 0) {
                perror("dup");
                perror("dup");
-               return(NULL);
+               return (NULL);
        }
        }
-       return(fdopen(f, mode));
+       return fdopen(f, mode);
 }
 }
index a873b26..5bf1729 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)getname.c   5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)getname.c   5.3 (Berkeley) %G%";
 #endif not lint
 
 #include <pwd.h>
 #endif not lint
 
 #include <pwd.h>
@@ -21,7 +21,6 @@ static char *sccsid = "@(#)getname.c  5.2 (Berkeley) %G%";
 /*
  * Search the passwd file for a uid.  Return name through ref parameter
  * if found, indicating success with 0 return.  Return -1 on error.
 /*
  * Search the passwd file for a uid.  Return name through ref parameter
  * if found, indicating success with 0 return.  Return -1 on error.
- * If -1 is passed as the user id, close the passwd file.
  */
 
 getname(uid, namebuf)
  */
 
 getname(uid, namebuf)
@@ -29,18 +28,15 @@ getname(uid, namebuf)
 {
        struct passwd *pw;
 
 {
        struct passwd *pw;
 
-       if (uid == -1) {
-               return(0);
-       }
        if ((pw = getpwuid(uid)) == NULL)
        if ((pw = getpwuid(uid)) == NULL)
-               return(-1);
+               return -1;
        strcpy(namebuf, pw->pw_name);
        return 0;
 }
 
 /*
  * Convert the passed name to a user id and return it.  Return -1
        strcpy(namebuf, pw->pw_name);
        return 0;
 }
 
 /*
  * Convert the passed name to a user id and return it.  Return -1
- * on error.  Iff the name passed is -1 (yech) close the pwfile.
+ * on error.
  */
 
 getuserid(name)
  */
 
 getuserid(name)
@@ -48,10 +44,7 @@ getuserid(name)
 {
        struct passwd *pw;
 
 {
        struct passwd *pw;
 
-       if (name == (char *) -1) {
-               return(0);
-       }
        if ((pw = getpwnam(name)) == NULL)
        if ((pw = getpwnam(name)) == NULL)
-               return 0;
+               return -1;
        return pw->pw_uid;
 }
        return pw->pw_uid;
 }
index 3253579..2cadc52 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)glob.h      5.1 (Berkeley) %G%
+ *     @(#)glob.h      5.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -27,7 +27,6 @@ int   readonly;                       /* Will be unable to rewrite file */
 int    noreset;                        /* String resets suspended */
 int    sourcing;                       /* Currently reading variant file */
 int    loading;                        /* Loading user definitions */
 int    noreset;                        /* String resets suspended */
 int    sourcing;                       /* Currently reading variant file */
 int    loading;                        /* Loading user definitions */
-int    shudann;                        /* Print headers when possible */
 int    cond;                           /* Current state of conditional exc. */
 FILE   *itf;                           /* Input temp file buffer */
 FILE   *otf;                           /* Output temp file buffer */
 int    cond;                           /* Current state of conditional exc. */
 FILE   *itf;                           /* Input temp file buffer */
 FILE   *otf;                           /* Output temp file buffer */
@@ -64,6 +63,8 @@ char  **altnames;                     /* List of alternate names for user */
 char   **localnames;                   /* List of aliases for our local host */
 int    debug;                          /* Debug flag set */
 int    rmail;                          /* Being called as rmail */
 char   **localnames;                   /* List of aliases for our local host */
 int    debug;                          /* Debug flag set */
 int    rmail;                          /* Being called as rmail */
+int    screenwidth;                    /* Screen width, or best guess */
+int    screenheight;                   /* Screen height, or best guess */
 
 #include <setjmp.h>
 
 
 #include <setjmp.h>
 
index 80cb5fd..ca78f6e 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)head.c      5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)head.c      5.3 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #endif not lint
 
 #include "rcv.h"
@@ -21,7 +21,6 @@ static char *sccsid = "@(#)head.c     5.2 (Berkeley) %G%";
  * Return true if yes.  Note the extreme pains to
  * accomodate all funny formats.
  */
  * Return true if yes.  Note the extreme pains to
  * accomodate all funny formats.
  */
-
 ishead(linebuf)
        char linebuf[];
 {
 ishead(linebuf)
        char linebuf[];
 {
@@ -30,32 +29,34 @@ ishead(linebuf)
        char parbuf[BUFSIZ];
 
        cp = linebuf;
        char parbuf[BUFSIZ];
 
        cp = linebuf;
-       if (strncmp("From ", cp, 5) != 0)
-               return(0);
-       parse(cp, &hl, parbuf);
+       if (*cp++ != 'F' || *cp++ != 'r' || *cp++ != 'o' || *cp++ != 'm' ||
+           *cp++ != ' ')
+               return (0);
+       parse(linebuf, &hl, parbuf);
        if (hl.l_from == NOSTR || hl.l_date == NOSTR) {
                fail(linebuf, "No from or date field");
        if (hl.l_from == NOSTR || hl.l_date == NOSTR) {
                fail(linebuf, "No from or date field");
-               return(0);
+               return (0);
        }
        if (!isdate(hl.l_date)) {
                fail(linebuf, "Date field not legal date");
        }
        if (!isdate(hl.l_date)) {
                fail(linebuf, "Date field not legal date");
-               return(0);
+               return (0);
        }
        }
-       
        /*
         * I guess we got it!
         */
        /*
         * I guess we got it!
         */
-
-       return(1);
+       return (1);
 }
 
 }
 
+/*ARGSUSED*/
 fail(linebuf, reason)
        char linebuf[], reason[];
 {
 
 fail(linebuf, reason)
        char linebuf[], reason[];
 {
 
-       if (1 /*value("debug") == NOSTR*/)
+       /*
+       if (value("debug") == NOSTR)
                return;
        fprintf(stderr, "\"%s\"\nnot a header because %s\n", linebuf, reason);
                return;
        fprintf(stderr, "\"%s\"\nnot a header because %s\n", linebuf, reason);
+       */
 }
 
 /*
 }
 
 /*
@@ -64,12 +65,11 @@ fail(linebuf, reason)
  * pointers into the copied line in the passed headline
  * structure.  Actually, it scans.
  */
  * pointers into the copied line in the passed headline
  * structure.  Actually, it scans.
  */
-
 parse(line, hl, pbuf)
        char line[], pbuf[];
 parse(line, hl, pbuf)
        char line[], pbuf[];
-       struct headline *hl;
+       register struct headline *hl;
 {
 {
-       register char *cp, *dp;
+       register char *cp;
        char *sp;
        char word[LINESIZE];
 
        char *sp;
        char word[LINESIZE];
 
@@ -78,25 +78,19 @@ parse(line, hl, pbuf)
        hl->l_date = NOSTR;
        cp = line;
        sp = pbuf;
        hl->l_date = NOSTR;
        cp = line;
        sp = pbuf;
-
        /*
        /*
-        * Skip the first "word" of the line, which should be "From"
-        * anyway.
+        * Skip over "From" first.
         */
         */
-
        cp = nextword(cp, word);
        cp = nextword(cp, word);
-       dp = nextword(cp, word);
-       if (!equal(word, ""))
+       cp = nextword(cp, word);
+       if (*word)
                hl->l_from = copyin(word, &sp);
                hl->l_from = copyin(word, &sp);
-       if (strncmp(dp, "tty", 3) == 0) {
-               cp = nextword(dp, word);
+       if (cp != NOSTR && cp[0] == 't' && cp[1] == 't' && cp[2] == 'y') {
+               cp = nextword(cp, word);
                hl->l_tty = copyin(word, &sp);
                hl->l_tty = copyin(word, &sp);
-               if (cp != NOSTR)
-                       hl->l_date = copyin(cp, &sp);
        }
        }
-       else
-               if (dp != NOSTR)
-                       hl->l_date = copyin(dp, &sp);
+       if (cp != NOSTR)
+               hl->l_date = copyin(cp, &sp);
 }
 
 /*
 }
 
 /*
@@ -105,22 +99,19 @@ parse(line, hl, pbuf)
  * Thus, dynamically allocate space in the right string, copying
  * the left string into it.
  */
  * Thus, dynamically allocate space in the right string, copying
  * the left string into it.
  */
-
 char *
 copyin(src, space)
 char *
 copyin(src, space)
-       char src[];
+       register char *src;
        char **space;
 {
        char **space;
 {
-       register char *cp, *top;
-       register int s;
+       register char *cp;
+       char *top;
 
 
-       s = strlen(src);
-       cp = *space;
-       top = cp;
-       strcpy(cp, src);
-       cp += s + 1;
+       top = cp = *space;
+       while (*cp++ = *src++)
+               ;
        *space = cp;
        *space = cp;
-       return(top);
+       return (top);
 }
 
 /*
 }
 
 /*
@@ -139,75 +130,62 @@ copyin(src, space)
 #define        N       6               /* A new line */
 #define U      7               /* An upper case char */
 
 #define        N       6               /* A new line */
 #define U      7               /* An upper case char */
 
-char ctypes[] = {U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,D,D,D,D,0};
-char tmztypes[] = {U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,U,U,U,S,D,D,D,D,0};
+char ctypes[] = { U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,D,D,D,D,0 };
+char tmztypes[] = { U,L,L,S,U,L,L,S,O,D,S,D,D,C,D,D,C,D,D,S,U,U,U,S,D,D,D,D,0 };
 
 isdate(date)
        char date[];
 {
 
 isdate(date)
        char date[];
 {
-       register char *cp;
 
 
-       cp = date;
-       if (cmatch(cp, ctypes))
-               return(1);
-       return(cmatch(cp, tmztypes));
+       if (cmatch(date, ctypes))
+               return (1);
+       return (cmatch(date, tmztypes));
 }
 
 /*
 }
 
 /*
- * Match the given string against the given template.
+ * Match the given string (cp) against the given template (tp).
  * Return 1 if they match, 0 if they don't
  */
 
  * Return 1 if they match, 0 if they don't
  */
 
-cmatch(str, temp)
-       char str[], temp[];
-{
+cmatch(cp, tp)
        register char *cp, *tp;
        register char *cp, *tp;
-       register int c;
+{
 
 
-       cp = str;
-       tp = temp;
-       while (*cp != '\0' && *tp != 0) {
-               c = *cp++;
+       while (*cp && *tp)
                switch (*tp++) {
                case L:
                switch (*tp++) {
                case L:
-                       if (c < 'a' || c > 'z')
-                               return(0);
+                       if (!islower(*cp++))
+                               return 0;
                        break;
                        break;
-
                case U:
                case U:
-                       if (c < 'A' || c > 'Z')
-                               return(0);
+                       if (!isupper(*cp++))
+                               return 0;
                        break;
                        break;
-
                case S:
                case S:
-                       if (c != ' ')
-                               return(0);
+                       if (*cp++ != ' ')
+                               return 0;
                        break;
                        break;
-
                case D:
                case D:
-                       if (!isdigit(c))
-                               return(0);
+                       if (!isdigit(*cp++))
+                               return 0;
                        break;
                        break;
-
                case O:
                case O:
-                       if (c != ' ' && !isdigit(c))
-                               return(0);
+                       if (*cp != ' ' && !isdigit(*cp))
+                               return 0;
+                       cp++;
                        break;
                        break;
-
                case C:
                case C:
-                       if (c != ':')
-                               return(0);
+                       if (*cp++ != ':')
+                               return 0;
                        break;
                        break;
-
                case N:
                case N:
-                       if (c != '\n')
-                               return(0);
+                       if (*cp++ != '\n')
+                               return 0;
                        break;
                }
                        break;
                }
-       }
-       if (*cp != '\0' || *tp != 0)
-               return(0);
-       return(1);
+       if (*cp || *tp)
+               return 0;
+       return (1);
 }
 
 /*
 }
 
 /*
@@ -215,100 +193,45 @@ cmatch(str, temp)
  * passed.  Also, return a pointer to the next word following that,
  * or NOSTR if none follow.
  */
  * passed.  Also, return a pointer to the next word following that,
  * or NOSTR if none follow.
  */
-
 char *
 nextword(wp, wbuf)
 char *
 nextword(wp, wbuf)
-       char wp[], wbuf[];
+       register char *wp, *wbuf;
 {
 {
-       register char *cp, *cp2;
+       register c;
 
 
-       if ((cp = wp) == NOSTR) {
-               copy("", wbuf);
-               return(NOSTR);
+       if (wp == NOSTR) {
+               *wbuf = 0;
+               return (NOSTR);
        }
        }
-       cp2 = wbuf;
-       while (!any(*cp, " \t") && *cp != '\0')
-               if (*cp == '"') {
-                       *cp2++ = *cp++;
-                       while (*cp != '\0' && *cp != '"')
-                               *cp2++ = *cp++;
-                       if (*cp == '"')
-                               *cp2++ = *cp++;
-               } else
-                       *cp2++ = *cp++;
-       *cp2 = '\0';
-       while (any(*cp, " \t"))
-               cp++;
-       if (*cp == '\0')
-               return(NOSTR);
-       return(cp);
-}
-
-/*
- * Test to see if the character is an ascii alphabetic.
- */
-
-isalpha(c)
-{
-       register int ch;
-
-       ch = raise(c);
-       return(ch >= 'A' && ch <= 'Z');
-}
-
-/*
- * Test to see if the character is an ascii digit.
- */
-
-isdigit(c)
-{
-       return(c >= '0' && c <= '9');
-}
-
-/*
- * Copy str1 to str2, return pointer to null in str2.
- */
-
-char *
-copy(str1, str2)
-       char *str1, *str2;
-{
-       register char *s1, *s2;
-
-       s1 = str1;
-       s2 = str2;
-       while (*s1)
-               *s2++ = *s1++;
-       *s2 = 0;
-       return(s2);
+       while ((c = *wp++) && c != ' ' && c != '\t') {
+               *wbuf++ = c;
+               if (c == '"') {
+                       while ((c = *wp++) && c != '"')
+                               *wbuf++ = c;
+                       if (c == '"')
+                               *wbuf++ = c;
+                       else
+                               wp--;
+               }
+       }
+       *wbuf = '\0';
+       for (; c == ' ' || c == '\t'; c = *wp++)
+               ;
+       if (c == 0)
+               return (NOSTR);
+       return (wp - 1);
 }
 
 /*
 }
 
 /*
- * Is ch any of the characters in str?
+ * Is c contained in s?
  */
  */
-
-any(ch, str)
-       char *str;
-{
-       register char *f;
+any(c, s)
        register c;
        register c;
-
-       f = str;
-       c = ch;
-       while (*f)
-               if (c == *f++)
-                       return(1);
-       return(0);
-}
-
-/*
- * Convert lower case letters to upper case.
- */
-
-raise(c)
-       register int c;
+       register char *s;
 {
 {
-       if (c >= 'a' && c <= 'z')
-               c += 'A' - 'a';
-       return(c);
+
+       while (*s)
+               if (*s++ == c)
+                       return 1;
+       return 0;
 }
 }
index ec8d536..a24a64a 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)lex.c       5.4 (Berkeley) %G%";
+static char *sccsid = "@(#)lex.c       5.5 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #endif not lint
 
 #include "rcv.h"
@@ -125,6 +125,7 @@ setfile(name, isedit)
  */
 
 int    *msgvec;
  */
 
 int    *msgvec;
+jmp_buf        commjmp;
 
 commands()
 {
 
 commands()
 {
@@ -133,14 +134,12 @@ commands()
        char linebuf[LINESIZE];
        int hangup(), contin();
 
        char linebuf[LINESIZE];
        int hangup(), contin();
 
-# ifdef VMUNIX
-       sigset(SIGCONT, SIG_DFL);
-# endif VMUNIX
+       signal(SIGCONT, SIG_DFL);
        if (rcvmode && !sourcing) {
        if (rcvmode && !sourcing) {
-               if (sigset(SIGINT, SIG_IGN) != SIG_IGN)
-                       sigset(SIGINT, stop);
-               if (sigset(SIGHUP, SIG_IGN) != SIG_IGN)
-                       sigset(SIGHUP, hangup);
+               if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+                       signal(SIGINT, stop);
+               if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+                       signal(SIGHUP, hangup);
        }
        shudprompt = intty && !sourcing;
        for (;;) {
        }
        shudprompt = intty && !sourcing;
        for (;;) {
@@ -156,13 +155,11 @@ commands()
                eofloop = 0;
 top:
                if (shudprompt) {
                eofloop = 0;
 top:
                if (shudprompt) {
+                       setjmp(commjmp);
+                       signal(SIGCONT, contin);
                        printf(prompt);
                        printf(prompt);
-                       fflush(stdout);
-# ifdef VMUNIX
-                       sigset(SIGCONT, contin);
-# endif VMUNIX
-               } else
-                       fflush(stdout);
+               }
+               fflush(stdout);
                sreset();
 
                /*
                sreset();
 
                /*
@@ -172,7 +169,7 @@ top:
 
                n = 0;
                for (;;) {
 
                n = 0;
                for (;;) {
-                       if (readline(input, &linebuf[n]) <= 0) {
+                       if (readline(input, &linebuf[n]) < 0) {
                                if (n != 0)
                                        break;
                                if (loading)
                                if (n != 0)
                                        break;
                                if (loading)
@@ -198,9 +195,7 @@ top:
                                break;
                        linebuf[n++] = ' ';
                }
                                break;
                        linebuf[n++] = ' ';
                }
-# ifdef VMUNIX
-               sigset(SIGCONT, SIG_DFL);
-# endif VMUNIX
+               signal(SIGCONT, SIG_DFL);
                if (execute(linebuf, 0))
                        return;
 more:          ;
                if (execute(linebuf, 0))
                        return;
 more:          ;
@@ -234,9 +229,8 @@ execute(linebuf, contxt)
         * lexical conventions.
         */
 
         * lexical conventions.
         */
 
-       cp = linebuf;
-       while (any(*cp, " \t"))
-               cp++;
+       for (cp = linebuf; isspace(*cp); cp++)
+               ;
        if (*cp == '!') {
                if (sourcing) {
                        printf("Can't \"!\" while sourcing\n");
        if (*cp == '!') {
                if (sourcing) {
                        printf("Can't \"!\" while sourcing\n");
@@ -259,7 +253,7 @@ execute(linebuf, contxt)
         * confusion.
         */
 
         * confusion.
         */
 
-       if (sourcing && equal(word, ""))
+       if (sourcing && *word == '\0')
                return(0);
        com = lex(word);
        if (com == NONE) {
                return(0);
        com = lex(word);
        if (com == NONE) {
@@ -293,7 +287,7 @@ execute(linebuf, contxt)
                return(0);
        }
        if (!edit && com->c_func == edstop) {
                return(0);
        }
        if (!edit && com->c_func == edstop) {
-               sigset(SIGINT, SIG_IGN);
+               signal(SIGINT, SIG_IGN);
                return(1);
        }
 
                return(1);
        }
 
@@ -378,7 +372,7 @@ execute(linebuf, contxt)
                 * Just the straight string, with
                 * leading blanks removed.
                 */
                 * Just the straight string, with
                 * leading blanks removed.
                 */
-               while (any(*cp, " \t"))
+               while (isspace(*cp))
                        cp++;
                e = (*com->c_func)(cp);
                break;
                        cp++;
                e = (*com->c_func)(cp);
                break;
@@ -440,17 +434,18 @@ execute(linebuf, contxt)
 /*
  * When we wake up after ^Z, reprint the prompt.
  */
 /*
  * When we wake up after ^Z, reprint the prompt.
  */
+/*ARGSUSED*/
 contin(s)
 {
 
 contin(s)
 {
 
-       printf(prompt);
-       fflush(stdout);
+       longjmp(commjmp, 1);
 }
 
 /*
  * Branch here on hangup signal and simulate quit.
  */
 }
 
 /*
  * Branch here on hangup signal and simulate quit.
  */
-hangup()
+/*ARGSUSED*/
+hangup(s)
 {
 
        holdsigs();
 {
 
        holdsigs();
@@ -472,8 +467,8 @@ hangup()
 setmsize(sz)
 {
 
 setmsize(sz)
 {
 
-       if (msgvec != (int *) 0)
-               cfree(msgvec);
+       if (msgvec != 0)
+               cfree((char *) msgvec);
        msgvec = (int *) calloc((unsigned) (sz + 1), sizeof *msgvec);
 }
 
        msgvec = (int *) calloc((unsigned) (sz + 1), sizeof *msgvec);
 }
 
@@ -514,12 +509,10 @@ isprefix(as1, as2)
 }
 
 /*
 }
 
 /*
- * The following gets called on receipt of a rubout.  This is
+ * The following gets called on receipt of an interrupt.  This is
  * to abort printout of a command, mainly.
  * Dispatching here when command() is inactive crashes rcv.
  * Close all open files except 0, 1, 2, and the temporary.
  * to abort printout of a command, mainly.
  * Dispatching here when command() is inactive crashes rcv.
  * Close all open files except 0, 1, 2, and the temporary.
- * The special call to getuserid() is needed so it won't get
- * annoyed about losing its open file.
  * Also, unstack all source files.
  */
 
  * Also, unstack all source files.
  */
 
@@ -553,20 +546,16 @@ xclose(iop)
        }
 }
 
        }
 }
 
+/*ARGSUSED*/
 stop(s)
 {
 stop(s)
 {
-       register FILE *fp;
 
 
-# ifndef VMUNIX
-       s = SIGINT;
-# endif VMUNIX
        noreset = 0;
        if (!inithdr)
                sawcom++;
        inithdr = 0;
        while (sourcing)
                unstack();
        noreset = 0;
        if (!inithdr)
                sawcom++;
        inithdr = 0;
        while (sourcing)
                unstack();
-       getuserid((char *) -1);
 
        /*
         * Walk through all the open FILEs, applying xclose() to them
 
        /*
         * Walk through all the open FILEs, applying xclose() to them
@@ -578,9 +567,6 @@ stop(s)
                image = -1;
        }
        fprintf(stderr, "Interrupt\n");
                image = -1;
        }
        fprintf(stderr, "Interrupt\n");
-# ifndef VMUNIX
-       signal(s, stop);
-# endif
        reset(0);
 }
 
        reset(0);
 }
 
@@ -668,14 +654,14 @@ newfileinfo()
        return(mdot);
 }
 
        return(mdot);
 }
 
-strace() {}
-
 /*
  * Print the current version number.
  */
 
 /*
  * Print the current version number.
  */
 
+/*ARGSUSED*/
 pversion(e)
 {
 pversion(e)
 {
+
        printf("Version %s\n", version);
        return(0);
 }
        printf("Version %s\n", version);
        return(0);
 }
index 21fb5d7..71c07cb 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)list.c      5.4 (Berkeley) %G%";
+static char *sccsid = "@(#)list.c      5.5 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #endif not lint
 
 #include "rcv.h"
@@ -414,7 +414,7 @@ scan(sp)
        int quotec;
 
        if (regretp >= 0) {
        int quotec;
 
        if (regretp >= 0) {
-               copy(stringstack[regretp], lexstring);
+               strcpy(lexstring, stringstack[regretp]);
                lexnumber = numberstack[regretp];
                return(regretstack[regretp--]);
        }
                lexnumber = numberstack[regretp];
                return(regretstack[regretp--]);
        }
index 6719ee7..ebaaddc 100644 (file)
@@ -3,29 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)local.h     5.1 (Berkeley) %G%
+ *     @(#)local.h     5.2 (Berkeley) %G%
  */
 
  */
 
-#ifdef V7
 #include "v7.local.h"
 #include "v7.local.h"
-#endif
-
-#ifdef CORY
-#include "c.local.h"
-#endif
-
-#ifdef INGRES
-#include "ing.local.h"
-#endif
-
-#ifdef V6
-#include "v6.local.h"
-#endif
-
-#ifdef CC
-#include "cc.local.h"
-#endif
-
-#ifdef V40
-#include "40.local.h"
-#endif
index 218e349..73bce5c 100644 (file)
@@ -11,7 +11,7 @@ char *copyright =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char *sccsid = "@(#)main.c      5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)main.c      5.4 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #endif not lint
 
 #include "rcv.h"
@@ -41,23 +41,15 @@ main(argc, argv)
 {
        register char *ef;
        register int i, argp;
 {
        register char *ef;
        register int i, argp;
-       int mustsend, uflag, hdrstop(), (*prevint)(), f;
-       FILE *ibuf, *ftat;
+       int mustsend, hdrstop(), (*prevint)(), f;
        struct sgttyb tbuf;
 
        struct sgttyb tbuf;
 
-#ifdef signal
-       Siginit();
-#endif
-
        /*
        /*
-        * Set up a reasonable environment.  We clobber the last
-        * element of argument list for compatibility with version 6,
-        * figure out whether we are being run interactively, set up
+        * Set up a reasonable environment.
+        * Figure out whether we are being run interactively, set up
         * all the temporary files, buffer standard output, and so forth.
         */
 
         * all the temporary files, buffer standard output, and so forth.
         */
 
-       uflag = 0;
-       argv[argc] = (char *) -1;
 #ifdef GETHOST
        inithost();
 #endif GETHOST
 #ifdef GETHOST
        inithost();
 #endif GETHOST
@@ -67,8 +59,7 @@ main(argc, argv)
        if (outtty) {
                gtty(1, &tbuf);
                baud = tbuf.sg_ospeed;
        if (outtty) {
                gtty(1, &tbuf);
                baud = tbuf.sg_ospeed;
-       }
-       else
+       } else
                baud = B9600;
        image = -1;
 
                baud = B9600;
        image = -1;
 
@@ -134,7 +125,6 @@ main(argc, argv)
                        /*
                         * Next argument is person to pretend to be.
                         */
                        /*
                         * Next argument is person to pretend to be.
                         */
-                       uflag++;
                        if (i >= argc - 1) {
                                fprintf(stderr, "Missing user name for -u\n");
                                exit(1);
                        if (i >= argc - 1) {
                                fprintf(stderr, "Missing user name for -u\n");
                                exit(1);
@@ -250,6 +240,7 @@ main(argc, argv)
                exit(1);
        }
        tinit();
                exit(1);
        }
        tinit();
+       setscreensize();
        input = stdin;
        rcvmode = argp == -1;
        if (!nosrc)
        input = stdin;
        rcvmode = argp == -1;
        if (!nosrc)
@@ -277,7 +268,7 @@ main(argc, argv)
                edit++;
                ename = expand(ef);
                if (ename != ef) {
                edit++;
                ename = expand(ef);
                if (ename != ef) {
-                       ef = (char *) calloc(1, strlen(ename) + 1);
+                       ef = malloc((unsigned) strlen(ename) + 1);
                        strcpy(ef, ename);
                }
                editfile = ef;
                        strcpy(ef, ename);
                }
                editfile = ef;
@@ -292,11 +283,11 @@ main(argc, argv)
        }
        if (!noheader && value("noheader") == NOSTR) {
                if (setjmp(hdrjmp) == 0) {
        }
        if (!noheader && value("noheader") == NOSTR) {
                if (setjmp(hdrjmp) == 0) {
-                       if ((prevint = sigset(SIGINT, SIG_IGN)) != SIG_IGN)
-                               sigset(SIGINT, hdrstop);
+                       if ((prevint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
+                               signal(SIGINT, hdrstop);
                        announce(!0);
                        fflush(stdout);
                        announce(!0);
                        fflush(stdout);
-                       sigset(SIGINT, prevint);
+                       signal(SIGINT, prevint);
                }
        }
        if (!edit && msgCount == 0) {
                }
        }
        if (!edit && msgCount == 0) {
@@ -306,9 +297,9 @@ main(argc, argv)
        }
        commands();
        if (!edit) {
        }
        commands();
        if (!edit) {
-               sigset(SIGHUP, SIG_IGN);
-               sigset(SIGINT, SIG_IGN);
-               sigset(SIGQUIT, SIG_IGN);
+               signal(SIGHUP, SIG_IGN);
+               signal(SIGINT, SIG_IGN);
+               signal(SIGQUIT, SIG_IGN);
                quit();
        }
        exit(0);
                quit();
        }
        exit(0);
@@ -324,3 +315,37 @@ hdrstop()
        fprintf(stderr, "\nInterrupt\n");
        longjmp(hdrjmp, 1);
 }
        fprintf(stderr, "\nInterrupt\n");
        longjmp(hdrjmp, 1);
 }
+
+/*
+ * Compute what the screen size should be.
+ * We use the following algorithm for the height:
+ *     If baud rate < 1200, use  9
+ *     If baud rate = 1200, use 14
+ *     If baud rate > 1200, use 24 or ws_row
+ * Width is either 80 or ws_col;
+ */
+setscreensize()
+{
+#ifdef TIOCGWINSZ
+       struct winsize ws;
+
+       if (ioctl(fileno(stdout), TIOCGWINSZ, (char *) &ws) < 0)
+               ws.ws_col = ws.ws_row = 0;
+#endif
+       if (baud < B1200)
+               screenheight = 9;
+       else if (baud == B1200)
+               screenheight = 14;
+#ifdef TIOCGWINSZ
+       else if (ws.ws_row != 0)
+               screenheight = ws.ws_row;
+#endif
+       else
+               screenheight = 24;
+#ifdef TIOCGWINSZ
+       if (ws.ws_col != 0)
+               screenwidth = ws.ws_col;
+       else
+#endif
+               screenwidth = 80;
+}
index 9613701..7631f4a 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)names.c     5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)names.c     5.4 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -15,6 +15,7 @@ static char *sccsid = "@(#)names.c    5.3 (Berkeley) %G%";
  */
 
 #include "rcv.h"
  */
 
 #include "rcv.h"
+#include <sys/wait.h>
 
 /*
  * Allocate a single element of a name list,
 
 /*
  * Allocate a single element of a name list,
@@ -194,12 +195,13 @@ struct name *
 verify(names)
        struct name *names;
 {
 verify(names)
        struct name *names;
 {
-       register struct name *np, *top, *t, *x;
-       register char *cp;
-
 #ifdef SENDMAIL
 #ifdef SENDMAIL
+
        return(names);
 #else
        return(names);
 #else
+       register struct name *np, *top, *t, *x;
+       register char *cp;
+
        top = names;
        np = names;
        while (np != NIL) {
        top = names;
        np = names;
        while (np != NIL) {
@@ -258,12 +260,16 @@ outof(names, fo, hp)
        struct header *hp;
 {
        register int c;
        struct header *hp;
 {
        register int c;
-       register struct name *np, *top, *t, *x;
-       long now;
+       register struct name *np, *top;
+#ifdef CRAZYWOW
+       register struct name *t, *x;
+#endif
+       time_t now, time();
        char *date, *fname, *shell, *ctime();
        FILE *fout, *fin;
        char *date, *fname, *shell, *ctime();
        FILE *fout, *fin;
-       int ispipe, s, pid;
+       int ispipe;
        extern char tempEdit[];
        extern char tempEdit[];
+       union wait s;
 
        top = names;
        np = names;
 
        top = names;
        np = names;
@@ -321,12 +327,11 @@ outof(names, fo, hp)
 
                if (ispipe) {
                        wait(&s);
 
                if (ispipe) {
                        wait(&s);
-                       switch (pid = fork()) {
+                       switch (fork()) {
                        case 0:
                        case 0:
-                               sigchild();
-                               sigsys(SIGHUP, SIG_IGN);
-                               sigsys(SIGINT, SIG_IGN);
-                               sigsys(SIGQUIT, SIG_IGN);
+                               signal(SIGHUP, SIG_IGN);
+                               signal(SIGINT, SIG_IGN);
+                               signal(SIGQUIT, SIG_IGN);
                                close(0);
                                dup(image);
                                close(image);
                                close(0);
                                dup(image);
                                close(image);
@@ -437,13 +442,11 @@ usermap(names)
        struct name *names;
 {
        register struct name *new, *np, *cp;
        struct name *names;
 {
        register struct name *new, *np, *cp;
-       struct name *getto;
        struct grouphead *gh;
        register int metoo;
 
        new = NIL;
        np = names;
        struct grouphead *gh;
        register int metoo;
 
        new = NIL;
        np = names;
-       getto = NIL;
        metoo = (value("metoo") != NOSTR);
        while (np != NIL) {
                if (np->n_name[0] == '\\') {
        metoo = (value("metoo") != NOSTR);
        while (np != NIL) {
                if (np->n_name[0] == '\\') {
@@ -790,16 +793,6 @@ count(np)
        return(c);
 }
 
        return(c);
 }
 
-cmpdomain(name, dname)
-       register char *name, *dname;
-{
-       char buf[BUFSIZ];
-
-       strcpy(buf, dname);
-       buf[strlen(name)] = '\0';
-       return(icequal(name, buf));
-}
-
 /*
  * Delete the given name from a namelist, using the passed
  * function to compare the names.
 /*
  * Delete the given name from a namelist, using the passed
  * function to compare the names.
@@ -851,6 +844,7 @@ mapf(np, from)
  * Uncomment it if you need it.
  */
 
  * Uncomment it if you need it.
  */
 
+/*
 prettyprint(name)
        struct name *name;
 {
 prettyprint(name)
        struct name *name;
 {
@@ -863,3 +857,4 @@ prettyprint(name)
        }
        fprintf(stderr, "\n");
 }
        }
        fprintf(stderr, "\n");
 }
+*/
index 2ec41a4..8fc9d96 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)optim.c     5.6 (Berkeley) %G%";
+static char *sccsid = "@(#)optim.c     5.7 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -16,8 +16,6 @@ static char *sccsid = "@(#)optim.c    5.6 (Berkeley) %G%";
 
 #include "rcv.h"
 #include "configdefs.h"
 
 #include "rcv.h"
 #include "configdefs.h"
-#include <ctype.h>
-#include <strings.h>
 
 /*
  * Map a name into the correct network "view" of the
 
 /*
  * Map a name into the correct network "view" of the
@@ -55,43 +53,6 @@ netmap(name, from)
        return(name);
 }
 
        return(name);
 }
 
-/*
- * Rename the given network path to use
- * the kinds of names that we would right here.
- */
-
-char *
-rename(str)
-       char str[];
-{
-       register char *cp, *cp2;
-       char buf[BUFSIZ], path[BUFSIZ];
-       register int c, host;
-
-       cp = str;
-       strcpy(path, "");
-       for (;;) {
-               if ((c = *cp++) == 0)
-                       break;
-               cp2 = buf;
-               while (!any(c, metanet) && c != 0) {
-                       *cp2++ = c;
-                       c = *cp++;
-               }
-               *cp2 = 0;
-               if (c == 0) {
-                       strcat(path, buf);
-                       break;
-               }
-               host = netlook(buf, ntype(c));
-               strcat(path, netname(host));
-               stradd(path, c);
-       }
-       if (strcmp(str, path) != 0)
-               return(savestr(path));
-       return(str);
-}
-
 /*
  * Turn a network machine name into a unique character
  */
 /*
  * Turn a network machine name into a unique character
  */
@@ -191,7 +152,7 @@ arpafix(name, from)
        if (cp == NOSTR)
                cp = rindex(name, '%');
        if (cp == NOSTR) {
        if (cp == NOSTR)
                cp = rindex(name, '%');
        if (cp == NOSTR) {
-               fprintf(stderr, "Somethings amiss -- no @ or % in arpafix\n");
+               fprintf(stderr, "Somethings amiss -- no @ or %% in arpafix\n");
                return(name);
        }
        cp++;
                return(name);
        }
        cp++;
@@ -270,7 +231,6 @@ short       midfree;                        /* Next free machine id */
 minit()
 {
        register struct xtrahash *xp, **tp;
 minit()
 {
        register struct xtrahash *xp, **tp;
-       register int i;
 
        midfree = 0;
        tp = &xtab[0];
 
        midfree = 0;
        tp = &xtab[0];
@@ -470,7 +430,7 @@ err:
                        printf("Made up bad net name\n");
                        printf("Machine code %c (0%o)\n", cp[-1], cp[-1]);
                        printf("Sorry -- dumping now.  Alert K. Shoens\n");
                        printf("Made up bad net name\n");
                        printf("Machine code %c (0%o)\n", cp[-1], cp[-1]);
                        printf("Sorry -- dumping now.  Alert K. Shoens\n");
-                       core(0);
+                       core();
                        goto err;
                }
                strcat(name, cp2);
                        goto err;
                }
                strcat(name, cp2);
@@ -872,17 +832,3 @@ yylex()
        yylval = dot;
        return(WORD);
 }
        yylval = dot;
        return(WORD);
 }
-
-/*
- * Add a single character onto a string.
- */
-
-stradd(str, c)
-       register char *str;
-       register int c;
-{
-
-       str += strlen(str);
-       *str++ = c;
-       *str = 0;
-}
index 1e5d86e..ed6ed6e 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)pathnames.h 5.2 (Berkeley) %G%
+ *     @(#)pathnames.h 5.3 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 #define        POSTAGE         "/usr/adm/maillog"
                                        /* Where to audit mail sending */
                                        /* Name of casual tilde help */
 #define        POSTAGE         "/usr/adm/maillog"
                                        /* Where to audit mail sending */
                                        /* Name of casual tilde help */
-#define        UIDMASK         0177777         /* Significant uid bits */
 #define        MASTER          "/usr/lib/Mail.rc"
 #define        APPEND                          /* New mail goes to end of mailbox */
 #define CANLOCK                                /* Locking protocol actually works */
 #define        UTIME                           /* System implements utime(2) */
 #define        MASTER          "/usr/lib/Mail.rc"
 #define        APPEND                          /* New mail goes to end of mailbox */
 #define CANLOCK                                /* Locking protocol actually works */
 #define        UTIME                           /* System implements utime(2) */
-
-#ifndef VMUNIX
-#include "sigretro.h"                  /* Retrofit signal defs */
-#endif VMUNIX
index 966f6f6..4e1af06 100644 (file)
@@ -5,24 +5,20 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)popen.c     5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)popen.c     5.3 (Berkeley) %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
-#include <signal.h>
+#include <sys/signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <errno.h>
 #include <errno.h>
+
 #define        tst(a,b)        (*mode == 'r'? (b) : (a))
 #define        RDR     0
 #define        WTR     1
 static int     popen_pid[20];
 
 #define        tst(a,b)        (*mode == 'r'? (b) : (a))
 #define        RDR     0
 #define        WTR     1
 static int     popen_pid[20];
 
-#ifndef VMUNIX
-#define vfork  fork
-#endif VMUNIX
-#ifndef        SIGRETRO
-#define        sigchild()
-#endif
-
 FILE *
 popen(cmd,mode)
 char   *cmd;
 FILE *
 popen(cmd,mode)
 char   *cmd;
@@ -37,7 +33,6 @@ char  *mode;
        hisside = tst(p[RDR], p[WTR]);
        if((pid = vfork()) == 0) {
                /* myside and hisside reverse roles in child */
        hisside = tst(p[RDR], p[WTR]);
        if((pid = vfork()) == 0) {
                /* myside and hisside reverse roles in child */
-               sigchild();
                close(myside);
                dup2(hisside, tst(0, 1));
                close(hisside);
                close(myside);
                dup2(hisside, tst(0, 1));
                close(hisside);
@@ -55,20 +50,17 @@ pclose(ptr)
 FILE *ptr;
 {
        register f, r;
 FILE *ptr;
 {
        register f, r;
-       int status, omask;
+       int omask;
+       union wait status;
        extern int errno;
 
        f = fileno(ptr);
        fclose(ptr);
        extern int errno;
 
        f = fileno(ptr);
        fclose(ptr);
-# ifdef VMUNIX
        omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
        omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
-# endif VMUNIX
        while((r = wait(&status)) != popen_pid[f] && r != -1 && errno != EINTR)
                ;
        if(r == -1)
        while((r = wait(&status)) != popen_pid[f] && r != -1 && errno != EINTR)
                ;
        if(r == -1)
-               status = -1;
-# ifdef VMUNIX
+               status.w_status = -1;
        sigsetmask(omask);
        sigsetmask(omask);
-# endif VMUNIX
-       return(status);
+       return (status.w_status);
 }
 }
index 4ca8d65..d581f9a 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)rcv.h       5.1 (Berkeley) %G%
+ *     @(#)rcv.h       5.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -13,8 +13,5 @@
  * globals and declarations.
  */
 
  * globals and declarations.
  */
 
-#ifdef pdp11
-#include <whoami.h>
-#endif
 #include "def.h"
 #include "glob.h"
 #include "def.h"
 #include "glob.h"
index 69fb345..22a4d99 100644 (file)
@@ -5,14 +5,11 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)send.c      5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)send.c      5.3 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #endif not lint
 
 #include "rcv.h"
-#ifdef VMUNIX
 #include <sys/wait.h>
 #include <sys/wait.h>
-#endif
-#include <ctype.h>
 #include <sys/stat.h>
 
 /*
 #include <sys/stat.h>
 
 /*
@@ -27,154 +24,153 @@ static char *sccsid = "@(#)send.c 5.2 (Berkeley) %G%";
  * the number of lines written.  Adjust the status: field
  * if need be.  If doign is set, suppress ignored header fields.
  */
  * the number of lines written.  Adjust the status: field
  * if need be.  If doign is set, suppress ignored header fields.
  */
-send(mailp, obuf, doign)
-       struct message *mailp;
+send(mp, obuf, doign)
+       register struct message *mp;
        FILE *obuf;
 {
        FILE *obuf;
 {
-       register struct message *mp;
-       register int t;
-       long c;
-       FILE *ibuf;
-       char line[LINESIZE], field[BUFSIZ];
-       int lc, ishead, infld, fline, dostat;
-       char *cp, *cp2;
-
-       mp = mailp;
+       long count;
+       register FILE *ibuf;
+       char line[LINESIZE];
+       int lc, ishead, infld, ignoring, dostat;
+       register char *cp, *cp2;
+       register int c;
+       int length;
+
        ibuf = setinput(mp);
        ibuf = setinput(mp);
-       c = mp->m_size;
+       count = mp->m_size;
        ishead = 1;
        ishead = 1;
-       dostat = 1;
+       dostat = !doign || !isign("status");
        infld = 0;
        infld = 0;
-       fline = 1;
        lc = 0;
        lc = 0;
-       while (c > 0L) {
-               fgets(line, LINESIZE, ibuf);
-               c -= (long) strlen(line);
-               lc++;
-               if (ishead) {
+       /*
+        * Process headers first
+        */
+       while (count > 0 && ishead) {
+               if (fgets(line, LINESIZE, ibuf) == NULL)
+                       break;
+               count -= length = strlen(line);
+               if (lc == 0) {
                        /* 
                         * First line is the From line, so no headers
                         * there to worry about
                         */
                        /* 
                         * First line is the From line, so no headers
                         * there to worry about
                         */
-                       if (fline) {
-                               fline = 0;
-                               goto writeit;
-                       }
+                       ignoring = 0;
+               } else if (line[0] == '\n') {
                        /*
                         * If line is blank, we've reached end of
                         * headers, so force out status: field
                         * and note that we are no longer in header
                         * fields
                         */
                        /*
                         * If line is blank, we've reached end of
                         * headers, so force out status: field
                         * and note that we are no longer in header
                         * fields
                         */
-                       if (line[0] == '\n') {
-                               if (dostat) {
-                                       statusput(mailp, obuf, doign);
-                                       dostat = 0;
-                               }
-                               ishead = 0;
-                               goto writeit;
+                       if (dostat) {
+                               statusput(mp, obuf);
+                               dostat = 0;
                        }
                        }
+                       ishead = 0;
+                       ignoring = 0;
+               } else if (infld && (line[0] == ' ' || line[0] == '\t')) {
                        /*
                         * If this line is a continuation (via space or tab)
                         * of a previous header field, just echo it
                         * (unless the field should be ignored).
                        /*
                         * If this line is a continuation (via space or tab)
                         * of a previous header field, just echo it
                         * (unless the field should be ignored).
+                        * In other words, nothing to do.
                         */
                         */
-                       if (infld && (isspace(line[0]) || line[0] == '\t')) {
-                               if (doign && isign(field)) continue;
-                               goto writeit;
-                       }
-                       infld = 0;
+               } else {
                        /*
                        /*
-                        * If we are no longer looking at real
-                        * header lines, force out status:
-                        * This happens in uucp style mail where
-                        * there are no headers at all.
+                        * Pick up the header field if we have one.
                         */
                         */
-                       if (!headerp(line)) {
+                       for (cp = line; (c = *cp++) && c != ':' && !isspace(c);)
+                               ;
+                       cp2 = --cp;
+                       while (isspace(*cp++))
+                               ;
+                       if (cp[-1] != ':') {
+                               /*
+                                * Not a header line, force out status:
+                                * This happens in uucp style mail where
+                                * there are no headers at all.
+                                */
                                if (dostat) {
                                if (dostat) {
-                                       statusput(mailp, obuf, doign);
+                                       statusput(mp, obuf);
                                        dostat = 0;
                                }
                                        dostat = 0;
                                }
-                               putc('\n', obuf);
+                               putc('\n', obuf);       /* add blank line */
+                               lc++;
                                ishead = 0;
                                ishead = 0;
-                               goto writeit;
-                       }
-                       infld++;
-                       /*
-                        * Pick up the header field.
-                        * If it is an ignored field and
-                        * we care about such things, skip it.
-                        */
-                       cp = line;
-                       cp2 = field;
-                       while (*cp && *cp != ':' && !isspace(*cp))
-                               *cp2++ = *cp++;
-                       *cp2 = 0;
-                       if (doign && isign(field))
-                               continue;
-                       /*
-                        * If the field is "status," go compute and print the
-                        * real Status: field
-                        */
-                       if (icequal(field, "status")) {
-                               if (dostat) {
-                                       statusput(mailp, obuf, doign);
-                                       dostat = 0;
+                               ignoring = 0;
+                       } else {
+                               /*
+                                * If it is an ignored field and
+                                * we care about such things, skip it.
+                                */
+                               *cp2 = 0;       /* temporarily null terminate */
+                               if (doign && isign(line))
+                                       ignoring = 1;
+                               else if ((line[0] == 's' || line[0] == 'S') &&
+                                        icequal(line, "status")) {
+                                       /*
+                                        * If the field is "status," go compute
+                                        * and print the real Status: field
+                                        */
+                                       if (dostat) {
+                                               statusput(mp, obuf);
+                                               dostat = 0;
+                                       }
+                                       ignoring = 1;
+                               } else {
+                                       ignoring = 0;
+                                       *cp2 = c;       /* restore */
                                }
                                }
-                               continue;
+                               infld = 1;
                        }
                }
                        }
                }
-writeit:
-               fputs(line, obuf);
-               if (ferror(obuf))
-                       return(-1);
+               if (!ignoring) {
+                       fwrite(line, sizeof *line, length, obuf);
+                       if (ferror(obuf))
+                               return -1;
+                       lc++;
+               }
        }
        }
-       if (ferror(obuf))
-               return(-1);
-       if (ishead && (mailp->m_flag & MSTATUS))
+       /*
+        * Copy out message body
+        */
+       while (count > 0) {
+               cp = line;
+               c = count < LINESIZE ? count : LINESIZE;
+               if ((c = fread(cp, sizeof *cp, c, ibuf)) <= 0)
+                       break;
+               if (fwrite(cp, sizeof *cp, c, obuf) != c)
+                       return -1;
+               count -= c;
+               while (--c >= 0)
+                       if (*cp++ == '\n')
+                               lc++;
+       }
+       if (ishead && (mp->m_flag & MSTATUS))
                printf("failed to fix up status field\n");
                printf("failed to fix up status field\n");
-       return(lc);
-}
-
-/*
- * Test if the passed line is a header line, RFC 733 style.
- */
-headerp(line)
-       register char *line;
-{
-       register char *cp = line;
-
-       while (*cp && !isspace(*cp) && *cp != ':')
-               cp++;
-       while (*cp && isspace(*cp))
-               cp++;
-       return(*cp == ':');
+       return (lc);
 }
 
 /*
  * Output a reasonable looking status field.
  * But if "status" is ignored and doign, forget it.
  */
 }
 
 /*
  * Output a reasonable looking status field.
  * But if "status" is ignored and doign, forget it.
  */
-statusput(mp, obuf, doign)
+statusput(mp, obuf)
        register struct message *mp;
        register struct message *mp;
-       register FILE *obuf;
+       FILE *obuf;
 {
        char statout[3];
 {
        char statout[3];
+       register char *cp = statout;
 
 
-       if (doign && isign("status"))
-               return;
-       if ((mp->m_flag & (MNEW|MREAD)) == MNEW)
-               return;
        if (mp->m_flag & MREAD)
        if (mp->m_flag & MREAD)
-               strcpy(statout, "R");
-       else
-               strcpy(statout, "");
+               *cp++ = 'R';
        if ((mp->m_flag & MNEW) == 0)
        if ((mp->m_flag & MNEW) == 0)
-               strcat(statout, "O");
-       fprintf(obuf, "Status: %s\n", statout);
+               *cp++ = 'O';
+       *cp = 0;
+       if (statout[0])
+               fprintf(obuf, "Status: %s\n", statout);
 }
 
 }
 
-
 /*
  * Interface between the argument list and the mail1 routine
  * which does all the dirty work.
 /*
  * Interface between the argument list and the mail1 routine
  * which does all the dirty work.
@@ -188,11 +184,11 @@ mail(people)
        char *buf, **ap;
        struct header head;
 
        char *buf, **ap;
        struct header head;
 
-       for (s = 0, ap = people; *ap != (char *) -1; ap++)
+       for (s = 0, ap = people; *ap != 0; ap++)
                s += strlen(*ap) + 1;
        buf = salloc(s+1);
        cp2 = buf;
                s += strlen(*ap) + 1;
        buf = salloc(s+1);
        cp2 = buf;
-       for (ap = people; *ap != (char *) -1; ap++) {
+       for (ap = people; *ap != 0; ap++) {
                cp2 = copy(*ap, cp2);
                *cp2++ = ' ';
        }
                cp2 = copy(*ap, cp2);
                *cp2++ = ' ';
        }
@@ -217,9 +213,6 @@ mail(people)
 sendmail(str)
        char *str;
 {
 sendmail(str)
        char *str;
 {
-       register char **ap;
-       char *bufp;
-       register int t;
        struct header head;
 
        if (blankline(str))
        struct header head;
 
        if (blankline(str))
@@ -243,7 +236,8 @@ mail1(hp)
        struct header *hp;
 {
        register char *cp;
        struct header *hp;
 {
        register char *cp;
-       int pid, i, s, p, gotcha;
+       int pid, i, p, gotcha;
+       union wait s;
        char **namelist, *deliver;
        struct name *to, *np;
        struct stat sbuf;
        char **namelist, *deliver;
        struct name *to, *np;
        struct stat sbuf;
@@ -330,10 +324,10 @@ topdog:
                        printf(" \"%s\"", *t);
                printf("\n");
                fflush(stdout);
                        printf(" \"%s\"", *t);
                printf("\n");
                fflush(stdout);
-               return;
+               return 0;
        }
        if ((cp = value("record")) != NOSTR)
        }
        if ((cp = value("record")) != NOSTR)
-               savemail(expand(cp), hp, mtf);
+               savemail(expand(cp), mtf);
 
        /*
         * Wait, to absorb a potential zombie, then
 
        /*
         * Wait, to absorb a potential zombie, then
@@ -343,17 +337,8 @@ topdog:
         * wants to await the completion of mail.
         */
 
         * wants to await the completion of mail.
         */
 
-#ifdef VMUNIX
-#ifdef pdp11
-       while (wait2(&s, WNOHANG) > 0)
-#endif
-#if defined(vax) || defined(sun)
-       while (wait3(&s, WNOHANG, 0) > 0)
-#endif
+       while (wait3(&s, WNOHANG, (struct timeval *) 0) > 0)
                ;
                ;
-#else
-       wait(&s);
-#endif
        rewind(mtf);
        pid = fork();
        if (pid == -1) {
        rewind(mtf);
        pid = fork();
        if (pid == -1) {
@@ -363,32 +348,26 @@ topdog:
                goto out;
        }
        if (pid == 0) {
                goto out;
        }
        if (pid == 0) {
-               sigchild();
 #ifdef SIGTSTP
                if (remote == 0) {
 #ifdef SIGTSTP
                if (remote == 0) {
-                       sigset(SIGTSTP, SIG_IGN);
-                       sigset(SIGTTIN, SIG_IGN);
-                       sigset(SIGTTOU, SIG_IGN);
+                       signal(SIGTSTP, SIG_IGN);
+                       signal(SIGTTIN, SIG_IGN);
+                       signal(SIGTTOU, SIG_IGN);
                }
 #endif
                }
 #endif
-               for (i = SIGHUP; i <= SIGQUIT; i++)
-                       sigset(i, SIG_IGN);
+               signal(SIGHUP, SIG_IGN);
+               signal(SIGINT, SIG_IGN);
+               signal(SIGQUIT, SIG_IGN);
                if (!stat(POSTAGE, &sbuf))
                        if ((postage = fopen(POSTAGE, "a")) != NULL) {
                                fprintf(postage, "%s %d %d\n", myname,
                                    count(to), fsize(mtf));
                                fclose(postage);
                        }
                if (!stat(POSTAGE, &sbuf))
                        if ((postage = fopen(POSTAGE, "a")) != NULL) {
                                fprintf(postage, "%s %d %d\n", myname,
                                    count(to), fsize(mtf));
                                fclose(postage);
                        }
-               s = fileno(mtf);
-               for (i = 3; i < 15; i++)
-                       if (i != s)
-                               close(i);
                close(0);
                close(0);
-               dup(s);
-               close(s);
-#ifdef CC
-               submit(getpid());
-#endif CC
+               dup(fileno(mtf));
+               for (i = getdtablesize(); --i > 2;)
+                       close(i);
 #ifdef SENDMAIL
                if ((deliver = value("sendmail")) == NOSTR)
                        deliver = SENDMAIL;
 #ifdef SENDMAIL
                if ((deliver = value("sendmail")) == NOSTR)
                        deliver = SENDMAIL;
@@ -403,7 +382,7 @@ out:
        if (remote || (value("verbose") != NOSTR)) {
                while ((p = wait(&s)) != pid && p != -1)
                        ;
        if (remote || (value("verbose") != NOSTR)) {
                while ((p = wait(&s)) != pid && p != -1)
                        ;
-               if (s != 0)
+               if (s.w_status != 0)
                        senderr++;
                pid = 0;
        }
                        senderr++;
                pid = 0;
        }
@@ -422,7 +401,6 @@ fixhead(hp, tolist)
        struct header *hp;
        struct name *tolist;
 {
        struct header *hp;
        struct name *tolist;
 {
-       register struct name *nlist;
        register int f;
        register struct name *np;
 
        register int f;
        register struct name *np;
 
@@ -529,7 +507,7 @@ fmt(str, txt, fo)
        bl = 0;
        while (*bg) {
                pt++;
        bl = 0;
        while (*bg) {
                pt++;
-               if (++col >72) {
+               if (++col > 72) {
                        if (!bl) {
                                bl = bg;
                                while (*bl && !isspace(*bl))
                        if (!bl) {
                                bl = bg;
                                while (*bl && !isspace(*bl))
@@ -559,32 +537,33 @@ finish:
  * Save the outgoing mail on the passed file.
  */
 
  * Save the outgoing mail on the passed file.
  */
 
-savemail(name, hp, fi)
+/*ARGSUSED*/
+savemail(name, fi)
        char name[];
        char name[];
-       struct header *hp;
-       FILE *fi;
+       register FILE *fi;
 {
        register FILE *fo;
 {
        register FILE *fo;
-       register int c;
-       long now;
+       char buf[BUFSIZ];
+       register i;
+       time_t now, time();
        char *n;
        char *n;
+       char *ctime();
 
        if ((fo = fopen(name, "a")) == NULL) {
                perror(name);
 
        if ((fo = fopen(name, "a")) == NULL) {
                perror(name);
-               return(-1);
+               return (-1);
        }
        time(&now);
        }
        time(&now);
-       n = rflag;
-       if (n == NOSTR)
+       if ((n = rflag) == NOSTR)
                n = myname;
        fprintf(fo, "From %s %s", n, ctime(&now));
        rewind(fi);
                n = myname;
        fprintf(fo, "From %s %s", n, ctime(&now));
        rewind(fi);
-       for (c = getc(fi); c != EOF; c = getc(fi))
-               putc(c, fo);
-       fprintf(fo, "\n");
+       while ((i = fread(buf, 1, sizeof buf, fi)) > 0)
+               fwrite(buf, 1, i, fo);
+       putc('\n', fo);
        fflush(fo);
        if (ferror(fo))
                perror(name);
        fclose(fo);
        fflush(fo);
        if (ferror(fo))
                perror(name);
        fclose(fo);
-       return(0);
+       return (0);
 }
 }
index c5b1e3d..48ba627 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)strings.c   5.3 (Berkeley) %G%";
+static char *sccsid = "@(#)strings.c   5.4 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
index 4f9d688..a18e7ad 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)temp.c      5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)temp.c      5.3 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #endif not lint
 
 #include "rcv.h"
@@ -25,10 +25,10 @@ char        tempMesg[14];
 
 tinit()
 {
 
 tinit()
 {
-       register char *cp, *cp2;
+       register char *cp;
        char uname[PATHSIZE];
        char uname[PATHSIZE];
-       register int err = 0;
        register int pid;
        register int pid;
+       uid_t getuid();
 
        pid = getpid();
        sprintf(tempMail, "/tmp/Rs%05d", pid);
 
        pid = getpid();
        sprintf(tempMail, "/tmp/Rs%05d", pid);
@@ -47,29 +47,23 @@ tinit()
                }
        }
        else {
                }
        }
        else {
-               uid = getuid() & UIDMASK;
+               uid = getuid();
                if (username(uid, uname) < 0) {
                if (username(uid, uname) < 0) {
-                       copy("ubluit", myname);
-                       err++;
+                       strcpy(myname, "ubluit");
                        if (rcvmode) {
                                printf("Who are you!?\n");
                                exit(1);
                        }
                        if (rcvmode) {
                                printf("Who are you!?\n");
                                exit(1);
                        }
-               }
-               else
-                       copy(uname, myname);
+               } else
+                       strcpy(myname, uname);
        }
        }
-       cp = value("HOME");
-       if (cp == NOSTR)
+       if ((cp = value("HOME")) == NOSTR)
                cp = ".";
                cp = ".";
-       copy(cp, homedir);
+       strcpy(homedir, cp);
        findmail();
        findmail();
-       cp = copy(homedir, mbox);
-       copy("/mbox", cp);
-       cp = copy(homedir, mailrc);
-       copy("/.mailrc", cp);
-       cp = copy(homedir, deadletter);
-       copy("/dead.letter", cp);
+       strcpy(copy(homedir, mbox), "/mbox");
+       strcpy(copy(homedir, mailrc), "/.mailrc");
+       strcpy(copy(homedir, deadletter), "/dead.letter");
        if (debug) {
                printf("uid = %d, user = %s, mailname = %s\n",
                    uid, myname, mailname);
        if (debug) {
                printf("uid = %d, user = %s, mailname = %s\n",
                    uid, myname, mailname);
index be56f74..94dd81d 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)tty.c       5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)tty.c       5.3 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -32,17 +32,14 @@ grabh(hp, gflags)
        struct header *hp;
 {
        struct sgttyb ttybuf;
        struct header *hp;
 {
        struct sgttyb ttybuf;
-       int ttycont(), signull();
+       int ttycont();
 #ifndef TIOCSTI
 #ifndef TIOCSTI
-       int (*savesigs[2])();
+       int (*saveint)(), (*savequit)();
 #endif
        int (*savecont)();
 #endif
        int (*savecont)();
-       register int s;
        int errs;
 
        int errs;
 
-# ifdef VMUNIX
-       savecont = sigset(SIGCONT, signull);
-# endif VMUNIX
+       savecont = signal(SIGCONT, SIG_DFL);
        errs = 0;
 #ifndef TIOCSTI
        ttyset = 0;
        errs = 0;
 #ifndef TIOCSTI
        ttyset = 0;
@@ -56,9 +53,10 @@ grabh(hp, gflags)
 #ifndef TIOCSTI
        ttybuf.sg_erase = 0;
        ttybuf.sg_kill = 0;
 #ifndef TIOCSTI
        ttybuf.sg_erase = 0;
        ttybuf.sg_kill = 0;
-       for (s = SIGINT; s <= SIGQUIT; s++)
-               if ((savesigs[s-SIGINT] = sigset(s, SIG_IGN)) == SIG_DFL)
-                       sigset(s, SIG_DFL);
+       if ((saveint = signal(SIGINT, SIG_IGN)) == SIG_DFL)
+               signal(SIGINT, SIG_DFL);
+       if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL)
+               signal(SIGQUIT, SIG_DFL);
 #endif
        if (gflags & GTO) {
 #ifndef TIOCSTI
 #endif
        if (gflags & GTO) {
 #ifndef TIOCSTI
@@ -96,16 +94,14 @@ grabh(hp, gflags)
                if (hp->h_bcc != NOSTR)
                        hp->h_seq++;
        }
                if (hp->h_bcc != NOSTR)
                        hp->h_seq++;
        }
-# ifdef VMUNIX
-       sigset(SIGCONT, savecont);
-# endif VMUNIX
+       signal(SIGCONT, savecont);
 #ifndef TIOCSTI
        ttybuf.sg_erase = c_erase;
        ttybuf.sg_kill = c_kill;
        if (ttyset)
                stty(fileno(stdin), &ttybuf);
 #ifndef TIOCSTI
        ttybuf.sg_erase = c_erase;
        ttybuf.sg_kill = c_kill;
        if (ttyset)
                stty(fileno(stdin), &ttybuf);
-       for (s = SIGINT; s <= SIGQUIT; s++)
-               sigset(s, savesigs[s-SIGINT]);
+       signal(SIGINT, saveint);
+       signal(SIGQUIT, savequit);
 #endif
        return(errs);
 }
 #endif
        return(errs);
 }
@@ -122,7 +118,7 @@ readtty(pr, src)
        char pr[], src[];
 {
        char ch, canonb[BUFSIZ];
        char pr[], src[];
 {
        char ch, canonb[BUFSIZ];
-       int c, signull();
+       int c;
        register char *cp, *cp2;
 
        fputs(pr, stdout);
        register char *cp, *cp2;
 
        fputs(pr, stdout);
@@ -157,9 +153,7 @@ readtty(pr, src)
        cp2 = cp;
        if (setjmp(rewrite))
                goto redo;
        cp2 = cp;
        if (setjmp(rewrite))
                goto redo;
-# ifdef VMUNIX
-       sigset(SIGCONT, ttycont);
-# endif VMUNIX
+       signal(SIGCONT, ttycont);
        clearerr(stdin);
        while (cp2 < canonb + BUFSIZ) {
                c = getc(stdin);
        clearerr(stdin);
        while (cp2 < canonb + BUFSIZ) {
                c = getc(stdin);
@@ -168,9 +162,7 @@ readtty(pr, src)
                *cp2++ = c;
        }
        *cp2 = 0;
                *cp2++ = c;
        }
        *cp2 = 0;
-# ifdef VMUNIX
-       sigset(SIGCONT, signull);
-# endif VMUNIX
+       signal(SIGCONT, SIG_DFL);
        if (c == EOF && ferror(stdin) && hadcont) {
 redo:
                hadcont = 0;
        if (c == EOF && ferror(stdin) && hadcont) {
 redo:
                hadcont = 0;
@@ -215,21 +207,13 @@ redo:
        return(savestr(canonb));
 }
 
        return(savestr(canonb));
 }
 
-# ifdef VMUNIX
 /*
  * Receipt continuation.
  */
 /*
  * Receipt continuation.
  */
+/*ARGSUSED*/
 ttycont(s)
 {
 
        hadcont++;
        longjmp(rewrite, 1);
 }
 ttycont(s)
 {
 
        hadcont++;
        longjmp(rewrite, 1);
 }
-# endif VMUNIX
-
-/*
- * Null routine to satisfy
- * silly system bug that denies us holding SIGCONT
- */
-signull(s)
-{}
index 68d14ad..24ed9b6 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)v7.local.c  5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)v7.local.c  5.3 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -25,10 +25,8 @@ static char *sccsid = "@(#)v7.local.c        5.2 (Berkeley) %G%";
 
 findmail()
 {
 
 findmail()
 {
-       register char *cp;
 
 
-       cp = copy("/usr/spool/mail/", mailname);
-       copy(myname, cp);
+       strcpy(copy("/usr/spool/mail/", mailname), myname);
        if (isdir(mailname)) {
                stradd(mailname, '/');
                strcat(mailname, myname);
        if (isdir(mailname)) {
                stradd(mailname, '/');
                strcat(mailname, myname);
index 3d82f73..7df1f1b 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)vars.c      5.2 (Berkeley) %G%";
+static char *sccsid = "@(#)vars.c      5.3 (Berkeley) %G%";
 #endif not lint
 
 #include "rcv.h"
 #endif not lint
 
 #include "rcv.h"
@@ -46,10 +46,10 @@ assign(name, value)
  */
 
 vfree(cp)
  */
 
 vfree(cp)
-       register char *cp;
+       char *cp;
 {
 {
-       if (!equal(cp, ""))
-               cfree(cp);
+       if (*cp)
+               free(cp);
 }
 
 /*
 }
 
 /*
@@ -61,17 +61,16 @@ char *
 vcopy(str)
        char str[];
 {
 vcopy(str)
        char str[];
 {
-       register char *top, *cp, *cp2;
-
-       if (equal(str, ""))
-               return("");
-       if ((top = calloc(strlen(str)+1, 1)) == NULL)
-               panic ("Out of memory");
-       cp = top;
-       cp2 = str;
-       while (*cp++ = *cp2++)
-               ;
-       return(top);
+       char *new;
+       unsigned len;
+
+       if (*str == '\0')
+               return "";
+       len = strlen(str) + 1;
+       if ((new = malloc(len)) == NULL)
+               panic("Out of memory");
+       bcopy(str, new, (int) len);
+       return new;
 }
 
 /*
 }
 
 /*
@@ -97,14 +96,12 @@ value(name)
 
 struct var *
 lookup(name)
 
 struct var *
 lookup(name)
-       char name[];
+       register char name[];
 {
        register struct var *vp;
 {
        register struct var *vp;
-       register int h;
 
 
-       h = hash(name);
-       for (vp = variables[h]; vp != NOVAR; vp = vp->v_link)
-               if (equal(vp->v_name, name))
+       for (vp = variables[hash(name)]; vp != NOVAR; vp = vp->v_link)
+               if (*vp->v_name == *name && equal(vp->v_name, name))
                        return(vp);
        return(NOVAR);
 }
                        return(vp);
        return(NOVAR);
 }
@@ -115,14 +112,12 @@ lookup(name)
 
 struct grouphead *
 findgroup(name)
 
 struct grouphead *
 findgroup(name)
-       char name[];
+       register char name[];
 {
        register struct grouphead *gh;
 {
        register struct grouphead *gh;
-       register int h;
 
 
-       h = hash(name);
-       for (gh = groups[h]; gh != NOGRP; gh = gh->g_link)
-               if (equal(gh->g_name, name))
+       for (gh = groups[hash(name)]; gh != NOGRP; gh = gh->g_link)
+               if (*gh->g_name == *name && equal(gh->g_name, name))
                        return(gh);
        return(NOGRP);
 }
                        return(gh);
        return(NOGRP);
 }
@@ -144,7 +139,7 @@ printgroup(name)
        printf("%s\t", gh->g_name);
        for (gp = gh->g_list; gp != NOGE; gp = gp->ge_link)
                printf(" %s", gp->ge_name);
        printf("%s\t", gh->g_name);
        for (gp = gh->g_list; gp != NOGE; gp = gp->ge_link)
                printf(" %s", gp->ge_name);
-       printf("\n");
+       putchar('\n');
 }
 
 /*
 }
 
 /*
@@ -153,16 +148,15 @@ printgroup(name)
  */
 
 hash(name)
  */
 
 hash(name)
-       char name[];
+       register char *name;
 {
 {
-       register unsigned h;
-       register char *cp;
-
-       for (cp = name, h = 0; *cp; h = (h << 2) + *cp++)
-               ;
-       if (h < 0)
-               h = -h;
-       if (h < 0)
+       register h = 0;
+
+       while (*name) {
+               h <<= 2;
+               h += *name++;
+       }
+       if (h < 0 && (h = -h) < 0)
                h = 0;
                h = 0;
-       return(h % HSHSIZE);
+       return (h % HSHSIZE);
 }
 }