1 /* File: h-define.h */ 2 3 #ifndef INCLUDED_H_DEFINE_H 4 #define INCLUDED_H_DEFINE_H 5 6 #ifdef SET_UID 7 #include <sys/param.h> 8 #endif 9 10 /* 11 * Define some simple constants 12 */ 13 14 15 /* 16 * Hack -- Define NULL 17 */ 18 #ifndef NULL 19 # ifdef __STDC__ 20 # define NULL ((void*)0) 21 # else 22 # define NULL ((char*)0) 23 # endif /* __STDC__ */ 24 #endif /* NULL */ 25 26 27 /* 28 * Hack -- assist "main-acn.c" XXX XXX XXX 29 */ 30 #ifdef ACORN 31 # define O_RDONLY 0 32 # define O_WRONLY 1 33 # define O_RDWR 2 34 #endif 35 36 37 /* 38 * Hack -- force definitions -- see fd_seek() 39 */ 40 #ifndef SEEK_SET 41 # define SEEK_SET 0 42 #endif 43 #ifndef SEEK_CUR 44 # define SEEK_CUR 1 45 #endif 46 #ifndef SEEK_END 47 # define SEEK_END 2 48 #endif 49 50 /* 51 * Hack -- force definitions -- see fd_lock() XXX XXX XXX 52 */ 53 #ifndef F_UNLCK 54 # define F_UNLCK 0 55 #endif 56 #ifndef F_RDLCK 57 # define F_RDLCK 1 58 #endif 59 #ifndef F_WRLCK 60 # define F_WRLCK 2 61 #endif 62 63 64 /* 65 * The constants "TRUE" and "FALSE" 66 */ 67 68 #undef TRUE 69 #define TRUE 1 70 71 #undef FALSE 72 #define FALSE 0 73 74 75 76 77 /**** Simple "Macros" ****/ 78 79 /* 80 * Force a character to lowercase/uppercase 81 */ 82 #define FORCELOWER(A) ((isupper((A))) ? tolower((A)) : (A)) 83 #define FORCEUPPER(A) ((islower((A))) ? toupper((A)) : (A)) 84 85 86 /* 87 * Non-typed minimum value macro 88 */ 89 #undef MIN 90 #define MIN(a,b) (((a) > (b)) ? (b) : (a)) 91 92 /* 93 * Non-typed maximum value macro 94 */ 95 #undef MAX 96 #define MAX(a,b) (((a) < (b)) ? (b) : (a)) 97 98 /* 99 * Non-typed absolute value macro 100 */ 101 #undef ABS 102 #define ABS(a) (((a) < 0) ? (-(a)) : (a)) 103 104 /* 105 * Non-typed sign extractor macro 106 */ 107 #undef SGN 108 #define SGN(a) (((a) < 0) ? (-1) : ((a) != 0)) 109 110 111 /* 112 * Hack -- allow use of "ASCII" and "EBCDIC" for "indexes", "digits", 113 * and "Control-Characters". 114 * 115 * Note that all "index" values must be "lowercase letters", while 116 * all "digits" must be "digits". Control characters can be made 117 * from any legal characters. XXX XXX XXX 118 */ 119 #ifdef VM 120 # define A2I(X) alphatoindex(X) 121 # define I2A(X) indextoalpha(X) 122 # define D2I(X) ((X) - '0') 123 # define I2D(X) ((X) + '0') 124 # define KTRL(X) ((X) & 0x1F) 125 # define ESCAPE '\033' 126 #else 127 # define A2I(X) ((X) - 'a') 128 # define I2A(X) ((X) + 'a') 129 # define D2I(X) ((X) - '0') 130 # define I2D(X) ((X) + '0') 131 # define KTRL(X) ((X) & 0x1F) 132 # define ESCAPE '\033' 133 #endif 134 135 136 /* 137 * Make sure the standard constants for types are available. 138 */ 139 #include <limits.h> 140 141 142 #endif 143