document distributed with 4.2BSD
[unix-history] / usr / src / usr.bin / mail / cmd3.c
index 8160da3..2aa78a6 100644 (file)
@@ -1,4 +1,12 @@
-#
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)cmd3.c      5.3 (Berkeley) %G%";
+#endif not lint
 
 #include "rcv.h"
 #include <sys/stat.h>
 
 #include "rcv.h"
 #include <sys/stat.h>
@@ -9,8 +17,6 @@
  * Still more user commands.
  */
 
  * Still more user commands.
  */
 
-static char *SccsId = "@(#)cmd3.c      2.12 %G%";
-
 /*
  * Process a shell escape by saving signals, ignoring signals,
  * and forking a sh -c
 /*
  * Process a shell escape by saving signals, ignoring signals,
  * and forking a sh -c
@@ -37,7 +43,7 @@ shell(str)
                for (t = 2; t < 4; t++)
                        if (sig[t-2] != SIG_IGN)
                                sigsys(t, SIG_DFL);
                for (t = 2; t < 4; t++)
                        if (sig[t-2] != SIG_IGN)
                                sigsys(t, SIG_DFL);
-               execl(Shell, Shell, "-c", cmd, 0);
+               execl(Shell, Shell, "-c", cmd, (char *)0);
                perror(Shell);
                _exit(1);
        }
                perror(Shell);
                _exit(1);
        }
@@ -71,7 +77,7 @@ dosh(str)
                for (t = 2; t < 4; t++)
                        if (sig[t-2] != SIG_IGN)
                                sigsys(t, SIG_DFL);
                for (t = 2; t < 4; t++)
                        if (sig[t-2] != SIG_IGN)
                                sigsys(t, SIG_DFL);
-               execl(Shell, Shell, 0);
+               execl(Shell, Shell, (char *)0);
                perror(Shell);
                _exit(1);
        }
                perror(Shell);
                _exit(1);
        }
@@ -181,12 +187,21 @@ schdir(str)
        return(0);
 }
 
        return(0);
 }
 
+respond(msgvec)
+       int *msgvec;
+{
+       if (value("Replyall") == NOSTR)
+               return (_respond(msgvec));
+       else
+               return (_Respond(msgvec));
+}
+
 /*
  * Reply to a list of messages.  Extract each name from the
  * message header and send them off to mail1()
  */
 
 /*
  * Reply to a list of messages.  Extract each name from the
  * message header and send them off to mail1()
  */
 
-respond(msgvec)
+_respond(msgvec)
        int *msgvec;
 {
        struct message *mp;
        int *msgvec;
 {
        struct message *mp;
@@ -202,10 +217,10 @@ respond(msgvec)
        mp = &message[msgvec[0] - 1];
        dot = mp;
        rcv = NOSTR;
        mp = &message[msgvec[0] - 1];
        dot = mp;
        rcv = NOSTR;
-       cp = nameof(mp, 1);
+       cp = skin(nameof(mp, 1));
        if (cp != NOSTR)
            rcv = cp;
        if (cp != NOSTR)
            rcv = cp;
-       cp = hfield("from", mp);
+       cp = skin(hfield("from", mp));
        if (cp != NOSTR)
            rcv = cp;
        replyto = skin(hfield("reply-to", mp));
        if (cp != NOSTR)
            rcv = cp;
        replyto = skin(hfield("reply-to", mp));
@@ -213,7 +228,7 @@ respond(msgvec)
        if (replyto != NOSTR)
                strcpy(buf, replyto);
        else {
        if (replyto != NOSTR)
                strcpy(buf, replyto);
        else {
-               cp = hfield("to", mp);
+               cp = skin(hfield("to", mp));
                if (cp != NOSTR)
                        strcpy(buf, cp);
        }
                if (cp != NOSTR)
                        strcpy(buf, cp);
        }
@@ -229,10 +244,10 @@ respond(msgvec)
                for (ap = altnames; *ap; ap++)
                        np = delname(np, *ap, icequal);
        head.h_seq = 1;
                for (ap = altnames; *ap; ap++)
                        np = delname(np, *ap, icequal);
        head.h_seq = 1;
-       cp = detract(np, GCOMMA);               /* do it with commas */
+       cp = detract(np, 0);
        if (cp != NOSTR && replyto == NOSTR) {
                strcpy(buf, cp);
        if (cp != NOSTR && replyto == NOSTR) {
                strcpy(buf, cp);
-               strcat(buf, ", ");
+               strcat(buf, " ");
                strcat(buf, rcv);
        }
        else {
                strcat(buf, rcv);
        }
        else {
@@ -314,6 +329,22 @@ preserve(msgvec)
        return(0);
 }
 
        return(0);
 }
 
+/*
+ * Mark all given messages as unread.
+ */
+unread(msgvec)
+       int     msgvec[];
+{
+       register int *ip;
+
+       for (ip = msgvec; *ip != NULL; ip++) {
+               dot = &message[*ip-1];
+               dot->m_flag &= ~(MREAD|MTOUCH);
+               dot->m_flag |= MSTATUS;
+       }
+       return(0);
+}
+
 /*
  * Print the size of each message.
  */
 /*
  * Print the size of each message.
  */
@@ -327,7 +358,7 @@ messize(msgvec)
        for (ip = msgvec; *ip != NULL; ip++) {
                mesg = *ip;
                mp = &message[mesg-1];
        for (ip = msgvec; *ip != NULL; ip++) {
                mesg = *ip;
                mp = &message[mesg-1];
-               printf("%d: %ld\n", mesg, mp->m_size);
+               printf("%d: %d/%ld\n", mesg, mp->m_lines, mp->m_size);
        }
        return(0);
 }
        }
        return(0);
 }
