Annotation of 3BSD/cmd/ucbmail/c.local.c, revision 1.1

1.1     ! root        1: #
        !             2: 
        !             3: /*
        !             4:  * Mail -- a mail program
        !             5:  *
        !             6:  * EECS Cory 11/70 Version 6.9.
        !             7:  *
        !             8:  * Local routines that are installation dependent.
        !             9:  * All fiddlers please note:  if you make careful note of
        !            10:  * what you change here, I will incorporate your changes and
        !            11:  * you won't have to remake them each release.
        !            12:  */
        !            13: 
        !            14: #include "rcv.h"
        !            15: 
        !            16: /*
        !            17:  * Locate the user's mailbox file (ie, the place where new, unread
        !            18:  * mail is queued).  At Cory, it is in /usr/mail/name.
        !            19:  */
        !            20: 
        !            21: findmail()
        !            22: {
        !            23:        register char *cp;
        !            24: 
        !            25:        cp = copy("/usr/mail/", mailname);
        !            26:        copy(myname, cp);
        !            27: }
        !            28: 
        !            29: /*
        !            30:  * Get rid of the queued mail.
        !            31:  * This is essential "mail -n > /dev/null &"
        !            32:  */
        !            33: 
        !            34: demail()
        !            35: {
        !            36:        register int p;
        !            37: 
        !            38:        if (uid == 0) {
        !            39:                remove(mailname);
        !            40:                return;
        !            41:        }
        !            42:        if ((p = fork()) != 0)
        !            43:                return;
        !            44:        for (p = 0; p < 15; p++)
        !            45:                 close(p);
        !            46:        open("/dev/null", 2);
        !            47:        dup(0);
        !            48:        dup(0);
        !            49:        for (p = SIGHUP; p <= SIGQUIT; p++)
        !            50:                signal(p, SIG_IGN);
        !            51:        execl(MAIL, "mail", "-n", 0);
        !            52:        perror(MAIL);
        !            53:        exit(1);
        !            54: }
        !            55: 
        !            56: /*
        !            57:  * Get the value of an environment variable.
        !            58:  */
        !            59: 
        !            60: char *
        !            61: getenv(name)
        !            62:        char name[];
        !            63: {
        !            64:        register int t;
        !            65:        static char val[30];
        !            66: 
        !            67:        t = ttyn(2);
        !            68:        hget(t);
        !            69:        if (equal(name, "SHELL"))
        !            70:                return("/bin/csh");
        !            71:        if (!equal(name, "HOME"))
        !            72:                return(NOSTR);
        !            73:        copy(hgethome(), val);
        !            74:        return(val);
        !            75: }
        !            76: 
        !            77: /*
        !            78:  * Mail file lock / unlock.
        !            79:  * Insignificant in version 6.
        !            80:  */
        !            81: 
        !            82: lock(name)
        !            83:        char *name;
        !            84: {
        !            85: 
        !            86:        return(0);
        !            87: }
        !            88: 
        !            89: unlock()
        !            90: {
        !            91: 
        !            92:        return(0);
        !            93: }
        !            94: 
        !            95: /*
        !            96:  * Discover user login name.
        !            97:  */
        !            98: 
        !            99: username(uid, namebuf)
        !           100:        char namebuf[];
        !           101: {
        !           102: 
        !           103:        return(getname(uid, namebuf));
        !           104: }
        !           105: 
        !           106: /*
        !           107:  * Unix routine to do an "fopen" on file descriptor
        !           108:  * The mode has to be repeated because you can't query its
        !           109:  * status
        !           110:  */
        !           111: 
        !           112: FILE *
        !           113: fdopen(fd, mode)
        !           114: register char *mode;
        !           115: {
        !           116:        extern int errno;
        !           117:        register FILE *iop;
        !           118:        extern FILE *_lastbuf;
        !           119: 
        !           120:        for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++)
        !           121:                if (iop >= _lastbuf)
        !           122:                        return(NULL);
        !           123:        iop->_cnt = 0;
        !           124:        iop->_file = fd;
        !           125:        if (*mode != 'r') {
        !           126:                iop->_flag |= _IOWRT;
        !           127:                if (*mode == 'a')
        !           128:                        lseek(fd, 0L, 2);
        !           129:        } else
        !           130:                iop->_flag |= _IOREAD;
        !           131:        return(iop);
        !           132: }

unix.superglobalmegacorp.com

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