2020-11-10 03:02:11 +03:00
|
|
|
/* Header: util.h,v 7.0 86/10/08 15:14:37 lwall Exp */
|
2020-11-10 02:37:05 +03:00
|
|
|
|
2020-11-10 03:02:11 +03:00
|
|
|
/* Log: util.h,v
|
2020-11-10 02:37:05 +03:00
|
|
|
* Revision 7.0 86/10/08 15:14:37 lwall
|
|
|
|
* Split into separate files. Added amoebas and pirates.
|
2021-05-02 15:50:43 +03:00
|
|
|
*
|
2020-11-10 02:37:05 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define RANDRAND 1152921504606846976.0 /* that's 2**60 */
|
|
|
|
#define HALFRAND 0x40000000 /* that's 2**30 */
|
2020-11-11 22:55:33 +03:00
|
|
|
#define myrand() (int)random()
|
2020-11-10 02:37:05 +03:00
|
|
|
#define rand_mod(m) ((myrand() / 37) % (m)) /* pick number in 0..m-1 */
|
|
|
|
/*
|
|
|
|
* The reason for the /37 above is that our random number generator yields
|
|
|
|
* successive evens and odds, for some reason. This makes strange star maps.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* we get fractions of seconds from calling ftime on timebuf */
|
|
|
|
|
2020-11-13 01:23:16 +03:00
|
|
|
extern struct timespec timebuf;
|
2020-11-21 12:24:02 +03:00
|
|
|
#define roundsleep(x) (clock_gettime(CLOCK_REALTIME, &timebuf),sleep(timebuf.tv_nsec > (500 * 1000 * 1000) ?x+1:x))
|
2020-11-10 02:37:05 +03:00
|
|
|
|
2020-11-10 11:49:08 +03:00
|
|
|
#define waiting 0
|
2020-11-10 02:37:05 +03:00
|
|
|
|
|
|
|
#ifdef NOTDEF
|
|
|
|
EXT int len_last_line_got INIT(0);
|
|
|
|
/* strlen of some_buf after */
|
|
|
|
/* some_buf = get_a_line(bufptr,buffersize,fp) */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NOTDEF
|
|
|
|
/* is the string for makedir a directory name or a filename? */
|
|
|
|
|
|
|
|
#define MD_DIR 0
|
|
|
|
#define MD_FILE 1
|
|
|
|
#endif
|
|
|
|
|
2020-11-11 01:42:19 +03:00
|
|
|
void util_init(void);
|
|
|
|
void movc3(int, char *, char *);
|
2020-11-13 01:23:16 +03:00
|
|
|
__dead void no_can_do(const char *);
|
2020-11-11 01:42:19 +03:00
|
|
|
int exdis(int);
|
|
|
|
void *safemalloc(size_t size);
|
|
|
|
char *safecpy(char *, const char *, size_t);
|
|
|
|
char *cpytill(char *, const char *, int);
|
|
|
|
char *instr(const char *, const char *);
|
2020-11-10 02:37:05 +03:00
|
|
|
#ifdef SETUIDGID
|
2020-11-11 01:42:19 +03:00
|
|
|
int eaccess(const char *, mode_t);
|
2020-11-10 02:37:05 +03:00
|
|
|
#endif
|
2020-11-13 01:23:16 +03:00
|
|
|
__dead void prexit(const char *);
|
2020-11-11 01:42:19 +03:00
|
|
|
char *savestr(const char *);
|
|
|
|
char *getval(const char *, const char *);
|