@@ -562,7 +593,7 @@ file(argv)
                perror(cp);
                return(-1);
        }
                perror(cp);
                return(-1);
        }
-       newfileinfo();
+       announce(0);
 }
 
 /*
 }
 
 /*
@@ -656,13 +687,22 @@ echo(argv)
        return(0);
 }
 
        return(0);
 }
 
+Respond(msgvec)
+       int *msgvec;
+{
+       if (value("Replyall") == NOSTR)
+               return (_Respond(msgvec));
+       else
+               return (_respond(msgvec));
+}
+
 /*
  * Reply to a series of messages by simply mailing to the senders
  * and not messing around with the To: and Cc: lists as in normal
  * reply.
  */
 
 /*
  * Reply to a series of messages by simply mailing to the senders
  * and not messing around with the To: and Cc: lists as in normal
  * reply.
  */
 
-Respond(msgvec)
+_Respond(msgvec)
        int msgvec[];
 {
        struct header head;
        int msgvec[];
 {
        struct header head;
@@ -673,10 +713,10 @@ Respond(msgvec)
        for (s = 0, ap = msgvec; *ap != 0; ap++) {
                mp = &message[*ap - 1];
                dot = mp;
        for (s = 0, ap = msgvec; *ap != 0; ap++) {
                mp = &message[*ap - 1];
                dot = mp;
-               if ((cp = hfield("from", mp)) != NOSTR)
+               if ((cp = skin(hfield("from", mp))) != NOSTR)
                    s+= strlen(cp) + 1;
                else
                    s+= strlen(cp) + 1;
                else
-                   s += strlen(nameof(mp, 2)) + 1;
+                   s += strlen(skin(nameof(mp, 2))) + 1;
        }
        if (s == 0)
                return(0);
        }
        if (s == 0)
                return(0);
@@ -684,8 +724,8 @@ Respond(msgvec)
        head.h_to = cp;
        for (ap = msgvec; *ap != 0; ap++) {
                mp = &message[*ap - 1];
        head.h_to = cp;
        for (ap = msgvec; *ap != 0; ap++) {
                mp = &message[*ap - 1];
-               if ((cp2 = hfield("from", mp)) == NOSTR)
-                   cp2 = nameof(mp, 2);
+               if ((cp2 = skin(hfield("from", mp))) == NOSTR)
+                   cp2 = skin(nameof(mp, 2));
                cp = copy(cp2, cp);
                *cp++ = ' ';
        }
                cp = copy(cp2, cp);
                *cp++ = ' ';
        }