Annotation of 43BSDReno/old/prmail/prmail.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #ifndef lint
        !             8: char copyright[] =
        !             9: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
        !            10:  All rights reserved.\n";
        !            11: #endif not lint
        !            12: 
        !            13: #ifndef lint
        !            14: static char sccsid[] = "@(#)prmail.c   5.1 (Berkeley) 5/31/85";
        !            15: #endif not lint
        !            16: 
        !            17: #include <pwd.h>
        !            18: /*
        !            19:  * prmail
        !            20:  */
        !            21: struct passwd *getpwuid();
        !            22: char   *getenv();
        !            23: 
        !            24: main(argc, argv)
        !            25:        int argc;
        !            26:        char **argv;
        !            27: {
        !            28:        register struct passwd *pp;
        !            29: 
        !            30:        --argc, ++argv;
        !            31:        if (chdir("/usr/spool/mail") < 0) {
        !            32:                perror("/usr/spool/mail");
        !            33:                exit(1);
        !            34:        }
        !            35:        if (argc == 0) {
        !            36:                char *user = getenv("USER");
        !            37:                if (user == 0) {
        !            38:                        pp = getpwuid(getuid());
        !            39:                        if (pp == 0) {
        !            40:                                printf("Who are you?\n");
        !            41:                                exit(1);
        !            42:                        }
        !            43:                        user = pp->pw_name;
        !            44:                }
        !            45:                prmail(user, 0);
        !            46:        } else
        !            47:                while (--argc >= 0)
        !            48:                        prmail(*argv++, 1);
        !            49:        exit(0);
        !            50: }
        !            51: 
        !            52: #include <sys/types.h>
        !            53: #include <sys/stat.h>
        !            54: 
        !            55: prmail(user, other)
        !            56:        char *user;
        !            57: {
        !            58:        struct stat stb;
        !            59:        char cmdbuf[256];
        !            60: 
        !            61:        if (stat(user, &stb) < 0) {
        !            62:                printf("No mail for %s.\n", user);
        !            63:                return;
        !            64:        }
        !            65:        if (access(user, 4) < 0) {
        !            66:                printf("Mailbox for %s unreadable\n", user);
        !            67:                return;
        !            68:        }
        !            69:        if (other)
        !            70:                printf(">>> %s <<<\n", user);
        !            71:        sprintf(cmdbuf, "more %s", user);
        !            72:        system(cmdbuf);
        !            73:        if (other)
        !            74:                printf("-----\n\n");
        !            75: }

unix.superglobalmegacorp.com

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