1 #ifndef LIB_DEFINITIONS 2 #define LIB_DEFINITIONS 3 /*****************************************************************************/ 4 /* MODULE NAME: lib_defs.h MODULE TYPE: (dat) */ 5 /*****************************************************************************/ 6 /* MODULE IMPORTS: */ 7 /*****************************************************************************/ 8 9 /*****************************************************************************/ 10 /* MODULE INTERFACE: */ 11 /*****************************************************************************/ 12 13 /* Note: weird names are used here in order to avoid name conflicts! */ 14 15 typedef unsigned char base; 16 17 /* = a BYTE, the BASE for everything (mnemonic: also starts with a "b") */ 18 19 typedef unsigned int unit; 20 21 /* = a machine WORD, the basic UNIT (mnemonic: unit is an anagram of uint!) */ 22 23 typedef unsigned long longunit; 24 typedef unsigned short shortunit; 25 26 typedef unsigned char N_char; 27 typedef unsigned int N_int; 28 typedef unsigned long N_long; 29 typedef unsigned short N_short; 30 31 /* mnemonic 1: the natural numbers, N = { 0, 1, 2, 3, ... } */ 32 /* mnemonic 2: Nnnn = u_N_signed, _N_ot signed */ 33 34 typedef signed char Z_char; 35 typedef signed int Z_int; 36 typedef signed long Z_long; 37 typedef signed short Z_short; 38 39 /* mnemonic 1: the whole numbers, Z = { 0, -1, 1, -2, 2, -3, 3, ... } */ 40 /* mnemonic 2: Zzzz = Ssss_igned */ 41 42 typedef void *voidptr; 43 44 typedef base *baseptr; 45 typedef unit *unitptr; 46 typedef longunit *longunitptr; 47 typedef shortunit *shortunitptr; 48 49 typedef unsigned char *N_charptr; 50 typedef unsigned int *N_intptr; 51 typedef unsigned long *N_longptr; 52 typedef unsigned short *N_shortptr; 53 54 typedef signed char *Z_charptr; 55 typedef signed int *Z_intptr; 56 typedef signed long *Z_longptr; 57 typedef signed short *Z_shortptr; 58 59 #undef FALSE 60 #define FALSE (0==1) 61 62 #undef TRUE 63 #define TRUE (0==0) 64 65 typedef enum { _false = FALSE , _true = TRUE } boolean; 66 67 #define blockdef(name,size) unsigned char name[size] 68 #define blocktypedef(name,size) typedef unsigned char name[size] 69 70 #define and && /* logical (boolean) operators: lower case */ 71 #define or || 72 #define not ! 73 74 #define AND & /* binary (bitwise) operators: UPPER CASE */ 75 #define OR | 76 #define XOR ^ 77 #define NOT ~ 78 #define SHL << 79 #define SHR >> 80 81 #ifdef EXTENDED_LIB_DEFINITIONS 82 83 #define mod % /* arithmetic operators */ 84 85 #define BELL '\a' /* bell 0x07 */ 86 #define BEL '\a' /* bell 0x07 */ 87 #define BACKSPACE '\b' /* backspace 0x08 */ 88 #define BS '\b' /* backspace 0x08 */ 89 #define TAB '\t' /* tab 0x09 */ 90 #define HT '\t' /* horizontal tab 0x09 */ 91 #define LINEFEED '\n' /* linefeed 0x0A */ 92 #define NEWLINE '\n' /* newline 0x0A */ 93 #define LF '\n' /* linefeed 0x0A */ 94 #define VTAB '\v' /* vertical tab 0x0B */ 95 #define VT '\v' /* vertical tab 0x0B */ 96 #define FORMFEED '\f' /* formfeed 0x0C */ 97 #define NEWPAGE '\f' /* newpage 0x0C */ 98 #define CR '\r' /* carriage return 0x0D */ 99 100 typedef struct 101 { 102 base l; 103 base h; 104 } twobases; 105 106 typedef struct 107 { 108 base a; 109 base b; 110 base c; 111 base d; 112 } fourbases; 113 114 typedef struct 115 { 116 unit l; 117 unit h; 118 } twounits; 119 120 /*******************************/ 121 /* implementation dependent!!! */ 122 /* (assumes int = 2 bytes) */ 123 /*******************************/ 124 125 typedef union 126 { 127 unit x; 128 twobases z; 129 } unitreg; 130 131 /**********************************************/ 132 /* implementation dependent!!! */ 133 /* (assumes long = 4 bytes and int = 2 bytes) */ 134 /**********************************************/ 135 136 typedef union 137 { 138 longunit x; 139 twounits y; 140 fourbases z; 141 } longunitreg; 142 143 #define lobyte(x) (((int)(x)) & 0xFF) 144 #define hibyte(x) ((((int)(x)) >> 8) & 0xFF) 145 146 #endif 147 148 /*****************************************************************************/ 149 /* MODULE RESOURCES: */ 150 /*****************************************************************************/ 151 152 /*****************************************************************************/ 153 /* MODULE IMPLEMENTATION: */ 154 /*****************************************************************************/ 155 156 /*****************************************************************************/ 157 /* AUTHOR: Steffen Beyer */ 158 /*****************************************************************************/ 159 /* VERSION: 3.0 */ 160 /*****************************************************************************/ 161 /* VERSION HISTORY: */ 162 /*****************************************************************************/ 163 /* 01.11.93 Created */ 164 /* 16.02.97 Version 3.0 */ 165 /*****************************************************************************/ 166 /* COPYRIGHT (C) 1993-1997 BY: Steffen Beyer */ 167 /*****************************************************************************/ 168 #endif 169