/* defs.h -- all-purpose definitions */ /* inclusions/constants for portability */ #if __GNUC__ #define ANSI 1 #else #define ANSI 0 #define SUN 1 #define OLD_NEWS 0 #define FACOM 0 #define MSC 0 #endif #include #include #include #if ANSI || SUN #include #endif /* Byte order-related macros */ #ifdef __BYTE_ORDER /* In GCC on Linux, both BIG_ENDIAN and LITTLE_ENDIAN are defined as non-zero */ #undef LITTLE_ENDIAN #undef BIG_ENDIAN #endif #ifndef LITTLE_ENDIAN #if MSC || __i386__ #define LITTLE_ENDIAN 1 #else #define LITTLE_ENDIAN 0 #endif #define BIG_ENDIAN !LITTLE_ENDIAN #endif #if OLD_NEWS /* Broken tolower/toupper macros */ #undef toupper #define toupper(c) (islower(c) ? (c)-('a'-'A') : (c)) #undef tolower #define tolower(c) (isupper(c) ? (c)+('a'-'A') : (c)) #endif #if OLD_NEWS /* strchr() not included in standard library */ #define NO_strchr 1 #endif #if OLD_NEWS || (SUN && !__GNUC__) /* Function to delete a file is named unlink() */ #define remove unlink #endif #if FACOM /* No function to delete a file available at all! */ #define remove(x) #endif #if SUN long strtol(); time_t time(); #endif #ifndef MAXINT /* Should be greater than number of entries in database */ #define MAXINT 999999 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif /* General-purpose constants */ #define YES 1 /* Boolean constant */ #define NO 0 /* .. */ #define OK 0 /* Function return status */ #define ERROR (-1) /* .. */ #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 /* Program return status */ #define EXIT_FAILURE 1 /* .. */ #endif #define NULL_CP (char *)0 /* Null character pointer */ /* Function-like macros */ #ifndef min #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) #endif /* Test for equality of strings (slightly fast) */ #define streq(x,y) (*(x)==*(y) && !strcmp((x),(y))) /* End of a string */ #define strtail(x) strchr((x),0) /* Like strncpy(), but without padding/omission of null */ #define strn_cpy(x,y,n) (*(x)=0, strncat(x,y,n)) /* fputs to stdout */ #define put_s(m) fputs((m),stdout) /* fputs to stderr */ #define errmsg(m) fputs((m),stderr) /* Advance pointer to non-blank character */ #define skipspace(p) while(isspace(*p)) p++ /* Advance pointer to blank character */ #define skipnspace(p) while(*p && !isspace(*p)) p++ /* ----- end of defs.h ----- */