home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / src / df.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  7.1 KB  |  234 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/df.h,v 1.5 1992/10/23 00:14:11 koziol beta koziol $
  27.  
  28. $Log: df.h,v $
  29.  * Revision 1.5  1992/10/23  00:14:11  koziol
  30.  * Changed all DFIstr*() and DFImem*() calls to HDstr*() and HDmem*() calls
  31.  * #ifdef'd out the macros Jason defined for Hopen, Hclose, etc. for Vsets
  32.  * Replaced Vset VFREESPACE and VGETSPACE calls with actual calls to HDfreespace
  33.  * and HDgetspace
  34.  * Added a MS-Windows lower lower for file I/O (which may not be completely working
  35.  *
  36.  * Revision 1.3  1992/10/12  18:59:56  koziol
  37.  * Removed prototype for DFIstrncpy(), it's now a macro
  38.  *
  39.  * Revision 1.2  1992/10/12  18:11:51  koziol
  40.  * Updated for v3.2r2 release
  41.  *
  42.  * Revision 1.1  1992/08/25  21:40:44  koziol
  43.  * Initial revision
  44.  *
  45. */
  46. /*-----------------------------------------------------------------------------
  47.  * File:    df.h
  48.  * Purpose: header file for HDF routines
  49.  * Invokes: dfi.h
  50.  * Contents: 
  51.  *  Structure definitions: DFddh, DFdd, DFdesc, DFdle, DF, DFdi, DFdata
  52.  *  Procedure type definitions
  53.  *  Global variables
  54.  *  Tag definitions
  55.  *  Error return codes
  56.  *  Logical constants
  57.  * Remarks: This file is included with user programs
  58.  *          Since it includes stdio.h etc., do not include these after df.h
  59.  *---------------------------------------------------------------------------*/
  60.  
  61.  
  62. #ifndef DF_H              /* avoid re-inclusion */
  63. #define DF_H
  64.  
  65. /* include DF (internal) header information */
  66. #include "hdf.h"
  67. #include "herr.h"
  68. /*#include "dfi.h"*/
  69.  
  70. /*-------------------------------------------------------------------------*/
  71. /*                      Type declarations                                   */
  72.  
  73. typedef struct DFddh {        /*format of data descriptor headers in file*/
  74.     int16 dds;            /* number of dds in header block */
  75.     int32 next;            /* offset of next header block */
  76. } DFddh;
  77.  
  78. typedef struct DFdd {        /* format of data descriptors as in file */
  79.     uint16 tag;            /* data tag */
  80.     uint16 ref;            /* data reference number */
  81.     int32 offset;        /* offset of data element in file */
  82.     int32 length;        /* number of bytes */
  83. } DFdd;
  84.  
  85. /* descriptor structure is same as dd structure.  ###Note: may be changed */
  86. typedef DFdd DFdesc;
  87.  
  88. /* DLE is the internal structure which stores data descriptor information */
  89. /* It is a linked list of DDs */
  90. typedef struct DFdle {        /* Data List element */
  91.     struct DFdle *next;        /* link to next dle */
  92.     DFddh ddh;            /* To store headers */
  93.     DFdd dd[1];            /* dummy size */
  94. } DFdle;
  95.  
  96. /* DF is the internal structure associated with each DF file */
  97. /* It holds information associated with the file as a whole */
  98. /* ### Note: there are hooks for having multiple DF files open at a time */
  99. typedef struct DF {
  100.     DFdle *list;        /* Pointer to the DLE list */
  101.     DFdle *last_dle;        /* last_dle and last_dd are used in searches */
  102.                 /* to indicate element returned */
  103.                 /* by previous call to DFfind */
  104.     intn type;  /* 0= not in use, 1= normal, -1 = multiple */
  105.                 /* this is a hook for when */
  106.                 /* multiple files are open */
  107.     intn access;/* permitted access types: */
  108.                 /* 0=none, 1=r, 2=w, 3=r/w */
  109.     intn changed;   /* True if anything in DDs modified */
  110.                 /* since last write */
  111.     uint16 last_tag;        /* Last tag searched for by DFfind */
  112.     uint16 last_ref;        /* Last reference number searched for */
  113.     intn last_dd;   /* see last_dle */
  114.     intn defdds;    /* default numer of DD's in each block */
  115.     intn up_access; /* access permissions to element being */
  116.                 /* read/updated. Used by DFstart */
  117.     DFdd *up_dd;        /* DD of element being read/updated, */
  118.                 /* used by DFstart */
  119.     /* File handle is a file pointer or file descriptor depending on whether */
  120.     /* we use buffered or unbuffered I/O.  But, since this structure is a */
  121.     /* fake, it doesn't matter whether I/O is buffered or not. */
  122.     int file;            /* file descriptor */
  123. } DF;
  124.  
  125.  
  126. typedef struct DFdata { /* structure for returning status information */
  127.     int32 version;        /* version number of program */
  128. } DFdata;
  129.  
  130. /*--------------------------------------------------------------------------*/
  131. /*                          Procedure types                                 */
  132.  
  133. /* prototypes for dfstubs.c */
  134. extern DF *DFopen
  135.   PROTO((char *name, int access, int ndds));
  136.  
  137. extern int DFclose
  138.   PROTO((DF *dfile));
  139.  
  140. extern int DFdescriptors
  141.   PROTO((DF *dfile, DFdesc ptr[], int begin, int num));
  142.  
  143. extern int DFnumber
  144.   PROTO((DF *dfile, uint16 tag));
  145.  
  146. extern int DFsetfind
  147.   PROTO((DF *dfile, uint16 tag, uint16 ref));
  148.  
  149. extern int DFfind
  150.   PROTO((DF *dfile, DFdesc *ptr));
  151.  
  152. extern int DFaccess
  153.   PROTO((DF *dfile, uint16 tag, uint16 ref, char *access));
  154.  
  155. extern int DFstart
  156.   PROTO((DF *dfile, uint16 tag, uint16 ref, char *access));
  157.  
  158. extern int32 DFread
  159.   PROTO((DF *dfile, char *ptr, int32 len));
  160.  
  161. extern int32 DFseek
  162.   PROTO((DF *dfile, int32 offset));
  163.  
  164. extern int32 DFwrite
  165.   PROTO((DF *dfile, char *ptr, int32 len));
  166.  
  167. extern int DFupdate
  168.   PROTO((DF *dfile));
  169.  
  170. extern int DFstat
  171.   PROTO((DF *dfile, DFdata *dfinfo));
  172.  
  173. extern int32 DFgetelement
  174.   PROTO((DF *dfile, uint16 tag, uint16 ref, char *ptr));
  175.  
  176. extern int32 DFputelement
  177.   PROTO((DF *dfile, uint16 tag, uint16 ref, char *ptr, int32 len));
  178.  
  179. extern int DFdup
  180.   PROTO((DF *dfile, uint16 itag, uint16 iref, uint16 otag, uint16 oref));
  181.  
  182. extern int DFdel
  183.   PROTO((DF *dfile, uint16 tag, uint16 ref));
  184.  
  185. extern uint16 DFnewref
  186.   PROTO((DF *dfile));
  187.  
  188. extern int DFishdf
  189.   PROTO((char *filename));
  190.  
  191. extern int DFerrno
  192.   PROTO((void));
  193.  
  194. extern int DFIerr
  195.   PROTO((DF *dfile));
  196.  
  197. extern int DFImemcopy
  198.   PROTO((char *from, char *to, register int length));
  199.  
  200. extern void *DFIgetspace
  201.   PROTO((uint32 qty));
  202.  
  203. extern void *DFIfreespace
  204.   PROTO((void *ptr));
  205.  
  206. extern int DFIc2fstr
  207.   PROTO((char *str, int len));
  208.  
  209. extern char *DFIf2cstring
  210.   PROTO((_fcd fdesc, intn len));
  211.  
  212. #ifdef PC
  213. extern int32 DFIspaceleft
  214.   PROTO((void));
  215. #endif /* PC */
  216.  
  217. /*--------------------------------------------------------------------------*/
  218. /*                          Global Variables                                */
  219.  
  220. #ifndef DFMASTER
  221. extern
  222. #endif /*DFMASTER*/
  223. int
  224. #ifdef PC
  225. far
  226. #endif /* PC */
  227. DFerror;            /* Error code for DF routines */
  228.  
  229. #define DFSETERR(error) (DFerror=(DFerror?DFerror:error))
  230.  
  231. #define DFTOFID(df) (int32)(df->list)
  232.  
  233. #endif /* DF_H */
  234.