home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / VSet2.0 / temp / vg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-16  |  9.7 KB  |  316 lines  |  [TEXT/????]

  1. /*****************************************************************************
  2. *              NCSA HDF Vset release 2.1
  3. *                    May 1991
  4. *
  5. * NCSA HDF Vset release 2.1 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. *  Likkai Ng MAY 91  NCSA
  17. * vg.h
  18. * Part of HDF VSet interface
  19. *
  20. * defines symbols and structures used in all v*.c files    
  21. *
  22. * NOTES:
  23. * This include file depends on the basic HDF *.h files dfi.h and df.h.
  24. * An 'S' in the comment means that that data field is saved in the HDF file.
  25. *
  26. ******************************************************************************/
  27.  
  28.  
  29. #include <df.h>
  30.  
  31. #define PUBLIC        
  32. #define PRIVATE    static
  33.  
  34.  
  35. /* 
  36. * interlacing supported by the vset. 
  37. */
  38.  
  39. #define FULL_INTERLACE    0
  40. #define NO_INTERLACE        1
  41.  
  42. /* 
  43. * some max lengths 
  44. *
  45. * Except for FIELDNAMELENMAX, change these as you please, they 
  46. * affect memory only, not the file. 
  47. *
  48. */
  49.  
  50. #define FIELDNAMELENMAX    16                /* fieldname   : 16 chars max */
  51.  
  52. #define VSFIELDMAX        20              /* max no of fields per vdata */
  53. #define VSNAMELENMAX        64                /* vdata name  : 64 chars max */    
  54. #define VGNAMELENMAX        64                /* vgroup name : 64 chars max */    
  55. #define VFILEMAX             40             /* max no of files that may be opened */
  56. /* actually, for now, this is the max # of file units that can be used */
  57.  
  58.  
  59. /*
  60. * definition of the 2 data elements of the vset.
  61. */
  62.  
  63. typedef struct vgroup_desc         VGROUP;
  64. typedef struct vdata_desc            VDATA;
  65.  
  66. typedef VDATA VSUBGROUP;
  67.  
  68.  
  69. /*
  70. * -----------------------------------------------------------------
  71. * structures that are part of the VDATA structure
  72. * -----------------------------------------------------------------
  73. */
  74.  
  75. typedef struct symdef_struct 
  76. {
  77.     char* name;                        /* symbol name */
  78.     int    type;                        /* whether int, char, float etc */
  79.     int    isize;                    /* field size as stored in vdata */
  80.     int    order;                    /* order of field */
  81.  
  82.     } SYMDEF;
  83.  
  84. typedef struct write_struct    
  85. {
  86.     int32    n;                            /* S actual # fields in element */
  87.     int    ivsize;                    /* S size of element as stored in vdata */
  88.      char     name[VSFIELDMAX][FIELDNAMELENMAX+1];
  89.                                         /* S name of each field */
  90.     int    len[VSFIELDMAX];         /* S length of each fieldname */
  91.     int    type[VSFIELDMAX];        /* S field type */
  92.       int    off[VSFIELDMAX];        /* S field offset in element in vdata */
  93.       int     isize[VSFIELDMAX];    /* S internal (HDF) size [incl order] */
  94.       int    order[VSFIELDMAX];    /* S order of field */
  95.       int    esize[VSFIELDMAX];    /*  external (local machine) size [incl order] */
  96.     int    (*toIEEEfn  [VSFIELDMAX] )();
  97.     int    (*fromIEEEfn[VSFIELDMAX] )();
  98.  
  99.       }         VWRITELIST;
  100.  
  101. typedef struct read_struct
  102. {
  103.     int    n;                         /* # fields to read */
  104.     int    item[VSFIELDMAX];     /* index into vftable_struct */
  105.  
  106.     } VREADLIST;
  107.  
  108. /* 
  109. *  ----------------------------------------------- 
  110.         V G R O U P     definition     
  111. *  ----------------------------------------------- 
  112. */
  113.  
  114. #define MAXNVELT  36                /* max no of elements in a vgroup */
  115.  
  116. struct vgroup_desc
  117.     int    otag, oref;            /* tag-ref of this vgroup */
  118.       DF         *f;                          /* HDF file ptr */
  119.     int16     nvelt;                     /* S no of elements */
  120.       int     access;                    /* 'r' or 'w' */
  121.     int     tag[MAXNVELT];        /* S tag of element */
  122.     int     ref[MAXNVELT];        /* S ref of element */
  123.      char     vgname[VGNAMELENMAX+1];/* S name of this vgroup */
  124.      char     vgclass[VGNAMELENMAX+1];/*  class name of this vgroup */
  125.     VDATA* velt[MAXNVELT];         /* pts to a element if opened; or else NULL */
  126.     int    marked;                    /* =1 if new info has been added to vgroup */
  127.     int16        extag, exref;            /* expansion tag-ref */
  128.     int16        version, more;            /* version and "more" field */    
  129.  
  130.     };                                    /* VGROUP */
  131.  
  132. /*
  133. *  ----------------------------------------------- 
  134. *         V D A T A      definition   
  135. *  ----------------------------------------------- 
  136. */
  137.  
  138. #define USYMMAX 36                /* max user-defined symbols allowed */
  139.  
  140. struct vdata_desc{ 
  141.       int    otag, oref;             /* tag,ref of this vdata */
  142.       DF        *f;                          /* HDF file ptr */
  143.       int    access;                    /* 'r' or 'w' */
  144.      char    vsname[VSNAMELENMAX+1];/* S name of this vdata */
  145.      char    vsclass[VSNAMELENMAX+1];/* class name of this vdata */
  146.       int    interlace;                /* S  interlace as in file */
  147.       int32    nvertices;                /* S  #vertices in this vdata */
  148.     int    vpos;                    /* cur position (in terms of elements) */
  149.     VWRITELIST    wlist;
  150.       VREADLIST    rlist;
  151.     int              nusym;
  152.     SYMDEF         usym[USYMMAX];
  153.     int    marked;                    /* =1 if new info has been added to vdata */
  154.  
  155.     int16        extag, exref;            /* expansion tag-ref */
  156.     int16        version, more;            /* version and "more" field */    
  157.  
  158.       };                                  /* VDATA */ 
  159.  
  160. /* MACROS - Use these for accessing field components of vdata. */
  161.  
  162. #define VFnfields(vdata)         (vdata->wlist.n)
  163. #define VFfieldname(vdata,t)     (vdata->wlist.name[t])
  164. #define VFfieldtype(vdata,t)     (vdata->wlist.type[t])
  165. #define VFfieldisize(vdata,t)     (vdata->wlist.isize[t])
  166. #define VFfieldesize(vdata,t)     (vdata->wlist.esize[t])
  167. #define VFfieldorder(vdata,t)     (vdata->wlist.order[t])
  168.  
  169.  
  170. /* --------------  H D F    V S E T   tags  ---------------------------- */
  171.  
  172. #define OLD_VGDESCTAG      61820        /* tag for a vgroup d*/ 
  173. #define OLD_VSDESCTAG     61821        /* tag for a vdata descriptor */
  174. #define OLD_VSDATATAG     61822        /* tag for actual raw data of a vdata */ 
  175.  
  176. #define NEW_VGDESCTAG    1965
  177. #define NEW_VSDESCTAG    1962
  178. #define NEW_VSDATATAG    1963
  179.  
  180. #define VGDESCTAG         NEW_VGDESCTAG 
  181. #define VSDESCTAG         NEW_VSDESCTAG 
  182. #define VSDATATAG          NEW_VSDATATAG 
  183.  
  184. /*
  185. * Actual sizes of data types stored in HDF file, and are IEEE-defined. 
  186. */
  187.  
  188. #define IEEE_UNTYPEDSIZE   0
  189. #define IEEE_CHARSIZE      1
  190. #define IEEE_INT16SIZE     2
  191. #define IEEE_INT32SIZE     4
  192. #define IEEE_FLOATSIZE     4
  193.  
  194. /*
  195. * types used in defining a new field via a call to VSfdefine
  196. */
  197.  
  198. #define LOCAL_NOTYPE            0
  199. #define LOCAL_CHARTYPE      1
  200. #define LOCAL_INTTYPE          2
  201. #define LOCAL_FLOATTYPE        3
  202. #define LOCAL_LONGTYPE          4
  203.  
  204. /*
  205. * actual LOCAL MACHINE sizes of the above types
  206. */
  207.  
  208. #define LOCAL_UNTYPEDSIZE  0
  209. #define LOCAL_CHARSIZE      sizeof(unsigned char)
  210. #define LOCAL_INTSIZE          sizeof(int)
  211. #define LOCAL_LONGSIZE         sizeof(long)
  212. #define LOCAL_FLOATSIZE     sizeof(float)
  213.  
  214. /* ------------------------------------------------------------------ */
  215. /* 2 GLOBAL VARIABLES (int vjv and char sj[]) provide a simple
  216. * debugging scheme. Debugging is turned on and off via calls to 
  217. * setjj and setnojj. These globals and functions are found in vgp.c.
  218. * If the debug feature is no longer needed, delete all these, and
  219. * all statements that refer to xzj,sjs, and vjv from the source
  220. *
  221. */
  222.  
  223. extern int         vjv;             /* debugger switch */
  224. extern char     sjs[];         /* contains the debug/error message */
  225.  
  226. /* zj just prints out the contents of the text buffer sjs. */
  227. /* sjs contains debugging messages when debug is on */
  228. /* for the Mac, replace define zj to be any print msg routine */
  229.  
  230. #ifdef MAC
  231. #define zj
  232. #else
  233. #define zj         fprintf(stderr,"%s",sjs) 
  234. #endif
  235.  
  236. /* Macros for returning null, -1 or no value with a message */
  237.  
  238. #define FAIL -1
  239. #define RTNULL(ss) { sprintf(sjs,"@%s\n",ss); zj; return(NULL); }
  240. #define RTNEG(ss) { sprintf(sjs,"@%s\n",ss); zj; return(FAIL); }
  241. #define RT(ss) { sprintf(sjs,"@%s\n",ss); zj; return; }
  242.  
  243. /* .................................................................. */
  244. /* Private data structures. Unlikely to be of interest to applications */
  245. /* 
  246. * These are just typedefs. Actual vfile_ts are declared PRIVATE and
  247. * are not accessible by applications. However, you may change VFILEMAX
  248. * to allow however many files to be opened.
  249. *
  250. * These are memory-resident copies of the tag-refs of the vgroups
  251. * and vdatas for each file that is opened.
  252. */
  253.  
  254. /* this is a memory copy of a vs tag/ref found in the file */
  255. typedef struct vg_instance_struct {
  256.     int     ref;            /* ref # of this vgroup in the file */
  257.     int     nattach;        /* # of current attachs to this vgroup */
  258.     int     nentries;    /* # of entries in that vgroup initially */
  259.     VGROUP *vg;            /* points to the vg when it is attached */
  260. struct vg_instance_struct * next;
  261. }    vginstance_t; 
  262.  
  263. /* this is a memory copy of a vs tag/ref found in the file */
  264. typedef struct vs_instance_struct {
  265.     int    ref;            /* ref # of this vdata in the file */
  266.     int    nattach;        /* # of current attachs to this vdata */
  267.     int    nvertices;    /* # of elements in that vdata initially */
  268.     VDATA    * vs;         /* points to the vdata when it is attached */
  269.     struct vs_instance_struct * next;
  270. }    vsinstance_t; 
  271.  
  272. /* each vfile_t maintains 2 linked lists: one of vgs and one of vdatas
  273. * that already exist or are just created for a given file.  */
  274.  
  275. typedef struct vfiledir_struct {
  276.     DF            * f;
  277.  
  278.    int                vgtabn;                /* # of vg entries in vgtab so far */
  279.     vginstance_t    vgtab;                /* start of vg linked list */
  280.    vginstance_t    *vgtabtail;             /* its tail end */
  281.  
  282.    int                vstabn;                /* # of vs entries in vstab so far */
  283.     vsinstance_t    vstab;                /* start of vs linked list */
  284.    vsinstance_t    *vstabtail;            /* its tail end */
  285. } vfile_t;
  286.  
  287. /* .................................................................. */
  288. #define VSET_VERSION 2                    /* DO NOT CHANGE!! */
  289.  
  290.  
  291. #ifdef MAC
  292. #include "vset-prototypes.h"
  293. #include <String.h>
  294. #include <ctype.h>
  295. #endif
  296.  
  297.  
  298. /* 
  299. * DFopen and DFclose are redefined to perform additional work, 
  300. * ie Vset data structure initialization and clean-up.
  301. * Does not affect usage by other HDF interfaces.
  302. */
  303.  
  304. #define DFopen (DF*)DFvsetopen
  305. #define DFclose DFvsetclose
  306.  
  307.