From: Bill Joy Date: Fri, 10 Oct 1980 16:51:33 +0000 (-0800) Subject: date and time created 80/10/10 00:51:33 by bill X-Git-Tag: BSD-4^3~360 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/750a6622d771b3c540c88767bb9899610765c221 date and time created 80/10/10 00:51:33 by bill SCCS-vsn: old/prmail/prmail.c 4.1 --- diff --git a/usr/src/old/prmail/prmail.c b/usr/src/old/prmail/prmail.c new file mode 100644 index 0000000000..47715d9736 --- /dev/null +++ b/usr/src/old/prmail/prmail.c @@ -0,0 +1,61 @@ +static char *sccsid = "@(#)prmail.c 4.1 (Berkeley) %G%"; + +#include +/* + * 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 +#include + +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"); +}