1 /****************************************************************************** 2 * 3 * NSSDC/CDF Header file for CDF distribution. 4 * 5 * Version 2.7e, 14-Dec-97, Hughes STX. 6 * 7 * Modification history: 8 * 9 * V1.0 20-Jul-91, J Love Original version (for CDF V2.1). 10 * V2.0 17-May-92, J Love IBM PC & HP-UX port. CDF V2.2. 11 * V2.1 15-Sep-92, J Love CDF V2.3 (shareable/zVar/NeXT). 12 * V2.2 30-Oct-92, J Love Added variable values display to CDFinquire. 13 * V2.3 25-Jan-94, J Love CDF V2.4. 14 * V2.3a 8-Feb-94, J Love DEC Alpha/OpenVMS port. 15 * V2.4 13-Dec-94, J Love CDF V2.5. 16 * V2.5 20-Jan-95, J Love `Trailer' function prototype. 17 * V2.5a 19-Jan-95, J Love IRIX 6.0 (64-bit). 18 * V2.5b 28-Feb-95, J Love `IsGraphChr' function prototype. Solaris 2.3 19 * IDL i/f. Pass `char' as `int'. 20 * V2.6 6-Apr-95, J Love POSIX. 21 * V2.6a 18-Apr-95, J Love More POSIX. 22 * V2.6b 9-May-95, J Love Virtual memory under Microsoft C 7.00. Added 23 * `EPOCHdataType'. EPOCH styles. 24 * V2.6c 13-Jun-95, J Love EPOCH custom format. Linux. 25 * V2.6d 25-Aug-95, J Love More system include files for UNIX. Moved 26 * `ASSIGNnotNULL' from `cdflib.h'. CDFexport- 27 * related changes. More virtual memory for 28 * Microsoft C 7.00. 29 * V2.7 9-Sep-96, J Love CDF V2.6. 30 * V2.7a 26-Nov-96, J Love Better handling of HP-UX POSIX-compliant 31 * compiler (c89). 32 * V2.7b 21-Feb-97, J Love Removed RICE. 33 * V2.7c 28-Feb-97, J Love Windows NT for MS Visual C/C++ on an IBM PC. 34 * V2.7d 16-Nov-97, J Love More Windows NT. 35 * V2.7e 14-Dec-97, J Love Added ALPHAVMSi encoding. 36 * V2.7f 27-May-98, M Liu SunOS/gnu has stdarg.h while SunOS/bsd doesn't. 37 * V2.7g 07-Feb-01, M Liu Added Solaris running on PC platform. 38 * V2.8 02-May-01, M Liu Added handling for CYGWIN. 39 * V2.9 25-Nov-02, M Liu Added handling for 64-bit Solaris sparcv9. 40 * V2.10 08-Apr-04, M Liu Added a new function for data type CDF_EPOCH16. 41 * V2.11 11-Jul-05, M Liu Added MingW port for PC. 42 * V2.12 30-Jan-06, M Liu Added FreeBSD port. 43 * V2.13 09-Jun-06, M Liu Added HP-UX and AIX for LFS. 44 * V2.14 09-Jul-06, M Liu Added MacOSX on i386 PC (macosXintel). 45 * V2.15 18-Apr-08, M Liu Further modified MacOS X into macosXppc and 46 * maxosXintel. For PPC, pre-defined macro 47 * "__ppc__" and "__ppc64__" by gcc for 32/64- 48 * bit mode, respectively on Mac. 49 * V2.16 28-Apr-09, M Liu Added linux-PPC (pre-defined macro "__PPC__" 50 * by gcc for either 32/64-bit). 51 * 52 ******************************************************************************/ 53 54 #if !defined(CDFDISTh_INCLUDEd__) 55 # define CDFDISTh_INCLUDEd__ 56 57 /****************************************************************************** 58 * Definitions for misguided compilers, etc. 59 ******************************************************************************/ 60 61 #if defined(WIN32) 62 # define IBMPC 63 # define win32 64 # if !defined MSVC67 65 # if (_MSC_VER == 1300) 66 /* VC7, building with pre-VC7 runtime libraries */ 67 # define MSVC67 68 # endif 69 # endif 70 #endif 71 72 #if defined(MSDOS) /* Microsoft C. */ 73 # define dos 74 # define MICROSOFTC 75 # if _MSC_VER == 600 76 # define MICROSOFTC_600 77 # endif 78 # if _MSC_VER == 700 79 # define MICROSOFTC_700 80 # endif 81 #endif 82 83 #if defined(__MSDOS__) /* Borland C. */ 84 # define dos 85 # define BORLANDC 86 #endif 87 88 #if defined(__SALFORD__) /* Salford C. */ 89 # define dos 1 90 # define SALFORDC 1 91 #endif 92 93 #if defined(dos) 94 # define IBMPC 95 #endif 96 97 #if defined(NeXT) 98 # define Mach 99 #endif 100 101 #if defined(__ppc__) || (defined(__APPLE__) && !defined(i386)) 102 # define POWERPC 103 # define unix 104 # if defined(__MACH__) /* Mac OS X cc (gcc) */ 105 # define macosXppc 106 # endif 107 #endif 108 109 #if (defined(__APPLE__) && defined(i386)) 110 # define unix 111 # define IBMPC 112 # define macosXintel 113 #endif 114 115 #if defined(AIX) 116 # define unix 117 #endif 118 119 #if defined(linux) || defined(__CYGWIN__) || defined(__MINGW32__) || \ 120 defined(__FreeBSD__) || defined(__DragonFly__) 121 # if defined(PPC) || defined(__PPC__) 122 # define POWERPC 123 # else 124 # if defined(i386) || defined(__amd64) || defined(__x86_64__) || \ 125 defined(__ia64__) 126 # define IBMPC 127 # else 128 # if defined(__alpha) 129 # define alphaosf 130 # endif 131 # endif 132 # endif 133 #endif 134 135 #if defined(__QNX__) 136 # define IBMPC 137 # define unix 138 #endif 139 140 #if defined(sun) && (defined(i386) || defined(__amd64) || \ 141 defined(__x86_64__) || defined(__ia64__)) 142 # define IBMPC 143 # undef sun 144 #endif 145 146 #if defined(__alpha) 147 # if defined(__osf__) 148 # define alphaosf 149 # else 150 # if defined(vms) 151 # define alphavms 152 # if __D_FLOAT 153 # define alphavmsD 154 # endif 155 # if __G_FLOAT 156 # define alphavmsG 157 # endif 158 # if __IEEE_FLOAT 159 # define alphavmsI 160 # endif 161 # else /* "vms" not defined if "-W ansi89" used. */ 162 # if !defined(linux) && !defined(__FreeBSD__) && !defined(__DragonFly__) 163 # define posixSHELL 164 # define posixSHELLalpha 165 # if __D_FLOAT 166 # define posixSHELLalphaD 167 # endif 168 # if __G_FLOAT 169 # define posixSHELLalphaG 170 # endif 171 # if __IEEE_FLOAT 172 # define posixSHELLalphaI 173 # endif 174 # endif 175 # endif 176 # endif 177 #endif 178 179 #if defined(vax) 180 # if defined(vms) 181 # define vaxvms 182 # else /* "vms" not defined if "-W ansi89" used. */ 183 # define posixSHELL 184 # define posixSHELLvax 185 # endif 186 #endif 187 188 #if defined(macintosh) || defined(__MWERKS__) /* Macintosh MPW or MetroWerks CodeWarrior */ 189 # define MPW_C 190 # define mac 191 192 # if defined(__MWERKS__) /* MetroWerks CodeWarrior */ 193 # define STDARG 194 195 # ifdef OLDROUTINENAMES 196 # undef OLDROUTINENAMES 197 # endif 198 # define OLDROUTINENAMES 1 199 200 # ifdef TARGET_OS_MAC 201 # undef TARGET_OS_MAC 202 # endif 203 # define TARGET_OS_MAC 1 204 # endif 205 #endif 206 207 #if defined(THINK_C) /* Macintosh Think C */ 208 # define mac 209 #endif 210 211 #if defined(HPUXposix) 212 # define unix 213 # define hpux 214 # define HP 215 # define _HPUX_SOURCE 216 #endif 217 218 #if defined(HP) 219 # if !defined(unix) 220 # define unix 221 # endif 222 # if !defined(hpux) 223 # define hpux 224 # endif 225 #endif 226 227 #if defined(__MINGW32__) 228 # undef win32 229 # define unix 230 #endif 231 232 /****************************************************************************** 233 * Determine variable argument list type - `stdarg' or `varargs'. Currently, 234 * only SunOS/bsd doesn't have `stdarg.h' (but SunOS/gnu and all Solaris do). 235 ******************************************************************************/ 236 237 #if defined(sun) && !defined(SOLARIS) && !defined(__GCC_NEW_VARARGS__) 238 # define VARARGS 239 #else 240 # define STDARG 241 #endif 242 243 /****************************************************************************** 244 * System include files. 245 ******************************************************************************/ 246 247 #if defined(vms) 248 # include <stdlib.h> 249 # include <stdio.h> 250 # include <string.h> 251 # include <ctype.h> 252 # include <time.h> 253 # include <math.h> 254 # include <unixio.h> 255 # include <types.h> 256 # include <descrip.h> 257 # include <rmsdef.h> 258 # include <climsgdef.h> 259 # include <smgdef.h> 260 # include <ssdef.h> 261 # include <stat.h> 262 # include <lib$routines.h> 263 # if defined(VARARGS) 264 # include <varargs.h> 265 # else 266 # include <stdarg.h> 267 # endif 268 #endif 269 270 #if (defined(unix) && !defined(__MINGW32__)) || defined(posixSHELL) 271 # include <stdlib.h> 272 # include <stdio.h> 273 # include <string.h> 274 # include <ctype.h> 275 # include <time.h> 276 # include <math.h> 277 # include <pwd.h> 278 # include <unistd.h> 279 # include <sys/types.h> 280 # include <sys/stat.h> 281 # include <sys/time.h> 282 # if defined(VARARGS) 283 # include <varargs.h> 284 # else 285 # include <stdarg.h> 286 # endif 287 # if defined (AIX) || defined(__QNX__) 288 # include <sys/select.h> 289 # endif 290 # if defined(Mach) 291 # include <sys/dir.h> 292 # else 293 # include <dirent.h> 294 # endif 295 #endif 296 297 #if defined(dos) || defined(win32) || defined(__MINGW32__) 298 # include <stdlib.h> 299 # include <stdio.h> 300 # include <string.h> 301 # include <ctype.h> 302 # include <time.h> 303 # include <math.h> 304 # if defined(win32) 305 # include <io.h> 306 # include <fcntl.h> 307 # endif 308 # if defined(BORLANDC) 309 # include <dir.h> 310 # endif 311 # if !defined(SALFORDC) 312 # include <dos.h> 313 # endif 314 # include <conio.h> 315 # include <sys\types.h> 316 # include <sys\stat.h> 317 # if defined(VARARGS) 318 # include <varargs.h> 319 # else 320 # include <stdarg.h> 321 # endif 322 #endif 323 324 #if defined(mac) 325 # if defined(MPW_C) 326 # include <StdLib.h> 327 # include <StdIO.h> 328 # include <String.h> 329 # include <CType.h> 330 # include <Time.h> 331 # include <Math.h> 332 # include <Types.h> 333 # include <Fonts.h> 334 # include <Windows.h> 335 # include <Dialogs.h> 336 # include <Textedit.h> 337 # include <Menus.h> 338 # include <Resources.h> 339 # include <StandardFile.h> 340 # include <ToolUtils.h> 341 # if defined(__MWERKS__) 342 # include <stdarg.h> 343 # include <Controls.h> 344 # include <Devices.h> 345 # include <Sound.h> 346 # else 347 # if defined(STDARG) 348 # include <StdArg.h> 349 # endif 350 # endif 351 # include <Files.h> 352 # include <Quickdraw.h> 353 # include <Events.h> 354 # ifndef __MWERKS__ 355 # include <OSEvents.h> 356 # include <Desk.h> 357 # endif 358 # endif 359 # if defined(THINK_C) 360 # include <stdlib.h> 361 # include <stdio.h> 362 # include <string.h> 363 # include <ctype.h> 364 # include <time.h> 365 # include <math.h> 366 # include <stat.h> 367 # if defined(STDARG) 368 # include <stdarg.h> 369 # endif 370 # endif 371 #endif 372 373 /****************************************************************************** 374 * If using the POSIX-compliant C comiler on an HP, redefine the macros that 375 * MAY have been undefined by the system include files. 376 ******************************************************************************/ 377 378 #if defined(HPUXposix) 379 # if !defined(unix) 380 # define unix 381 # endif 382 # if !defined(hpux) 383 # define hpux 384 # endif 385 #endif 386 387 /****************************************************************************** 388 * Typedefs. 389 ******************************************************************************/ 390 391 typedef int Logical; 392 393 typedef unsigned short uShort; 394 typedef unsigned int uInt; 395 typedef unsigned long uLong; 396 397 #if defined(alphaosf) || defined(IRIX64bit) || defined(SOLARIS64) || \ 398 defined(__amd64) || defined(__x86_64__) || defined(__ia64__) || \ 399 defined(AIX64) || defined(HP64) || defined(__PPC64__) || \ 400 defined(__ppc64__) 401 /*************************************************************************** 402 * `long' is 64 bits on a DEC Alpha/OSF1, an SGi/IRIX 6.x using the `-64' 403 * option (64-bit objects) and a Solaris sparcv9, AMD64 and EM64T/IA64. 404 * They are also 64-bits on AIX, HP-UX and PPC if 64-bit mode is on. 405 * `int' is 32 bits in these cases. 406 ***************************************************************************/ 407 typedef int Int32; 408 typedef uInt uInt32; 409 #else 410 typedef long Int32; 411 typedef uLong uInt32; 412 #endif 413 414 typedef short Int16; 415 typedef uShort uInt16; 416 417 #if defined(AIX) || defined(dos) || defined(sgi) || defined(__QNX__) 418 /*************************************************************************** 419 * `char' is unsigned by default under AIX, MS-DOS, IRIX, and QNX... 420 ***************************************************************************/ 421 typedef signed char sChar; 422 #else 423 /*************************************************************************** 424 * ...and signed by default everywhere else. 425 ***************************************************************************/ 426 typedef char sChar; 427 #endif 428 429 typedef unsigned char uChar; 430 431 #if !defined(mac) 432 /**************************************************************************** 433 * `Byte' is already defined in `types.h' on a Macintosh (MPW C & Think C). 434 ****************************************************************************/ 435 typedef uChar Byte; 436 #endif 437 438 typedef uChar uByte; 439 typedef sChar sByte; 440 441 /****************************************************************************** 442 * Non-system include files. 443 ******************************************************************************/ 444 445 #include "cdf.h" 446 #include "cdfconfig.h" 447 448 #define FSEEK fseek 449 #define FTELL ftell 450 #if defined(STAT) 451 # undef STAT 452 #endif 453 #define STAT stat 454 #define FOPEN fopen 455 #define FWRITE fwrite 456 #define FREAD fread 457 #define FCLOSE fclose 458 #define FLUSH fflush 459 460 #if (_FILE_OFFSET_BITS == 64) || defined(_LARGEFILE_SOURCE) || \ 461 defined(_LARGEFILE64_SOURCE) || defined(_LARGEFILE) 462 # if defined(win32) 463 typedef __int64 OFF_T; 464 # define FSEEK64 _lseeki64 465 # define FTELL64 _telli64 466 # define FOPEN64 _open 467 # define FWRITE64 _write 468 # define FREAD64 _read 469 # define FCLOSE64 _close 470 # define FLUSH64 _commit 471 # else 472 # if defined(__MINGW32__) || defined(AIX) 473 typedef off64_t OFF_T; 474 # else 475 typedef off_t OFF_T; 476 # endif 477 # if defined(sgi) 478 # define FSEEK64 fseek64 479 # define FTELL64 ftell64 480 # else 481 # if defined(__MINGW32__) 482 # define FSEEK64 fseeko64 483 # define FTELL64 ftello64 484 # else 485 # define FSEEK64 fseeko 486 # define FTELL64 ftello 487 # endif 488 # endif 489 # if defined(__osf__) || defined(__CYGWIN__) || \ 490 defined(vms) || defined(sgi) || defined(__MINGW32__) || \ 491 defined(__FreeBSD__) || defined(macosXintel) || defined(macosXppc) || \ 492 defined(__PPC__) || defined(__DragonFly__) 493 # define FOPEN64 fopen 494 # else 495 # define FOPEN64 fopen64 496 # endif 497 # define FWRITE64 fwrite 498 # define FREAD64 fread 499 # define FCLOSE64 fclose 500 # define FLUSH64 fflush 501 # endif 502 #else 503 typedef long OFF_T; 504 #endif 505 506 /****************************************************************************** 507 * Configuration-dependent system include files. 508 ******************************************************************************/ 509 510 #if defined(MICROSOFTC_700) 511 # if INCLUDEvMEMORY 512 # include <vmemory.h> 513 # endif 514 #endif 515 516 /****************************************************************************** 517 * Debugging. 518 ******************************************************************************/ 519 520 #define Trace(msg) {printf(msg); fflush(stdout); fflush(stderr);} 521 522 /****************************************************************************** 523 * Variable argument list function prototyping. 524 ******************************************************************************/ 525 526 #if defined(STDARG) 527 # if defined(PROTOs_) 528 # define VARPROTOARGs(args) args 529 # else 530 # define VARPROTOARGs(args) () 531 # endif 532 #else 533 # if defined(PROTOs_) 534 # define VARPROTOARGs(args) () 535 # else 536 # define VARPROTOARGs(args) () 537 # endif 538 #endif 539 540 /***************************************************************************** 541 * Floating-point encodings. 542 * 1..........Sun, SGi, IBM-RS, HP, NeXT, Macintosh, PowerPC 543 * 2..........DECstation, IBM-PC, Alpha (OSF/1), Alpha (OpenVMS - IEEE_FLOAT) 544 * 3..........VAX, Alpha (OpenVMS - D_FLOAT) 545 * 4..........Alpha (OpenVMS - G_FLOAT) 546 *****************************************************************************/ 547 548 #if defined(sun) || defined(MIPSEB) || defined(IBMRS) || defined(HP) || \ 549 defined(NeXT) || defined(mac) || defined(POWERPC) 550 # define FP1cpu 551 #endif 552 553 #if defined(MIPSEL) || defined(IBMPC) || defined(alphaosf) || \ 554 defined(alphavmsI) || defined(posixSHELLalphaI) 555 # define FP2cpu 556 #endif 557 558 #if defined(vax) || defined(alphavmsD) || defined(posixSHELLalphaD) 559 # define FP3cpu 560 #endif 561 562 #if defined(alphavmsG) || defined(posixSHELLalphaG) 563 # define FP4cpu 564 #endif 565 566 /***************************************************************************** 567 * VA_START. 568 * This is necessary because of some HP9000s which don't like it when 569 * `va_start' is passed an element of a structure. It is apparently related 570 * to the version of HP-UX being used (other HP9000s are happy with the 571 * structure element being passed). 572 *****************************************************************************/ 573 574 #if defined(hpux) 575 # define VA_START(ap) { \ 576 va_list _apT_; \ 577 va_start (_apT_); \ 578 ap = _apT_; \ 579 } 580 #else 581 # define VA_START(ap) va_start(ap) 582 #endif 583 584 /***************************************************************************** 585 * Sizes/limits/constants. 586 *****************************************************************************/ 587 588 #define NO_RECORD (-1) 589 #define NO_ENTRY (-1) 590 591 #define DU_MAX_DIR_LEN 512 592 #define DU_MAX_NAME_LEN 256 593 #define DU_MAX_PATH_LEN DU_MAX_DIR_LEN + DU_MAX_NAME_LEN 594 595 #define MAX_aMODE_LEN 3 596 597 #if defined(BORLANDC) || defined(MICROSOFTC) 598 # define LIMITof64K 1 599 #else 600 # define LIMITof64K 0 601 #endif 602 603 /***************************************************************************** 604 * Compression. 605 *****************************************************************************/ 606 607 #define NUM_RLE_PARMS 1 608 #define NUM_HUFF_PARMS 1 609 #define NUM_AHUFF_PARMS 1 610 #define NUM_GZIP_PARMS 1 611 /* #define NUM_ZLIB_PARMS 1 */ 612 613 /***************************************************************************** 614 * ASCII characters. 615 * Beware when using NL and CR with MPW C. Their values are reversed from 616 * all of the other platforms/compilers. 617 *****************************************************************************/ 618 619 #define Nl '\n' /* Newline. */ 620 #define Cr '\r' /* Carriage return. */ 621 #define Bs '\b' /* Backspace. */ 622 #define Ht '\t' /* Horizontal tab. */ 623 #define NUL '\0' /* Null character. */ 624 625 /***************************************************************************** 626 * C Run-time Library redirections. 627 *****************************************************************************/ 628 629 #if defined(dos) 630 # define cfree free 631 #endif 632 633 #if defined(unix) 634 # if (defined(sun) && !defined(SOLARIS)) || defined(sgi) 635 # define memmove(dst,src,nbytes) bcopy(src,dst,nbytes) 636 # endif 637 #endif 638 639 /***************************************************************************** 640 * Range macros. 641 *****************************************************************************/ 642 643 #define INCLUSIVE(a,b,c) ((a <= b) && (b <= c)) 644 #define EXCLUSIVE(a,b,c) ((a < b) && (b < c)) 645 646 /****************************************************************************** 647 * CDFstatus checking macros. 648 * WARNING: Be careful that `status' is not an embedded function call when 649 * using `StatusWARN' (it will be called twice). 650 ******************************************************************************/ 651 652 #define StatusOK(status) ((CDFstatus) status > CDF_WARN) 653 #define StatusBAD(status) ((CDFstatus) status < CDF_WARN) 654 #define StatusERROR(status) ((CDFstatus) status < CDF_WARN) 655 #define StatusWARN(status) EXCLUSIVE(CDF_WARN,(CDFstatus) status,CDF_OK) 656 #define StatusINFO(status) ((CDFstatus) status > CDF_OK) 657 658 /***************************************************************************** 659 * TRUE/FALSE (for where they don't exist). 660 *****************************************************************************/ 661 662 #if !defined(TRUE) 663 # define TRUE 1 664 #endif 665 666 #if !defined(FALSE) 667 # define FALSE 0 668 #endif 669 670 #define LogicalTRUE ((Logical) TRUE) 671 #define LogicalFALSE ((Logical) FALSE) 672 673 /***************************************************************************** 674 * Bit macros. 675 *****************************************************************************/ 676 677 #define BITSET(a,bit) ((a & (1 << bit)) ? TRUE : FALSE) 678 #define BITCLR(a,bit) ((!(a & (1 << bit))) ? TRUE : FALSE) 679 680 #define SETBIT(a,bitN) a = a | (1 << bitN) 681 #define CLRBIT(a,bitN) a = a & ~(1 << bitN) 682 #define FLPBIT(a,bitN) a = a ^ (1 << bitN) 683 684 /***************************************************************************** 685 * Minimum/Maximum macros. 686 *****************************************************************************/ 687 688 #if !defined(MINIMUM) 689 # define MINIMUM(a,b) ((a) < (b) ? (a) : (b)) 690 #endif 691 692 #if !defined(MAXIMUM) 693 # define MAXIMUM(a,b) ((a) > (b) ? (a) : (b)) 694 #endif 695 696 #if !defined(MINIMUM64) 697 # define MINIMUM64(a,b) ((OFF_T)(a) < (OFF_T)(b) ? (OFF_T)(a) : (OFF_T)(b)) 698 #endif 699 700 #if !defined(MAXIMUM64) 701 # define MAXIMUM64(a,b) ((OFF_T)(a) > (OFF_T)(b) ? (OFF_T)(a) : (OFF_T)(b)) 702 #endif 703 704 #define MINIMUMof3(a,b,c) (MINIMUM(a,MINIMUM(b,c))) 705 #define MAXIMUMof3(a,b,c) (MAXIMUM(a,MAXIMUM(b,c))) 706 707 #define MINIMUM64of3(a,b,c) (MINIMUM64(a,MINIMUM64(b,c))) 708 #define MAXIMUM64of3(a,b,c) (MAXIMUM64(a,MAXIMUM64(b,c))) 709 710 /***************************************************************************** 711 * ONEof/PICKfrom macros. 712 *****************************************************************************/ 713 714 #define ONEof2(a,b1,b2) ((a == b1) || (a == b2)) 715 #define ONEof3(a,b1,b2,b3) ((a == b1) || (a == b2) || (a == b3)) 716 #define ONEof6(a,b1,b2,b3,b4,b5,b6) \ 717 ((a == b1) || (a == b2) || (a == b3) || (a == b4) || (a == b5) || (a == b6)) 718 719 #define PICKfrom3(a,b1,c1,b2,c2,b3,c3) \ 720 (BOO(a == b1,c1,BOO(a == b2,c2,BOO(a == b3,c3,0)))) 721 722 /****************************************************************************** 723 * BOO. 724 * Choose one of two things based on a boolean value. 725 ******************************************************************************/ 726 727 #define BOO(b,t,f) (b ? t : f) 728 729 /****************************************************************************** 730 * NULstring. 731 * Macro to check if a null-string (length of zero). 732 ******************************************************************************/ 733 734 #define NULstring(string) (string[0] == NUL) 735 736 /****************************************************************************** 737 * MakeNUL. 738 * Macro which makes a string a null-string (length of 0). 739 ******************************************************************************/ 740 741 #define MakeNUL(string) strcpy(string,"") 742 743 /****************************************************************************** 744 * ROWmajor/COLmajor. 745 ******************************************************************************/ 746 747 #define ROWmajor(majority) (majority == ROW_MAJOR) 748 #define COLmajor(majority) (majority == COLUMN_MAJOR) 749 750 /****************************************************************************** 751 * CHECKsum. 752 ******************************************************************************/ 753 754 #define CHECKsum(checksum) (checksum != NO_CHECKSUM) 755 756 /****************************************************************************** 757 * STRINGdataType. 758 * Macro to check if a character string data type. 759 ******************************************************************************/ 760 761 #define STRINGdataType(dataType) \ 762 (dataType == CDF_CHAR || dataType == CDF_UCHAR) 763 764 /****************************************************************************** 765 * EPOCHdataType. 766 * Macro to check if an EPOCH data type. 767 ******************************************************************************/ 768 769 #define EPOCHdataType(dataType) (dataType == CDF_EPOCH) 770 771 /****************************************************************************** 772 * EPOCH16dataType. 773 * Macro to check if an EPOCH16 data type. 774 ******************************************************************************/ 775 776 #define EPOCH16dataType(dataType) (dataType == CDF_EPOCH16) 777 778 /****************************************************************************** 779 * EofS (End of String). 780 * Macro which expands to a pointer to the NUL character at the end of a 781 * character string. 782 ******************************************************************************/ 783 784 #define EofS(string) &string[strlen(string)] 785 786 /****************************************************************************** 787 * ASSIGNnotNULL & ASSIGNnotNULLarray. 788 * These is used in those cases where the caller of a routine has the option 789 * of passing in a NULL pointer for those parameters for which a returned 790 * value is not desired. 791 ******************************************************************************/ 792 793 #define ASSIGNnotNULL(ptr,value) if (ptr != NULL) *ptr = value; 794 795 #define ASSIGNnotNULLarray(ptr,count,values) \ 796 if (ptr != NULL) { \ 797 int _i_; for (_i_ = 0; _i_ < count; _i_++) ptr[_i_] = values[_i_]; \ 798 } 799 800 /****************************************************************************** 801 * Entry type constants/macros. 802 ******************************************************************************/ 803 804 #define gENTRYt 1 805 #define rENTRYt 2 806 #define zENTRYt 3 807 808 #define E3(type,itemG,itemR,itemZ) \ 809 (BOO(type == gENTRYt, \ 810 itemG,BOO(type == rENTRYt, \ 811 itemR,BOO(type == zENTRYt,itemZ,0)))) 812 813 #define E3p(E,g,r,z) \ 814 (BOO(E == g,gENTRYt,BOO(E == r,rENTRYt,BOO(E == z,zENTRYt,0)))) 815 816 /****************************************************************************** 817 * TOObigIBMpc. Check for overflow on IBM PCs (running MS-DOS) because of 64Kb 818 * limit on segment sizes. 819 ******************************************************************************/ 820 821 #define TOObigIBMpc(size) ((long) size > 65535L) 822 823 /****************************************************************************** 824 * ARRAYtoVALUE. 825 ******************************************************************************/ 826 827 #define ARRAYtoVALUE(array,value,count) \ 828 {int _i_; for (_i_ = 0; _i_ < count; _i_++) array[_i_] = value;} 829 830 /****************************************************************************** 831 * ARRAYtoARRAY. 832 ******************************************************************************/ 833 834 #define ARRAYtoARRAY(dst,src,count) \ 835 {int _i_; for (_i_ = 0; _i_ < count; _i_++) dst[_i_] = src[_i_];} 836 837 /****************************************************************************** 838 * vSTATS structure. 839 ******************************************************************************/ 840 841 typedef struct vSTATSstruct { 842 int maxBuffers; /* Maximum number of cache buffers to be used. */ 843 int nBuffers; /* Actual number of cache buffers being used. */ 844 long nV_reads; /* Number of calls to `V_read'. */ 845 long nV_writes; /* Number of calls to `V_write'. */ 846 long nBlockReads; /* Number of file blocks which have been read. */ 847 long nBlockWrites; /* Number of file blocks which have been written. */ 848 long nPageIns; /* Number of blocks paged in from the file. */ 849 long nPageOuts; /* Number of blocks paged out to the file. */ 850 } vSTATS; 851 852 /****************************************************************************** 853 * Entry items... 854 ******************************************************************************/ 855 856 #define ENTRY(eT) E3(eT,gENTRY_,rENTRY_,zENTRY_) 857 #define ENTRY_DATA(eT) E3(eT,gENTRY_DATA_,rENTRY_DATA_,zENTRY_DATA_) 858 #define ENTRY_NAME(eT) E3(eT,0L,rENTRY_NAME_,zENTRY_NAME_) 859 #define ENTRY_EXISTENCE(eT) E3(eT,gENTRY_EXISTENCE_, \ 860 rENTRY_EXISTENCE_, \ 861 zENTRY_EXISTENCE_) 862 #define ENTRY_DATATYPE(eT) E3(eT,gENTRY_DATATYPE_, \ 863 rENTRY_DATATYPE_, \ 864 zENTRY_DATATYPE_) 865 #define ENTRY_NUMELEMS(eT) E3(eT,gENTRY_NUMELEMS_, \ 866 rENTRY_NUMELEMS_, \ 867 zENTRY_NUMELEMS_) 868 #define ENTRY_DATASPEC(eT) E3(eT,gENTRY_DATASPEC_, \ 869 rENTRY_DATASPEC_, \ 870 zENTRY_DATASPEC_) 871 #define CURENTRY_EXISTENCE(eT) E3(eT,CURgENTRY_EXISTENCE_, \ 872 CURrENTRY_EXISTENCE_, \ 873 CURzENTRY_EXISTENCE_) 874 875 /****************************************************************************** 876 * Variable items... 877 ******************************************************************************/ 878 879 #define VAR(zOp) BOO(zOp,zVAR_,rVAR_) 880 #define VAR_NAME(zOp) BOO(zOp,zVAR_NAME_,rVAR_NAME_) 881 #define VAR_PADVALUE(zOp) BOO(zOp,zVAR_PADVALUE_,rVAR_PADVALUE_) 882 #define VAR_DATATYPE(zOp) BOO(zOp,zVAR_DATATYPE_,rVAR_DATATYPE_) 883 #define VAR_NUMELEMS(zOp) BOO(zOp,zVAR_NUMELEMS_,rVAR_NUMELEMS_) 884 #define VAR_RECVARY(zOp) BOO(zOp,zVAR_RECVARY_,rVAR_RECVARY_) 885 #define VAR_DIMVARYS(zOp) BOO(zOp,zVAR_DIMVARYS_,rVAR_DIMVARYS_) 886 #define VAR_DATA(zOp) BOO(zOp,zVAR_DATA_,rVAR_DATA_) 887 #define VAR_HYPERDATA(zOp) BOO(zOp,zVAR_HYPERDATA_,rVAR_HYPERDATA_) 888 #define VAR_SEQDATA(zOp) BOO(zOp,zVAR_SEQDATA_,rVAR_SEQDATA_) 889 #define VAR_SEQPOS(zOp) BOO(zOp,zVAR_SEQPOS_,rVAR_SEQPOS_) 890 #define VAR_MAXREC(zOp) BOO(zOp,zVAR_MAXREC_,rVAR_MAXREC_) 891 #define VAR_MAXallocREC(zOp) BOO(zOp,zVAR_MAXallocREC_,rVAR_MAXallocREC_) 892 #define VAR_DATASPEC(zOp) BOO(zOp,zVAR_DATASPEC_,rVAR_DATASPEC_) 893 #define VAR_INITIALRECS(zOp) BOO(zOp,zVAR_INITIALRECS_,rVAR_INITIALRECS_) 894 #define VAR_nINDEXRECORDS(zOp) BOO(zOp,zVAR_nINDEXRECORDS_,rVAR_nINDEXRECORDS_) 895 #define VAR_nINDEXENTRIES(zOp) BOO(zOp,zVAR_nINDEXENTRIES_,rVAR_nINDEXENTRIES_) 896 #define VAR_EXISTENCE(zOp) BOO(zOp,zVAR_EXISTENCE_,rVAR_EXISTENCE_) 897 #define VAR_NUMBER(zOp) BOO(zOp,zVAR_NUMBER_,rVAR_NUMBER_) 898 #define VAR_CACHESIZE(zOp) BOO(zOp,zVAR_CACHESIZE_,rVAR_CACHESIZE_) 899 #define VAR_ALLOCATERECS(zOp) BOO(zOp,zVAR_ALLOCATERECS_,rVAR_ALLOCATERECS_) 900 #define VAR_COMPRESSION(zOp) BOO(zOp,zVAR_COMPRESSION_,rVAR_COMPRESSION_) 901 #define VAR_SPARSERECORDS(zOp) BOO(zOp,zVAR_SPARSERECORDS_,rVAR_SPARSERECORDS_) 902 #define VAR_SPARSEARRAYS(zOp) BOO(zOp,zVAR_SPARSEARRAYS_,rVAR_SPARSEARRAYS_) 903 #define VAR_ALLOCATEBLOCK(zOp) BOO(zOp,zVAR_ALLOCATEBLOCK_,rVAR_ALLOCATEBLOCK_) 904 #define VAR_NUMRECS(zOp) BOO(zOp,zVAR_NUMRECS_,rVAR_NUMRECS_) 905 #define VAR_NUMallocRECS(zOp) BOO(zOp,zVAR_NUMallocRECS_,rVAR_NUMallocRECS_) 906 #define VAR_ALLOCATEDFROM(zOp) BOO(zOp,zVAR_ALLOCATEDFROM_,rVAR_ALLOCATEDFROM_) 907 #define VAR_ALLOCATEDTO(zOp) BOO(zOp,zVAR_ALLOCATEDTO_,rVAR_ALLOCATEDTO_) 908 #define VAR_nINDEXLEVELS(zOp) BOO(zOp,zVAR_nINDEXLEVELS_,rVAR_nINDEXLEVELS_) 909 #define VAR_RECORDS(zOp) BOO(zOp,zVAR_RECORDS_,rVAR_RECORDS_) 910 #define VAR_BLOCKINGFACTOR(zOp) BOO(zOp,zVAR_BLOCKINGFACTOR_, \ 911 rVAR_BLOCKINGFACTOR_) 912 #define VAR_RESERVEPERCENT(zOp) BOO(zOp,zVAR_RESERVEPERCENT_, \ 913 rVAR_RESERVEPERCENT_) 914 915 #define VARs_MAXREC(zOp) BOO(zOp,zVARs_MAXREC_,rVARs_MAXREC_) 916 #define VARs_RECDATA(zOp) BOO(zOp,zVARs_RECDATA_,rVARs_RECDATA_) 917 #define VARs_RECNUMBER(zOp) BOO(zOp,zVARs_RECNUMBER_,rVARs_RECNUMBER_) 918 #define VARs_CACHESIZE(zOp) BOO(zOp,zVARs_CACHESIZE_,rVARs_CACHESIZE_) 919 920 /****************************************************************************** 921 * Function prototypes for routines contained in the CDF library but also used 922 * by the toolkit/toolbox/IDL. 923 ******************************************************************************/ 924 925 #if defined(__cplusplus) 926 extern "C" { 927 #endif 928 VISIBLE_PREFIX void *cdf_AllocateMemory PROTOARGs(( 929 size_t nBytes, void (*fatalFnc) PROTOARGs((char *msg)) 930 )); 931 VISIBLE_PREFIX void *cdf_ReallocateMemory PROTOARGs(( 932 void *ptr, size_t nBytes, void (*fatalFnc) PROTOARGs((char *msg)) 933 )); 934 VISIBLE_PREFIX int cdf_FreeMemory PROTOARGs(( 935 void *ptr, void (*fatalFnc) PROTOARGs((char *msg)) 936 )); 937 VISIBLE_PREFIX int cdf_FreeMemoryX PROTOARGs(( 938 void *ptr, void (*fatalFnc) PROTOARGs((char *msg)), int loc 939 )); 940 VISIBLE_PREFIX void *CallocateMemory PROTOARGs(( 941 size_t nObjects, size_t objSize, void (*fatalFnc) PROTOARGs((char *msg)) 942 )); 943 VISIBLE_PREFIX char *strcpyX PROTOARGs((char *dst, char *src, size_t max)); 944 VISIBLE_PREFIX char *strcatX PROTOARGs((char *dst, char *src, size_t max)); 945 #if defined(__cplusplus) 946 } 947 #endif 948 949 VISIBLE_PREFIX int CDFelemSize PROTOARGs((long)); 950 VISIBLE_PREFIX void ClearBytes PROTOARGs(( 951 void *buffer, int firstByte, int lastByte 952 )); 953 VISIBLE_PREFIX char *catchrX PROTOARGs((char *dst, int src, size_t max)); 954 VISIBLE_PREFIX char *prependX PROTOARGs((char *dst, char *src, size_t max)); 955 VISIBLE_PREFIX Logical IsReg PROTOARGs((char *)); 956 VISIBLE_PREFIX void ExpandPath PROTOARGs(( 957 char *shortPath, char longPath[DU_MAX_PATH_LEN] 958 )); 959 VISIBLE_PREFIX void TimeStamp PROTOARGs((char *)); 960 VISIBLE_PREFIX int strcmpITB PROTOARGs((char *, char *)); 961 VISIBLE_PREFIX Logical NegativeZeroReal8 PROTOARGs((double *value)); 962 VISIBLE_PREFIX Logical NegativeZeroReal4 PROTOARGs((float *value)); 963 VISIBLE_PREFIX void MakeUpperString PROTOARGs((char *string)); 964 VISIBLE_PREFIX void MakeLowerString PROTOARGs((char *string)); 965 VISIBLE_PREFIX void ROWtoCOL PROTOARGs(( 966 void *iBuffer, void *oBuffer, long numDims, long dimSizes[], long nValueBytes 967 )); 968 VISIBLE_PREFIX void COLtoROW PROTOARGs(( 969 void *iBuffer, void *oBuffer, long numDims, long dimSizes[], long nValueBytes 970 )); 971 VISIBLE_PREFIX void INCRindicesROW PROTOARGs(( 972 long numDims, long *dimSizes, long *indices 973 )); 974 VISIBLE_PREFIX void INCRindicesCOL PROTOARGs(( 975 long numDims, long *dimSizes, long *indices 976 )); 977 VISIBLE_PREFIX Logical Trailer PROTOARGs((char *string, char *trailer)); 978 VISIBLE_PREFIX int MakeLower PROTOARGs((int c)); 979 VISIBLE_PREFIX int MakeUpper PROTOARGs((int c)); 980 VISIBLE_PREFIX int Printable PROTOARGs((int c)); 981 VISIBLE_PREFIX int UpperCase PROTOARGs((int c)); 982 VISIBLE_PREFIX int LowerCase PROTOARGs((int c)); 983 VISIBLE_PREFIX int Alphabetic PROTOARGs((int c)); 984 VISIBLE_PREFIX int Decimal PROTOARGs((int c)); 985 VISIBLE_PREFIX int Spacing PROTOARGs((int c)); 986 VISIBLE_PREFIX int Visible PROTOARGs((int c)); 987 VISIBLE_PREFIX CDFid Int32ToCDFid PROTOARGs((Int32 id)); 988 VISIBLE_PREFIX Int32 CDFidToInt32 PROTOARGs((CDFid id)); 989 VISIBLE_PREFIX Logical sX PROTOARGs((CDFstatus cStatus, CDFstatus *pStatus)); 990 VISIBLE_PREFIX void AppendToDir PROTOARGs((char *, char *)); 991 VISIBLE_PREFIX int CompressionParmsCount PROTOARGs((Int32 cType)); 992 VISIBLE_PREFIX int SparsenessParmsCount PROTOARGs((Int32 sArraysType)); 993 VISIBLE_PREFIX int MinInt PROTOARGs((int a, int b)); 994 VISIBLE_PREFIX Int32 MinInt32 PROTOARGs((Int32 a, Int32 b)); 995 VISIBLE_PREFIX long MinLong PROTOARGs((long a, long b)); 996 VISIBLE_PREFIX OFF_T MinLongLong PROTOARGs((OFF_T a, OFF_T b)); 997 VISIBLE_PREFIX int MaxInt PROTOARGs((int a, int b)); 998 VISIBLE_PREFIX Int32 MaxInt32 PROTOARGs((Int32 a, Int32 b)); 999 VISIBLE_PREFIX long MaxLong PROTOARGs((long a, long b)); 1000 VISIBLE_PREFIX OFF_T MaxLongLong PROTOARGs((OFF_T a, OFF_T b)); 1001 VISIBLE_PREFIX int EndsWith PROTOARGs((char *s1, char *s2)); 1002 VISIBLE_PREFIX int EndsWithIgCase PROTOARGs((char *s1, char *s2)); 1003 VISIBLE_PREFIX int StrLaststr PROTOARGs((char *s1, char *s2)); 1004 VISIBLE_PREFIX int StrLaststrIgCase PROTOARGs((char *s1, char *s2)); 1005 VISIBLE_PREFIX void RemoveCDFFileExtension PROTOARGs(( 1006 char *fileName, char *dstPath 1007 )); 1008 1009 #if defined(mac) 1010 STATICforIDL Logical MacDirSpecified PROTOARGs(( 1011 char *path, short *vRefNum, long *dirID 1012 )); 1013 STATICforIDL char *PstrcpyX PROTOARGs((char *dst, char *src, size_t max)); 1014 STATICforIDL char *PstrcatX PROTOARGs((char *dst, char *src, size_t max)); 1015 STATICforIDL char *PprependX PROTOARGs((char *dst, char *src, size_t max)); 1016 # if defined(MPW_C) 1017 STATICforIDL uChar *CtoPstr PROTOARGs((char *string)); 1018 STATICforIDL char *PtoCstr PROTOARGs((uChar *string)); 1019 # endif 1020 #endif 1021 1022 /*****************************************************************************/ 1023 1024 #endif 1025