MISR Toolkit  1.5.1
dfi.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF. The full HDF copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the files COPYING and Copyright.html. COPYING can be found at the root *
9  * of the source code distribution tree; Copyright.html can be found at *
10  * http://hdfgroup.org/products/hdf4/doc/Copyright.html. If you do not have *
11  * access to either file, you may request a copy from help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* $Id: dfi.h 4932 2007-09-07 17:17:23Z bmribler $ */
15 
16 /*-----------------------------------------------------------------------------
17  * File: dfi.h
18  * Purpose: HDF internal header file
19  * Invokes: stdio.h, sys/file.h
20  * Contents:
21  * Compilation parameters
22  * Machine-dependent definitions
23  * Flexibility definitions: i/o buffering, dynamic memory, structure i/o
24  * Size parameters
25  * Remarks: To port to a new system, only dfi.h and Makefile need be modified.
26  * This file is included with user programs, but users do not see it.
27  *---------------------------------------------------------------------------*/
28 
29 #ifndef DFI_H
30 #define DFI_H
31 
32 /*--------------------------------------------------------------------------*/
33 /* Compilation Parameters for Flexibility and Portability */
34 
35 /* modify this line for buffered/unbuffered i/o */
36 #define DF_BUFFIO
37 
38 /* modify this line for dynamic/static memory allocation */
39 #define DF_DYNAMIC
40 
41 /* modify this line if structures cannot be read/written as is */
42 #undef DF_STRUCTOK /* leave it this way - hdfsh expects it */
43 
44 /*--------------------------------------------------------------------------*/
45 /* Machine dependencies */
46 /*--------------------------------------------------------------------------*/
47 
48 #ifdef IRIX
49 #undef DF_STRUCTOK
50 #include <sys/types.h>
51 #include <sys/file.h> /* for unbuffered i/o stuff */
52 #ifndef DFmovmem
53 #define DFmovmem(from, to, len) bcopy(from, to, len)
54 #endif /* DFmovmem */
55 #ifndef DF_STRUCTOK
56 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
57 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
58 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
59  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
60 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
61 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
62 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
63  *p++ = (x>>8) & 255; *p++ = x & 255; }
64 #endif /*DF_STRUCTOK */
65 #define DF_CREAT(name, prot) creat(name, prot)
66 #ifndef DF_MT
67 #define DF_MT DFMT_IRIX
68 #endif /* DF_MT */
69 #endif /*IRIX */
70 
71 #ifdef IBM6000 /* NOTE: IBM6000 defines are same as for SUN */
72 #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
73 #undef DF_STRUCTOK
74 #endif
75 #include <sys/file.h> /* for unbuffered i/o stuff */
76 #define DFmovmem(from, to, len) memcpy(to, from, len)
77 #ifndef DF_STRUCTOK
78 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
79 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
80 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
81  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
82 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
83 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
84 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
85  *p++ = (x>>8) & 255; *p++ = x & 255; }
86 #endif /*DF_STRUCTOK */
87 #define DF_CREAT(name, prot) creat(name, prot)
88 #define DF_MT DFMT_IBM6000
89 #endif /*IBM6000 */
90 
91 #if defined (MAC) || defined (macintosh) || defined (SYMANTEC_C)
92 #undef DF_BUFFIO /* use unbuffered i/o */
93 #include <memory.h> /* malloc stuff for MPW 3.0 */
94 #include <fcntl.h> /* unbuffered IO stuff for MPW 3.0 */
95 #ifdef SYMANTEC_C /* for LightSpeed C */
96 #include <unix.h>
97 #else /*SYMANTEC_C MPW, possibly others */
98 #include <Files.h> /* for unbuffered i/o stuff */
99 #endif /*SYMANTEC_C */
100 #define DF_CAPFNAMES /* fortran names are in all caps */
101 #define DF_DYNAMIC /* use dynamic allocation */
102 #ifdef SYMANTEC_C /* LightSpeed C does not have memcpy */
103 #define DFmovmem(from, to, len) DFImemcopy(from, to, len)
104 #else /*SYMANTEC_C */
105 #define DFmovmem(from, to, len) memcpy(to, from, len)
106 #endif /*SYMANTEC_C */
107 #define malloc(x) NewPtr((Size) (x)) /* don't use malloc on the Mac */
108 #define free(x) DisposPtr((Ptr) (x)) /* don't use free on the Nac */
109 #undef DF_STRUCTOK
110 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
111 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
112 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
113  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
114 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
115 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
116 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
117  *p++ = (x>>8) & 255; *p++ = x & 255; }
118 #define DF_CREAT(name, prot) mopen(name, O_WRONLY|O_TRUNC|O_CREAT)
119 #define DF_MT DFMT_MAC
120 #endif /*MAC */
121 
122 #ifdef VMS
123 /*#undef DF_BUFFIO should be buff !!!! */
124  /* use only unbuff i/o - buff doesn't work! */
125 #ifndef DFopen /* avoid double includes */
126 /* #include "dfivms.h" */
127 #endif /*DFopen */
128 #undef DF_STRUCTOK
129 #define DF_CAPFNAMES /* fortran names are in all caps */
130 #include <file.h> /* for unbuffered i/o stuff */
131 #define DFmovmem(from, to, len) memcpy(to, from, len)
132 #ifndef DF_STRUCTOK
133 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
134 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
135 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
136  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
137 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
138 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
139 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
140  *p++ = (x>>8) & 255; *p++ = x & 255; }
141 #endif /*DF_STRUCTOK */
142 #define DF_CREAT(name, prot) creat(name, prot)
143 #define DF_MT DFMT_VAX
144 #endif /*VMS */
145 
146 #ifdef APOLLO
147 #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
148 #undef DF_STRUCTOK
149 #endif
150 #include <sys/file.h> /* for unbuffered i/o stuff */
151 #define int8 char
152 #define uint8 unsigned char
153 #define int16 short int
154 #define uint16 unsigned short int
155 #define int32 long int
156 #define uint32 unsigned long int
157 #define float32 float
158 #define DFmovmem(from, to, len) memcpy(to, from, len)
159 #ifndef DF_STRUCTOK
160 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
161 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
162 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
163  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
164 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
165 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
166 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
167  *p++ = (x>>8) & 255; *p++ = x & 255; }
168 #endif /*DF_STRUCTOK */
169 #define DF_CREAT(name, prot) creat(name, prot)
170 #define DF_MT DFMT_APOLLO
171 #endif /*APOLLO */
172 
173 /*--------------------------------------------------------------------------*/
174 /* Flexibility parameters */
175 #if defined (MAC) || defined (macintosh) || defined (SYMANTEC_C) /* MAC specific file manager calls */
176 # define DF_OPEN(x,y) mopen(x,y)
177 # define DF_CLOSE(x) mclose(x)
178 # define DF_SEEK(x,y,z) mlseek(x,y,z)
179 # define DF_SKEND(x,y,z) mlseek(x,-1*y,z)
180 # define DF_TELL(x) mlseek(x,0L,1)
181 # define DF_READ(a,b,c,d) mread(d,a,b*c)
182 # define DF_WRITE(a,b,c,d) mwrite(d,a,b*c)
183 # define DF_FLUSH(a) /* no need to flush */
184 # define DF_RDACCESS 0 /* dummy */
185 # define DF_WRACCESS 0 /* dummy */
186 # define DF_OPENERR(f) ((f) == -1)
187 #else /* !MAC */
188 #ifdef DF_BUFFIO /* set all calls to do buffered I/O */
189 #define DF_OPEN(x,y) fopen(x,y)
190 #define DF_CLOSE(x) fclose(x)
191 #define DF_SEEK(x,y,z) fseek(x,y,z)
192 #define DF_SKEND(x,y,z) fseek(x,y,z)
193 #define DF_TELL(x) ftell(x)
194 #define DF_READ(a,b,c,d) fread(a,b,c,d)
195 #define DF_WRITE(a,b,c,d) fwrite(a,b,c,d)
196 #define DF_FLUSH(a) fflush(a)
197 #define DF_OPENERR(f) (!(f))
198 #define DF_RDACCESS "rb"
199 #define DF_WRACCESS "rb+"
200 
201 #else /*DF_BUFFIO unbuffered i/o */
202 #define DF_OPEN(x,y) open(x,y)
203 #define DF_CLOSE(x) close(x)
204 #define DF_SEEK(x,y,z) lseek(x,y,z)
205 #define DF_SKEND(x,y,z) lseek(x,-1*y,z)
206 #define DF_TELL(x) lseek(x,0L,1)
207 #define DF_READ(a,b,c,d) read(d,a,b*c)
208 #define DF_WRITE(a,b,c,d) write(d,a,b*c)
209 #define DF_OPENERR(f) ((f) == -1)
210 #define DF_FLUSH(a) /* no need to flush */
211 #define DF_RDACCESS O_RDONLY
212 #define DF_WRACCESS O_RDWR
213 #endif /* DF_BUFFIO */
214 #endif /* !MAC */
215 
216 #ifndef FILE
217 #include <stdio.h>
218 #endif /*FILE */
219 
220 #endif /* DFI_H */

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52