cleanups, add manual page
[unix-history] / usr / src / usr.bin / mail / quit.c
index ca9033f..09044f0 100644 (file)
@@ -3,16 +3,21 @@
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at 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'' without express or implied warranty.
+ * 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.
  */
 
  */
 
-#ifdef notdef
-static char sccsid[] = "@(#)quit.c     5.6 (Berkeley) %G%";
-#endif /* notdef */
+#ifndef lint
+static char sccsid[] = "@(#)quit.c     5.10 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "rcv.h"
 #include <sys/stat.h>
 
 #include "rcv.h"
 #include <sys/stat.h>
@@ -38,7 +43,7 @@ quit()
        register int c;
        extern char tempQuit[], tempResid[];
        struct stat minfo;
        register int c;
        extern char tempQuit[], tempResid[];
        struct stat minfo;
-       char *id;
+       char *mbox;
 
        /*
         * If we are read only, we can't do anything,
 
        /*
         * If we are read only, we can't do anything,
@@ -121,18 +126,17 @@ quit()
                if (mp->m_flag & MODIFY)
                        modify++;
                if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
                if (mp->m_flag & MODIFY)
                        modify++;
                if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
-                       id = hfield("article-id", mp);
-                       if (id != NOSTR)
+                       char *id;
+
+                       if ((id = hfield("article-id", mp)) != NOSTR)
                                fprintf(readstat, "%s\n", id);
                }
        }
        if (Tflag != NOSTR)
                fclose(readstat);
        if (p == msgCount && !modify && !anystat) {
                                fprintf(readstat, "%s\n", id);
                }
        }
        if (Tflag != NOSTR)
                fclose(readstat);
        if (p == msgCount && !modify && !anystat) {
-               if (p == 1)
-                       printf("Held 1 message in %s\n", mailname);
-               else
-                       printf("Held %2d messages in %s\n", p, mailname);
+               printf("Held %d message%s in %s\n",
+                       p, p == 1 ? "" : "s", mailname);
                fclose(fbuf);
                return;
        }
                fclose(fbuf);
                return;
        }
@@ -152,6 +156,7 @@ quit()
         * just copy saveable entries at the end.
         */
 
         * just copy saveable entries at the end.
         */
 
+       mbox = expand("&");
        mcount = c;
        if (value("append") == NOSTR) {
                if ((obuf = fopen(tempQuit, "w")) == NULL) {
        mcount = c;
        if (value("append") == NOSTR) {
                if ((obuf = fopen(tempQuit, "w")) == NULL) {
@@ -198,7 +203,7 @@ quit()
        }
        for (mp = &message[0]; mp < &message[msgCount]; mp++)
                if (mp->m_flag & MBOX)
        }
        for (mp = &message[0]; mp < &message[msgCount]; mp++)
                if (mp->m_flag & MBOX)
-                       if (send(mp, obuf, saveignore) < 0) {
+                       if (send(mp, obuf, saveignore, NOSTR) < 0) {
                                perror(mbox);
                                fclose(ibuf);
                                fclose(obuf);
                                perror(mbox);
                                fclose(ibuf);
                                fclose(obuf);
@@ -303,7 +308,7 @@ writeback(res)
        for (mp = &message[0]; mp < &message[msgCount]; mp++)
                if ((mp->m_flag&MPRESERVE)||(mp->m_flag&MTOUCH)==0) {
                        p++;
        for (mp = &message[0]; mp < &message[msgCount]; mp++)
                if ((mp->m_flag&MPRESERVE)||(mp->m_flag&MTOUCH)==0) {
                        p++;
-                       if (send(mp, obuf, 0) < 0) {
+                       if (send(mp, obuf, (struct ignoretab *)0, NOSTR) < 0) {
                                perror(mailname);
                                fclose(obuf);
                                return(-1);
                                perror(mailname);
                                fclose(obuf);
                                return(-1);