MISR Toolkit  1.5.1
hfile.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: hfile.h 5656 2011-06-14 19:28:08Z acheng $ */
15 
16 /*+ hfile.h
17  *** Header for hfile.c, routines for low level data element I/O
18  + */
19 
20 #ifndef HFILE_H
21 #define HFILE_H
22 
23 #include "H4api_adpt.h"
24 
25 #include "tbbt.h"
26 #include "bitvect.h"
27 #include "atom.h"
28 #include "linklist.h"
29 #include "dynarray.h"
30 
31 /* Magic cookie for HDF data files */
32 #define MAGICLEN 4 /* length */
33 #define HDFMAGIC "\016\003\023\001" /* ^N^C^S^A */
34 
35 /* sizes of elements in a file. This is necessary because
36  the size of variables need not be the same as in the file
37  (cannot use sizeof) */
38 #define DD_SZ 12 /* 2+2+4+4 */
39 #define NDDS_SZ 2
40 #define OFFSET_SZ 4
41 
42 /* invalid offset & length to indicate a partially defined element
43 * written to the HDF file i.e. can handle the case where the the
44 * element is defined but not written out */
45 #define INVALID_OFFSET -1
46 #define INVALID_LENGTH -1
47 
48 
49 /* ----------------------------- Version Tags ----------------------------- */
50 /* Library version numbers */
51 
52 #define LIBVER_MAJOR 4
53 #define LIBVER_MINOR 2
54 #define LIBVER_RELEASE 6
55 #define LIBVER_SUBRELEASE "" /* For pre-releases like snap0 */
56  /* Empty string for real releases. */
57 #define LIBVER_STRING "HDF Version 4.2 Release 6, June 14, 2011"
58 #define LIBVSTR_LEN 80 /* length of version string */
59 #define LIBVER_LEN 92 /* 4+4+4+80 = 92 */
60 /* end of version tags */
61 
62 /* -------------------------- File I/O Functions -------------------------- */
63 /* FILELIB -- file library to use for file access: 1 stdio, 2 fcntl
64  default to stdio library i.e. UNIX buffered I/O */
65 
66 #ifndef FILELIB
67 # define FILELIB UNIXBUFIO /* UNIX buffered I/O is the default */
68 #endif /* FILELIB */
69 
70 #if (FILELIB == UNIXBUFIO)
71 /* using C buffered file I/O routines to access files */
72 #include <stdio.h>
73 typedef FILE *hdf_file_t;
74 #ifdef VMS
75 /* For VMS, use "mbc=64" to improve performance */
76 # define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \
77  fopen((p), "r+", "mbc=64") : \
78  fopen((p), "r", "mbc=64"))
79 # define HI_CREATE(p) (fopen((p), "w+", "mbc=64"))
80 #else /* !VMS */
81 #if defined SUN && defined (__GNUC__)
82 # define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \
83  fopen((p), "r+") : fopen((p), "r"))
84 # define HI_CREATE(p) (fopen((p), "w+"))
85 #else /* !SUN w/ GNU CC */
86 # define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \
87  fopen((p), "rb+") : fopen((p), "rb"))
88 # define HI_CREATE(p) (fopen((p), "wb+"))
89 #endif /* !SUN w/ GNU CC */
90 #endif /* VMS */
91 # define HI_READ(f, b, n) (((size_t)(n) == (size_t)fread((b), 1, (size_t)(n), (f))) ? \
92  SUCCEED : FAIL)
93 # define HI_WRITE(f, b, n) (((size_t)(n) == (size_t)fwrite((b), 1, (size_t)(n), (f))) ? \
94  SUCCEED : FAIL)
95 # define HI_CLOSE(f) (((f = ((fclose(f)==0) ? NULL : f))==NULL) ? SUCCEED:FAIL)
96 # define HI_FLUSH(f) (fflush(f)==0 ? SUCCEED : FAIL)
97 # define HI_SEEK(f,o) (fseek((f), (long)(o), SEEK_SET)==0 ? SUCCEED : FAIL)
98 # define HI_SEEK_CUR(f,o) (fseek((f), (long)(o), SEEK_CUR)==0 ? SUCCEED : FAIL)
99 # define HI_SEEKEND(f) (fseek((f), (long)0, SEEK_END)==0 ? SUCCEED : FAIL)
100 # define HI_TELL(f) (ftell(f))
101 # define OPENERR(f) ((f) == (FILE *)NULL)
102 #endif /* FILELIB == UNIXBUFIO */
103 
104 #if (FILELIB == UNIXUNBUFIO)
105 /* using UNIX unbuffered file I/O routines to access files */
106 typedef int hdf_file_t;
107 # define HI_OPEN(p, a) (((a) & DFACC_WRITE) ? \
108  open((p), O_RDWR) : open((p), O_RDONLY))
109 # define HI_CREATE(p) (open((p), O_RDWR | O_CREAT | O_TRUNC, 0666))
110 # define HI_CLOSE(f) (((f = ((close(f)==0) ? NULL : f))==NULL) ? SUCCEED:FAIL)
111 # define HI_FLUSH(f) (SUCCEED)
112 # define HI_READ(f, b, n) (((n)==read((f), (char *)(b), (n))) ? SUCCEED : FAIL)
113 # define HI_WRITE(f, b, n) (((n)==write((f), (char *)(b), (n))) ? SUCCEED : FAIL)
114 # define HI_SEEK(f, o) (lseek((f), (off_t)(o), SEEK_SET)!=(-1) ? SUCCEED : FAIL)
115 # define HI_SEEKEND(f) (lseek((f), (off_t)0, SEEK_END)!=(-1) ? SUCCEED : FAIL)
116 # define HI_TELL(f) (lseek((f), (off_t)0, SEEK_CUR))
117 # define OPENERR(f) (f < 0)
118 #endif /* FILELIB == UNIXUNBUFIO */
119 
120 #if (FILELIB == MACIO)
121 /* using special routines to redirect to Mac Toolkit I/O */
122 typedef short hdf_file_t;
123 # define HI_OPEN(x,y) mopen(x,y)
124 # define HI_CREATE(name) mopen(name, DFACC_CREATE)
125 # define HI_CLOSE(x) (((x = ((mclose(x)==0) ? NULL : x))==NULL) ? SUCCEED:FAIL)
126 # define HI_FLUSH(a) (SUCCEED)
127 # define HI_READ(a,b,c) mread(a, (char *) b, (int32) c)
128 # define HI_WRITE(a,b,c) mwrite(a, (char *) b, (int32) c)
129 # define HI_SEEK(x,y) mlseek(x, (int32 )y, 0)
130 # define HI_SEEKEND(x) mlseek(x, 0L, 2)
131 # define HI_TELL(x) mlseek(x,0L,1)
132 # define DF_OPENERR(f) ((f) == -1)
133 # define OPENERR(f) (f < 0)
134 #endif /* FILELIB == MACIO */
135 
136 
137 /* ----------------------- Internal Data Structures ----------------------- */
138 /* The internal structure used to keep track of the files opened: an
139  array of filerec_t structures, each has a linked list of ddblock_t.
140  Each ddblock_t struct points to an array of dd_t structs.
141 
142  File Header(4 bytes)
143  ===================
144  <--- 32 bits ----->
145  ------------------
146  |HDF magic number |
147  ------------------
148 
149  HDF magic number - 0x0e031301 (Hexadecimal)
150 
151  Data Descriptor(DD - 12 bytes)
152  ==============================
153  <- 16 bits -> <- 16 bits -> <- 32 bits -> <- 32 bits ->
154  --------------------------------------------------------
155  | Tag | reference | Offset | Length |
156  | | number | | |
157  --------------------------------------------------------
158  \____________/
159  V
160  tag/ref (unique data indentifier in file)
161 
162  Tag -- identifies the type of data, 16 bit unsigned integer whose
163  value ranges from 1 - 65535. Tags are assigned by NCSA.
164  The HDF tag space is divided as follows based on the 2 highest bits:
165 
166  00: NCSA reserved ordinary tags
167  01: NCSA reserved special tags(i.e. regular tags made into
168  linked-block, external,
169  compressed or chunked.)
170  10, 11: User tags.
171 
172  Current tag assingments are:
173  00001 - 32767 - reserved for NCSA use
174  00001 - 16383 - NCSA regular tags
175  16384 - 32767 - NCSA special tags
176  32768 - 64999 - user definable
177  65000 - 65535 - reserved for expansion of format
178 
179  Refererence number - 16 bit unsigned integer whose assignment is not
180  gauranteed to be consecutive. Provides a way to distinguish
181  elements with the same tag in the file.
182 
183  Offset - Specifies the byte offset of the data element from the
184  beginning of the file - 32 bit unsigned integer
185 
186  Length - Indicates the byte length of the data element
187  32 bit unsigned integer
188 
189  Data Descriptor Header(DDH - 6 bytes)
190  ====================================
191  <- 16 bits -> <- 32 bits ->
192  -----------------------------
193  | Block Size | Next Block |
194  -----------------------------
195 
196  Block Size - Indicates the number of DD's in the DD Block,
197  16 bit unsigned integer value
198  Next Block - Gives the offset of the next DD Block. The last DD Block has
199  a ZERO(0) in the "Next Block" field in the DDH.
200  32 bit unsigned integer value
201 
202  Data Descriptor Block(DDB - variable size)
203  ==========================================
204  <- DD Header -> <--------------- DD's --------------------->
205  --------------------------------------------------------...-
206  |Block | Next | DD | DD | DD | DD | DD | DD | DD | DD |...|
207  |Size | Block | | | | | | | | | |
208  --------------------------------------------------------...-
209  <-------------------------- DD Block ---------------------->
210 
211  Note: default number of DD's in a DD Block is 16
212 
213  HDF file layout
214  =============================
215  (one example)
216  ---------------------------------------------------------------------
217  | FH | DD Block | Data | DD Block | Data | DD Block | Data | .....
218  ---------------------------------------------------------------------
219 
220 */
221 
222 /* record of each data decsriptor */
223 typedef struct dd_t
224  {
225  uint16 tag; /* Tag number of element i.e. type of data */
226  uint16 ref; /* Reference number of element */
227  int32 length; /* length of data element */
228  int32 offset; /* byte offset of data element from */
229  struct ddblock_t *blk; /* Pointer to the block this dd is in */
230  } /* beginning of file */
231 dd_t;
232 
233 /* version tags */
234 typedef struct version_t
235  {
236  uint32 majorv; /* major version number */
237  uint32 minorv; /* minor version number */
238  uint32 release; /* release number */
239  char string[LIBVSTR_LEN + 1]; /* optional text description, len 80+1 */
240  int16 modified; /* indicates file was modified */
241  }
242 version_t;
243 
244 /* record of a block of data descriptors, mirrors structure of a HDF file. */
245 typedef struct ddblock_t
246  {
247  uintn dirty; /* boolean: should this DD block be flushed? */
248  int32 myoffset; /* offset of this DD block in the file */
249  int16 ndds; /* number of dd's in this block */
250  int32 nextoffset; /* offset to the next ddblock in the file */
251  struct filerec_t *frec; /* Pointer to the filerec this block is in */
252  struct ddblock_t *next; /* pointer to the next ddblock in memory */
253  struct ddblock_t *prev; /* Pointer to previous ddblock. */
254  struct dd_t *ddlist; /* pointer to array of dd's */
255  }
256 ddblock_t;
257 
258 /* Tag tree node structure */
259 typedef struct tag_info_str
260  {
261  uint16 tag; /* tag value for this node */
262  /* Needs to be first in this structure */
263  bv_ptr b; /* bit-vector to keep track of which refs are used */
264  dynarr_p d; /* dynarray of the refs for this tag */
265  }tag_info;
266 
267 /* For determining what the last file operation was */
268 typedef enum
269  {
270  H4_OP_UNKNOWN = 0, /* Don't know what the last operation was (after fopen frex) */
271  H4_OP_SEEK, /* Last operation was a seek */
272  H4_OP_WRITE, /* Last operation was a write */
273  H4_OP_READ /* Last operation was a read */
274  }
275 fileop_t;
276 
277 /* File record structure */
278 typedef struct filerec_t
279  {
280  char *path; /* name of file */
281  hdf_file_t file; /* either file descriptor or pointer */
282  uint16 maxref; /* highest ref in this file */
283  intn access; /* access mode */
284  intn refcount; /* reference count / times opened */
285  intn attach; /* number of access elts attached */
286  intn version_set; /* version tag stuff */
287  version_t version; /* file version info */
288 
289  /* Seek caching info */
290  int32 f_cur_off; /* Current location in the file */
291  fileop_t last_op; /* the last file operation performed */
292 
293  /* DD block caching info */
294  intn cache; /* boolean: whether caching is on */
295  intn dirty; /* boolean: if dd list needs to be flushed */
296  int32 f_end_off; /* offset of the end of the file */
297 
298  /* DD list pointers */
299  struct ddblock_t *ddhead; /* head of ddblock list */
300  struct ddblock_t *ddlast; /* end of ddblock list */
301 
302  /* NULL DD pointers (for fast lookup of DFTAG_NULL) */
303  struct ddblock_t *ddnull; /* location of last ddblock with a DFTAG_NULL */
304  int32 ddnull_idx; /* offset of the last location with DFTAG_NULL */
305 
306  /* tag tree for file */
307  TBBT_TREE *tag_tree; /* TBBT of the tags in the file */
308 
309  /* annotation stuff for file */
310  intn an_num[4]; /* Holds number of annotations found of each type */
311  TBBT_TREE *an_tree[4]; /* tbbt trees for each type of annotation in file
312  * i.e. file/data labels and descriptions.
313  * This is done for faster searching of annotations
314  * of a particular type. */
315  }
316 filerec_t;
317 
318 /* bits for filerec_t 'dirty' flag */
319 #define DDLIST_DIRTY 0x01 /* mark whether to flush dirty DD blocks */
320 #define FILE_END_DIRTY 0x02 /* indicate that the file needs to be extended */
321 
322 /* Each access element is associated with a tag/ref to keep track of
323  the dd it is pointing at. To facilitate searching for next dd's,
324  instead of pointing directly to the dd, we point to the ddblock and
325  index into the ddlist of that ddblock. */
326 typedef struct accrec_t
327  {
328  /* Flags for this access record */
329  intn appendable; /* whether appends to the data are allowed */
330  intn special; /* special element ? */
331  intn new_elem; /* is a new element (i.e. no length set yet) */
332  int32 block_size; /* size of the blocks for linked-block element*/
333  int32 num_blocks; /* number blocks in the linked-block element */
334  uint32 access; /* access codes */
335  uintn access_type; /* I/O access type: serial/parallel/... */
336  int32 file_id; /* id of attached file */
337  atom_t ddid; /* DD id for the DD attached to */
338  int32 posn; /* seek position with respect to start of element */
339  void * special_info; /* special element info? */
340  struct funclist_t *special_func; /* ptr to special function? */
341  struct accrec_t *next; /* for free-list linking */
342  }
343 accrec_t;
344 
345 #ifdef HFILE_MASTER
346 /* Pointer to the access record node free list */
347 static accrec_t *accrec_free_list=NULL;
348 #endif /* HFILE_MASTER */
349 
350 /* this type is returned to applications programs or other special
351  interfaces when they need to know information about a given
352  special element. This is all information that would not be returned
353  via Hinquire(). This should probably be a union of structures. */
354 typedef struct sp_info_block_t
355  {
356  int16 key; /* type of special element this is */
357 
358  /* external elements */
359  int32 offset; /* offset in the file */
360  char *path; /* file name - should not be freed by user */
361 
362  /* linked blocks */
363  int32 first_len; /* length of first block */
364  int32 block_len; /* length of standard block */
365  int32 nblocks; /* number of blocks per chunk */
366 
367  /* compressed elements */
368  int32 comp_type; /* compression type */
369  int32 model_type; /* model type */
370  int32 comp_size; /* size of compressed information */
371 
372  /* variable-length linked blocks */
373  int32 min_block; /* the minimum block size */
374 
375  /* Chunked elements */
376  int32 chunk_size; /* logical size of chunks */
377  int32 ndims; /* number of dimensions */
378  int32 *cdims; /* array of chunk lengths for each dimension */
379 
380  /* Buffered elements */
381  int32 buf_aid; /* AID of element buffered */
382  }
384 
385 /* a function table record for accessing special data elements.
386  special data elements of a key could be accessed through the list
387  of functions in array pointed to by tab. */
388 typedef struct funclist_t
389  {
390  int32 (*stread) (accrec_t * rec);
391  int32 (*stwrite) (accrec_t * rec);
392  int32 (*seek) (accrec_t * access_rec, int32 offset, intn origin);
393  int32 (*inquire) (accrec_t * access_rec, int32 *pfile_id,
394  uint16 *ptag, uint16 *pref, int32 *plength,
395  int32 *poffset, int32 *pposn, int16 *paccess,
396  int16 *pspecial);
397  int32 (*read) (accrec_t * access_rec, int32 length, void * data);
398  int32 (*write) (accrec_t * access_rec, int32 length, const void * data);
399  intn (*endaccess) (accrec_t * access_rec);
400  int32 (*info) (accrec_t * access_rec, sp_info_block_t * info);
401  int32 (*reset) (accrec_t * access_rec, sp_info_block_t * info);
402  }
403 funclist_t;
404 
405 typedef struct functab_t
406  {
407  int16 key; /* the key for this type of special elt */
408  funclist_t *tab; /* table of accessing functions */
409  }
410 functab_t;
411 
412 /* ---------------------- ID Types and Manipulation ----------------------- */
413 /* each id, what ever the type, will be represented with a 32-bit word,
414  the most-significant 16 bits is a number unique for type. The less-
415  significant 16 bits is an id unique to each type; in this, we use the
416  internal slot number. */
417 
418 #define FIDTYPE 1
419 #define AIDTYPE 2
420 #define GROUPTYPE 3
421 #define SDSTYPE 4
422 #define DIMTYPE 5
423 #define CDFTYPE 6
424 #define VGIDTYPE 8 /* also defined in vg.h for Vgroups */
425 #define VSIDTYPE 9 /* also defined in vg.h for Vsets */
426 #define BITTYPE 10 /* For bit-accesses */
427 #define GRIDTYPE 11 /* for GR access */
428 #define RIIDTYPE 12 /* for RI access */
429 
430 #define BADFREC(r) ((r)==NULL || (r)->refcount==0)
431 
432 /* --------------------------- Special Elements --------------------------- */
433 /* The HDF tag space is divided as follows based on the 2 highest bits:
434  00: NCSA reserved ordinary tags
435  01: NCSA reserved special tags(e.g. linked-block, external, compressed,..)
436  10, 11: User tags.
437 
438  It is relatively cheap to operate with special tags within the NCSA
439  reserved tags range. For users to specify special tags and their
440  corresponding ordinary tag, the pair has to be added to the
441  special_table in hfile.c and SPECIAL_TABLE must be defined. */
442 
443 #ifdef SPECIAL_TABLE
444 #define BASETAG(t) (HDbase_tag(t))
445 #define SPECIALTAG(t) (HDis_special_tag(t))
446 #define MKSPECIALTAG(t) (HDmake_special_tag(t))
447 #else
448 /* This macro converts a (potentially) special tag into a normal tag */
449 #define BASETAG(t) (uint16)((~(t) & 0x8000) ? ((t) & ~0x4000) : (t))
450 /* This macro checks if a tag is special */
451 #define SPECIALTAG(t) (uint16)((~(t) & 0x8000) && ((t) & 0x4000))
452 /* This macro (potentially) converts a regular tag into a special tag */
453 #define MKSPECIALTAG(t) (uint16)((~(t) & 0x8000) ? ((t) | 0x4000) : DFTAG_NULL)
454 #endif /*SPECIAL_TABLE */
455 
456 /* -------------------------- H-Layer Prototypes -------------------------- */
457 /*
458  ** Functions to get information of special elt from other access records.
459  ** defined in hfile.c
460  ** These should really be HD... routines, but they are only used within
461  ** the H-layer...
462  */
463 
464 #if defined c_plusplus || defined __cplusplus
465 extern "C"
466 {
467 #endif /* c_plusplus || __cplusplus */
468 
470  (void);
471 
473 
474  HDFLIBAPI void * HIgetspinfo
475  (accrec_t * access_rec);
476 
478  (const void * obj, const void * key);
479 
481  (const void * rec1, const void * rec2);
482 
484  (filerec_t * file_rec, int32 block_size, intn moveto);
485 
487  (filerec_t * file_rec, int32 block_offset, int32 block_size);
488 
490  (const char *path);
491 
493  (int32 file_id, uint16 tag, uint16 ref, intn *emptySDS);
494 
496  (int32 access_id, sp_info_block_t * info_block);
497 
499  (intn file_id, uint16 tag, uint16 ref, sp_info_block_t *info);
500 
502  (int32 access_id, sp_info_block_t * info_block);
503 
504  HDFLIBAPI intn HP_read
505  (filerec_t *file_rec,void * buf,int32 bytes);
506 
507  HDFLIBAPI intn HPseek
508  (filerec_t *file_rec,int32 offset);
509 
510  HDFLIBAPI intn HP_write
511  (filerec_t *file_rec,const void * buf,int32 bytes);
512 
513  HDFLIBAPI int32 HPread_drec
514  (int32 file_id, atom_t data_id, uint8** drec_buf);
515 
516  HDFLIBAPI intn tagcompare
517  (void * k1, void * k2, intn cmparg);
518 
520  (void * n);
521 
522 /*
523  ** from hblocks.c
524  */
525  HDFLIBAPI int32 HLPstread
526  (accrec_t * access_rec);
527 
528  HDFLIBAPI int32 HLPstwrite
529  (accrec_t * access_rec);
530 
531  HDFLIBAPI int32 HLPseek
532  (accrec_t * access_rec, int32 offset, int origin);
533 
534  HDFLIBAPI int32 HLPread
535  (accrec_t * access_rec, int32 length, void * data);
536 
537  HDFLIBAPI int32 HLPwrite
538  (accrec_t * access_rec, int32 length, const void * data);
539 
540  HDFLIBAPI int32 HLPinquire
541  (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref,
542  int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess,
543  int16 *pspecial);
544 
546  (accrec_t * access_rec);
547 
548  HDFLIBAPI int32 HLPcloseAID
549  (accrec_t * access_rec);
550 
551  HDFLIBAPI int32 HLPinfo
552  (accrec_t * access_rec, sp_info_block_t * info_block);
553 
554 /*
555  ** from hextelt.c
556  */
557  HDFLIBAPI int32 HXPstread
558  (accrec_t * rec);
559 
560  HDFLIBAPI int32 HXPstwrite
561  (accrec_t * rec);
562 
563  HDFLIBAPI int32 HXPseek
564  (accrec_t * access_rec, int32 offset, int origin);
565 
566  HDFLIBAPI int32 HXPread
567  (accrec_t * access_rec, int32 length, void * data);
568 
569  HDFLIBAPI int32 HXPwrite
570  (accrec_t * access_rec, int32 length, const void * data);
571 
572  HDFLIBAPI int32 HXPinquire
573  (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref,
574  int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess,
575  int16 *pspecial);
576 
578  (accrec_t * access_rec);
579 
580  HDFLIBAPI int32 HXPcloseAID
581  (accrec_t * access_rec);
582 
583  HDFLIBAPI int32 HXPinfo
584  (accrec_t * access_rec, sp_info_block_t * info_block);
585 
586  HDFLIBAPI int32 HXPreset
587  (accrec_t * access_rec, sp_info_block_t * info_block);
588 
590  (accrec_t * access_rec);
591 
593  (void);
594 
595 /*
596  ** from hcomp.c
597  */
598 
599  HDFLIBAPI int32 HCPstread
600  (accrec_t * rec);
601 
602  HDFLIBAPI int32 HCPstwrite
603  (accrec_t * rec);
604 
605  HDFLIBAPI int32 HCPseek
606  (accrec_t * access_rec, int32 offset, int origin);
607 
608  HDFLIBAPI int32 HCPinquire
609  (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref,
610  int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess,
611  int16 *pspecial);
612 
613  HDFLIBAPI int32 HCPread
614  (accrec_t * access_rec, int32 length, void * data);
615 
616  HDFLIBAPI int32 HCPwrite
617  (accrec_t * access_rec, int32 length, const void * data);
618 
620  (accrec_t * access_rec);
621 
622  HDFLIBAPI int32 HCPcloseAID
623  (accrec_t * access_rec);
624 
625  HDFLIBAPI int32 HCPinfo
626  (accrec_t * access_rec, sp_info_block_t * info_block);
627 
628  HDFLIBAPI int32 get_comp_len
629  (accrec_t* access_rec);
630 
631 /*
632  ** from hchunks.c - should be the same as found in 'hchunks.h'
633  */
634 #include "hchunks.h"
635 
636 #if defined (MAC) || defined (macintosh) || defined (SYMANTEC_C)
637  HDFLIBAPI hdf_file_t mopen
638  (char *filename, intn access);
639 
640  HDFLIBAPI int32 mclose
641  (hdf_file_t rn);
642 
643  HDFLIBAPI int32 mlseek
644  (hdf_file_t rn, int32 n, intn m);
645 
646  HDFLIBAPI int32 mread
647  (hdf_file_t rn, char *buf, int32 n);
648 
649  HDFLIBAPI int32 mwrite
650  (hdf_file_t rn, char *buf, int32 n);
651  HDFLIBAPI intn mstat
652  (char *path);
653 
654 #endif /* macintosh */
655 
656 /*
657  ** from hbuffer.c
658  */
659 
660  HDFLIBAPI int32 HBPstread
661  (accrec_t * rec);
662 
663  HDFLIBAPI int32 HBPstwrite
664  (accrec_t * rec);
665 
666  HDFLIBAPI int32 HBPseek
667  (accrec_t * access_rec, int32 offset, int origin);
668 
669  HDFLIBAPI int32 HBPinquire
670  (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref,
671  int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess,
672  int16 *pspecial);
673 
674  HDFLIBAPI int32 HBPread
675  (accrec_t * access_rec, int32 length, void * data);
676 
677  HDFLIBAPI int32 HBPwrite
678  (accrec_t * access_rec, int32 length, const void * data);
679 
681  (accrec_t * access_rec);
682 
683  HDFLIBAPI int32 HBPcloseAID
684  (accrec_t * access_rec);
685 
686  HDFLIBAPI int32 HBPinfo
687  (accrec_t * access_rec, sp_info_block_t * info_block);
688 
689 /*
690  ** from hcompri.c
691  */
692 
693  HDFLIBAPI int32 HRPstread
694  (accrec_t * rec);
695 
696  HDFLIBAPI int32 HRPstwrite
697  (accrec_t * rec);
698 
699  HDFLIBAPI int32 HRPseek
700  (accrec_t * access_rec, int32 offset, int origin);
701 
702  HDFLIBAPI int32 HRPinquire
703  (accrec_t * access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref,
704  int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess,
705  int16 *pspecial);
706 
707  HDFLIBAPI int32 HRPread
708  (accrec_t * access_rec, int32 length, void * data);
709 
710  HDFLIBAPI int32 HRPwrite
711  (accrec_t * access_rec, int32 length, const void * data);
712 
714  (accrec_t * access_rec);
715 
716  HDFLIBAPI int32 HRPcloseAID
717  (accrec_t * access_rec);
718 
719  HDFLIBAPI int32 HRPinfo
720  (accrec_t * access_rec, sp_info_block_t * info_block);
721 
722 /*
723  ** from hfiledd.c
724  */
725 /******************************************************************************
726  NAME
727  HTPstart - Initialize the DD list in memory
728 
729  DESCRIPTION
730  Reads the DD blocks from disk and creates the in-memory structures for
731  handling them. This routine should only be called once for a given
732  file and HTPend should be called when finished with the DD list (i.e.
733  when the file is being closed).
734 
735  RETURNS
736  Returns SUCCEED if successful and FAIL otherwise
737 
738 *******************************************************************************/
739 intn HTPstart(filerec_t *file_rec /* IN: File record to store info in */
740 );
741 
742 /******************************************************************************
743  NAME
744  HTPinit - Create a new DD list in memory
745 
746  DESCRIPTION
747  Creates a new DD list in memory for a newly created file. This routine
748  should only be called once for a given file and HTPend should be called
749  when finished with the DD list (i.e. when the file is being closed).
750 
751  RETURNS
752  Returns SUCCEED if successful and FAIL otherwise
753 
754 *******************************************************************************/
755 intn HTPinit(filerec_t *file_rec, /* IN: File record to store info in */
756  int16 ndds /* IN: # of DDs to store in each block */
757 );
758 
759 /******************************************************************************
760  NAME
761  HTPsync - Flush the DD list in memory
762 
763  DESCRIPTION
764  Syncronizes the in-memory copy of the DD list with the copy on disk by
765  writing out the DD blocks which have changed to disk.
766 
767  RETURNS
768  Returns SUCCEED if successful and FAIL otherwise
769 
770 *******************************************************************************/
771 intn HTPsync(filerec_t *file_rec /* IN: File record to store info in */
772 );
773 
774 /******************************************************************************
775  NAME
776  HTPend - Terminate the DD list in memory
777 
778  DESCRIPTION
779  Terminates access to the DD list in memory, writing the DD blocks out to
780  the disk (if they've changed). After this routine is called, no further
781  access to tag/refs (or essentially any other HDF objects) can be performed
782  on the file.
783 
784  RETURNS
785  Returns SUCCEED if successful and FAIL otherwise
786 
787 *******************************************************************************/
788 intn HTPend(filerec_t *file_rec /* IN: File record to store info in */
789 );
790 
791 /******************************************************************************
792  NAME
793  HTPcreate - Create (and attach to) a tag/ref pair
794 
795  DESCRIPTION
796  Creates a new tag/ref pair in memory and inserts the tag/ref pair into the
797  DD list to be written out to disk. This routine returns a DD id which can
798  be used in the other tag/ref routines to modify the DD.
799 
800  RETURNS
801  Returns DD id if successful and FAIL otherwise
802 
803 *******************************************************************************/
804 atom_t HTPcreate(filerec_t *file_rec, /* IN: File record to store info in */
805  uint16 tag, /* IN: Tag to create */
806  uint16 ref /* IN: ref to create */
807 );
808 
809 /******************************************************************************
810  NAME
811  HTPselect - Attach to an existing tag/ref pair
812 
813  DESCRIPTION
814  Attaches to an existing tag/ref pair. This routine returns a DD id which
815  can be used in the other tag/ref routines to modify the DD.
816 
817  RETURNS
818  Returns DD id if successful and FAIL otherwise
819 
820 *******************************************************************************/
821 atom_t HTPselect(filerec_t *file_rec, /* IN: File record to store info in */
822  uint16 tag, /* IN: Tag to select */
823  uint16 ref /* IN: ref to select */
824 );
825 
826 /******************************************************************************
827  NAME
828  HTPendaccess - End access to an existing tag/ref pair
829 
830  DESCRIPTION
831  Ends access to an existing tag/ref pair. Any further access to the tag/ref
832  pair may result in incorrect information being recorded about the DD in
833  memory or on disk.
834 
835  RETURNS
836  Returns SUCCEED if successful and FAIL otherwise
837 
838 *******************************************************************************/
839 intn HTPendaccess(atom_t ddid /* IN: DD id to end access to */
840 );
841 
842 /******************************************************************************
843  NAME
844  HTPdelete - Delete an existing tag/ref pair
845 
846  DESCRIPTION
847  Deletes a tag/ref from the file. Also ends access to the tag/ref pair.
848  Any further access to the tag/ref pair may result in incorrect information
849  being recorded about the DD in memory or on disk.
850 
851  RETURNS
852  Returns SUCCEED if successful and FAIL otherwise
853 
854 *******************************************************************************/
855 intn HTPdelete(atom_t ddid /* IN: DD id to delete */
856 );
857 
858 /******************************************************************************
859  NAME
860  HTPupdate - Change the offset or length of an existing tag/ref pair
861 
862  DESCRIPTION
863  Updates a tag/ref in the file, allowing the length and/or offset to be
864  modified. Note: "INVALID_OFFSET" & "INVALID_LENGTH" are used to indicate
865  that the length or offset (respectively) is unchanged.
866 
867  RETURNS
868  Returns SUCCEED if successful and FAIL otherwise
869 
870 *******************************************************************************/
871 intn HTPupdate(atom_t ddid, /* IN: DD id to update */
872  int32 new_off, /* IN: new offset for DD */
873  int32 new_len /* IN: new length for DD */
874 );
875 
876 /******************************************************************************
877  NAME
878  HTPinquire - Get the DD information for a DD (i.e. tag/ref/offset/length)
879 
880  DESCRIPTION
881  Get the DD information for a DD id from the DD block. Passing NULL for
882  any parameter does not try to update that parameter.
883 
884  RETURNS
885  Returns SUCCEED if successful and FAIL otherwise
886 
887 *******************************************************************************/
888 intn HTPinquire(atom_t ddid, /* IN: DD id to inquire about */
889  uint16 *tag, /* IN: tag of DD */
890  uint16 *ref, /* IN: ref of DD */
891  int32 *off, /* IN: offset of DD */
892  int32 *len /* IN: length of DD */
893 );
894 
895 /******************************************************************************
896  NAME
897  HTPis_special - Check if a DD id is associated with a special tag
898 
899  DESCRIPTION
900  Checks if the tag for the DD id is a special tag.
901 
902  RETURNS
903  Returns TRUE(1)/FALSE(0) if successful and FAIL otherwise
904 
905 *******************************************************************************/
906 intn HTPis_special(atom_t ddid /* IN: DD id to inquire about */
907 );
908 
909 /******************************************************************************
910  NAME
911  HTPdump_dds -- Dump out the dd information for a file
912 
913  DESCRIPTION
914  Prints out all the information (that you could _ever_ want to know) about
915  the dd blocks and dd list for a file.
916 
917  RETURNS
918  returns SUCCEED (0) if successful and FAIL (-1) if failed.
919 
920 *******************************************************************************/
921 intn HTPdump_dds(int32 file_id, /* IN: file ID of HDF file to dump info for */
922  FILE *fout /* IN: file stream to output to */
923 );
924 
925 #if defined c_plusplus || defined __cplusplus
926 }
927 #endif /* c_plusplus || __cplusplus */
928 
929 /* #define DISKBLOCK_DEBUG */
930 #ifdef DISKBLOCK_DEBUG
931 
932 #ifndef HFILE_MASTER
933 extern
934 #endif /* HFILE_MASTER */
935 const uint8 diskblock_header[4]
936 #ifdef HFILE_MASTER
937 ={0xde, 0xad, 0xbe, 0xef}
938 #endif /* HFILE_MASTER */
939 ;
940 
941 #ifndef HFILE_MASTER
942 extern
943 #endif /* HFILE_MASTER */
944 const uint8 diskblock_tail[4]
945 #ifdef HFILE_MASTER
946 ={0xfe, 0xeb, 0xda, 0xed}
947 #endif /* HFILE_MASTER */
948 ;
949 #define DISKBLOCK_HSIZE sizeof(diskblock_header)
950 #define DISKBLOCK_TSIZE sizeof(diskblock_tail)
951 
952 #endif /* DISKBLOCK_DEBUG */
953 
954 #endif /* HFILE_H */
HDFLIBAPI int32 get_comp_len(accrec_t *access_rec)
int32 num_blocks
Definition: hfile.h:333
HDFLIBAPI intn HXPshutdown(void)
bv_ptr b
Definition: hfile.h:263
HDFLIBAPI int32 HPgetdiskblock(filerec_t *file_rec, int32 block_size, intn moveto)
HDFFCLIBAPI intf * len
HDFLIBAPI int32 HXPread(accrec_t *access_rec, int32 length, void *data)
int32 buf_aid
Definition: hfile.h:381
HDFLIBAPI int32 HCPcloseAID(accrec_t *access_rec)
int32 ddnull_idx
Definition: hfile.h:304
intn dirty
Definition: hfile.h:295
int32 comp_type
Definition: hfile.h:368
HDFLIBAPI intn HPcompare_filerec_path(const void *obj, const void *key)
int32 offset
Definition: hfile.h:228
HDFFCLIBAPI intf * info
struct dd_t * ddlist
Definition: hfile.h:254
Definition: hfile.h:223
HDFFCLIBAPI intf * block_size
HDFLIBAPI intn HXPendaccess(accrec_t *access_rec)
HDFLIBAPI int32 HBPcloseAID(accrec_t *access_rec)
struct ddblock_t * ddnull
Definition: hfile.h:303
intn HTPdump_dds(int32 file_id, FILE *fout)
HDFLIBAPI intn HBPendaccess(accrec_t *access_rec)
intn HTPsync(filerec_t *file_rec)
intn HTPinit(filerec_t *file_rec, int16 ndds)
int32 posn
Definition: hfile.h:338
int32 f_cur_off
Definition: hfile.h:290
struct ddblock_t * next
Definition: hfile.h:252
char * filename
Definition: cdjpeg.h:133
HDFLIBAPI int32 HCPseek(accrec_t *access_rec, int32 offset, int origin)
atom_t ddid
Definition: hfile.h:337
int32 file_id
Definition: hfile.h:336
struct ddblock_t ddblock_t
HDFLIBAPI int32 HRPstread(accrec_t *rec)
struct dd_t dd_t
uint16 tag
Definition: hfile.h:261
HDFLIBAPI int32 HBPinquire(accrec_t *access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, int16 *pspecial)
intn cache
Definition: hfile.h:294
HDFLIBAPI intn HP_read(filerec_t *file_rec, void *buf, int32 bytes)
intn HTPis_special(atom_t ddid)
HDFLIBAPI int32 HLPread(accrec_t *access_rec, int32 length, void *data)
struct ddblock_t * ddlast
Definition: hfile.h:300
int32(* info)(accrec_t *access_rec, sp_info_block_t *info)
Definition: hfile.h:400
uint32 access
Definition: hfile.h:334
struct funclist_t * special_func
Definition: hfile.h:340
version_t version
Definition: hfile.h:287
int32 min_block
Definition: hfile.h:373
int32 length
Definition: hfile.h:227
intn refcount
Definition: hfile.h:284
HDFLIBAPI int32 HDset_special_info(int32 access_id, sp_info_block_t *info_block)
HDFLIBAPI accrec_t * HIget_access_rec(void)
HDFLIBAPI int32 HRPseek(accrec_t *access_rec, int32 offset, int origin)
HDFLIBAPI int32 HBPinfo(accrec_t *access_rec, sp_info_block_t *info_block)
HDFLIBAPI intn HCPendaccess(accrec_t *access_rec)
struct accrec_t accrec_t
HDFLIBAPI int32 HCPread(accrec_t *access_rec, int32 length, void *data)
HDFLIBAPI int32 HXPinfo(accrec_t *access_rec, sp_info_block_t *info_block)
char * path
Definition: hfile.h:360
HDFLIBAPI intn HLPendaccess(accrec_t *access_rec)
fileop_t last_op
Definition: hfile.h:291
HDFLIBAPI int32 HBPstread(accrec_t *rec)
Definition: tbbt.h:31
HDFLIBAPI int32 HXPseek(accrec_t *access_rec, int32 offset, int origin)
void origin(double A)
intn HTPupdate(atom_t ddid, int32 new_off, int32 new_len)
HDFLIBAPI int32 HBPseek(accrec_t *access_rec, int32 offset, int origin)
intn new_elem
Definition: hfile.h:331
int32 chunk_size
Definition: hfile.h:376
dynarr_p d
Definition: hfile.h:264
uint32 majorv
Definition: hfile.h:236
uintn dirty
Definition: hfile.h:247
HDFLIBAPI intn tagcompare(void *k1, void *k2, intn cmparg)
HDFLIBAPI void * HIgetspinfo(accrec_t *access_rec)
HDFLIBAPI int32 HBPstwrite(accrec_t *rec)
fileop_t
Definition: hfile.h:268
uint16 ref
Definition: hfile.h:226
struct ddblock_t * ddhead
Definition: hfile.h:299
int32 block_len
Definition: hfile.h:364
TBBT_TREE * tag_tree
Definition: hfile.h:307
struct filerec_t filerec_t
intn appendable
Definition: hfile.h:329
intn HTPstart(filerec_t *file_rec)
struct filerec_t * frec
Definition: hfile.h:251
int16 ndds
Definition: hfile.h:249
atom_t HTPcreate(filerec_t *file_rec, uint16 tag, uint16 ref)
#define LIBVSTR_LEN
Definition: hfile.h:58
int32 model_type
Definition: hfile.h:369
int32 comp_size
Definition: hfile.h:370
HDFLIBAPI int32 HRPinfo(accrec_t *access_rec, sp_info_block_t *info_block)
HDFLIBAPI int32 HRPstwrite(accrec_t *rec)
hdf_file_t file
Definition: hfile.h:281
HDFLIBAPI int32 HRPcloseAID(accrec_t *access_rec)
HDFLIBAPI intn HDgetspecinfo(intn file_id, uint16 tag, uint16 ref, sp_info_block_t *info)
int32 offset
Definition: hfile.h:359
intn HTPend(filerec_t *file_rec)
struct version_t version_t
HDFLIBAPI intn HPcompare_accrec_tagref(const void *rec1, const void *rec2)
int32 * cdims
Definition: hfile.h:378
int16 modified
Definition: hfile.h:240
HDFLIBAPI int32 HLPstread(accrec_t *access_rec)
struct ddblock_t * blk
Definition: hfile.h:229
HDFLIBAPI intn HP_write(filerec_t *file_rec, const void *buf, int32 bytes)
struct ddblock_t * prev
Definition: hfile.h:253
HDFLIBAPI int32 HDcheck_empty(int32 file_id, uint16 tag, uint16 ref, intn *emptySDS)
HDFLIBAPI int32 HPread_drec(int32 file_id, atom_t data_id, uint8 **drec_buf)
HDFLIBAPI VOID tagdestroynode(void *n)
HDFLIBAPI int32 HXPreset(accrec_t *access_rec, sp_info_block_t *info_block)
HDFLIBAPI int32 HCPinfo(accrec_t *access_rec, sp_info_block_t *info_block)
atom_t HTPselect(filerec_t *file_rec, uint16 tag, uint16 ref)
int32 first_len
Definition: hfile.h:363
uint16 maxref
Definition: hfile.h:282
HDFFCLIBAPI _fcd _fcd intf * n
struct accrec_t * next
Definition: hfile.h:341
int16 key
Definition: hfile.h:356
intn HTPinquire(atom_t ddid, uint16 *tag, uint16 *ref, int32 *off, int32 *len)
HDFLIBAPI intn HXPsetaccesstype(accrec_t *access_rec)
struct tag_info_str tag_info
HDFLIBAPI int32 HXPstread(accrec_t *rec)
HDFLIBAPI int32 HLPstwrite(accrec_t *access_rec)
int32 myoffset
Definition: hfile.h:248
intn version_set
Definition: hfile.h:286
HDFLIBAPI intn HPseek(filerec_t *file_rec, int32 offset)
void * special_info
Definition: hfile.h:339
struct bv_struct_tag * bv_ptr
Definition: bitvect.h:48
HDFLIBAPI int32 HCPstread(accrec_t *rec)
intn special
Definition: hfile.h:330
int32 ndims
Definition: hfile.h:377
struct funclist_t funclist_t
struct functab_t functab_t
uintn access_type
Definition: hfile.h:335
HDFLIBAPI int32 HXPinquire(accrec_t *access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, int16 *pspecial)
struct dynarray_tag * dynarr_p
Definition: dynarray.h:36
HDFLIBAPI int32 HLPwrite(accrec_t *access_rec, int32 length, const void *data)
HDFFCLIBAPI void * data
struct sp_info_block_t sp_info_block_t
HDFLIBAPI int32 HRPread(accrec_t *access_rec, int32 length, void *data)
HDFLIBAPI int32 HLPseek(accrec_t *access_rec, int32 offset, int origin)
HDFLIBAPI int32 HXPstwrite(accrec_t *rec)
funclist_t * tab
Definition: hfile.h:408
HDFLIBAPI int32 HDget_special_info(int32 access_id, sp_info_block_t *info_block)
uint32 release
Definition: hfile.h:238
HDFLIBAPI int32 HXPcloseAID(accrec_t *access_rec)
int32 f_end_off
Definition: hfile.h:296
HDFLIBAPI int32 HLPcloseAID(accrec_t *access_rec)
HDFLIBAPI int32 HBPread(accrec_t *access_rec, int32 length, void *data)
HDFLIBAPI int32 HBPwrite(accrec_t *access_rec, int32 length, const void *data)
uint32 minorv
Definition: hfile.h:237
HDFLIBAPI int32 HLPinquire(accrec_t *access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, int16 *pspecial)
HDFLIBAPI int32 HCPwrite(accrec_t *access_rec, int32 length, const void *data)
int32 nblocks
Definition: hfile.h:365
HDFLIBAPI int32 HCPstwrite(accrec_t *rec)
int32 block_size
Definition: hfile.h:332
intn HTPendaccess(atom_t ddid)
int32 atom_t
Definition: atom.h:80
uint16 tag
Definition: hfile.h:225
intn access
Definition: hfile.h:283
#define HDFLIBAPI
Definition: H4api_adpt.h:195
HDFLIBAPI intn HPisfile_in_use(const char *path)
HDFLIBAPI int32 HRPwrite(accrec_t *access_rec, int32 length, const void *data)
int32 nextoffset
Definition: hfile.h:250
intn HTPdelete(atom_t ddid)
HDFLIBAPI intn HPfreediskblock(filerec_t *file_rec, int32 block_offset, int32 block_size)
HDFLIBAPI void HIrelease_accrec_node(accrec_t *acc)
intn attach
Definition: hfile.h:285
char * path
Definition: hfile.h:280
int16 key
Definition: hfile.h:407
HDFLIBAPI int32 HXPwrite(accrec_t *access_rec, int32 length, const void *data)
HDFLIBAPI intn HRPendaccess(accrec_t *access_rec)
HDFLIBAPI int32 HLPinfo(accrec_t *access_rec, sp_info_block_t *info_block)
HDFLIBAPI int32 HRPinquire(accrec_t *access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, int16 *pspecial)
HDFFCLIBAPI intf * buf
FILE * hdf_file_t
Definition: hfile.h:73
HDFLIBAPI int32 HCPinquire(accrec_t *access_rec, int32 *pfile_id, uint16 *ptag, uint16 *pref, int32 *plength, int32 *poffset, int32 *pposn, int16 *paccess, int16 *pspecial)

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