1 /* 2 * SMAPI; Modified Squish MSGAPI 3 * 4 * Squish MSGAPI0 is copyright 1991 by Scott J. Dudley. All rights reserved. 5 * Modifications released to the public domain. 6 * 7 * Use of this file is subject to the restrictions contain in the Squish 8 * MSGAPI0 licence agreement. Please refer to licence.txt for complete 9 * details of the licencing restrictions. If you do not find the text 10 * of this agreement in licence.txt, or if you do not have this file, 11 * you should contact Scott Dudley at FidoNet node 1:249/106 or Internet 12 * e-mail Scott.Dudley@f106.n249.z1.fidonet.org. 13 * 14 * In no event should you proceed to use any of the source files in this 15 * archive without having accepted the terms of the MSGAPI0 licensing 16 * agreement, or such other agreement as you are able to reach with the 17 * author. 18 */ 19 20 #ifndef __COMPILER_H__ 21 #define __COMPILER_H__ 22 23 /* 24 BeOS is NOT Unix, but sometime it seem's to Be ... ;) 25 */ 26 #if defined (__BEOS__) 27 #ifndef UNIX 28 #define UNIX 29 #endif 30 #endif 31 32 #if defined ( __WATCOMC__ ) 33 #include <direct.h> 34 #include <io.h> 35 #endif 36 37 #if defined(OS2) && !defined(_MSC_VER) 38 #ifndef __386__ 39 #define __386__ 40 #endif 41 #ifndef __FLAT__ 42 #define __FLAT__ 43 #endif 44 #endif 45 46 #ifdef MSDOS 47 48 #define _XPENTRY pascal 49 50 /* WATCOM has both M_I86xxx and __modeltype__ macros */ 51 52 #ifdef M_I86SM 53 #ifndef __SMALL__ 54 #define __SMALL__ 55 #endif 56 #endif 57 58 #ifdef M_I86MM 59 #ifndef __MEDIUM__ 60 #define __MEDIUM__ 61 #endif 62 #endif 63 64 #ifdef M_I86CM 65 #ifndef __COMPACT__ 66 #define __COMPACT__ 67 #endif 68 #endif 69 70 #ifdef M_I86LM 71 #ifndef __LARGE__ 72 #define __LARGE__ 73 #endif 74 #endif 75 76 #ifdef M_I86HM 77 #ifndef __HUGE__ 78 #define __HUGE__ 79 #endif 80 #endif 81 82 #endif 83 84 /* Handle 386 "flat" memory model */ 85 86 #ifdef __FLAT__ 87 88 /* Other macros may get defined by braindead compilers */ 89 90 #ifdef __SMALL__ 91 #undef __SMALL__ 92 #endif 93 94 #ifdef __TINY__ 95 #undef __TINY__ 96 #endif 97 98 #ifdef __MEDIUM__ 99 #undef __MEDIUM__ 100 #endif 101 102 #ifdef __COMPACT__ 103 #undef __COMPACT__ 104 #endif 105 106 #ifdef __LARGE__ 107 #undef __LARGE__ 108 #endif 109 110 #ifdef __HUGE__ 111 #undef __HUGE__ 112 #endif 113 114 /* 115 * Code is really "near", but "far" in this context means that we 116 * want a 32-bit pointer (vice 16-bit). 117 */ 118 119 #define __FARCODE__ 120 #define __FARDATA__ 121 122 /* Everything should be "near" in the flat model */ 123 124 #ifdef near 125 #undef near 126 #define near 127 #endif 128 129 #ifdef far 130 #undef far 131 #define far near 132 #endif 133 134 #ifdef huge 135 #undef huge 136 #define huge near 137 #endif 138 139 #endif 140 141 #if defined(__SMALL__) || defined(__TINY__) 142 #define __NEARCODE__ 143 #define __NEARDATA__ 144 #endif 145 146 #ifdef __MEDIUM__ 147 #define __FARCODE__ 148 #define __NEARDATA__ 149 #endif 150 151 #ifdef __COMPACT__ 152 #define __NEARCODE__ 153 #define __FARDATA__ 154 #endif 155 156 #if defined(__LARGE__) || defined(__HUGE__) 157 #define __FARCODE__ 158 #define __FARDATA__ 159 #endif 160 161 /* 162 * Compiler-specific stuff: 163 * 164 * _stdc - Standard calling sequence. This should be the type of function 165 * required for function pointers for qsort() et al. 166 * 167 * _fast - Fastest calling sequence supported. If the default calling 168 * sequence is the fastest, or if your compiler only has one, 169 * define this to nothing. 170 * 171 * _intr - For defining interrupt functions. For some idiotic reason, MSC 172 * requires that interrupt routines be declared as "cdecl interrupt", 173 * instead of just "interrupt". 174 */ 175 176 #if defined(__TURBOC__) && defined(__MSDOS__) 177 178 /* Borland Turbo C/C++ for MS-DOS */ 179 180 /* for BC++ 3.1 */ 181 #define strcasecmp stricmp 182 #define strncasecmp strncmpi 183 184 #define _stdc cdecl 185 #define _intr interrupt far 186 #define _intcast void (_intr *)() 187 #define _veccast _intcast 188 #define _fast pascal 189 #define _loadds 190 191 /* #include <conio.h> */ 192 #define mysleep(x) delay(x); 193 194 #ifndef _XPENTRY 195 #define _XPENTRY 196 #endif 197 198 199 #elif defined(__WATCOMC__) && defined(MSDOS) 200 201 /* WATCOM C/C++ for MS-DOS */ 202 203 #define _stdc cdecl 204 #define _intr interrupt far 205 #define _intcast void (_intr *)() 206 #define _veccase _intcast 207 #define _fast pascal 208 209 #ifdef __FLAT__ 210 #define farread read 211 #define farwrite write 212 #endif 213 214 #define strcasecmp stricmp 215 #define strncasecmp strnicmp 216 217 #elif (defined(_MSC_VER) && (_MSC_VER < 1200)) 218 219 /* Microsoft C or Microsoft QuickC for MS-DOS or OS/2 */ 220 221 #define _stdc cdecl 222 #define _intr cdecl interrupt far 223 #define _intcast void (_intr *)() 224 #define _veccast _intcast 225 226 #if _MSC_VER >= 600 227 #define _fast _fastcall 228 #else 229 #define _fast pascal 230 #endif 231 232 int unlock(int handle, long ofs, long length); 233 int lock(int handle, long ofs, long length); 234 235 #ifdef OS2 236 /* just don't use 16 bit OS/2, we doubt that it still works */ 237 #define farread read 238 #define farwrite write 239 #define _XPENTRY pascal far 240 #define mysleep(x) DosSleep(1000L*(x)) 241 #endif 242 243 #elif defined(__WATCOMC__) && (defined(__OS2__) || defined(OS2)) 244 245 /* WATCOM C/C++ for OS/2 */ 246 247 #define _stdc 248 #define _intr 249 #define _intcast 250 #define _veccast 251 #define _fast 252 253 #define farread read 254 #define farwrite write 255 256 #define strcasecmp stricmp 257 #define strncasecmp strnicmp 258 259 #define _XPENTRY _System 260 #define mysleep(x) sleep(x) 261 #define mode_t int 262 263 264 #elif defined(__WATCOMC__) && defined(__NT__) 265 266 /* WATCOM C/C++ for Windows NT */ 267 268 #define _stdc 269 #define _intr 270 #define _intcast 271 #define _veccast 272 #define _fast 273 274 #define farread read 275 #define farwrite write 276 277 #define strcasecmp stricmp 278 #define strncasecmp strnicmp 279 280 #define _XPENTRY pascal 281 #define mode_t int 282 283 #elif defined(__HIGHC__) 284 285 /* MetaWare High C/C++ for OS/2 */ 286 287 #define _stdc 288 #define _intr 289 #define _intcast 290 #define _veccast 291 #define _fast 292 #define pascal 293 #define near 294 #define far 295 296 #define farread read 297 #define farwrite write 298 299 #define mysleep(x) DosSlep(1000L*(x)) 300 301 #define unlock(a,b,c) unused(a) 302 #define lock(a,b,c) 0 303 #error "Don't know how to implement record locking." 304 /* Using an executable that does no support record locking is 305 discouraged in a multitasking environment. If you want to 306 do it anyway, you may uncomment this line. Record lokcing is used 307 to obtain a lock on the very first byte of a SQD file which 308 indicates that no other program should use the message area now. 309 */ 310 311 312 313 #define _XPENTRY 314 315 #elif defined(__MINGW32__) 316 317 /* MINGW32 for 32-bit Windows NT on Intel and AXP */ 318 319 #define _stdc 320 #define _intr 321 #define _intcast 322 #define _veccast 323 #define _fast 324 #define _loadds 325 #define cdecl 326 #define pascal __stdcall 327 #define near 328 #define far 329 330 #define farread _read 331 #define farwrite _write 332 #define mymkdir _mkdir 333 #define fdopen _fdopen 334 #define close _close 335 #define open _open 336 #define lseek _lseek 337 #define tell _tell 338 #define sleep _sleep 339 340 #define stricmp _strcmpi 341 #define strcmpi _strcmpi 342 343 /*extern int __mkdir (__const__ char *name);*/ 344 345 int unlock(int handle, long ofs, long length); 346 int lock(int handle, long ofs, long length); 347 #define sopen _sopen 348 349 /* older mingw headers are too lazy ... */ 350 #include <share.h> 351 #ifndef SH_DENYRW 352 #define SH_DENYRW 0x10 353 #endif 354 #ifndef SH_DENYWR 355 #define SH_DENYWR 0x20 356 #endif 357 #ifndef SH_DENYRD 358 #define SH_DENYRD 0x30 359 #endif 360 #ifndef SH_DENYNO 361 #define SH_DENYNO 0x40 362 #endif 363 364 #ifndef _XPENTRY 365 #define _XPENTRY 366 #endif 367 368 #elif defined(__TURBOC__) && defined(WINNT) 369 370 /* Borland C/C++ for Win32 */ 371 372 #define _stdc cdecl 373 #define _intr 374 #define _intcast 375 #define _veccast 376 #define _fast pascal 377 #define _loadds 378 #define near 379 #define far 380 381 #define farread read 382 #define farwrite write 383 384 #define _XPENTRY 385 386 #define strcasecmp stricmp 387 #define strncasecmp strncmpi 388 389 390 #elif defined(__EMX__) 391 392 /* EMX for 32-bit OS/2 and RSX for Windows NT */ 393 394 #define _stdc 395 #define _intr 396 #define _intcast 397 #define _veccast 398 #define _fast 399 #define _loadds 400 #define cdecl 401 #define pascal 402 #define near 403 #define far 404 405 #define farread read 406 #define farwrite write 407 #define mymkdir(a) mkdir((a), 0) 408 409 int unlock(int handle, long ofs, long length); 410 int lock(int handle, long ofs, long length); 411 412 #define strcasecmp stricmp 413 #define strncasecmp strnicmp 414 415 #define _XPENTRY 416 417 #elif defined(__TURBOC__) && defined(WINNT) 418 419 /* Borland C/C++ for Win32 */ 420 421 #define _stdc cdecl 422 #define _intr 423 #define _intcast 424 #define _veccast 425 #define _fast pascal 426 #define _loadds 427 #define near 428 #define far 429 430 #define farread read 431 #define farwrite write 432 433 #define _XPENTRY 434 435 #elif defined(__TURBOC__) && defined(__OS2__) 436 437 /* Borland C/C++ for OS/2 */ 438 439 #define _stdc cdecl 440 #define _intr 441 #define _intcast 442 #define _veccast 443 #define _fast pascal 444 #define _loadds 445 #define near 446 #define far 447 448 #define farread read 449 #define farwrite write 450 451 #ifndef _XPENTRY 452 #define _XPENTRY __syscall 453 #endif 454 #define mysleep(x) sleep(x); 455 456 #include <io.h> 457 #include <dos.h> 458 459 #define strcasecmp stricmp 460 #define strncasecmp strncmpi 461 462 #elif defined(__IBMC__) 463 464 /* IBM C/Set++ for OS/2 */ 465 466 #define _stdc 467 #define _intr 468 #define _intcast 469 #define _veccast 470 #define _fast 471 #define _loadds 472 473 #define cdecl 474 #define pascal 475 #define near 476 #define far 477 478 #define farread read 479 #define farwrite write 480 #define mysleep(x) DosSleep(1000L*(x)) 481 482 #define _XPENTRY pascal far 483 484 485 #elif defined(UNIX) 486 487 /* Linux, FreeBSD, etc. */ 488 489 #define _stdc 490 #define _intr 491 #define _intcast 492 #define _veccast 493 #define _fast 494 #define _loadds 495 496 #define cdecl 497 #define pascal 498 #define near 499 #define far 500 501 #define farread read 502 #define farwrite write 503 504 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(_AIX) || defined(__sun__) || defined(__linux__) || defined(__osf__) || defined(__hpux) || defined(__BEOS__) || defined(__OpenBSD__) 505 #define mymkdir(a) mkdir((a), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) 506 #else 507 #define mymkdir(a) __mkdir((a), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) 508 #endif 509 510 int lock(int handle, long ofs, long length); /* in locking.c */ 511 int unlock(int handle, long ofs, long length); 512 int sopen(const char *name, int oflag, int ishared, int mode); 513 514 #ifndef __sun__ 515 #define tell(a) lseek((a),0,SEEK_CUR) 516 #endif 517 518 #ifndef stricmp 519 #define stricmp strcasecmp 520 #endif 521 522 #ifndef __BEOS__ 523 #define O_BINARY 0 524 #endif 525 526 #define SH_DENYNONE 0 527 #define SH_DENYNO 0 528 #define SH_DENYALL 1 529 530 #define _XPENTRY 531 532 /* Other OS's may sleep with other functions */ 533 534 #ifdef __BEOS__ 535 #define mysleep(x) snooze(x*1000000l) 536 #elif defined(__linux__) || defined(__sun__) 537 #define mysleep(x) usleep(x*1000000l) 538 #endif 539 540 #elif defined(__DJGPP__) 541 542 /* DJGPP for MS-DOS */ 543 544 #define _stdc 545 #define _intr 546 #define _intcast 547 #define _veccast 548 #define _fast 549 #define _loadds 550 551 #define cdecl 552 #define pascal 553 #define near 554 #define far 555 556 #define farread read 557 #define farwrite write 558 559 #define mymkdir(a) mkdir((a), 0) 560 561 #define stricmp strcasecmp 562 #define SH_DENYNONE 0 563 564 #include <unistd.h> 565 #include <io.h> 566 #define mysleep(x) sleep(x) 567 568 #elif defined(SASC) 569 570 /* SAS C for AmigaDOS */ 571 572 #define _stdc 573 #define _intr 574 #define _intcast 575 #define _veccast 576 #define _fast 577 #define _loadds 578 579 #define cdecl 580 #define pascal 581 #define near 582 #define far 583 584 #define farread read 585 #define farwrite write 586 #define mymkdir(a) mkdir((a)) 587 588 #define unlock(a,b,c) unused(a) 589 #define lock(a,b,c) 0 590 #define mysleep(x) unused(x) 591 592 #error "Don't know how to implement record locking." 593 /* Using an executable that does no support record locking is 594 discouraged in a multitasking environment. If you want to 595 do it anyway, you may uncomment this line. Record locking is used 596 to obtain a lock on the very first byte of a SQD file which 597 indicates that no other program should use the message area now. 598 */ 599 600 #define SH_DENYNONE 0 601 #define sopen(a,b,c,d) open((a),(b),(d)) 602 603 #define _XPENTRY 604 605 #elif defined(_MSC_VER) && (_MSC_VER >= 1200) 606 607 #define _stdc 608 #ifdef pascal 609 #undef pascal 610 #endif 611 #define pascal 612 #define far 613 #define _fast 614 #define near 615 #define _XPENTRY 616 #define strncasecmp strnicmp 617 #define sleep(x) Sleep(1000L*(x)) 618 #define farread read 619 #define farwrite write 620 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 621 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 622 #define mode_t int 623 624 #else 625 626 #error compiler.h: Unknown compiler! 627 628 #endif 629 630 #ifndef mymkdir 631 #define mymkdir mkdir 632 #endif 633 634 #define NO_MKTIME 635 #define NO_STRFTIME 636 637 /* waitlock works like lock, but blocks until the lock can be 638 * performed. 639 * waitlock2 works like a timed waitlock. 640 */ 641 #ifndef mysleep 642 #define mysleep(x) 643 #endif 644 645 // extern int waitlock(int, long, long); 646 // extern int waitlock2(int, long, long, long); 647 648 #endif 649 650 651 652