home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / src / dfi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  12.0 KB  |  335 lines

  1. /***************************************************************************
  2. *
  3. *
  4. *                         NCSA HDF version 3.2r2
  5. *                            October 30, 1992
  6. *
  7. * NCSA HDF Version 3.2 source code and documentation are in the public
  8. * domain.  Specifically, we give to the public domain all rights for future
  9. * licensing of the source code, all resale rights, and all publishing rights.
  10. *
  11. * We ask, but do not require, that the following message be included in all
  12. * derived works:
  13. *
  14. * Portions developed at the National Center for Supercomputing Applications at
  15. * the University of Illinois at Urbana-Champaign, in collaboration with the
  16. * Information Technology Institute of Singapore.
  17. *
  18. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  19. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  20. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  21. *
  22. ****************************************************************************
  23. */
  24.  
  25. /*
  26. $Header: /hdf/hdf/v3.2r2/src/RCS/dfi.h,v 1.1 1992/08/25 21:40:44 koziol beta koziol $
  27.  
  28. $Log: dfi.h,v $
  29.  * Revision 1.1  1992/08/25  21:40:44  koziol
  30.  * Initial revision
  31.  *
  32. */
  33. /*-----------------------------------------------------------------------------
  34.  * File:    dfi.h
  35.  * Purpose: HDF internal header file
  36.  * Invokes: stdio.h, sys/file.h
  37.  * Contents: 
  38.  *  Compilation parameters
  39.  *  Machine-dependent definitions
  40.  *  Flexibility definitions: i/o buffering, dynamic memory, structure i/o
  41.  *  Size parameters
  42.  * Remarks: To port to a new system, only dfi.h and Makefile need be modified.
  43.  *          This file is included with user programs, but users do not see it.
  44.  *---------------------------------------------------------------------------*/
  45.  
  46.  
  47. #ifndef DFI_H
  48. #define DFI_H
  49.  
  50. /*--------------------------------------------------------------------------*/
  51. /*          Compilation Parameters for Flexibility and Portability          */
  52.  
  53. /* modify this line for buffered/unbuffered i/o */
  54. #define    DF_BUFFIO
  55.  
  56. /* modify this line for dynamic/static memory allocation */
  57. #define    DF_DYNAMIC
  58.  
  59. /* modify this line if structures cannot be read/written as is */
  60. #undef    DF_STRUCTOK        /* leave it this way - hdfsh expects it */
  61.  
  62. #ifdef PERM_OUT
  63. /* Current version number */
  64. #define    DFVERSION   3.20
  65. #endif /* PERM_OUT */
  66.  
  67. /*--------------------------------------------------------------------------*/
  68. /*                      Machine dependencies                                */
  69. /*--------------------------------------------------------------------------*/
  70.  
  71. #ifdef IRIS4
  72. #undef DF_STRUCTOK
  73. #include <sys/types.h>
  74. #include <sys/file.h>               /* for unbuffered i/o stuff */
  75. #ifndef DFmovmem
  76. #define    DFmovmem(from, to, len) bcopy(from, to, len)
  77. #endif /* DFmovmem */
  78. #ifndef DF_STRUCTOK
  79. #define    UINT16READ(p, x)    { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  80. #define INT16READ(p, x)     { x = (*p++)<<8; x |= (*p++) & 255; }
  81. #define INT32READ(p, x)     { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  82.                                 x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  83. #define UINT16WRITE(p, x)   { *p++ = (x>>8) & 255; *p++ = x & 255; }
  84. #define INT16WRITE(p, x)    { *p++ = (x>>8) & 255; *p++ = x & 255; }
  85. #define INT32WRITE(p, x)    { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;   \
  86.                                 *p++ = (x>>8) & 255; *p++ = x & 255; }
  87. #endif /*DF_STRUCTOK*/
  88. #define DF_CREAT(name, prot) creat(name, prot)
  89. #ifndef DF_MT
  90. #define DF_MT   DFMT_IRIS4
  91. #endif /* DF_MT  */
  92. #endif /*IRIS4*/
  93.  
  94.  
  95. #ifdef IBM6000  /* NOTE: IBM6000 defines are same as for SUN */
  96. #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
  97. #undef DF_STRUCTOK
  98. #endif
  99. #include <sys/file.h>               /* for unbuffered i/o stuff */
  100. #define DFmovmem(from, to, len) memcpy(to, from, len)
  101. #ifndef DF_STRUCTOK
  102. #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  103. #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  104. #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  105.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  106. #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  107. #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  108. #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  109.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  110. #endif /*DF_STRUCTOK*/
  111. #define DF_CREAT(name, prot) creat(name, prot)
  112. #define DF_MT   DFMT_IBM6000
  113. #endif /*IBM6000*/
  114.  
  115.  
  116. #ifdef MAC
  117. #undef DF_BUFFIO        /* use unbuffered i/o */
  118. #include <memory.h>             /* malloc stuff for MPW 3.0 */
  119. #include <fcntl.h>              /* unbuffered IO stuff for MPW 3.0 */
  120. #ifdef THINK_C                  /* for LightSpeed C */
  121. #include <unix.h>
  122. #else /*THINK_C                   MPW, possibly others */
  123. #include <Files.h>              /* for unbuffered i/o stuff */
  124. #endif /*THINK_C*/
  125. #define    DF_CAPFNAMES            /* fortran names are in all caps */
  126. #define DF_DYNAMIC        /* use dynamic allocation */
  127. #ifdef THINK_C                   /* LightSpeed C does not have memcpy */
  128. #define DFmovmem(from, to, len) DFImemcopy(from, to, len)
  129. #else /*THINK_C*/
  130. #define DFmovmem(from, to, len) memcpy(to, from, len)
  131. #endif /*THINK_C*/
  132. #define malloc(x)   NewPtr((Size)   (x))    /* don't use malloc on the Mac */
  133. #define free(x)     DisposPtr((Ptr) (x))    /* don't use free on the Nac   */ 
  134. #undef DF_STRUCTOK
  135. #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  136. #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  137. #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  138.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  139. #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  140. #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  141. #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  142.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  143. #define DF_CREAT(name, prot) mopen(name, O_WRONLY|O_TRUNC|O_CREAT)
  144. #define DF_MT   DFMT_MAC
  145. #endif /*MAC*/
  146.  
  147. #ifdef VMS
  148. /*#undef DF_BUFFIO should be buff !!!!*/
  149.    /* use only unbuff i/o - buff doesn't work! */
  150. #ifndef DFopen                  /* avoid double includes */
  151. /* #include "dfivms.h" */
  152. #endif /*DFopen*/
  153. #undef DF_STRUCTOK
  154. #define DF_CAPFNAMES            /* fortran names are in all caps */
  155. #include <file.h>               /* for unbuffered i/o stuff */
  156. #define DFmovmem(from, to, len) memcpy(to, from, len)
  157. #ifndef DF_STRUCTOK
  158. #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  159. #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  160. #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  161.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  162. #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  163. #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  164. #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  165.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  166. #endif /*DF_STRUCTOK*/
  167. #define DF_CREAT(name, prot) creat(name, prot)
  168. #define DF_MT   DFMT_VAX
  169. #endif /*VMS*/
  170.  
  171. #ifdef APOLLO
  172. #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
  173. #undef DF_STRUCTOK
  174. #endif
  175. #include <sys/file.h>               /* for unbuffered i/o stuff */
  176. #define int8 char
  177. #define uint8 unsigned char
  178. #define int16 short int
  179. #define uint16 unsigned short int
  180. #define int32 long int
  181. #define uint32 unsigned long int
  182. #define float32 float
  183. #define DFmovmem(from, to, len) memcpy(to, from, len)
  184. #ifndef DF_STRUCTOK
  185. #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  186. #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  187. #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  188.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  189. #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  190. #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  191. #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  192.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  193. #endif /*DF_STRUCTOK*/
  194. #define DF_CREAT(name, prot) creat(name, prot)
  195. #define DF_MT   DFMT_APOLLO
  196. #endif /*APOLLO*/
  197.  
  198.  
  199. /*--------------------------------------------------------------------------*/
  200. /*                      Flexibility parameters                              */
  201. #ifdef MAC            /* MAC specific file manager calls */
  202. #    define DF_OPEN(x,y) mopen(x,y)
  203. #    define DF_CLOSE(x) mclose(x)
  204. #    define DF_SEEK(x,y,z) mlseek(x,y,z)
  205. #    define DF_SKEND(x,y,z) mlseek(x,-1*y,z)
  206. #    define DF_TELL(x) mlseek(x,0L,1)
  207. #    define DF_READ(a,b,c,d) mread(d,a,b*c)
  208. #    define DF_WRITE(a,b,c,d) mwrite(d,a,b*c)
  209. #    define DF_FLUSH(a)            /* no need to flush */
  210. #    define DF_RDACCESS 0        /* dummy */
  211. #    define DF_WRACCESS 0        /* dummy */
  212. #    define DF_OPENERR(f)    ((f) == -1)
  213. #else /* !MAC */
  214. #ifdef DF_BUFFIO            /* set all calls to do buffered I/O */
  215. #define DF_OPEN(x,y) fopen(x,y)
  216. #define DF_CLOSE(x) fclose(x)
  217. #define DF_SEEK(x,y,z) fseek(x,y,z)
  218. #define DF_SKEND(x,y,z) fseek(x,y,z)
  219. #define DF_TELL(x) ftell(x)
  220. #define DF_READ(a,b,c,d) fread(a,b,c,d)
  221. #define DF_WRITE(a,b,c,d) fwrite(a,b,c,d)
  222. #define DF_FLUSH(a) fflush(a)
  223. #define DF_OPENERR(f)    (!(f))
  224. #ifdef PC
  225. #define DF_RDACCESS "rb"
  226. #define DF_WRACCESS "rb+"
  227. #else /*PC*/
  228. #define DF_RDACCESS "r"
  229. #define DF_WRACCESS "r+"
  230. #endif /*PC*/
  231.  
  232. #else /*DF_BUFFIO         unbuffered i/o */
  233. #ifdef PC
  234. #ifdef WIN3
  235. #define DF_OPEN(x,y) _lopen((LPSTR)(x),(int)(y))
  236. #define DF_CLOSE(x) _lclose((int)(x))
  237. #define DF_SEEK(x,y,z) _llseek((int)(x),(LONG)(y),(int)(z))
  238. #define DF_SKEND(x,y,z) _llseek((int)(x),(LONG)(-1*(y)),(int)(z))
  239. #define DF_TELL(x) _llseek((int)(x),(LONG)0L,(int)1)
  240. #define DF_READ(a,b,c,d) _lread((int)(d),(LPSTR)(a),(WORD)((WORD)(b)*(WORD)(c)))
  241. #define DF_WRITE(a,b,c,d) _lwrite((int)(d),(LPSTR)(a),(WORD)((WORD)(b)*(WORD)(c)))
  242. #define DF_OPENERR(f)   ((f) == -1)
  243. #define DF_FLUSH(a)                             /* no need to flush */
  244. #define DF_RDACCESS OF_READ
  245. #define DF_WRACCESS OF_READWRITE
  246. #else
  247. #define DF_OPEN(x,y) open(x,y,S_IWRITE|S_IREAD)
  248. #define DF_CLOSE(x) close(x)
  249. #define DF_SEEK(x,y,z) lseek(x,y,z)
  250. #define DF_SKEND(x,y,z) lseek(x,-1*y,z)
  251. #define DF_TELL(x) lseek(x,0L,1)
  252. #define DF_READ(a,b,c,d) read(d,a,b*c)
  253. #define DF_WRITE(a,b,c,d) write(d,a,b*c)
  254. #define DF_OPENERR(f)   ((f) == -1)
  255. #define DF_FLUSH(a)                             /* no need to flush */
  256. #define DF_RDACCESS O_RDONLY | O_BINARY
  257. #define DF_WRACCESS O_RDWR | O_BINARY
  258. #endif
  259. #else
  260. #define DF_OPEN(x,y) open(x,y)
  261. #define DF_CLOSE(x) close(x)
  262. #define DF_SEEK(x,y,z) lseek(x,y,z)
  263. #define DF_SKEND(x,y,z) lseek(x,-1*y,z)
  264. #define DF_TELL(x) lseek(x,0L,1)
  265. #define DF_READ(a,b,c,d) read(d,a,b*c)
  266. #define DF_WRITE(a,b,c,d) write(d,a,b*c)
  267. #define DF_OPENERR(f)    ((f) == -1)
  268. #define DF_FLUSH(a)                             /* no need to flush */
  269. #define DF_RDACCESS O_RDONLY
  270. #define DF_WRACCESS O_RDWR
  271. #endif /* PC */
  272. #endif /* DF_BUFFIO */
  273. #endif /* !MAC */
  274.  
  275.  
  276.     /* if not allocating memory dynamically, need buffer for compression */
  277. #ifndef DF_DYNAMIC
  278. #define DF_TBUF
  279. #define DF_TBUFSZ    10000    /* buffer size */
  280. #endif /*DF_DYNAMIC*/
  281.  
  282.     /* if reading/writing structures not ok, need buffer for conversion */
  283. #ifdef PERM_OUT
  284. #ifndef DF_TBUF
  285. #ifndef DF_STRUCTOK
  286. #define DF_TBUF
  287. #define DF_TBUFSZ    512    /* buffer size can be smaller */
  288. #endif /*DF_STRUCTOK*/
  289. #endif /*DF_TBUF*/
  290.  
  291. /* 
  292. MACRO FCALLKEYW for any special fortran-C stub keyword
  293.  
  294. MacIntosh MPW LS-fortran needs pascal since it can interface best with
  295. pascal functions
  296. */
  297. #if defined(MAC)        /* with LS FORTRAN */
  298. #   define FCALLKEYW    pascal
  299. #else /* !MAC */
  300. #   define FCALLKEYW    /*NONE*/
  301. #endif
  302.  
  303. #ifndef PC
  304. #ifndef MAC
  305. #ifndef IRIS4
  306. #ifndef IBM6000
  307. #ifndef CONVEX
  308. #ifndef UNICOS
  309. char *strncpy();
  310. char *strcpy();
  311. char *memcpy();
  312. char *malloc();
  313. #endif /* !UNICOS */
  314. #endif /* !CONVEX */
  315. #endif /* !IBM6000 */
  316. #endif /* !IRIS4 */
  317. #endif /* !MAC */
  318. #endif /* !PC */
  319. #endif /* PERM_OUT */
  320.  
  321.  
  322. /*--------------------------------------------------------------------------*/
  323. /*                          Size parameters                                 */
  324. #ifdef PERM_OUT
  325. #define DF_MAXDFS           32  /* How many DF's can be open at once */
  326. #define DF_DEFAULTDDS       16  /* How many DD's a file has by default */
  327. #define DF_MAXFNLEN         256 /* maximum length of filename parameters */
  328. #endif /* PERM_OUT */
  329.  
  330. #ifndef FILE
  331. #include <stdio.h>
  332. #endif /*FILE*/
  333.  
  334. #endif /* DFI_H */
  335.