4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / mail / collect.c
index 8a3bc95..73a0d98 100644 (file)
@@ -1,12 +1,12 @@
 /*
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)collect.c  5.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)collect.c  8.1 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -17,7 +17,7 @@ static char sccsid[] = "@(#)collect.c 5.22 (Berkeley) %G%";
  */
 
 #include "rcv.h"
  */
 
 #include "rcv.h"
-#include <sys/stat.h>
+#include "extern.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
@@ -45,15 +45,16 @@ static      jmp_buf collabort;              /* To end collection with error */
 FILE *
 collect(hp, printheaders)
        struct header *hp;
 FILE *
 collect(hp, printheaders)
        struct header *hp;
+       int printheaders;
 {
        FILE *fbuf;
        int lc, cc, escape, eofcount;
 {
        FILE *fbuf;
        int lc, cc, escape, eofcount;
-       int collint(), collhup(), collstop();
        register int c, t;
        char linebuf[LINESIZE], *cp;
        extern char tempMail[];
        char getsub;
        int omask;
        register int c, t;
        char linebuf[LINESIZE], *cp;
        extern char tempMail[];
        char getsub;
        int omask;
+       void collint(), collhup(), collstop();
 
        collf = NULL;
        /*
 
        collf = NULL;
        /*
@@ -69,7 +70,7 @@ collect(hp, printheaders)
        savettou = signal(SIGTTOU, collstop);
        savettin = signal(SIGTTIN, collstop);
        if (setjmp(collabort) || setjmp(colljmp)) {
        savettou = signal(SIGTTOU, collstop);
        savettin = signal(SIGTTIN, collstop);
        if (setjmp(collabort) || setjmp(colljmp)) {
-               remove(tempMail);
+               rm(tempMail);
                goto err;
        }
        sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
                goto err;
        }
        sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
@@ -358,10 +359,11 @@ out:
 /*
  * Write a file, ex-like if f set.
  */
 /*
  * Write a file, ex-like if f set.
  */
-
+int
 exwrite(name, fp, f)
        char name[];
        FILE *fp;
 exwrite(name, fp, f)
        char name[];
        FILE *fp;
+       int f;
 {
        register FILE *of;
        register int c;
 {
        register FILE *of;
        register int c;
@@ -406,14 +408,16 @@ exwrite(name, fp, f)
  * Edit the message being collected on fp.
  * On return, make the edit file the new temp file.
  */
  * Edit the message being collected on fp.
  * On return, make the edit file the new temp file.
  */
+void
 mesedit(fp, c)
        FILE *fp;
 mesedit(fp, c)
        FILE *fp;
+       int c;
 {
        sig_t sigint = signal(SIGINT, SIG_IGN);
        FILE *nf = run_editor(fp, (off_t)-1, c, 0);
 
        if (nf != NULL) {
 {
        sig_t sigint = signal(SIGINT, SIG_IGN);
        FILE *nf = run_editor(fp, (off_t)-1, c, 0);
 
        if (nf != NULL) {
-               fseek(nf, (off_t)0, 2);
+               fseek(nf, 0L, 2);
                collf = nf;
                Fclose(fp);
        }
                collf = nf;
                Fclose(fp);
        }
@@ -426,6 +430,7 @@ mesedit(fp, c)
  * New message collected from stdout.
  * Sh -c must return 0 to accept the new message.
  */
  * New message collected from stdout.
  * Sh -c must return 0 to accept the new message.
  */
+void
 mespipe(fp, cmd)
        FILE *fp;
        char cmd[];
 mespipe(fp, cmd)
        FILE *fp;
        char cmd[];
@@ -443,7 +448,8 @@ mespipe(fp, cmd)
         * stdin = current message.
         * stdout = new message.
         */
         * stdin = current message.
         * stdout = new message.
         */
-       if (run_command(cmd, 0, fileno(fp), fileno(nf), NOSTR) < 0) {
+       if (run_command(cmd,
+           0, fileno(fp), fileno(nf), NOSTR, NOSTR, NOSTR) < 0) {
                (void) Fclose(nf);
                goto out;
        }
                (void) Fclose(nf);
                goto out;
        }
@@ -470,9 +476,11 @@ out:
  * 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.
  */
+int
 forward(ms, fp, f)
        char ms[];
        FILE *fp;
 forward(ms, fp, f)
        char ms[];
        FILE *fp;
+       int f;
 {
        register int *msgvec;
        extern char tempMail[];
 {
        register int *msgvec;
        extern char tempMail[];
@@ -516,7 +524,9 @@ forward(ms, fp, f)
  * Print (continue) when continued after ^Z.
  */
 /*ARGSUSED*/
  * Print (continue) when continued after ^Z.
  */
 /*ARGSUSED*/
+void
 collstop(s)
 collstop(s)
+       int s;
 {
        sig_t old_action = signal(s, SIG_DFL);
 
 {
        sig_t old_action = signal(s, SIG_DFL);
 
@@ -536,7 +546,9 @@ collstop(s)
  * Then jump out of the collection loop.
  */
 /*ARGSUSED*/
  * Then jump out of the collection loop.
  */
 /*ARGSUSED*/
+void
 collint(s)
 collint(s)
+       int s;
 {
        /*
         * the control flow is subtle, because we can be called from ~q.
 {
        /*
         * the control flow is subtle, because we can be called from ~q.
@@ -558,7 +570,9 @@ collint(s)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
+void
 collhup(s)
 collhup(s)
+       int s;
 {
        rewind(collf);
        savedeadletter(collf);
 {
        rewind(collf);
        savedeadletter(collf);
@@ -569,6 +583,7 @@ collhup(s)
        exit(1);
 }
 
        exit(1);
 }
 
+void
 savedeadletter(fp)
        register FILE *fp;
 {
 savedeadletter(fp)
        register FILE *fp;
 {