home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / hdf3_2r2.lha / HDF3.2r2 / src / vg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-28  |  14.2 KB  |  452 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/vg.h,v 1.2 1992/10/23 00:14:11 koziol beta koziol $
  27.  
  28. $Log: vg.h,v $
  29.  * Revision 1.2  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.1  1992/08/25  21:40:44  koziol
  37.  * Initial revision
  38.  *
  39. */
  40. /*****************************************************************************
  41. *  Likkai Ng MAY 91  NCSA
  42. * vg.h
  43. * Part of HDF VSet interface
  44. *
  45. * defines symbols and structures used in all v*.c files    
  46. *
  47. * NOTES:
  48. * This include file depends on the basic HDF *.h files dfi.h and df.h.
  49. * An 'S' in the comment means that that data field is saved in the HDF file.
  50. *
  51. ******************************************************************************/
  52.  
  53. #ifndef _VG_H
  54. #define _VG_H
  55.  
  56. #include "hdf.h"
  57. #include "herr.h"
  58.  
  59. /* H-level customization jason ng 12-Feb-92 */
  60. typedef int32           HFILEID;
  61. typedef unsigned char   BYTE;
  62. #ifdef OLD_WAY
  63. #define VGETSPACE(n)        HDgetspace((uint32)n)
  64. #define VFREESPACE(m)    HDfreespace((void*)m)
  65. #endif /* OLD_WAY */
  66.  
  67. #define QQnewref Hnewref
  68. #define QQstartread Hstartread 
  69. #define QQstartwrite Hstartwrite
  70. #define QQendaccess  Hendaccess
  71. #define QQQueryspecial HQueryspecial
  72. #define QQQuerytagref  HQuerytagref 
  73. #define QQQuerylength  HQuerylength
  74. #define QQgetelement  Hgetelement 
  75. #define QQputelement  Hputelement
  76. #define QQnextread  Hnextread
  77. #define QQdupdd  Hdupdd
  78. #define QQopen Hopen
  79. #define QQclose Hclose
  80. #define QQseek Hseek
  81. #define QQread Hread
  82. #define QQwrite Hwrite
  83.  
  84. /* 
  85. * interlacing supported by the vset. 
  86. */
  87.  
  88. #define FULL_INTERLACE    0
  89. #define NO_INTERLACE        1
  90.  
  91. /* 
  92. * some max lengths 
  93. *
  94. * Except for FIELDNAMELENMAX, change these as you please, they 
  95. * affect memory only, not the file. 
  96. *
  97. */
  98.  
  99. #define FIELDNAMELENMAX            16    /* fieldname   : 16 chars max */
  100.  
  101. #define VSFIELDMAX        20      /* max no of fields per vdata */
  102. #define VSNAMELENMAX        64    /* vdata name  : 64 chars max */    
  103. #define VGNAMELENMAX        64    /* vgroup name : 64 chars max */ 
  104.  
  105.  
  106. /*
  107. * definition of the 2 data elements of the vset.
  108. */
  109.  
  110. typedef struct vgroup_desc         VGROUP;
  111. typedef struct vdata_desc            VDATA;
  112.  
  113. typedef VDATA VSUBGROUP;
  114.  
  115.  
  116. /*
  117. * -----------------------------------------------------------------
  118. * structures that are part of the VDATA structure
  119. * -----------------------------------------------------------------
  120. */
  121.  
  122. typedef struct symdef_struct 
  123. {
  124.   char* name;            /* symbol name */
  125.   intn    type;            /* whether int, char, float etc */
  126.   intn    isize;            /* field size as stored in vdata */
  127.   intn    order;            /* order of field */
  128. } SYMDEF;
  129.  
  130. typedef struct vdata_memory_struct
  131. {
  132.   int32 n;                   /* byte size */
  133.   BYTE  * mem;
  134.   struct vdata_memory_struct * next;
  135. } VMBLOCK;
  136.  
  137.  
  138. typedef struct write_struct    
  139. {
  140.   int16    n;        /* S actual # fields in element */
  141.   int16    ivsize;        /* S size of element as stored in vdata */
  142.   char     name[VSFIELDMAX][FIELDNAMELENMAX+1]; /* S name of each field */
  143.   
  144.   int16    len[VSFIELDMAX];     /* S length of each fieldname */
  145.   int16    type[VSFIELDMAX];    /* S field type */
  146.   int16    off[VSFIELDMAX];     /* S field offset in element in vdata */
  147.   int16 isize[VSFIELDMAX];   /* S internal (HDF) size [incl order] */
  148.   int16    order[VSFIELDMAX];   /* S order of field */
  149.   int16    esize[VSFIELDMAX];   /*  external (local machine) size [incl order] */
  150.   int32    (*toIEEEfn  [VSFIELDMAX] )();
  151.   int32    (*fromIEEEfn[VSFIELDMAX] )();
  152. } VWRITELIST;
  153.  
  154. typedef struct read_struct
  155. {
  156.   intn  n;             /* # fields to read */
  157.   intn    item[VSFIELDMAX];     /* index into vftable_struct */
  158. } VREADLIST;
  159.  
  160. /* 
  161. *  ----------------------------------------------- 
  162.         V G R O U P     definition     
  163. *  ----------------------------------------------- 
  164. */
  165.  
  166. #define MAXNVELT  64        /* max no of objects in a vgroup */
  167.  
  168. struct vgroup_desc
  169.   uint16  otag, oref;           /* tag-ref of this vgroup */
  170.   HFILEID f;                 /* HDF file id  */
  171.   uint16  nvelt;         /* S no of objects */
  172.   intn      access;        /* 'r' or 'w' */
  173.   uint16  tag[MAXNVELT];    /* S tag of objects */
  174.   uint16  ref[MAXNVELT];    /* S ref of objects */
  175.   char      vgname[VGNAMELENMAX+1];/* S name of this vgroup */
  176.   char      vgclass[VGNAMELENMAX+1];/* S class name of this vgroup */
  177.   VDATA*  velt[MAXNVELT];    /* pts to a objects if attached; or else NULL */
  178.   intn      marked;        /* =1 if new info has been added to vgroup */
  179.   uint16  extag, exref;            /* expansion tag-ref */
  180.   int16      version, more;    /* version and "more" field */    
  181. };        
  182. /* VGROUP */
  183.  
  184. /*
  185. *  ----------------------------------------------- 
  186. *         V D A T A      definition   
  187. *  ----------------------------------------------- 
  188. */
  189.  
  190. #define USYMMAX 36            /* max user-defined symbols allowed */
  191.  
  192. struct vdata_desc { 
  193.   uint16    otag, oref;         /* tag,ref of this vdata */
  194.   HFILEID    f;               /* HDF file id */
  195.   intn        access;            /* 'r' or 'w' */
  196.   char        vsname[VSNAMELENMAX+1]; /* S name of this vdata */
  197.   char        vsclass[VSNAMELENMAX+1];/* S class name of this vdata */
  198.   int16        interlace;        /* S  interlace as in file */
  199.   int32        nvertices;        /* S  #vertices in this vdata */
  200.   VWRITELIST    wlist;
  201.   VREADLIST    rlist;
  202.   int16      nusym;
  203.   SYMDEF     usym[USYMMAX];
  204.   intn             marked;            /* =1 if new info has been added to vdata */
  205.   intn          islinked;         /* =1 if vdata is a linked-block in file */
  206.   
  207.   uint16    extag, exref;        /* expansion tag-ref */
  208.   int16        version, more;        /* version and "more" field */    
  209.   
  210.   VMBLOCK * vm;
  211.   int32     aid;  /* access id - for LINKED blocks */
  212.   struct vs_instance_struct *instance; /* ptr to the intance struct for this VData */
  213. }; /* VDATA */ 
  214.  
  215. /* macros - Use these for accessing items in a vdata or a group. */
  216. #define VQuerytag(vgroup)    (vgroup->otag)
  217. #define VQueryref(vgroup)    (vgroup->oref)
  218. #define VSQuerytag(vdata)    (vdata->otag)
  219. #define VSQueryref(vdata)    (vdata->oref)
  220.  
  221. /* macros - Use these for accessing user-defined fields in a vdata. */
  222. #define VFnfields(vdata)     (vdata->wlist.n)
  223. #define VFfieldname(vdata,t)     (vdata->wlist.name[t])
  224. #define VFfieldtype(vdata,t)     (vdata->wlist.type[t])
  225. #define VFfieldisize(vdata,t)     (vdata->wlist.isize[t])
  226. #define VFfieldesize(vdata,t)     (vdata->wlist.esize[t])
  227. #define VFfieldorder(vdata,t)     (vdata->wlist.order[t])
  228.  
  229. /* --------------  H D F    V S E T   tags  ---------------------------- */
  230.  
  231. #define OLD_VGDESCTAG      61820        /* tag for a vgroup d*/ 
  232. #define OLD_VSDESCTAG     61821        /* tag for a vdata descriptor */
  233. #define OLD_VSDATATAG     61822        /* tag for actual raw data of a vdata */ 
  234.  
  235. #define NEW_VGDESCTAG    1965
  236. #define NEW_VSDESCTAG    1962
  237. #define NEW_VSDATATAG    1963
  238.  
  239. #define VGDESCTAG         NEW_VGDESCTAG 
  240. #define VSDESCTAG         NEW_VSDESCTAG 
  241. #define VSDATATAG          NEW_VSDATATAG 
  242.  
  243. /*
  244. * Actual sizes of data types stored in HDF file. see hdf.h
  245. */
  246.  
  247. /*
  248. * Actual sizes of data types stored in HDF file, and are IEEE-defined. 
  249. *  == Obsolete. ==  24/March/92 
  250. */
  251. #define IEEE_UNTYPEDSIZE   0
  252. #define IEEE_CHARSIZE      1
  253. #define IEEE_INT16SIZE     2
  254. #define IEEE_INT32SIZE     4
  255. #define IEEE_FLOATSIZE     4
  256.  
  257. /*
  258. * types used in defining a new field via a call to VSfdefine
  259. */
  260.  
  261. #define LOCAL_NOTYPE            0
  262. #define LOCAL_CHARTYPE      1  /* 8-bit ascii text stream */
  263. #define LOCAL_INTTYPE          2  /* 32-bit integers - don't use */
  264. #define LOCAL_FLOATTYPE        3    /* as opposed to DOUBLE */ 
  265. #define LOCAL_LONGTYPE          4  /* 32-bit integers */
  266. #define LOCAL_BYTETYPE          5    /* 8-bit byte stream - unsupported */
  267. #define LOCAL_SHORTTYPE     6  /* 16-bit integers - unsupported */
  268. #define LOCAL_DOUBLETYPE     7    /* as opposed to FLOAT - unsupported */
  269.  
  270. /*
  271. * actual LOCAL MACHINE sizes of the above types
  272. */
  273.  
  274. #define LOCAL_UNTYPEDSIZE  0
  275. #define LOCAL_CHARSIZE      sizeof(char)
  276. #define LOCAL_INTSIZE          sizeof(int)
  277. #define LOCAL_FLOATSIZE     sizeof(float)
  278. #define LOCAL_LONGSIZE         sizeof(long)
  279. #define LOCAL_BYTESIZE      sizeof(unsigned char)
  280. #define LOCAL_SHORTSIZE      sizeof(short)
  281. #define LOCAL_DOUBLESIZE      sizeof(double)
  282.  
  283. /* kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk */
  284.  
  285. /* ------------------------------------------------------------------ */
  286. /* 2 GLOBAL VARIABLES (int vjv and char sj[]) provide a simple
  287. * debugging scheme. Debugging is turned on and off via calls to 
  288. * setjj and setnojj. These globals and functions are found in vgp.c.
  289. * If the debug feature is no longer needed, delete all these, and
  290. * all statements that refer to zj,sjs, and vjv from the source
  291. *
  292. */
  293.  
  294.  
  295. extern int16     vjv;         /* debugger switch */
  296. extern char     sjs[];         /* contains the debug/error message */
  297.  
  298. /* zj just prints out the contents of the text buffer sjs. */
  299. /* sjs contains debugging messages when debug is on */
  300. /* for the Mac, replace define zj to be any print msg routine */
  301.  
  302. #ifdef MAC
  303. #define zj
  304. #else
  305. #define zj \
  306.    {fprintf(stderr,"%s L-%d: %s",__FILE__,__LINE__,sjs); fflush(stderr); }
  307. #endif
  308.  
  309. /* Macros for returning null, -1 or no value with a message */
  310.  
  311. #define RTNULL(ss) { sprintf(sjs,"@%s\n",ss); zj; return(NULL); }
  312. #define RTNEG(ss) { sprintf(sjs,"@%s\n",ss); zj; return(FAIL); }
  313. #define RT(ss)     { sprintf(sjs,"@%s\n",ss); zj; return; }
  314.  
  315. /* need to tune these to vertex boundary later.  Jason Ng 6-APR-92 */
  316. #define VDEFAULTBLKSIZE    512
  317. #define VDEFAULTNBLKS      8
  318.  
  319. /* .................................................................. */
  320. /* Private data structures. Unlikely to be of interest to applications */
  321. /* 
  322. * These are just typedefs. Actual vfile_ts are declared PRIVATE and
  323. * are not accessible by applications. However, you may change VFILEMAX
  324. * to allow however many files to be opened.
  325. *
  326. * These are memory-resident copies of the tag-refs of the vgroups
  327. * and vdatas for each file that is opened.
  328. */
  329.  
  330. /* this is a memory copy of a vs tag/ref found in the file */
  331. typedef struct vg_instance_struct {
  332.     uintn    ref;           /* ref # of this vgroup in the file */
  333.     intn     nattach;        /* # of current attachs to this vgroup */
  334.     int32     nentries;    /* # of entries in that vgroup initially */
  335.     VGROUP     *vg;            /* points to the vg when it is attached */
  336.     struct vg_instance_struct * next;
  337. }    vginstance_t; 
  338.  
  339. /* this is a memory copy of a vs tag/ref found in the file */
  340. typedef struct vs_instance_struct {
  341.     uintn    ref;           /* ref # of this vdata in the file */
  342.     intn    nattach;        /* # of current attachs to this vdata */
  343.         int32   nvertices;  /* # of elements in that vdata initially */
  344.     VDATA    *vs;             /* points to the vdata when it is attached */
  345.     struct vs_instance_struct * next;
  346. }    vsinstance_t; 
  347.  
  348. /* each vfile_t maintains 2 linked lists: one of vgs and one of vdatas
  349. * that already exist or are just created for a given file.  */
  350.  
  351. typedef struct vfiledir_struct {
  352.  
  353.   int32            vgtabn;        /* # of vg entries in vgtab so far */
  354.   vginstance_t    vgtab;            /* start of vg linked list */
  355.   vginstance_t    *vgtabtail;         /* its tail end */
  356.   
  357.   int32            vstabn;        /* # of vs entries in vstab so far */
  358.   vsinstance_t    vstab;        /* start of vs linked list */
  359.   vsinstance_t    *vstabtail;        /* its tail end */
  360. } vfile_t;
  361.  
  362. /*
  363.  * NOTE:  People at large should not use this macro as they do not
  364.  *        have access to vfile[]
  365.  */
  366. #define Get_vfile(f) (f > 0 ? (&vfile[(f & 0xffff)]) : NULL)
  367.  
  368. /* .................................................................. */
  369. #define VSET_VERSION   3     /* DO NOT CHANGE!! */
  370. #define VSET_OLD_TYPES 2     /* All version <= 2 use old type mappings */
  371.  
  372. #ifdef MAC
  373. #include "vproto.h"
  374. #include <String.h>
  375. #endif
  376. #include <ctype.h>
  377.  
  378. /**  Quincy, these are to be deletedma dn put into hfile.c
  379.  
  380. * DFopen and DFclose are redefined to perform additional work, 
  381. * ie Vset data structure initialization and clean-up.
  382. * Does not affect usage by other HDF interfaces.
  383. */
  384.  
  385. #ifdef OLD_WAY
  386. #ifndef VMS
  387.  
  388. #define DFopen (HFILEID) DFvsetopen
  389. #define DFclose DFvsetclose
  390.  
  391. #define Hopen (HFILEID) DFvsetopen
  392. #define Hclose DFvsetclose
  393.  
  394. #else
  395.  
  396. /*
  397.   Hopen and DFopen have already been defined in dfivms.h to avoid
  398.   linker conflicts as the VMS linker is case insensitive
  399. */
  400.  
  401. #undef Hopen
  402. #undef DFopen
  403.  
  404. #define DFopen (HFILEID) DFvsetopen
  405. #define DFclose DFvsetclose
  406.  
  407. #define Hopen (HFILEID) DFvsetopen
  408. #define Hclose DFvsetclose
  409.  
  410. #endif /* VMS */
  411. #endif /* OLD_WAY */
  412.  
  413. /* .................................................................. */
  414.  
  415. /* all these macros should be public for users */
  416. /* macros for VSinquire */
  417.  
  418. #define VSQuerycount(vs, count) \
  419.         (VSinquire ((VDATA *) vs, (int32 *) count, (int32*) NULL, (char*) NULL, (int32*) NULL, (char*) NULL))
  420.  
  421. #define VSQueryinterlace(vs, intr) \
  422.         (VSinquire ((VDATA *) vs, (int32 *) NULL, (int32*) intr, (char*) NULL, (int32*) NULL, (char*) NULL))
  423.  
  424. #define VSQueryfields(vs, flds) \
  425.         (VSinquire ((VDATA *) vs, (int32 *) NULL, (int32*) NULL, (char*) flds, (int32*) NULL, (char*) NULL))
  426.  
  427. #define VSQueryvsize(vs, size) \
  428.         (VSinquire ((VDATA *) vs, (int32 *) NULL, (int32*) NULL, (char*) NULL, (int32*) size, (char*) NULL))
  429.  
  430. #define VSQueryname(vs, name) \
  431.         (VSinquire ((VDATA *) vs, (int32 *) NULL, (int32*) NULL, (char*) NULL, (int32*) size, (char*) name))
  432.  
  433. /*
  434.  *   Macros to provide fast access to the name and class of a Vset
  435.  *     element.  The information returned is only guarenteed to be
  436.  *     valid as long as the provided Vstructure is attached
  437.  */
  438.  
  439. #define VGCLASS(vg) ((vg)->vgclass)
  440. #define VGNAME(vg)  ((vg)->vgname)
  441.  
  442. #define VSCLASS(vs) ((vs)->vsclass)
  443. #define VSNAME(vs)  ((vs)->vsname)
  444.  
  445. #include "vproto.h"
  446.  
  447. #endif  /* _VG_H */
  448.