1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 void *
 ss_blob_read1(ss_blob_t *blob,                  /* The blob from which data should be read. */
               hsize_t offset,                   /* Offset w.r.t. the blob's data for the first element to be read. */
               hsize_t nelmts,                   /* Number of elements to be read from the blob's data. */
               unsigned flags,                   /* See the FLAGS argument of ss_blob_read(). */
               ss_prop_t *props                  /* See [Blob Properties]. */
               )
 {
     SS_ENTER(ss_blob_read1, voidP);
     hid_t       iospace=-1;
     void        *retval=NULL;
     int         ndims;

     SS_ASSERT_MEM(blob, ss_blob_t);
     if ((ndims=ss_blob_space(blob, NULL, &iospace))<0) SS_ERROR(FAILED);
     if (1!=ndims && 0!=ndims) SS_ERROR_FMT(USAGE, ("blob is not one-dimensional or scalar"));

     /* Select the elements of the `iospce'. Even if `nelmts' is zero we still have to call ss_blob_read() for some side
      * effects like for the SS_BLOB_UNBIND bit flag. */
     if (0==ndims) {
         SS_ASSERT(0==nelmts || 1==nelmts);
         SS_ASSERT(0==offset || 0==nelmts);
         if (0==nelmts) {
             if (H5Sselect_none(iospace)<0) SS_ERROR(HDF5);
         } else {
             if (H5Sselect_all(iospace)<0) SS_ERROR(HDF5);
         }
     } else {
         if (H5Sselect_slab(iospace, H5S_SELECT_SET, (hsize_t)0, &offset, &nelmts)<0) SS_ERROR(HDF5);
     }

     /* The actual write */
     if (NULL==(retval=ss_blob_read(blob, iospace, flags, props))) SS_ERROR(FAILED);

     /* Successful cleanup */
     if (H5Sclose(iospace)<0) SS_ERROR(HDF5);
     iospace = -1;

  SS_CLEANUP:
     if (iospace>0) H5Sclose(iospace);
     SS_LEAVE(retval);
 }