1 /****************************************************************************** 2 3 #### # # #### ##### ###### # # # # 4 # # # # # # ## ## # # 5 #### # #### # ##### # ## # ###### 6 # # # # # # # ### # # 7 # # # # # # # # # ### # # 8 #### # #### # ###### # # ### # # 9 10 ******************************************************************************/ 11 /* This file is part of MAPMAKER, Copyright 1987-1992 Whitehead Institute. 12 See the READ.ME file for license agreement and non-warranty information. */ 13 14 /*************************************************************************** 15 This file, along with the syscode.c file, is used to provide most, if 16 not all system specific, definitions allowing our library files to 17 port from one system to another. Note that these declarations are 18 provided for the shell library code, NOT NECESSARILY FOR THE APPLICATION 19 CODE! See the apropriate ...lib.h file for a list of the functions you 20 should use. 21 22 With the increasing encroachment of ANSI C, we can now get away with 23 only only one system.h files (with #ifdefs, of course) for all 24 systems. An ANSI compiler doesn't help too much, because Sun/DEC (and 25 others) include files are just not ANSI. At present, fixes are in 26 place for: 27 28 * SunOS 4.1.x with the bundled cc (ANSI-C, just say no) 29 * DEC Ultrix 4.2 on the nice but now obsolete DECStation line (cc, not acc) 30 * Apple's A/UX 3.0 on high end Macintoshes 31 * WATCOM C/386 9.0 on MicroSloth's MS-DOG, optionally with M$-Windoze 3.1 32 33 Previous versions of this library have been ported in various flavors 34 to Mac ThinkC and VMS as well as other flavors of Unix - hopefully 35 these ports will happen again for this version soon. If you port this 36 code, we suggest you use the following flags: 37 38 _SYS_SUNOS Specifics for SunOS 4.1.x (only tried SPARC) 39 _SYS_SOLARIS Specifics for Solaris 2.x (SPARC and Intel versions identical?) 40 _SYS_AUX Specifics for Apple's A/UX 3.0 41 _SYS_MACHTEN Specifics for Tennon's MachTen on Macintosh (tried & failed!) 42 _SYS_ULTRIX Specifics for DEC RISC/ULTRIX 4.x (for MIPS based DECStations) 43 _SYS_OSF Specifics for OSF/1 for DEC Alpha (like, if it ever ships) 44 _SYS_AIX Specifics for the inferior but marketable AIX (RISC or other?) 45 _SYS_HPUX Specifics for HP-UX (8.x?) for HP 9000/700 series. 46 _SYS_BSD Specifics for modern BSD systems (tested on FreeBSD 6.3) 47 _SYS_UNIX Basic Unix semantics, defined if any one of the above is 48 49 _SYS_WATCOM Specifics for WATCOM C/386 9.0 with apropriate libraries 50 _SYS_DOS Basic DOS semantics, defined if the above is 51 52 _SYS_THINKC Specifics for ThinkC (5.0?) 53 _SYS_MPW Specifics for MPW C (ver???) 54 _SYS_MAC Basic MAC semantics, should be defined if one of the above is 55 56 Things I'm not quite sure what to do with... 57 _SYS_NT Windoze/NT (Not There) on Intel (what about Alpha/MIPS/etc?) 58 _SYS_OS2 OS/2 2.x (gives me the willies just to think about it) 59 _SYS_NEXT NeXTStep 3.0, wiTh ThE fUNkey CaPItaLizAtION (040 or Intel?) 60 _SYS_VMS Basic VMS semantics (what options are there?) 61 62 Of course most of these flags are not handled yet. Happy porting :-) 63 64 Among other things ,this is the only file which understands which of 65 the system's #include files need to be used, as well as what order 66 they should be included in! (This is handled at the end of this file). 67 You should include standard files by #defining one or more of the 68 following and then #including "system.h": 69 70 INC_IO File and TTY I/O routines, including stdio. 71 INC_MATH Simple math routines. 72 INC_MSG Message sending and trapping routines. 73 INC_MEM Memory allocation/free routines. 74 INC_STR String functions, including C's and this library's. 75 INC_LIB All five of the above. 76 77 INC_MISC Misc. functions (time, subshells, array dumps, sorting, etc). 78 INC_SHELL The ubiquitous MAPMAKERish shell. 79 INC_TABLE A useful data struct, used by the shell and other things. 80 *************************************************************************/ 81 82 #ifdef _SYS_SUNOS 83 #define _SYS_UNIX 84 #else 85 #ifdef _SYS_ULTRIX 86 #define _SYS_UNIX 87 #else 88 #ifdef _SYS_AUX 89 #define _SYS_UNIX /* Note: NOT _SYS_MAC */ 90 #else 91 #ifdef _SYS_BSD 92 #define _SYS_UNIX 93 #else 94 #endif 95 #endif 96 #endif 97 #endif 98 #ifdef _SYS_WATCOM 99 #define _SYS_DOS 100 #endif 101 102 103 104 /************************ File name syntax **************************** 105 Setup the following for the OS's path types (these are used by the 106 make_filename() procedure in iolib.c). Note that the lengths of various 107 elements of a path are not checked, only its total length. 108 *************************************************************************/ 109 #define PATH_LENGTH 200 110 111 #ifndef _SYS_DOS /* e.g. _SYS_UNIX or some POSIX like thing */ 112 #define HELP_EXT ".help" 113 #define ARG_CHAR '-' /* Usual char for command line switches */ 114 #define PATH_REQUIRE_EXTENSION FALSE 115 #define PATH_SINGLE_EXTENSION FALSE 116 #define PATH_UPPERCASE FALSE 117 #define PATH_DIR_SEPARATORS "/" /* rightmost separating char */ 118 #define PATH_DIR_FILE_INSERT "/" /* insert between a dir and filename */ 119 #define PATH_OK_CHARS \ 120 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~#/" 121 #define PATH_DIR_CHARS \ 122 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~#/" 123 124 #else /* is _SYS_DOS */ 125 #define HELP_EXT ".hlp" 126 #define ARG_CHAR '/' /* Usual char for command line switches */ 127 #define PATH_REQUIRE_EXTENSION TRUE 128 #define PATH_SINGLE_EXTENSION TRUE 129 #define PATH_UPPERCASE TRUE 130 #define PATH_DIR_SEPARATORS "\\" /* rightmost separating char */ 131 #define PATH_DIR_FILE_INSERT "\\" /* insert between a dir and filename */ 132 #define PATH_OK_CHARS \ 133 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.$#/\\" 134 #define PATH_DIR_CHARS \ 135 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.$#/\\" 136 #endif 137 138 139 /**************************** Subshells ********************************* 140 To help portability, we use the system() function to spawn subshells 141 on all operating systems. (However, system specific code may be placed 142 in syscode.c to do it another way). Under Unix, if TRY_SHELL_VAR is 143 TRUE, getenv() will be used to get the value of SHELL to run by 144 calling system(getenv("SHELL")). If the SHELL variable is not set we 145 try calling system(TRY_SHELL_CMD). Naturally, these presume 146 HAVE_GETENV is defined. 147 148 On MS-DOS we will first try system(getenv("COMSPEC")). Otherwise, 149 TRY_SHELL_CMD should be "command.com". System() is not supported on the 150 Mac, and on VMS, SHELL_CMD should be "SPAWN". 151 **************************************************************************/ 152 /* #define NO_SYSTEM_FUNC *//* ANSI/POSIX - All should have system() now */ 153 154 #ifdef _SYS_DOS 155 #define TRY_COMSPEC_VAR 156 #define TRY_SHELL_CMD "command.com" 157 #define SHELL_MESSAGE "Running DOS prompt: Type 'exit' to return...\n" 158 159 #else /* _SYS_UNIX */ 160 #define TRY_SHELL_VAR 161 #define TRY_SHELL_CMD "/bin/csh" /* csh is the default on Sun, DEC, A/UX */ 162 #define SHELL_MESSAGE \ 163 "Running Unix shell: Type 'exit' or hit Control-D to return...\n" 164 #endif 165 166 167 /************************ Error handling routines ************************* 168 Errno lookups: strerror(), which is allegedly ANSI standard, should 169 return an error message (char*) when given a correct system errno 170 (generally from ferror()). Don't use perror(). For systems without 171 strerror(), use sys_errlist[] and sys_nerr (this includes Lightspeed, 172 System V, HP-UX, and SunOS). If sys_nerr does not exist, we ignore it 173 and hope that sysnerr[errno] is valid... On some systems (Sun) 174 sys_errlist does not appear in any #include file, although errno 175 (extern int) is defined (usu. in math.h?). 176 177 Also, define HAVE_MATHERR if matherr() trapping is supported, as it 178 is on System V (See msglib.h). SIGHANDLE should be the return value 179 type of a signal handling function used as an argument to signal(). 180 ***************************************************************************/ 181 #define HAVE_MATHERR /* Doesn't hurt to not define it... */ 182 183 #ifdef _SYS_WATCOM /* strerror is defined, as it should be */ 184 #define SIGHANDLE int 185 #define SIGQUIT SIGABRT /* bizzare */ 186 #endif 187 #ifdef _SYS_SUNOS /* the @#!$% map pages lie */ 188 #define SIGHANDLE int 189 #define strerror(num) (num<sys_nerr ? sys_errlist[num]:(char*)NULL) 190 extern char *sys_errlist[]; extern int sys_nerr; 191 #endif 192 #ifdef _SYS_AUX 193 #define SIGHANDLE void 194 #define strerror(num) (num<sys_nerr ? sys_errlist[num]:(char*)NULL) 195 extern char *sys_errlist[]; extern int sys_nerr; 196 #endif 197 #ifdef _SYS_ULTRIX 198 #define SIGHANDLE void 199 #endif 200 #ifdef _SYS_BSD 201 #define SIGHANDLE void 202 #endif 203 204 205 206 /************************* Random Numbers ********************************** 207 There are at least 3 standard random number generators in C-libraries: 208 rand() (ANSI, fairly ubiquitous), drand48() (System V), and random() (BSD). 209 Rand() is a lousy random number generator: don't use it unless no 210 other is available. See the code for these in syscode.c. The limits sont 211 seem to be real portable, so be careful. 212 ***************************************************************************/ 213 #ifdef _SYS_AUX 214 #define USE_DRAND48 215 #else 216 #ifdef _SYS_SUNOS 217 #define USE_RANDOM 218 #else 219 #ifdef _SYS_ULTRIX 220 #define USE_RANDOM 221 #else 222 #ifdef _SYS_BSD 223 #define USE_DRAND48 /* bsd has 'random' */ 224 #else 225 #define USE_SRAND 226 #endif 227 #endif 228 #endif 229 #endif 230 231 232 /***************************** C-Library ************************************** 233 Here are some casts to make various incompatible C-library functions 234 compatible accross machines. NONE OF THESE FUNCTIONS SHOULD BE CALLED 235 DIRECTLY! RATHER, THEY SHOULD BE CALLED ONLY BY THE HELPERS ROUTINES 236 WHICH DRIVE THEM! Define the constants appropriately so that the 237 following declarations are correct on the target machine: 238 239 CALLOC_PTR_TO *calloc(num,sizeof(...)) 240 CALLOC_NUM_TYPE num; 241 SIZEOF_TYPE size; 242 243 TIME_TYPE time(); 244 char *ctime(ptr) 245 TIME_TYPE *ptr; 246 247 qsort(data,array_length,width,compare) \*** portability hell ***\ 248 QSORT_DATA_PTR_TO *data; \* an array \* 249 QSORT_LENGTH array_length; 250 SIZEOF_TYPE width; 251 int (*compare)(); 252 int compare(a,b) 253 QSORT_COMPARE_PTR_TO(type) *a, *b; 254 255 where type is the type of thing that pointers into data (eg a and b) really 256 point to. For example, to compare long integers, the code should read (Note: 257 better interfaces are provided in the library - see misclib.h for them!) 258 259 int long_compare(a,b) 260 QSORT_COMPARE_PTR_TO(long) *a; 261 QSORT_COMPARE_PTR_TO(long) *b; 262 { 263 long x,y; 264 x= *(long*)a; y= *(long*)b; 265 if (x<y) return(-1); else if (x==y) return(0); else return(1); 266 } 267 ... 268 qsort(QSORT_CAST(data),(QSORT_LENGTH)length,sizeof(long),long_compare) 269 270 Qsort()'s return value, if it has one, is ignored. We assume that qsort never 271 fails (perhaps this is stupid). 272 273 Define (and use!) exit_main as the statement which main() should execute 274 when the program normally terminates. abnormal_exit should be an exit() 275 call for abnormal situations (mostly for the HP 800 exit() bus-error bug!) 276 277 Define HAVE_CHDIR, HAVE_GETCWD, and/or HAVE_GETENV if those functions exist. 278 Check out their usage (arguments, etc) in syscode.c to be safe! 279 ***************************************************************************/ 280 #define HAVE_GETENV /* Don't all ANSI compilers have these now? */ 281 #define HAVE_GETCWD 282 #define HAVE_CHDIR 283 #define normal_exit() exit(0) 284 #define abnormal_exit() exit(1) 285 #define exit_main() return(0) 286 #define TIME_TYPE time_t /* for ctime - yes even on SunOS! */ 287 #define QSORT_CAST(x) ((QSORT_DATA_PTR_TO*)(x)) 288 #define QSORT_COMPARE_PTR_TO(type) type 289 290 #ifdef _SYS_ULTRIX /* way old and quite kludgey C specs, BSD 4.2 da! */ 291 #define CALLOC_PTR_TO char 292 #define CALLOC_NUM_TYPE size_t /* unsigned in man page is wrong? */ 293 #define SIZEOF_TYPE size_t 294 #define QSORT_DATA_PTR_TO char 295 #define QSORT_LENGTH int /* actually width is an int, not a unsigned */ 296 #endif 297 298 #ifdef _SYS_BSD /* modern BSD systems (tested on FreeBSD 6.3) */ 299 #define CALLOC_PTR_TO char 300 #define CALLOC_NUM_TYPE size_t /* unsigned in man page is wrong? */ 301 #define SIZEOF_TYPE size_t 302 #define QSORT_DATA_PTR_TO char 303 #define QSORT_LENGTH int /* actually width is an int, not a unsigned */ 304 #endif 305 306 #ifdef _SYS_AUX /* just like ULTRIX? */ 307 #define CALLOC_PTR_TO char 308 #define CALLOC_NUM_TYPE size_t /* unsigned in man page is wrong? */ 309 #define SIZEOF_TYPE size_t 310 #define QSORT_DATA_PTR_TO char 311 #define QSORT_LENGTH int /* actually width is an int, not a unsigned */ 312 #endif 313 314 #ifdef _SYS_SUNOS /* semi-ANSI is neither better nor worse */ 315 #define CALLOC_PTR_TO void /* the man pages lie? */ 316 #define CALLOC_NUM_TYPE size_t 317 #define SIZEOF_TYPE size_t 318 #define QSORT_DATA_PTR_TO char 319 #define QSORT_LENGTH int /* actually width is an int, not a unsigned */ 320 int system(); /* why is this in no include file */ 321 int fseek(); /* ditto */ 322 /* Fucking Suns: exit() is really of type int, but it's void in the lint-lib */ 323 #endif 324 325 #ifdef _SYS_WATCOM /* should be good for any ANSI system */ 326 #define CALLOC_PTR_TO void 327 #define CALLOC_NUM_TYPE size_t 328 #define SIZEOF_TYPE size_t 329 #define QSORT_DATA_PTR_TO void 330 #define QSORT_LENGTH size_t 331 #endif 332 333 334 335 /**************************** Terminal I/O ******************************** 336 If TRY_GETENV_TERM is set, the system first tries to recognize the 337 string returned by getenv("TERM"). The system can deal with the 338 following terminal types, in terms of very, very basic screen I/O: 339 340 Default Escape Assume 341 TERM variable Terminal #Lines Codes Scrollback? 342 ------------ ------- ------ ----- ----------- 343 ansi* simple DEC VT-100 compatible 24 ANSI Yes (new) 344 dec*, vt* " " " " 345 xterm* X-Windows vt-100 emulator " " " 346 mac* A/UX CommandShell window " " " 347 sun* Sun workstation console or 36 ANSI Yes (new) 348 SunView shelltool/cmdtool 349 pc* PC with ANSI.SYS loaded 25 ANSI No 350 hp* most Hewlett-Packards 24 HP Yes 351 300* HP 9000 console 46 HP Yes 352 anything else unknown terminal type 24 none No 353 354 [Note: here * means any characters can follow, including possibly none.] 355 356 If the TERM shell variable is set, then on Unix we may try to lookup 357 the screen length using the termcap functions, if HAVE_TERMCAP is 358 defined. On any system we then try to use the LINES environment 359 variable (LINES over-rides termcap). We do not try to look up anything 360 else using termcap (too ugly, bleach). If HAVE_WINSIZE is defined, the 361 termios (POSIX) ioctl(fileno(stdout),TIOCGWINSZ,struct winsize*) is 362 used to get the #lines, and it WILL be used appropriately to see if 363 the window's size changed (we do not have a SIGWINCH handler however). 364 This value will supercede the defaults above. As yet no attempt is 365 made to determine the screen width (see note below). 366 367 There was a TRY_TERMINFO flag, to use terminfo instead of termcap, but 368 it may be broken. All Unixes seem to have termcap these days. Someone 369 wanna fix it? 370 371 IMPORTANT NOTE FOR WINDOWING SYSTEMS: If HAVE_WINSIZE does not work, 372 then it will be impossible for the shell to tell if the #lines changes 373 after it has started (e.g. if a terminal emulator window is resized). 374 375 In ALL cases, we really want to use an 80-character wide window or 376 screen! We assume 79 chars max per output line with tabs every 8 377 spaces, to maximize portability. (Really avoid system dependent 378 terminal widths, or otherwise transcript files must be printed on a 379 wider printer, other system's editors and so forth must be able to 380 deal, E-mailing files can be a problem, and... ick!). It's probably a 381 good idea to always keep TRANSLATE_TABS set. 382 383 If DEFAULT_SCROLLBACK is defined (to either TRUE or FALSE) the default 384 assumptions about scrollback are ignored. If scrollback is assumed, then 385 the screen is not cleared. More-mode is now always diabled at first. 386 ***************************************************************************/ 387 #define TRY_GETENV_TERM /* Might as well always leave these defined? */ 388 #define TRY_GETENV_LINES /* see syscode.c */ 389 #define TRY_ISATTY 390 /* #define DEFAULT_SCROLLBACK TRUE */ /* define ONLY to over-ride */ 391 #define DEFAULT_MORE_MODE TRUE /* is over-ridden with -nomore */ 392 #define TRANSLATE_TABS TRUE 393 #define MEMORY_LINES 150 394 #define MAX_HOLD_LINES 150 395 396 #ifdef _SYS_UNIX 397 #define DEFAULT_TERM_TYPE SCROLLING_ANSI 398 #define TRY_TERMCAP 399 #define TRY_WINSIZE 400 401 #else /* _SYS_DOS */ 402 #define DEFAULT_TERM_TYPE PC_CONSOLE 403 #endif 404 405 406 407 408 /************************** Stdio interface ******************************* 409 The TTY/Text File I/O library now assumes that the following functions 410 exist and work as in ANSI (or Unix System V, if not in K&R). Note that 411 we use a very small subset of the USUAL stdio/Unix-I/O library, for 412 portability's sake. If a function is not listed here, then we probably 413 found a portability problem somewhere, so don't use it! (Actually, as 414 always, the application code should only use the functions described 415 in iolib.h). 416 417 K&R did not specify what the output routine putc() does on errors, 418 nor does it specify its return value type. The same is true of fclose(). 419 In practice, on different systems they do different things. Define 420 xputc() and xclose() here to return TRUE if OK or FALSE if error. 421 422 We assume that fgets() provides standard I/O preprocessing (delete key 423 and so forth). For details of the curses interface, see cursesio.c. 424 425 printf(...) not used in general, but only in special cases 426 fprintf(...) ditto 427 scanf(...) ditto 428 fscanf(...) ditto 429 sprintf(...) used everywhere (aliased to "sf" in strlib.h) 430 int sscanf(...) returns # tokens parsed 431 fflush(FILE *fp) can't fail if fp is OK 432 433 int feof(FILE *fp) returns T/F AFTER a call to xgetc() gives EOF 434 int ferror(FILE *fp) returns errno>=0 or 0 indicating "no error" 435 int getc(FILE *fp) returns c or EOF 436 ungetc(int c; FILE *fp) it can't fail 437 438 FILE *fopen(char *nam,*mode) NULL if fail 439 fseek(FILE *fp; long num; int dir) it can't fail if fp is OK 440 int fgets(FILE *fp; char *s; int n) may return EOF char 441 442 Note that functions listed without return types here may or may not be of 443 type void: on many systems they are of type int! However, the fuction's 444 return value is always (and should always be) discarded, if it exists. 445 446 We provide a workaround for fseek(), which seems to have bugs on VMS. 447 ***************************************************************************/ 448 #define xputc(c,fp) (putc(c,fp)!= EOF) 449 #define xclose(fp) (fclose(fp)!= EOF) 450 #define file_seek(fp,char_num) fseek(fp,((long)(char_num)),0) 451 /* #define REPLACE_FSEEK *//* Needed on VMS? */ 452 453 454 /**************** GLOBAL DECLARATIONS FOR USERS OF LIB ***************** 455 Good working assumptions about data types, etc: 456 457 * Doubles are big (say e+/-30, at least): avoid single precision (float) 458 or other floating point types like the plauge. 459 * A short is 2 bytes and a long is 4 bytes, both are signed. 460 * An int is either a short or a long. On everything we use now, its long. 461 * A char can take 7 (NOT 8) bits (0-127), positive values only. 462 * unsigned ints exist, but there are a number of reasons not to use them 463 (it is easy for arguments to get passed incorrectly). 464 * Never-ever assume that shifts wrap around correctly (or don't wrap 465 correctly), or that overflow/underflow ever produces predictable results 466 * God knows what a pointer is. Always cast pointer types correctly, 467 and avoid recasting pointers in general. 468 * Always make sure that arguments passed=arguments declared EXACTLY! Many 469 bugs arrise if you don't. Never assume that parameters in a function call 470 will be automaticly be cast correctly. Be explicit. 471 * Pass structs/unions/arrays as args by pointer ONLY. Passing by value is not 472 even close to portable. Variable length argument lists are not portable. 473 Returning structs/unions/arrays by value is also unportable. 474 * Never-ever-ever try to side-effect constants. The biggest culprit here 475 is passing a string argument to a function which then try to change 476 characters in the string. This causes bus errors on most systems. 477 * void exists, but void* doesn't, nor does enum. Use void, not int, for 478 procedures that return nothing 479 * Really avoid other implicit int declarations (ex arguments w/o a type 480 are assumed to be ints - YUK!) 481 * Only assume that the result of a boolean expression (ex x<y) is zero 482 (FALSE) or nonzero (TRUE). Thus, expressions like "if (flag==TRUE) ..." 483 are a very bad idea. Instead say "if (flag) ...". 484 * Otherwise, what the original K&R version 1 says goes. 485 486 Note that the following definitions are specs and should never be 487 changed! They exist only to clarify code, not to allow any sort of 488 data-type abstraction! 489 ******************************************************************************/ 490 491 #ifndef NO_INCLUDE_HELPERS 492 493 #define real double 494 #define bool int 495 #define flag int 496 #define TRUE (1) 497 #define FALSE (0) 498 #define MAYBE (-1) 499 /* rely on the system to define NULL */ 500 501 /* One of the lib_init() routines must be called before ANYTHING else 502 is done, or the program will crash in wierd ways! In general, user's 503 _init routines should come right after the lib_init() call and should 504 just initialize variables, malloc things, etc. They should not do 505 anything important, and particularly should not generate any I/O. */ 506 507 void lib_init(); /* no args - assumes line type tty I/O */ 508 509 void lib_inits(); /* args: int *argc_pointer; char *argv[]; both are 510 side-effected. This is more or less the same as lib_init() except that it 511 checks the environment and may start up either curses or wimp I/O via 512 screen_init(); */ 513 514 void custom_lib_init(); /* no args: This is like lib_init() except 515 that tty_init() is not called. A screen_init() routine must be invoked 516 before ANY I/O is attempted, or else... (see iolib.h) */ 517 518 void get_cmd_line_args(); /* args: int *argc_ptr; char **argv; 519 side-effects file_arg[] and nulls the args it parses, so another 520 arg sucker can go at it afterwards */ 521 522 #endif 523 524 525 /*************************** Library Include files **************************/ 526 #ifdef INC_LIB 527 #define INC_MATH 528 #define INC_MSG 529 #define INC_IO 530 #define INC_STR 531 #define INC_MEM 532 #endif 533 534 #include <stdlib.h> 535 #ifndef _SYS_WATCOM 536 #include <unistd.h> /* not quite sure why we need this */ 537 #endif 538 539 #ifdef INC_IO 540 #include <stdio.h> 541 #include "iolib.h" 542 #endif 543 544 #ifdef INC_MATH 545 #ifdef _SYS_WATCOM 546 #undef real 547 #endif 548 #include <math.h> /* WATCOM has problems with this if "real" is a macro */ 549 #ifdef _SYS_WATCOM 550 #define real double 551 #endif 552 #include "mathlib.h" 553 #endif 554 555 #ifdef INC_MSG 556 #include <setjmp.h> 557 #include "msglib.h" 558 #endif 559 560 #ifdef INC_MEM 561 #include "memlib.h" 562 #endif 563 564 #ifdef INC_STR 565 #include <string.h> 566 #include <ctype.h> 567 #include "strlib.h" 568 #endif 569 570 /* The following are NOT included by INC_LIB */ 571 572 #ifdef INC_MISC 573 #include "misclib.h" 574 #endif 575 576 #ifdef INC_SHELL 577 #include "shell.h" 578 #endif 579 580 #ifdef INC_TABLE 581 #include "table.h" 582 #endif 583 584 #ifdef INC_EQN 585 #include "eqn.h" 586 #endif 587 588 #ifdef INC_HISTO 589 void make_histo(); /* that's all? */ 590 #endif 591 592 #ifdef INC_STATS 593 #include "stats.h" 594 #endif 595 596 /********************* Defs internal to the library ********************* 597 Here are definitions needed ONLY to compile the helpers files themselves. 598 None of this stuff should be used by the user code: much better (that is, 599 robust and portable) interfaces are provided by the library. */ 600 /*************************************************************************/ 601 602 #ifdef INC_HELP_DEFS 603 604 #include <signal.h> 605 #include <errno.h> 606 #include <time.h> /* for ctime() def - Who does not have this file? */ 607 #include <stdlib.h> 608 #include <sys/types.h> 609 610 #ifdef TRY_WINSIZE 611 #include <sys/ioctl.h> 612 #endif 613 614 /* The BSD random number functions... seemingly not declared anywhere */ 615 #ifdef USE_RANDOM 616 long random(); 617 int srandom(); 618 #endif 619 620 /* The HPUX (and System V?) random number functions... ditto */ 621 #ifdef USE_DRAND48 622 double drand48(); 623 void srand48(); 624 #endif 625 626 /* Library declarations only to be used by the helpers library code itself */ 627 extern char *ps_, *ln_; /* defined in iolib.c */ 628 void dummy_math_calls(); 629 630 #endif /* for #ifdef INC_HELP_DEFS */ 631 632 #undef fflush /* a special version is used by the application code */ 633 634 /*************************************************************************/ 635