]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/util.h
cgram: allow providing an input file instead of the random fortune
[bsdgames-darwin.git] / warp / util.h
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 #include <time.h>
10 #define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
11
12 #define RANDRAND 1152921504606846976.0 /* that's 2**60 */
13 #define HALFRAND 0x40000000 /* that's 2**30 */
14 #define myrand() (int)random()
15 #define rand_mod(m) ((myrand() / 37) % (m)) /* pick number in 0..m-1 */
16 /*
17 * The reason for the /37 above is that our random number generator yields
18 * successive evens and odds, for some reason. This makes strange star maps.
19 */
20
21 /* we get fractions of seconds from calling ftime on timebuf */
22
23 extern struct timespec timebuf;
24 #define roundsleep(x) (clock_gettime(CLOCK_REALTIME, &timebuf),sleep(timebuf.tv_nsec > (500 * 1000 * 1000) ?x+1:x))
25
26 #define waiting 0
27
28 #ifdef NOTDEF
29 EXT int len_last_line_got INIT(0);
30 /* strlen of some_buf after */
31 /* some_buf = get_a_line(bufptr,buffersize,fp) */
32 #endif
33
34 #ifdef NOTDEF
35 /* is the string for makedir a directory name or a filename? */
36
37 #define MD_DIR 0
38 #define MD_FILE 1
39 #endif
40
41 void util_init(void);
42 void movc3(int, char *, char *);
43 __dead void no_can_do(const char *);
44 int exdis(int);
45 void *safemalloc(size_t size);
46 char *safecpy(char *, const char *, size_t);
47 char *cpytill(char *, const char *, int);
48 char *instr(const char *, const char *);
49 #ifdef SETUIDGID
50 int eaccess(const char *, mode_t);
51 #endif
52 __dead void prexit(const char *);
53 char *savestr(const char *);
54 char *getval(const char *, const char *);