date and time created 80/10/10 00:51:33 by bill
authorBill Joy <bill@ucbvax.Berkeley.EDU>
Fri, 10 Oct 1980 16:51:33 +0000 (08:51 -0800)
committerBill Joy <bill@ucbvax.Berkeley.EDU>
Fri, 10 Oct 1980 16:51:33 +0000 (08:51 -0800)
SCCS-vsn: old/prmail/prmail.c 4.1

usr/src/old/prmail/prmail.c [new file with mode: 0644]

diff --git a/usr/src/old/prmail/prmail.c b/usr/src/old/prmail/prmail.c
new file mode 100644 (file)
index 0000000..47715d9
--- /dev/null
@@ -0,0 +1,61 @@
+static char *sccsid = "@(#)prmail.c    4.1 (Berkeley) %G%";
+
+#include <pwd.h>
+/*
+ * prmail
+ */
+struct passwd *getpwuid();
+char   *getenv();
+
+main(argc, argv)
+       int argc;
+       char **argv;
+{
+       register struct passwd *pp;
+
+       --argc, ++argv;
+       if (chdir("/usr/spool/mail") < 0) {
+               perror("/usr/spool/mail");
+               exit(1);
+       }
+       if (argc == 0) {
+               char *user = getenv("USER");
+               if (user == 0) {
+                       pp = getpwuid(getuid());
+                       if (pp == 0) {
+                               printf("Who are you?\n");
+                               exit(1);
+                       }
+                       user = pp->pw_name;
+               }
+               prmail(user, 0);
+       } else
+               while (--argc >= 0)
+                       prmail(*argv++, 1);
+       exit(0);
+}
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+prmail(user, other)
+       char *user;
+{
+       struct stat stb;
+       char cmdbuf[256];
+
+       if (stat(user, &stb) < 0) {
+               printf("No mail for %s.\n", user);
+               return;
+       }
+       if (access(user, "4") < 0) {
+               printf("Mailbox for %s unreadable\n", user);
+               return;
+       }
+       if (other)
+               printf(">>> %s <<<\n", user);
+       sprintf(cmdbuf, "more %s", user);
+       system(cmdbuf);
+       if (other)
+               printf("-----\n\n");
+}