Annotation of 43BSDReno/games/dungeon/rtim.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Interface routines for dungeon.
        !             3:  * These routines are for functions expected by the game
        !             4:  * that are not available in the Unix/f77 library.
        !             5:  */
        !             6: 
        !             7: #ifdef SYSV
        !             8: #include <stdio.h>
        !             9: #endif
        !            10: 
        !            11: #include <sys/types.h>
        !            12: 
        !            13: #ifdef SYSV
        !            14: #include <time.h>
        !            15: #else
        !            16: #include <sys/timeb.h>
        !            17: #include <sys/time.h>
        !            18: #endif
        !            19: 
        !            20: /* routine to get time in hours minutes and seconds */
        !            21: 
        !            22: long time();
        !            23: struct tm *localtime();
        !            24: struct tm *tmptr;
        !            25: long timebuf;
        !            26: 
        !            27: itime_(hrptr,minptr,secptr)
        !            28: 
        !            29: int *hrptr,*minptr,*secptr;
        !            30: {
        !            31: 
        !            32:        time(&timebuf);
        !            33:        tmptr = localtime(&timebuf);
        !            34:        
        !            35:        *hrptr  = tmptr->tm_hour;
        !            36:        *minptr = tmptr->tm_min;
        !            37:        *secptr = tmptr->tm_sec;
        !            38: 
        !            39:        return;
        !            40: }
        !            41: 
        !            42: #ifdef SYSV
        !            43: /* idate - return day (1-31), month (1-12) and year (AD) */
        !            44: /*     by Dave Newkirk, ihnp4!ihlpm!dcn */
        !            45: 
        !            46: idate_( date )
        !            47: long date[];
        !            48: {
        !            49:        struct tm *t, *localtime();
        !            50:        long time(), *tloc, loc;
        !            51: 
        !            52:        tloc = &loc;                    /* get pointer to time in seconds */
        !            53:        time(tloc);
        !            54:        t = localtime(tloc);            /* get time structure filled in */
        !            55:        date[0] = t->tm_mday;
        !            56:        date[1] = t->tm_mon + 1;
        !            57:        date[2] = t->tm_year + 1900;
        !            58: 
        !            59: } /* end idate */
        !            60: #endif
        !            61: 
        !            62: /* random number initializer */
        !            63: inirnd_(seedptr)
        !            64: 
        !            65: int *seedptr;
        !            66: {
        !            67: int seed;
        !            68: 
        !            69:        seed = *seedptr;
        !            70:        srand(seed);
        !            71:        return;
        !            72: }
        !            73: 
        !            74: /*  random number generator */
        !            75: rnd_(maxval)
        !            76: 
        !            77: int *maxval;
        !            78: {
        !            79: /* note: returned random number ranges from 0 to maxval */
        !            80: 
        !            81: int rndval;
        !            82: 
        !            83:        rndval = rand();
        !            84: 
        !            85:        rndval = rndval % *maxval;
        !            86: 
        !            87:        return(rndval);
        !            88: }
        !            89: 
        !            90: #ifdef SYSV
        !            91: /* thanks to Dave Newkirk, ihnp4!ihlpm!dcn for the following routines */
        !            92: 
        !            93: /* getuid - fortran callable getuid */
        !            94: 
        !            95: int
        !            96: getuid_()
        !            97: {
        !            98:        return (int)getuid();
        !            99: }
        !           100: 
        !           101: /* unbuf - make output completely unbuffered */
        !           102: 
        !           103: unbuf_()
        !           104: {
        !           105:        void setbuf();
        !           106: 
        !           107:        setbuf(stdout, NULL);
        !           108: }
        !           109: #endif

unix.superglobalmegacorp.com

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