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