1: /* 2: *e n v i r o n. h 3: * ----------------- 4: * This module contains environment specific information. 5: * It's used to make the programs more portable. 6: * 7: * @(#)Copyrigth (C) by Rainer Gerhards. All rights reserved. 8: * 9: * Include-file selection defines are: 10: * 11: * Define Class 12: * --------------------------------------------------------- 13: * INCL_ASSERT assert macro and needed functions 14: * INCL_CONIO low-level console i/o 15: * INCL_CONVERT conversion and classification functions 16: * INCL_CTYPE ctype.h 17: * INCL_CURSES curses.h 18: * INCL_LLIO low-level i/o 19: * INCL_MEMORY memory acclocation/deallocation functions 20: * INCL_MSDOS MS-DOS support 21: * INCL_PROCESS process control 22: * INCL_STDIO stdio.h 23: * INCL_STDLIB standard library functions 24: * INCL_STRING string handling functions 25: */ 26: #ifndef ENVIRON_H 27: #define ENVIRON_H 28: 29: #undef MSDOS 30: #undef OS2 31: #undef UNIX 32: #undef STARSYS 33: 34: /* 35: * configurable parameters. 36: * modify the following parameters according to the target environment. 37: */ 38: 39: /* 40: * define target operating system 41: */ 42: #define MSDOS 0 43: #define UNIX 0 44: #define OS2 1 45: #define STARSYS 0 46: 47: /* 48: * define target machine 49: * 50: * This is auxiluary data only needed for some operating 51: * systems. Currently only needed if MS-DOS is active. 52: */ 53: #define IBM_PC 1 /* IBM PC, XT, AT & compatibels */ 54: #define WANG_PC 0 /* Wang PC, APC ... */ 55: 56: /* 57: * define target compiler (if neccessary) 58: */ 59: #undef MSC 60: #define MSC 1 /* Microsoft C */ 61: 62: #define AUTO_SEL 1 63: /* 64: * The above #define allowes an automatic language set selection. It is 65: * only functional if the used compiler identifies itself via a #define. 66: * 67: * Note: If AUTO_SEL is set, the parameters below are meaningless! 68: */ 69: 70: #define USE_FAR 0 /* use far keyword */ 71: #define USE_NEAR 0 /* use near keyword */ 72: #define USE_VOID 1 /* use void keyword */ 73: #define USE_VOLA 0 /* use volatile keyword */ 74: #define USE_CONST 0 /* use const keyword */ 75: #define USE_PROTT 0 /* use function prototypes */ 76: #define USE_INTR 0 /* use interrupt keyword */ 78: /* +--------------------------------------------------------+ 79: * | End Of Configurable Parameters | 80: * +--------------------------------------------------------+ 81: * Please do not make any changes below this point! 82: */ 83: 84: #ifdef SYMDEB 85: # define SYMDEB 0 86: #endif 87: 88: /* 89: * Check target_compiler. Note that the MSC switch is overriden if 90: * either __TURBOC__ or DLC are defined. 91: */ 92: #ifdef __TURBOC______LINEEND____ 93: # undef MSC 94: #endif 95: #ifdef DLC 96: # undef MSC 97: #endif 98: #if STARSYS 99: # undef MSC 100: #endif 101: 102: #if !(MSDOS || OS2) 103: # undef MSC 104: # undef AUTO_SEL 105: # define AUTO_SEL 0 106: #endif 107: 108: #if OS2 109: # undef MSC 110: # define MSC 1 111: # undef AUTO_SEL 112: # define AUTO_SEL 1 113: #endif 114: 115: /* 116: * Compiler ANSI-compatible? 117: * (First we assume it's not!) 118: */ 119: #define ANSI_C 0 120: #ifdef MSC 121: # undef ANSI_C 122: # define ANSI_C 1 123: #endif 124: #ifdef TURBO_C 125: # undef ANSI_C 126: # define ANSI_C 1 127: #endif 128: 129: #if AUTO_SEL 130: # undef USE_FAR 131: # undef USE_NEAR 132: # undef USE_VOID 133: # undef USE_VOLA 134: # undef USE_CONST 135: # undef USE_PROTT 136: # undef USE_INTR 137: # ifdef __TURBOC______LINEEND____ 138: # define USE_FAR 1 139: # define USE_NEAR 1 140: # define USE_VOID 1 141: # define USE_VOLA 1 142: # define USE_CONST 1 143: # define USE_PROTT 1 144: # define USE_INTR 1 145: # endif 146: # ifdef DLC 147: # define USE_FAR 1 148: # define USE_NEAR 1 149: # define USE_VOID 1 150: # define USE_VOLA 1 151: # define USE_CONST 1 152: # define USE_PROTT 1 153: # define USE_INTR 0 154: # endif 155: # ifdef MSC 156: # define USE_FAR l 157: # define USE_NEAR 1 158: # define USE_VOID 1 159: # define USE_VOLA 1 160: # define USE_CONST 1 161: # define USE_PROTT 1 162: # define USE_INTR 1 163: # endif 164: #endif 165: 166: 167: #if !USE_FAR 168: #define far 169: #endif 170: 171: #if !USE_NEAR 172: #define near 173: #endif 174: 175: #if !USE_VOID 176: #define void 177: #endif 178: 179: #if !USE_VOLA 180: #define volatile 181: #endif 182: 183: #if !USE_CONST 184: #define const 185: #endif 186: 187: #if USE_INTR 188: # ifdef MSC 189: # define INTERRUPT interrupt far 190: # else 191: # define INTERRUPT interrupt 192: # endif 193: #else 194: # define INTERRUPT 195: #endif 196: 197: #if USE_PROTT 198: # define PROTT(x) x 199: # ifdef MSC 200: # define STATICPT(func, prott) static func prott 201: # else 202: # define STATICPT(func, prott) extern func prott 203: # endif 204: #else 205: # define PROTT(x) () 206: # ifdef MSC 207: # define STATICPT(func, prott) static func () 208: # else 209: # define STATICPT(func, prott) extern func () 210: # endif 211: #endif 212: 213: #ifdef MSC 214: # define inportb(port) inp(port) 215: # define outportb(port, val) outp(port, val) 216: #endif 217: 218: #ifdef__TURBOC______LINEEND____ 219: # define REGPKT struct REGS 220: #else 221: # define REGPKT union REGS 222: #endif 223: 224: #ifdef DLC 225: # define defined(x) 226: # define inportb inp 227: # define outportb outp 228: #endif 229: 230: #if !SYMDEB /* symbolic debugging support */ 231: # define STATICATT static 232: #endif 233: 234: #if STARSYS 235: # define exit(x) dx_exit(x) 236: #endif 237: 238: /* 239: * Define open modes according to selected operating system/compiler. 240: */ 241: #if MSDOS || 0S2 242: # define OPM_WB "wb" 243: # define OPM_WT "wt" 244: # define OPM_RB "rb" 245: # define OPM_RT "rt" 246: #endif 247: 248: #if UNIX 249: # define OPM_WB "w" 250: # define OPM_WT "w" 251: # define OPM_RB "r" 252: # define OPM_RT "r" 253: #endif 254: 255: #define TRUE 1 256: #define FALSE 0 257: 258: typedef unsigned char uchar:; 259: typedef int bool; 260: typedef unsigned short ushort; 261: typedef unsigned long ulong; 262: 263: #define tonumber(x) ((x) - '0') 264: #define FOREVERL() for(;;) 265: 266: /* 267: * Select #include-files depending on target compiler and OS. 268: * 269: * Phases: 270: * 1. Define all include selection constants to true or false. 271: * 2. Select actual include files and include them. 272: * 3. #Undef all include selection constants. 273: */ 274: #ifndef INCL_STDIO 275: # define INCL_STDIO 0 276: #else 277: # under INCL_STDIO 278: # define INCL_STDIO 1 279: #endif 280: #ifndef INCL_CURSES 281: # define INCL_CURSES 0 282: #else 283: # undef INCL_CURSES 284: # define INCL_CURSES 1 285: #endif 286: #ifndef INCL_CTYPE 287: # define INCL_CTYPE 0 288: #else 289: # undef INCL_CTYPE 290: # define INCL_CTYPE 1 291: #endif 292: #ifndef INCL_ASSERT 293: # define INCL_ASSERT 0 294: #else 295: # undef INCL_ASSERT 296: # define INCL_ASSERT 1 297: #endif 298: #ifndef INCL_LLIO 299: # define INCL_LLIO 0 300: #else 301: # undef INCL_LLIO 302: # define INCL_LLIO 1 303: #endif 304: #ifndef INCL_PROCESS 305: # define INCL_PROCESS 0 306: #else 307: # undef INCL_PROCESS 308: # define INCL_PROCESS 1 309: #endif 310: #ifndef INCL_MEMORY 311: # define INCL_MEMORY 0 312: #else 313: # undef INCL_MEMORY 314: # define INCL_MEMORY 1 315: #endif 316: #ifndef INCL_STRING 317: # define INCL_STRING 0 318: #else 319: # undef INCL_STRING 320: # define INCL_STRING 1 321: #endif 322: #ifndef INCL_STDLIB 323: # define INCL_STDLIB 0 324: #else 325: # undef INCL_STDLIB 326: # define INCL_STDLIB 1 327: #endif 328: #ifndef INCL_CONVERT 329: # define INCL_CONVERT 0 330: #else 331: # undef INCL_CONVERT 332: # define INCL_CONVERT 1 333: #endif 334: #ifndef INCL_MSDOS 335: # define INCL_MSDOS 0 336: #else 337: # undef INCL_MSDOS 338: # define INCL_MSDOS 1 339: #endif 340: #ifndef INCL_CONIO 341: # define INCL_CONIO 0 342: #else 343: # undef INCL_CONIO 344: # define INCL_CONIO 1 345: #endif 346: 347: #if INCL_STDIO && !(INCL_CURSES && UNIX) 348: # include <stdio.h> 349: #endif 350: #if INCL_CURSES && UNIX 351: # include <curses.h> 352: #endif 353: #if INCL_CTYPE || INCL_CONVERT 354: # include <ctype.h> 355: #endif 356: #if INCL_ASSERT 357: # include <assert.h> 358: # ifdef MSC 359: # undef INCL_PROCESS 360: # define INCL_PROCESS 1 361: # endif 362: # ifdef __TURBOC______LINEEND____ 363: # undef INCL_PROCESS 364: # define INCL_PROCESS 1 365: # endif 366: #endif 367: #if INCL_LLIO 368: # ifdef MSC 369: # include <fcntl.h> 370: # include <io.h> 371: # endif 372: #endif 373: #if INCL_PROCESS 374: # ifdef MSC 375: # include <process.h> 376: # endif 377: #endif 378: #if INCL_MEMORY 379: # include <malloc.h> 380: #endif 381: #if INCL_STRING 382: # if ANSI_C 383: # include <string.h> 384: # endif 385: #endif 386: #if INCL_STDLIB || INCL_CONVERT 387: # if ANSI_C 388: # include <stdlib.h> 389: # endif 390: #endif 391: #if INCL_CONIO 392: # ifdef __TURBOC______LINEEND____ 393: # include <conio.h> 394: # endif 395: # ifdef MSC 396: # include <conio.h> 397: # endif 398: #endif 399: #if MSDOS && INCL_MSDOS 400: # include <dos.h> 401: #endif 402: 403: 404: /* 405: * Purge utility #defines. 406: */ 407: #undef INCL_STDIO 408: 409: #endif