util.h revision 1.1 1 /* $Header: /tank/opengrok/rsync2/NetBSD/src/games/warp/util.h,v 1.1 2020/11/09 23:37:05 kamil Exp $ */
2
3 /* $Log: util.h,v $
4 /* Revision 1.1 2020/11/09 23:37:05 kamil
5 /* Add Warp Kit, Version 7.0 by Larry Wall
6 /*
7 /* Warp is a real-time space war game that doesn't get boring very quickly.
8 /* Read warp.doc and the manual page for more information.
9 /*
10 /* games/warp originally distributed with 4.3BSD-Reno, is back to the BSD
11 /* world via NetBSD. Its remnants were still mentioned in games/Makefile.
12 /*
13 /* Larry Wall, the original author and the copyright holder, generously
14 /* donated the game and copyright to The NetBSD Foundation, Inc.
15 /*
16 /* Import the game sources as-is from 4.3BSD-Reno, with the cession
17 /* of the copyright and license to BSD-2-clause NetBSD-style.
18 /*
19 /* Signed-off-by: Larry Wall <larry (at) wall.org>
20 /* Signed-off-by: Kamil Rytarowski <kamil (at) netbsd.org>
21 /*
22 * Revision 7.0 86/10/08 15:14:37 lwall
23 * Split into separate files. Added amoebas and pirates.
24 *
25 */
26
27 #if RANDBITS < 15 || defined(lint)
28 #define rand_mod(m) getpid()
29 #define RANDRAND 0.0
30 #define HALFRAND 0
31 #define myrand() getpid()
32 #else
33 #if RANDBITS == 15 /* 15 bits of rand()? */
34 #define RANDRAND 268435456.0 /* that's 2**28 */
35 #define HALFRAND 0x4000 /* that's 2**14 */
36 int rand();
37 #define myrand() (rand()&32767)
38 #define rand_mod(m) ((int)((double)myrand() / 32768.0 * ((double)(m))))
39 /* pick number in 0..m-1 */
40
41 #else
42
43 #if RANDBITS < 31 /* 16 bits of rand()? */
44 #define RANDRAND 1073741824.0 /* that's 2**30 */
45 #define HALFRAND 0x8000 /* that's 2**15 */
46 unsigned rand();
47 #define myrand() (rand()&65535)
48 #define rand_mod(m) ((int)((double)myrand() / 65536.0 * ((double)(m))))
49 /* pick number in 0..m-1 */
50
51 #else /* assume 31 bits */
52 #define RANDRAND 1152921504606846976.0 /* that's 2**60 */
53 #define HALFRAND 0x40000000 /* that's 2**30 */
54 long rand();
55 #define myrand() rand()
56 #define rand_mod(m) ((myrand() / 37) % (m)) /* pick number in 0..m-1 */
57 /*
58 * The reason for the /37 above is that our random number generator yields
59 * successive evens and odds, for some reason. This makes strange star maps.
60 */
61 #endif
62 #endif
63 #endif
64
65
66 /* we get fractions of seconds from calling ftime on timebuf */
67
68 EXT struct timeb timebuf;
69 #define roundsleep(x) (ftime(&timebuf),sleep(timebuf.millitm > 500?x+1:x))
70
71 void movc3();
72 void no_can_do();
73 int exdis();
74
75 EXT bool waiting INIT(FALSE); /* are we waiting for subprocess (in doshell)? */
76
77 #ifdef NOTDEF
78 EXT int len_last_line_got INIT(0);
79 /* strlen of some_buf after */
80 /* some_buf = get_a_line(bufptr,buffersize,fp) */
81 #endif
82
83 #ifdef NOTDEF
84 /* is the string for makedir a directory name or a filename? */
85
86 #define MD_DIR 0
87 #define MD_FILE 1
88 #endif
89
90 void util_init();
91 char *safemalloc();
92 char *safecpy();
93 char *cpytill();
94 char *instr();
95 #ifdef SETUIDGID
96 int eaccess();
97 #endif
98 char *getwd();
99 void cat();
100 void prexit();
101 char *savestr();
102 char *getval();
103