summaryrefslogtreecommitdiffstats
path: root/hl/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-04-21 22:46:38 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-04-21 22:46:38 (GMT)
commit5bb857476f99118cda0e54ea522f52933a582747 (patch)
tree741024b69250fe9166091aa8f28bc78c35d3fb64 /hl/src
parent35bbc743d4cf77d6aa8af2acf5578db02e5129ca (diff)
downloadhdf5-5bb857476f99118cda0e54ea522f52933a582747.zip
hdf5-5bb857476f99118cda0e54ea522f52933a582747.tar.gz
hdf5-5bb857476f99118cda0e54ea522f52933a582747.tar.bz2
[svn-r16825] Description:
Bring revisions 16636:16821 from trunk to revise_chunks branch Tested on: FreeBSD/32 6.3 (duty) Mac OS X/32 10.5.6 (amazon) (h5committest not needed on this branch)
Diffstat (limited to 'hl/src')
-rw-r--r--hl/src/H5DS.c222
-rw-r--r--hl/src/H5IM.c1817
-rw-r--r--hl/src/H5LT.c3328
-rw-r--r--hl/src/H5TB.c2346
-rw-r--r--hl/src/Makefile.am4
-rw-r--r--hl/src/Makefile.in40
6 files changed, 3924 insertions, 3833 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index 83bb1ed..9efa95e 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -142,13 +142,18 @@ herr_t H5DSattach_scale(hid_t did,
H5I_type_t it1, it2;
int i, len;
int found_ds=0;
+ htri_t is_scale;
/*-------------------------------------------------------------------------
* parameter checking
*-------------------------------------------------------------------------
*/
+
+ if ((is_scale = H5DSis_scale(did)) < 0)
+ return FAIL;
+
/* the dataset cannot be a DS dataset */
- if ((H5DSis_scale(did))==1)
+ if ( is_scale == 1)
return FAIL;
/* get info for the dataset in the parameter list */
@@ -477,7 +482,7 @@ herr_t H5DSattach_scale(hid_t did,
nelmts++;
- dsbuf = malloc((size_t)nelmts * sizeof(ds_list_t));
+ dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t));
if (dsbuf == NULL)
goto out;
@@ -637,13 +642,18 @@ herr_t H5DSdetach_scale(hid_t did,
H5O_info_t oi1, oi2, oi3, oi4;
int found_dset = 0, found_ds = 0;
H5I_type_t it1, it2;
+ htri_t is_scale;
/*-------------------------------------------------------------------------
* parameter checking
*-------------------------------------------------------------------------
*/
+
+ if ((is_scale = H5DSis_scale(did)) < 0)
+ return FAIL;
+
/* the dataset cannot be a DS dataset */
- if ((H5DSis_scale(did))==1)
+ if ( is_scale == 1)
return FAIL;
/* get info for the dataset in the parameter list */
@@ -691,6 +701,9 @@ herr_t H5DSdetach_scale(hid_t did,
if (H5Sclose(sid) < 0)
return FAIL;
+ /* parameter range checking */
+ if (idx>(unsigned)rank-1)
+ return FAIL;
/*-------------------------------------------------------------------------
* find "REFERENCE_LIST"
@@ -749,13 +762,21 @@ herr_t H5DSdetach_scale(hid_t did,
goto out;
/* same object, reset */
- if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) {
+ if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr)
+ {
+ size_t len;
+
for(jj=j; jj<buf[idx].len-1; jj++)
+ {
((hobj_ref_t *)buf[idx].p)[jj] = ((hobj_ref_t *)buf[idx].p)[jj+1];
+ }
+
buf[idx].len--;
-
+ len = buf[idx].len;
+ buf[idx].p = realloc( buf[idx].p, len * sizeof(hobj_ref_t));
+
found_ds = 1;
-
+
/* close the dereferenced dataset and break */
if (H5Dclose(dsid_j) < 0)
goto out;
@@ -810,7 +831,7 @@ herr_t H5DSdetach_scale(hid_t did,
if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
- dsbuf = malloc((size_t)nelmts * sizeof(ds_list_t));
+ dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t));
if(dsbuf == NULL)
goto out;
@@ -886,7 +907,7 @@ herr_t H5DSdetach_scale(hid_t did,
goto out;
dims[0] = nelmts;
- dsbufn = malloc((size_t)nelmts * sizeof(ds_list_t));
+ dsbufn = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t));
if(dsbufn == NULL)
goto out;
@@ -1014,13 +1035,18 @@ htri_t H5DSis_attached(hid_t did,
H5I_type_t it1, it2;
int i;
int found_dset=0, found_ds=0;
+ htri_t is_scale;
/*-------------------------------------------------------------------------
* parameter checking
*-------------------------------------------------------------------------
*/
+
+ if ((is_scale = H5DSis_scale(did)) < 0)
+ return FAIL;
+
/* the dataset cannot be a DS dataset */
- if ((H5DSis_scale(did))==1)
+ if ( is_scale == 1)
return FAIL;
/* get info for the dataset in the parameter list */
@@ -1063,7 +1089,7 @@ htri_t H5DSis_attached(hid_t did,
/* parameter range checking */
if(idx > ((unsigned)rank - 1))
- goto out;
+ return FAIL;
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
@@ -1169,7 +1195,7 @@ htri_t H5DSis_attached(hid_t did,
if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
- dsbuf = malloc((size_t)nelmts * sizeof(ds_list_t));
+ dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t));
if (dsbuf == NULL)
goto out;
@@ -1266,11 +1292,12 @@ out:
* Parameters:
*
* hid_t DID; IN: the dataset
-* unsigned int dim; IN: the dimension of the dataset
-* int *idx; IN/OUT: input the index to start iterating, output the
-* next index to visit. If NULL, start at the first position.
-* H5DS_iterate_t visitor; IN: the visitor function
-* void *visitor_data; IN: arbitrary data to pass to the visitor function.
+* unsigned int DIM; IN: the dimension of the dataset
+* int *DS_IDX; IN/OUT: on input the dimension scale index to start iterating,
+* on output the next index to visit. If NULL, start at
+* the first position.
+* H5DS_iterate_t VISITOR; IN: the visitor function
+* void *VISITOR_DATA; IN: arbitrary data to pass to the visitor function.
*
* Iterate over all scales of DIM, calling an application callback
* with the item, key and any operator data.
@@ -1298,7 +1325,7 @@ out:
herr_t H5DSiterate_scales(hid_t did,
unsigned int dim,
- int *idx,
+ int *ds_idx,
H5DS_iterate_t visitor,
void *visitor_data )
{
@@ -1331,6 +1358,13 @@ herr_t H5DSiterate_scales(hid_t did,
if ((nscales = H5DSget_num_scales(did,dim)) < 0)
return FAIL;
+ /* parameter range checking */
+ if (ds_idx!=NULL)
+ {
+ if (*ds_idx>=nscales)
+ return FAIL;
+ }
+
/* get dataset space */
if ((sid = H5Dget_space(did)) < 0)
return FAIL;
@@ -1343,6 +1377,9 @@ herr_t H5DSiterate_scales(hid_t did,
if(H5Sclose(sid) < 0)
goto out;
+ if ( dim >= (unsigned)rank )
+ return FAIL;
+
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
@@ -1371,8 +1408,8 @@ herr_t H5DSiterate_scales(hid_t did,
if ( buf[dim].len > 0 )
{
- if (idx!=NULL)
- j_idx = *idx;
+ if (ds_idx!=NULL)
+ j_idx = *ds_idx;
else
j_idx=0;
@@ -1389,14 +1426,16 @@ herr_t H5DSiterate_scales(hid_t did,
goto out;
} H5E_END_TRY;
- if((ret_value=(visitor)(did,dim,scale_id,visitor_data))!=0)
+ /* set the return IDX OUT value at current scale index */
+ if (ds_idx!=NULL)
{
- /* set the return IDX OUT value at current scale index and break */
- if (idx!=NULL)
- {
- *idx = i;
- }
+ *ds_idx = i;
+ }
+ if((ret_value=(visitor)(did,dim,scale_id,visitor_data))!=0)
+ {
+ /* break */
+
/* close the DS id */
if (H5Dclose(scale_id) < 0)
goto out;
@@ -1462,16 +1501,17 @@ out:
*-------------------------------------------------------------------------
*/
-herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
- int has_labels;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- hsize_t dims[1]; /* dimensions of dataset */
- const char **buf = NULL; /* buffer to store in the attribute */
- H5I_type_t it; /* ID type */
- unsigned int i;
+herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
+{
+ int has_labels;
+ hid_t sid = -1; /* space ID */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t aid = -1; /* attribute ID */
+ int rank; /* rank of dataset */
+ hsize_t dims[1]; /* dimensions of dataset */
+ const char **buf = NULL; /* buffer to store in the attribute */
+ H5I_type_t it; /* ID type */
+ unsigned int i;
/*-------------------------------------------------------------------------
* parameter checking
@@ -1484,16 +1524,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
if (H5I_DATASET != it)
return FAIL;
- /*-------------------------------------------------------------------------
- * attribute "DIMENSION_LABELS"
- *-------------------------------------------------------------------------
- */
-
- /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */
- if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0)
- return FAIL;
-
- /* get dataset space */
+ /* get dataset space */
if ((sid = H5Dget_space(did)) < 0)
return FAIL;
@@ -1505,12 +1536,25 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
if (H5Sclose(sid) < 0)
goto out;
+ if ( idx >= (unsigned)rank )
+ return FAIL;
+
+ /*-------------------------------------------------------------------------
+ * attribute "DIMENSION_LABELS"
+ *-------------------------------------------------------------------------
+ */
+
+ /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */
+ if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0)
+ return FAIL;
+
/*-------------------------------------------------------------------------
* make the attribute and insert label
*-------------------------------------------------------------------------
*/
- if (has_labels == 0) {
+ if (has_labels == 0)
+ {
dims[0] = rank;
/* space for the attribute */
@@ -1524,8 +1568,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
goto out;
/* create the attribute */
- if ((aid = H5Acreate2(did, DIMENSION_LABELS, tid, sid,
- H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(did, DIMENSION_LABELS, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* allocate and initialize */
@@ -1553,7 +1596,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
goto out;
if (buf)
{
- free((void *) buf);
+ free(buf);
buf = NULL;
}
}
@@ -1563,7 +1606,8 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
*-------------------------------------------------------------------------
*/
- else {
+ else
+ {
if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0)
goto out;
@@ -1595,7 +1639,8 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
buf[idx] = NULL;
/* free all the ptr's from the H5Aread() */
- for (i = 0; i < (unsigned int) rank; i++) {
+ for (i = 0; i < (unsigned int) rank; i++)
+ {
if (buf[i])
free(buf[i]);
}
@@ -1607,7 +1652,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
goto out;
if (buf)
{
- free((void *) buf);
+ free(buf);
buf = NULL;
}
}
@@ -1616,11 +1661,13 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) {
/* error zone */
out:
- if (buf) {
+ if (buf)
+ {
if (buf[idx]) /* check if we errored during H5Awrite */
buf[idx] = NULL; /* don't free label */
/* free all the ptr's from the H5Aread() */
- for (i = 0; i < (unsigned int) rank; i++) {
+ for (i = 0; i < (unsigned int) rank; i++)
+ {
if (buf[i])
free(buf[i]);
}
@@ -1656,17 +1703,18 @@ out:
*
*-------------------------------------------------------------------------
*/
-ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) {
- int has_labels;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- char **buf = NULL; /* buffer to store in the attribute */
- H5I_type_t it; /* ID type */
- size_t nbytes;
- size_t copy_len;
- int i;
+ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
+{
+ int has_labels;
+ hid_t sid = -1; /* space ID */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t aid = -1; /* attribute ID */
+ int rank; /* rank of dataset */
+ char **buf = NULL; /* buffer to store in the attribute */
+ H5I_type_t it; /* ID type */
+ size_t nbytes;
+ size_t copy_len;
+ int i;
/*-------------------------------------------------------------------------
* parameter checking
@@ -1679,6 +1727,21 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) {
if (H5I_DATASET != it)
return FAIL;
+ /* get dataset space */
+ if ((sid = H5Dget_space(did)) < 0)
+ return FAIL;
+
+ /* get rank */
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ goto out;
+
+ /* close dataset space */
+ if (H5Sclose(sid) < 0)
+ goto out;
+
+ if ( idx >= (unsigned)rank )
+ return FAIL;
+
/*-------------------------------------------------------------------------
* attribute "DIMENSION_LABELS"
*-------------------------------------------------------------------------
@@ -1694,19 +1757,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) {
if (label)
label[0] = 0;
return 0;
- }
-
- /* get dataset space */
- if ((sid = H5Dget_space(did)) < 0)
- return FAIL;
-
- /* get rank */
- if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
- goto out;
-
- /* close dataset space */
- if (H5Sclose(sid) < 0)
- goto out;
+ }
/*-------------------------------------------------------------------------
* open the attribute and read label
@@ -1737,7 +1788,8 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) {
copy_len = MIN(size-1, nbytes);
/* copy all/some of the name */
- if (label) {
+ if (label)
+ {
memcpy(label, buf[idx], copy_len);
/* terminate the string */
@@ -1745,7 +1797,8 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) {
}
/* free all the ptr's from the H5Aread() */
- for (i = 0; i < (unsigned int) rank; i++) {
+ for (i = 0; i < rank; i++)
+ {
if (buf[i])
free(buf[i]);
}
@@ -1765,9 +1818,11 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) {
/* error zone */
out:
- if (buf) {
+ if (buf)
+ {
/* free all the ptr's from the H5Aread() */
- for (i = 0; i < (unsigned int) rank; i++) {
+ for (i = 0; i < rank; i++)
+ {
if (buf[i])
free(buf[i]);
}
@@ -2186,7 +2241,8 @@ herr_t H5DS_is_reserved(hid_t did)
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(tid);
H5Aclose(aid);
} H5E_END_TRY;
diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c
index 479b572..361a65b 100644
--- a/hl/src/H5IM.c
+++ b/hl/src/H5IM.c
@@ -1,17 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+* Copyright by The HDF Group. *
+* Copyright by the Board of Trustees of the University of Illinois. *
+* All rights reserved. *
+* *
+* This file is part of HDF5. The full HDF5 copyright notice, including *
+* terms governing use, modification, and redistribution, is contained in *
+* the files COPYING and Copyright.html. COPYING can be found at the root *
+* of the source code distribution tree; Copyright.html can be found at the *
+* root level of an installed copy of the electronic HDF5 document set and *
+* is linked from the top-level documents page. It can also be found at *
+* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+* access to either file, you may request a copy from help@hdfgroup.org. *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5IMprivate.h"
#include "H5LTprivate.h"
@@ -19,155 +19,156 @@
#include <stdlib.h>
/*-------------------------------------------------------------------------
- * Function: H5IMmake_image_8bit
- *
- * Purpose: Creates and writes an image an 8 bit image
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: June 13, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMmake_image_8bit
+*
+* Purpose: Creates and writes an image an 8 bit image
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: June 13, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMmake_image_8bit( hid_t loc_id,
- const char *dset_name,
- hsize_t width,
- hsize_t height,
- const unsigned char *buffer )
+ const char *dset_name,
+ hsize_t width,
+ hsize_t height,
+ const unsigned char *buf )
{
- hsize_t dims[IMAGE8_RANK];
+ hsize_t dims[IMAGE8_RANK];
- /* Initialize the image dimensions */
- dims[0] = height;
- dims[1] = width;
+ /* Initialize the image dimensions */
+ dims[0] = height;
+ dims[1] = width;
- /* Make the dataset */
- if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0)
- return -1;
+ /* Make the dataset */
+ if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0)
+ return -1;
- /* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0)
- return -1;
+ /* Attach the CLASS attribute */
+ if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0)
+ return -1;
- /* Attach the VERSION attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0)
- return -1;
+ /* Attach the VERSION attribute */
+ if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0)
+ return -1;
- /* Attach the IMAGE_SUBCLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0)
- return -1;
+ /* Attach the IMAGE_SUBCLASS attribute */
+ if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0)
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5IMmake_image_24bit
- *
- * Purpose:
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: June 13, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Interlace Mode Dimensions in the Dataspace
- * INTERLACE_PIXEL [height][width][pixel components]
- * INTERLACE_PLANE [pixel components][height][width]
- *
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMmake_image_24bit
+*
+* Purpose:
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: June 13, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Interlace Mode Dimensions in the Dataspace
+* INTERLACE_PIXEL [height][width][pixel components]
+* INTERLACE_PLANE [pixel components][height][width]
+*
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMmake_image_24bit( hid_t loc_id,
- const char *dset_name,
- hsize_t width,
- hsize_t height,
- const char *interlace,
- const unsigned char *buffer )
+ const char *dset_name,
+ hsize_t width,
+ hsize_t height,
+ const char *interlace,
+ const unsigned char *buf )
{
- hsize_t dims[IMAGE24_RANK];
-
- /* Initialize the image dimensions */
-
- if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 )
- {
- /* Number of color planes is defined as the third dimension */
- dims[0] = height;
- dims[1] = width;
- dims[2] = IMAGE24_RANK;
- }
- else
- if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 )
- {
- /* Number of color planes is defined as the first dimension */
- dims[0] = IMAGE24_RANK;
- dims[1] = height;
- dims[2] = width;
- }
- else return -1;
-
- /* Make the dataset */
- if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0)
- return -1;
-
- /* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0)
- return -1;
-
- /* Attach the VERSION attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0)
- return -1;
-
- /* Attach the IMAGE_SUBCLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0)
- return -1;
-
- /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */
- if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0)
- return -1;
-
- return 0;
+ hsize_t dims[IMAGE24_RANK];
+
+ /* Initialize the image dimensions */
+
+ if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 )
+ {
+ /* Number of color planes is defined as the third dimension */
+ dims[0] = height;
+ dims[1] = width;
+ dims[2] = IMAGE24_RANK;
+ }
+ else
+ if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 )
+ {
+ /* Number of color planes is defined as the first dimension */
+ dims[0] = IMAGE24_RANK;
+ dims[1] = height;
+ dims[2] = width;
+ }
+ else return -1;
+
+ /* Make the dataset */
+ if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0)
+ return -1;
+
+ /* Attach the CLASS attribute */
+ if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0)
+ return -1;
+
+ /* Attach the VERSION attribute */
+ if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0)
+ return -1;
+
+ /* Attach the IMAGE_SUBCLASS attribute */
+ if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0)
+ return -1;
+
+ /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */
+ if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0)
+ return -1;
+
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: find_palette
- *
- * Purpose: operator function used by H5LT_find_palette
- *
- * Return:
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 28, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
- void *op_data)
+* Function: find_palette
+*
+* Purpose: operator function used by H5LT_find_palette
+*
+* Return:
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: May 28, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
+static herr_t find_palette(hid_t loc_id,
+ const char *name,
+ const H5A_info_t *ainfo,
+ void *op_data)
{
int ret = H5_ITER_CONT;
@@ -175,9 +176,9 @@ find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
loc_id = loc_id; ainfo = ainfo; op_data = op_data;
/* Define a positive value for return value if the attribute was found. This will
- * cause the iterator to immediately return that positive value,
- * indicating short-circuit success
- */
+ * cause the iterator to immediately return that positive value,
+ * indicating short-circuit success
+ */
if(strcmp(name, "PALETTE") == 0)
ret = H5_ITER_STOP;
@@ -186,23 +187,23 @@ find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
/*-------------------------------------------------------------------------
- * Function: H5IM_find_palette
- *
- * Purpose: Private function. Find the attribute "PALETTE" in the image dataset
- *
- * Return: Success: 1, Failure: 0
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 11, 2001
- *
- * Comments:
- * The function uses H5Aiterate2 with the operator function find_palette
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IM_find_palette
+*
+* Purpose: Private function. Find the attribute "PALETTE" in the image dataset
+*
+* Return: Success: 1, Failure: 0
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: May 11, 2001
+*
+* Comments:
+* The function uses H5Aiterate2 with the operator function find_palette
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IM_find_palette( hid_t loc_id )
{
@@ -211,1007 +212,1011 @@ herr_t H5IM_find_palette( hid_t loc_id )
/*-------------------------------------------------------------------------
- * Function: H5IMget_image_info
- *
- * Purpose: Gets information about an image dataset (dimensions, interlace mode
- * and number of associated palettes).
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: July 25, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMget_image_info
+*
+* Purpose: Gets information about an image dataset (dimensions, interlace mode
+* and number of associated palettes).
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: July 25, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMget_image_info( hid_t loc_id,
- const char *dset_name,
- hsize_t *width,
- hsize_t *height,
- hsize_t *planes,
- char *interlace,
- hssize_t *npals )
+ const char *dset_name,
+ hsize_t *width,
+ hsize_t *height,
+ hsize_t *planes,
+ char *interlace,
+ hssize_t *npals )
{
- hid_t did, sid;
- hsize_t dims[IMAGE24_RANK];
- hid_t attr_id;
- hid_t attr_type;
- int has_attr;
- hid_t attr_space_id;
- hid_t attr_class;
- int has_pal;
+ hid_t did;
+ hid_t sid;
+ hsize_t dims[IMAGE24_RANK];
+ hid_t aid;
+ hid_t asid;
+ hid_t atid;
+ H5T_class_t aclass;
+ int has_pal;
+ int has_attr;
- /*assume initially we have no palettes attached*/
- *npals = 0;
+ /*assume initially we have no palettes attached*/
+ *npals = 0;
- /* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the dataset. */
+ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Try to find the attribute "INTERLACE_MODE" on the >>image<< dataset */
- has_attr = H5LT_find_attribute(did, "INTERLACE_MODE");
+ /* Try to find the attribute "INTERLACE_MODE" on the >>image<< dataset */
+ has_attr = H5LT_find_attribute(did, "INTERLACE_MODE");
- /* It exists, get it */
- if(has_attr == 1)
- {
+ /* It exists, get it */
+ if(has_attr == 1)
+ {
- if((attr_id = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0)
- goto out;
+ if((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if(H5Aread(attr_id, attr_type, interlace) < 0)
- goto out;
+ if(H5Aread(aid, atid, interlace) < 0)
+ goto out;
- if(H5Tclose(attr_type) < 0)
- goto out;
+ if(H5Tclose(atid) < 0)
+ goto out;
- if(H5Aclose(attr_id) < 0)
- goto out;
- }
+ if(H5Aclose(aid) < 0)
+ goto out;
+ }
- /* Get the dataspace handle */
- if ( (sid = H5Dget_space( did )) < 0)
- goto out;
+ /* Get the dataspace handle */
+ if ( (sid = H5Dget_space( did )) < 0)
+ goto out;
- /* Get dimensions */
- if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0)
- goto out;
+ /* Get dimensions */
+ if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0)
+ goto out;
- /* Initialize the image dimensions */
+ /* Initialize the image dimensions */
- if ( has_attr == 1 )
- /* This is a 24 bit image */
- {
+ if ( has_attr == 1 )
+ /* This is a 24 bit image */
+ {
- if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 )
- {
- /* Number of color planes is defined as the third dimension */
- *height = dims[0];
- *width = dims[1];
- *planes = dims[2];
- }
- else
- if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 )
- {
- /* Number of color planes is defined as the first dimension */
- *planes = dims[0];
- *height = dims[1];
- *width = dims[2];
- }
- else return -1;
- }
- else
- /* This is a 8 bit image */
- {
- *height = dims[0];
- *width = dims[1];
- *planes = 1;
- }
+ if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 )
+ {
+ /* Number of color planes is defined as the third dimension */
+ *height = dims[0];
+ *width = dims[1];
+ *planes = dims[2];
+ }
+ else
+ if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 )
+ {
+ /* Number of color planes is defined as the first dimension */
+ *planes = dims[0];
+ *height = dims[1];
+ *width = dims[2];
+ }
+ else return -1;
+ }
+ else
+ /* This is a 8 bit image */
+ {
+ *height = dims[0];
+ *width = dims[1];
+ *planes = 1;
+ }
- /* Close */
- if ( H5Sclose( sid ) < 0)
- goto out;
+ /* Close */
+ if ( H5Sclose( sid ) < 0)
+ goto out;
- /* Get number of palettes */
+ /* Get number of palettes */
- /* Try to find the attribute "PALETTE" on the >>image<< dataset */
- has_pal = H5IM_find_palette(did);
+ /* Try to find the attribute "PALETTE" on the >>image<< dataset */
+ has_pal = H5IM_find_palette(did);
- if(has_pal == 1)
- {
+ if(has_pal == 1)
+ {
- if((attr_id = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
- goto out;
+ if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if((attr_class = H5Tget_class(attr_type)) < 0)
- goto out;
+ if((aclass = H5Tget_class(atid)) < 0)
+ goto out;
- /* Check if it is really a reference */
+ /* Check if it is really a reference */
- if(attr_class == H5T_REFERENCE)
- {
+ if(aclass == H5T_REFERENCE)
+ {
- /* Get the reference(s) */
+ /* Get the reference(s) */
- if ( (attr_space_id = H5Aget_space( attr_id )) < 0)
- goto out;
+ if ( (asid = H5Aget_space( aid )) < 0)
+ goto out;
- *npals = H5Sget_simple_extent_npoints( attr_space_id );
+ *npals = H5Sget_simple_extent_npoints( asid );
- if ( H5Sclose( attr_space_id ) < 0)
- goto out;
+ if ( H5Sclose( asid ) < 0)
+ goto out;
- } /* H5T_REFERENCE */
+ } /* H5T_REFERENCE */
- if ( H5Tclose( attr_type ) < 0)
- goto out;
+ if ( H5Tclose( atid ) < 0)
+ goto out;
- /* Close the attribute. */
- if ( H5Aclose( attr_id ) < 0)
- goto out;
+ /* Close the attribute. */
+ if ( H5Aclose( aid ) < 0)
+ goto out;
- }
+ }
- /* End access to the dataset and release resources used by it. */
- if ( H5Dclose( did ) < 0)
- goto out;
+ /* End access to the dataset and release resources used by it. */
+ if ( H5Dclose( did ) < 0)
+ goto out;
- return 0;
+ return 0;
out:
- H5Dclose( did );
- return -1;
+ H5Dclose( did );
+ H5Aclose( aid );
+ H5Sclose( asid );
+ H5Tclose( atid );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMread_image
- *
- * Purpose: Reads image data from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: June 13, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMread_image
+*
+* Purpose: Reads image data from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: June 13, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMread_image( hid_t loc_id,
const char *dset_name,
- unsigned char *buffer )
+ unsigned char *buf )
{
- hid_t did;
+ hid_t did;
- /* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the dataset. */
+ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Read */
- if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer ) < 0)
- goto out;
+ /* Read */
+ if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0)
+ goto out;
- /* End access to the dataset and release resources used by it. */
- if ( H5Dclose( did ) )
- return -1;
+ /* End access to the dataset and release resources used by it. */
+ if ( H5Dclose( did ) )
+ return -1;
- return 0;
+ return 0;
out:
- H5Dclose( did );
- return -1;
+ H5Dclose( did );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMmake_palette
- *
- * Purpose: Creates and writes a palette.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 01, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMmake_palette
+*
+* Purpose: Creates and writes a palette.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: May 01, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMmake_palette( hid_t loc_id,
- const char *pal_name,
- const hsize_t *pal_dims,
- const unsigned char *pal_data )
+ const char *pal_name,
+ const hsize_t *pal_dims,
+ const unsigned char *pal_data )
{
- int has_pal;
+ int has_pal;
- /* Check if the dataset already exists */
- has_pal = H5LTfind_dataset( loc_id, pal_name );
+ /* Check if the dataset already exists */
+ has_pal = H5LTfind_dataset( loc_id, pal_name );
- /* It exists. Return */
- if ( has_pal == 1 )
- return 0;
+ /* It exists. Return */
+ if ( has_pal == 1 )
+ return 0;
- /* Make the palette dataset. */
- if ( H5LTmake_dataset( loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data ) < 0 )
- return -1;
+ /* Make the palette dataset. */
+ if ( H5LTmake_dataset( loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data ) < 0 )
+ return -1;
- /* Attach the attribute "CLASS" to the >>palette<< dataset*/
- if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0)
- return -1;
+ /* Attach the attribute "CLASS" to the >>palette<< dataset*/
+ if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0)
+ return -1;
- /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/
- if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0)
- return -1;
+ /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/
+ if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0)
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5IMlink_palette
- *
- * Purpose: This function attaches a palette to an existing image dataset
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 01, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * An image (dataset) within an HDF5 file may optionally specify an array of
- * palettes to be viewed with. The dataset will have an attribute
- * which contains an array of object reference pointers which refer to palettes in the file.
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMlink_palette
+*
+* Purpose: This function attaches a palette to an existing image dataset
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: May 01, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* An image (dataset) within an HDF5 file may optionally specify an array of
+* palettes to be viewed with. The dataset will have an attribute
+* which contains an array of object reference pointers which refer to palettes in the file.
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMlink_palette( hid_t loc_id,
- const char *image_name,
- const char *pal_name )
+ const char *image_name,
+ const char *pal_name )
{
- hid_t image_id;
- hid_t attr_type=-1;
- hid_t attr_id=-1;
- hid_t attr_space_id=-1;
- hobj_ref_t ref; /* write a new reference */
- hobj_ref_t *refbuf; /* buffer to read references */
- hssize_t n_refs;
- hsize_t dim_ref;
- int ok_pal;
-
- /* The image dataset may or may not have the attribute "PALETTE"
- * First we try to open to see if it is already there; if not, it is created.
- * If it exists, the array of references is extended to hold the reference
- * to the new palette
- */
-
- /* First we get the image id */
- if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
- return -1;
-
- /* Try to find the attribute "PALETTE" on the >>image<< dataset */
- ok_pal = H5LT_find_attribute( image_id, "PALETTE" );
+ hid_t did;
+ hid_t atid=-1;
+ hid_t aid=-1;
+ hid_t asid=-1;
+ hobj_ref_t ref; /* write a new reference */
+ hobj_ref_t *refbuf; /* buffer to read references */
+ hssize_t n_refs;
+ hsize_t dim_ref;
+ int ok_pal;
+
+ /* The image dataset may or may not have the attribute "PALETTE"
+ * First we try to open to see if it is already there; if not, it is created.
+ * If it exists, the array of references is extended to hold the reference
+ * to the new palette
+ */
+
+ /* First we get the image id */
+ if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ return -1;
+
+ /* Try to find the attribute "PALETTE" on the >>image<< dataset */
+ ok_pal = H5LT_find_attribute( did, "PALETTE" );
+
+ /*-------------------------------------------------------------------------
+ * It does not exist. We create the attribute and one reference
+ *-------------------------------------------------------------------------
+ */
+ if(ok_pal == 0 )
+ {
+ if((asid = H5Screate(H5S_SCALAR)) < 0)
+ goto out;
-/*-------------------------------------------------------------------------
- * It does not exist. We create the attribute and one reference
- *-------------------------------------------------------------------------
- */
- if(ok_pal == 0 )
- {
- if((attr_space_id = H5Screate(H5S_SCALAR)) < 0)
- goto out;
-
- /* Create the attribute type for the reference */
- if((attr_type = H5Tcopy(H5T_STD_REF_OBJ)) < 0)
- goto out;
-
- /* Create the attribute "PALETTE" to be attached to the image*/
- if((attr_id = H5Acreate2(image_id, "PALETTE", attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
-
- /* Create a reference. The reference is created on the local id. */
- if(H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, -1) < 0)
- goto out;
-
- /* Write the attribute with the reference */
- if(H5Awrite(attr_id, attr_type, &ref) < 0)
- goto out;
-
- /* close */
- if(H5Sclose(attr_space_id) < 0)
- goto out;
- if ( H5Tclose( attr_type ) < 0)
- goto out;
- if(H5Aclose(attr_id) < 0)
- goto out;
-
- }
+ /* Create the attribute type for the reference */
+ if((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 0)
+ goto out;
-/*-------------------------------------------------------------------------
- * The attribute already exists, open it
- *-------------------------------------------------------------------------
- */
- else if(ok_pal == 1)
- {
- if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0)
- goto out;
+ /* Create the attribute "PALETTE" to be attached to the image*/
+ if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ /* Create a reference. The reference is created on the local id. */
+ if(H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, -1) < 0)
+ goto out;
- if(H5Tget_class(attr_type) < 0)
- goto out;
+ /* Write the attribute with the reference */
+ if(H5Awrite(aid, atid, &ref) < 0)
+ goto out;
- /* Get and save the old reference(s) */
- if((attr_space_id = H5Aget_space(attr_id)) < 0)
- goto out;
+ /* close */
+ if(H5Sclose(asid) < 0)
+ goto out;
+ if ( H5Tclose( atid ) < 0)
+ goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
- n_refs = H5Sget_simple_extent_npoints(attr_space_id);
+ }
- dim_ref = n_refs + 1;
+ /*-------------------------------------------------------------------------
+ * The attribute already exists, open it
+ *-------------------------------------------------------------------------
+ */
+ else if(ok_pal == 1)
+ {
+ if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ goto out;
- refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref );
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if ( H5Aread( attr_id, attr_type, refbuf ) < 0)
- goto out;
+ if(H5Tget_class(atid) < 0)
+ goto out;
- /* The attribute must be deleted, in order to the new one can reflect the changes*/
- if(H5Adelete(image_id, "PALETTE") < 0)
- goto out;
+ /* Get and save the old reference(s) */
+ if((asid = H5Aget_space(aid)) < 0)
+ goto out;
- /* Create a new reference for this palette. */
- if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, -1 ) < 0)
- goto out;
+ n_refs = H5Sget_simple_extent_npoints(asid);
- refbuf[n_refs] = ref;
+ dim_ref = n_refs + 1;
- /* Create the data space for the new references */
- if(H5Sclose(attr_space_id) < 0)
- goto out;
+ refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref );
- if((attr_space_id = H5Screate_simple(1, &dim_ref, NULL)) < 0)
- goto out;
+ if ( H5Aread( aid, atid, refbuf ) < 0)
+ goto out;
- /* Create the attribute again with the changes of space */
- if(H5Aclose(attr_id) < 0)
- goto out;
+ /* The attribute must be deleted, in order to the new one can reflect the changes*/
+ if(H5Adelete(did, "PALETTE") < 0)
+ goto out;
- if((attr_id = H5Acreate2(image_id, "PALETTE", attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ /* Create a new reference for this palette. */
+ if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, -1 ) < 0)
+ goto out;
- /* Write the attribute with the new references */
- if(H5Awrite(attr_id, attr_type, refbuf) < 0)
- goto out;
+ refbuf[n_refs] = ref;
- /* close */
- if(H5Sclose(attr_space_id) < 0)
- goto out;
- if(H5Aclose(attr_id) < 0)
- goto out;
+ /* Create the data space for the new references */
+ if(H5Sclose(asid) < 0)
+ goto out;
- free( refbuf );
+ if((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0)
+ goto out;
- } /* ok_pal == 1 */
+ /* Create the attribute again with the changes of space */
+ if(H5Aclose(aid) < 0)
+ goto out;
- /* Close the image dataset. */
- if ( H5Dclose( image_id ) < 0)
- return -1;
+ if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- return 0;
+ /* Write the attribute with the new references */
+ if(H5Awrite(aid, atid, refbuf) < 0)
+ goto out;
+
+ /* close */
+ if(H5Sclose(asid) < 0)
+ goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
+
+ free( refbuf );
+
+ } /* ok_pal == 1 */
+
+ /* Close the image dataset. */
+ if ( H5Dclose( did ) < 0)
+ return -1;
+
+ return 0;
out:
- H5Dclose( image_id );
- H5Sclose( attr_space_id );
- H5Tclose( attr_type );
- H5Aclose( attr_id );
- return -1;
+ H5Dclose( did );
+ H5Sclose( asid );
+ H5Tclose( atid );
+ H5Aclose( aid );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMunlink_palette
- *
- * Purpose: This function dettaches a palette from an existing image dataset
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: September 10, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMunlink_palette
+*
+* Purpose: This function dettaches a palette from an existing image dataset
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: September 10, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMunlink_palette( hid_t loc_id,
- const char *image_name,
- const char *pal_name )
+ const char *image_name,
+ const char *pal_name )
{
- hid_t image_id;
- hid_t attr_type;
- hid_t attr_id;
- hid_t attr_class;
- int ok_pal, has_pal;
+ hid_t did;
+ hid_t atid;
+ hid_t aid;
+ H5T_class_t aclass;
+ int ok_pal, has_pal;
- /* Try to find the palette dataset */
- has_pal = H5LTfind_dataset( loc_id, pal_name );
+ /* Try to find the palette dataset */
+ has_pal = H5LTfind_dataset( loc_id, pal_name );
- /* It does not exist. Return */
- if ( has_pal == 0 )
- return -1;
+ /* It does not exist. Return */
+ if ( has_pal == 0 )
+ return -1;
- /* The image dataset may or not have the attribute "PALETTE"
- * First we try to open to see if it is already there; if not, it is created.
- * If it exists, the array of references is extended to hold the reference
- * to the new palette
- */
+ /* The image dataset may or not have the attribute "PALETTE"
+ * First we try to open to see if it is already there; if not, it is created.
+ * If it exists, the array of references is extended to hold the reference
+ * to the new palette
+ */
- /* First we get the image id */
- if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* First we get the image id */
+ if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Try to find the attribute "PALETTE" on the >>image<< dataset */
- ok_pal = H5LT_find_attribute(image_id, "PALETTE");
+ /* Try to find the attribute "PALETTE" on the >>image<< dataset */
+ ok_pal = H5LT_find_attribute(did, "PALETTE");
- /* It does not exist. Nothing to do */
- if(ok_pal == 0)
- return -1;
+ /* It does not exist. Nothing to do */
+ if(ok_pal == 0)
+ return -1;
- /* The attribute exists, open it */
- else if(ok_pal == 1)
- {
- if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0)
- goto out;
+ /* The attribute exists, open it */
+ else if(ok_pal == 1)
+ {
+ if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if((attr_class = H5Tget_class(attr_type)) < 0)
- goto out;
+ if((aclass = H5Tget_class(atid)) < 0)
+ goto out;
- /* Check if it is really a reference */
- if(attr_class == H5T_REFERENCE)
- {
- /* Delete the attribute */
- if(H5Adelete(image_id, "PALETTE") < 0)
- goto out;
+ /* Check if it is really a reference */
+ if(aclass == H5T_REFERENCE)
+ {
+ /* Delete the attribute */
+ if(H5Adelete(did, "PALETTE") < 0)
+ goto out;
- } /* H5T_REFERENCE */
+ } /* H5T_REFERENCE */
- if(H5Tclose(attr_type) < 0)
- goto out;
+ if(H5Tclose(atid) < 0)
+ goto out;
- /* Close the attribute. */
- if(H5Aclose(attr_id) < 0)
- goto out;
+ /* Close the attribute. */
+ if(H5Aclose(aid) < 0)
+ goto out;
- } /* ok_pal */
+ } /* ok_pal */
- /* Close the image dataset. */
- if(H5Dclose(image_id) < 0)
- return -1;
+ /* Close the image dataset. */
+ if(H5Dclose(did) < 0)
+ return -1;
- return 0;
+ return 0;
out:
- H5Dclose( image_id );
- return -1;
+ H5Dclose( did );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMget_npalettes
- *
- * Purpose: Gets the number of palettes associated to an image
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: July 22, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMget_npalettes
+*
+* Purpose: Gets the number of palettes associated to an image
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: July 22, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMget_npalettes( hid_t loc_id,
- const char *image_name,
- hssize_t *npals )
+ const char *image_name,
+ hssize_t *npals )
{
- hid_t image_id;
- hid_t attr_type;
- hid_t attr_id;
- hid_t attr_space_id;
- hid_t attr_class;
- int has_pal;
+ hid_t did;
+ hid_t atid;
+ hid_t aid;
+ hid_t asid;
+ H5T_class_t aclass;
+ int has_pal;
- /*assume initially we have no palettes attached*/
- *npals = 0;
+ /*assume initially we have no palettes attached*/
+ *npals = 0;
- /* Open the dataset. */
- if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the dataset. */
+ if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Try to find the attribute "PALETTE" on the >>image<< dataset */
- has_pal = H5IM_find_palette(image_id);
+ /* Try to find the attribute "PALETTE" on the >>image<< dataset */
+ has_pal = H5IM_find_palette(did);
- if(has_pal == 1 )
- {
+ if(has_pal == 1 )
+ {
- if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0)
- goto out;
+ if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if((attr_class = H5Tget_class(attr_type)) < 0)
- goto out;
+ if((aclass = H5Tget_class(atid)) < 0)
+ goto out;
- /* Check if it is really a reference */
+ /* Check if it is really a reference */
- if(attr_class == H5T_REFERENCE)
- {
- if((attr_space_id = H5Aget_space(attr_id)) < 0)
- goto out;
+ if(aclass == H5T_REFERENCE)
+ {
+ if((asid = H5Aget_space(aid)) < 0)
+ goto out;
- *npals = H5Sget_simple_extent_npoints( attr_space_id );
+ *npals = H5Sget_simple_extent_npoints( asid );
- if ( H5Sclose( attr_space_id ) < 0)
- goto out;
+ if ( H5Sclose( asid ) < 0)
+ goto out;
- } /* H5T_REFERENCE */
+ } /* H5T_REFERENCE */
- if ( H5Tclose( attr_type ) < 0)
- goto out;
+ if ( H5Tclose( atid ) < 0)
+ goto out;
- /* Close the attribute. */
- if ( H5Aclose( attr_id ) < 0)
- goto out;
+ /* Close the attribute. */
+ if ( H5Aclose( aid ) < 0)
+ goto out;
- }
+ }
- /* Close the image dataset. */
- if ( H5Dclose( image_id ) < 0)
- return -1;
+ /* Close the image dataset. */
+ if ( H5Dclose( did ) < 0)
+ return -1;
- return 0;
+ return 0;
out:
- H5Dclose( image_id );
- return -1;
+ H5Dclose( did );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMget_palette_info
- *
- * Purpose: Get palette information
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: July 22, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMget_palette_info
+*
+* Purpose: Get palette information
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: July 22, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMget_palette_info( hid_t loc_id,
- const char *image_name,
- int pal_number,
- hsize_t *pal_dims )
+ const char *image_name,
+ int pal_number,
+ hsize_t *pal_dims )
{
- hid_t image_id;
- int has_pal;
- hid_t attr_type=-1;
- hid_t attr_id;
- hid_t attr_space_id=-1;
- hssize_t n_refs;
- hsize_t dim_ref;
- hobj_ref_t *refbuf; /* buffer to read references */
- hid_t pal_id;
- hid_t pal_space_id;
- hsize_t pal_maxdims[2];
+ hid_t did;
+ int has_pal;
+ hid_t atid=-1;
+ hid_t aid;
+ hid_t asid=-1;
+ hssize_t n_refs;
+ hsize_t dim_ref;
+ hobj_ref_t *refbuf; /* buffer to read references */
+ hid_t pal_id;
+ hid_t pal_space_id;
+ hsize_t pal_maxdims[2];
- /* Open the dataset. */
- if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the dataset. */
+ if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Try to find the attribute "PALETTE" on the >>image<< dataset */
- has_pal = H5IM_find_palette(image_id);
+ /* Try to find the attribute "PALETTE" on the >>image<< dataset */
+ has_pal = H5IM_find_palette(did);
- if(has_pal == 1)
- {
- if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0)
- goto out;
+ if(has_pal == 1)
+ {
+ if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if(H5Tget_class(attr_type) < 0)
- goto out;
+ if(H5Tget_class(atid) < 0)
+ goto out;
- /* Get the reference(s) */
- if((attr_space_id = H5Aget_space(attr_id)) < 0)
- goto out;
+ /* Get the reference(s) */
+ if((asid = H5Aget_space(aid)) < 0)
+ goto out;
- n_refs = H5Sget_simple_extent_npoints(attr_space_id);
+ n_refs = H5Sget_simple_extent_npoints(asid);
- dim_ref = n_refs;
+ dim_ref = n_refs;
- refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref );
+ refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref );
- if ( H5Aread( attr_id, attr_type, refbuf ) < 0)
- goto out;
+ if ( H5Aread( aid, atid, refbuf ) < 0)
+ goto out;
- /* Get the actual palette */
- if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0)
- goto out;
+ /* Get the actual palette */
+ if ( (pal_id = H5Rdereference( did, H5R_OBJECT, &refbuf[pal_number] )) < 0)
+ goto out;
- if ( (pal_space_id = H5Dget_space( pal_id )) < 0)
- goto out;
+ if ( (pal_space_id = H5Dget_space( pal_id )) < 0)
+ goto out;
- if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0)
- goto out;
+ if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0)
+ goto out;
- if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0)
- goto out;
+ if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0)
+ goto out;
- /* close */
- if (H5Dclose(pal_id)<0)
- goto out;
- if ( H5Sclose( pal_space_id ) < 0)
- goto out;
- if ( H5Sclose( attr_space_id ) < 0)
- goto out;
- if ( H5Tclose( attr_type ) < 0)
- goto out;
- if ( H5Aclose( attr_id ) < 0)
- goto out;
- free( refbuf );
+ /* close */
+ if (H5Dclose(pal_id)<0)
+ goto out;
+ if ( H5Sclose( pal_space_id ) < 0)
+ goto out;
+ if ( H5Sclose( asid ) < 0)
+ goto out;
+ if ( H5Tclose( atid ) < 0)
+ goto out;
+ if ( H5Aclose( aid ) < 0)
+ goto out;
+ free( refbuf );
- }
+ }
- /* Close the image dataset. */
- if ( H5Dclose( image_id ) < 0)
- return -1;
+ /* Close the image dataset. */
+ if ( H5Dclose( did ) < 0)
+ return -1;
- return 0;
+ return 0;
out:
- H5Dclose( image_id );
- H5Sclose( attr_space_id );
- H5Tclose( attr_type );
- H5Aclose( attr_id );
- return -1;
+ H5Dclose( did );
+ H5Sclose( asid );
+ H5Tclose( atid );
+ H5Aclose( aid );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMget_palette
- *
- * Purpose: Read palette
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: August 30, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMget_palette
+*
+* Purpose: Read palette
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: August 30, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMget_palette( hid_t loc_id,
- const char *image_name,
- int pal_number,
- unsigned char *pal_data )
+ const char *image_name,
+ int pal_number,
+ unsigned char *pal_data )
{
- hid_t image_id;
- int has_pal;
- hid_t attr_type=-1;
- hid_t attr_id;
- hid_t attr_space_id=-1;
- hssize_t n_refs;
- hsize_t dim_ref;
- hobj_ref_t *refbuf; /* buffer to read references */
- hid_t pal_id;
+ hid_t did;
+ int has_pal;
+ hid_t atid=-1;
+ hid_t aid;
+ hid_t asid=-1;
+ hssize_t n_refs;
+ hsize_t dim_ref;
+ hobj_ref_t *refbuf; /* buffer to read references */
+ hid_t pal_id;
- /* Open the dataset. */
- if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the dataset. */
+ if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Try to find the attribute "PALETTE" on the >>image<< dataset */
- has_pal = H5IM_find_palette(image_id);
+ /* Try to find the attribute "PALETTE" on the >>image<< dataset */
+ has_pal = H5IM_find_palette(did);
- if(has_pal == 1 )
- {
- if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0)
- goto out;
+ if(has_pal == 1 )
+ {
+ if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if(H5Tget_class(attr_type) < 0)
- goto out;
+ if(H5Tget_class(atid) < 0)
+ goto out;
- /* Get the reference(s) */
- if((attr_space_id = H5Aget_space(attr_id)) < 0)
- goto out;
+ /* Get the reference(s) */
+ if((asid = H5Aget_space(aid)) < 0)
+ goto out;
- n_refs = H5Sget_simple_extent_npoints(attr_space_id);
+ n_refs = H5Sget_simple_extent_npoints(asid);
- dim_ref = n_refs;
+ dim_ref = n_refs;
- refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref );
+ refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref );
- if ( H5Aread( attr_id, attr_type, refbuf ) < 0)
- goto out;
+ if ( H5Aread( aid, atid, refbuf ) < 0)
+ goto out;
- /* Get the palette id */
- if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0)
- goto out;
+ /* Get the palette id */
+ if ( (pal_id = H5Rdereference( did, H5R_OBJECT, &refbuf[pal_number] )) < 0)
+ goto out;
- /* Read the palette dataset */
- if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0)
- goto out;
+ /* Read the palette dataset */
+ if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0)
+ goto out;
- /* close */
- if (H5Dclose(pal_id)<0)
- goto out;
- if ( H5Sclose( attr_space_id ) < 0)
- goto out;
- if ( H5Tclose( attr_type ) < 0)
- goto out;
- if ( H5Aclose( attr_id ) < 0)
- goto out;
- free( refbuf );
- }
+ /* close */
+ if (H5Dclose(pal_id)<0)
+ goto out;
+ if ( H5Sclose( asid ) < 0)
+ goto out;
+ if ( H5Tclose( atid ) < 0)
+ goto out;
+ if ( H5Aclose( aid ) < 0)
+ goto out;
+ free( refbuf );
+ }
- /* Close the image dataset. */
- if ( H5Dclose( image_id ) < 0)
- return -1;
+ /* Close the image dataset. */
+ if ( H5Dclose( did ) < 0)
+ return -1;
- return 0;
+ return 0;
out:
- H5Dclose( image_id );
- H5Sclose( attr_space_id );
- H5Tclose( attr_type );
- H5Aclose( attr_id );
- return -1;
+ H5Dclose( did );
+ H5Sclose( asid );
+ H5Tclose( atid );
+ H5Aclose( aid );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMis_image
- *
- * Purpose:
- *
- * Return: true, false, fail
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: August 30, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMis_image
+*
+* Purpose:
+*
+* Return: true, false, fail
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: August 30, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMis_image( hid_t loc_id,
- const char *dset_name )
+ const char *dset_name )
{
- hid_t did;
- int has_class;
- hid_t attr_type;
- hid_t attr_id;
- char attr_data[20];
- herr_t ret;
+ hid_t did;
+ int has_class;
+ hid_t atid;
+ hid_t aid;
+ char attr_data[20];
+ herr_t ret;
- /* Assume initially fail condition */
- ret = -1;
+ /* Assume initially fail condition */
+ ret = -1;
- /* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the dataset. */
+ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Try to find the attribute "CLASS" on the dataset */
- has_class = H5LT_find_attribute(did, "CLASS");
+ /* Try to find the attribute "CLASS" on the dataset */
+ has_class = H5LT_find_attribute(did, "CLASS");
- if(has_class == 0)
- {
- H5Dclose(did);
- return 0;
- }
- else if(has_class == 1)
- {
+ if(has_class == 0)
+ {
+ H5Dclose(did);
+ return 0;
+ }
+ else if(has_class == 1)
+ {
- if((attr_id = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
- goto out;
+ if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if(H5Tget_class(attr_type) < 0)
- goto out;
+ if(H5Tget_class(atid) < 0)
+ goto out;
- if(H5Aread(attr_id, attr_type, attr_data) < 0)
- goto out;
+ if(H5Aread(aid, atid, attr_data) < 0)
+ goto out;
- if(strcmp(attr_data, IMAGE_CLASS) == 0)
- ret = 1;
- else
- ret = 0;
+ if(strcmp(attr_data, IMAGE_CLASS) == 0)
+ ret = 1;
+ else
+ ret = 0;
- if ( H5Tclose( attr_type ) < 0)
- goto out;
+ if ( H5Tclose( atid ) < 0)
+ goto out;
- if ( H5Aclose( attr_id ) < 0)
- goto out;
+ if ( H5Aclose( aid ) < 0)
+ goto out;
- }
+ }
- /* Close the dataset. */
- if ( H5Dclose( did ) < 0)
- return -1;
+ /* Close the dataset. */
+ if ( H5Dclose( did ) < 0)
+ return -1;
- return ret;
+ return ret;
out:
- H5Dclose( did );
- return -1;
+ H5Dclose( did );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5IMis_palette
- *
- * Purpose:
- *
- * Return: true, false, fail
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: August 30, 2001
- *
- * Comments:
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5IMis_palette
+*
+* Purpose:
+*
+* Return: true, false, fail
+*
+* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
+*
+* Date: August 30, 2001
+*
+* Comments:
+* based on HDF5 Image and Palette Specification
+* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5IMis_palette( hid_t loc_id,
- const char *dset_name )
+ const char *dset_name )
{
- hid_t did;
- int has_class;
- hid_t attr_type;
- hid_t attr_id;
- char attr_data[20];
- herr_t ret;
+ hid_t did;
+ int has_class;
+ hid_t atid;
+ hid_t aid;
+ char attr_data[20];
+ herr_t ret;
- /* Assume initially fail condition */
- ret = -1;
+ /* Assume initially fail condition */
+ ret = -1;
- /* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the dataset. */
+ if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Try to find the attribute "CLASS" on the dataset */
- has_class = H5LT_find_attribute(did, "CLASS");
+ /* Try to find the attribute "CLASS" on the dataset */
+ has_class = H5LT_find_attribute(did, "CLASS");
- if(has_class == 0)
- {
- H5Dclose( did );
- return 0;
- }
- else if(has_class == 1)
- {
+ if(has_class == 0)
+ {
+ H5Dclose( did );
+ return 0;
+ }
+ else if(has_class == 1)
+ {
- if((attr_id = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
- goto out;
+ if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
+ goto out;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((atid = H5Aget_type(aid)) < 0)
+ goto out;
- if(H5Tget_class(attr_type) < 0)
- goto out;
+ if(H5Tget_class(atid) < 0)
+ goto out;
- if(H5Aread(attr_id, attr_type, attr_data) < 0)
- goto out;
+ if(H5Aread(aid, atid, attr_data) < 0)
+ goto out;
- if(strcmp(attr_data, PALETTE_CLASS) == 0)
- ret = 1;
- else
- ret = 0;
+ if(strcmp(attr_data, PALETTE_CLASS) == 0)
+ ret = 1;
+ else
+ ret = 0;
- if ( H5Tclose( attr_type ) < 0)
- goto out;
+ if ( H5Tclose( atid ) < 0)
+ goto out;
- if ( H5Aclose( attr_id ) < 0)
- goto out;
+ if ( H5Aclose( aid ) < 0)
+ goto out;
- }
+ }
- /* Close the dataset. */
- if ( H5Dclose( did ) < 0)
- return -1;
+ /* Close the dataset. */
+ if ( H5Dclose( did ) < 0)
+ return -1;
- return ret;
+ return ret;
out:
- H5Dclose( did );
- return -1;
+ H5Dclose( did );
+ return -1;
}
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index 92965fd..7c073d6 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -1,17 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+* Copyright by The HDF Group. *
+* Copyright by the Board of Trustees of the University of Illinois. *
+* All rights reserved. *
+* *
+* This file is part of HDF5. The full HDF5 copyright notice, including *
+* terms governing use, modification, and redistribution, is contained in *
+* the files COPYING and Copyright.html. COPYING can be found at the root *
+* of the source code distribution tree; Copyright.html can be found at the *
+* root level of an installed copy of the electronic HDF5 document set and *
+* is linked from the top-level documents page. It can also be found at *
+* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+* access to either file, you may request a copy from help@hdfgroup.org. *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string.h>
#include <stdlib.h>
@@ -33,38 +33,38 @@ int indent = 0;
/*-------------------------------------------------------------------------
- *
- * internal functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* internal functions
+*
+*-------------------------------------------------------------------------
+*/
static herr_t H5LT_get_attribute_mem(hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- hid_t mem_type_id,
- void *data);
-
-/*-------------------------------------------------------------------------
- * Function: H5LT_make_dataset
- *
- * Purpose: Creates and writes a dataset of a type tid
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: October 10, 2007
- *
- *-------------------------------------------------------------------------
- */
+ const char *obj_name,
+ const char *attr_name,
+ hid_t mem_type_id,
+ void *data);
+
+/*-------------------------------------------------------------------------
+* Function: H5LT_make_dataset
+*
+* Purpose: Creates and writes a dataset of a type tid
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Quincey Koziol, koziol@hdfgroup.org
+*
+* Date: October 10, 2007
+*
+*-------------------------------------------------------------------------
+*/
static herr_t
H5LT_make_dataset_numerical( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- hid_t tid,
- const void *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ hid_t tid,
+ const void *data )
{
hid_t did = -1, sid = -1;
@@ -100,124 +100,124 @@ out:
}
/*-------------------------------------------------------------------------
- *
- * Public functions
- *
- *-------------------------------------------------------------------------
- */
-
-/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset
- *
- * Purpose: Creates and writes a dataset of a type tid
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 19, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+*
+* Public functions
+*
+*-------------------------------------------------------------------------
+*/
+
+/*-------------------------------------------------------------------------
+* Function: H5LTmake_dataset
+*
+* Purpose: Creates and writes a dataset of a type tid
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 19, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- hid_t tid,
- const void *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ hid_t tid,
+ const void *data )
{
return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset_char
- *
- * Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 14, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTmake_dataset_char
+*
+* Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 14, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset_char( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const char *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ const char *data )
{
return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset_short
- *
- * Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 14, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTmake_dataset_short
+*
+* Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 14, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset_short( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const short *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ const short *data )
{
return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset_int
- *
- * Purpose: Creates and writes a dataset of H5T_NATIVE_INT type
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 14, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTmake_dataset_int
+*
+* Purpose: Creates and writes a dataset of H5T_NATIVE_INT type
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 14, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset_int( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const int *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ const int *data )
{
return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data));
}
@@ -225,59 +225,59 @@ herr_t H5LTmake_dataset_int( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset_long
- *
- * Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 14, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTmake_dataset_long
+*
+* Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 14, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset_long( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const long *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ const long *data )
{
return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset_float
- *
- * Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 14, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTmake_dataset_float
+*
+* Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 14, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset_float( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const float *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ const float *data )
{
return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data));
}
@@ -285,53 +285,53 @@ herr_t H5LTmake_dataset_float( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset_double
- *
- * Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 14, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTmake_dataset_double
+*
+* Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 14, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset_double( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const double *data )
+ const char *dset_name,
+ int rank,
+ const hsize_t *dims,
+ const double *data )
{
return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTmake_dataset_string
- *
- * Purpose: Creates and writes a dataset of H5T_C_S1 type
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 05, 2004
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTmake_dataset_string
+*
+* Purpose: Creates and writes a dataset of H5T_C_S1 type
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: October 05, 2004
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTmake_dataset_string(hid_t loc_id,
@@ -389,18 +389,18 @@ out:
/*-------------------------------------------------------------------------
- * Function: H5LT_read_dataset
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: October 8, 2007
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LT_read_dataset
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Quincey Koziol, koziol@hdfgroup.org
+*
+* Date: October 8, 2007
+*
+*-------------------------------------------------------------------------
+*/
static herr_t
H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data)
@@ -427,18 +427,18 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: June 13, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: June 13, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset(hid_t loc_id,
const char *dset_name,
@@ -450,150 +450,150 @@ herr_t H5LTread_dataset(hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset_char
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 5, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset_char
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 5, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset_char( hid_t loc_id,
- const char *dset_name,
- char *data )
+ const char *dset_name,
+ char *data )
{
return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset_short
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 5, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset_short
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 5, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset_short( hid_t loc_id,
- const char *dset_name,
- short *data )
+ const char *dset_name,
+ short *data )
{
return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset_int
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 5, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset_int
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 5, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset_int( hid_t loc_id,
- const char *dset_name,
- int *data )
+ const char *dset_name,
+ int *data )
{
return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset_long
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 5, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset_long
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 5, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset_long( hid_t loc_id,
- const char *dset_name,
- long *data )
+ const char *dset_name,
+ long *data )
{
return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset_float
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 5, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset_float
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 5, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset_float( hid_t loc_id,
- const char *dset_name,
- float *data )
+ const char *dset_name,
+ float *data )
{
return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset_double
- *
- * Purpose: Reads a dataset from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 5, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset_double
+*
+* Purpose: Reads a dataset from disk.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 5, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset_double( hid_t loc_id,
- const char *dset_name,
- double *data )
+ const char *dset_name,
+ double *data )
{
return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data));
}
/*-------------------------------------------------------------------------
- * Function: H5LTread_dataset_string
- *
- * Purpose: Reads a dataset
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 05, 2004
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTread_dataset_string
+*
+* Purpose: Reads a dataset
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: October 05, 2004
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTread_dataset_string( hid_t loc_id,
- const char *dset_name,
- char *buf )
+ const char *dset_name,
+ char *buf )
{
hid_t did = -1;
hid_t tid = -1;
@@ -627,22 +627,22 @@ out:
/*-------------------------------------------------------------------------
- * Function: H5LTget_dataset_ndims
- *
- * Purpose: Gets the dimensionality of a dataset.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 4, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_dataset_ndims
+*
+* Purpose: Gets the dimensionality of a dataset.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 4, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_dataset_ndims( hid_t loc_id,
- const char *dset_name,
- int *rank )
+ const char *dset_name,
+ int *rank )
{
hid_t did = -1;
hid_t sid = -1;
@@ -679,25 +679,25 @@ out:
/*-------------------------------------------------------------------------
- * Function: H5LTget_dataset_info
- *
- * Purpose: Gets information about a dataset.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 4, 2001
- * Modified: February 28, 2006: checked for NULL parameters
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_dataset_info
+*
+* Purpose: Gets information about a dataset.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 4, 2001
+* Modified: February 28, 2006: checked for NULL parameters
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_dataset_info( hid_t loc_id,
- const char *dset_name,
- hsize_t *dims,
- H5T_class_t *type_class,
- size_t *type_size )
+ const char *dset_name,
+ hsize_t *dims,
+ H5T_class_t *type_class,
+ size_t *type_size )
{
hid_t did = -1;
hid_t tid = -1;
@@ -753,27 +753,27 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: find_dataset
- *
- * Purpose: operator function used by H5LTfind_dataset
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: June 21, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: find_dataset
+*
+* Purpose: operator function used by H5LTfind_dataset
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: June 21, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
static herr_t
find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_data)
{
/* Define a default zero value for return. This will cause the iterator to continue if
- * the dataset is not found yet.
- */
+ * the dataset is not found yet.
+ */
int ret = 0;
/* Shut the compiler up */
@@ -781,9 +781,9 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d
linfo = linfo;
/* Define a positive value for return value if the dataset was found. This will
- * cause the iterator to immediately return that positive value,
- * indicating short-circuit success
- */
+ * cause the iterator to immediately return that positive value,
+ * indicating short-circuit success
+ */
if(strcmp(name, (char *)op_data) == 0)
ret = 1;
@@ -792,26 +792,26 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d
/*-------------------------------------------------------------------------
- * Function: H5LTfind_dataset
- *
- * Purpose: Inquires if a dataset named dset_name exists attached
- * to the object loc_id.
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: July 15, 2001
- *
- * Return:
- * Success: The return value of the first operator that
- * returns non-zero, or zero if all members were
- * processed with no operator returning non-zero.
- *
- * Failure: Negative if something goes wrong within the
- * library, or the negative value returned by one
- * of the operators.
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTfind_dataset
+*
+* Purpose: Inquires if a dataset named dset_name exists attached
+* to the object loc_id.
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: July 15, 2001
+*
+* Return:
+* Success: The return value of the first operator that
+* returns non-zero, or zero if all members were
+* processed with no operator returning non-zero.
+*
+* Failure: Negative if something goes wrong within the
+* library, or the negative value returned by one
+* of the operators.
+*
+*-------------------------------------------------------------------------
+*/
herr_t
H5LTfind_dataset( hid_t loc_id, const char *dset_name )
@@ -821,98 +821,98 @@ H5LTfind_dataset( hid_t loc_id, const char *dset_name )
/*-------------------------------------------------------------------------
- *
- * Set attribute functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Set attribute functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_string
- *
- * Purpose: Creates and writes a string attribute named attr_name and attaches
- * it to the object specified by the name obj_name.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: July 23, 2001
- *
- * Comments: If the attribute already exists, it is overwritten
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_string
+*
+* Purpose: Creates and writes a string attribute named attr_name and attaches
+* it to the object specified by the name obj_name.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: July 23, 2001
+*
+* Comments: If the attribute already exists, it is overwritten
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_string( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const char *attr_data )
+ const char *obj_name,
+ const char *attr_name,
+ const char *attr_data )
{
- hid_t attr_type;
- hid_t attr_space_id;
- hid_t attr_id;
- hid_t obj_id;
- int has_attr;
- size_t attr_size;
+ hid_t attr_type;
+ hid_t attr_space_id;
+ hid_t attr_id;
+ hid_t obj_id;
+ int has_attr;
+ size_t attr_size;
- /* Open the object */
- if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the object */
+ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Create the attribute */
- if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 )
- goto out;
+ /* Create the attribute */
+ if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 )
+ goto out;
- attr_size = strlen( attr_data ) + 1; /* extra null term */
+ attr_size = strlen( attr_data ) + 1; /* extra null term */
- if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 )
- goto out;
+ if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 )
+ goto out;
- if ( H5Tset_strpad( attr_type, H5T_STR_NULLTERM ) < 0 )
- goto out;
+ if ( H5Tset_strpad( attr_type, H5T_STR_NULLTERM ) < 0 )
+ goto out;
- if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 )
- goto out;
+ if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 )
+ goto out;
- /* Verify if the attribute already exists */
- has_attr = H5LT_find_attribute(obj_id, attr_name);
+ /* Verify if the attribute already exists */
+ has_attr = H5LT_find_attribute(obj_id, attr_name);
- /* The attribute already exists, delete it */
- if(has_attr == 1)
- if(H5Adelete(obj_id, attr_name) < 0)
- goto out;
+ /* The attribute already exists, delete it */
+ if(has_attr == 1)
+ if(H5Adelete(obj_id, attr_name) < 0)
+ goto out;
- /* Create and write the attribute */
+ /* Create and write the attribute */
- if((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ if((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Awrite(attr_id, attr_type, attr_data) < 0)
- goto out;
+ if(H5Awrite(attr_id, attr_type, attr_data) < 0)
+ goto out;
- if(H5Aclose(attr_id) < 0)
- goto out;
+ if(H5Aclose(attr_id) < 0)
+ goto out;
- if(H5Sclose(attr_space_id) < 0)
- goto out;
+ if(H5Sclose(attr_space_id) < 0)
+ goto out;
- if(H5Tclose(attr_type) < 0)
- goto out;
+ if(H5Tclose(attr_type) < 0)
+ goto out;
- /* Close the object */
- if(H5Oclose(obj_id) < 0)
- return -1;
+ /* Close the object */
+ if(H5Oclose(obj_id) < 0)
+ return -1;
- return 0;
+ return 0;
out:
- H5Oclose(obj_id);
- return -1;
+ H5Oclose(obj_id);
+ return -1;
}
@@ -920,185 +920,185 @@ out:
/*-------------------------------------------------------------------------
- * Function: H5LT_set_attribute_numerical
- *
- * Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: July 25, 2001
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LT_set_attribute_numerical
+*
+* Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: July 25, 2001
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LT_set_attribute_numerical( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- size_t size,
- hid_t tid,
- const void *data )
+ const char *obj_name,
+ const char *attr_name,
+ size_t size,
+ hid_t tid,
+ const void *data )
{
- hid_t obj_id, sid, attr_id;
- hsize_t dim_size=size;
- int has_attr;
+ hid_t obj_id, sid, attr_id;
+ hsize_t dim_size=size;
+ int has_attr;
- /* Open the object */
- if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the object */
+ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Create the data space for the attribute. */
- if ( (sid = H5Screate_simple( 1, &dim_size, NULL )) < 0 )
- goto out;
+ /* Create the data space for the attribute. */
+ if ( (sid = H5Screate_simple( 1, &dim_size, NULL )) < 0 )
+ goto out;
- /* Verify if the attribute already exists */
- has_attr = H5LT_find_attribute(obj_id, attr_name);
+ /* Verify if the attribute already exists */
+ has_attr = H5LT_find_attribute(obj_id, attr_name);
- /* The attribute already exists, delete it */
- if(has_attr == 1)
- if(H5Adelete(obj_id, attr_name) < 0)
- goto out;
+ /* The attribute already exists, delete it */
+ if(has_attr == 1)
+ if(H5Adelete(obj_id, attr_name) < 0)
+ goto out;
- /* Create the attribute. */
- if((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ /* Create the attribute. */
+ if((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- /* Write the attribute data. */
- if(H5Awrite(attr_id, tid, data) < 0)
- goto out;
+ /* Write the attribute data. */
+ if(H5Awrite(attr_id, tid, data) < 0)
+ goto out;
- /* Close the attribute. */
- if(H5Aclose(attr_id) < 0)
- goto out;
+ /* Close the attribute. */
+ if(H5Aclose(attr_id) < 0)
+ goto out;
- /* Close the dataspace. */
- if(H5Sclose(sid) < 0)
- goto out;
+ /* Close the dataspace. */
+ if(H5Sclose(sid) < 0)
+ goto out;
- /* Close the object */
- if(H5Oclose(obj_id) < 0)
- return -1;
+ /* Close the object */
+ if(H5Oclose(obj_id) < 0)
+ return -1;
- return 0;
+ return 0;
out:
- H5Oclose(obj_id);
- return -1;
+ H5Oclose(obj_id);
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_char
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 7, 2001
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_char
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 7, 2001
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_char( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const char *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const char *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_CHAR, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_CHAR, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_uchar
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_uchar
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_uchar( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned char *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const unsigned char *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_UCHAR, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_UCHAR, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_short
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 7, 2001
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_short
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 7, 2001
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_short( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const short *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const short *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_SHORT, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_SHORT, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_ushort
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_ushort
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_ushort( hid_t loc_id,
const char *obj_name,
@@ -1107,60 +1107,60 @@ herr_t H5LTset_attribute_ushort( hid_t loc_id,
size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_USHORT, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_USHORT, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_int
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 7, 2001
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_int
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 7, 2001
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_int( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const int *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const int *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_INT, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_INT, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_uint
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_uint
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_uint( hid_t loc_id,
const char *obj_name,
@@ -1169,92 +1169,92 @@ herr_t H5LTset_attribute_uint( hid_t loc_id,
size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_UINT, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_UINT, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_long
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 7, 2001
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_long
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 7, 2001
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_long( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const long *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const long *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_LONG, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_LONG, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_long_long
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu
- *
- * Date: June 17, 2005
- *
- * Comments: This function was added to support attributes of type long long
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_long_long
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu
+*
+* Date: June 17, 2005
+*
+* Comments: This function was added to support attributes of type long long
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_long_long( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const long long *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const long long *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_LLONG, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_LLONG, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_ulong
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_ulong
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_ulong( hid_t loc_id,
const char *obj_name,
@@ -1263,99 +1263,99 @@ herr_t H5LTset_attribute_ulong( hid_t loc_id,
size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_ULONG, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_ULONG, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_float
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: July 25, 2001
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_float
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: July 25, 2001
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_float( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const float *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const float *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_FLOAT, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_FLOAT, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_double
- *
- * Purpose: Create and write an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 7, 2001
- *
- * Comments:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTset_attribute_double
+*
+* Purpose: Create and write an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 7, 2001
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTset_attribute_double( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const double *data,
- size_t size )
+ const char *obj_name,
+ const char *attr_name,
+ const double *data,
+ size_t size )
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_DOUBLE, data ) < 0 )
- return -1;
+ if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
+ H5T_NATIVE_DOUBLE, data ) < 0 )
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: find_attr
- *
- * Purpose: operator function used by H5LT_find_attribute
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: June 21, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: find_attr
+*
+* Purpose: operator function used by H5LT_find_attribute
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: June 21, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
static herr_t
find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
- void *op_data)
+ void *op_data)
{
int ret = H5_ITER_CONT;
@@ -1363,9 +1363,9 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
loc_id = loc_id; ainfo = ainfo;
/* Define a positive value for return value if the attribute was found. This will
- * cause the iterator to immediately return that positive value,
- * indicating short-circuit success
- */
+ * cause the iterator to immediately return that positive value,
+ * indicating short-circuit success
+ */
if(strcmp(name, (char *)op_data) == 0)
ret = H5_ITER_STOP;
@@ -1374,51 +1374,51 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
/*-------------------------------------------------------------------------
- * Function: H5LTfind_attribute
- *
- * Purpose: Inquires if an attribute named attr_name exists attached to
- * the object loc_id.
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 17, 2006
- *
- * Comments:
- * Calls the private version of the function
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTfind_attribute
+*
+* Purpose: Inquires if an attribute named attr_name exists attached to
+* the object loc_id.
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: May 17, 2006
+*
+* Comments:
+* Calls the private version of the function
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name )
{
- return H5LT_find_attribute(loc_id,attr_name);
+ return H5LT_find_attribute(loc_id,attr_name);
}
/*-------------------------------------------------------------------------
- * Function: H5LT_find_attribute
- *
- * Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id.
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: June 21, 2001
- *
- * Comments:
- * The function uses H5Aiterate2 with the operator function find_attr
- *
- * Return:
- * Success: The return value of the first operator that
- * returns non-zero, or zero if all members were
- * processed with no operator returning non-zero.
- *
- * Failure: Negative if something goes wrong within the
- * library, or the negative value returned by one
- * of the operators.
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LT_find_attribute
+*
+* Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id.
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: June 21, 2001
+*
+* Comments:
+* The function uses H5Aiterate2 with the operator function find_attr
+*
+* Return:
+* Success: The return value of the first operator that
+* returns non-zero, or zero if all members were
+* processed with no operator returning non-zero.
+*
+* Failure: Negative if something goes wrong within the
+* library, or the negative value returned by one
+* of the operators.
+*
+*-------------------------------------------------------------------------
+*/
herr_t
H5LT_find_attribute( hid_t loc_id, const char* attr_name )
@@ -1429,146 +1429,146 @@ H5LT_find_attribute( hid_t loc_id, const char* attr_name )
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_ndims
- *
- * Purpose: Gets the dimensionality of an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 4, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_ndims
+*
+* Purpose: Gets the dimensionality of an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 4, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_ndims( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- int *rank )
+ const char *obj_name,
+ const char *attr_name,
+ int *rank )
{
- hid_t attr_id;
- hid_t sid;
- hid_t obj_id;
+ hid_t attr_id;
+ hid_t sid;
+ hid_t obj_id;
- /* Open the object */
- if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the object */
+ if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Open the attribute. */
- if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0)
- {
- H5Oclose(obj_id);
- return -1;
- }
+ /* Open the attribute. */
+ if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0)
+ {
+ H5Oclose(obj_id);
+ return -1;
+ }
- /* Get the dataspace handle */
- if((sid = H5Aget_space(attr_id)) < 0)
- goto out;
+ /* Get the dataspace handle */
+ if((sid = H5Aget_space(attr_id)) < 0)
+ goto out;
- /* Get rank */
- if((*rank = H5Sget_simple_extent_ndims(sid)) < 0)
- goto out;
+ /* Get rank */
+ if((*rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ goto out;
- /* Terminate access to the attribute */
- if ( H5Sclose( sid ) < 0 )
- goto out;
+ /* Terminate access to the attribute */
+ if ( H5Sclose( sid ) < 0 )
+ goto out;
- /* End access to the attribute */
- if ( H5Aclose( attr_id ) )
- goto out;;
+ /* End access to the attribute */
+ if ( H5Aclose( attr_id ) )
+ goto out;;
- /* Close the object */
- if(H5Oclose(obj_id) < 0 )
- return -1;
+ /* Close the object */
+ if(H5Oclose(obj_id) < 0 )
+ return -1;
- return 0;
+ return 0;
out:
- H5Aclose( attr_id );
- H5Oclose(obj_id);
- return -1;
+ H5Aclose( attr_id );
+ H5Oclose(obj_id);
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_info
- *
- * Purpose: Gets information about an attribute.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 4, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_info
+*
+* Purpose: Gets information about an attribute.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 4, 2001
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_info( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- hsize_t *dims,
- H5T_class_t *type_class,
- size_t *type_size )
+ const char *obj_name,
+ const char *attr_name,
+ hsize_t *dims,
+ H5T_class_t *type_class,
+ size_t *type_size )
{
- hid_t attr_id;
- hid_t tid;
- hid_t sid;
- hid_t obj_id;
+ hid_t attr_id;
+ hid_t tid;
+ hid_t sid;
+ hid_t obj_id;
- /* Open the object */
- if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the object */
+ if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Open the attribute. */
- if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0)
- {
- H5Oclose(obj_id);
- return -1;
- }
+ /* Open the attribute. */
+ if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0)
+ {
+ H5Oclose(obj_id);
+ return -1;
+ }
- /* Get an identifier for the datatype. */
- tid = H5Aget_type(attr_id);
+ /* Get an identifier for the datatype. */
+ tid = H5Aget_type(attr_id);
- /* Get the class. */
- *type_class = H5Tget_class(tid);
+ /* Get the class. */
+ *type_class = H5Tget_class(tid);
- /* Get the size. */
- *type_size = H5Tget_size( tid );
+ /* Get the size. */
+ *type_size = H5Tget_size( tid );
- /* Get the dataspace handle */
- if ( (sid = H5Aget_space( attr_id )) < 0 )
- goto out;
+ /* Get the dataspace handle */
+ if ( (sid = H5Aget_space( attr_id )) < 0 )
+ goto out;
- /* Get dimensions */
- if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 )
- goto out;
+ /* Get dimensions */
+ if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 )
+ goto out;
- /* Terminate access to the dataspace */
- if ( H5Sclose( sid ) < 0 )
- goto out;
+ /* Terminate access to the dataspace */
+ if ( H5Sclose( sid ) < 0 )
+ goto out;
- /* Release the datatype. */
- if ( H5Tclose( tid ) )
- goto out;
+ /* Release the datatype. */
+ if ( H5Tclose( tid ) )
+ goto out;
- /* End access to the attribute */
- if ( H5Aclose( attr_id ) )
- goto out;
+ /* End access to the attribute */
+ if ( H5Aclose( attr_id ) )
+ goto out;
- /* Close the object */
- if(H5Oclose(obj_id) < 0 )
- return -1;
+ /* Close the object */
+ if(H5Oclose(obj_id) < 0 )
+ return -1;
- return 0;
+ return 0;
out:
- H5Tclose(tid);
- H5Aclose(attr_id);
- H5Oclose(obj_id);
- return -1;
+ H5Tclose(tid);
+ H5Aclose(attr_id);
+ H5Oclose(obj_id);
+ return -1;
}
@@ -1576,65 +1576,65 @@ out:
/*-------------------------------------------------------------------------
- * Function: H5LTtext_to_dtype
- *
- * Purpose: Convert DDL description to HDF5 data type.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Raymond Lu, slu@ncsa.uiuc.edu
- *
- * Date: October 6, 2004
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTtext_to_dtype
+*
+* Purpose: Convert DDL description to HDF5 data type.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Raymond Lu, slu@ncsa.uiuc.edu
+*
+* Date: October 6, 2004
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type)
{
- extern int H5LTyyparse(void);
- hid_t type_id;
+ extern int H5LTyyparse(void);
+ hid_t type_id;
- if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG)
- goto out;
+ if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG)
+ goto out;
- if(lang_type != H5LT_DDL) {
- fprintf(stderr, "only DDL is supported for now.\n");
- goto out;
- }
+ if(lang_type != H5LT_DDL) {
+ fprintf(stderr, "only DDL is supported for now.\n");
+ goto out;
+ }
- input_len = strlen(text);
- myinput = strdup(text);
+ input_len = strlen(text);
+ myinput = strdup(text);
- if((type_id = H5LTyyparse()) < 0)
- goto out;
+ if((type_id = H5LTyyparse()) < 0)
+ goto out;
- free(myinput);
- input_len = 0;
+ free(myinput);
+ input_len = 0;
- return type_id;
+ return type_id;
out:
- return -1;
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: indentation
- *
- * Purpose: Print spaces for indentation
- *
- * Return: void
- *
- * Programmer: Raymond Lu, slu@ncsa.uiuc.edu
- *
- * Date: December 6, 2005
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: indentation
+*
+* Purpose: Print spaces for indentation
+*
+* Return: void
+*
+* Programmer: Raymond Lu, slu@ncsa.uiuc.edu
+*
+* Date: December 6, 2005
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
static void
indentation(int x, char* str)
{
@@ -1648,17 +1648,17 @@ indentation(int x, char* str)
}
/*-------------------------------------------------------------------------
- * Function: print_enum
- *
- * Purpose: prints the enum data
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Raymond Lu
- *
- * Modifications:
- *
- *-----------------------------------------------------------------------*/
+* Function: print_enum
+*
+* Purpose: prints the enum data
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Raymond Lu
+*
+* Modifications:
+*
+*-----------------------------------------------------------------------*/
static herr_t
print_enum(hid_t type, char* str, int indt)
{
@@ -1682,9 +1682,9 @@ print_enum(hid_t type, char* str, int indt)
goto out;
/* Use buffer of INT or UNSIGNED INT to print enum values because
- * we don't expect these values to be so big that INT or UNSIGNED
- * INT can't hold.
- */
+ * we don't expect these values to be so big that INT or UNSIGNED
+ * INT can't hold.
+ */
if (H5T_SGN_NONE == H5Tget_sign(super)) {
native = H5T_NATIVE_UINT;
} else {
@@ -1699,9 +1699,9 @@ print_enum(hid_t type, char* str, int indt)
value = (unsigned char*)calloc((size_t)nmembs, MAX(dst_size, super_size));
for (i = 0; i < nmembs; i++) {
- if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL)
+ if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL)
goto out;
- if(H5Tget_member_value(type, (unsigned)i, value + i * super_size) < 0)
+ if(H5Tget_member_value(type, (unsigned)i, value + i * super_size) < 0)
goto out;
}
@@ -1712,45 +1712,45 @@ print_enum(hid_t type, char* str, int indt)
}
/*
- * Sort members by increasing value
- * ***not implemented yet***
- */
+ * Sort members by increasing value
+ * ***not implemented yet***
+ */
/* Print members */
for (i = 0; i < nmembs; i++) {
- indentation(indt + COL, str);
- nchars = sprintf(tmp_str, "\"%s\"", name[i]);
+ indentation(indt + COL, str);
+ nchars = sprintf(tmp_str, "\"%s\"", name[i]);
strcat(str, tmp_str);
- sprintf(tmp_str, "%*s ", MAX(0, 16 - nchars), "");
+ sprintf(tmp_str, "%*s ", MAX(0, 16 - nchars), "");
strcat(str, tmp_str);
- if (H5T_SGN_NONE == H5Tget_sign(native)) {
- /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
- *strangely, unless use another pointer "copy".*/
- copy = value+i*dst_size;
- sprintf(tmp_str,"%u", *((unsigned int*)((void *)copy)));
+ if (H5T_SGN_NONE == H5Tget_sign(native)) {
+ /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
+ *strangely, unless use another pointer "copy".*/
+ copy = value+i*dst_size;
+ sprintf(tmp_str,"%u", *((unsigned int*)((void *)copy)));
strcat(str, tmp_str);
- } else {
- /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
- *strangely, unless use another pointer "copy".*/
- copy = value+i*dst_size;
- sprintf(tmp_str,"%d", *((int*)((void *)copy)));
+ } else {
+ /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
+ *strangely, unless use another pointer "copy".*/
+ copy = value+i*dst_size;
+ sprintf(tmp_str,"%d", *((int*)((void *)copy)));
strcat(str, tmp_str);
- }
+ }
- strcat(str, ";\n");
+ strcat(str, ";\n");
}
/* Release resources */
for (i = 0; i < nmembs; i++)
- free(name[i]);
+ free(name[i]);
free(name);
free(value);
H5Tclose(super);
if (0 == nmembs) {
- sprintf(tmp_str, "\n%*s <empty>", indt + 4, "");
+ sprintf(tmp_str, "\n%*s <empty>", indt + 4, "");
strcat(str, tmp_str);
}
@@ -1761,22 +1761,22 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5LTdtype_to_text
- *
- * Purpose: Convert HDF5 data type to DDL description.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Raymond Lu, slu@ncsa.uiuc.edu
- *
- * Date: December 6, 2005
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTdtype_to_text
+*
+* Purpose: Convert HDF5 data type to DDL description.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Raymond Lu, slu@ncsa.uiuc.edu
+*
+* Date: December 6, 2005
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len)
{
size_t str_len = INCREMENT;
@@ -1805,24 +1805,24 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5LT_dtype_to_text
- *
- * Purpose: Private function to convert HDF5 data type to DDL description.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Raymond Lu, slu@ncsa.uiuc.edu
- *
- * Date: December 20, 2005
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LT_dtype_to_text
+*
+* Purpose: Private function to convert HDF5 data type to DDL description.
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Raymond Lu, slu@ncsa.uiuc.edu
+*
+* Date: December 20, 2005
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LT_dtype_to_text(hid_t dtype, char **dt_str, H5LT_lang_t lang, size_t *slen,
- hbool_t no_user_buf)
+ hbool_t no_user_buf)
{
H5T_class_t tcls;
char tmp_str[256];
@@ -1834,8 +1834,8 @@ herr_t H5LT_dtype_to_text(hid_t dtype, char **dt_str, H5LT_lang_t lang, size_t *
*slen += INCREMENT;
tmp = (char*)realloc(*dt_str, *slen);
if(tmp != *dt_str) {
- free(*dt_str);
- *dt_str = tmp;
+ free(*dt_str);
+ *dt_str = tmp;
}
}
@@ -1930,150 +1930,150 @@ herr_t H5LT_dtype_to_text(hid_t dtype, char **dt_str, H5LT_lang_t lang, size_t *
break;
case H5T_STRING:
{
- /* Make a copy of type in memory in case when DTYPE is on disk, the size
- * will be bigger than in memory. This makes it easier to compare
- * types in memory. */
- hid_t str_type;
- H5T_order_t order;
- hid_t tmp_type;
- size_t size;
- H5T_str_t str_pad;
- H5T_cset_t cset;
- htri_t is_vlstr;
-
- if((tmp_type = H5Tcopy(dtype)) < 0)
- goto out;
- if((size = H5Tget_size(tmp_type))==0)
- goto out;
- if((str_pad = H5Tget_strpad(tmp_type)) < 0)
- goto out;
- if((cset = H5Tget_cset(tmp_type)) < 0)
- goto out;
- if((is_vlstr = H5Tis_variable_str(tmp_type)) < 0)
- goto out;
+ /* Make a copy of type in memory in case when DTYPE is on disk, the size
+ * will be bigger than in memory. This makes it easier to compare
+ * types in memory. */
+ hid_t str_type;
+ H5T_order_t order;
+ hid_t tmp_type;
+ size_t size;
+ H5T_str_t str_pad;
+ H5T_cset_t cset;
+ htri_t is_vlstr;
+
+ if((tmp_type = H5Tcopy(dtype)) < 0)
+ goto out;
+ if((size = H5Tget_size(tmp_type))==0)
+ goto out;
+ if((str_pad = H5Tget_strpad(tmp_type)) < 0)
+ goto out;
+ if((cset = H5Tget_cset(tmp_type)) < 0)
+ goto out;
+ if((is_vlstr = H5Tis_variable_str(tmp_type)) < 0)
+ goto out;
- /* Print lead-in */
- sprintf(*dt_str, "H5T_STRING {\n");
- indent += COL;
+ /* Print lead-in */
+ sprintf(*dt_str, "H5T_STRING {\n");
+ indent += COL;
- indentation(indent + COL, *dt_str);
+ indentation(indent + COL, *dt_str);
- if(is_vlstr)
- strcat(*dt_str, "STRSIZE H5T_VARIABLE;\n");
- else {
- sprintf(tmp_str, "STRSIZE %d;\n", (int)size);
- strcat(*dt_str, tmp_str);
- }
+ if(is_vlstr)
+ strcat(*dt_str, "STRSIZE H5T_VARIABLE;\n");
+ else {
+ sprintf(tmp_str, "STRSIZE %d;\n", (int)size);
+ strcat(*dt_str, tmp_str);
+ }
- indentation(indent + COL, *dt_str);
+ indentation(indent + COL, *dt_str);
- if (str_pad == H5T_STR_NULLTERM)
- strcat(*dt_str, "STRPAD H5T_STR_NULLTERM;\n");
- else if (str_pad == H5T_STR_NULLPAD)
- strcat(*dt_str, "STRPAD H5T_STR_NULLPAD;\n");
- else if (str_pad == H5T_STR_SPACEPAD)
- strcat(*dt_str, "STRPAD H5T_STR_SPACEPAD;\n");
- else
- strcat(*dt_str, "STRPAD H5T_STR_ERROR;\n");
+ if (str_pad == H5T_STR_NULLTERM)
+ strcat(*dt_str, "STRPAD H5T_STR_NULLTERM;\n");
+ else if (str_pad == H5T_STR_NULLPAD)
+ strcat(*dt_str, "STRPAD H5T_STR_NULLPAD;\n");
+ else if (str_pad == H5T_STR_SPACEPAD)
+ strcat(*dt_str, "STRPAD H5T_STR_SPACEPAD;\n");
+ else
+ strcat(*dt_str, "STRPAD H5T_STR_ERROR;\n");
- indentation(indent + COL, *dt_str);
+ indentation(indent + COL, *dt_str);
- if (cset == H5T_CSET_ASCII)
- strcat(*dt_str, "CSET H5T_CSET_ASCII;\n");
- else if (cset == H5T_CSET_UTF8)
- strcat(*dt_str, "CSET H5T_CSET_UTF8;\n");
- else
- strcat(*dt_str, "CSET unknown;\n");
+ if (cset == H5T_CSET_ASCII)
+ strcat(*dt_str, "CSET H5T_CSET_ASCII;\n");
+ else if (cset == H5T_CSET_UTF8)
+ strcat(*dt_str, "CSET H5T_CSET_UTF8;\n");
+ else
+ strcat(*dt_str, "CSET unknown;\n");
- /* Reproduce a C type string */
- if((str_type = H5Tcopy(H5T_C_S1)) < 0)
- goto out;
- if(is_vlstr) {
- if(H5Tset_size(str_type, H5T_VARIABLE) < 0)
+ /* Reproduce a C type string */
+ if((str_type = H5Tcopy(H5T_C_S1)) < 0)
goto out;
- } else {
- if(H5Tset_size(str_type, size) < 0)
+ if(is_vlstr) {
+ if(H5Tset_size(str_type, H5T_VARIABLE) < 0)
+ goto out;
+ } else {
+ if(H5Tset_size(str_type, size) < 0)
+ goto out;
+ }
+ if(H5Tset_cset(str_type, cset) < 0)
+ goto out;
+ if(H5Tset_strpad(str_type, str_pad) < 0)
goto out;
- }
- if(H5Tset_cset(str_type, cset) < 0)
- goto out;
- if(H5Tset_strpad(str_type, str_pad) < 0)
- goto out;
- indentation(indent + COL, *dt_str);
+ indentation(indent + COL, *dt_str);
- /* Check C variable-length string first. Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- strcat(*dt_str, "CTYPE H5T_C_S1;\n");
- goto next;
- }
+ /* Check C variable-length string first. Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ strcat(*dt_str, "CTYPE H5T_C_S1;\n");
+ goto next;
+ }
- /* Change the endianness and see if they're equal. */
- if((order = H5Tget_order(tmp_type)) < 0)
- goto out;
- if(order==H5T_ORDER_LE) {
- if(H5Tset_order(str_type, H5T_ORDER_LE) < 0)
+ /* Change the endianness and see if they're equal. */
+ if((order = H5Tget_order(tmp_type)) < 0)
goto out;
- } else if(order==H5T_ORDER_BE) {
- if(H5Tset_order(str_type, H5T_ORDER_BE) < 0)
+ if(order==H5T_ORDER_LE) {
+ if(H5Tset_order(str_type, H5T_ORDER_LE) < 0)
+ goto out;
+ } else if(order==H5T_ORDER_BE) {
+ if(H5Tset_order(str_type, H5T_ORDER_BE) < 0)
+ goto out;
+ }
+
+ if (H5Tequal(tmp_type, str_type)) {
+ strcat(*dt_str, "H5T_C_S1;\n");
+ goto next;
+ }
+
+ /* If not equal to C variable-length string, check Fortran type.
+ * Actually H5Tequal can't tell difference between H5T_C_S1 and H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+ if(H5Tclose(str_type) < 0)
goto out;
- }
-
- if (H5Tequal(tmp_type, str_type)) {
- strcat(*dt_str, "H5T_C_S1;\n");
- goto next;
- }
-
- /* If not equal to C variable-length string, check Fortran type.
- * Actually H5Tequal can't tell difference between H5T_C_S1 and H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
- if(H5Tclose(str_type) < 0)
- goto out;
- if((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0)
- goto out;
- if(H5Tset_cset(str_type, cset) < 0)
- goto out;
- if(H5Tset_size(str_type, size) < 0)
- goto out;
- if(H5Tset_strpad(str_type, str_pad) < 0)
- goto out;
-
- /* Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n");
- goto next;
- }
-
- /* Change the endianness and see if they're equal. */
- if((order = H5Tget_order(tmp_type)) < 0)
- goto out;
- if(order==H5T_ORDER_LE) {
- if(H5Tset_order(str_type, H5T_ORDER_LE) < 0)
+ if((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0)
goto out;
- } else if(order==H5T_ORDER_BE) {
- if(H5Tset_order(str_type, H5T_ORDER_BE) < 0)
+ if(H5Tset_cset(str_type, cset) < 0)
+ goto out;
+ if(H5Tset_size(str_type, size) < 0)
+ goto out;
+ if(H5Tset_strpad(str_type, str_pad) < 0)
goto out;
- }
- /* Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n");
- goto next;
- }
+ /* Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n");
+ goto next;
+ }
- /* Type doesn't match any of above. */
- strcat(*dt_str, "CTYPE unknown_one_character_type;\n ");
+ /* Change the endianness and see if they're equal. */
+ if((order = H5Tget_order(tmp_type)) < 0)
+ goto out;
+ if(order==H5T_ORDER_LE) {
+ if(H5Tset_order(str_type, H5T_ORDER_LE) < 0)
+ goto out;
+ } else if(order==H5T_ORDER_BE) {
+ if(H5Tset_order(str_type, H5T_ORDER_BE) < 0)
+ goto out;
+ }
+
+ /* Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n");
+ goto next;
+ }
+
+ /* Type doesn't match any of above. */
+ strcat(*dt_str, "CTYPE unknown_one_character_type;\n ");
next:
- H5Tclose(str_type);
- H5Tclose(tmp_type);
+ H5Tclose(str_type);
+ H5Tclose(tmp_type);
- /* Print closing */
- indent -= COL;
- indentation(indent + COL, *dt_str);
- strcat(*dt_str, "}");
+ /* Print closing */
+ indent -= COL;
+ indentation(indent + COL, *dt_str);
+ strcat(*dt_str, "}");
- break;
+ break;
}
case H5T_OPAQUE:
/* Print lead-in */
@@ -2096,166 +2096,166 @@ next:
break;
case H5T_ENUM:
{
- hid_t super;
- size_t super_len;
- char* stmp;
+ hid_t super;
+ size_t super_len;
+ char* stmp;
- /* Print lead-in */
- sprintf(*dt_str, "H5T_ENUM {\n");
- indent += COL;
- indentation(indent + COL, *dt_str);
+ /* Print lead-in */
+ sprintf(*dt_str, "H5T_ENUM {\n");
+ indent += COL;
+ indentation(indent + COL, *dt_str);
- if((super = H5Tget_super(dtype)) < 0)
- goto out;
- if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
- goto out;
- stmp = (char*)calloc(super_len, sizeof(char));
- if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
- goto out;
- strcat(*dt_str, stmp);
- free(stmp);
- strcat(*dt_str, ";\n");
- H5Tclose(super);
-
- if(print_enum(dtype, *dt_str, indent) < 0)
- goto out;
+ if((super = H5Tget_super(dtype)) < 0)
+ goto out;
+ if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
+ goto out;
+ stmp = (char*)calloc(super_len, sizeof(char));
+ if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
+ goto out;
+ strcat(*dt_str, stmp);
+ free(stmp);
+ strcat(*dt_str, ";\n");
+ H5Tclose(super);
- /* Print closing */
- indent -= COL;
- indentation(indent + COL, *dt_str);
- strcat(*dt_str, "}");
+ if(print_enum(dtype, *dt_str, indent) < 0)
+ goto out;
- break;
+ /* Print closing */
+ indent -= COL;
+ indentation(indent + COL, *dt_str);
+ strcat(*dt_str, "}");
+
+ break;
}
case H5T_VLEN:
{
- hid_t super;
- size_t super_len;
- char* stmp;
+ hid_t super;
+ size_t super_len;
+ char* stmp;
- /* Print lead-in */
- sprintf(*dt_str, "H5T_VLEN {\n");
- indent += COL;
- indentation(indent + COL, *dt_str);
+ /* Print lead-in */
+ sprintf(*dt_str, "H5T_VLEN {\n");
+ indent += COL;
+ indentation(indent + COL, *dt_str);
- if((super = H5Tget_super(dtype)) < 0)
- goto out;
- if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
- goto out;
- stmp = (char*)calloc(super_len, sizeof(char));
- if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
- goto out;
- strcat(*dt_str, stmp);
- free(stmp);
- strcat(*dt_str, "\n");
- H5Tclose(super);
+ if((super = H5Tget_super(dtype)) < 0)
+ goto out;
+ if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
+ goto out;
+ stmp = (char*)calloc(super_len, sizeof(char));
+ if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
+ goto out;
+ strcat(*dt_str, stmp);
+ free(stmp);
+ strcat(*dt_str, "\n");
+ H5Tclose(super);
- /* Print closing */
- indent -= COL;
- indentation(indent + COL, *dt_str);
- strcat(*dt_str, "}");
+ /* Print closing */
+ indent -= COL;
+ indentation(indent + COL, *dt_str);
+ strcat(*dt_str, "}");
- break;
+ break;
}
case H5T_ARRAY:
{
- hid_t super;
- size_t super_len;
- char* stmp;
- hsize_t dims[H5S_MAX_RANK];
- int ndims;
-
- /* Print lead-in */
- sprintf(*dt_str, "H5T_ARRAY {\n");
- indent += COL;
- indentation(indent + COL, *dt_str);
-
- /* Get array information */
- if((ndims = H5Tget_array_ndims(dtype)) < 0)
- goto out;
- if(H5Tget_array_dims2(dtype, dims) < 0)
- goto out;
-
- /* Print array dimensions */
- for (i = 0; i < ndims; i++) {
- sprintf(tmp_str, "[%d]", (int) dims[i]);
- strcat(*dt_str, tmp_str);
- }
- strcat(*dt_str, " ");
-
- if((super = H5Tget_super(dtype)) < 0)
- goto out;
- if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
- goto out;
- stmp = (char*)calloc(super_len, sizeof(char));
- if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
- goto out;
- strcat(*dt_str, stmp);
- free(stmp);
- strcat(*dt_str, "\n");
- H5Tclose(super);
-
- /* Print closing */
- indent -= COL;
- indentation(indent + COL, *dt_str);
- strcat(*dt_str, "}");
-
- break;
- }
- case H5T_COMPOUND:
- {
- char *mname;
- hid_t mtype;
- size_t moffset;
- H5T_class_t mclass;
- size_t mlen;
- char* mtmp;
- int nmembs;
-
- if((nmembs = H5Tget_nmembers(dtype)) < 0)
- goto out;
-
- sprintf(*dt_str, "H5T_COMPOUND {\n");
- indent += COL;
+ hid_t super;
+ size_t super_len;
+ char* stmp;
+ hsize_t dims[H5S_MAX_RANK];
+ int ndims;
+
+ /* Print lead-in */
+ sprintf(*dt_str, "H5T_ARRAY {\n");
+ indent += COL;
+ indentation(indent + COL, *dt_str);
- for (i = 0; i < nmembs; i++) {
- if((mname = H5Tget_member_name(dtype, (unsigned)i))==NULL)
+ /* Get array information */
+ if((ndims = H5Tget_array_ndims(dtype)) < 0)
goto out;
- if((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0)
+ if(H5Tget_array_dims2(dtype, dims) < 0)
goto out;
- moffset = H5Tget_member_offset(dtype, (unsigned)i);
- indentation(indent + COL, *dt_str);
- if((mclass = H5Tget_class(mtype)) < 0)
- goto out;
- if (H5T_COMPOUND == mclass)
- indent += COL;
+ /* Print array dimensions */
+ for (i = 0; i < ndims; i++) {
+ sprintf(tmp_str, "[%d]", (int) dims[i]);
+ strcat(*dt_str, tmp_str);
+ }
+ strcat(*dt_str, " ");
- if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0)
+ if((super = H5Tget_super(dtype)) < 0)
goto out;
- mtmp = (char*)calloc(mlen, sizeof(char));
- if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0)
+ if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
goto out;
- strcat(*dt_str, mtmp);
- free(mtmp);
-
- if (H5T_COMPOUND == mclass)
- indent -= COL;
+ stmp = (char*)calloc(super_len, sizeof(char));
+ if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
+ goto out;
+ strcat(*dt_str, stmp);
+ free(stmp);
+ strcat(*dt_str, "\n");
+ H5Tclose(super);
- sprintf(tmp_str, " \"%s\"", mname);
- strcat(*dt_str, tmp_str);
- free(mname);
+ /* Print closing */
+ indent -= COL;
+ indentation(indent + COL, *dt_str);
+ strcat(*dt_str, "}");
- sprintf(tmp_str, " : %lu;\n", (unsigned long)moffset);
- strcat(*dt_str, tmp_str);
+ break;
}
+ case H5T_COMPOUND:
+ {
+ char *mname;
+ hid_t mtype;
+ size_t moffset;
+ H5T_class_t mclass;
+ size_t mlen;
+ char* mtmp;
+ int nmembs;
+
+ if((nmembs = H5Tget_nmembers(dtype)) < 0)
+ goto out;
- /* Print closing */
- indent -= COL;
- indentation(indent + COL, *dt_str);
- strcat(*dt_str, "}");
+ sprintf(*dt_str, "H5T_COMPOUND {\n");
+ indent += COL;
+
+ for (i = 0; i < nmembs; i++) {
+ if((mname = H5Tget_member_name(dtype, (unsigned)i))==NULL)
+ goto out;
+ if((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0)
+ goto out;
+ moffset = H5Tget_member_offset(dtype, (unsigned)i);
+ indentation(indent + COL, *dt_str);
+
+ if((mclass = H5Tget_class(mtype)) < 0)
+ goto out;
+ if (H5T_COMPOUND == mclass)
+ indent += COL;
+
+ if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0)
+ goto out;
+ mtmp = (char*)calloc(mlen, sizeof(char));
+ if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0)
+ goto out;
+ strcat(*dt_str, mtmp);
+ free(mtmp);
+
+ if (H5T_COMPOUND == mclass)
+ indent -= COL;
+
+ sprintf(tmp_str, " \"%s\"", mname);
+ strcat(*dt_str, tmp_str);
+ free(mname);
+
+ sprintf(tmp_str, " : %lu;\n", (unsigned long)moffset);
+ strcat(*dt_str, tmp_str);
+ }
+
+ /* Print closing */
+ indent -= COL;
+ indentation(indent + COL, *dt_str);
+ strcat(*dt_str, "}");
- break;
+ break;
}
case H5T_TIME:
sprintf(*dt_str, "H5T_TIME: not yet implemented");
@@ -2278,77 +2278,77 @@ out:
/*-------------------------------------------------------------------------
- *
- * Get attribute functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Get attribute functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_string
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_string
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_string( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- char *data )
+ const char *obj_name,
+ const char *attr_name,
+ char *data )
{
- /* identifiers */
- hid_t obj_id;
+ /* identifiers */
+ hid_t obj_id;
- /* Open the object */
- if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0)
- return -1;
+ /* Open the object */
+ if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0)
+ return -1;
- /* Get the attribute */
- if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 )
+ return -1;
- /* Close the object */
- if(H5Oclose(obj_id) < 0)
- return -1;
+ /* Close the object */
+ if(H5Oclose(obj_id) < 0)
+ return -1;
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_char
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_char
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_char( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- char *data )
+ const char *obj_name,
+ const char *attr_name,
+ char *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0)
@@ -2358,26 +2358,26 @@ herr_t H5LTget_attribute_char( hid_t loc_id,
}
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_uchar
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_uchar
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_uchar( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- unsigned char *data )
+ const char *obj_name,
+ const char *attr_name,
+ unsigned char *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0)
@@ -2389,26 +2389,26 @@ herr_t H5LTget_attribute_uchar( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_short
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_short
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_short( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- short *data )
+ const char *obj_name,
+ const char *attr_name,
+ short *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0)
@@ -2418,22 +2418,22 @@ herr_t H5LTget_attribute_short( hid_t loc_id,
}
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_ushort
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_ushort
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_ushort( hid_t loc_id,
const char *obj_name,
const char *attr_name,
@@ -2449,26 +2449,26 @@ herr_t H5LTget_attribute_ushort( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_int
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_int
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_int( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- int *data )
+ const char *obj_name,
+ const char *attr_name,
+ int *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0)
@@ -2478,22 +2478,22 @@ herr_t H5LTget_attribute_int( hid_t loc_id,
}
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_uint
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_uint
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_uint( hid_t loc_id,
const char *obj_name,
const char *attr_name,
@@ -2509,22 +2509,22 @@ herr_t H5LTget_attribute_uint( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_long
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_long
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_long( hid_t loc_id,
const char *obj_name,
const char *attr_name,
@@ -2538,26 +2538,26 @@ herr_t H5LTget_attribute_long( hid_t loc_id,
}
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_long_long
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu
- *
- * Date: June 17, 2005
- *
- * Comments: This funstion was added to suuport INTEGER*8 Fortran types
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_long_long
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu
+*
+* Date: June 17, 2005
+*
+* Comments: This funstion was added to suuport INTEGER*8 Fortran types
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_long_long( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- long long *data )
+ const char *obj_name,
+ const char *attr_name,
+ long long *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0)
@@ -2568,26 +2568,26 @@ herr_t H5LTget_attribute_long_long( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_ulong
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_ulong
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_ulong( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- unsigned long *data )
+ const char *obj_name,
+ const char *attr_name,
+ unsigned long *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0)
@@ -2598,28 +2598,28 @@ herr_t H5LTget_attribute_ulong( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_float
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_float
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_float( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- float *data )
+ const char *obj_name,
+ const char *attr_name,
+ float *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0)
@@ -2630,28 +2630,28 @@ herr_t H5LTget_attribute_float( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute_double
- *
- * Purpose: Reads an attribute named attr_name
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute_double
+*
+* Purpose: Reads an attribute named attr_name
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute_double( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- double *data )
+ const char *obj_name,
+ const char *attr_name,
+ double *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0)
@@ -2662,29 +2662,29 @@ herr_t H5LTget_attribute_double( hid_t loc_id,
/*-------------------------------------------------------------------------
- * Function: H5LTget_attribute
- *
- * Purpose: Reads an attribute named attr_name with the memory type mem_type_id
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments: Private function
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LTget_attribute
+*
+* Purpose: Reads an attribute named attr_name with the memory type mem_type_id
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments: Private function
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LTget_attribute( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- hid_t mem_type_id,
- void *data )
+ const char *obj_name,
+ const char *attr_name,
+ hid_t mem_type_id,
+ void *data )
{
/* Get the attribute */
if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0)
@@ -2695,35 +2695,35 @@ herr_t H5LTget_attribute( hid_t loc_id,
/*-------------------------------------------------------------------------
- * private functions
- *-------------------------------------------------------------------------
- */
+* private functions
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5LT_get_attribute_mem
- *
- * Purpose: Reads an attribute named attr_name with the memory type mem_type_id
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments: Private function
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LT_get_attribute_mem
+*
+* Purpose: Reads an attribute named attr_name with the memory type mem_type_id
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments: Private function
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
static herr_t H5LT_get_attribute_mem(hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- hid_t mem_type_id,
- void *data)
+ const char *obj_name,
+ const char *attr_name,
+ hid_t mem_type_id,
+ void *data)
{
/* identifiers */
hid_t obj_id = -1;
@@ -2745,7 +2745,7 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id,
/* Close the object */
if(H5Oclose(obj_id) < 0)
- goto out;
+ goto out;
obj_id = -1;
return 0;
@@ -2757,138 +2757,138 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5LT_get_attribute_disk
- *
- * Purpose: Reads an attribute named attr_name with the datatype stored on disk
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: September 19, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LT_get_attribute_disk
+*
+* Purpose: Reads an attribute named attr_name with the datatype stored on disk
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: September 19, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LT_get_attribute_disk( hid_t loc_id,
- const char *attr_name,
- void *attr_out )
+ const char *attr_name,
+ void *attr_out )
{
- /* identifiers */
- hid_t attr_id;
- hid_t attr_type;
+ /* identifiers */
+ hid_t attr_id;
+ hid_t attr_type;
- if(( attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0)
- return -1;
+ if(( attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0)
+ return -1;
- if((attr_type = H5Aget_type(attr_id)) < 0)
- goto out;
+ if((attr_type = H5Aget_type(attr_id)) < 0)
+ goto out;
- if(H5Aread(attr_id, attr_type, attr_out) < 0)
- goto out;
+ if(H5Aread(attr_id, attr_type, attr_out) < 0)
+ goto out;
- if(H5Tclose(attr_type) < 0)
- goto out;
+ if(H5Tclose(attr_type) < 0)
+ goto out;
- if ( H5Aclose( attr_id ) < 0 )
- return -1;;
+ if ( H5Aclose( attr_id ) < 0 )
+ return -1;;
- return 0;
+ return 0;
out:
- H5Tclose( attr_type );
- H5Aclose( attr_id );
- return -1;
+ H5Tclose( attr_type );
+ H5Aclose( attr_id );
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: H5LT_set_attribute_string
- *
- * Purpose: creates and writes an attribute named NAME to the dataset DSET_ID
- *
- * Return: FAIL on error, SUCCESS on success
- *
- * Programmer: pvn@ncsa.uiuc.edu
- *
- * Date: January 04, 2005
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5LT_set_attribute_string
+*
+* Purpose: creates and writes an attribute named NAME to the dataset DSET_ID
+*
+* Return: FAIL on error, SUCCESS on success
+*
+* Programmer: pvn@ncsa.uiuc.edu
+*
+* Date: January 04, 2005
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5LT_set_attribute_string(hid_t dset_id,
const char *name,
const char *buf )
{
- hid_t tid;
- hid_t sid = -1;
- hid_t aid = -1;
- int has_attr;
- size_t size;
-
- /* verify if the attribute already exists */
- has_attr = H5LT_find_attribute(dset_id,name);
-
- /* the attribute already exists, delete it */
- if(has_attr == 1)
- if(H5Adelete(dset_id, name) < 0)
- return FAIL;
+ hid_t tid;
+ hid_t sid = -1;
+ hid_t aid = -1;
+ int has_attr;
+ size_t size;
-/*-------------------------------------------------------------------------
- * create the attribute type
- *-------------------------------------------------------------------------
- */
- if((tid = H5Tcopy(H5T_C_S1)) < 0)
- return FAIL;
+ /* verify if the attribute already exists */
+ has_attr = H5LT_find_attribute(dset_id,name);
- size = strlen(buf) + 1; /* extra null term */
+ /* the attribute already exists, delete it */
+ if(has_attr == 1)
+ if(H5Adelete(dset_id, name) < 0)
+ return FAIL;
- if(H5Tset_size(tid,(size_t)size) < 0)
- goto out;
+ /*-------------------------------------------------------------------------
+ * create the attribute type
+ *-------------------------------------------------------------------------
+ */
+ if((tid = H5Tcopy(H5T_C_S1)) < 0)
+ return FAIL;
- if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0)
- goto out;
+ size = strlen(buf) + 1; /* extra null term */
- if((sid = H5Screate(H5S_SCALAR)) < 0)
- goto out;
+ if(H5Tset_size(tid,(size_t)size) < 0)
+ goto out;
+ if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0)
+ goto out;
-/*-------------------------------------------------------------------------
- * create and write the attribute
- *-------------------------------------------------------------------------
- */
- if((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ if((sid = H5Screate(H5S_SCALAR)) < 0)
+ goto out;
- if(H5Awrite(aid, tid, buf) < 0)
- goto out;
- if(H5Aclose(aid) < 0)
- goto out;
+ /*-------------------------------------------------------------------------
+ * create and write the attribute
+ *-------------------------------------------------------------------------
+ */
+ if((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
+ if(H5Awrite(aid, tid, buf) < 0)
+ goto out;
- if(H5Tclose(tid) < 0)
- goto out;
+ if(H5Aclose(aid) < 0)
+ goto out;
- return SUCCEED;
+ if(H5Sclose(sid) < 0)
+ goto out;
+
+ if(H5Tclose(tid) < 0)
+ goto out;
+
+ return SUCCEED;
- /* error zone, gracefully close */
+ /* error zone */
out:
- H5E_BEGIN_TRY {
- H5Aclose(aid);
- H5Tclose(tid);
- H5Sclose(sid);
- } H5E_END_TRY;
- return FAIL;
+ H5E_BEGIN_TRY {
+ H5Aclose(aid);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return FAIL;
}
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c
index 30a8490..a035319 100644
--- a/hl/src/H5TB.c
+++ b/hl/src/H5TB.c
@@ -1,17 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+* Copyright by The HDF Group. *
+* Copyright by the Board of Trustees of the University of Illinois. *
+* All rights reserved. *
+* *
+* This file is part of HDF5. The full HDF5 copyright notice, including *
+* terms governing use, modification, and redistribution, is contained in *
+* the files COPYING and Copyright.html. COPYING can be found at the root *
+* of the source code distribution tree; Copyright.html can be found at the *
+* root level of an installed copy of the electronic HDF5 document set and *
+* is linked from the top-level documents page. It can also be found at *
+* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+* access to either file, you may request a copy from help@hdfgroup.org. *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -20,11 +20,11 @@
/*-------------------------------------------------------------------------
- *
- * internal functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* internal functions
+*
+*-------------------------------------------------------------------------
+*/
static int H5TB_find_field(const char *field,
const char *field_list);
@@ -43,47 +43,47 @@ static hid_t H5TB_create_type(hid_t loc_id,
hid_t ftype_id);
/*-------------------------------------------------------------------------
- *
- * Create functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Create functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TBmake_table
- *
- * Purpose: Make a table
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- * Quincey Koziol
- *
- * Date: January 17, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBmake_table
+*
+* Purpose: Make a table
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+* Quincey Koziol
+*
+* Date: January 17, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBmake_table( const char *table_title,
- hid_t loc_id,
- const char *dset_name,
- hsize_t nfields,
- hsize_t nrecords,
- size_t type_size,
- const char *field_names[],
- const size_t *field_offset,
- const hid_t *field_types,
- hsize_t chunk_size,
- void *fill_data,
- int compress,
- const void *buf )
+ hid_t loc_id,
+ const char *dset_name,
+ hsize_t nfields,
+ hsize_t nrecords,
+ size_t type_size,
+ const char *field_names[],
+ const size_t *field_offset,
+ const hid_t *field_types,
+ hsize_t chunk_size,
+ void *fill_data,
+ int compress,
+ const void *buf )
{
-
+
hid_t did;
hid_t sid;
hid_t mem_type_id;
@@ -97,37 +97,37 @@ herr_t H5TBmake_table( const char *table_title,
char aux[255];
hsize_t i;
unsigned char *tmp_buf;
-
+
dims[0] = nrecords;
dims_chunk[0] = chunk_size;
-
+
/* create the memory data type. */
if ((mem_type_id = H5Tcreate (H5T_COMPOUND, type_size )) < 0)
return -1;
-
+
/* insert fields. */
for ( i = 0; i < nfields; i++)
{
if(H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i] ) < 0)
return -1;
}
-
+
/* create a simple data space with unlimited size */
if ((sid = H5Screate_simple( 1, dims, maxdims )) < 0)
return -1;
-
+
/* modify dataset creation properties, i.e. enable chunking */
plist_id = H5Pcreate(H5P_DATASET_CREATE);
if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0)
return -1;
-
+
/* set the fill value using a struct as the data type. */
if (fill_data)
{
if(H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0)
return -1;
}
-
+
/*
dataset creation property list is modified to use
GZIP compression with the compression effort set to 6.
@@ -137,11 +137,11 @@ herr_t H5TBmake_table( const char *table_title,
if(H5Pset_deflate(plist_id, 6) < 0)
return -1;
}
-
+
/* create the dataset. */
if ((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0)
goto out;
-
+
/* only write if there is something to write */
if (buf)
{
@@ -149,108 +149,108 @@ herr_t H5TBmake_table( const char *table_title,
if (H5Dwrite( did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0)
goto out;
}
-
+
/* terminate access to the data space. */
if (H5Sclose(sid) < 0)
goto out;
-
+
/* end access to the dataset */
if (H5Dclose(did) < 0)
goto out;
-
+
/* end access to the property list */
if (H5Pclose(plist_id) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* set the conforming table attributes
*-------------------------------------------------------------------------
*/
-
+
/* attach the CLASS attribute */
if (H5LTset_attribute_string( loc_id, dset_name, "CLASS", TABLE_CLASS ) < 0)
goto out;
-
+
/* attach the VERSION attribute */
if (H5LTset_attribute_string( loc_id, dset_name, "VERSION", TABLE_VERSION ) < 0)
goto out;
-
+
/* attach the TITLE attribute */
if (H5LTset_attribute_string( loc_id, dset_name, "TITLE", table_title ) < 0)
goto out;
-
+
/* attach the FIELD_ name attribute */
for ( i = 0; i < nfields; i++)
{
/* get the member name */
member_name = H5Tget_member_name( mem_type_id,(unsigned) i );
-
+
strcpy( attr_name, "FIELD_" );
sprintf( aux, "%d", (int)i );
strcat( attr_name, aux );
sprintf( aux, "%s", "_NAME" );
strcat( attr_name, aux );
-
+
/* attach the attribute */
if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0)
goto out;
-
+
free( member_name );
-
+
}
-
+
/* attach the FIELD_ fill value attribute */
if (fill_data )
{
-
- tmp_buf = fill_data;
-
+
+ tmp_buf = (unsigned char *) fill_data;
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
if (( sid = H5Screate(H5S_SCALAR)) < 0)
goto out;
-
+
for ( i = 0; i < nfields; i++)
{
-
+
/* get the member name */
member_name = H5Tget_member_name(mem_type_id, (unsigned)i);
-
+
strcpy(attr_name, "FIELD_");
sprintf(aux, "%d", (int)i);
strcat(attr_name, aux);
sprintf(aux, "%s", "_FILL");
strcat(attr_name, aux);
-
+
if ((attr_id = H5Acreate2(did, attr_name, field_types[i], sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
-
+
if (H5Awrite(attr_id, field_types[i], tmp_buf+field_offset[i]) < 0)
goto out;
-
+
if (H5Aclose(attr_id) < 0)
goto out;
-
+
free(member_name);
}
-
+
/* terminate access to the data space. */
if (H5Sclose(sid) < 0)
goto out;
-
+
/* end access to the dataset */
if (H5Dclose(did) < 0)
goto out;
}
-
+
/* release the datatype. */
if (H5Tclose( mem_type_id ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY {
@@ -260,45 +260,45 @@ out:
H5Tclose(mem_type_id);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- *
- * Write functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Write functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TBappend_records
- *
- * Purpose: Appends records to a table
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmers:
- * Pedro Vicente, pvn@ncsa.uiuc.edu
- * Quincey Koziol
- *
- * Date: November 19, 2001
- *
- * Comments: Uses memory offsets
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define the memory type ID
- * returned by H5TB_create_type
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBappend_records
+*
+* Purpose: Appends records to a table
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmers:
+* Pedro Vicente, pvn@ncsa.uiuc.edu
+* Quincey Koziol
+*
+* Date: November 19, 2001
+*
+* Comments: Uses memory offsets
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define the memory type ID
+* returned by H5TB_create_type
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBappend_records( hid_t loc_id,
- const char *dset_name,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- const void *buf )
+ const char *dset_name,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ const void *buf )
{
hid_t did;
hid_t tid=-1;
@@ -307,26 +307,26 @@ herr_t H5TBappend_records( hid_t loc_id,
hid_t m_sid=-1;
hsize_t nrecords_orig;
hsize_t nfields;
-
+
/* get the original number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords_orig ) < 0)
return -1;
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatypes */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,tid)) < 0)
goto out;
-
+
/* append the records */
if ((H5TB_common_append_records(did, mem_type_id, (size_t)nrecords, nrecords_orig, buf)) < 0)
goto out;
-
+
/* close */
if (H5Tclose( tid ) < 0)
return -1;
@@ -334,9 +334,9 @@ herr_t H5TBappend_records( hid_t loc_id,
goto out;
if (H5Dclose( did ) < 0)
goto out;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -351,36 +351,36 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5TBwrite_records
- *
- * Purpose: Writes records
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 19, 2001
- *
- * Comments: Uses memory offsets
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define the memory type ID
- * returned by H5TB_create_type
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBwrite_records
+*
+* Purpose: Writes records
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 19, 2001
+*
+* Comments: Uses memory offsets
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define the memory type ID
+* returned by H5TB_create_type
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBwrite_records( hid_t loc_id,
- const char *dset_name,
- hsize_t start,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- const void *buf )
+ const char *dset_name,
+ hsize_t start,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ const void *buf )
{
-
+
hid_t did;
hid_t tid;
hsize_t count[1];
@@ -390,43 +390,43 @@ herr_t H5TBwrite_records( hid_t loc_id,
hsize_t mem_size[1];
hsize_t dims[1];
hid_t mem_type_id=-1;
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get the datatype */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,tid)) < 0)
goto out;
-
+
/* get the dataspace handle */
if ((sid = H5Dget_space( did )) < 0)
goto out;
-
+
/* get records */
if (H5Sget_simple_extent_dims( sid, dims, NULL) < 0)
goto out;
-
+
if (start + nrecords > dims[0] )
goto out;
-
+
/* define a hyperslab in the dataset of the size of the records */
offset[0] = start;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0)
goto out;
-
+
/* close */
if (H5Sclose( m_sid ) < 0)
goto out;
@@ -438,9 +438,9 @@ herr_t H5TBwrite_records( hid_t loc_id,
return -1;
if (H5Dclose( did ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -455,32 +455,32 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5TBwrite_fields_name
- *
- * Purpose: Writes fields
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 21, 2001
- *
- * Comments:
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define a memory type ID
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBwrite_fields_name
+*
+* Purpose: Writes fields
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 21, 2001
+*
+* Comments:
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define a memory type ID
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBwrite_fields_name( hid_t loc_id,
- const char *dset_name,
- const char *field_names,
- hsize_t start,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- const void *buf )
+ const char *dset_name,
+ const char *field_names,
+ hsize_t start,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ const void *buf )
{
hid_t did;
hid_t tid=-1;
@@ -496,57 +496,57 @@ herr_t H5TBwrite_fields_name( hid_t loc_id,
hssize_t i, j;
hid_t preserve_id;
size_t size_native;
-
+
/* create xfer properties to preserve initialized data */
if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0)
return -1;
if (H5Pset_preserve (preserve_id, 1) < 0)
return -1;
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
/* get the number of fields */
if (( nfields = H5Tget_nmembers( tid )) < 0)
goto out;
-
+
/* create a write id */
if (( write_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0)
goto out;
-
+
j = 0;
-
+
/* iterate tru the members */
for ( i = 0; i < nfields; i++)
{
/* get the member name */
member_name = H5Tget_member_name( tid, (unsigned)i );
-
+
if(H5TB_find_field( member_name, field_names ) > 0 )
{
-
+
/* get the member type */
if(( member_type_id = H5Tget_member_type( tid,(unsigned) i )) < 0)
goto out;
-
+
/* convert to native type */
if ((nmtype_id=H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0)
goto out;
-
+
size_native=H5Tget_size(nmtype_id);
-
+
/* adjust, if necessary */
if (field_sizes[j]!=size_native)
{
if (H5Tset_size(nmtype_id, field_sizes[j]) < 0)
goto out;
}
-
+
/* the field in the file is found by its name */
if (field_offset )
{
@@ -559,36 +559,36 @@ herr_t H5TBwrite_fields_name( hid_t loc_id,
if (H5Tinsert( write_type_id, member_name, (size_t)0, nmtype_id ) < 0)
goto out;
}
-
+
j++;
-
+
/* close */
if(H5Tclose( member_type_id ) < 0)
goto out;
if(H5Tclose( nmtype_id ) < 0)
goto out;
}
-
+
free( member_name );
-
+
}
-
+
/* get the dataspace handle */
if ((file_space_id = H5Dget_space( did )) < 0)
goto out;
if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0)
goto out;
-
+
/* define a hyperslab in the dataset */
offset[0] = start;
count[0] = nrecords;
if (H5Sselect_hyperslab( file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* write */
if (H5Dwrite( did, write_type_id, m_sid, file_space_id, preserve_id, buf ) < 0)
goto out;
-
+
/* close */
if(H5Tclose( write_type_id ) )
goto out;
@@ -602,9 +602,9 @@ herr_t H5TBwrite_fields_name( hid_t loc_id,
return -1;
if(H5Sclose( m_sid ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -617,41 +617,41 @@ out:
H5Tclose(tid);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBwrite_fields_index
- *
- * Purpose: Writes fields
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 21, 2001
- *
- * Comments: Uses memory offsets
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define a memory type ID
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBwrite_fields_index
+*
+* Purpose: Writes fields
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 21, 2001
+*
+* Comments: Uses memory offsets
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define a memory type ID
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBwrite_fields_index( hid_t loc_id,
- const char *dset_name,
- hsize_t nfields,
- const int *field_index,
- hsize_t start,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- const void *buf )
+ const char *dset_name,
+ hsize_t nfields,
+ const int *field_index,
+ hsize_t start,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ const void *buf )
{
hid_t did;
hid_t tid=-1;
@@ -666,50 +666,50 @@ herr_t H5TBwrite_fields_index( hid_t loc_id,
hsize_t i, j;
hid_t preserve_id;
size_t size_native;
-
+
/* create xfer properties to preserve initialized data */
if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0)
return -1;
if (H5Pset_preserve (preserve_id, 1) < 0)
return -1;
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
/* create a write id */
if (( write_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0)
goto out;
-
+
/* iterate tru the members */
for ( i = 0; i < nfields; i++)
{
-
+
j = field_index[i];
-
+
/* get the member name */
member_name = H5Tget_member_name( tid, (unsigned) j );
-
+
/* get the member type */
if (( member_type_id = H5Tget_member_type( tid, (unsigned) j )) < 0)
goto out;
-
+
/* convert to native type */
if ((nmtype_id = H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0)
goto out;
-
+
size_native = H5Tget_size(nmtype_id);
-
+
if (field_sizes[i]!=size_native)
{
if (H5Tset_size(nmtype_id, field_sizes[i]) < 0)
goto out;
}
-
+
/* the field in the file is found by its name */
if ( field_offset )
{
@@ -727,27 +727,27 @@ herr_t H5TBwrite_fields_index( hid_t loc_id,
goto out;
if(H5Tclose( nmtype_id ) < 0)
goto out;
-
+
free( member_name );
-
+
}
-
+
/* get the dataspace handles */
if ((file_space_id = H5Dget_space( did )) < 0)
goto out;
if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0)
goto out;
-
+
/* define a hyperslab in the dataset */
offset[0] = start;
count[0] = nrecords;
if (H5Sselect_hyperslab( file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* write */
if (H5Dwrite( did, write_type_id, m_sid, file_space_id, preserve_id, buf ) < 0)
goto out;
-
+
/* close */
if (H5Tclose( write_type_id ) )
goto out;
@@ -761,9 +761,9 @@ herr_t H5TBwrite_fields_index( hid_t loc_id,
return -1;
if (H5Sclose( m_sid ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -780,68 +780,68 @@ out:
/*-------------------------------------------------------------------------
- *
- * Read functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Read functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TBread_table
- *
- * Purpose: Reads a table
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 20, 2001
- *
- * Comments:
- *
- * Modifications: April 1, 2004
- * used a memory type ID returned by H5TB_create_type
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBread_table
+*
+* Purpose: Reads a table
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 20, 2001
+*
+* Comments:
+*
+* Modifications: April 1, 2004
+* used a memory type ID returned by H5TB_create_type
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBread_table( hid_t loc_id,
- const char *dset_name,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- void *dst_buf )
+ const char *dset_name,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ void *dst_buf )
{
hid_t did;
hid_t ftype_id=-1;
hid_t mem_type_id=-1;
hid_t sid;
hsize_t dims[1];
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get the dataspace handle */
if ((sid = H5Dget_space( did )) < 0)
goto out;
-
+
/* get dimensions */
if (H5Sget_simple_extent_dims( sid, dims, NULL) < 0)
goto out;
-
+
/* get the datatypes */
if ((ftype_id=H5Dget_type (did)) < 0)
goto out;
-
+
if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,ftype_id)) < 0)
goto out;
-
+
/* read */
if (H5Dread( did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, dst_buf) < 0)
goto out;
-
+
/* close */
if (H5Tclose( ftype_id ) < 0)
goto out;
@@ -851,9 +851,9 @@ herr_t H5TBread_table( hid_t loc_id,
goto out;
if (H5Dclose( did ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -867,36 +867,36 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5TBread_records
- *
- * Purpose: Reads records
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 19, 2001
- *
- * Comments:
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define the memory type ID
- * returned by H5TB_create_type
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBread_records
+*
+* Purpose: Reads records
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 19, 2001
+*
+* Comments:
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define the memory type ID
+* returned by H5TB_create_type
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBread_records( hid_t loc_id,
- const char *dset_name,
- hsize_t start,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- void *buf )
+ const char *dset_name,
+ hsize_t start,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ void *buf )
{
-
+
hid_t did;
hid_t ftype_id;
hid_t mem_type_id=-1;
@@ -904,22 +904,22 @@ herr_t H5TBread_records( hid_t loc_id,
hid_t m_sid=-1;
hsize_t nrecords_orig;
hsize_t nfields;
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords_orig ) < 0)
return -1;
-
+
/* open the dataset */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get the datatypes */
if ((ftype_id = H5Dget_type( did )) < 0)
goto out;
-
+
if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,ftype_id)) < 0)
goto out;
-
+
/* read the records */
if ((H5TB_common_read_records(did, mem_type_id, start, (size_t)nrecords, nrecords_orig, buf)) < 0)
goto out;
@@ -931,9 +931,9 @@ herr_t H5TBread_records( hid_t loc_id,
return -1;
if (H5Dclose( did ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY {
@@ -944,40 +944,40 @@ out:
H5Sclose(sid);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBread_fields_name
- *
- * Purpose: Reads fields
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 19, 2001
- *
- * Comments:
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define the memory type ID
- * returned by H5TB_create_type
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBread_fields_name
+*
+* Purpose: Reads fields
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 19, 2001
+*
+* Comments:
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define the memory type ID
+* returned by H5TB_create_type
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBread_fields_name( hid_t loc_id,
- const char *dset_name,
- const char *field_names,
- hsize_t start,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- void *buf )
+ const char *dset_name,
+ const char *field_names,
+ hsize_t start,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ void *buf )
{
hid_t did;
@@ -994,41 +994,41 @@ herr_t H5TBread_fields_name( hid_t loc_id,
hsize_t mem_size[1];
size_t size_native;
hssize_t i, j;
-
+
/* open the dataset */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if ((ftype_id = H5Dget_type( did )) < 0)
goto out;
-
+
/* get the number of fields */
if (( nfields = H5Tget_nmembers( ftype_id )) < 0)
goto out;
-
+
/* create a memory read id */
if (( mem_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0)
goto out;
-
+
/* iterate tru the members */
for ( i=0,j=0; i<nfields; i++)
{
/* get the member name */
member_name = H5Tget_member_name( ftype_id, (unsigned)i );
-
+
if(H5TB_find_field( member_name, field_names ) > 0 )
{
/* get the member type */
if (( mtype_id = H5Tget_member_type( ftype_id, (unsigned) i )) < 0)
goto out;
-
+
/* convert to native type */
if ((nmtype_id=H5Tget_native_type(mtype_id,H5T_DIR_DEFAULT)) < 0)
goto out;
-
+
size_native=H5Tget_size(nmtype_id);
-
+
if (field_sizes[j]!=size_native)
{
if (H5Tset_size(nmtype_id, field_sizes[j]) < 0)
@@ -1045,7 +1045,7 @@ herr_t H5TBread_fields_name( hid_t loc_id,
if(H5Tinsert( mem_type_id, member_name, (size_t)0, nmtype_id ) < 0)
goto out;
}
-
+
/* close */
if(H5Tclose( mtype_id ) < 0)
goto out;
@@ -1055,26 +1055,26 @@ herr_t H5TBread_fields_name( hid_t loc_id,
}
free( member_name );
}
-
+
/* get the dataspace handle */
if ((sid = H5Dget_space( did )) < 0)
goto out;
-
+
/* define a hyperslab in the dataset */
offset[0] = start;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
/* read */
if (H5Dread( did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0)
goto out;
-
+
/* close */
if (H5Tclose( mem_type_id ) )
goto out;
@@ -1086,9 +1086,9 @@ herr_t H5TBread_fields_name( hid_t loc_id,
goto out;
if (H5Dclose( did ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -1100,43 +1100,43 @@ out:
H5Sclose(sid);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBread_fields_index
- *
- * Purpose: Reads fields
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 19, 2001
- *
- * Comments:
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define the memory type ID
- * returned by H5TB_create_type
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBread_fields_index
+*
+* Purpose: Reads fields
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 19, 2001
+*
+* Comments:
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define the memory type ID
+* returned by H5TB_create_type
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBread_fields_index( hid_t loc_id,
- const char *dset_name,
- hsize_t nfields,
- const int *field_index,
- hsize_t start,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- void *buf )
+ const char *dset_name,
+ hsize_t nfields,
+ const int *field_index,
+ hsize_t start,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ void *buf )
{
-
+
hid_t did;
hid_t tid=-1;
hid_t read_type_id=-1;
@@ -1150,47 +1150,47 @@ herr_t H5TBread_fields_index( hid_t loc_id,
hsize_t mem_size[1];
size_t size_native;
hsize_t i, j;
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
/* create a read id */
if (( read_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0)
goto out;
-
+
/* iterate tru the members */
for ( i = 0; i < nfields; i++)
{
j = field_index[i];
-
+
/* get the member name */
member_name = H5Tget_member_name( tid, (unsigned) j );
-
+
/* get the member type */
if (( member_type_id = H5Tget_member_type( tid, (unsigned) j )) < 0)
goto out;
-
+
/* get the member size */
if (H5Tget_size( member_type_id ) == 0 )
goto out;
-
+
/* convert to native type */
if ((nmtype_id=H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0)
goto out;
-
+
size_native=H5Tget_size(nmtype_id);
-
+
if (field_sizes[i]!=size_native)
{
if (H5Tset_size(nmtype_id, field_sizes[i]) < 0)
goto out;
}
-
+
/* the field in the file is found by its name */
if (field_offset )
{
@@ -1202,35 +1202,35 @@ herr_t H5TBread_fields_index( hid_t loc_id,
if(H5Tinsert( read_type_id, member_name, (size_t)0, nmtype_id ) < 0)
goto out;
}
-
+
/* close the member type */
if (H5Tclose( member_type_id ) < 0)
goto out;
if (H5Tclose( nmtype_id ) < 0)
goto out;
-
+
free( member_name );
}
-
+
/* get the dataspace handle */
if ((sid = H5Dget_space( did )) < 0)
goto out;
-
+
/* define a hyperslab in the dataset */
offset[0] = start;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
/* read */
if (H5Dread( did, read_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0)
goto out;
-
+
/* close */
if (H5Sclose( sid ) < 0)
goto out;
@@ -1242,9 +1242,9 @@ herr_t H5TBread_fields_index( hid_t loc_id,
return -1;
if (H5Dclose( did ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -1256,40 +1256,40 @@ out:
H5Sclose(sid);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- *
- * Manipulation functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Manipulation functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TBdelete_record
- *
- * Purpose: Delete records from middle of table ("pulling up" all the records after it)
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 26, 2001
- *
- * Modifications: April 29, 2003
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBdelete_record
+*
+* Purpose: Delete records from middle of table ("pulling up" all the records after it)
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 26, 2001
+*
+* Modifications: April 29, 2003
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBdelete_record( hid_t loc_id,
- const char *dset_name,
- hsize_t start,
- hsize_t nrecords )
+ const char *dset_name,
+ hsize_t start,
+ hsize_t nrecords )
{
-
+
hsize_t nfields;
hsize_t ntotal_records;
hsize_t read_start;
@@ -1306,24 +1306,24 @@ herr_t H5TBdelete_record( hid_t loc_id,
size_t *src_offset;
size_t *src_sizes;
hsize_t dims[1];
-
+
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
*-------------------------------------------------------------------------
*/
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &ntotal_records ) < 0)
return -1;
-
+
src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t));
src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t));
-
+
if (src_offset == NULL )
return -1;
if (src_sizes == NULL )
return -1;
-
+
/* get field info */
if (H5TBget_field_info( loc_id, dset_name, NULL, src_sizes, src_offset, &src_size ) < 0)
return -1;
@@ -1331,53 +1331,53 @@ herr_t H5TBdelete_record( hid_t loc_id,
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* read the records after the deleted one(s)
*-------------------------------------------------------------------------
*/
-
+
read_start = start + nrecords;
read_nrecords = ntotal_records - read_start;
if ( read_nrecords )
{
tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, src_size );
-
+
if (tmp_buf == NULL )
return -1;
-
+
/* read the records after the deleted one(s) */
if (H5TBread_records( loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* write the records in another position
*-------------------------------------------------------------------------
*/
-
+
/* get the datatype */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
/* get the dataspace handle */
if ((sid = H5Dget_space( did )) < 0)
goto out;
-
+
/* define a hyperslab in the dataset of the size of the records */
offset[0] = start;
count[0] = read_nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
if (H5Dwrite( did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0)
goto out;
-
+
/* close */
if (H5Sclose( m_sid ) < 0)
goto out;
@@ -1385,10 +1385,10 @@ herr_t H5TBdelete_record( hid_t loc_id,
goto out;
if (H5Tclose( tid ) < 0)
goto out;
-
+
} /* read_nrecords */
-
-
+
+
/*-------------------------------------------------------------------------
* change the dataset dimension
*-------------------------------------------------------------------------
@@ -1396,20 +1396,20 @@ herr_t H5TBdelete_record( hid_t loc_id,
dims[0] = ntotal_records - nrecords;
if (H5Dset_extent( did, dims ) < 0)
goto out;
-
+
/* close dataset */
if (H5Dclose( did ) < 0)
return -1;
-
+
if (tmp_buf !=NULL)
free( tmp_buf );
free( src_offset );
free( src_sizes );
-
-
+
+
return 0;
- /* error zone */
+ /* error zone */
out:
if (tmp_buf !=NULL )
@@ -1421,41 +1421,41 @@ out:
H5Sclose(sid);
} H5E_END_TRY;
return -1;
-
-
+
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBinsert_record
- *
- * Purpose: Inserts records into middle of table ("pushing down" all the records after it)
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 26, 2001
- *
- * Comments: Uses memory offsets
- *
- * Modifications: April 1, 2004
- * the FIELD_SIZES parameter is used to define the memory type ID
- * returned by H5TB_create_type
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBinsert_record
+*
+* Purpose: Inserts records into middle of table ("pushing down" all the records after it)
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 26, 2001
+*
+* Comments: Uses memory offsets
+*
+* Modifications: April 1, 2004
+* the FIELD_SIZES parameter is used to define the memory type ID
+* returned by H5TB_create_type
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBinsert_record( hid_t loc_id,
- const char *dset_name,
- hsize_t start,
- hsize_t nrecords,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- void *buf )
+ const char *dset_name,
+ hsize_t start,
+ hsize_t nrecords,
+ size_t type_size,
+ const size_t *field_offset,
+ const size_t *field_sizes,
+ void *buf )
{
-
+
hsize_t nfields;
hsize_t ntotal_records;
hsize_t read_nrecords;
@@ -1469,93 +1469,93 @@ herr_t H5TBinsert_record( hid_t loc_id,
hsize_t dims[1];
hsize_t mem_dims[1];
unsigned char *tmp_buf;
-
+
/*-------------------------------------------------------------------------
* read the records after the inserted one(s)
*-------------------------------------------------------------------------
*/
-
+
/* get the dimensions */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &ntotal_records ) < 0)
return -1;
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
/* create the memory data type. */
if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,tid)) < 0)
goto out;
-
+
read_nrecords = ntotal_records - start;
tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, type_size);
-
+
/* read the records after the inserted one(s) */
if (H5TBread_records( loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes, tmp_buf ) < 0)
return -1;
-
+
/* extend the dataset */
dims[0] = ntotal_records + nrecords;
-
+
if (H5Dset_extent(did, dims) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* write the inserted records
*-------------------------------------------------------------------------
*/
-
+
/* create a simple memory data space */
mem_dims[0] = nrecords;
if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0)
return -1;
-
+
/* get the file data space */
if ((sid = H5Dget_space( did )) < 0)
return -1;
-
+
/* define a hyperslab in the dataset to write the new data */
offset[0] = start;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0)
goto out;
-
+
/* terminate access to the dataspace */
if (H5Sclose( m_sid ) < 0)
goto out;
if (H5Sclose( sid ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* write the "pushed down" records
*-------------------------------------------------------------------------
*/
-
+
/* create a simple memory data space */
mem_dims[0]=read_nrecords;
if ((m_sid = H5Screate_simple( 1, mem_dims, NULL )) < 0)
return -1;
-
+
/* get the file data space */
if ((sid = H5Dget_space( did )) < 0)
return -1;
-
+
/* define a hyperslab in the dataset to write the new data */
offset[0] = start + nrecords;
count[0] = read_nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0)
goto out;
-
+
/* close */
if (H5Sclose( m_sid ) < 0)
goto out;
@@ -1567,11 +1567,11 @@ herr_t H5TBinsert_record( hid_t loc_id,
return -1;
if (H5Dclose( did ) < 0)
return -1;
-
+
free( tmp_buf );
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -1586,30 +1586,30 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: H5TBadd_records_from
- *
- * Purpose: Add records from first table to second table
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 5, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBadd_records_from
+*
+* Purpose: Add records from first table to second table
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: December 5, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBadd_records_from( hid_t loc_id,
- const char *dset_name1,
- hsize_t start1,
- hsize_t nrecords,
- const char *dset_name2,
- hsize_t start2 )
+ const char *dset_name1,
+ hsize_t start1,
+ hsize_t nrecords,
+ const char *dset_name2,
+ hsize_t start2 )
{
hid_t did_1;
hid_t tid_1;
@@ -1625,75 +1625,75 @@ herr_t H5TBadd_records_from( hid_t loc_id,
size_t src_size;
size_t *src_offset;
size_t *src_sizes;
-
+
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
*-------------------------------------------------------------------------
*/
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name1, &nfields, &ntotal_records ) < 0)
return -1;
-
+
src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t));
src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t));
-
+
if (src_offset == NULL )
return -1;
-
+
/* get field info */
if (H5TBget_field_info( loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* Get information about the first table and read it
*-------------------------------------------------------------------------
*/
-
+
/* open the 1st dataset. */
if ((did_1 = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get the datatype */
if ((tid_1 = H5Dget_type( did_1 )) < 0)
goto out;
-
+
/* get the dataspace handle */
if ((sid_1 = H5Dget_space( did_1 )) < 0)
goto out;
-
+
/* get the size of the datatype */
if (( type_size1 = H5Tget_size( tid_1 )) == 0 )
goto out;
-
+
tmp_buf = (unsigned char *)calloc((size_t)nrecords, type_size1 );
-
+
/* define a hyperslab in the dataset of the size of the records */
offset[0] = start1;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((msid_1 = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
if (H5Dread( did_1, tid_1, msid_1, sid_1, H5P_DEFAULT, tmp_buf ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* add to the second table
*-------------------------------------------------------------------------
*/
if (H5TBinsert_record(loc_id,dset_name2,start2,nrecords,src_size,src_offset,src_sizes,tmp_buf ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* close resources for table 1
*-------------------------------------------------------------------------
*/
-
+
if (H5Sclose( msid_1 ) < 0)
goto out;
if (H5Sclose( sid_1 ) < 0)
@@ -1702,13 +1702,13 @@ herr_t H5TBadd_records_from( hid_t loc_id,
return -1;
if (H5Dclose( did_1 ) < 0)
return -1;
-
+
free( tmp_buf );
free( src_offset );
free( src_sizes );
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -1719,34 +1719,34 @@ out:
H5Tclose(tid_1);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBcombine_tables
- *
- * Purpose: Combine records from two tables into a third
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 10, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBcombine_tables
+*
+* Purpose: Combine records from two tables into a third
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: December 10, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBcombine_tables( hid_t loc_id1,
- const char *dset_name1,
- hid_t loc_id2,
- const char *dset_name2,
- const char *dset_name3 )
+ const char *dset_name1,
+ hid_t loc_id2,
+ const char *dset_name2,
+ const char *dset_name3 )
{
-
+
/* identifiers for the 1st dataset. */
hid_t did_1=-1;
hid_t tid_1=-1;
@@ -1784,178 +1784,178 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
size_t *src_offset;
size_t *src_sizes;
int has_fill=0;
-
+
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
*-------------------------------------------------------------------------
*/
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id1, dset_name1, &nfields, &nrecords ) < 0)
return -1;
-
+
src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t));
src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t));
-
+
if (src_offset == NULL )
return -1;
-
+
/* get field info */
if (H5TBget_field_info( loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* get information about the first table
*-------------------------------------------------------------------------
*/
-
+
/* open the 1st dataset. */
if ((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if ((tid_1 = H5Dget_type( did_1 )) < 0)
goto out;
-
+
/* get the dataspace handle */
if ((sid_1 = H5Dget_space( did_1 )) < 0)
goto out;
-
+
/* get creation properties list */
if ((pid_1 = H5Dget_create_plist( did_1 )) < 0)
goto out;
-
+
/* get the dimensions */
if (H5TBget_table_info ( loc_id1, dset_name1, &nfields, &nrecords ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* make the merged table with no data originally
*-------------------------------------------------------------------------
*/
-
+
/* clone the property list */
if ((pid_3 = H5Pcopy(pid_1)) < 0)
goto out;
-
+
/* clone the type id */
if ((tid_3 = H5Tcopy(tid_1)) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* here we do not clone the file space from the 1st dataset, because we want to create
* an empty table. Instead we create a new dataspace with zero records and expandable.
*-------------------------------------------------------------------------
*/
dims[0] = 0;
-
+
/* create a simple data space with unlimited size */
if ((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0)
return -1;
-
+
/* create the dataset */
if ((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* attach the conforming table attributes
*-------------------------------------------------------------------------
*/
if (H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* get attributes
*-------------------------------------------------------------------------
*/
-
+
type_size = H5Tget_size(tid_3);
-
+
/* alloc fill value attribute buffer */
tmp_fill_buf = (unsigned char *)malloc(type_size);
-
+
/* get the fill value attributes */
has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf);
-
+
/*-------------------------------------------------------------------------
* attach the fill attributes from previous table
*-------------------------------------------------------------------------
*/
if (has_fill == 1 )
{
-
+
if (( sid = H5Screate(H5S_SCALAR)) < 0)
goto out;
-
+
for ( i = 0; i < nfields; i++)
{
-
+
/* get the member type */
if (( member_type_id = H5Tget_member_type( tid_3, (unsigned) i )) < 0)
goto out;
-
+
/* get the member offset */
member_offset = H5Tget_member_offset(tid_3, (unsigned)i);
-
+
strcpy(attr_name, "FIELD_");
sprintf(aux, "%d", (int)i);
strcat(attr_name, aux);
sprintf(aux, "%s", "_FILL");
strcat(attr_name, aux);
-
+
if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
-
+
if (H5Awrite(attr_id, member_type_id, tmp_fill_buf+member_offset) < 0)
goto out;
-
+
if (H5Aclose(attr_id) < 0)
goto out;
-
+
if (H5Tclose(member_type_id) < 0)
goto out;
}
-
+
/* close data space. */
if (H5Sclose( sid ) < 0)
goto out;
}
-
+
/*-------------------------------------------------------------------------
* read data from 1st table
*-------------------------------------------------------------------------
*/
-
+
tmp_buf = (unsigned char *)calloc((size_t) nrecords, type_size );
-
+
/* define a hyperslab in the dataset of the size of the records */
offset[0] = 0;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
if (H5Dread( did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* save data from 1st table into new table
*-------------------------------------------------------------------------
*/
-
+
/* append the records to the new table */
if (H5TBappend_records( loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* release resources from 1st table
*-------------------------------------------------------------------------
*/
-
+
if (H5Sclose( m_sid ) < 0)
goto out;
if(H5Sclose( sid_1 ) < 0)
@@ -1966,70 +1966,70 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
goto out;
if(H5Dclose( did_1 ) < 0)
goto out;
-
+
/* Release resources. */
free( tmp_buf );
-
+
/*-------------------------------------------------------------------------
* get information about the 2nd table
*-------------------------------------------------------------------------
*/
-
+
/* open the dataset. */
if ((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if ((tid_2 = H5Dget_type( did_2 )) < 0)
goto out;
-
+
/* get the dataspace handle */
if ((sid_2 = H5Dget_space( did_2 )) < 0)
goto out;
-
+
/* get the property list handle */
if ((pid_2 = H5Dget_create_plist( did_2 )) < 0)
goto out;
-
+
/* get the dimensions */
if (H5TBget_table_info ( loc_id2, dset_name2, &nfields, &nrecords ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* read data from 2nd table
*-------------------------------------------------------------------------
*/
-
+
tmp_buf = (unsigned char *)calloc((size_t) nrecords, type_size );
-
+
/* define a hyperslab in the dataset of the size of the records */
offset[0] = 0;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
if (H5Dread( did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* save data from 2nd table into new table
*-------------------------------------------------------------------------
*/
-
+
/* append the records to the new table */
if (H5TBappend_records( loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* release resources from 2nd table
*-------------------------------------------------------------------------
*/
-
+
if (H5Sclose( m_sid ) < 0)
goto out;
if (H5Sclose( sid_2 ) < 0)
@@ -2040,12 +2040,12 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
goto out;
if (H5Dclose( did_2 ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* release resources from 3rd table
*-------------------------------------------------------------------------
*/
-
+
if (H5Sclose( sid_3 ) < 0)
return -1;
if (H5Tclose( tid_3 ) < 0)
@@ -2054,16 +2054,16 @@ herr_t H5TBcombine_tables( hid_t loc_id1,
return -1;
if (H5Dclose( did_3 ) < 0)
return -1;
-
+
/* Release resources. */
free( tmp_buf );
free( tmp_fill_buf );
free( src_offset );
free( src_sizes );
-
+
return 0;
-
- /* error zone */
+
+ /* error zone */
out:
H5E_BEGIN_TRY
{
@@ -2081,34 +2081,34 @@ out:
H5Pclose(pid_3);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBinsert_field
- *
- * Purpose: Inserts a field
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: January 30, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBinsert_field
+*
+* Purpose: Inserts a field
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: January 30, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBinsert_field( hid_t loc_id,
- const char *dset_name,
- const char *field_name,
- hid_t field_type,
- hsize_t position,
- const void *fill_data,
- const void *buf )
+ const char *dset_name,
+ const char *field_name,
+ hid_t field_type,
+ hsize_t position,
+ const void *fill_data,
+ const void *buf )
{
/* identifiers for the 1st, original dataset */
hid_t did_1;
@@ -2148,214 +2148,214 @@ herr_t H5TBinsert_field( hid_t loc_id,
unsigned char *tmp_buf;
unsigned char *tmp_fill_buf;
hsize_t i;
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* get information about the old data type
*-------------------------------------------------------------------------
*/
-
+
/* open the dataset. */
if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get creation properties list */
if ((pid_1 = H5Dget_create_plist( did_1 )) < 0)
goto out;
-
+
/* get the datatype */
if ((tid_1 = H5Dget_type( did_1 )) < 0)
goto out;
-
+
/* get the size of the datatype */
if (( total_size = H5Tget_size( tid_1 )) == 0 )
goto out;
-
+
/* get the dataspace handle */
if ((sid_1 = H5Dget_space( did_1 )) < 0)
goto out;
-
+
/* get dimension */
if (H5Sget_simple_extent_dims( sid_1, dims, NULL) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* get attributes
*-------------------------------------------------------------------------
*/
-
+
/* get the table title */
if ((H5TBAget_title( did_1, table_title )) < 0)
goto out;
-
+
/* alloc fill value attribute buffer */
tmp_fill_buf = (unsigned char *)malloc(total_size );
-
+
/* get the fill value attributes */
if ((H5TBAget_fill( loc_id, dset_name, did_1, tmp_fill_buf )) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* create a new data type
*-------------------------------------------------------------------------
*/
-
+
/* get the new member size */
member_size = H5Tget_size( field_type );
-
+
/* create the data type. */
if (( tid_2 = H5Tcreate (H5T_COMPOUND,(size_t)(total_size + member_size) )) < 0)
goto out;
-
+
curr_offset = 0;
inserted = 0;
-
+
/* insert the old fields, counting with the new one */
for ( i = 0; i < nfields + 1; i++)
{
idx = i;
if (inserted )
idx = i - 1;
-
+
if (i == position )
{
/* get the new member size */
new_member_size = H5Tget_size( field_type );
-
+
/* insert the new field type */
if (H5Tinsert( tid_2, field_name, curr_offset, field_type ) < 0)
goto out;
-
+
curr_offset += new_member_size;
-
+
inserted = 1;
-
+
continue;
}
-
+
/* get the member name */
member_name = H5Tget_member_name( tid_1, (unsigned)idx );
-
+
/* get the member type */
if (( member_type_id = H5Tget_member_type( tid_1,(unsigned)idx )) < 0)
goto out;
-
+
/* get the member size */
member_size = H5Tget_size( member_type_id );
-
+
/* insert it into the new type */
if (H5Tinsert( tid_2, member_name, curr_offset, member_type_id ) < 0)
goto out;
-
+
curr_offset += member_size;
-
+
free( member_name );
-
+
/* close the member type */
if(H5Tclose( member_type_id ) < 0)
goto out;
} /* i */
-
+
/*-------------------------------------------------------------------------
* create a new temporary dataset
*-------------------------------------------------------------------------
*/
-
+
/* retrieve the size of chunk */
if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0)
goto out;
-
+
/* create a new simple data space with unlimited size, using the dimension */
if ((sid_2 = H5Screate_simple( 1, dims, maxdims)) < 0)
return -1;
-
+
/* modify dataset creation properties, i.e. enable chunking */
pid_2 = H5Pcreate(H5P_DATASET_CREATE);
if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0)
return -1;
-
+
/* create the dataset. */
if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* read data from 1st table
*-------------------------------------------------------------------------
*/
-
+
tmp_buf = (unsigned char *)calloc((size_t)nrecords, (size_t)total_size);
-
+
/* define a hyperslab in the dataset of the size of the records */
offset[0] = 0;
count[0] = nrecords;
if (H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((msid_1 = H5Screate_simple(1, mem_size, NULL)) < 0)
goto out;
-
+
if (H5Dread(did_1, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* save data from 1st table into new table, using the 1st type id
*-------------------------------------------------------------------------
*/
-
+
/* write */
if (H5Dwrite( did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* save the function supplied data of the new field
*-------------------------------------------------------------------------
*/
-
+
/* create a write id */
if (( write_type_id = H5Tcreate( H5T_COMPOUND, (size_t)new_member_size )) < 0)
goto out;
-
+
/* the field in the file is found by its name */
if (H5Tinsert( write_type_id, field_name, (size_t)0, field_type ) < 0)
goto out;
-
+
/* create xfer properties to preserve initialized data */
if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0)
goto out;
if (H5Pset_preserve (preserve_id, 1) < 0)
goto out;
-
+
/* only write if there is something to write */
if ( buf )
{
/* create a memory dataspace handle */
if ((msid_2 = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
-
+
/* write */
if (H5Dwrite( did_2, write_type_id, msid_2, sid_2, preserve_id, buf ) < 0)
goto out;
-
+
/* terminate access to the memory dataspace */
if (H5Sclose( msid_2 ) < 0)
goto out;
}
-
+
/* end access to the property list */
if (H5Pclose( preserve_id ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* release resources from 1st table
*-------------------------------------------------------------------------
*/
-
+
if (H5Sclose( msid_1 ) < 0)
goto out;
if (H5Tclose( tid_1 ) < 0)
@@ -2366,13 +2366,13 @@ herr_t H5TBinsert_field( hid_t loc_id,
goto out;
if (H5Dclose( did_1 ) < 0)
goto out;
-
-
+
+
/*-------------------------------------------------------------------------
* release resources from 2nd table
*-------------------------------------------------------------------------
*/
-
+
if (H5Sclose( sid_2 ) < 0)
goto out;
if (H5Tclose( tid_2 ) < 0)
@@ -2380,112 +2380,112 @@ herr_t H5TBinsert_field( hid_t loc_id,
if (H5Pclose( pid_2 ) < 0)
goto out;
if (H5Dclose( did_2 ) < 0)
- goto out;
-
+ goto out;
+
/*-------------------------------------------------------------------------
* delete 1st table
*-------------------------------------------------------------------------
*/
if (H5Ldelete( loc_id, dset_name, H5P_DEFAULT ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* rename 2nd table
*-------------------------------------------------------------------------
*/
-
+
if (H5Lmove( loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* attach the conforming table attributes
*-------------------------------------------------------------------------
*/
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0)
return -1;
-
+
/* open the dataset. */
if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get the datatype */
if ((tid_1 = H5Dget_type( did_1 )) < 0)
goto out;
-
+
/* set the attributes */
if (H5TB_attach_attributes( table_title, loc_id, dset_name,(hsize_t) nfields, tid_1 ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* attach the fill attributes from previous table
*-------------------------------------------------------------------------
*/
-
+
if (( sid_1 = H5Screate(H5S_SCALAR)) < 0)
goto out;
-
+
for ( i = 0; i < nfields-1; i++)
{
/* get the member type */
if(( member_type_id = H5Tget_member_type( tid_1, (unsigned) i )) < 0)
goto out;
-
+
/* get the member offset */
member_offset = H5Tget_member_offset(tid_1, (unsigned)i);
-
+
strcpy(attr_name, "FIELD_");
sprintf(aux, "%d", (int)i);
strcat(attr_name, aux);
sprintf(aux, "%s", "_FILL");
strcat(attr_name, aux);
-
+
if ((attr_id = H5Acreate2(did_1, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
-
+
if (H5Awrite(attr_id, member_type_id, tmp_fill_buf+member_offset) < 0)
goto out;
-
+
if (H5Aclose(attr_id) < 0)
goto out;
-
+
/* close the member type */
if (H5Tclose(member_type_id) < 0)
goto out;
}
-
+
/*-------------------------------------------------------------------------
* attach the fill attribute from the new field, if present
*-------------------------------------------------------------------------
*/
if (fill_data)
{
-
+
strcpy(attr_name, "FIELD_");
sprintf(aux, "%d",(int)(nfields - 1));
strcat(attr_name, aux);
sprintf(aux, "%s", "_FILL");
strcat(attr_name, aux);
-
+
/* get the member type */
if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)nfields - 1)) < 0)
goto out;
-
+
if ((attr_id = H5Acreate2(did_1, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
-
+
if (H5Awrite(attr_id, member_type_id, fill_data) < 0)
goto out;
-
+
if (H5Aclose(attr_id) < 0)
goto out;
-
+
if (H5Tclose(member_type_id) < 0)
goto out;
-
+
}
-
+
/* close */
if (H5Sclose( sid_1 ) < 0)
goto out;
@@ -2493,13 +2493,13 @@ herr_t H5TBinsert_field( hid_t loc_id,
goto out;
if (H5Dclose( did_1 ) < 0)
goto out;
-
+
/* release resources. */
free ( tmp_buf );
free ( tmp_fill_buf );
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -2512,33 +2512,33 @@ out:
H5Sclose(sid_2);
H5Tclose(tid_2);
H5Pclose(pid_2);
-
+
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBdelete_field
- *
- * Purpose: Deletes a field
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: January 30, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBdelete_field
+*
+* Purpose: Deletes a field
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: January 30, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBdelete_field( hid_t loc_id,
- const char *dset_name,
- const char *field_name )
+ const char *dset_name,
+ const char *field_name )
{
/* identifiers for the 1st original dataset */
hid_t did_1;
@@ -2574,179 +2574,179 @@ herr_t H5TBdelete_field( hid_t loc_id,
hid_t attr_id;
hsize_t i;
int has_fill=0;
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* get information about the old data type
*-------------------------------------------------------------------------
*/
-
+
/* open the dataset. */
if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get creation properties list */
if ((pid_1 = H5Dget_create_plist( did_1 )) < 0)
goto out;
-
+
/* get the datatype */
if ((tid_1 = H5Dget_type( did_1 )) < 0)
goto out;
-
+
/* get the size of the datatype */
type_size1 = H5Tget_size( tid_1 );
-
+
/* get the dataspace handle */
if ((sid_1 = H5Dget_space( did_1 )) < 0)
goto out;
-
+
/* get dimension */
if (H5Sget_simple_extent_dims( sid_1, dims, NULL) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* create a new data type; first we find the size of the datatype to delete
*-------------------------------------------------------------------------
*/
-
+
/* check out the field */
for ( i = 0; i < nfields; i++)
{
/* get the member name */
member_name = H5Tget_member_name( tid_1,(unsigned) i );
-
+
/* we want to find the field to delete */
if (H5TB_find_field( member_name, field_name ) > 0 )
{
/* get the member type */
if (( member_type_id = H5Tget_member_type( tid_1,(unsigned) i )) < 0)
goto out;
-
+
/* get the member size */
delete_member_size = H5Tget_size( member_type_id );
-
+
/* close the member type */
if (H5Tclose( member_type_id ) < 0)
goto out;
-
+
free( member_name );
-
+
break;
-
+
}
-
+
free( member_name );
-
+
} /* i */
-
+
/* no field to delete was found */
if (delete_member_size == 0 )
goto out;
-
+
/*-------------------------------------------------------------------------
* create a new data type; we now insert all the fields into the new type
*-------------------------------------------------------------------------
*/
-
+
type_size2 = type_size1 - delete_member_size;
-
+
/* create the data type. */
if (( tid_2 = H5Tcreate (H5T_COMPOUND, type_size2 )) < 0)
goto out;
-
+
curr_offset = 0;
-
+
/* alloc fill value attribute buffer */
tmp_fill_buf = (unsigned char *)malloc((size_t) type_size2 );
-
+
/*-------------------------------------------------------------------------
* get attributes from previous table in the process
*-------------------------------------------------------------------------
*/
-
+
/* get the table title */
if ((H5TBAget_title( did_1, table_title )) < 0)
goto out;
-
+
/* insert the old fields except the one to delete */
for ( i = 0; i < nfields; i++)
{
/* get the member name */
member_name = H5Tget_member_name( tid_1, (unsigned) i );
-
+
/* we want to skip the field to delete */
if (H5TB_find_field( member_name, field_name ) > 0 )
{
free( member_name );
continue;
}
-
+
/* get the member type */
if (( member_type_id = H5Tget_member_type( tid_1, (unsigned)i )) < 0)
goto out;
-
+
/* get the member size */
member_size = H5Tget_size( member_type_id );
-
+
/* insert it into the new type */
if (H5Tinsert( tid_2, member_name, curr_offset, member_type_id ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* get the fill value information
*-------------------------------------------------------------------------
*/
-
+
strcpy( attr_name, "FIELD_" );
sprintf( aux, "%d", (int)i );
strcat( attr_name, aux );
sprintf( aux, "%s", "_FILL" );
strcat( attr_name, aux );
-
+
/* check if we have the _FILL attribute */
has_fill = H5LT_find_attribute( did_1, attr_name );
-
+
/* get it */
if (has_fill == 1 )
{
if(H5LT_get_attribute_disk( did_1, attr_name, tmp_fill_buf+curr_offset ) < 0)
goto out;
}
-
+
curr_offset += member_size;
-
+
free(member_name);
-
+
/* close the member type */
if (H5Tclose(member_type_id) < 0)
goto out;
} /* i */
-
+
/*-------------------------------------------------------------------------
* create a new temporary dataset
*-------------------------------------------------------------------------
*/
-
+
/* retrieve the size of chunk */
if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0)
goto out;
-
+
/* create a new simple data space with unlimited size, using the dimension */
if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0)
return -1;
-
+
/* modify dataset creation properties, i.e. enable chunking */
pid_2 = H5Pcreate(H5P_DATASET_CREATE);
if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0)
return -1;
-
+
/* create the dataset. */
if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* we have to read field by field of the old dataset and save it into the new one
*-------------------------------------------------------------------------
@@ -2755,80 +2755,80 @@ herr_t H5TBdelete_field( hid_t loc_id,
{
/* get the member name */
member_name = H5Tget_member_name(tid_1, (unsigned)i);
-
+
/* skip the field to delete */
if (H5TB_find_field(member_name, field_name) > 0)
{
free(member_name);
continue;
}
-
+
/* get the member type */
if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0)
goto out;
-
+
/* get the member size */
member_size = H5Tget_size(member_type_id);
-
+
/* create a read id */
if ((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0)
goto out;
-
+
/* insert it into the new type */
if (H5Tinsert( read_type_id, member_name, (size_t)0, member_type_id ) < 0)
goto out;
-
+
tmp_buf = (unsigned char *)calloc((size_t) nrecords, member_size );
-
+
/* read */
if (H5Dread( did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf ) < 0)
goto out;
-
+
/* create a write id */
if (( write_type_id = H5Tcreate( H5T_COMPOUND, member_size )) < 0)
goto out;
-
+
/* the field in the file is found by its name */
if (H5Tinsert( write_type_id, member_name, (size_t)0, member_type_id ) < 0)
goto out;
-
+
/* create xfer properties to preserve initialized data */
if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0)
goto out;
if (H5Pset_preserve (preserve_id, 1) < 0)
goto out;
-
+
/* write */
if(H5Dwrite( did_2, write_type_id, H5S_ALL, H5S_ALL, preserve_id, tmp_buf ) < 0)
goto out;
-
+
/* end access to the property list */
if (H5Pclose( preserve_id ) < 0)
goto out;
-
+
/* close the member type */
if (H5Tclose( member_type_id ) < 0)
goto out;
-
+
/* close the read type */
if (H5Tclose( read_type_id ) < 0)
goto out;
-
+
/* close the write type */
if (H5Tclose( write_type_id ) < 0)
goto out;
-
+
/* release resources. */
free( member_name );
free ( tmp_buf );
-
+
} /* i */
-
+
/*-------------------------------------------------------------------------
* release resources from 1st table
*-------------------------------------------------------------------------
*/
-
+
if (H5Tclose( tid_1 ) < 0)
goto out;
if (H5Pclose( pid_1 ) < 0)
@@ -2837,13 +2837,13 @@ herr_t H5TBdelete_field( hid_t loc_id,
goto out;
if (H5Dclose( did_1 ) < 0)
goto out;
-
-
+
+
/*-------------------------------------------------------------------------
* release resources from 2nd table
*-------------------------------------------------------------------------
*/
-
+
if (H5Sclose( sid_2 ) < 0)
goto out;
if (H5Tclose( tid_2 ) < 0)
@@ -2852,104 +2852,104 @@ herr_t H5TBdelete_field( hid_t loc_id,
goto out;
if (H5Dclose( did_2 ) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* delete 1st table
*-------------------------------------------------------------------------
*/
-
+
if (H5Ldelete( loc_id, dset_name, H5P_DEFAULT ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* rename 2nd table
*-------------------------------------------------------------------------
*/
-
+
if (H5Lmove( loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* attach the conforming table attributes
*-------------------------------------------------------------------------
*/
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0)
return -1;
-
+
/* open the dataset. */
if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get the datatype */
if ((tid_1 = H5Dget_type( did_1 )) < 0)
goto out;
-
+
/* set the attributes */
if (H5TB_attach_attributes( table_title, loc_id, dset_name, nfields, tid_1 ) < 0)
return -1;
-
+
/*-------------------------------------------------------------------------
* attach the fill attributes from previous table
*-------------------------------------------------------------------------
*/
-
+
if (has_fill == 1)
{
if((sid_1 = H5Screate(H5S_SCALAR)) < 0)
goto out;
-
+
for(i = 0; i < nfields; i++)
{
-
+
/* get the member type */
if (( member_type_id = H5Tget_member_type( tid_1, (unsigned)i )) < 0)
goto out;
-
+
/* get the member offset */
member_offset = H5Tget_member_offset(tid_1, (unsigned)i);
-
+
strcpy(attr_name, "FIELD_");
sprintf(aux, "%d", (int)i);
strcat(attr_name, aux);
sprintf(aux, "%s", "_FILL");
strcat(attr_name, aux);
-
+
if ((attr_id = H5Acreate2(did_1, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
-
+
if (H5Awrite(attr_id, member_type_id, tmp_fill_buf+member_offset) < 0)
goto out;
-
+
if (H5Aclose(attr_id) < 0)
goto out;
-
+
/* close the member type */
if (H5Tclose(member_type_id) < 0)
goto out;
}
-
+
/* close data space. */
if (H5Sclose(sid_1) < 0)
goto out;
-
+
} /*has_fill*/
-
+
/* release the datatype. */
if (H5Tclose( tid_1 ) < 0)
goto out;
-
+
/* end access to the dataset */
if (H5Dclose( did_1 ) < 0)
goto out;
-
+
/* Release resources. */
free ( tmp_fill_buf );
-
+
return 0;
-
-/* error zone */
+
+ /* error zone */
out:
H5E_BEGIN_TRY
{
@@ -2961,74 +2961,74 @@ out:
H5Sclose(sid_2);
H5Tclose(tid_2);
H5Pclose(pid_2);
-
+
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- *
- * Table attribute functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Table attribute functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TBAget_title
- *
- * Purpose: Read the table title
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: January 30, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBAget_title
+*
+* Purpose: Read the table title
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: January 30, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBAget_title( hid_t loc_id,
- char *table_title )
+ char *table_title )
{
-
+
/* Get the TITLE attribute */
if(H5LT_get_attribute_disk( loc_id, "TITLE", table_title ) < 0)
return -1;
-
-
+
+
return 0;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBAget_fill
- *
- * Purpose: Read the table attribute fill values
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: January 30, 2002
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBAget_fill
+*
+* Purpose: Read the table attribute fill values
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: January 30, 2002
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBAget_fill( hid_t loc_id,
- const char *dset_name,
- hid_t dset_id,
- unsigned char *dst_buf )
+ const char *dset_name,
+ hid_t dset_id,
+ unsigned char *dst_buf )
{
-
+
hsize_t nfields;
hsize_t nrecords;
char attr_name[255];
@@ -3036,20 +3036,20 @@ herr_t H5TBAget_fill( hid_t loc_id,
hsize_t i;
size_t *src_offset;
int has_fill=0;
-
+
/* get the number of records and fields */
if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0)
return -1;
-
+
src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t));
-
+
if (src_offset == NULL )
return -1;
-
+
/* get field info */
if (H5TBget_field_info( loc_id, dset_name, NULL, NULL, src_offset, NULL ) < 0)
goto out;
-
+
for ( i = 0; i < nfields; i++)
{
strcpy( attr_name, "FIELD_" );
@@ -3057,125 +3057,125 @@ herr_t H5TBAget_fill( hid_t loc_id,
strcat( attr_name, aux );
sprintf( aux, "%s", "_FILL" );
strcat( attr_name, aux );
-
+
/* check if we have the _FILL attribute */
has_fill = H5LT_find_attribute( dset_id, attr_name );
-
+
/* get it */
if (has_fill == 1 )
{
if(H5LT_get_attribute_disk( dset_id, attr_name, dst_buf+src_offset[i] ) < 0)
goto out;
}
-
+
}
-
+
free( src_offset );
-
+
return has_fill;
-
+
out:
free( src_offset );
return -1;
-
+
}
/*-------------------------------------------------------------------------
- *
- * Inquiry functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* Inquiry functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TBget_table_info
- *
- * Purpose: Gets the number of records and fields of a table
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 19, 2001
- *
- * Comments:
- *
- * Modifications:
- * May 08, 2003
- * In version 2.0 of Table, the number of records is stored as an
- * attribute "NROWS"
- * November 24, 2008
- * In version 3.0 of Table, "NROWS" was deprecated
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBget_table_info
+*
+* Purpose: Gets the number of records and fields of a table
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 19, 2001
+*
+* Comments:
+*
+* Modifications:
+* May 08, 2003
+* In version 2.0 of Table, the number of records is stored as an
+* attribute "NROWS"
+* November 24, 2008
+* In version 3.0 of Table, "NROWS" was deprecated
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBget_table_info ( hid_t loc_id,
- const char *dset_name,
- hsize_t *nfields,
- hsize_t *nrecords )
+ const char *dset_name,
+ hsize_t *nfields,
+ hsize_t *nrecords )
{
hid_t tid=-1;
hid_t sid=-1;
hid_t did=-1;
int num_members;
hsize_t dims[1];
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
-
+
/* get the datatype */
if ((tid = H5Dget_type( did )) < 0)
goto out;
-
+
/* get the number of members */
if ((num_members = H5Tget_nmembers( tid )) < 0)
goto out;
-
+
/*-------------------------------------------------------------------------
* get number of nfields
*-------------------------------------------------------------------------
*/
-
+
if (nfields)
{
*nfields = num_members;
}
-
-
+
+
/*-------------------------------------------------------------------------
* get number of records
*-------------------------------------------------------------------------
*/
-
+
if (nrecords)
{
/* get the dataspace handle */
if ((sid = H5Dget_space( did )) < 0)
goto out;
-
+
/* get dimension */
if (H5Sget_simple_extent_dims( sid, dims, NULL) < 0)
goto out;
-
+
/* terminate access to the dataspace */
if (H5Sclose( sid ) < 0)
goto out;
-
+
*nrecords = dims[0];
}
-
+
/* close */
if (H5Tclose( tid ) < 0)
goto out;
if (H5Dclose( did ) < 0)
return -1;
-
+
return 0;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -3185,33 +3185,33 @@ out:
H5Tclose(tid);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TBget_field_info
- *
- * Purpose: Get information about fields
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 19, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TBget_field_info
+*
+* Purpose: Get information about fields
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 19, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TBget_field_info( hid_t loc_id,
- const char *dset_name,
- char *field_names[],
- size_t *field_sizes,
- size_t *field_offsets,
- size_t *type_size )
+ const char *dset_name,
+ char *field_names[],
+ size_t *field_sizes,
+ size_t *field_offsets,
+ size_t *type_size )
{
hid_t did; /* dataset ID */
hid_t tid; /* file type ID */
@@ -3224,73 +3224,73 @@ herr_t H5TBget_field_info( hid_t loc_id,
size_t member_offset;
size_t size;
hssize_t i;
-
+
/* open the dataset. */
if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
-
+
/* get the datatype */
if (( tid = H5Dget_type( did )) < 0)
goto out;
-
+
if ((n_tid = H5Tget_native_type(tid,H5T_DIR_DEFAULT)) < 0)
goto out;
-
+
/* get the type size */
size = H5Tget_size( n_tid );
-
+
if ( type_size )
{
*type_size = size;
}
-
+
/* get the number of members */
if (( nfields = H5Tget_nmembers( tid )) < 0)
goto out;
-
+
/* iterate tru the members */
for ( i = 0; i < nfields; i++)
{
/* get the member name */
member_name = H5Tget_member_name( tid, (unsigned)i );
-
+
if (field_names )
{
strcpy( field_names[i], member_name );
}
-
+
/* get the member type */
if (( m_tid = H5Tget_member_type( tid,(unsigned) i )) < 0)
goto out;
if ((nm_tid = H5Tget_native_type(m_tid,H5T_DIR_DEFAULT)) < 0)
goto out;
-
+
/* get the member size */
member_size = H5Tget_size( nm_tid );
-
+
if(field_sizes )
{
field_sizes[i] = member_size;
}
-
+
/* get the member offset */
member_offset = H5Tget_member_offset( n_tid,(unsigned) i );
-
+
if(field_offsets )
{
field_offsets[i] = member_offset;
}
-
+
/* close the member types */
if (H5Tclose( m_tid ) < 0)
goto out;
if (H5Tclose( nm_tid ) < 0)
goto out;
-
+
free( member_name );
-
+
} /* i */
-
+
/* close */
if (H5Tclose( tid ) < 0)
goto out;
@@ -3298,10 +3298,10 @@ herr_t H5TBget_field_info( hid_t loc_id,
goto out;
if (H5Dclose( did ) < 0)
return -1;
-
+
return 0;
-
- /* error zone */
+
+ /* error zone */
out:
H5E_BEGIN_TRY
{
@@ -3310,36 +3310,36 @@ out:
H5Tclose(n_tid);
} H5E_END_TRY;
return -1;
-
+
}
/*-------------------------------------------------------------------------
- *
- * internal functions
- *
- *-------------------------------------------------------------------------
- */
+*
+* internal functions
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TB_find_field
- *
- * Purpose: Find a string field
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 19, 2001
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TB_find_field
+*
+* Purpose: Find a string field
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: November 19, 2001
+*
+*-------------------------------------------------------------------------
+*/
static
int H5TB_find_field( const char *field, const char *field_list )
{
const char *start = field_list;
const char *end;
-
+
while ( (end = strstr( start, "," )) != 0 )
{
size_t count = end - start;
@@ -3347,105 +3347,105 @@ int H5TB_find_field( const char *field, const char *field_list )
return 1;
start = end + 1;
}
-
+
if(strcmp( start, field ) == 0 )
return 1;
-
+
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TB_attach_attributes
- *
- * Purpose: Private function that creates the conforming table attributes;
- * Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read
- * the fill value attributes from an existing table
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 6, 2001
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TB_attach_attributes
+*
+* Purpose: Private function that creates the conforming table attributes;
+* Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read
+* the fill value attributes from an existing table
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: December 6, 2001
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
static
herr_t H5TB_attach_attributes( const char *table_title,
- hid_t loc_id,
- const char *dset_name,
- hsize_t nfields,
- hid_t tid )
+ hid_t loc_id,
+ const char *dset_name,
+ hsize_t nfields,
+ hid_t tid )
{
-
+
char attr_name[255];
char *member_name;
char aux[255];
hsize_t i;
-
+
/* attach the CLASS attribute */
if (H5LTset_attribute_string( loc_id, dset_name, "CLASS", TABLE_CLASS ) < 0)
goto out;
-
+
/* attach the VERSION attribute */
if (H5LTset_attribute_string( loc_id, dset_name, "VERSION", TABLE_VERSION ) < 0)
goto out;
-
+
/* attach the TITLE attribute */
if (H5LTset_attribute_string( loc_id, dset_name, "TITLE", table_title ) < 0)
goto out;
-
+
/* attach the FIELD_ name attribute */
for ( i = 0; i < nfields; i++)
{
-
+
/* get the member name */
member_name = H5Tget_member_name( tid, (unsigned)i );
-
+
strcpy( attr_name, "FIELD_" );
sprintf( aux, "%d", (int)i );
strcat( attr_name, aux );
sprintf( aux, "%s", "_NAME" );
strcat( attr_name, aux );
-
+
/* attach the attribute */
if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0)
goto out;
-
+
free( member_name );
-
+
}
-
+
return 0;
-
+
out:
return -1;
-
+
}
/*-------------------------------------------------------------------------
- * Function: H5TB_create_type
- *
- * Purpose: Private function that creates a memory type ID
- *
- * Return: Success: the memory type ID, Failure: -1
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 31, 2004
- *
- * Comments:
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TB_create_type
+*
+* Purpose: Private function that creates a memory type ID
+*
+* Return: Success: the memory type ID, Failure: -1
+*
+* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+*
+* Date: March 31, 2004
+*
+* Comments:
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
static
hid_t H5TB_create_type(hid_t loc_id,
@@ -3462,31 +3462,31 @@ hid_t H5TB_create_type(hid_t loc_id,
hsize_t nfields;
char **fnames;
unsigned i;
-
+
/* get the number of fields */
if (H5TBget_table_info(loc_id,dset_name,&nfields,NULL) < 0)
return -1;
-
- if ((fnames=malloc(sizeof(char*)*(size_t)nfields))==NULL)
+
+ if ((fnames = (char**) malloc(sizeof(char*)*(size_t)nfields))==NULL)
return -1;
-
+
for ( i = 0; i < nfields; i++)
{
- if ((fnames[i]=malloc(sizeof(char)*HLTB_MAX_FIELD_LEN))==NULL)
+ if ((fnames[i] = (char*) malloc(sizeof(char)*HLTB_MAX_FIELD_LEN))==NULL)
{
free(fnames);
return -1;
}
}
-
+
/* get field info */
if (H5TBget_field_info(loc_id,dset_name,fnames,NULL,NULL,NULL) < 0)
goto out;
-
+
/* create the memory data type */
if ((mem_type_id=H5Tcreate(H5T_COMPOUND,type_size)) < 0)
goto out;
-
+
/* get each field ID and adjust its size, if necessary */
for ( i = 0; i < nfields; i++)
{
@@ -3507,15 +3507,15 @@ hid_t H5TB_create_type(hid_t loc_id,
if (H5Tclose(nmtype_id) < 0)
goto out;
}
-
+
for ( i=0; i<nfields; i++)
{
free (fnames[i]);
}
free (fnames);
-
+
return mem_type_id;
-
+
/* error zone */
out:
H5E_BEGIN_TRY
@@ -3531,40 +3531,40 @@ out:
if (fnames)
free (fnames);
return -1;
-
+
}
/*-------------------------------------------------------------------------
- *
- * Functions shared between H5TB and H5PT
- *
- *-------------------------------------------------------------------------
- */
+*
+* Functions shared between H5TB and H5PT
+*
+*-------------------------------------------------------------------------
+*/
/*-------------------------------------------------------------------------
- * Function: H5TB_common_append_records
- *
- * Purpose: Common code for reading records shared between H5PT and H5TB
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu
- * James Laird, jlaird@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments: Called by H5TBappend_records and H5PTappend_records
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TB_common_append_records
+*
+* Purpose: Common code for reading records shared between H5PT and H5TB
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu
+* James Laird, jlaird@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments: Called by H5TBappend_records and H5PTappend_records
+*
+* Modifications:
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TB_common_append_records( hid_t dataset_id,
- hid_t mem_type_id,
- size_t nrecords,
- hsize_t orig_table_size,
- const void * buf)
+ hid_t mem_type_id,
+ size_t nrecords,
+ hsize_t orig_table_size,
+ const void * buf)
{
hsize_t count[1];
hsize_t offset[1];
@@ -3572,39 +3572,39 @@ herr_t H5TB_common_append_records( hid_t dataset_id,
hid_t m_sid = H5I_BADID;
hsize_t dims[1];
hsize_t mem_dims[1];
-
+
/* extend the dataset */
dims[0] = nrecords + orig_table_size;
if (H5Dset_extent(dataset_id, dims) < 0)
goto out;
-
+
/* create a simple memory data space */
mem_dims[0] = nrecords;
if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0)
goto out;
-
+
/* get a copy of the new file data space for writing */
if ((sid = H5Dget_space(dataset_id)) < 0)
goto out;
-
+
/* define a hyperslab in the dataset */
offset[0] = orig_table_size;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* write the records */
if (H5Dwrite( dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0)
goto out;
-
+
/* close */
if (H5Sclose( m_sid ) < 0)
goto out;
if (H5Sclose( sid ) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY
{
@@ -3617,66 +3617,66 @@ out:
/*-------------------------------------------------------------------------
- * Function: H5TB_common_read_records
- *
- * Purpose: Common code for reading records shared between H5PT and H5TB
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu
- * James Laird, jlaird@ncsa.uiuc.edu
- *
- * Date: March 8, 2004
- *
- * Comments: Called by H5TBread_records and H5PTread_records
- *
- * Modifications:
- *
- *
- *-------------------------------------------------------------------------
- */
+* Function: H5TB_common_read_records
+*
+* Purpose: Common code for reading records shared between H5PT and H5TB
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu
+* James Laird, jlaird@ncsa.uiuc.edu
+*
+* Date: March 8, 2004
+*
+* Comments: Called by H5TBread_records and H5PTread_records
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
herr_t H5TB_common_read_records( hid_t dataset_id,
- hid_t mem_type_id,
- hsize_t start,
- size_t nrecords,
- hsize_t table_size,
- void *buf)
+ hid_t mem_type_id,
+ hsize_t start,
+ size_t nrecords,
+ hsize_t table_size,
+ void *buf)
{
hsize_t count[1];
hsize_t offset[1];
hid_t sid = H5I_BADID;
hid_t m_sid = H5I_BADID;
hsize_t mem_size[1];
-
+
/* make sure the read request is in bounds */
if (start + nrecords > table_size )
goto out;
-
+
/* get the dataspace handle */
if ((sid = H5Dget_space( dataset_id )) < 0)
goto out;
-
+
/* define a hyperslab in the dataset of the size of the records */
offset[0] = start;
count[0] = nrecords;
if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto out;
-
+
/* create a memory dataspace handle */
mem_size[0] = count[0];
if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0)
goto out;
if ((H5Dread( dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf)) < 0)
goto out;
-
+
/* close */
if (H5Sclose( m_sid ) < 0)
goto out;
if (H5Sclose( sid ) < 0)
goto out;
-
+
return 0;
-
+
out:
H5E_BEGIN_TRY
{
diff --git a/hl/src/Makefile.am b/hl/src/Makefile.am
index 37bff7b..3ee186e 100644
--- a/hl/src/Makefile.am
+++ b/hl/src/Makefile.am
@@ -19,6 +19,7 @@
#
include $(top_srcdir)/config/commence.am
+include $(top_srcdir)/config/lt_vers.am
# Add include directories to the C preprocessor flags
AM_CPPFLAGS=-I$(top_srcdir)/src
@@ -26,6 +27,9 @@ AM_CPPFLAGS=-I$(top_srcdir)/src
# This library is our main target.
lib_LTLIBRARIES=libhdf5_hl.la
+# Add libtool numbers to the HDF5 hl library (from config/lt_vers.am)
+libhdf5_hl_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE)
+
libhdf5_hl_la_SOURCES=H5DS.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c
# Public header files (to be installed)
diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in
index bb5fd25..d5cd6be 100644
--- a/hl/src/Makefile.in
+++ b/hl/src/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -52,7 +52,8 @@ build_triplet = @build@
host_triplet = @host@
DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/config/commence.am \
- $(top_srcdir)/config/conclude.am COPYING
+ $(top_srcdir)/config/conclude.am \
+ $(top_srcdir)/config/lt_vers.am COPYING
TESTS =
subdir = hl/src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -75,6 +76,9 @@ libhdf5_hl_la_LIBADD =
am_libhdf5_hl_la_OBJECTS = H5DS.lo H5IM.lo H5LT.lo H5LTanalyze.lo \
H5LTparse.lo H5PT.lo H5TB.lo
libhdf5_hl_la_OBJECTS = $(am_libhdf5_hl_la_OBJECTS)
+libhdf5_hl_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libhdf5_hl_la_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
@@ -343,11 +347,20 @@ TRACE = perl $(top_srcdir)/bin/trace
# *.clog are from the MPE option.
CHECK_CLEANFILES = *.chkexe *.chklog *.clog
+# Add libtool shared library version numbers to the HDF5 library
+# See libtool versioning documentation online.
+LT_VERS_INTERFACE = 6
+LT_VERS_REVISION = 29
+LT_VERS_AGE = 0
+
# Add include directories to the C preprocessor flags
AM_CPPFLAGS = -I$(top_srcdir)/src
# This library is our main target.
lib_LTLIBRARIES = libhdf5_hl.la
+
+# Add libtool numbers to the HDF5 hl library (from config/lt_vers.am)
+libhdf5_hl_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE)
libhdf5_hl_la_SOURCES = H5DS.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c
# Public header files (to be installed)
@@ -372,12 +385,12 @@ all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/lt_vers.am $(top_srcdir)/config/conclude.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
@@ -429,7 +442,7 @@ clean-libLTLIBRARIES:
rm -f "$${dir}/so_locations"; \
done
libhdf5_hl.la: $(libhdf5_hl_la_OBJECTS) $(libhdf5_hl_la_DEPENDENCIES)
- $(LINK) -rpath $(libdir) $(libhdf5_hl_la_OBJECTS) $(libhdf5_hl_la_LIBADD) $(LIBS)
+ $(libhdf5_hl_la_LINK) -rpath $(libdir) $(libhdf5_hl_la_OBJECTS) $(libhdf5_hl_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -494,7 +507,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
@@ -683,6 +696,19 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
help:
@$(top_srcdir)/bin/makehelp
+# Copyright by The HDF Group.
+# Copyright by the Board of Trustees of the University of Illinois.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the files COPYING and Copyright.html. COPYING can be found at the root
+# of the source code distribution tree; Copyright.html can be found at the
+# root level of an installed copy of the electronic HDF5 document set and
+# is linked from the top-level documents page. It can also be found at
+# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
+# access to either file, you may request a copy from help@hdfgroup.org.
+
# lib/progs/tests targets recurse into subdirectories. build-* targets
# build files in this directory.
build-lib: $(LIB)