home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / imdisp79.zip / DF.H < prev    next >
Text File  |  2003-02-02  |  12KB  |  267 lines

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