Annotation of 43BSD/games/adventure/okplay.c, revision 1.1

1.1     ! root        1: static char sccsid[] = "       okplay.c        4.1     82/05/11        ";
        !             2: 
        !             3: main(argc, argv)
        !             4: int argc; char *argv[];
        !             5: {
        !             6:        argv[argc] = 0;
        !             7:        okplay();
        !             8:        if (argc == 1)
        !             9:                advmotd();
        !            10:        execv("/usr/games/lib/adventure", argv);
        !            11:        write(2, "No adventure just now\n", 22);
        !            12:        exit(1);
        !            13: }
        !            14: 
        !            15: okplay()
        !            16: {
        !            17:        int tvec[2];
        !            18:        register struct local {
        !            19:                int seconds,minutes,hours,daymo,month,year,daywk,dayyr,dst;
        !            20:        } *local;
        !            21: 
        !            22:        return;
        !            23:        time(tvec);
        !            24:        local = localtime(tvec);
        !            25:        local->month++;
        !            26:        if (local->daywk == 6||local->daywk == 0)
        !            27:                return;
        !            28:        if (local->hours>=9&&local->hours<18)
        !            29:                if (!holiday(local->month, local->daymo))
        !            30:                        notinprime();
        !            31: }
        !            32: 
        !            33: holiday(mo,da)
        !            34:        int mo,da;
        !            35: {
        !            36:        int stbuf[30];
        !            37:        char *np, *op;
        !            38: 
        !            39:        np = "/usr/games/holiday/XXXX";
        !            40:        for(op=np;*op;op++);
        !            41:        *--op=(da%10)|'0';
        !            42:        *--op=(da/10)|'0';
        !            43:        *--op=(mo%10)|'0';
        !            44:        *--op=(mo/10)|'0';
        !            45:        return(stat(np,stbuf) == 0);
        !            46: }
        !            47: char notinm[] "No adventure in prime time (M-F 9am-5pm) except on holidays\n";
        !            48: 
        !            49: notinprime()
        !            50: {
        !            51:        write(2, notinm, sizeof notinm);
        !            52:        exit(1);
        !            53: }
        !            54: 
        !            55: advmotd()
        !            56: {
        !            57:        char ch;
        !            58:        int fd;
        !            59: 
        !            60:        fd = open("/usr/games/lib/advmotd", 0);
        !            61:        if (fd < 0) return;
        !            62:        while(read(fd,&ch,1) ==1) write(1,&ch,1);
        !            63:        close(fd);
        !            64: }

unix.superglobalmegacorp.com

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