Annotation of 40BSD/cmd/prmail.c, revision 1.1

1.1     ! root        1: static char *sccsid = "@(#)prmail.c    4.1 (Berkeley) 10/9/80";
        !             2: 
        !             3: #include <pwd.h>
        !             4: /*
        !             5:  * prmail
        !             6:  */
        !             7: struct passwd *getpwuid();
        !             8: char   *getenv();
        !             9: 
        !            10: main(argc, argv)
        !            11:        int argc;
        !            12:        char **argv;
        !            13: {
        !            14:        register struct passwd *pp;
        !            15: 
        !            16:        --argc, ++argv;
        !            17:        if (chdir("/usr/spool/mail") < 0) {
        !            18:                perror("/usr/spool/mail");
        !            19:                exit(1);
        !            20:        }
        !            21:        if (argc == 0) {
        !            22:                char *user = getenv("USER");
        !            23:                if (user == 0) {
        !            24:                        pp = getpwuid(getuid());
        !            25:                        if (pp == 0) {
        !            26:                                printf("Who are you?\n");
        !            27:                                exit(1);
        !            28:                        }
        !            29:                        user = pp->pw_name;
        !            30:                }
        !            31:                prmail(user, 0);
        !            32:        } else
        !            33:                while (--argc >= 0)
        !            34:                        prmail(*argv++, 1);
        !            35:        exit(0);
        !            36: }
        !            37: 
        !            38: #include <sys/types.h>
        !            39: #include <sys/stat.h>
        !            40: 
        !            41: prmail(user, other)
        !            42:        char *user;
        !            43: {
        !            44:        struct stat stb;
        !            45:        char cmdbuf[256];
        !            46: 
        !            47:        if (stat(user, &stb) < 0) {
        !            48:                printf("No mail for %s.\n", user);
        !            49:                return;
        !            50:        }
        !            51:        if (access(user, "4") < 0) {
        !            52:                printf("Mailbox for %s unreadable\n", user);
        !            53:                return;
        !            54:        }
        !            55:        if (other)
        !            56:                printf(">>> %s <<<\n", user);
        !            57:        sprintf(cmdbuf, "more %s", user);
        !            58:        system(cmdbuf);
        !            59:        if (other)
        !            60:                printf("-----\n\n");
        !            61: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.