home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / hdf / hdf.lha / DF.H next >
Encoding:
C/C++ Source or Header  |  1980-02-06  |  10.9 KB  |  252 lines

  1. /*****************************************************************************
  2. *              NCSA HDF version 3.10r2
  3. *                Sept 20, 1990
  4. *
  5. * NCSA HDF Version 3.10r2 source code and documentation are in the public
  6. * domain.  Specifically, we give to the public domain all rights for future
  7. * licensing of the source code, all resale rights, and all publishing rights.
  8. * We ask, but do not require, that the following message be included in all
  9. * derived works:
  10. * Portions developed at the National Center for Supercomputing Applications at
  11. * the University of Illinois at Urbana-Champaign.
  12. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  13. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  14. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  15. *****************************************************************************/
  16.  
  17. /*
  18. $Header: /pita/work/HDF/dev/RCS/src/df.h,v 3.2 90/05/17 17:12:32 clow beta $
  19. $Log:    df.h,v $
  20.  * Revision 3.2  90/05/17  17:12:32  clow
  21.  * removed #include <fortran.h> which has migrated to dfi.h
  22.  * 
  23. */
  24. /*-----------------------------------------------------------------------------
  25.  * File:    df.h
  26.  * Purpose: header file for HDF routines
  27.  * Invokes: dfi.h
  28.  * Contents: 
  29.  *  Structure definitions: DFddh, DFdd, DFdesc, DFdle, DF, DFdi, DFdata
  30.  *  Procedure type definitions
  31.  *  Global variables
  32.  *  Tag definitions
  33.  *  Error return codes
  34.  *  Logical constants
  35.  * Remarks: This file is included with user programs
  36.  *          Since it includes stdio.h etc., do not include these after df.h
  37.  *-----------------------------------------------------------------------*/
  38.  
  39.  
  40. #include "dfi.h"
  41.  
  42. /*-----------------------------------------------------------------------*/
  43. /*                      Type declarations                                */
  44.  
  45. typedef struct DFddh {        /*format of data descriptor headers in file*/
  46.     int16 dds;            /* number of dds in header block */
  47.     int32 next;            /* offset of next header block */
  48. } DFddh;
  49.  
  50. typedef struct DFdd {        /* format of data descriptors as in file */
  51.     uint16 tag;            /* data tag */
  52.     uint16 ref;            /* data reference number */
  53.     int32 offset;        /* offset of data element in file */
  54.     int32 length;        /* number of bytes */
  55. } DFdd;
  56.  
  57. /* descriptor structure is same as dd structure.  ###Note: may be changed */
  58. #define DFdesc DFdd
  59.  
  60. /* DLE is the internal structure which stores data descriptor information */
  61. /* It is a linked list of DDs */
  62. typedef struct DFdle {        /* Data List element */
  63.     struct DFdle *next;        /* link to next dle */
  64.     DFddh ddh;            /* To store headers */
  65.     DFdd dd[1];            /* dummy size */
  66. } DFdle;
  67.  
  68. /* DF is the internal structure associated with each DF file */
  69. /* It holds information associated with the file as a whole */
  70. /* ### Note: there are hooks for having multiple DF files open at a time */
  71. typedef struct DF {
  72.     DFdle *list;        /* Pointer to the DLE list */
  73.     DFdle *last_dle;        /* last_dle and last_dd are used in searches */
  74.                 /* to indicate element returned */
  75.                 /* by previous call to DFfind */
  76.     int type;            /* 0= not in use, 1= normal, -1 = multiple */
  77.                 /* this is a hook for when */
  78.                 /* multiple files are open */
  79.     int access;            /* permitted access types: */
  80.                 /* 0=none, 1=r, 2=w, 3=r/w */
  81.     int changed;        /* True if anything in DDs modified */
  82.                 /* since last write */
  83.     uint16 last_tag;        /* Last tag searched for by DFfind */
  84.     uint16 last_ref;        /* Last reference number searched for */
  85.     int last_dd;        /* see last_dle */
  86.     int defdds;            /* default numer of DD's in each block */
  87.     int up_access;        /* access permissions to element being */
  88.                 /* read/updated. Used by DFstart */
  89.     DFdd *up_dd;        /* DD of element being read/updated, */
  90.                 /* used by DFstart */
  91.     /* file handle is a file pointer or file descriptor depending on whether */
  92.     /* we use buffered or unbuffered i/o */
  93. #ifdef DF_BUFFIO
  94.     FILE *file;            /* file pointer */
  95. #else /*DF_BUFFIO*/
  96.     int file;            /* file descriptor */
  97. #endif /*DF_BUFFIO*/
  98. } DF;
  99.  
  100.  
  101. typedef struct DFdi {   /* data identifier: specifies data element uniquely */
  102.     uint16 tag;
  103.     uint16 ref;
  104. } DFdi;
  105.  
  106.  
  107.  
  108. typedef struct DFdata { /* structure for returning status information */
  109.     int version;        /* version number of program */
  110. } DFdata;
  111.  
  112. /*--------------------------------------------------------------------------*/
  113. /*                          Procedure types                                 */
  114. #include "dfproto.h"
  115.  
  116. /*--------------------------------------------------------------------------*/
  117. /*                          Global Variables                                */
  118.  
  119. #ifndef DFMASTER
  120. extern
  121. #endif /*DFMASTER*/
  122. int DFerror;            /* Error code for DF routines */
  123.  
  124. /*--------------------------------------------------------------------------*/
  125. /*                           Tag Definitions                                */
  126.  
  127. #define DFREF_WILDCARD ((uint16)0) /* wildcard ref for searches */
  128.  
  129. #define DFTAG_WILDCARD ((uint16)0) /* wildcard tag for searches */
  130. #define DFTAG_NULL  ((uint16)1)    /* empty DD */
  131.  
  132. /* utility set */
  133. #define DFTAG_FID   ((uint16)100) /* File identifier */
  134. #define DFTAG_FD    ((uint16)101) /* File description */
  135. #define DFTAG_TID   ((uint16)102) /* Tag identifier */
  136. #define DFTAG_TD    ((uint16)103) /* Tag descriptor */
  137. #define DFTAG_DIL   ((uint16)104) /* data identifier label */
  138. #define DFTAG_DIA   ((uint16)105) /* data identifier annotation */
  139. #define DFTAG_NT    ((uint16)106) /* number type */
  140. #define DFTAG_MT    ((uint16)107) /* machine type */
  141.  
  142. /* raster-8 set */
  143. #define DFTAG_ID8   ((uint16)200) /* 8-bit Image dimension */
  144. #define DFTAG_IP8   ((uint16)201) /* 8-bit Image palette */
  145. #define DFTAG_RI8   ((uint16)202) /* Raster-8 image */
  146. #define DFTAG_CI8   ((uint16)203) /* RLE compressed 8-bit image */
  147. #define DFTAG_II8   ((uint16)204) /* IMCOMP compressed 8-bit image */
  148.  
  149. /* Raster Image set */
  150. #define DFTAG_ID    ((uint16)300) /* Image DimRec */
  151. #define DFTAG_LUT   ((uint16)301) /* Image Palette */
  152. #define DFTAG_RI    ((uint16)302) /* Raster Image */
  153. #define DFTAG_CI    ((uint16)303) /* Compressed Image */
  154.  
  155. #define DFTAG_RIG   ((uint16)306) /* Raster Image Group */
  156. #define DFTAG_LD    ((uint16)307) /* Palette DimRec */
  157. #define DFTAG_MD    ((uint16)308) /* Matte DimRec */
  158. #define DFTAG_MA    ((uint16)309) /* Matte Data */
  159. #define DFTAG_CCN   ((uint16)310) /* color correction */
  160. #define DFTAG_CFM   ((uint16)311) /* color format */
  161. #define DFTAG_AR    ((uint16)312) /* aspect ratio */
  162.  
  163. #define DFTAG_DRAW  ((uint16)400) /* Draw these images in sequence */
  164. #define DFTAG_RUN   ((uint16)401) /* run this as a program/script */
  165.  
  166. #define DFTAG_XYP   ((uint16)500) /* x-y position */
  167. #define DFTAG_MTO   ((uint16)501) /* machine-type override */
  168.  
  169. /* Tektronix */
  170. #define DFTAG_T14   ((uint16)602) /* TEK 4014 data */
  171. #define DFTAG_T105  ((uint16)603) /* TEK 4105 data */
  172.  
  173. /* Scientific Data set */
  174. #define DFTAG_SDG   ((uint16)700) /* Scientific Data Group */
  175. #define DFTAG_SDD   ((uint16)701) /* Scientific Data DimRec */
  176. #define DFTAG_SD    ((uint16)702) /* Scientific Data */
  177. #define DFTAG_SDS   ((uint16)703) /* Scales */
  178. #define DFTAG_SDL   ((uint16)704) /* Labels */
  179. #define DFTAG_SDU   ((uint16)705) /* Units */
  180. #define DFTAG_SDF   ((uint16)706) /* Formats */
  181. #define DFTAG_SDM   ((uint16)707) /* Max/Min */
  182. #define DFTAG_SDC   ((uint16)708) /* Coord sys */
  183. #define DFTAG_SDT   ((uint16)709) /* Transpose */
  184.  
  185. /* compression schemes */
  186. #define DFTAG_RLE   ((uint16)11) /* run length encoding */
  187. #define DFTAG_IMC   ((uint16)12) /* IMCOMP compression */
  188.  
  189. /*--------------------------------------------------------------------------*/
  190. /*                          Error Return Codes                              */
  191.  
  192. #define DFE_NOERROR     0   /* No error */
  193. #define DFE_FNF         -1  /* File not found error */
  194. #define DFE_DENIED      -2  /* Access to file denied */
  195. #define DFE_ALROPEN     -3  /* File already open */
  196. #define DFE_TOOMANY     -4  /* Too Many DF's or files open */
  197. #define DFE_BADNAME     -5  /* Bad file name on open */
  198. #define DFE_BADACC      -6  /* Bad file access mode */
  199. #define DFE_BADOPEN     -7  /* Other open error */
  200. #define DFE_NOTOPEN     -8  /* File can't be closed 'cause it isn't open */
  201. #define DFE_CANTCLOSE   -9  /* fclose wouldn't work! */
  202. #define DFE_DFNULL      -10 /* DF is a null pointer */
  203. #define DFE_ILLTYPE     -11 /* DF has an illegal type: internal error */
  204. #define DFE_UNSUPPORTED -12 /* Feature not currently supported */
  205. #define DFE_BADDDLIST   -13 /* The DD list is non-existent: internal error */
  206. #define DFE_NOTDFFILE   -14 /* This is not a DF file and it is not 0 length */
  207. #define DFE_SEEDTWICE   -15 /* The DD list already seeded: internal error */
  208. #define DFE_NOSPACE     -16 /* Malloc failed */
  209. #define DFE_NOSUCHTAG   -17 /* There is no such tag in the file: search failed*/
  210. #define DFE_READERROR   -18 /* There was a read error */
  211. #define DFE_WRITEERROR  -19 /* There was a write error */
  212. #define DFE_SEEKERROR   -20 /* There was a seek error */
  213. #define DFE_NOFREEDD    -21 /* There are no free DD's left: internal error */
  214. #define DFE_BADTAG      -22 /* illegal WILDCARD tag */
  215. #define DFE_BADREF      -23 /* illegal WILDCARD reference # */
  216. #define DFE_RDONLY      -24 /* The DF is read only */
  217. #define DFE_BADCALL     -25 /* Calls in wrong order */
  218. #define DFE_BADPTR      -26 /* NULL ptr argument */
  219. #define DFE_BADLEN      -27 /* negative len specified */
  220. #define DFE_BADSEEK     -28 /* Attempt to seek past end of element */
  221. #define DFE_NOMATCH     -29 /* No (more) DDs which match specified tag/ref */
  222. #define DFE_NOTINSET    -30 /* Warning: Set contained unknown tag: ignored */
  223. #define DFE_BADDIM      -31 /* negative or zero dimensions specified */
  224. #define DFE_BADOFFSET   -32 /* Illegal offset specified */
  225. #define DFE_BADSCHEME   -33 /* Unknown compression scheme specified */
  226. #define DFE_NODIM       -34 /* No dimension record associated with image */
  227. #define DFE_NOTENOUGH   -35 /* space provided insufficient for size of data */
  228. #define DFE_NOVALS      -36 /* Values not available */
  229. #define DFE_CORRUPT     -37 /* File is corrupted */
  230. #define DFE_BADCONV     -37 /* Don't know how to convert data type */
  231. #define DFE_BADFP       -38 /* The file contained an illegal floating point no*/
  232. #define DFE_NOREF       -39 /* no more reference numbers are available */
  233. #define DFE_BADDATATYPE -40 /* unknown or unavailable data type specified */
  234. #define DFE_BADMCTYPE   -41 /* unknown or unavailable machine type specified */
  235. #define DFE_BADNUMTYPE  -42 /* unknown or unavailable number type specified */
  236. #define DFE_BADORDER    -43 /* unknown or illegal array order specified */
  237. #define DFE_NOTIMPL     -44 /* This feature not yet implemented */
  238.  
  239. /*--------------------------------------------------------------------------*/
  240. /*                          Logical Constants                               */
  241.  
  242. #define DFACC_READ      1   /* Read Access */
  243. #define DFACC_WRITE     2   /* Write Access */
  244. #define DFACC_CREATE    4   /* force file to be created */
  245. #define DFACC_ALL       7   /* the logical and of all the above values */
  246.  
  247.