BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / mail / lex.c
index 01e938c..880c99a 100644 (file)
@@ -2,21 +2,23 @@
  * Copyright (c) 1980 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1980 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)lex.c      5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c      5.21 (Berkeley) 6/25/90";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
@@ -52,7 +54,7 @@ setfile(name)
        if ((name = expand(name)) == NOSTR)
                return -1;
 
        if ((name = expand(name)) == NOSTR)
                return -1;
 
-       if ((ibuf = fopen(name, "r")) == NULL) {
+       if ((ibuf = Fopen(name, "r")) == NULL) {
                if (!isedit && errno == ENOENT)
                        goto nomail;
                perror(name);
                if (!isedit && errno == ENOENT)
                        goto nomail;
                perror(name);
@@ -61,13 +63,13 @@ setfile(name)
 
        if (fstat(fileno(ibuf), &stb) < 0) {
                perror("fstat");
 
        if (fstat(fileno(ibuf), &stb) < 0) {
                perror("fstat");
-               fclose(ibuf);
+               Fclose(ibuf);
                return (-1);
        }
 
        switch (stb.st_mode & S_IFMT) {
        case S_IFDIR:
                return (-1);
        }
 
        switch (stb.st_mode & S_IFMT) {
        case S_IFDIR:
-               fclose(ibuf);
+               Fclose(ibuf);
                errno = EISDIR;
                perror(name);
                return (-1);
                errno = EISDIR;
                perror(name);
                return (-1);
@@ -76,7 +78,7 @@ setfile(name)
                break;
 
        default:
                break;
 
        default:
-               fclose(ibuf);
+               Fclose(ibuf);
                errno = EINVAL;
                perror(name);
                return (-1);
                errno = EINVAL;
                perror(name);
                return (-1);
@@ -124,7 +126,7 @@ setfile(name)
        remove(tempMesg);
        setptr(ibuf);
        setmsize(msgCount);
        remove(tempMesg);
        setptr(ibuf);
        setmsize(msgCount);
-       fclose(ibuf);
+       Fclose(ibuf);
        relsesigs();
        sawcom = 0;
        if (!edit && msgCount == 0) {
        relsesigs();
        sawcom = 0;
        if (!edit && msgCount == 0) {
@@ -468,34 +470,6 @@ isprefix(as1, as2)
 
 int    inithdr;                        /* am printing startup headers */
 
 
 int    inithdr;                        /* am printing startup headers */
 
-#ifdef _NFILE
-static
-_fwalk(function)
-       register int (*function)();
-{
-       register FILE *iop;
-
-       for (iop = _iob; iop < _iob + _NFILE; iop++)
-               (*function)(iop);
-}
-#endif
-
-static
-xclose(iop)
-       register FILE *iop;
-{
-       if (iop == stdin || iop == stdout ||
-           iop == stderr || iop == itf || iop == otf)
-               return;
-
-       if (iop != pipef)
-               fclose(iop);
-       else {
-               Pclose(pipef);
-               pipef = NULL;
-       }
-}
-
 /*ARGSUSED*/
 intr(s)
 {
 /*ARGSUSED*/
 intr(s)
 {
@@ -507,10 +481,7 @@ intr(s)
        while (sourcing)
                unstack();
 
        while (sourcing)
                unstack();
 
-       /*
-        * Walk through all the open FILEs, applying xclose() to them
-        */
-       _fwalk(xclose);
+       close_all_files();
 
        if (image >= 0) {
                close(image);
 
        if (image >= 0) {
                close(image);
@@ -525,7 +496,7 @@ intr(s)
  */
 stop(s)
 {
  */
 stop(s)
 {
-       int (*old_action)() = signal(s, SIG_DFL);
+       sig_t old_action = signal(s, SIG_DFL);
 
        sigsetmask(sigblock(0) & ~sigmask(s));
        kill(0, s);
 
        sigsetmask(sigblock(0) & ~sigmask(s));
        kill(0, s);
@@ -648,7 +619,7 @@ load(name)
 {
        register FILE *in, *oldin;
 
 {
        register FILE *in, *oldin;
 
-       if ((in = fopen(name, "r")) == NULL)
+       if ((in = Fopen(name, "r")) == NULL)
                return;
        oldin = input;
        input = in;
                return;
        oldin = input;
        input = in;
@@ -658,5 +629,5 @@ load(name)
        loading = 0;
        sourcing = 0;
        input = oldin;
        loading = 0;
        sourcing = 0;
        input = oldin;
-       fclose(in);
+       Fclose(in);
 }
 }