4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / mail / cmd2.c
index ccfb3d4..e3734a7 100644 (file)
@@ -1,16 +1,17 @@
 /*
 /*
- * 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[] = "@(#)cmd2.c     5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd2.c     8.1 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "rcv.h"
 #include <sys/wait.h>
 #endif /* not lint */
 
 #include "rcv.h"
 #include <sys/wait.h>
+#include "extern.h"
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -23,7 +24,7 @@ static char sccsid[] = "@(#)cmd2.c    5.13 (Berkeley) %G%";
  * following dot, otherwise, go to the next applicable message.
  * If given as first command with no arguments, print first message.
  */
  * following dot, otherwise, go to the next applicable message.
  * If given as first command with no arguments, print first message.
  */
-
+int
 next(msgvec)
        int *msgvec;
 {
 next(msgvec)
        int *msgvec;
 {
@@ -102,6 +103,7 @@ hitit:
  * Save a message in a file.  Mark the message as saved
  * so we can discard when the user quits.
  */
  * Save a message in a file.  Mark the message as saved
  * so we can discard when the user quits.
  */
+int
 save(str)
        char str[];
 {
 save(str)
        char str[];
 {
@@ -112,6 +114,7 @@ save(str)
 /*
  * Copy a message to a file without affected its saved-ness
  */
 /*
  * Copy a message to a file without affected its saved-ness
  */
+int
 copycmd(str)
        char str[];
 {
 copycmd(str)
        char str[];
 {
@@ -123,8 +126,10 @@ copycmd(str)
  * Save/copy the indicated messages at the end of the passed file name.
  * If mark is true, mark the message "saved."
  */
  * Save/copy the indicated messages at the end of the passed file name.
  * If mark is true, mark the message "saved."
  */
+int
 save1(str, mark, cmd, ignore)
        char str[];
 save1(str, mark, cmd, ignore)
        char str[];
+       int mark;
        char *cmd;
        struct ignoretab *ignore;
 {
        char *cmd;
        struct ignoretab *ignore;
 {
@@ -155,7 +160,7 @@ save1(str, mark, cmd, ignore)
                disp = "[Appended]";
        else
                disp = "[New file]";
                disp = "[Appended]";
        else
                disp = "[New file]";
-       if ((obuf = fopen(file, "a")) == NULL) {
+       if ((obuf = Fopen(file, "a")) == NULL) {
                perror(NOSTR);
                return(1);
        }
                perror(NOSTR);
                return(1);
        }
@@ -164,7 +169,7 @@ save1(str, mark, cmd, ignore)
                touch(mp);
                if (send(mp, obuf, ignore, NOSTR) < 0) {
                        perror(file);
                touch(mp);
                if (send(mp, obuf, ignore, NOSTR) < 0) {
                        perror(file);
-                       fclose(obuf);
+                       Fclose(obuf);
                        return(1);
                }
                if (mark)
                        return(1);
                }
                if (mark)
@@ -173,7 +178,7 @@ save1(str, mark, cmd, ignore)
        fflush(obuf);
        if (ferror(obuf))
                perror(file);
        fflush(obuf);
        if (ferror(obuf))
                perror(file);
-       fclose(obuf);
+       Fclose(obuf);
        printf("%s\n", disp);
        return(0);
 }
        printf("%s\n", disp);
        return(0);
 }
@@ -182,7 +187,7 @@ save1(str, mark, cmd, ignore)
  * Write the indicated messages at the end of the passed
  * file name, minus header and trailing blank line.
  */
  * Write the indicated messages at the end of the passed
  * file name, minus header and trailing blank line.
  */
-
+int
 swrite(str)
        char str[];
 {
 swrite(str)
        char str[];
 {
@@ -237,7 +242,7 @@ snarf(linebuf, flag)
 /*
  * Delete messages.
  */
 /*
  * Delete messages.
  */
-
+int
 delete(msgvec)
        int msgvec[];
 {
 delete(msgvec)
        int msgvec[];
 {
@@ -248,7 +253,7 @@ delete(msgvec)
 /*
  * Delete messages, then type the new dot.
  */
 /*
  * Delete messages, then type the new dot.
  */
-
+int
 deltype(msgvec)
        int msgvec[];
 {
 deltype(msgvec)
        int msgvec[];
 {
@@ -274,7 +279,7 @@ deltype(msgvec)
  * Set dot to some nice place afterwards.
  * Internal interface.
  */
  * Set dot to some nice place afterwards.
  * Internal interface.
  */
-
+int
 delm(msgvec)
        int *msgvec;
 {
 delm(msgvec)
        int *msgvec;
 {
@@ -313,7 +318,7 @@ delm(msgvec)
 /*
  * Undelete the indicated messages.
  */
 /*
  * Undelete the indicated messages.
  */
-
+int
 undelete(msgvec)
        int *msgvec;
 {
 undelete(msgvec)
        int *msgvec;
 {
@@ -332,7 +337,7 @@ undelete(msgvec)
 /*
  * Interactively dump core on "core"
  */
 /*
  * Interactively dump core on "core"
  */
-
+int
 core()
 {
        int pid;
 core()
 {
        int pid;
@@ -359,6 +364,7 @@ core()
 /*
  * Clobber as many bytes of stack as the user requests.
  */
 /*
  * Clobber as many bytes of stack as the user requests.
  */
+int
 clobber(argv)
        char **argv;
 {
 clobber(argv)
        char **argv;
 {
@@ -375,7 +381,9 @@ clobber(argv)
 /*
  * Clobber the stack.
  */
 /*
  * Clobber the stack.
  */
+void
 clob1(n)
 clob1(n)
+       int n;
 {
        char buf[512];
        register char *cp;
 {
        char buf[512];
        register char *cp;
@@ -391,6 +399,7 @@ clob1(n)
  * Add the given header fields to the retained list.
  * If no arguments, print the current list of retained fields.
  */
  * Add the given header fields to the retained list.
  * If no arguments, print the current list of retained fields.
  */
+int
 retfield(list)
        char *list[];
 {
 retfield(list)
        char *list[];
 {
@@ -402,6 +411,7 @@ retfield(list)
  * Add the given header fields to the ignored list.
  * If no arguments, print the current list of ignored fields.
  */
  * Add the given header fields to the ignored list.
  * If no arguments, print the current list of ignored fields.
  */
+int
 igfield(list)
        char *list[];
 {
 igfield(list)
        char *list[];
 {
@@ -409,6 +419,7 @@ igfield(list)
        return ignore1(list, ignore, "ignored");
 }
 
        return ignore1(list, ignore, "ignored");
 }
 
+int
 saveretfield(list)
        char *list[];
 {
 saveretfield(list)
        char *list[];
 {
@@ -416,6 +427,7 @@ saveretfield(list)
        return ignore1(list, saveignore + 1, "retained");
 }
 
        return ignore1(list, saveignore + 1, "retained");
 }
 
+int
 saveigfield(list)
        char *list[];
 {
 saveigfield(list)
        char *list[];
 {
@@ -423,6 +435,7 @@ saveigfield(list)
        return ignore1(list, saveignore, "ignored");
 }
 
        return ignore1(list, saveignore, "ignored");
 }
 
+int
 ignore1(list, tab, which)
        char *list[];
        struct ignoretab *tab;
 ignore1(list, tab, which)
        char *list[];
        struct ignoretab *tab;
@@ -454,6 +467,7 @@ ignore1(list, tab, which)
 /*
  * Print out all currently retained fields.
  */
 /*
  * Print out all currently retained fields.
  */
+int
 igshow(tab, which)
        struct ignoretab *tab;
        char *which;
 igshow(tab, which)
        struct ignoretab *tab;
        char *which;
@@ -473,7 +487,7 @@ igshow(tab, which)
                for (igp = tab->i_head[h]; igp != 0; igp = igp->i_link)
                        *ap++ = igp->i_field;
        *ap = 0;
                for (igp = tab->i_head[h]; igp != 0; igp = igp->i_link)
                        *ap++ = igp->i_field;
        *ap = 0;
-       qsort((char *) ring, tab->i_count, sizeof (char *), igcomp);
+       qsort(ring, tab->i_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;
@@ -482,9 +496,9 @@ igshow(tab, which)
 /*
  * Compare two names for sorting ignored field list.
  */
 /*
  * Compare two names for sorting ignored field list.
  */
+int
 igcomp(l, r)
 igcomp(l, r)
-       char **l, **r;
+       const void *l, *r;
 {
 {
-
-       return strcmp(*l, *r);
+       return (strcmp(*(char **)l, *(char **)r));
 }
 }