xref: /netbsd-src/games/warp/util.h (revision 1182a44c59cae4d586117d55eca24b4b8b173211)
1 /* Header: util.h,v 7.0 86/10/08 15:14:37 lwall Exp */
2 
3 /* Log:	util.h,v
4  * Revision 7.0  86/10/08  15:14:37  lwall
5  * Split into separate files.  Added amoebas and pirates.
6  *
7  */
8 
9 #define RANDRAND 1152921504606846976.0 /* that's 2**60 */
10 #define HALFRAND 0x40000000 /* that's 2**30 */
11 #define myrand() (int)random()
12 #define rand_mod(m) ((myrand() / 37) % (m)) /* pick number in 0..m-1 */
13 /*
14  * The reason for the /37 above is that our random number generator yields
15  * successive evens and odds, for some reason.  This makes strange star maps.
16  */
17 
18     /* we get fractions of seconds from calling ftime on timebuf */
19 
20 extern struct timespec timebuf;
21 #define roundsleep(x) (clock_gettime(CLOCK_REALTIME, &timebuf),sleep(timebuf.tv_nsec > (500 * 1000 * 1000) ?x+1:x))
22 
23 #define waiting 0
24 
25 #ifdef NOTDEF
26 EXT int len_last_line_got INIT(0);
27 			/* strlen of some_buf after */
28 			/*  some_buf = get_a_line(bufptr,buffersize,fp) */
29 #endif
30 
31 #ifdef NOTDEF
32 /* is the string for makedir a directory name or a filename? */
33 
34 #define MD_DIR 0
35 #define MD_FILE 1
36 #endif
37 
38 void util_init(void);
39 void movc3(int, char *, char *);
40 __dead void no_can_do(const char *);
41 int exdis(int);
42 void *safemalloc(size_t size);
43 char *safecpy(char *, const char *, size_t);
44 char *cpytill(char *, const char *, int);
45 char *instr(const char *, const char *);
46 #ifdef SETUIDGID
47 int eaccess(const char *, mode_t);
48 #endif
49 __dead void prexit(const char *);
50 char *savestr(const char *);
51 char *getval(const char *, const char *);
52