Added ``#include <whoami.h>'' if pdp11 is defined.
[unix-history] / usr / src / usr.bin / mail / cmd1.c
index e54e433..33c0c6a 100644 (file)
@@ -8,7 +8,7 @@
  * User commands.
  */
 
  * User commands.
  */
 
-static char *SccsId = "@(#)cmd1.c      2.4 %G%";
+static char *SccsId = "@(#)cmd1.c      2.8 %G%";
 
 /*
  * Print the current active headings.
 
 /*
  * Print the current active headings.
@@ -231,12 +231,31 @@ pcmdlist()
 }
 
 /*
 }
 
 /*
- * Type out the messages requested.
+ * Type out messages, honor ignored fields.
  */
  */
+type(msgvec)
+       int *msgvec;
+{
+
+       return(type1(msgvec, 1));
+}
 
 
+/*
+ * Type out messages, even printing ignored fields.
+ */
+Type(msgvec)
+       int *msgvec;
+{
+
+       return(type1(msgvec, 0));
+}
+
+/*
+ * Type out the messages requested.
+ */
 jmp_buf        pipestop;
 
 jmp_buf        pipestop;
 
-type(msgvec)
+type1(msgvec, doign)
        int *msgvec;
 {
        register *ip;
        int *msgvec;
 {
        register *ip;
@@ -276,7 +295,7 @@ type(msgvec)
                touch(mesg);
                mp = &message[mesg-1];
                dot = mp;
                touch(mesg);
                mp = &message[mesg-1];
                dot = mp;
-               print(mp, obuf);
+               print(mp, obuf, doign);
        }
        if (obuf != stdout) {
                pipef = NULL;
        }
        if (obuf != stdout) {
                pipef = NULL;
@@ -293,8 +312,11 @@ type(msgvec)
 
 brokpipe()
 {
 
 brokpipe()
 {
-
+# ifdef VMUNIX
        sigrelse(SIGPIPE);
        sigrelse(SIGPIPE);
+# else
+       signal(SIGPIPE, brokpipe);
+# endif
        longjmp(pipestop, 1);
 }
 
        longjmp(pipestop, 1);
 }
 
@@ -302,7 +324,7 @@ brokpipe()
  * Print the indicated message on standard output.
  */
 
  * Print the indicated message on standard output.
  */
 
-print(mp, obuf)
+print(mp, obuf, doign)
        register struct message *mp;
        FILE *obuf;
 {
        register struct message *mp;
        FILE *obuf;
 {
@@ -310,7 +332,7 @@ print(mp, obuf)
        if (value("quiet") == NOSTR)
                fprintf(obuf, "Message %2d:\n", mp - &message[0] + 1);
        touch(mp - &message[0] + 1);
        if (value("quiet") == NOSTR)
                fprintf(obuf, "Message %2d:\n", mp - &message[0] + 1);
        touch(mp - &message[0] + 1);
-       send(mp, obuf);
+       send(mp, obuf, doign);
 }
 
 /*
 }
 
 /*
@@ -398,27 +420,18 @@ mboxit(msgvec)
  */
 folders()
 {
  */
 folders()
 {
-       char *maildir, *shell;
        char dirname[BUFSIZ], cmd[BUFSIZ];
        int pid, s, e;
 
        char dirname[BUFSIZ], cmd[BUFSIZ];
        int pid, s, e;
 
-       if ((maildir = value("maildir")) == NOSTR) {
-               printf("No value set for \"maildir\"\n");
+       if (getfold(dirname) < 0) {
+               printf("No value set for \"folder\"\n");
                return(-1);
        }
                return(-1);
        }
-       if (*maildir != '/')
-               sprintf(dirname, "%s/%s", homedir, maildir);
-       else
-               strcpy(dirname, maildir);
-       sprintf(cmd, "ls %s", dirname);
-       shell = value("SHELL");
-       if (shell == 0)
-               shell = SHELL;
        switch ((pid = fork())) {
        case 0:
        switch ((pid = fork())) {
        case 0:
-               execl(shell, "sh", "-c", cmd, 0);
+               sigchild();
+               execlp("ls", "ls", dirname, 0);
                clrbuf(stdout);
                clrbuf(stdout);
-               perror(shell);
                exit(1);
 
        case -1:
                exit(1);
 
        case -1: