H-basic.h

/* * File: h-basic.h  * * The most basic "include" file. */ /* * Include autoconf autodetections, otherwise try to autodetect ourselves */ /* * Extract the "RISCOS" flag from the compiler */ /* * Extract the "WINDOWS" flag from the compiler */     defined(__WIN32__) || defined(WIN32) || \ defined(__WINNT__) || defined(__NT__) /* * Using C99, assume we have stdint and stdbool */ /* * Everyone except RISC OS has fcntl.h  */ /* * OPTION: set "SET_UID" if the machine is a "multi-user" wmachine. * * This option is used to verify the use of "uids" and "gids" for * various "Unix" calls, and of "pids" for getting a random seed, * and of the "umask" call for various reasons, and to guess if * the "kill" function is available, and for permission to use * functions to extract user names and expand "tildes" in filenames. * It is also used for "locking" and "unlocking" the score file. * Basically, SET_UID should *only* be set for "Unix" machines. */    !defined(RISCOS) && !defined(GAMEBOY) /* Without autoconf, turn on some things */ /* * Every system seems to use its own symbol as a path separator. * * Default to the standard Unix slash, but attempt to change this * for various other systems. Note that any system that uses the * "period" as a separator (i.e. RISCOS) will have to pretend that * it uses the slash, and do its own mapping of period <-> slash. * * It is most definitely wrong to have such things here. Platform-specific * code should handle shifting Angband filenames to platform ones. XXX */ /* * Mac support */ /* OS X uses filetypes when creating files. */ /*** Include the library header files ***/ /* Use various POSIX functions if available */ /** ANSI C headers **/ /** POSIX headers **/ /*** Define the basic game types ***/ /* * cptr is a shortcut type for "const char *". XXX * errr is an error code * * A "byte" is an unsigned byte of memory. * s16b/u16b are exactly 2 bytes (where possible) * s32b/u32b are exactly 4 bytes (where possible) */ /* C++ defines its own bool type, so we hack around it */ typedef const char *cptr; typedef int errr; /* * Use a real bool type where possible */  #include  #define TRUE true #define FALSE false /* Use a char otherwise */ typedef char bool; #undef TRUE #undef FALSE #define TRUE  1 #define FALSE 0 /* * Use guaranteed-size ints where possible */  /* Use guaranteed-size types */ #include  typedef uint8_t byte; typedef uint16_t u16b; typedef int16_t s16b; typedef uint32_t u32b; typedef int32_t s32b; /* Try hacks instead (not guaranteed to work) */ typedef unsigned char byte; typedef signed short s16b; typedef unsigned short u16b; /* Detect >32-bit longs */ #if (UINT_MAX == 0xFFFFFFFFUL) && (ULONG_MAX > 0xFFFFFFFFUL) typedef signed int s32b; typedef unsigned int u32b; #else typedef signed long s32b; typedef unsigned long u32b; #endif /*** Simple constants ***/ /* Define NULL */ /*** Basic math macros ***/ /*** Useful fairly generic macros ***/ /* * Given an array, determine how many elements are in it. */ /* * Return "s" (or not) depending on whether n is singular. */ /*** Some hackish character manipulation ***/ /* * Note that all "index" values must be "lowercase letters", while * all "digits" must be "digits". Control characters can be made * from any legal characters. XXX XXX XXX */ /* * System-independent definitions for the arrow keys. */ /* Analogous to isdigit etc in ctypes */
 * 1) ifndef INCLUDED_H_BASIC_H
 * 2) define INCLUDED_H_BASIC_H
 * 1) ifdef HAVE_CONFIG_H
 * 1) include "autoconf.h"
 * 1) else
 * 1) ifdef __riscos
 * 2)  ifndef RISCOS
 * 3)   define RISCOS
 * 4)  endif
 * 5) endif
 * 1) if defined(_Windows) || defined(__WINDOWS__) || \
 * 1)  ifndef WINDOWS
 * 2)   define WINDOWS
 * 3)  endif
 * 4) endif
 * 1) if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
 * 2)  define HAVE_STDINT_H
 * 3)  define HAVE_STDBOOL_H
 * 4) endif
 * 1) ifndef RISCOS
 * 2) define HAVE_FCNTL_H
 * 3) endif
 * 1) endif /* HAVE_CONFIG_H */
 * 1) if !defined(MACH_O_CARBON) && !defined(WINDOWS) && \
 * 1) define SET_UID
 * 1) ifndef HAVE_CONFIG_H
 * 2)  define HAVE_DIRENT_H
 * 3)  define HAVE_SETEGID
 * 4)  if defined(linux)
 * 5)   define HAVE_SETRESGID
 * 6)  endif
 * 7) endif
 * 1) endif
 * 1) undef PATH_SEP
 * 2) define PATH_SEP "/"
 * 1) ifdef WINDOWS
 * 2) undef PATH_SEP
 * 3) define PATH_SEP "\\"
 * 4) endif
 * 1) ifdef MACH_O_CARBON
 * 1) define FILE_TYPE_TEXT 'TEXT'
 * 2) define FILE_TYPE_DATA 'DATA'
 * 3) define FILE_TYPE_SAVE 'SAVE'
 * 4) define FILE_TYPE(X) (_ftype = (X))
 * 1) else
 * 1) define FILE_TYPE(X) ((void)0)
 * 1) endif
 * 1) undef _GNU_SOURCE
 * 2) define _GNU_SOURCE
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) include 
 * 1) if defined(SET_UID) || defined(MACH_O_CARBON)
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) endif
 * 1) undef bool
 * 2) define bool bool_hack
 * 1) ifdef HAVE_STDBOOL_H
 * 1) else
 * 1) endif
 * 1) ifdef HAVE_STDINT_H
 * 1) define MAX_UCHAR		UINT8_MAX
 * 2) define MAX_SHORT		INT16_MAX
 * 1) else /* HAVE_STDINT_H */
 * 1) define MAX_UCHAR		UCHAR_MAX
 * 2) define MAX_SHORT		32767
 * 1) endif /* HAVE_STDINT_H */
 * 1) ifndef NULL
 * 2) define NULL ((void*)0)
 * 3) endif
 * 1) undef MIN
 * 2) undef MAX
 * 3) undef ABS
 * 4) undef SGN
 * 1) define MIN(a,b)	(((a) > (b)) ? (b) : (a))
 * 2) define MAX(a,b)	(((a) < (b)) ? (b) : (a))
 * 3) define ABS(a)		(((a) < 0)  ? (-(a)) : (a))
 * 4) define SGN(a)		(((a) < 0)  ? (-1) : ((a) != 0))
 * 1) define N_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
 * 1) define PLURAL(n)		((n) == 1 ? "" : "s")
 * 1) define A2I(X)	((X) - 'a')
 * 2) define I2A(X)	((X) + 'a')
 * 3) define D2I(X)	((X) - '0')
 * 4) define I2D(X)	((X) + '0')
 * 5) define KTRL(X)	((X) & 0x1F)
 * 6) define UN_KTRL(X)	((X) + 64)
 * 7) define ESCAPE	'\033'
 * 1) define ARROW_DOWN	'\x8A'
 * 2) define ARROW_LEFT	'\x8B'
 * 3) define ARROW_RIGHT	'\x8C'
 * 4) define ARROW_UP	'\x8D'
 * 1) define isarrow(c)	((c >= ARROW_DOWN) && (c <= ARROW_UP))
 * 1) endif /* INCLUDED_H_BASIC_H */