/*
 * config.h - header for configuring game system
 */

/*
 * include any headers here that might be useful
 */

#include	<ctype.h>
#include	<fcntl.h>
#include	<unistd.h>
#include	<malloc.h>

/*
 * CREAT(filename) will make the file anew
 */

#define	CREAT(filename)	open((filename), O_RDWR | O_CREAT | O_TRUNC, 0644)

/*
 * OPEN(filename) will open the file for read
 */

#define	OPEN(filename)	(open((filename), O_RDONLY))

/*
 * SEEK(fd, pos) will seek to pos * 128 within the file
 */

#define	SEEK(fd, pos)	lseek((fd), (pos) * 128, SEEK_SET)

/*
 * RWBSIZ is the number of bytes read or written by a read(fg, buff, 1)
 */

#define	RWBSIZ	1

/*
 * #define this to be whatever int type has 16 bits
 */

#define INT	short

/*
 * TMPFMT should be a printf string that creates a temp filename from a string
 */

#define TMPFMT	"%s.$$$"

/*
 * fopen modes
 */

#ifdef BSD
#define	RTEXT	"r"
#define	RBIN	"r"
#define	WTEXT	"w"
#define	WBIN	"w"
#else
#define	RTEXT	"r"
#define	RBIN	"rb"
#define	WTEXT	"w"
#define	WBIN	"wb"
#endif

/*
 * initrnd() should initialise the RNG
 */

#ifdef BSD
#define	initrnd() (srandom(time(0) + getpid()))
#else
#define	initrnd() (srand48(time(0) + getpid()))
#endif

/*
 * prompt(s) should print string s as a prompt
 */

#define	prompt(s) (printf(s), fflush(stdout))

/*
 * rnd(n) return a random number from 0 -- (n - 1)
 */

#ifdef BSD
#define rnd(n) (random() % n)
#else
#define rnd(n) (lrand48() % n)
#endif

/*
 * alloc(n) should allocate n bytes
 */

#define	alloc(n)	(malloc((n)))

/*
 * rename(old, new) - change old filename into new
 */

rename(old, new)
char *old;
char *new;
 {
    link(old, new);
    unlink(old);
 }
