home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / hdf3_2r2.lha / HDF3.2r2 / src / vhi.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-28  |  4.8 KB  |  178 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. #ifdef RCSID
  26. static char RcsId[] = "@(#)$Revision: 1.1 $";
  27. #endif
  28. /*
  29. $Header: /hdf/hdf/v3.2r2/src/RCS/vhi.c,v 1.1 1992/08/25 21:40:44 koziol beta koziol $
  30.  
  31. $Log: vhi.c,v $
  32.  * Revision 1.1  1992/08/25  21:40:44  koziol
  33.  * Initial revision
  34.  *
  35. */
  36. /* 
  37. * ============================================
  38. * VHxxx  routines:
  39. * HDF Vset high-level access routines
  40. * 28-MAR-91 Jason Ng NCSA
  41. * Likkai Ng NCSA Feb 92 - update to use H-routines
  42.  
  43. * ============================================
  44. */
  45.  
  46. #include "vg.h"
  47.  
  48. /* ------------------------ VHstoredata ------------------------------- */
  49. /*
  50. Stores 'n' elements of data from 'buf' as a field 'field' in a new vdata 
  51. called 'vsname' into the already opened HDF file (with pointer 'f').
  52.  
  53. The datatype variable must be specified as a valid HDF type
  54.  
  55. NOTES:
  56. n should not be zero or negative.
  57. RETURN:
  58.       -1 if error.
  59.       ref of that new vdata (a +ve integer) if successful.
  60. */
  61.  
  62. #ifdef PROTOTYPE
  63. PUBLIC int32 VHstoredata (HFILEID f, char *field, BYTE buf[], int32 n, int32 datatype, char *vsname, char *vsclass)
  64. #else
  65.  
  66. PUBLIC int32 VHstoredata (f, field, buf, n, datatype, vsname, vsclass)
  67.     HFILEID     f;
  68.     char *     field;
  69.     BYTE        buf[];
  70.     int32     n;
  71.     char *     vsname, * vsclass;
  72.     int32     datatype;
  73. #endif
  74.  
  75. {
  76.   int32    ref;
  77.   int32 order = 1;
  78.   char * FUNC = "VHstoredata";
  79.   
  80.   ref = (int32) VHstoredatam (f, field, buf, n, datatype, vsname, vsclass, order);
  81.   return (ref);
  82. }
  83.  
  84. /* ----------------------- VHstoredatam ---------------------------- */
  85. /*
  86. Same as VHstoredata but allows aggregate-typed field.
  87. Stores 'n' elements of data from 'buf' as a
  88. field 'field' in a new vdata called 'vsname' into the
  89. already opened HDF file (with pointer 'f').
  90.  
  91. The datatype variable must be specified as a valid HDF type
  92.  
  93. NOTES:
  94. n should not be zero or negative.
  95. RETURN:
  96.       -1 if error.
  97.       ref of that new vdata (a +ve integer) if successful.
  98. */
  99. #ifdef PROTOTYPE
  100. PUBLIC int32 VHstoredatam (HFILEID f, char *field, BYTE buf[], int32  n, int32 datatype, char *vsname, char *vsclass, int32 order)
  101. #else
  102.  
  103. PUBLIC int32 VHstoredatam (f, field, buf, n, datatype, vsname, vsclass, order)
  104.     HFILEID     f;
  105.     char     *    field;
  106.     BYTE        buf[];
  107.     int32     n;
  108.     int32     datatype;
  109.     int32     order;
  110.     char *    vsname, * vsclass;
  111. #endif
  112.  
  113. {
  114.     int32 s;
  115.     int32 ref;
  116.     VDATA * vs;
  117.     char * FUNC = "VHstoredatam";
  118.  
  119.     vs = (VDATA*) VSattach (f,-1,"w");          if (vs==NULL) return (FAIL);
  120.     s = VSfdefine (vs, field, datatype, order); if (s == -1)  return (FAIL);
  121.     s = VSsetfields (vs,field);                 if (s == -1)  return (FAIL);
  122.     s = VSwrite (vs, buf, n, FULL_INTERLACE);   if (n != s)   return (FAIL);
  123.     VSsetname (vs, vsname);
  124.     VSsetclass(vs, vsclass);
  125.     ref = VSQueryref(vs);
  126.     VSdetach(vs);
  127.  
  128.     return ((int32) ref);
  129.  
  130. } /* VHstoredatam */
  131.  
  132. /* ------------------------ VHmakegroup ------------------------------- */
  133. /* 
  134. Takes an array of tags and and array of refs and create a vgroup to
  135. store them. You tell it how many tag/ref pairs there are. You must 
  136. also give the vgroup a name.
  137. NOTE:
  138. Does bot check if a tag/ref is valid or exist, but ALL tag/ref 
  139. pairs MUST be unique.
  140. Creating EMPTY vgroups is allowed.
  141.  
  142. RETURN: 
  143.       -1 if error
  144.       ref of the new vgroup (a +ve integre) if ok.
  145. */
  146. #ifdef PROTOTYPE
  147. PUBLIC int32 VHmakegroup (HFILEID f, int32 tagarray[], int32 refarray[] , int32 n, char *vgname, char *vgclass)
  148. #else
  149.  
  150. PUBLIC int32 VHmakegroup (f, tagarray, refarray , n, vgname, vgclass)
  151.     HFILEID     f;
  152.     int32      tagarray[], refarray[];
  153.     int32     n;
  154.     char         * vgname, * vgclass;
  155. #endif
  156.  
  157. {
  158.     int32     ref, i, s;    
  159.     VGROUP *    vg;
  160.     char * FUNC = "VHmakegroup";
  161.  
  162.     vg = (VGROUP*) Vattach (f, -1, "w"); if (vg==NULL) return (FAIL);
  163.     Vsetname (vg, vgname);
  164.     Vsetclass(vg, vgclass);
  165.  
  166.     for (i=0; i<n; i++) {
  167.         s = Vaddtagref (vg, tagarray[i], refarray[i]);
  168.         if (s == -1) return (FAIL);
  169.         }
  170.  
  171.     ref = VQueryref(vg);
  172.     Vdetach (vg);
  173.     return (ref);
  174.  
  175. } /* VHmakegroup */
  176.  
  177. /* ------------------------------------------------------------------ */
  178.