summaryrefslogtreecommitdiffstats
path: root/hl/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2021-03-25 00:39:37 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2021-03-25 00:39:37 (GMT)
commitfeb20aac304b39e18c70f88cae2f7cf7d5c82db2 (patch)
treee15d7e751af4e3c42e77ea955d91db4cf27a71cf /hl/src
parentbdac2ecdbff2c389a222b3d93ff1eb1d23ec6b23 (diff)
downloadhdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.zip
hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.gz
hdf5-feb20aac304b39e18c70f88cae2f7cf7d5c82db2.tar.bz2
Formats the source and updates the gcc warning pragmas
Diffstat (limited to 'hl/src')
-rw-r--r--hl/src/H5DO.c147
-rw-r--r--hl/src/H5DOpublic.h13
-rw-r--r--hl/src/H5DS.c1839
-rw-r--r--hl/src/H5DSprivate.h10
-rw-r--r--hl/src/H5DSpublic.h48
-rw-r--r--hl/src/H5HLprivate2.h1
-rw-r--r--hl/src/H5IM.c1297
-rw-r--r--hl/src/H5IMprivate.h10
-rw-r--r--hl/src/H5IMpublic.h85
-rw-r--r--hl/src/H5LD.c527
-rw-r--r--hl/src/H5LDprivate.h5
-rw-r--r--hl/src/H5LDpublic.h5
-rw-r--r--hl/src/H5LT.c4479
-rw-r--r--hl/src/H5LTprivate.h23
-rw-r--r--hl/src/H5LTpublic.h349
-rw-r--r--hl/src/H5PT.c885
-rw-r--r--hl/src/H5PTprivate.h1
-rw-r--r--hl/src/H5PTpublic.h28
-rw-r--r--hl/src/H5TB.c3247
-rw-r--r--hl/src/H5TBprivate.h27
-rw-r--r--hl/src/H5TBpublic.h195
-rw-r--r--hl/src/hdf5_hl.h1
22 files changed, 6263 insertions, 6959 deletions
diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c
index 66997cb..5b617cc 100644
--- a/hl/src/H5DO.c
+++ b/hl/src/H5DO.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* High-level library internal header file */
#include "H5HLprivate2.h"
@@ -18,7 +18,7 @@
#include "H5DOpublic.h"
#ifndef H5_NO_DEPRECATED_SYMBOLS
-
+
/*-------------------------------------------------------------------------
* Function: H5DOwrite_chunk
*
@@ -33,8 +33,8 @@
*-------------------------------------------------------------------------
*/
herr_t
-H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset,
- size_t data_size, const void *buf)
+H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size,
+ const void *buf)
{
/* Call underlying H5D function */
if (H5Dwrite_chunk(dset_id, dxpl_id, filters, offset, data_size, buf) < 0)
@@ -44,7 +44,6 @@ H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *o
} /* end H5DOwrite_chunk() */
-
/*-------------------------------------------------------------------------
* Function: H5DOread_chunk
*
@@ -59,19 +58,17 @@ H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *o
*---------------------------------------------------------------------------
*/
herr_t
-H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters,
- void *buf)
+H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf)
{
/* Call underlying H5D function */
if (H5Dread_chunk(dset_id, dxpl_id, offset, filters, buf) < 0)
return FAIL;
else
return SUCCEED;
- } /* end H5DOread_chunk() */
+} /* end H5DOread_chunk() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/*-------------------------------------------------------------------------
* Function: H5DOappend()
*
@@ -103,57 +100,56 @@ H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fi
*-------------------------------------------------------------------------
*/
herr_t
-H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension,
- hid_t memtype, const void *buf)
+H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t memtype, const void *buf)
{
- hsize_t size[H5S_MAX_RANK]; /* The new size (after extension */
- hsize_t old_size = 0; /* The size of the dimension to be extended */
- int sndims; /* Number of dimensions in dataspace (signed) */
- unsigned ndims; /* Number of dimensions in dataspace */
- hid_t space_id = FAIL; /* Old file space */
- hid_t new_space_id = FAIL; /* New file space (after extension) */
- hid_t mem_space_id = FAIL; /* Memory space for data buffer */
- hssize_t snelmts; /* Number of elements in selection (signed) */
- hsize_t nelmts; /* Number of elements in selection */
- hid_t dapl = FAIL; /* Dataset access property list */
-
- hsize_t start[H5S_MAX_RANK]; /* H5Sselect_Hyperslab: starting offset */
- hsize_t count[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of blocks to select */
- hsize_t stride[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements to move when selecting */
- hsize_t block[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements in a block */
-
- hsize_t *boundary = NULL; /* Boundary set in append flush property */
- H5D_append_cb_t append_cb; /* Callback function set in append flush property */
- void *udata; /* User data set in append flush property */
- hbool_t hit = FALSE; /* Boundary is hit or not */
- hsize_t k; /* Local index variable */
- unsigned u; /* Local index variable */
- herr_t ret_value = FAIL; /* Return value */
+ hsize_t size[H5S_MAX_RANK]; /* The new size (after extension */
+ hsize_t old_size = 0; /* The size of the dimension to be extended */
+ int sndims; /* Number of dimensions in dataspace (signed) */
+ unsigned ndims; /* Number of dimensions in dataspace */
+ hid_t space_id = FAIL; /* Old file space */
+ hid_t new_space_id = FAIL; /* New file space (after extension) */
+ hid_t mem_space_id = FAIL; /* Memory space for data buffer */
+ hssize_t snelmts; /* Number of elements in selection (signed) */
+ hsize_t nelmts; /* Number of elements in selection */
+ hid_t dapl = FAIL; /* Dataset access property list */
+
+ hsize_t start[H5S_MAX_RANK]; /* H5Sselect_Hyperslab: starting offset */
+ hsize_t count[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of blocks to select */
+ hsize_t stride[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements to move when selecting */
+ hsize_t block[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements in a block */
+
+ hsize_t * boundary = NULL; /* Boundary set in append flush property */
+ H5D_append_cb_t append_cb; /* Callback function set in append flush property */
+ void * udata; /* User data set in append flush property */
+ hbool_t hit = FALSE; /* Boundary is hit or not */
+ hsize_t k; /* Local index variable */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = FAIL; /* Return value */
/* check arguments */
- if(H5I_DATASET != H5Iget_type(dset_id))
+ if (H5I_DATASET != H5Iget_type(dset_id))
goto done;
/* If the user passed in a default DXPL, sanity check it */
- if(H5P_DEFAULT != dxpl_id)
- if(TRUE != H5Pisa_class(dxpl_id, H5P_DATASET_XFER))
+ if (H5P_DEFAULT != dxpl_id)
+ if (TRUE != H5Pisa_class(dxpl_id, H5P_DATASET_XFER))
goto done;
/* Get the dataspace of the dataset */
- if(FAIL == (space_id = H5Dget_space(dset_id)))
+ if (FAIL == (space_id = H5Dget_space(dset_id)))
goto done;
/* Get the rank of this dataspace */
- if((sndims = H5Sget_simple_extent_ndims(space_id)) < 0)
+ if ((sndims = H5Sget_simple_extent_ndims(space_id)) < 0)
goto done;
ndims = (unsigned)sndims;
/* Verify correct axis */
- if(axis >= ndims)
+ if (axis >= ndims)
goto done;
/* Get the dimensions sizes of the dataspace */
- if(H5Sget_simple_extent_dims(space_id, size, NULL) < 0)
+ if (H5Sget_simple_extent_dims(space_id, size, NULL) < 0)
goto done;
/* Adjust the dimension size of the requested dimension,
@@ -161,99 +157,98 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension,
*/
old_size = size[axis];
size[axis] += extension;
- if(size[axis] < old_size)
+ if (size[axis] < old_size)
goto done;
/* Set the extent of the dataset to the new dimension */
- if(H5Dset_extent(dset_id, size) < 0)
+ if (H5Dset_extent(dset_id, size) < 0)
goto done;
/* Get the new dataspace of the dataset */
- if(FAIL == (new_space_id = H5Dget_space(dset_id)))
+ if (FAIL == (new_space_id = H5Dget_space(dset_id)))
goto done;
/* Select a hyperslab corresponding to the append operation */
- for(u = 0 ; u < ndims ; u++) {
- start[u] = 0;
+ for (u = 0; u < ndims; u++) {
+ start[u] = 0;
stride[u] = 1;
- count[u] = size[u];
- block[u] = 1;
- if(u == axis) {
+ count[u] = size[u];
+ block[u] = 1;
+ if (u == axis) {
count[u] = extension;
start[u] = old_size;
} /* end if */
- } /* end for */
- if(FAIL == H5Sselect_hyperslab(new_space_id, H5S_SELECT_SET, start, stride, count, block))
+ } /* end for */
+ if (FAIL == H5Sselect_hyperslab(new_space_id, H5S_SELECT_SET, start, stride, count, block))
goto done;
/* The # of elemnts in the new extended dataspace */
- if((snelmts = H5Sget_select_npoints(new_space_id)) < 0)
+ if ((snelmts = H5Sget_select_npoints(new_space_id)) < 0)
goto done;
nelmts = (hsize_t)snelmts;
/* create a memory space */
- if(FAIL == (mem_space_id = H5Screate_simple(1, &nelmts, NULL)))
+ if (FAIL == (mem_space_id = H5Screate_simple(1, &nelmts, NULL)))
goto done;
/* Write the data */
- if(H5Dwrite(dset_id, memtype, mem_space_id, new_space_id, dxpl_id, buf) < 0)
+ if (H5Dwrite(dset_id, memtype, mem_space_id, new_space_id, dxpl_id, buf) < 0)
goto done;
/* Obtain the dataset's access property list */
- if((dapl = H5Dget_access_plist(dset_id)) < 0)
+ if ((dapl = H5Dget_access_plist(dset_id)) < 0)
goto done;
/* Allocate the boundary array */
boundary = (hsize_t *)HDmalloc(ndims * sizeof(hsize_t));
/* Retrieve the append flush property */
- if(H5Pget_append_flush(dapl, ndims, boundary, &append_cb, &udata) < 0)
+ if (H5Pget_append_flush(dapl, ndims, boundary, &append_cb, &udata) < 0)
goto done;
/* No boundary for this axis */
- if(boundary[axis] != 0) {
+ if (boundary[axis] != 0) {
/* Determine whether a boundary is hit or not */
- for(k = start[axis]; k < size[axis]; k++)
- if(!((k + 1) % boundary[axis])) {
+ for (k = start[axis]; k < size[axis]; k++)
+ if (!((k + 1) % boundary[axis])) {
hit = TRUE;
break;
}
- if(hit) { /* Hit the boundary */
+ if (hit) { /* Hit the boundary */
/* Invoke callback if there is one */
- if(append_cb && append_cb(dset_id, size, udata) < 0)
+ if (append_cb && append_cb(dset_id, size, udata) < 0)
goto done;
- /* Do a dataset flush */
- if(H5Dflush(dset_id) < 0)
+ /* Do a dataset flush */
+ if (H5Dflush(dset_id) < 0)
goto done;
} /* end if */
- } /* end if */
+ } /* end if */
/* Indicate success */
ret_value = SUCCEED;
done:
/* Close old dataspace */
- if(space_id != FAIL && H5Sclose(space_id) < 0)
+ if (space_id != FAIL && H5Sclose(space_id) < 0)
ret_value = FAIL;
/* Close new dataspace */
- if(new_space_id != FAIL && H5Sclose(new_space_id) < 0)
+ if (new_space_id != FAIL && H5Sclose(new_space_id) < 0)
ret_value = FAIL;
/* Close memory dataspace */
- if(mem_space_id != FAIL && H5Sclose(mem_space_id) < 0)
+ if (mem_space_id != FAIL && H5Sclose(mem_space_id) < 0)
ret_value = FAIL;
/* Close the dataset access property list */
- if(dapl != FAIL && H5Pclose(dapl) < 0)
+ if (dapl != FAIL && H5Pclose(dapl) < 0)
ret_value = FAIL;
- if(boundary)
+ if (boundary)
HDfree(boundary);
return ret_value;
} /* H5DOappend() */
-
diff --git a/hl/src/H5DOpublic.h b/hl/src/H5DOpublic.h
index e09ebca..214f1e5 100644
--- a/hl/src/H5DOpublic.h
+++ b/hl/src/H5DOpublic.h
@@ -25,8 +25,8 @@ extern "C" {
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis,
- size_t extension, hid_t memtype, const void *buf);
+H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t memtype,
+ const void *buf);
/* Symbols defined for compatibility with previous versions of the HDF5 API.
*
@@ -35,10 +35,10 @@ H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis,
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Compatibility wrappers for functionality moved to H5D */
-H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters,
- const hsize_t *offset, size_t data_size, const void *buf);
-H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset,
- uint32_t *filters /*out*/, void *buf /*out*/);
+H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset,
+ size_t data_size, const void *buf);
+H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters /*out*/,
+ void *buf /*out*/);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
@@ -47,4 +47,3 @@ H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offs
#endif
#endif
-
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index 63fb461..7cb5759 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <assert.h>
#include <stdlib.h>
@@ -19,138 +19,133 @@
#include "H5IMprivate.h"
#include "H5TBprivate.h"
-
/* Local routines */
static herr_t H5DS_is_reserved(hid_t did);
-static hid_t H5DS_get_REFLIST_type(void);
+static hid_t H5DS_get_REFLIST_type(void);
/*-------------------------------------------------------------------------
-* Function: H5DSset_scale
-*
-* Purpose: The dataset DSID is converted to a Dimension Scale dataset.
-* Creates the CLASS attribute, set to the value "DIMENSION_SCALE"
-* and an empty REFERENCE_LIST attribute.
-* If DIMNAME is specified, then an attribute called NAME is created,
-* with the value DIMNAME.
-*
-* Return: Success: SUCCEED, Failure: FAIL
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: January 04, 2005
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5DSset_scale(hid_t dsid,
- const char *dimname)
+ * Function: H5DSset_scale
+ *
+ * Purpose: The dataset DSID is converted to a Dimension Scale dataset.
+ * Creates the CLASS attribute, set to the value "DIMENSION_SCALE"
+ * and an empty REFERENCE_LIST attribute.
+ * If DIMNAME is specified, then an attribute called NAME is created,
+ * with the value DIMNAME.
+ *
+ * Return: Success: SUCCEED, Failure: FAIL
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: January 04, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5DSset_scale(hid_t dsid, const char *dimname)
{
- int has_dimlist;
+ int has_dimlist;
H5I_type_t it;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* get ID type */
if ((it = H5Iget_type(dsid)) < 0)
return FAIL;
- if (H5I_DATASET!=it)
+ if (H5I_DATASET != it)
return FAIL;
/*-------------------------------------------------------------------------
- * check if the dataset is a dataset wich has references to dimension scales
- *-------------------------------------------------------------------------
- */
+ * check if the dataset is a dataset wich has references to dimension scales
+ *-------------------------------------------------------------------------
+ */
/* try to find the attribute "DIMENSION_LIST" */
- if ((has_dimlist = H5LT_find_attribute(dsid,DIMENSION_LIST)) < 0)
+ if ((has_dimlist = H5LT_find_attribute(dsid, DIMENSION_LIST)) < 0)
return FAIL;
if (has_dimlist == 1)
return FAIL;
/*-------------------------------------------------------------------------
- * write the standard attributes for a Dimension Scale dataset
- *-------------------------------------------------------------------------
- */
+ * write the standard attributes for a Dimension Scale dataset
+ *-------------------------------------------------------------------------
+ */
- if (H5LT_set_attribute_string(dsid,"CLASS",DIMENSION_SCALE_CLASS) < 0)
+ if (H5LT_set_attribute_string(dsid, "CLASS", DIMENSION_SCALE_CLASS) < 0)
return FAIL;
- if (dimname!=NULL)
- {
- if (H5LT_set_attribute_string(dsid,"NAME",dimname) < 0)
+ if (dimname != NULL) {
+ if (H5LT_set_attribute_string(dsid, "NAME", dimname) < 0)
return FAIL;
}
return SUCCEED;
}
-
-
/*-------------------------------------------------------------------------
-* Function: H5DSattach_scale
-*
-* Purpose: Define Dimension Scale DSID to be associated with dimension IDX
-* of Dataset DID. Entries are created in the DIMENSION_LIST and
-* REFERENCE_LIST attributes.
-*
-* Return:
-* Success: SUCCEED
-* Failure: FAIL
-*
-* Fails if: Bad arguments
-* If DSID is not a Dimension Scale
-* If DID is a Dimension Scale (A Dimension Scale cannot have scales)
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: December 20, 2004
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5DSattach_scale(hid_t did,
- hid_t dsid,
- unsigned int idx)
+ * Function: H5DSattach_scale
+ *
+ * Purpose: Define Dimension Scale DSID to be associated with dimension IDX
+ * of Dataset DID. Entries are created in the DIMENSION_LIST and
+ * REFERENCE_LIST attributes.
+ *
+ * Return:
+ * Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Fails if: Bad arguments
+ * If DSID is not a Dimension Scale
+ * If DID is a Dimension Scale (A Dimension Scale cannot have scales)
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: December 20, 2004
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
- int is_ds;
- hssize_t nelmts;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t ntid = -1; /* attribute native type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
- ds_list_t dsl; /* attribute data in the DS pointing to the dataset */
- ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
- hobj_ref_t ref_to_ds; /* reference to the DS */
- hobj_ref_t ref_j; /* iterator reference */
- hvl_t *buf = NULL; /* VL buffer to store in the attribute */
- hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
+ int has_dimlist;
+ int has_reflist;
+ int is_ds;
+ hssize_t nelmts;
+ hid_t sid; /* space ID */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t ntid = -1; /* attribute native type ID */
+ hid_t aid = -1; /* attribute ID */
+ int rank; /* rank of dataset */
+ hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
+ ds_list_t dsl; /* attribute data in the DS pointing to the dataset */
+ ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ hobj_ref_t ref_to_ds; /* reference to the DS */
+ hobj_ref_t ref_j; /* iterator reference */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
H5O_info2_t oi1, oi2;
- H5I_type_t it1, it2;
- int i;
- size_t len;
- int found_ds=0;
- htri_t is_scale;
+ H5I_type_t it1, it2;
+ int i;
+ size_t len;
+ int found_ds = 0;
+ htri_t is_scale;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
if ((is_scale = H5DSis_scale(did)) < 0)
return FAIL;
@@ -160,20 +155,20 @@ herr_t H5DSattach_scale(hid_t did,
return FAIL;
/* get info for the dataset in the parameter list */
- if(H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0)
return FAIL;
/* get info for the scale in the parameter list */
- if(H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0)
return FAIL;
/* same object, not valid */
- if(oi1.fileno == oi2.fileno) {
+ if (oi1.fileno == oi2.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
return FAIL;
- if(!token_cmp)
+ if (!token_cmp)
return FAIL;
} /* end if */
@@ -187,21 +182,20 @@ herr_t H5DSattach_scale(hid_t did,
return FAIL;
/* the DS dataset cannot have dimension scales */
- if (H5LT_find_attribute(dsid,DIMENSION_LIST)==1)
+ if (H5LT_find_attribute(dsid, DIMENSION_LIST) == 1)
return FAIL;
/* check if the dataset is a "reserved" dataset (image, table) */
- if (H5DS_is_reserved(did)==1)
+ if (H5DS_is_reserved(did) == 1)
return FAIL;
-
/*-------------------------------------------------------------------------
- * The dataset may or may not have the associated DS attribute
- * 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 DS
- *-------------------------------------------------------------------------
- */
+ * The dataset may or may not have the associated DS attribute
+ * 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 DS
+ *-------------------------------------------------------------------------
+ */
/* get dataset space */
if ((sid = H5Dget_space(did)) < 0)
@@ -220,14 +214,14 @@ herr_t H5DSattach_scale(hid_t did,
return FAIL;
/* parameter range checking */
- if (idx > (unsigned)rank-1)
+ if (idx > (unsigned)rank - 1)
return FAIL;
/*-------------------------------------------------------------------------
- * two references are created: one to the DS, saved in "DIMENSION_LIST"
- * and one to the dataset, saved in "REFERENCE_LIST"
- *-------------------------------------------------------------------------
- */
+ * two references are created: one to the DS, saved in "DIMENSION_LIST"
+ * and one to the dataset, saved in "REFERENCE_LIST"
+ *-------------------------------------------------------------------------
+ */
/* create a reference for the >>DS<< dataset */
if (H5Rcreate(&ref_to_ds, dsid, ".", H5R_OBJECT, (hid_t)-1) < 0)
return FAIL;
@@ -237,57 +231,56 @@ herr_t H5DSattach_scale(hid_t did,
return FAIL;
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if ((has_dimlist = H5LT_find_attribute(did,DIMENSION_LIST)) < 0)
+ if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
/*-------------------------------------------------------------------------
- * it does not exist. we create the attribute and its reference data
- *-------------------------------------------------------------------------
- */
- if (has_dimlist == 0)
- {
+ * it does not exist. we create the attribute and its reference data
+ *-------------------------------------------------------------------------
+ */
+ if (has_dimlist == 0) {
dims[0] = (hsize_t)rank;
/* space for the attribute */
- if((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
return FAIL;
/* create the type for the attribute "DIMENSION_LIST" */
- if((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0)
+ if ((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0)
goto out;
/* create the attribute */
- if((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* allocate and initialize the VL */
buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t));
- if(buf == NULL)
+ if (buf == NULL)
goto out;
- for(i = 0; i < rank; i++) {
+ for (i = 0; i < rank; i++) {
buf[i].len = 0;
- buf[i].p = NULL;
+ buf[i].p = NULL;
}
/* store the REF information in the index of the dataset that has the DS */
- buf[idx].len = 1;
- buf[idx].p = HDmalloc( 1 * sizeof(hobj_ref_t));
+ buf[idx].len = 1;
+ buf[idx].p = HDmalloc(1 * sizeof(hobj_ref_t));
((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds;
/* write the attribute with the reference */
- if(H5Awrite(aid, tid, buf) < 0)
+ if (H5Awrite(aid, tid, buf) < 0)
goto out;
/* close */
- if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
HDfree(buf);
@@ -295,218 +288,217 @@ herr_t H5DSattach_scale(hid_t did,
}
/*-------------------------------------------------------------------------
- * the attribute already exists, open it, extend the buffer,
- * and insert the new reference
- *-------------------------------------------------------------------------
- */
- else if(has_dimlist == 1)
- {
- if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
+ * the attribute already exists, open it, extend the buffer,
+ * and insert the new reference
+ *-------------------------------------------------------------------------
+ */
+ else if (has_dimlist == 1) {
+ if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
/* allocate and initialize the VL */
buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t));
- if(buf == NULL)
+ if (buf == NULL)
goto out;
/* read */
- if(H5Aread(aid, tid, buf) < 0)
+ if (H5Aread(aid, tid, buf) < 0)
goto out;
/* check to avoid inserting duplicates. it is not FAIL, just do nothing */
/* iterate all the REFs in this dimension IDX */
- for(i = 0; i < (int)buf[idx].len; i++) {
+ for (i = 0; i < (int)buf[idx].len; i++) {
/* get the reference */
ref_j = ((hobj_ref_t *)buf[idx].p)[i];
/* get the scale id for this REF */
- if((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0)
+ if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0)
goto out;
/* get info for DS in the parameter list */
- if(H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0)
goto out;
/* get info for this DS */
- if(H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0)
goto out;
/* same object, so this DS scale is already in this DIM IDX */
- if(oi1.fileno == oi2.fileno) {
+ if (oi1.fileno == oi2.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
goto out;
- if(!token_cmp)
+ if (!token_cmp)
found_ds = 1;
} /* end if */
/* close the dereferenced dataset */
- if(H5Dclose(dsid_j) < 0)
+ if (H5Dclose(dsid_j) < 0)
goto out;
} /* end for */
- if(found_ds == 0) {
+ if (found_ds == 0) {
/* we are adding one more DS to this dimension */
- if(buf[idx].len > 0) {
+ if (buf[idx].len > 0) {
buf[idx].len++;
- len = buf[idx].len;
- buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t));
+ len = buf[idx].len;
+ buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t));
((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds;
} /* end if */
else {
/* store the REF information in the index of the dataset that has the DS */
- buf[idx].len = 1;
- buf[idx].p = HDmalloc(sizeof(hobj_ref_t));
+ buf[idx].len = 1;
+ buf[idx].p = HDmalloc(sizeof(hobj_ref_t));
((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds;
} /* end else */
- } /* end if */
+ } /* end if */
/* write the attribute with the new references */
- if(H5Awrite(aid, tid, buf) < 0)
+ if (H5Awrite(aid, tid, buf) < 0)
goto out;
/* close */
- if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
HDfree(buf);
buf = NULL;
} /* has_dimlist */
/*-------------------------------------------------------------------------
- * save DS info on the >>DS<< dataset
- *-------------------------------------------------------------------------
- */
+ * save DS info on the >>DS<< dataset
+ *-------------------------------------------------------------------------
+ */
/* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */
- if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
+ if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * it does not exist. we create the attribute and its reference data
- *-------------------------------------------------------------------------
- */
- if(has_reflist == 0) {
+ * it does not exist. we create the attribute and its reference data
+ *-------------------------------------------------------------------------
+ */
+ if (has_reflist == 0) {
dims[0] = 1;
/* space for the attribute */
- if((sid = H5Screate_simple(1,dims,NULL)) < 0)
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
goto out;
/* create the compound datatype for the attribute "REFERENCE_LIST" */
- if((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0)
+ if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0)
goto out;
/* insert reference field */
- if(H5Tinsert(tid, "dataset", HOFFSET(ds_list_t,ref), H5T_STD_REF_OBJ) < 0)
+ if (H5Tinsert(tid, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0)
goto out;
/* insert dimension idx of the dataset field */
- if(H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0)
goto out;
/* create the attribute */
- if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* store the IDX information */
dsl.dim_idx = idx;
/* write the attribute with the reference */
- if(H5Awrite(aid, tid, &dsl) < 0)
+ if (H5Awrite(aid, tid, &dsl) < 0)
goto out;
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
} /* end if */
/*-------------------------------------------------------------------------
- * the "REFERENCE_LIST" array already exists, open it and extend it
- *-------------------------------------------------------------------------
- */
- else if(has_reflist == 1) {
- if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
+ * the "REFERENCE_LIST" array already exists, open it and extend it
+ *-------------------------------------------------------------------------
+ */
+ else if (has_reflist == 1) {
+ if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
/* get native type to read attribute REFERENCE_LIST */
- if((ntid = H5DS_get_REFLIST_type()) < 0)
+ if ((ntid = H5DS_get_REFLIST_type()) < 0)
goto out;
/* get and save the old reference(s) */
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
- if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
+ if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
nelmts++;
- dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t));
- if(dsbuf == NULL)
+ dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ if (dsbuf == NULL)
goto out;
- if(H5Aread(aid, ntid, dsbuf) < 0)
+ if (H5Aread(aid, ntid, dsbuf) < 0)
goto out;
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create a new attribute
- *-------------------------------------------------------------------------
- */
+ * create a new attribute
+ *-------------------------------------------------------------------------
+ */
/* the attribute must be deleted, in order to the new one can reflect the changes*/
- if(H5Adelete(dsid, REFERENCE_LIST) < 0)
+ if (H5Adelete(dsid, REFERENCE_LIST) < 0)
goto out;
/* store the IDX information (index of the dataset that has the DS) */
- dsl.dim_idx = idx;
+ dsl.dim_idx = idx;
dsbuf[nelmts - 1] = dsl;
/* create a new data space for the new references array */
dims[0] = (hsize_t)nelmts;
- if((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
goto out;
/* create the attribute again with the changes of space */
- if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* write the attribute with the new references */
- if(H5Awrite(aid, ntid, dsbuf) < 0)
+ if (H5Awrite(aid, ntid, dsbuf) < 0)
goto out;
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
if (H5Tclose(ntid) < 0)
goto out;
@@ -516,15 +508,15 @@ herr_t H5DSattach_scale(hid_t did,
} /* has_reflist */
/*-------------------------------------------------------------------------
- * write the standard attributes for a Dimension Scale dataset
- *-------------------------------------------------------------------------
- */
+ * write the standard attributes for a Dimension Scale dataset
+ *-------------------------------------------------------------------------
+ */
- if((is_ds = H5DSis_scale(dsid)) < 0)
+ if ((is_ds = H5DSis_scale(dsid)) < 0)
return FAIL;
- if(is_ds == 0) {
- if (H5LT_set_attribute_string(dsid,"CLASS",DIMENSION_SCALE_CLASS) < 0)
+ if (is_ds == 0) {
+ if (H5LT_set_attribute_string(dsid, "CLASS", DIMENSION_SCALE_CLASS) < 0)
return FAIL;
}
@@ -532,117 +524,117 @@ herr_t H5DSattach_scale(hid_t did,
/* error zone */
out:
- if(buf)
+ if (buf)
HDfree(buf);
- if(dsbuf)
+ if (dsbuf)
HDfree(dsbuf);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Aclose(aid);
H5Tclose(ntid);
H5Tclose(tid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
/*-------------------------------------------------------------------------
-* Function: H5DSdetach_scale
-*
-* Purpose: If possible, deletes association of Dimension Scale DSID with
-* dimension IDX of Dataset DID. This deletes the entries in the
-* DIMENSION_LIST and REFERENCE_LIST attributes.
-*
-* Return:
-* Success: SUCCEED
-* Failure: FAIL
-*
-* Fails if: Bad arguments
-* The dataset DID or DSID do not exist.
-* The DSID is not a Dimension Scale
-* DSID is not attached to DID.
-* Note that a scale may be associated with more than dimension of the same dataset.
-* If so, the detach operation only deletes one of the associations, for DID.
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: December 20, 2004
-*
-* Comments:
-*
-* Modifications: Function didn't delete DIMENSION_LIST attribute, when
-* all dimension scales were detached from a dataset; added.
-* 2010/05/13 EIP
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5DSdetach_scale(hid_t did,
- hid_t dsid,
- unsigned int idx)
+ * Function: H5DSdetach_scale
+ *
+ * Purpose: If possible, deletes association of Dimension Scale DSID with
+ * dimension IDX of Dataset DID. This deletes the entries in the
+ * DIMENSION_LIST and REFERENCE_LIST attributes.
+ *
+ * Return:
+ * Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Fails if: Bad arguments
+ * The dataset DID or DSID do not exist.
+ * The DSID is not a Dimension Scale
+ * DSID is not attached to DID.
+ * Note that a scale may be associated with more than dimension of the same dataset.
+ * If so, the detach operation only deletes one of the associations, for DID.
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: December 20, 2004
+ *
+ * Comments:
+ *
+ * Modifications: Function didn't delete DIMENSION_LIST attribute, when
+ * all dimension scales were detached from a dataset; added.
+ * 2010/05/13 EIP
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
- hssize_t nelmts;
- hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
- hid_t did_i; /* dataset ID in REFERENCE_LIST */
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t ntid = -1; /* attribute native type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
- hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
- hobj_ref_t ref; /* reference to the DS */
- hvl_t *buf = NULL; /* VL buffer to store in the attribute */
- int i;
- size_t j;
- hssize_t ii;
+ int has_dimlist;
+ int has_reflist;
+ hssize_t nelmts;
+ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
+ hid_t did_i; /* dataset ID in REFERENCE_LIST */
+ hid_t sid; /* space ID */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t ntid = -1; /* attribute native type ID */
+ hid_t aid = -1; /* attribute ID */
+ int rank; /* rank of dataset */
+ ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
+ hobj_ref_t ref; /* reference to the DS */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ int i;
+ size_t j;
+ hssize_t ii;
H5O_info2_t did_oi, dsid_oi, tmp_oi;
- int found_dset = 0, found_ds = 0;
- int have_ds = 0;
- htri_t is_scale;
+ int found_dset = 0, found_ds = 0;
+ int have_ds = 0;
+ htri_t is_scale;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* check for valid types of identifiers */
- if(H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid))
+ if (H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid))
return FAIL;
- if((is_scale = H5DSis_scale(did)) < 0)
+ if ((is_scale = H5DSis_scale(did)) < 0)
return FAIL;
/* the dataset cannot be a DS dataset */
- if( is_scale == 1)
+ if (is_scale == 1)
return FAIL;
/* get info for the dataset in the parameter list */
- if(H5Oget_info3(did, &did_oi, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(did, &did_oi, H5O_INFO_BASIC) < 0)
return FAIL;
/* get info for the scale in the parameter list */
- if(H5Oget_info3(dsid, &dsid_oi, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid, &dsid_oi, H5O_INFO_BASIC) < 0)
return FAIL;
/* same object, not valid */
- if(did_oi.fileno == dsid_oi.fileno) {
+ if (did_oi.fileno == dsid_oi.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &did_oi.token, &dsid_oi.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &did_oi.token, &dsid_oi.token, &token_cmp) < 0)
return FAIL;
- if(!token_cmp)
+ if (!token_cmp)
return FAIL;
} /* end if */
-
/*-------------------------------------------------------------------------
- * Find "DIMENSION_LIST"
- *-------------------------------------------------------------------------
- */
+ * Find "DIMENSION_LIST"
+ *-------------------------------------------------------------------------
+ */
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
@@ -663,58 +655,56 @@ herr_t H5DSdetach_scale(hid_t did,
return FAIL;
/* parameter range checking */
- if (idx > (unsigned)rank-1)
+ if (idx > (unsigned)rank - 1)
return FAIL;
/*-------------------------------------------------------------------------
- * find "REFERENCE_LIST"
- *-------------------------------------------------------------------------
- */
+ * find "REFERENCE_LIST"
+ *-------------------------------------------------------------------------
+ */
/* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */
- if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
+ if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
return FAIL;
- if(has_reflist == 0)
+ if (has_reflist == 0)
return FAIL;
/*-------------------------------------------------------------------------
- * open "DIMENSION_LIST", and delete the reference
- *-------------------------------------------------------------------------
- */
+ * open "DIMENSION_LIST", and delete the reference
+ *-------------------------------------------------------------------------
+ */
- if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
return FAIL;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
/* allocate and initialize the VL */
buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t));
- if(buf == NULL)
+ if (buf == NULL)
goto out;
/* read */
- if(H5Aread(aid, tid, buf) < 0)
+ if (H5Aread(aid, tid, buf) < 0)
goto out;
/* reset */
- if ( buf[idx].len > 0 )
- {
- for (j=0; j<buf[idx].len; j++)
- {
+ if (buf[idx].len > 0) {
+ for (j = 0; j < buf[idx].len; j++) {
/* get the reference */
ref = ((hobj_ref_t *)buf[idx].p)[j];
/* get the DS id */
- if ((dsid_j = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0)
+ if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
goto out;
/* get info for this DS */
- if(H5Oget_info3(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0)
goto out;
/* Close the dereferenced dataset */
@@ -722,12 +712,12 @@ herr_t H5DSdetach_scale(hid_t did,
goto out;
/* same object, reset */
- if(dsid_oi.fileno == tmp_oi.fileno) {
+ if (dsid_oi.fileno == tmp_oi.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &dsid_oi.token, &tmp_oi.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &dsid_oi.token, &tmp_oi.token, &token_cmp) < 0)
goto out;
- if(!token_cmp) {
+ if (!token_cmp) {
/* If there are more than one reference in the VL element
and the reference we found is not the last one,
copy the last one to replace the found one since the order
@@ -738,10 +728,10 @@ herr_t H5DSdetach_scale(hid_t did,
size_t len = buf[idx].len;
- if(j < len - 1)
- ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len-1];
+ if (j < len - 1)
+ ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len - 1];
len = --buf[idx].len;
- if(len == 0) {
+ if (len == 0) {
HDfree(buf[idx].p);
buf[idx].p = NULL;
}
@@ -750,108 +740,107 @@ herr_t H5DSdetach_scale(hid_t did,
found_ds = 1;
break;
} /* end if */
- } /* end if */
- } /* j */
- } /* if */
+ } /* end if */
+ } /* j */
+ } /* if */
/* the scale must be present to continue */
- if(found_ds == 0)
+ if (found_ds == 0)
goto out;
/* Write the attribute, but check first, if we have any scales left,
because if not, we should delete the attribute according to the spec */
- for(i = 0; i < rank; i++) {
- if(buf[i].len > 0) {
+ for (i = 0; i < rank; i++) {
+ if (buf[i].len > 0) {
have_ds = 1;
break;
}
}
- if(have_ds) {
- if(H5Awrite(aid, tid, buf) < 0)
+ if (have_ds) {
+ if (H5Awrite(aid, tid, buf) < 0)
goto out;
}
else {
- if(H5Adelete(did, DIMENSION_LIST) < 0)
+ if (H5Adelete(did, DIMENSION_LIST) < 0)
goto out;
}
/* close */
- if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
HDfree(buf);
buf = NULL;
-
/*-------------------------------------------------------------------------
- * the "REFERENCE_LIST" array exists, update
- *-------------------------------------------------------------------------
- */
+ * the "REFERENCE_LIST" array exists, update
+ *-------------------------------------------------------------------------
+ */
- if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
/* get native type to read attribute REFERENCE_LIST */
- if((ntid = H5DS_get_REFLIST_type()) < 0)
+ if ((ntid = H5DS_get_REFLIST_type()) < 0)
goto out;
/* get and save the old reference(s) */
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
- if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
+ if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
- dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t));
- if(dsbuf == NULL)
+ dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ if (dsbuf == NULL)
goto out;
- if(H5Aread(aid, ntid, dsbuf) < 0)
+ if (H5Aread(aid, ntid, dsbuf) < 0)
goto out;
- for(ii = 0; ii < nelmts; ii++) {
+ for (ii = 0; ii < nelmts; ii++) {
/* First check if we have the same dimension index */
- if(idx == dsbuf[ii].dim_idx) {
+ if (idx == dsbuf[ii].dim_idx) {
/* get the reference to the dataset */
ref = dsbuf[ii].ref;
/* get the dataset id */
- if ((did_i = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0)
+ if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
goto out;
/* get info for this dataset */
- if(H5Oget_info3(did_i, &tmp_oi, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(did_i, &tmp_oi, H5O_INFO_BASIC) < 0)
goto out;
/* close the dereferenced dataset */
- if(H5Dclose(did_i) < 0)
+ if (H5Dclose(did_i) < 0)
goto out;
/* same object, reset. we want to detach only for this DIM */
- if(did_oi.fileno == tmp_oi.fileno) {
+ if (did_oi.fileno == tmp_oi.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &did_oi.token, &tmp_oi.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &did_oi.token, &tmp_oi.token, &token_cmp) < 0)
goto out;
- if(!token_cmp) {
+ if (!token_cmp) {
/* copy the last one to replace the one which is found */
- dsbuf[ii] = dsbuf[nelmts-1];
+ dsbuf[ii] = dsbuf[nelmts - 1];
nelmts--;
- found_dset=1;
+ found_dset = 1;
break;
} /* end if */
- } /* end if */
- } /* if we have the same dimension index */
- } /* ii */
+ } /* end if */
+ } /* if we have the same dimension index */
+ } /* ii */
/* close space and attribute */
if (H5Sclose(sid) < 0)
@@ -860,44 +849,43 @@ herr_t H5DSdetach_scale(hid_t did,
goto out;
/*-------------------------------------------------------------------------
- * check if we found the pointed dataset
- *-------------------------------------------------------------------------
- */
+ * check if we found the pointed dataset
+ *-------------------------------------------------------------------------
+ */
/* the pointed dataset must exist */
if (found_dset == 0)
goto out;
/*-------------------------------------------------------------------------
- * create a new attribute
- *-------------------------------------------------------------------------
- */
+ * create a new attribute
+ *-------------------------------------------------------------------------
+ */
/* the attribute must be deleted, in order to the new one can reflect the changes*/
if (H5Adelete(dsid, REFERENCE_LIST) < 0)
goto out;
/* don't do anything for an empty array */
- if(nelmts)
- {
+ if (nelmts) {
/* create a new data space for the new references array */
- dims[0] = (hsize_t)nelmts;
+ dims[0] = (hsize_t)nelmts;
- if((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
goto out;
/* create the attribute again with the changes of space */
- if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* write the new attribute with the new references */
- if(H5Awrite(aid, ntid, dsbuf) < 0)
+ if (H5Awrite(aid, ntid, dsbuf) < 0)
goto out;
/* close space and attribute */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
} /* nelmts */
@@ -914,108 +902,108 @@ herr_t H5DSdetach_scale(hid_t did,
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Aclose(aid);
H5Tclose(ntid);
H5Tclose(tid);
- if(dsbuf) {
+ if (dsbuf) {
HDfree(dsbuf);
dsbuf = NULL;
}
- if(buf) {
+ if (buf) {
/* Failure occured before H5Treclaim was called;
free the pointers allocated when we read data in */
- for(i = 0; i < rank; i++) {
- if(buf[i].p)
+ for (i = 0; i < rank; i++) {
+ if (buf[i].p)
HDfree(buf[i].p);
}
HDfree(buf);
buf = NULL;
}
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
-
}
/*-------------------------------------------------------------------------
-* Function: H5DSis_attached
-*
-* Purpose: Report if dimension scale DSID is currently attached to
-* dimension IDX of dataset DID by checking if DID has a pointer in the REFERENCE_LIST
-* attribute and DSID (scale ) has a pointer in the DIMENSION_LIST attribute
-*
-* Return:
-* 1: both the DS and the dataset pointers match
-* 0: one of them or both do not match
-* FAIL (-1): error
-*
-* Fails if: Bad arguments
-* If DSID is not a Dimension Scale
-* If DID is a Dimension Scale (A Dimension Scale cannot have scales)
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: February 18, 2005
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-htri_t H5DSis_attached(hid_t did,
- hid_t dsid,
- unsigned int idx)
+ * Function: H5DSis_attached
+ *
+ * Purpose: Report if dimension scale DSID is currently attached to
+ * dimension IDX of dataset DID by checking if DID has a pointer in the REFERENCE_LIST
+ * attribute and DSID (scale ) has a pointer in the DIMENSION_LIST attribute
+ *
+ * Return:
+ * 1: both the DS and the dataset pointers match
+ * 0: one of them or both do not match
+ * FAIL (-1): error
+ *
+ * Fails if: Bad arguments
+ * If DSID is not a Dimension Scale
+ * If DID is a Dimension Scale (A Dimension Scale cannot have scales)
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: February 18, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+htri_t
+H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
- hssize_t nelmts;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t ntid = -1; /* attribute native type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
- hobj_ref_t ref; /* reference to the DS */
- hvl_t *buf = NULL; /* VL buffer to store in the attribute */
- hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
- hid_t did_i; /* dataset ID in REFERENCE_LIST */
+ int has_dimlist;
+ int has_reflist;
+ hssize_t nelmts;
+ hid_t sid; /* space ID */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t ntid = -1; /* attribute native type ID */
+ hid_t aid = -1; /* attribute ID */
+ int rank; /* rank of dataset */
+ ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ hobj_ref_t ref; /* reference to the DS */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
+ hid_t did_i; /* dataset ID in REFERENCE_LIST */
H5O_info2_t oi1, oi2, oi3, oi4;
- H5I_type_t it1, it2;
- int i;
- int found_dset=0, found_ds=0;
- htri_t is_scale;
+ H5I_type_t it1, it2;
+ int i;
+ int found_dset = 0, found_ds = 0;
+ htri_t is_scale;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
if ((is_scale = H5DSis_scale(did)) < 0)
return FAIL;
/* the dataset cannot be a DS dataset */
- if ( is_scale == 1)
+ if (is_scale == 1)
return FAIL;
/* get info for the dataset in the parameter list */
- if(H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0)
return FAIL;
/* get info for the scale in the parameter list */
- if(H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0)
return FAIL;
/* same object, not valid */
- if(oi1.fileno == oi2.fileno) {
+ if (oi1.fileno == oi2.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
return FAIL;
- if(!token_cmp)
+ if (!token_cmp)
return FAIL;
} /* end if */
@@ -1029,16 +1017,16 @@ htri_t H5DSis_attached(hid_t did,
return FAIL;
/*-------------------------------------------------------------------------
- * get space
- *-------------------------------------------------------------------------
- */
+ * get space
+ *-------------------------------------------------------------------------
+ */
/* get dataset space */
if ((sid = H5Dget_space(did)) < 0)
return FAIL;
/* get rank */
- if ((rank=H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* close dataset space */
@@ -1046,32 +1034,31 @@ htri_t H5DSis_attached(hid_t did,
goto out;
/* parameter range checking */
- if(idx > ((unsigned)rank - 1))
+ if (idx > ((unsigned)rank - 1))
return FAIL;
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
+ if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
/*-------------------------------------------------------------------------
- * open "DIMENSION_LIST"
- *-------------------------------------------------------------------------
- */
+ * open "DIMENSION_LIST"
+ *-------------------------------------------------------------------------
+ */
- if(has_dimlist == 1)
- {
- if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
+ if (has_dimlist == 1) {
+ if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
/* allocate and initialize the VL */
- buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t));
- if(buf == NULL)
+ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t));
+ if (buf == NULL)
goto out;
/* read */
@@ -1079,8 +1066,7 @@ htri_t H5DSis_attached(hid_t did,
goto out;
/* iterate all the REFs in this dimension IDX */
- for (i=0; i<(int)buf[idx].len; i++)
- {
+ for (i = 0; i < (int)buf[idx].len; i++) {
/* get the reference */
ref = ((hobj_ref_t *)buf[idx].p)[i];
@@ -1089,30 +1075,28 @@ htri_t H5DSis_attached(hid_t did,
goto out;
/* get info for DS in the parameter list */
- if(H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0)
goto out;
/* get info for this DS */
- if(H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0)
goto out;
/* same object */
- if(oi1.fileno == oi2.fileno) {
+ if (oi1.fileno == oi2.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0)
goto out;
- if(!token_cmp)
+ if (!token_cmp)
found_ds = 1;
} /* end if */
/* close the dereferenced dataset */
if (H5Dclose(dsid_j) < 0)
goto out;
-
}
-
/* close */
if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
@@ -1127,39 +1111,38 @@ htri_t H5DSis_attached(hid_t did,
} /* has_dimlist */
/*-------------------------------------------------------------------------
- * info on the >>DS<< dataset
- *-------------------------------------------------------------------------
- */
+ * info on the >>DS<< dataset
+ *-------------------------------------------------------------------------
+ */
/* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */
- if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
+ if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * open "REFERENCE_LIST"
- *-------------------------------------------------------------------------
- */
+ * open "REFERENCE_LIST"
+ *-------------------------------------------------------------------------
+ */
- if(has_reflist == 1)
- {
- if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
+ if (has_reflist == 1) {
+ if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
/* get native type to read REFERENCE_LIST attribute */
- if((ntid = H5DS_get_REFLIST_type()) < 0)
+ if ((ntid = H5DS_get_REFLIST_type()) < 0)
goto out;
/* get and save the old reference(s) */
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
- if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
+ if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
- dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
if (dsbuf == NULL)
goto out;
@@ -1168,46 +1151,43 @@ htri_t H5DSis_attached(hid_t did,
goto out;
/*-------------------------------------------------------------------------
- * iterate
- *-------------------------------------------------------------------------
- */
+ * iterate
+ *-------------------------------------------------------------------------
+ */
- for(i = 0; i < nelmts; i++)
- {
+ for (i = 0; i < nelmts; i++) {
/* get the reference */
ref = dsbuf[i].ref;
/* the reference was not deleted */
- if (ref)
- {
+ if (ref) {
/* get the dataset id */
if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
goto out;
/* get info for dataset in the parameter list */
- if(H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0)
goto out;
/* get info for this dataset */
- if(H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0)
goto out;
/* same object */
- if(oi3.fileno == oi4.fileno) {
+ if (oi3.fileno == oi4.fileno) {
int token_cmp;
- if(H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0)
+ if (H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0)
goto out;
- if(!token_cmp && (idx == dsbuf[i].dim_idx))
- found_dset=1;
+ if (!token_cmp && (idx == dsbuf[i].dim_idx))
+ found_dset = 1;
} /* end if */
/* close the dereferenced dataset */
if (H5Dclose(did_i) < 0)
goto out;
} /* if */
- } /* i */
-
+ } /* i */
/* close */
if (H5Sclose(sid) < 0)
@@ -1230,18 +1210,20 @@ htri_t H5DSis_attached(hid_t did,
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Aclose(aid);
H5Tclose(tid);
H5Tclose(ntid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
if (buf) {
HDfree(buf);
buf = NULL;
}
- if(dsbuf) {
+ if (dsbuf) {
HDfree(dsbuf);
dsbuf = NULL;
}
@@ -1249,88 +1231,84 @@ out:
}
/*-------------------------------------------------------------------------
-* Function: H5DSiterate_scales
-*
-* Purpose: H5DSiterate_scales iterates over the scales attached to dimension DIM
-* of dataset DID. For each scale in the list, the visitor_data and some
-* additional information, specified below, are passed to the visitor function.
-* The iteration begins with the IDX object in the group and the next element
-* to be processed by the operator is returned in IDX. If IDX is NULL, then the
-* iterator starts at zero.
-*
-* Parameters:
-*
-* hid_t DID; IN: the dataset
-* 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.
-*
-* The operator callback receives a pointer to the item ,
-* and the pointer to the operator data passed
-* in to H5SL_iterate ('op_data'). The return values from an operator are:
-* A. Zero causes the iterator to continue, returning zero when all
-* nodes of that type have been processed.
-* B. Positive causes the iterator to immediately return that positive
-* value, indicating short-circuit success.
-* C. Negative causes the iterator to immediately return that value,
-* indicating failure.
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: January 31, 2005
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5DSiterate_scales(hid_t did,
- unsigned int dim,
- int *ds_idx,
- H5DS_iterate_t visitor,
- void *visitor_data )
+ * Function: H5DSiterate_scales
+ *
+ * Purpose: H5DSiterate_scales iterates over the scales attached to dimension DIM
+ * of dataset DID. For each scale in the list, the visitor_data and some
+ * additional information, specified below, are passed to the visitor function.
+ * The iteration begins with the IDX object in the group and the next element
+ * to be processed by the operator is returned in IDX. If IDX is NULL, then the
+ * iterator starts at zero.
+ *
+ * Parameters:
+ *
+ * hid_t DID; IN: the dataset
+ * 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.
+ *
+ * The operator callback receives a pointer to the item ,
+ * and the pointer to the operator data passed
+ * in to H5SL_iterate ('op_data'). The return values from an operator are:
+ * A. Zero causes the iterator to continue, returning zero when all
+ * nodes of that type have been processed.
+ * B. Positive causes the iterator to immediately return that positive
+ * value, indicating short-circuit success.
+ * C. Negative causes the iterator to immediately return that value,
+ * indicating failure.
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: January 31, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visitor, void *visitor_data)
{
- hid_t scale_id;
- int rank;
- hobj_ref_t ref; /* reference to the DS */
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- hvl_t *buf = NULL; /* VL buffer to store in the attribute */
- H5I_type_t it; /* ID type */
- herr_t ret_value=0;
- int j_idx;
- int nscales;
- int has_dimlist;
- int i;
+ hid_t scale_id;
+ int rank;
+ hobj_ref_t ref; /* reference to the DS */
+ hid_t sid; /* space ID */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t aid = -1; /* attribute ID */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ H5I_type_t it; /* ID type */
+ herr_t ret_value = 0;
+ int j_idx;
+ int nscales;
+ int has_dimlist;
+ int i;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* get ID type */
if ((it = H5Iget_type(did)) < 0)
return FAIL;
- if (H5I_DATASET!=it)
+ if (H5I_DATASET != it)
return FAIL;
/* get the number of scales assotiated with this DIM */
- if ((nscales = H5DSget_num_scales(did,dim)) < 0)
+ if ((nscales = H5DSget_num_scales(did, dim)) < 0)
return FAIL;
/* parameter range checking */
- if (ds_idx!=NULL)
- {
- if (*ds_idx>=nscales)
+ if (ds_idx != NULL) {
+ if (*ds_idx >= nscales)
return FAIL;
}
@@ -1339,70 +1317,67 @@ herr_t H5DSiterate_scales(hid_t did,
return FAIL;
/* get rank */
- if ((rank=H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* close dataset space */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if ( dim >= (unsigned)rank )
+ 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)
+ if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
- if(has_dimlist == 0)
+ if (has_dimlist == 0)
return SUCCEED;
- else if(has_dimlist == 1)
- {
- if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
+ else if (has_dimlist == 1) {
+ if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
/* allocate and initialize the VL */
- buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t));
+ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t));
- if(buf == NULL)
+ if (buf == NULL)
goto out;
/* read */
- if(H5Aread(aid, tid, buf) < 0)
+ if (H5Aread(aid, tid, buf) < 0)
goto out;
- if ( buf[dim].len > 0 )
- {
- if (ds_idx!=NULL)
+ if (buf[dim].len > 0) {
+ if (ds_idx != NULL)
j_idx = *ds_idx;
else
- j_idx=0;
+ j_idx = 0;
/* iterate */
- for(i=j_idx; i<nscales; i++)
- {
+ for (i = j_idx; i < nscales; i++) {
/* get the reference */
- ref = ((hobj_ref_t *)buf[dim].p)[ i ];
+ ref = ((hobj_ref_t *)buf[dim].p)[i];
/* disable error reporting, the ID might refer to a deleted dataset */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
/* get the DS id */
- if ((scale_id = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0)
+ if ((scale_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
goto out;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* set the return IDX OUT value at current scale index */
- if (ds_idx!=NULL)
- {
+ if (ds_idx != NULL) {
*ds_idx = i;
}
- if((ret_value=(visitor)(did,dim,scale_id,visitor_data))!=0)
- {
+ if ((ret_value = (visitor)(did, dim, scale_id, visitor_data)) != 0) {
/* break */
/* close the DS id */
@@ -1417,10 +1392,10 @@ herr_t H5DSiterate_scales(hid_t did,
goto out;
} /* i */
- } /* if */
+ } /* if */
/* close */
- if (H5Treclaim(tid,sid,H5P_DEFAULT,buf) < 0)
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
if (H5Sclose(sid) < 0)
goto out;
@@ -1436,55 +1411,58 @@ herr_t H5DSiterate_scales(hid_t did,
return ret_value;
out:
- H5E_BEGIN_TRY {
- if(buf) {
- H5Treclaim(tid,sid,H5P_DEFAULT,buf);
+ H5E_BEGIN_TRY
+ {
+ if (buf) {
+ H5Treclaim(tid, sid, H5P_DEFAULT, buf);
HDfree(buf);
}
H5Sclose(sid);
H5Aclose(aid);
H5Tclose(tid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
/*-------------------------------------------------------------------------
-* Function: H5DSset_label
-*
-* Purpose: Set label for the dimension IDX of dataset DID to the value LABEL
-*
-* Return: Success: SUCCEED, Failure: FAIL
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: January 11, 2005
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
+ * Function: H5DSset_label
+ *
+ * Purpose: Set label for the dimension IDX of dataset DID to the value LABEL
+ *
+ * Return: Success: SUCCEED, Failure: FAIL
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: January 11, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+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 */
- H5I_type_t it; /* ID type */
- unsigned int i;
- union { /* union is needed to eliminate compiler warnings about */
- char ** buf; /* discarding the 'const' qualifier in the free */
- char const ** const_buf; /* buf calls */
+ 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 */
+ H5I_type_t it; /* ID type */
+ unsigned int i;
+ union { /* union is needed to eliminate compiler warnings about */
+ char ** buf; /* discarding the 'const' qualifier in the free */
+ char const **const_buf; /* buf calls */
} u;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* get ID type */
if ((it = H5Iget_type(did)) < 0)
return FAIL;
@@ -1495,7 +1473,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
if (label == NULL)
return FAIL;
- /* get dataset space */
+ /* get dataset space */
if ((sid = H5Dget_space(did)) < 0)
return FAIL;
@@ -1507,25 +1485,24 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
if (H5Sclose(sid) < 0)
goto out;
- if ( idx >= (unsigned)rank )
+ if (idx >= (unsigned)rank)
return FAIL;
/*-------------------------------------------------------------------------
- * attribute "DIMENSION_LABELS"
- *-------------------------------------------------------------------------
- */
+ * 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
- *-------------------------------------------------------------------------
- */
+ * make the attribute and insert label
+ *-------------------------------------------------------------------------
+ */
- if (has_labels == 0)
- {
+ if (has_labels == 0) {
dims[0] = (hsize_t)rank;
/* space for the attribute */
@@ -1543,12 +1520,12 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
goto out;
/* allocate and initialize */
- u.const_buf = (char const **) HDmalloc((size_t) rank * sizeof(char *));
+ u.const_buf = (char const **)HDmalloc((size_t)rank * sizeof(char *));
if (u.const_buf == NULL)
goto out;
- for (i = 0; i < (unsigned int) rank; i++)
+ for (i = 0; i < (unsigned int)rank; i++)
u.const_buf[i] = NULL;
/* store the label information in the required index */
@@ -1565,20 +1542,18 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
goto out;
if (H5Aclose(aid) < 0)
goto out;
- if (u.const_buf)
- {
+ if (u.const_buf) {
HDfree(u.const_buf);
u.const_buf = NULL;
}
}
/*-------------------------------------------------------------------------
- * just insert label
- *-------------------------------------------------------------------------
- */
+ * just insert label
+ *-------------------------------------------------------------------------
+ */
- else
- {
+ else {
if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0)
goto out;
@@ -1587,7 +1562,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
goto out;
/* allocate and initialize */
- u.buf = (char **) HDmalloc((size_t) rank * sizeof(char *));
+ u.buf = (char **)HDmalloc((size_t)rank * sizeof(char *));
if (u.buf == NULL)
goto out;
@@ -1611,8 +1586,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
u.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 (u.buf[i])
HDfree(u.buf[i]);
}
@@ -1622,8 +1596,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
goto out;
if (H5Aclose(aid) < 0)
goto out;
- if (u.buf)
- {
+ if (u.buf) {
HDfree(u.buf);
u.buf = NULL;
}
@@ -1634,13 +1607,11 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label)
/* error zone */
out:
- if (u.buf)
- {
- if (u.buf[idx]) /* check if we errored during H5Awrite */
+ if (u.buf) {
+ if (u.buf[idx]) /* check if we errored during H5Awrite */
u.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 (u.buf[i])
HDfree(u.buf[i]);
}
@@ -1651,50 +1622,52 @@ out:
H5Sclose(sid);
H5Aclose(aid);
H5Tclose(tid);
- }H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
/*-------------------------------------------------------------------------
-* Function: H5DSget_label
-*
-* Purpose: Read the label LABEL for dimension IDX of dataset DID
-* Up to 'size' characters are stored in 'label' followed by a '\0' string
-* terminator. If the label is longer than 'size'-1,
-* the string terminator is stored in the last position of the buffer to
-* properly terminate the string.
-*
-* Return: 0 if no label found, size of label if found, Failure: FAIL
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: January 11, 2005
-*
-* Comments:
-*
-* Modifications:
-* JIRA HDFFV-7673: Added a check to see if the label name exists,
-* if not then returns zero. July 30, 2011. MSB
-*
-*-------------------------------------------------------------------------
-*/
-ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
+ * Function: H5DSget_label
+ *
+ * Purpose: Read the label LABEL for dimension IDX of dataset DID
+ * Up to 'size' characters are stored in 'label' followed by a '\0' string
+ * terminator. If the label is longer than 'size'-1,
+ * the string terminator is stored in the last position of the buffer to
+ * properly terminate the string.
+ *
+ * Return: 0 if no label found, size of label if found, Failure: FAIL
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: January 11, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ * JIRA HDFFV-7673: Added a check to see if the label name exists,
+ * if not then returns zero. July 30, 2011. MSB
+ *
+ *-------------------------------------------------------------------------
+ */
+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 */
+ 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 = 0;
size_t copy_len;
int i;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* get ID type */
if ((it = H5Iget_type(did)) < 0)
return FAIL;
@@ -1702,7 +1675,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
if (H5I_DATASET != it)
return FAIL;
- /* get dataset space */
+ /* get dataset space */
if ((sid = H5Dget_space(did)) < 0)
return FAIL;
@@ -1714,41 +1687,39 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
if (H5Sclose(sid) < 0)
goto out;
- if ( idx >= (unsigned)rank )
+ if (idx >= (unsigned)rank)
return FAIL;
/*-------------------------------------------------------------------------
- * attribute "DIMENSION_LABELS"
- *-------------------------------------------------------------------------
- */
+ * 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;
/* return 0 and NULL for label if no label found */
- if (has_labels == 0)
- {
+ if (has_labels == 0) {
if (label)
label[0] = 0;
return 0;
}
/*-------------------------------------------------------------------------
- * open the attribute and read label
- *-------------------------------------------------------------------------
- */
+ * open the attribute and read label
+ *-------------------------------------------------------------------------
+ */
- assert (has_labels == 1);
+ assert(has_labels == 1);
if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0)
goto out;
-
if ((tid = H5Aget_type(aid)) < 0)
goto out;
/* allocate and initialize */
- buf = (char **) HDmalloc((size_t) rank * sizeof(char *));
+ buf = (char **)HDmalloc((size_t)rank * sizeof(char *));
if (buf == NULL)
goto out;
@@ -1758,27 +1729,23 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
goto out;
/* do only if the label name exists for the dimension */
- if (buf[idx] != NULL)
- {
+ if (buf[idx] != NULL) {
/* get the real string length */
nbytes = HDstrlen(buf[idx]);
/* compute the string length which will fit into the user's buffer */
- copy_len = MIN(size-1, nbytes);
+ copy_len = MIN(size - 1, nbytes);
/* copy all/some of the name */
- if (label)
- {
+ if (label) {
HDmemcpy(label, buf[idx], copy_len);
/* terminate the string */
label[copy_len] = '\0';
}
-
}
/* free all the ptr's from the H5Aread() */
- for (i = 0; i < rank; i++)
- {
+ for (i = 0; i < rank; i++) {
if (buf[i])
HDfree(buf[i]);
}
@@ -1788,21 +1755,18 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
goto out;
if (H5Aclose(aid) < 0)
goto out;
- if (buf)
- {
+ if (buf) {
HDfree(buf);
buf = NULL;
}
- return (ssize_t) nbytes;
+ return (ssize_t)nbytes;
/* error zone */
out:
- if (buf)
- {
+ if (buf) {
/* free all the ptr's from the H5Aread() */
- for (i = 0; i < rank; i++)
- {
+ for (i = 0; i < rank; i++) {
if (buf[i])
HDfree(buf[i]);
}
@@ -1813,37 +1777,37 @@ out:
H5Sclose(sid);
H5Aclose(aid);
H5Tclose(tid);
- }H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
/*-------------------------------------------------------------------------
-* Function: H5DSget_scale_name
-*
-* Purpose: Read the name of dataset scale DID into buffer NAME
-* Up to 'size' characters are stored in 'name' followed by a '\0' string
-* terminator. If the name is longer than 'size'-1,
-* the string terminator is stored in the last position of the buffer to
-* properly terminate the string.
-*
-* Return: size of name if found, zero if not found, Failure: FAIL
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: January 04, 2005
-*
-* Comments:
-*
-* Modifications:
-* The size of the name returned should not include the NULL termination
-* in its value so as to be consistent with other HDF5 APIs.
-*
-*-------------------------------------------------------------------------
-*/
-
-ssize_t H5DSget_scale_name(hid_t did,
- char *name,
- size_t size)
+ * Function: H5DSget_scale_name
+ *
+ * Purpose: Read the name of dataset scale DID into buffer NAME
+ * Up to 'size' characters are stored in 'name' followed by a '\0' string
+ * terminator. If the name is longer than 'size'-1,
+ * the string terminator is stored in the last position of the buffer to
+ * properly terminate the string.
+ *
+ * Return: size of name if found, zero if not found, Failure: FAIL
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: January 04, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ * The size of the name returned should not include the NULL termination
+ * in its value so as to be consistent with other HDF5 APIs.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ssize_t
+H5DSget_scale_name(hid_t did, char *name, size_t size)
{
hid_t aid; /* attribute ID */
hid_t tid = -1; /* attribute type ID */
@@ -1852,26 +1816,26 @@ ssize_t H5DSget_scale_name(hid_t did,
size_t nbytes;
size_t copy_len;
int has_name;
- char *buf=NULL;
+ char * buf = NULL;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* get ID type */
if ((it = H5Iget_type(did)) < 0)
return FAIL;
- if (H5I_DATASET!=it)
+ if (H5I_DATASET != it)
return FAIL;
- if ((H5DSis_scale(did))<=0)
+ if ((H5DSis_scale(did)) <= 0)
return FAIL;
/*-------------------------------------------------------------------------
- * check if the DS has a name
- *-------------------------------------------------------------------------
- */
+ * check if the DS has a name
+ *-------------------------------------------------------------------------
+ */
/* try to find the attribute "NAME" on the >>DS<< dataset */
if ((has_name = H5LT_find_attribute(did, "NAME")) < 0)
@@ -1881,43 +1845,43 @@ ssize_t H5DSget_scale_name(hid_t did,
return 0;
/*-------------------------------------------------------------------------
- * open the attribute
- *-------------------------------------------------------------------------
- */
+ * open the attribute
+ *-------------------------------------------------------------------------
+ */
- if((aid = H5Aopen(did, "NAME", H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, "NAME", H5P_DEFAULT)) < 0)
return FAIL;
/* get space */
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
/* get type */
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
/* get the size */
- if((nbytes = H5Tget_size(tid)) == 0)
+ if ((nbytes = H5Tget_size(tid)) == 0)
goto out;
/* allocate a temporary buffer */
- buf = (char*)HDmalloc(nbytes * sizeof(char));
+ buf = (char *)HDmalloc(nbytes * sizeof(char));
if (buf == NULL)
goto out;
/* read */
- if (H5Aread(aid,tid,buf) < 0)
+ if (H5Aread(aid, tid, buf) < 0)
goto out;
/* compute the string length which will fit into the user's buffer */
- copy_len = MIN(size-1, nbytes);
+ copy_len = MIN(size - 1, nbytes);
/* copy all/some of the name */
if (name) {
HDmemcpy(name, buf, copy_len);
/* terminate the string */
- name[copy_len]='\0';
+ name[copy_len] = '\0';
}
/* close */
@@ -1934,221 +1898,222 @@ ssize_t H5DSget_scale_name(hid_t did,
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Aclose(aid);
H5Tclose(tid);
H5Sclose(sid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
if (buf)
HDfree(buf);
return FAIL;
}
/*-------------------------------------------------------------------------
-* Function: H5DSis_scale
-*
-* Purpose: check if the dataset DID is a dimension scale
-*
-* Return: 1, is, 0, not, FAIL, error
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: January 04, 2005
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-htri_t H5DSis_scale(hid_t did)
+ * Function: H5DSis_scale
+ *
+ * Purpose: check if the dataset DID is a dimension scale
+ *
+ * Return: 1, is, 0, not, FAIL, error
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: January 04, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+htri_t
+H5DSis_scale(hid_t did)
{
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- herr_t has_class; /* has the "CLASS" attribute */
- htri_t is_ds; /* boolean return value */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t aid = -1; /* attribute ID */
+ herr_t has_class; /* has the "CLASS" attribute */
+ htri_t is_ds; /* boolean return value */
H5I_type_t it; /* ID type */
- char *buf; /* Name of attribute */
+ char * buf; /* Name of attribute */
hsize_t storage_size; /* Size of storage for attribute */
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* get ID type */
if ((it = H5Iget_type(did)) < 0)
return FAIL;
- if(H5I_DATASET != it)
+ if (H5I_DATASET != it)
return FAIL;
/* try to find the attribute "CLASS" on the dataset */
- if((has_class = H5LT_find_attribute(did, "CLASS")) < 0)
+ if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0)
return FAIL;
- if(has_class == 0)
+ if (has_class == 0)
is_ds = 0;
- else
- {
- if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
+ else {
+ if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
/* check to make sure attribute is a string */
- if(H5T_STRING != H5Tget_class(tid))
+ if (H5T_STRING != H5Tget_class(tid))
goto out;
/* check to make sure string is null-terminated */
- if(H5T_STR_NULLTERM != H5Tget_strpad(tid))
+ if (H5T_STR_NULLTERM != H5Tget_strpad(tid))
goto out;
/* allocate buffer large enough to hold string */
- if((storage_size = H5Aget_storage_size(aid)) == 0)
+ if ((storage_size = H5Aget_storage_size(aid)) == 0)
goto out;
- buf = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1);
- if(buf == NULL)
+ buf = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1);
+ if (buf == NULL)
goto out;
/* Read the attribute */
- if(H5Aread(aid, tid, buf) < 0)
+ if (H5Aread(aid, tid, buf) < 0)
goto out;
/* compare strings */
- if(HDstrncmp(buf, DIMENSION_SCALE_CLASS, MIN(HDstrlen(DIMENSION_SCALE_CLASS),HDstrlen(buf)))==0)
+ if (HDstrncmp(buf, DIMENSION_SCALE_CLASS, MIN(HDstrlen(DIMENSION_SCALE_CLASS), HDstrlen(buf))) == 0)
is_ds = 1;
else
is_ds = 0;
HDfree(buf);
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
if (H5Aclose(aid) < 0)
goto out;
-
-
}
return is_ds;
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Aclose(aid);
H5Tclose(tid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
-
}
/*-------------------------------------------------------------------------
-* Function: H5DSget_num_scales
-*
-* Purpose: get the number of scales linked to the IDX dimension of dataset DID
-*
-* Return:
-* Success: number of scales
-* Failure: FAIL
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: January 13, 2005
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-int H5DSget_num_scales(hid_t did,
- unsigned int idx)
+ * Function: H5DSget_num_scales
+ *
+ * Purpose: get the number of scales linked to the IDX dimension of dataset DID
+ *
+ * Return:
+ * Success: number of scales
+ * Failure: FAIL
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: January 13, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+int
+H5DSget_num_scales(hid_t did, unsigned int idx)
{
int has_dimlist;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- hvl_t *buf = NULL; /* VL buffer to store in the attribute */
- H5I_type_t it; /* ID type */
+ hid_t sid; /* space ID */
+ hid_t tid = -1; /* attribute type ID */
+ hid_t aid = -1; /* attribute ID */
+ int rank; /* rank of dataset */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ H5I_type_t it; /* ID type */
int nscales;
/*-------------------------------------------------------------------------
- * parameter checking
- *-------------------------------------------------------------------------
- */
+ * parameter checking
+ *-------------------------------------------------------------------------
+ */
/* get ID type */
- if((it = H5Iget_type(did)) < 0)
+ if ((it = H5Iget_type(did)) < 0)
return FAIL;
- if(H5I_DATASET != it)
+ if (H5I_DATASET != it)
return FAIL;
/*-------------------------------------------------------------------------
- * the attribute "DIMENSION_LIST" on the >>data<< dataset must exist
- *-------------------------------------------------------------------------
- */
+ * the attribute "DIMENSION_LIST" on the >>data<< dataset must exist
+ *-------------------------------------------------------------------------
+ */
/* get dataset space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
return FAIL;
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* close dataset space */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/* dimemsion index IDX range checking */
- if(idx >= (unsigned int )rank)
+ if (idx >= (unsigned int)rank)
return FAIL;
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
+ if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
/* it does not exist */
- if(has_dimlist == 0)
+ if (has_dimlist == 0)
return 0;
/*-------------------------------------------------------------------------
- * the attribute exists, open it
- *-------------------------------------------------------------------------
- */
+ * the attribute exists, open it
+ *-------------------------------------------------------------------------
+ */
else {
- if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
- if((sid = H5Aget_space(aid)) < 0)
+ if ((sid = H5Aget_space(aid)) < 0)
goto out;
/* allocate and initialize the VL */
buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t));
- if(buf == NULL)
+ if (buf == NULL)
goto out;
/* read */
- if(H5Aread(aid, tid, buf) < 0)
+ if (H5Aread(aid, tid, buf) < 0)
goto out;
nscales = (int)buf[idx].len;
/* close */
- if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
HDfree(buf);
buf = NULL;
@@ -2158,84 +2123,85 @@ int H5DSget_num_scales(hid_t did,
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Aclose(aid);
H5Tclose(tid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- if(buf)
+ if (buf)
HDfree(buf);
return FAIL;
}
/*-------------------------------------------------------------------------
-* Function: H5DS_is_reserved
-*
-* Purpose: Verify that a dataset's CLASS is either an image, palette or table
-*
-* Return: true, false, fail
-*
-* Programmer: pvn@ncsa.uiuc.edu
-*
-* Date: March 19, 2005
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-static
-herr_t H5DS_is_reserved(hid_t did)
+ * Function: H5DS_is_reserved
+ *
+ * Purpose: Verify that a dataset's CLASS is either an image, palette or table
+ *
+ * Return: true, false, fail
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: March 19, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static herr_t
+H5DS_is_reserved(hid_t did)
{
- int has_class;
- hid_t tid = -1;
- hid_t aid = -1;
- char *buf; /* Name of attribute */
+ int has_class;
+ hid_t tid = -1;
+ hid_t aid = -1;
+ char * buf; /* Name of attribute */
hsize_t storage_size; /* Size of storage for attribute */
- herr_t ret;
+ herr_t ret;
/* try to find the attribute "CLASS" on the dataset */
- if((has_class = H5LT_find_attribute(did, "CLASS")) < 0)
+ if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0)
return -1;
- if(has_class == 0)
+ if (has_class == 0)
return 0;
- assert(has_class == 1);
- if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
+ assert(has_class == 1);
+ if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
goto out;
- if((tid = H5Aget_type(aid)) < 0)
+ if ((tid = H5Aget_type(aid)) < 0)
goto out;
/* check to make sure attribute is a string */
- if(H5T_STRING != H5Tget_class(tid))
- goto out;
+ if (H5T_STRING != H5Tget_class(tid))
+ goto out;
/* check to make sure string is null-terminated */
- if(H5T_STR_NULLTERM != H5Tget_strpad(tid))
- goto out;
+ if (H5T_STR_NULLTERM != H5Tget_strpad(tid))
+ goto out;
/* allocate buffer large enough to hold string */
- if((storage_size = H5Aget_storage_size(aid)) == 0)
- goto out;
+ if ((storage_size = H5Aget_storage_size(aid)) == 0)
+ goto out;
- buf = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1);
- if(buf == NULL)
- goto out;
+ buf = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1);
+ if (buf == NULL)
+ goto out;
/* Read the attribute */
- if(H5Aread(aid, tid, buf) < 0)
- goto out;
-
+ if (H5Aread(aid, tid, buf) < 0)
+ goto out;
- if(HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(buf))) == 0 ||
- HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(buf))) == 0 ||
- HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS),HDstrlen(buf))) == 0 )
+ if (HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS), HDstrlen(buf))) == 0 ||
+ HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS), HDstrlen(buf))) == 0 ||
+ HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS), HDstrlen(buf))) == 0)
ret = 1;
else
ret = 0;
@@ -2248,7 +2214,6 @@ herr_t H5DS_is_reserved(hid_t did)
if (H5Aclose(aid) < 0)
goto out;
-
return ret;
/* error zone */
@@ -2257,31 +2222,32 @@ out:
{
H5Tclose(tid);
H5Aclose(aid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
/*-------------------------------------------------------------------------
-* Function: H5DS_get_REFLIST_type
-*
-* Purpose: This is a helper function to return a native type for
-* the REFERENCE_LIST attribute.
-*
-* Return: Type identifier on success and negative on failure
-*
-* Programmer: epourmal@hdfgroup.org
-*
-* Date: May 22, 2010
-*
-* Comments:
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-static
-hid_t H5DS_get_REFLIST_type(void)
+ * Function: H5DS_get_REFLIST_type
+ *
+ * Purpose: This is a helper function to return a native type for
+ * the REFERENCE_LIST attribute.
+ *
+ * Return: Type identifier on success and negative on failure
+ *
+ * Programmer: epourmal@hdfgroup.org
+ *
+ * Date: May 22, 2010
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static hid_t
+H5DS_get_REFLIST_type(void)
{
hid_t ntid_t = -1;
@@ -2289,20 +2255,21 @@ hid_t H5DS_get_REFLIST_type(void)
used to store ds_list_t structure in the REFERENCE_LIST
attribute */
- if((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0)
+ if ((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0)
goto out;
- if(H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t,ref), H5T_STD_REF_OBJ) < 0)
+ if (H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0)
goto out;
- if(H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0)
goto out;
return ntid_t;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(ntid_t);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
-
diff --git a/hl/src/H5DSprivate.h b/hl/src/H5DSprivate.h
index 9d20d48..58bb82e 100644
--- a/hl/src/H5DSprivate.h
+++ b/hl/src/H5DSprivate.h
@@ -20,21 +20,15 @@
/* public LT prototypes */
#include "H5DSpublic.h"
-
-
-
/* attribute type of a DS dataset */
typedef struct ds_list_t {
- hobj_ref_t ref; /* object reference */
- unsigned int dim_idx; /* dimension index of the dataset */
+ hobj_ref_t ref; /* object reference */
+ unsigned int dim_idx; /* dimension index of the dataset */
} ds_list_t;
-
/*-------------------------------------------------------------------------
* private functions
*-------------------------------------------------------------------------
*/
-
#endif
-
diff --git a/hl/src/H5DSpublic.h b/hl/src/H5DSpublic.h
index 615122c..0c29a36 100644
--- a/hl/src/H5DSpublic.h
+++ b/hl/src/H5DSpublic.h
@@ -14,61 +14,37 @@
#ifndef _H5DSpublic_H
#define _H5DSpublic_H
-
-
#define DIMENSION_SCALE_CLASS "DIMENSION_SCALE"
#define DIMENSION_LIST "DIMENSION_LIST"
#define REFERENCE_LIST "REFERENCE_LIST"
#define DIMENSION_LABELS "DIMENSION_LABELS"
-
-typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *visitor_data);
-
+typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *visitor_data);
#ifdef __cplusplus
extern "C" {
#endif
-H5_HLDLL herr_t H5DSattach_scale( hid_t did,
- hid_t dsid,
- unsigned int idx);
-
-H5_HLDLL herr_t H5DSdetach_scale( hid_t did,
- hid_t dsid,
- unsigned int idx);
-
-H5_HLDLL herr_t H5DSset_scale( hid_t dsid,
- const char *dimname);
+H5_HLDLL herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx);
-H5_HLDLL int H5DSget_num_scales( hid_t did,
- unsigned int dim);
+H5_HLDLL herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx);
-H5_HLDLL herr_t H5DSset_label( hid_t did,
- unsigned int idx,
- const char *label);
+H5_HLDLL herr_t H5DSset_scale(hid_t dsid, const char *dimname);
-H5_HLDLL ssize_t H5DSget_label( hid_t did,
- unsigned int idx,
- char *label,
- size_t size);
+H5_HLDLL int H5DSget_num_scales(hid_t did, unsigned int dim);
-H5_HLDLL ssize_t H5DSget_scale_name( hid_t did,
- char *name,
- size_t size);
+H5_HLDLL herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label);
-H5_HLDLL htri_t H5DSis_scale( hid_t did);
+H5_HLDLL ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size);
-H5_HLDLL herr_t H5DSiterate_scales( hid_t did,
- unsigned int dim,
- int *idx,
- H5DS_iterate_t visitor,
- void *visitor_data);
+H5_HLDLL ssize_t H5DSget_scale_name(hid_t did, char *name, size_t size);
-H5_HLDLL htri_t H5DSis_attached( hid_t did,
- hid_t dsid,
- unsigned int idx);
+H5_HLDLL htri_t H5DSis_scale(hid_t did);
+H5_HLDLL herr_t H5DSiterate_scales(hid_t did, unsigned int dim, int *idx, H5DS_iterate_t visitor,
+ void *visitor_data);
+H5_HLDLL htri_t H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx);
#ifdef __cplusplus
}
diff --git a/hl/src/H5HLprivate2.h b/hl/src/H5HLprivate2.h
index 45591e8..989c799 100644
--- a/hl/src/H5HLprivate2.h
+++ b/hl/src/H5HLprivate2.h
@@ -24,4 +24,3 @@
#include "H5private.h"
#endif /* _H5HLprivate2_H */
-
diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c
index 6f7414b..e08d006 100644
--- a/hl/src/H5IM.c
+++ b/hl/src/H5IM.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5IMprivate.h"
#include "H5LTprivate.h"
@@ -17,31 +17,29 @@
#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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMmake_image_8bit( hid_t loc_id,
- const char *dset_name,
- hsize_t width,
- hsize_t height,
- const unsigned char *buf )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMmake_image_8bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height,
+ const unsigned char *buf)
{
- hsize_t dims[IMAGE8_RANK];
+ hsize_t dims[IMAGE8_RANK];
/* check the arguments */
if (dset_name == NULL)
@@ -52,56 +50,53 @@ herr_t H5IMmake_image_8bit( hid_t loc_id,
dims[1] = width;
/* Make the dataset */
- if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0)
+ 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)
+ 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)
+ 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)
+ if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED") < 0)
return -1;
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
-*
-* 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 *buf )
+ * 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
+ *
+ * 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 *buf)
{
- hsize_t dims[IMAGE24_RANK];
+ hsize_t dims[IMAGE24_RANK];
/* check the arguments */
if (interlace == NULL)
@@ -109,73 +104,65 @@ herr_t H5IMmake_image_24bit( hid_t loc_id,
if (dset_name == NULL)
return -1;
-
/* Initialize the image dimensions */
- if ( HDstrncmp( interlace, "INTERLACE_PIXEL",15 ) == 0 )
- {
+ if (HDstrncmp(interlace, "INTERLACE_PIXEL", 15) == 0) {
/* Number of color planes is defined as the third dimension */
dims[0] = height;
dims[1] = width;
dims[2] = IMAGE24_RANK;
}
+ else if (HDstrncmp(interlace, "INTERLACE_PLANE", 15) == 0) {
+ /* Number of color planes is defined as the first dimension */
+ dims[0] = IMAGE24_RANK;
+ dims[1] = height;
+ dims[2] = width;
+ }
else
- if ( HDstrncmp( interlace, "INTERLACE_PLANE",15 ) == 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;
+ return -1;
- /* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0)
- return -1;
+ /* Make the dataset */
+ if (H5LTmake_dataset(loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buf) < 0)
+ return -1;
- /* Attach the VERSION attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0)
- return -1;
+ /* Attach the CLASS attribute */
+ if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 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 VERSION attribute */
+ if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 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;
+ /* Attach the IMAGE_SUBCLASS attribute */
+ if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR") < 0)
+ return -1;
- return 0;
+ /* 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;
@@ -184,93 +171,90 @@ static herr_t find_palette(hid_t loc_id,
return -1;
/* Shut compiler up */
- loc_id = loc_id; ainfo = ainfo; op_data = op_data;
+ 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
- */
- if(HDstrncmp(name, "PALETTE",7) == 0)
+ * cause the iterator to immediately return that positive value,
+ * indicating short-circuit success
+ */
+ if (HDstrncmp(name, "PALETTE", 7) == 0)
ret = H5_ITER_STOP;
return ret;
}
-
/*-------------------------------------------------------------------------
-* 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 )
+ * 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)
{
return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_palette, NULL);
}
-
/*-------------------------------------------------------------------------
-* 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
-*
-* 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 )
+ * 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
+ *
+ * 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)
{
- hid_t did = -1;
- hid_t sid = -1;
+ hid_t did = -1;
+ hid_t sid = -1;
hsize_t dims[IMAGE24_RANK];
- hid_t aid = -1;
- hid_t asid = -1;
- hid_t atid = -1;
+ hid_t aid = -1;
+ hid_t asid = -1;
+ hid_t atid = -1;
H5T_class_t aclass;
int has_pal;
int has_attr;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
if (interlace == NULL)
- return -1;
+ return -1;
/*assume initially we have no palettes attached*/
*npals = 0;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
/* Try to find the attribute "INTERLACE_MODE" on the >>image<< dataset */
@@ -278,58 +262,55 @@ herr_t H5IMget_image_info( hid_t loc_id,
goto out;
/* It exists, get it */
- if(has_attr == 1)
- {
+ if (has_attr == 1) {
- if((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- if(H5Aread(aid, atid, interlace) < 0)
+ if (H5Aread(aid, atid, interlace) < 0)
goto out;
- if(H5Tclose(atid) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
}
/* Get the dataspace handle */
- if ( (sid = H5Dget_space( did )) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* Get dimensions */
- if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
/* 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 ( HDstrncmp( interlace, "INTERLACE_PIXEL", 15 ) == 0 )
- {
+ if (HDstrncmp(interlace, "INTERLACE_PIXEL", 15) == 0) {
/* Number of color planes is defined as the third dimension */
*height = dims[0];
*width = dims[1];
*planes = dims[2];
}
+ else if (HDstrncmp(interlace, "INTERLACE_PLANE", 15) == 0) {
+ /* Number of color planes is defined as the first dimension */
+ *planes = dims[0];
+ *height = dims[1];
+ *width = dims[2];
+ }
else
- if ( HDstrncmp( interlace, "INTERLACE_PLANE", 15 ) == 0 )
- {
- /* Number of color planes is defined as the first dimension */
- *planes = dims[0];
- *height = dims[1];
- *width = dims[2];
- }
- else return -1;
+ return -1;
}
else
- /* This is a 8 bit image */
+ /* This is a 8 bit image */
{
*height = dims[0];
*width = dims[1];
@@ -337,147 +318,135 @@ herr_t H5IMget_image_info( hid_t loc_id,
}
/* Close */
- if ( H5Sclose( sid ) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
-
/* Get number of palettes */
-
/* 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((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- if((aclass = H5Tget_class(atid)) < 0)
+ if ((aclass = H5Tget_class(atid)) < 0)
goto out;
/* Check if it is really a reference */
- if(aclass == H5T_REFERENCE)
- {
+ if (aclass == H5T_REFERENCE) {
/* Get the reference(s) */
- if ( (asid = H5Aget_space( aid )) < 0)
+ if ((asid = H5Aget_space(aid)) < 0)
goto out;
- *npals = H5Sget_simple_extent_npoints( asid );
+ *npals = H5Sget_simple_extent_npoints(asid);
- if ( H5Sclose( asid ) < 0)
+ if (H5Sclose(asid) < 0)
goto out;
} /* H5T_REFERENCE */
- if ( H5Tclose( atid ) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
/* Close the attribute. */
- if ( H5Aclose( aid ) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
-
}
/* End access to the dataset and release resources used by it. */
- if ( H5Dclose( did ) < 0)
+ if (H5Dclose(did) < 0)
goto out;
return 0;
out:
- if(did > 0)
- H5Dclose( did );
- if(aid > 0)
- H5Aclose( aid );
- if(asid > 0)
- H5Sclose( asid );
- if(atid > 0)
- H5Tclose( atid );
+ if (did > 0)
+ H5Dclose(did);
+ if (aid > 0)
+ H5Aclose(aid);
+ if (asid > 0)
+ H5Sclose(asid);
+ if (atid > 0)
+ 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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMread_image( hid_t loc_id,
- const char *dset_name,
- unsigned char *buf )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMread_image(hid_t loc_id, const char *dset_name, unsigned char *buf)
{
- hid_t did;
+ hid_t did;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ 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, buf ) < 0)
+ 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 ) )
+ if (H5Dclose(did))
return -1;
return 0;
out:
- H5Dclose( did );
+ 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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMmake_palette( hid_t loc_id,
- const char *pal_name,
- const hsize_t *pal_dims,
- const unsigned char *pal_data )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMmake_palette(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, const unsigned char *pal_data)
{
@@ -485,231 +454,221 @@ herr_t H5IMmake_palette( hid_t loc_id,
/* check the arguments */
if (pal_name == NULL)
- return -1;
+ return -1;
/* Check if the dataset already exists */
- has_pal = H5LTfind_dataset( loc_id, pal_name );
+ has_pal = H5LTfind_dataset(loc_id, pal_name);
/* It exists. Return */
- if ( has_pal == 1 )
+ 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 )
+ 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)
+ 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)
+ if (H5LTset_attribute_string(loc_id, pal_name, "PAL_VERSION", "1.2") < 0)
return -1;
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
-*
-* 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 )
+ * 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
+ *
+ * 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)
{
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 */
+ 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;
-
/* check the arguments */
if (image_name == NULL)
- return -1;
+ return -1;
if (pal_name == NULL)
- return -1;
+ return -1;
/* 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 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)
+ 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" );
+ 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)
+ * It does not exist. We create the attribute and one reference
+ *-------------------------------------------------------------------------
+ */
+ if (ok_pal == 0) {
+ if ((asid = H5Screate(H5S_SCALAR)) < 0)
goto out;
/* Create the attribute type for the reference */
- if((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 0)
+ if ((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 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)
+ if ((aid = H5Acreate2(did, "PALETTE", atid, asid, 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, (hid_t)-1) < 0)
+ if (H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0)
goto out;
/* Write the attribute with the reference */
- if(H5Awrite(aid, atid, &ref) < 0)
+ if (H5Awrite(aid, atid, &ref) < 0)
goto out;
/* close */
- if(H5Sclose(asid) < 0)
+ if (H5Sclose(asid) < 0)
goto out;
- if(H5Tclose(atid) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
-
}
/*-------------------------------------------------------------------------
- * The attribute already exists, open it
- *-------------------------------------------------------------------------
- */
- else if(ok_pal == 1)
- {
- if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ * The attribute already exists, open it
+ *-------------------------------------------------------------------------
+ */
+ else if (ok_pal == 1) {
+ if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- if(H5Tget_class(atid) < 0)
+ if (H5Tget_class(atid) < 0)
goto out;
/* Get and save the old reference(s) */
- if((asid = H5Aget_space(aid)) < 0)
+ if ((asid = H5Aget_space(aid)) < 0)
goto out;
n_refs = H5Sget_simple_extent_npoints(asid);
dim_ref = (hsize_t)n_refs + 1;
- refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref );
+ refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref);
- if ( H5Aread( aid, atid, refbuf ) < 0)
+ if (H5Aread(aid, atid, refbuf) < 0)
goto out;
/* The attribute must be deleted, in order to the new one can reflect the changes*/
- if(H5Adelete(did, "PALETTE") < 0)
+ if (H5Adelete(did, "PALETTE") < 0)
goto out;
/* Create a new reference for this palette. */
- if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1 ) < 0)
+ if (H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0)
goto out;
refbuf[n_refs] = ref;
/* Create the data space for the new references */
- if(H5Sclose(asid) < 0)
+ if (H5Sclose(asid) < 0)
goto out;
- if((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0)
+ if ((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0)
goto out;
/* Create the attribute again with the changes of space */
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
- if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* Write the attribute with the new references */
- if(H5Awrite(aid, atid, refbuf) < 0)
+ if (H5Awrite(aid, atid, refbuf) < 0)
goto out;
/* close */
- if(H5Sclose(asid) < 0)
+ if (H5Sclose(asid) < 0)
goto out;
- if(H5Tclose(atid) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
- HDfree( refbuf );
+ HDfree(refbuf);
} /* ok_pal == 1 */
/* Close the image dataset. */
- if ( H5Dclose( did ) < 0)
+ if (H5Dclose(did) < 0)
return -1;
return 0;
out:
- H5Dclose( did );
- H5Sclose( asid );
- H5Tclose( atid );
- H5Aclose( aid );
+ 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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMunlink_palette( hid_t loc_id,
- const char *image_name,
- const char *pal_name )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMunlink_palette(hid_t loc_id, const char *image_name, const char *pal_name)
{
hid_t did;
hid_t atid;
@@ -718,98 +677,94 @@ herr_t H5IMunlink_palette( hid_t loc_id,
int ok_pal, has_pal;
/* check the arguments */
- if(image_name == NULL)
- return -1;
- if(pal_name == NULL)
- return -1;
+ if (image_name == NULL)
+ return -1;
+ if (pal_name == NULL)
+ return -1;
/* Try to find the palette dataset */
- has_pal = H5LTfind_dataset( loc_id, pal_name );
+ has_pal = H5LTfind_dataset(loc_id, pal_name);
/* It does not exist. Return */
- if ( has_pal == 0 )
+ 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
- */
+ * 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)
+ 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. Nothing to do */
- if(ok_pal == 0)
+ if (ok_pal == 0)
return -1;
/* The attribute exists, open it */
- else if(ok_pal == 1)
- {
- if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ else if (ok_pal == 1) {
+ if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- if((aclass = H5Tget_class(atid)) < 0)
+ if ((aclass = H5Tget_class(atid)) < 0)
goto out;
/* Check if it is really a reference */
- if(aclass == H5T_REFERENCE)
- {
+ if (aclass == H5T_REFERENCE) {
/* Delete the attribute */
- if(H5Adelete(did, "PALETTE") < 0)
+ if (H5Adelete(did, "PALETTE") < 0)
goto out;
- } /* H5T_REFERENCE */
+ } /* H5T_REFERENCE */
- if(H5Tclose(atid) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
/* Close the attribute. */
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
} /* ok_pal */
/* Close the image dataset. */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
return -1;
return 0;
out:
- H5Dclose( did );
+ 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:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMget_npalettes( hid_t loc_id,
- const char *image_name,
- hssize_t *npals )
+ * 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)
{
hid_t did;
hid_t atid;
@@ -819,495 +774,469 @@ herr_t H5IMget_npalettes( hid_t loc_id,
int has_pal;
/* check the arguments */
- if(image_name == NULL)
- return -1;
+ if (image_name == NULL)
+ return -1;
/*assume initially we have no palettes attached*/
*npals = 0;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ 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(did);
- if(has_pal == 1 )
- {
+ if (has_pal == 1) {
- if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- if((aclass = H5Tget_class(atid)) < 0)
+ if ((aclass = H5Tget_class(atid)) < 0)
goto out;
/* Check if it is really a reference */
- if(aclass == H5T_REFERENCE)
- {
- if((asid = H5Aget_space(aid)) < 0)
+ if (aclass == H5T_REFERENCE) {
+ if ((asid = H5Aget_space(aid)) < 0)
goto out;
- *npals = H5Sget_simple_extent_npoints( asid );
+ *npals = H5Sget_simple_extent_npoints(asid);
- if ( H5Sclose( asid ) < 0)
+ if (H5Sclose(asid) < 0)
goto out;
} /* H5T_REFERENCE */
- if ( H5Tclose( atid ) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
/* Close the attribute. */
- if ( H5Aclose( aid ) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
-
}
/* Close the image dataset. */
- if ( H5Dclose( did ) < 0)
+ if (H5Dclose(did) < 0)
return -1;
return 0;
out:
- H5Dclose( did );
+ 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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMget_palette_info( hid_t loc_id,
- const char *image_name,
- int pal_number,
- hsize_t *pal_dims )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMget_palette_info(hid_t loc_id, const char *image_name, int pal_number, hsize_t *pal_dims)
{
- 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];
+ 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];
/* check the arguments */
if (image_name == NULL)
- return -1;
+ return -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ 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(did);
- if(has_pal == 1)
- {
- if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ if (has_pal == 1) {
+ if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- if(H5Tget_class(atid) < 0)
+ if (H5Tget_class(atid) < 0)
goto out;
/* Get the reference(s) */
- if((asid = H5Aget_space(aid)) < 0)
+ if ((asid = H5Aget_space(aid)) < 0)
goto out;
n_refs = H5Sget_simple_extent_npoints(asid);
dim_ref = (hsize_t)n_refs;
- refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref );
+ refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref);
- if ( H5Aread( aid, atid, refbuf ) < 0)
+ if (H5Aread(aid, atid, refbuf) < 0)
goto out;
/* Get the actual palette */
- if ( (pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0)
+ if ((pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0)
goto out;
- if ( (pal_space_id = H5Dget_space( pal_id )) < 0)
+ if ((pal_space_id = H5Dget_space(pal_id)) < 0)
goto out;
- if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0)
+ if (H5Sget_simple_extent_ndims(pal_space_id) < 0)
goto out;
- if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0)
+ if (H5Sget_simple_extent_dims(pal_space_id, pal_dims, pal_maxdims) < 0)
goto out;
/* close */
- if (H5Dclose(pal_id)<0)
+ if (H5Dclose(pal_id) < 0)
goto out;
- if ( H5Sclose( pal_space_id ) < 0)
+ if (H5Sclose(pal_space_id) < 0)
goto out;
- if ( H5Sclose( asid ) < 0)
+ if (H5Sclose(asid) < 0)
goto out;
- if ( H5Tclose( atid ) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
- if ( H5Aclose( aid ) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
- HDfree( refbuf );
-
-
+ HDfree(refbuf);
}
/* Close the image dataset. */
- if ( H5Dclose( did ) < 0)
+ if (H5Dclose(did) < 0)
return -1;
return 0;
out:
- H5Dclose( did );
- H5Sclose( asid );
- H5Tclose( atid );
- H5Aclose( aid );
+ 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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMget_palette( hid_t loc_id,
- const char *image_name,
- int pal_number,
- unsigned char *pal_data )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMget_palette(hid_t loc_id, const char *image_name, int pal_number, unsigned char *pal_data)
{
- 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 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;
/* check the arguments */
if (image_name == NULL)
- return -1;
+ return -1;
if (pal_data == NULL)
- return -1;
-
+ return -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
+ 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(did);
- if(has_pal == 1 )
- {
- if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
+ if (has_pal == 1) {
+ if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- if(H5Tget_class(atid) < 0)
+ if (H5Tget_class(atid) < 0)
goto out;
/* Get the reference(s) */
- if((asid = H5Aget_space(aid)) < 0)
+ if ((asid = H5Aget_space(aid)) < 0)
goto out;
n_refs = H5Sget_simple_extent_npoints(asid);
dim_ref = (hsize_t)n_refs;
- refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref );
+ refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref);
- if ( H5Aread( aid, atid, refbuf ) < 0)
+ if (H5Aread(aid, atid, refbuf) < 0)
goto out;
/* Get the palette id */
- if ( (pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0)
+ if ((pal_id = H5Rdereference2(did, H5P_DEFAULT, 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)
+ 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)
+ if (H5Dclose(pal_id) < 0)
goto out;
- if ( H5Sclose( asid ) < 0)
+ if (H5Sclose(asid) < 0)
goto out;
- if ( H5Tclose( atid ) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
- if ( H5Aclose( aid ) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
- HDfree( refbuf );
+ HDfree(refbuf);
}
/* Close the image dataset. */
- if ( H5Dclose( did ) < 0)
+ if (H5Dclose(did) < 0)
return -1;
return 0;
out:
- H5Dclose( did );
- H5Sclose( asid );
- H5Tclose( atid );
- H5Aclose( aid );
+ 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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMis_image( hid_t loc_id,
- const char *dset_name )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMis_image(hid_t loc_id, const char *dset_name)
{
- hid_t did;
- int has_class;
- hid_t atid;
- hid_t aid = -1;
- char* attr_data; /* Name of attribute */
- hsize_t storage_size; /* Size of storage for attribute */
- herr_t ret;
+ hid_t did;
+ int has_class;
+ hid_t atid;
+ hid_t aid = -1;
+ char * attr_data; /* Name of attribute */
+ hsize_t storage_size; /* Size of storage for attribute */
+ herr_t ret;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* Assume initially fail condition */
ret = -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ 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");
- if(has_class == 0)
- {
+ if (has_class == 0) {
H5Dclose(did);
return 0;
}
- else if(has_class == 1)
- {
+ else if (has_class == 1) {
- if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- /* check to make sure attribute is a string */
- if(H5T_STRING != H5Tget_class(atid))
- goto out;
+ /* check to make sure attribute is a string */
+ if (H5T_STRING != H5Tget_class(atid))
+ goto out;
- /* check to make sure string is null-terminated */
- if(H5T_STR_NULLTERM != H5Tget_strpad(atid))
- goto out;
+ /* check to make sure string is null-terminated */
+ if (H5T_STR_NULLTERM != H5Tget_strpad(atid))
+ goto out;
- /* allocate buffer large enough to hold string */
- if((storage_size = H5Aget_storage_size(aid)) == 0)
- goto out;
+ /* allocate buffer large enough to hold string */
+ if ((storage_size = H5Aget_storage_size(aid)) == 0)
+ goto out;
- attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1);
- if(attr_data == NULL)
- goto out;
+ attr_data = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1);
+ if (attr_data == NULL)
+ goto out;
- if(H5Aread(aid, atid, attr_data) < 0)
+ if (H5Aread(aid, atid, attr_data) < 0)
goto out;
- if(HDstrncmp(attr_data, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(attr_data))) == 0)
+ if (HDstrncmp(attr_data, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS), HDstrlen(attr_data))) == 0)
ret = 1;
else
ret = 0;
- HDfree(attr_data);
+ HDfree(attr_data);
- if ( H5Tclose( atid ) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
- if ( H5Aclose( aid ) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
-
}
/* Close the dataset. */
- if ( H5Dclose( did ) < 0)
+ if (H5Dclose(did) < 0)
return -1;
return ret;
out:
- H5Dclose( did );
+ 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
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-
-herr_t H5IMis_palette( hid_t loc_id,
- const char *dset_name )
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5IMis_palette(hid_t loc_id, const char *dset_name)
{
- hid_t did;
- int has_class;
- hid_t atid;
- hid_t aid = -1;
- char* attr_data; /* Name of attribute */
- hsize_t storage_size; /* Size of storage for attribute */
- herr_t ret;
+ hid_t did;
+ int has_class;
+ hid_t atid;
+ hid_t aid = -1;
+ char * attr_data; /* Name of attribute */
+ hsize_t storage_size; /* Size of storage for attribute */
+ herr_t ret;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* Assume initially fail condition */
ret = -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ 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");
- if(has_class == 0)
- {
- H5Dclose( did );
+ if (has_class == 0) {
+ H5Dclose(did);
return 0;
}
- else if(has_class == 1)
- {
+ else if (has_class == 1) {
- if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
+ if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
goto out;
- if((atid = H5Aget_type(aid)) < 0)
+ if ((atid = H5Aget_type(aid)) < 0)
goto out;
- /* check to make sure attribute is a string */
- if(H5T_STRING != H5Tget_class(atid))
- goto out;
+ /* check to make sure attribute is a string */
+ if (H5T_STRING != H5Tget_class(atid))
+ goto out;
- /* check to make sure string is null-terminated */
- if(H5T_STR_NULLTERM != H5Tget_strpad(atid))
- goto out;
+ /* check to make sure string is null-terminated */
+ if (H5T_STR_NULLTERM != H5Tget_strpad(atid))
+ goto out;
- /* allocate buffer large enough to hold string */
- if((storage_size = H5Aget_storage_size(aid)) == 0)
- goto out;
+ /* allocate buffer large enough to hold string */
+ if ((storage_size = H5Aget_storage_size(aid)) == 0)
+ goto out;
- attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1);
- if(attr_data == NULL)
- goto out;
+ attr_data = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1);
+ if (attr_data == NULL)
+ goto out;
- if(H5Aread(aid, atid, attr_data) < 0)
+ if (H5Aread(aid, atid, attr_data) < 0)
goto out;
- if(HDstrncmp(attr_data, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(attr_data))) == 0)
+ if (HDstrncmp(attr_data, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS), HDstrlen(attr_data))) == 0)
ret = 1;
else
ret = 0;
- HDfree(attr_data);
+ HDfree(attr_data);
- if ( H5Tclose( atid ) < 0)
+ if (H5Tclose(atid) < 0)
goto out;
- if ( H5Aclose( aid ) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
-
}
/* Close the dataset. */
- if ( H5Dclose( did ) < 0)
+ if (H5Dclose(did) < 0)
return -1;
return ret;
out:
- H5Dclose( did );
+ H5Dclose(did);
return -1;
-
}
-
diff --git a/hl/src/H5IMprivate.h b/hl/src/H5IMprivate.h
index 6776c9d..0e47509 100644
--- a/hl/src/H5IMprivate.h
+++ b/hl/src/H5IMprivate.h
@@ -20,20 +20,16 @@
/* public IM prototypes */
#include "H5IMpublic.h"
-
#define IMAGE_CLASS "IMAGE"
#define PALETTE_CLASS "PALETTE"
#define IMAGE_VERSION "1.2"
-#define IMAGE8_RANK 2
-#define IMAGE24_RANK 3
-
+#define IMAGE8_RANK 2
+#define IMAGE24_RANK 3
/*-------------------------------------------------------------------------
* Private functions
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5IM_find_palette(hid_t loc_id );
-
+H5_HLDLL herr_t H5IM_find_palette(hid_t loc_id);
#endif
-
diff --git a/hl/src/H5IMpublic.h b/hl/src/H5IMpublic.h
index a95e439..745eade 100644
--- a/hl/src/H5IMpublic.h
+++ b/hl/src/H5IMpublic.h
@@ -14,69 +14,38 @@
#ifndef _H5IMpublic_H
#define _H5IMpublic_H
-
#ifdef __cplusplus
extern "C" {
#endif
+H5_HLDLL herr_t H5IMmake_image_8bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height,
+ const unsigned char *buffer);
+
+H5_HLDLL 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);
+
+H5_HLDLL 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);
+
+H5_HLDLL herr_t H5IMread_image(hid_t loc_id, const char *dset_name, unsigned char *buffer);
+
+H5_HLDLL herr_t H5IMmake_palette(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims,
+ const unsigned char *pal_data);
+
+H5_HLDLL herr_t H5IMlink_palette(hid_t loc_id, const char *image_name, const char *pal_name);
+
+H5_HLDLL herr_t H5IMunlink_palette(hid_t loc_id, const char *image_name, const char *pal_name);
+
+H5_HLDLL herr_t H5IMget_npalettes(hid_t loc_id, const char *image_name, hssize_t *npals);
+
+H5_HLDLL herr_t H5IMget_palette_info(hid_t loc_id, const char *image_name, int pal_number, hsize_t *pal_dims);
+
+H5_HLDLL herr_t H5IMget_palette(hid_t loc_id, const char *image_name, int pal_number,
+ unsigned char *pal_data);
+
+H5_HLDLL herr_t H5IMis_image(hid_t loc_id, const char *dset_name);
-H5_HLDLL herr_t H5IMmake_image_8bit( hid_t loc_id,
- const char *dset_name,
- hsize_t width,
- hsize_t height,
- const unsigned char *buffer );
-
-H5_HLDLL 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 );
-
-H5_HLDLL 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 );
-
-H5_HLDLL herr_t H5IMread_image( hid_t loc_id,
- const char *dset_name,
- unsigned char *buffer );
-
-H5_HLDLL herr_t H5IMmake_palette( hid_t loc_id,
- const char *pal_name,
- const hsize_t *pal_dims,
- const unsigned char *pal_data );
-
-H5_HLDLL herr_t H5IMlink_palette( hid_t loc_id,
- const char *image_name,
- const char *pal_name );
-
-H5_HLDLL herr_t H5IMunlink_palette( hid_t loc_id,
- const char *image_name,
- const char *pal_name );
-
-H5_HLDLL herr_t H5IMget_npalettes( hid_t loc_id,
- const char *image_name,
- hssize_t *npals );
-
-H5_HLDLL herr_t H5IMget_palette_info( hid_t loc_id,
- const char *image_name,
- int pal_number,
- hsize_t *pal_dims );
-
-H5_HLDLL herr_t H5IMget_palette( hid_t loc_id,
- const char *image_name,
- int pal_number,
- unsigned char *pal_data );
-
-H5_HLDLL herr_t H5IMis_image( hid_t loc_id,
- const char *dset_name );
-
-H5_HLDLL herr_t H5IMis_palette( hid_t loc_id,
- const char *dset_name );
+H5_HLDLL herr_t H5IMis_palette(hid_t loc_id, const char *dset_name);
#ifdef __cplusplus
}
diff --git a/hl/src/H5LD.c b/hl/src/H5LD.c
index 3106ea8..7e8dc30 100644
--- a/hl/src/H5LD.c
+++ b/hl/src/H5LD.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string.h>
#include <stdlib.h>
@@ -26,10 +26,9 @@
static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid);
static herr_t H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims);
static size_t H5LD_get_dset_type_size(hid_t did, const char *fields);
-static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims,
- const hsize_t *cur_dims, const char *fields, void *buf);
+static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims,
+ const char *fields, void *buf);
-
/*-------------------------------------------------------------------------
* Function: H5LD_clean_vector
*
@@ -47,30 +46,29 @@ static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims,
void
H5LD_clean_vector(H5LD_memb_t *listv[])
{
- unsigned n; /* Local index variable */
+ unsigned n; /* Local index variable */
HDassert(listv);
/* Go through info for each field stored in listv[] */
- for(n = 0; listv[n] != NULL; n++) {
- if(listv[n]->names) {
- HDfree(listv[n]->names);
- listv[n]->names = NULL;
- } /* end if */
-
- /* Close the type id of the last member in the field */
- if(!(listv[n]->last_tid < 0)) {
- H5Tclose(listv[n]->last_tid);
- listv[n]->last_tid = -1;
- } /* end if */
-
- /* Free the H5LD_memb_t structure for the field */
- HDfree(listv[n]);
- listv[n] = NULL;
+ for (n = 0; listv[n] != NULL; n++) {
+ if (listv[n]->names) {
+ HDfree(listv[n]->names);
+ listv[n]->names = NULL;
+ } /* end if */
+
+ /* Close the type id of the last member in the field */
+ if (!(listv[n]->last_tid < 0)) {
+ H5Tclose(listv[n]->last_tid);
+ listv[n]->last_tid = -1;
+ } /* end if */
+
+ /* Free the H5LD_memb_t structure for the field */
+ HDfree(listv[n]);
+ listv[n] = NULL;
} /* end for */
} /* H5LD_clean_vector() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_construct_info()
*
@@ -89,27 +87,27 @@ H5LD_clean_vector(H5LD_memb_t *listv[])
static herr_t
H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid)
{
- hid_t tmp_tid = -1; /* Dataset type id */
- unsigned i; /* Local index variable */
- herr_t ret_value = FAIL; /* Return value */
+ hid_t tmp_tid = -1; /* Dataset type id */
+ unsigned i; /* Local index variable */
+ herr_t ret_value = FAIL; /* Return value */
/* Make a copy of the incoming datatype */
tmp_tid = H5Tcopy(par_tid);
/* Validate all the members in a field */
- for(i = 0; memb->names[i] != NULL; i++) {
- hid_t memb_tid; /* Type id for a member in a field */
- int idx; /* Index # of a member in a compound datatype */
+ for (i = 0; memb->names[i] != NULL; i++) {
+ hid_t memb_tid; /* Type id for a member in a field */
+ int idx; /* Index # of a member in a compound datatype */
/* Get the member index and member type id */
- if((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0)
+ if ((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0)
goto done;
- if((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0)
+ if ((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0)
goto done;
- /* Sum up the offset of all the members in the field */
+ /* Sum up the offset of all the members in the field */
memb->tot_offset += H5Tget_member_offset(tmp_tid, (unsigned)idx);
- if(H5Tclose(tmp_tid) < 0)
+ if (H5Tclose(tmp_tid) < 0)
goto done;
tmp_tid = memb_tid;
} /* end for */
@@ -125,13 +123,12 @@ H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid)
done:
H5E_BEGIN_TRY
- H5Tclose(tmp_tid);
+ H5Tclose(tmp_tid);
H5E_END_TRY
- return(ret_value);
+ return (ret_value);
} /* H5LD_construct_info() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_construct_vector
*
@@ -157,84 +154,87 @@ done:
*
* Programmer: Vailin Choi; Aug 2010
*
-*-------------------------------------------------------------------------
-*/
+ *-------------------------------------------------------------------------
+ */
int
-H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid)
+H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid)
{
- int nfields; /* The # of comma-separated fields in "fields" */
- hbool_t end_of_fields = FALSE; /* end of "fields" */
- char *fields_ptr; /* Pointer to "fields" */
- int ret_value = FAIL; /* Return value */
+ int nfields; /* The # of comma-separated fields in "fields" */
+ hbool_t end_of_fields = FALSE; /* end of "fields" */
+ char * fields_ptr; /* Pointer to "fields" */
+ int ret_value = FAIL; /* Return value */
HDassert(listv);
HDassert(fields);
fields_ptr = fields;
- nfields = 0;
+ nfields = 0;
/* Process till end of "fields" */
- while(!end_of_fields) {
- H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */
- char *cur; /* Pointer to a member in a field */
- size_t len; /* Estimated # of members in a field */
- hbool_t gotcomma = FALSE; /* A comma encountered */
- hbool_t gotmember = FALSE; /* Getting member in a field */
- hbool_t valid = TRUE; /* Whether a field being processed is valid or not */
- int j = 0; /* The # of members in a field */
-
- len = (HDstrlen(fields_ptr) / 2) + 2;
-
- /* Allocate memory for an H5LD_memb_t for storing a field's info */
- if(NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t))))
- goto done;
-
- /* Allocate memory for an array of pointers to member names */
- if(NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *))))
- goto done;
-
- memb->names[j] = fields_ptr;
- memb->last_tid = -1;
- cur = fields_ptr;
-
- /* Continue processing till: not valid or comma encountered or "fields" ended */
- while(valid && !gotcomma && !end_of_fields) {
- switch(*fields_ptr) {
- case '\0': /* end of list */
- if(gotmember) { /* getting something and end of "fields" */
- *cur++ = '\0';;
+ while (!end_of_fields) {
+ H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */
+ char * cur; /* Pointer to a member in a field */
+ size_t len; /* Estimated # of members in a field */
+ hbool_t gotcomma = FALSE; /* A comma encountered */
+ hbool_t gotmember = FALSE; /* Getting member in a field */
+ hbool_t valid = TRUE; /* Whether a field being processed is valid or not */
+ int j = 0; /* The # of members in a field */
+
+ len = (HDstrlen(fields_ptr) / 2) + 2;
+
+ /* Allocate memory for an H5LD_memb_t for storing a field's info */
+ if (NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t))))
+ goto done;
+
+ /* Allocate memory for an array of pointers to member names */
+ if (NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *))))
+ goto done;
+
+ memb->names[j] = fields_ptr;
+ memb->last_tid = -1;
+ cur = fields_ptr;
+
+ /* Continue processing till: not valid or comma encountered or "fields" ended */
+ while (valid && !gotcomma && !end_of_fields) {
+ switch (*fields_ptr) {
+ case '\0': /* end of list */
+ if (gotmember) { /* getting something and end of "fields" */
+ *cur++ = '\0';
+ ;
memb->names[++j] = NULL;
- } /* end if */
+ } /* end if */
else /* getting nothing but end of list */
valid = FALSE;
end_of_fields = TRUE;
break;
- case '\\': /* escape character */
+ case '\\': /* escape character */
++fields_ptr; /* skip it */
- if(*fields_ptr == '\0')
+ if (*fields_ptr == '\0')
valid = FALSE;
else {
- *cur++ = *fields_ptr++;
+ *cur++ = *fields_ptr++;
gotmember = TRUE;
} /* end else */
break;
case '.': /* nested field separator */
- *fields_ptr++ = *cur++ = '\0';;
- if(gotmember) {
+ *fields_ptr++ = *cur++ = '\0';
+ ;
+ if (gotmember) {
memb->names[++j] = cur;
- gotmember = FALSE;
+ gotmember = FALSE;
} /* end if */
else
valid = FALSE;
break;
case ',': /* field separator */
- *fields_ptr++ = *cur++ = '\0';;
- if(gotmember) {
+ *fields_ptr++ = *cur++ = '\0';
+ ;
+ if (gotmember) {
memb->names[++j] = NULL;
- gotmember = FALSE;
+ gotmember = FALSE;
} /* end if */
else
valid = FALSE;
@@ -242,37 +242,36 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid)
break;
default:
- *cur++ = *fields_ptr++;
+ *cur++ = *fields_ptr++;
gotmember = TRUE;
break;
- } /* end switch */
- } /* while (valid && !gotcomma && !end_of_fields) */
-
- /* If valid, put into listv and continue processing further info */
- if(valid) {
- listv[nfields++] = memb;
- if(H5LD_construct_info(memb, par_tid) < 0)
- goto done;
- } /* end if */
+ } /* end switch */
+ } /* while (valid && !gotcomma && !end_of_fields) */
+
+ /* If valid, put into listv and continue processing further info */
+ if (valid) {
+ listv[nfields++] = memb;
+ if (H5LD_construct_info(memb, par_tid) < 0)
+ goto done;
+ } /* end if */
else {
- if(memb)
+ if (memb)
HDfree(memb);
- goto done;
- } /* end else */
- } /* while !end_of_fields */
+ goto done;
+ } /* end else */
+ } /* while !end_of_fields */
/* Indicate success */
ret_value = nfields;
done:
listv[nfields] = NULL;
- if(ret_value == FAIL)
- H5LD_clean_vector(listv);
+ if (ret_value == FAIL)
+ H5LD_clean_vector(listv);
- return(ret_value);
-} /* H5LD_construct_vector() */
+ return (ret_value);
+} /* H5LD_construct_vector() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_get_dset_dims
*
@@ -284,38 +283,39 @@ done:
*
* Programmer: Vailin Choi; March 2010
*
-*-------------------------------------------------------------------------
-*/
+ *-------------------------------------------------------------------------
+ */
static herr_t
H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims)
{
- hid_t sid = -1; /* Dataspace ID */
- herr_t ret_value = FAIL; /* Return Value */
+ hid_t sid = -1; /* Dataspace ID */
+ herr_t ret_value = FAIL; /* Return Value */
/* Verify parameter */
- if(cur_dims == NULL)
+ if (cur_dims == NULL)
goto done;
/* Get the dataset's dataspace */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto done;
/* Get the current dimension size */
- if(H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0)
goto done;
/* Indicate success */
ret_value = SUCCEED;
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- return(ret_value);
+ return (ret_value);
} /* H5LD_get_dset_dims() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_get_dset_type_size
*
@@ -334,73 +334,72 @@ done:
static size_t
H5LD_get_dset_type_size(hid_t did, const char *fields)
{
- hid_t dset_tid = -1; /* Dataset's type identifier */
- hid_t tid = -1; /* Native Type identifier */
- H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
- char *dup_fields = NULL; /* A copy of "fields" */
- size_t ret_value = 0; /* Return value */
+ hid_t dset_tid = -1; /* Dataset's type identifier */
+ hid_t tid = -1; /* Native Type identifier */
+ H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
+ char * dup_fields = NULL; /* A copy of "fields" */
+ size_t ret_value = 0; /* Return value */
/* Get the datatype of the dataset */
- if((dset_tid = H5Dget_type(did)) < 0)
+ if ((dset_tid = H5Dget_type(did)) < 0)
goto done;
- if((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0)
+ if ((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0)
goto done;
- if(fields == NULL) /* If no "fields" is specified */
+ if (fields == NULL) /* If no "fields" is specified */
ret_value = H5Tget_size(tid);
- else { /* "fields" are specified */
- size_t len; /* Estimate the number of comma-separated fields in "fields" */
- size_t tot = 0; /* Data type size of all the fields in "fields" */
- int n = 0, num = 0; /* Local index variables */
+ else { /* "fields" are specified */
+ size_t len; /* Estimate the number of comma-separated fields in "fields" */
+ size_t tot = 0; /* Data type size of all the fields in "fields" */
+ int n = 0, num = 0; /* Local index variables */
HDassert(fields && *fields);
/* Should be a compound datatype if "fields" exists */
- if(H5Tget_class(dset_tid) != H5T_COMPOUND)
+ if (H5Tget_class(dset_tid) != H5T_COMPOUND)
goto done;
- /* Get a copy of "fields" */
- if(NULL == (dup_fields = HDstrdup(fields)))
+ /* Get a copy of "fields" */
+ if (NULL == (dup_fields = HDstrdup(fields)))
goto done;
- /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */
- len = (HDstrlen(fields) / 2) + 2;
- if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
+ /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */
+ len = (HDstrlen(fields) / 2) + 2;
+ if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
goto done;
- /* Process and store info for "fields" */
- if((num = H5LD_construct_vector(dup_fields, listv/*OUT*/, tid)) < 0)
+ /* Process and store info for "fields" */
+ if ((num = H5LD_construct_vector(dup_fields, listv /*OUT*/, tid)) < 0)
goto done;
- /* Sum up the size of all the datatypes in "fields" */
- for(n = 0; n < num; n++)
- tot += listv[n]->last_tsize;
+ /* Sum up the size of all the datatypes in "fields" */
+ for (n = 0; n < num; n++)
+ tot += listv[n]->last_tsize;
- /* Clean up the vector of H5LD_memb_t structures */
- H5LD_clean_vector(listv);
+ /* Clean up the vector of H5LD_memb_t structures */
+ H5LD_clean_vector(listv);
- /* Return the total size */
- ret_value = tot;
+ /* Return the total size */
+ ret_value = tot;
} /* end else */
done:
H5E_BEGIN_TRY
- H5Tclose(tid);
- H5Tclose(dset_tid);
+ H5Tclose(tid);
+ H5Tclose(dset_tid);
H5E_END_TRY
/* Free the array of H5LD_memb_t pointers */
- if(listv)
+ if (listv)
HDfree(listv);
/* Free memory */
- if(dup_fields)
+ if (dup_fields)
HDfree(dup_fields);
- return(ret_value);
+ return (ret_value);
} /* H5LD_get_dset_type_size() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_get_dset_elmts
*
@@ -414,136 +413,136 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims,
- const char *fields, void *buf)
+H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields,
+ void *buf)
{
- hid_t dtid = -1, tid = -1; /* Dataset type id */
- hid_t sid = -1, mid = -1; /* Dataspace and memory space id */
- hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */
- hsize_t num_elmts; /* Number of dataset elements in the selection */
- hsize_t start[H5S_MAX_RANK];/* Starting offset */
- hsize_t count[H5S_MAX_RANK];/* ??offset */
- H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
- char *dup_fields = NULL; /* A copy of "fields" */
- char *sav_buf = NULL; /* Saved pointer temporary buffer */
- unsigned ctr; /* Counter for # of curr_dims > prev_dims */
- int ndims; /* Number of dimensions for the dataset */
- int i; /* Local index variable */
- herr_t ret_value = FAIL; /* Return value */
+ hid_t dtid = -1, tid = -1; /* Dataset type id */
+ hid_t sid = -1, mid = -1; /* Dataspace and memory space id */
+ hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */
+ hsize_t num_elmts; /* Number of dataset elements in the selection */
+ hsize_t start[H5S_MAX_RANK]; /* Starting offset */
+ hsize_t count[H5S_MAX_RANK]; /* ??offset */
+ H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
+ char * dup_fields = NULL; /* A copy of "fields" */
+ char * sav_buf = NULL; /* Saved pointer temporary buffer */
+ unsigned ctr; /* Counter for # of curr_dims > prev_dims */
+ int ndims; /* Number of dimensions for the dataset */
+ int i; /* Local index variable */
+ herr_t ret_value = FAIL; /* Return value */
/* Verify parameters */
- if(prev_dims == NULL || cur_dims == NULL || buf == NULL)
- goto done;
+ if (prev_dims == NULL || cur_dims == NULL || buf == NULL)
+ goto done;
/* Get dataset's dataspace */
- if((sid = H5Dget_space(did)) < 0)
- goto done;
+ if ((sid = H5Dget_space(did)) < 0)
+ goto done;
/* Get the number of dimensions */
- if((ndims = H5Sget_simple_extent_ndims(sid)) < 0)
- goto done;
+ if ((ndims = H5Sget_simple_extent_ndims(sid)) < 0)
+ goto done;
/* Verify that cur_dims must have one dimension whose size is greater than prev_dims */
HDmemset(start, 0, sizeof start);
HDmemset(count, 0, sizeof count);
ctr = 0;
- for(i = 0; i < ndims; i++)
- if(cur_dims[i] > prev_dims[i]) {
- ++ctr;
- count[i] = cur_dims[i] - prev_dims[i];
- start[i] = prev_dims[i];
- } /* end if */
+ for (i = 0; i < ndims; i++)
+ if (cur_dims[i] > prev_dims[i]) {
+ ++ctr;
+ count[i] = cur_dims[i] - prev_dims[i];
+ start[i] = prev_dims[i];
+ } /* end if */
else { /* < or = */
- start[i] = 0;
- count[i] = MIN(prev_dims[i], cur_dims[i]);
- } /* end else */
- if(!ctr)
- goto done;
-
- if(ctr == 1) { /* changes for only one dimension */
- /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
- goto done;
- } /* end if */
+ start[i] = 0;
+ count[i] = MIN(prev_dims[i], cur_dims[i]);
+ } /* end else */
+ if (!ctr)
+ goto done;
+
+ if (ctr == 1) { /* changes for only one dimension */
+ /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ goto done;
+ } /* end if */
else { /* changes for more than one dimensions */
- HDmemset(start, 0, sizeof start);
+ HDmemset(start, 0, sizeof start);
- /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0)
- goto done;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0)
- goto done;
+ /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0)
+ goto done;
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0)
+ goto done;
} /* end else */
/* Get the number of elements in the selection */
- if(0 == (snum_elmts = H5Sget_select_npoints(sid)))
+ if (0 == (snum_elmts = H5Sget_select_npoints(sid)))
goto done;
num_elmts = (hsize_t)snum_elmts;
/* Create the memory space for the selection */
- if((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0)
- goto done;
+ if ((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0)
+ goto done;
/* Get the native datatype size */
- if((dtid = H5Dget_type(did)) < 0)
+ if ((dtid = H5Dget_type(did)) < 0)
goto done;
- if((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0)
+ if ((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0)
goto done;
- if(fields == NULL) { /* nothing in "fields" */
- /* Read and store all the elements in "buf" */
- if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0)
- goto done;
- } /* end if */
- else { /* "fields" is specified */
- unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */
- char *tmp_buf; /* Temporary buffer for data read */
- size_t tot_tsize; /* Total datatype size */
- size_t len; /* Estimate the number of comma-separated fields in "fields" */
-
- /* should be a compound datatype if "fields" exists */
- if(H5Tget_class(tid) != H5T_COMPOUND)
- goto done;
-
- /* Get the total size of the dataset's datatypes */
- if(0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL)))
- goto done;
-
- /* Allocate memory for reading in the elements in the dataset selection */
- if(NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize)))
- goto done;
-
- /* Read the dataset elements in the selection */
- if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0)
- goto done;
-
- /* Make a copy of "fields" */
- if(NULL == (dup_fields = HDstrdup(fields)))
- goto done;
-
- /* Allocate memory for the vector of H5LD_memb_t pointers */
- len = (HDstrlen(fields) / 2) + 2;
- if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
- goto done;
-
- /* Process and store information for "fields" */
- if(H5LD_construct_vector(dup_fields, listv, tid) < 0)
+ if (fields == NULL) { /* nothing in "fields" */
+ /* Read and store all the elements in "buf" */
+ if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0)
+ goto done;
+ } /* end if */
+ else { /* "fields" is specified */
+ unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */
+ char * tmp_buf; /* Temporary buffer for data read */
+ size_t tot_tsize; /* Total datatype size */
+ size_t len; /* Estimate the number of comma-separated fields in "fields" */
+
+ /* should be a compound datatype if "fields" exists */
+ if (H5Tget_class(tid) != H5T_COMPOUND)
goto done;
- /* Copy data for each dataset element in the selection */
- for(i = 0; i < (int)num_elmts; i++) {
- int j; /* Local index variable */
+ /* Get the total size of the dataset's datatypes */
+ if (0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL)))
+ goto done;
- /* Copy data for "fields" to the input buffer */
- for(j = 0; listv[j] != NULL; j++) {
- HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize);
- buf_p += listv[j]->last_tsize;
- } /* end for */
- tmp_buf += tot_tsize;
- } /* end for */
+ /* Allocate memory for reading in the elements in the dataset selection */
+ if (NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize)))
+ goto done;
+
+ /* Read the dataset elements in the selection */
+ if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0)
+ goto done;
+
+ /* Make a copy of "fields" */
+ if (NULL == (dup_fields = HDstrdup(fields)))
+ goto done;
- /* Clean up the vector of H5LD_memb_t structures */
- H5LD_clean_vector(listv);
+ /* Allocate memory for the vector of H5LD_memb_t pointers */
+ len = (HDstrlen(fields) / 2) + 2;
+ if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
+ goto done;
+
+ /* Process and store information for "fields" */
+ if (H5LD_construct_vector(dup_fields, listv, tid) < 0)
+ goto done;
+
+ /* Copy data for each dataset element in the selection */
+ for (i = 0; i < (int)num_elmts; i++) {
+ int j; /* Local index variable */
+
+ /* Copy data for "fields" to the input buffer */
+ for (j = 0; listv[j] != NULL; j++) {
+ HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize);
+ buf_p += listv[j]->last_tsize;
+ } /* end for */
+ tmp_buf += tot_tsize;
+ } /* end for */
+
+ /* Clean up the vector of H5LD_memb_t structures */
+ H5LD_clean_vector(listv);
} /* end else */
/* Indicate success */
@@ -551,23 +550,23 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims
done:
H5E_BEGIN_TRY
- H5Tclose(dtid);
- H5Tclose(tid);
- H5Sclose(sid);
- H5Sclose(mid);
+ H5Tclose(dtid);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Sclose(mid);
H5E_END_TRY
/* Free the array of H5LD_memb_t pointers */
- if(listv)
+ if (listv)
HDfree(listv);
/* Free memory */
- if(dup_fields)
+ if (dup_fields)
HDfree(dup_fields);
- if(sav_buf)
+ if (sav_buf)
HDfree(sav_buf);
- return(ret_value);
+ return (ret_value);
} /* H5LD_get_dset_elmts() */
/*-------------------------------------------------------------------------
@@ -577,7 +576,6 @@ done:
*-------------------------------------------------------------------------
*/
-
/*-------------------------------------------------------------------------
* Function: H5LDget_dset_dims
*
@@ -593,11 +591,9 @@ done:
herr_t
H5LDget_dset_dims(hid_t did, hsize_t *cur_dims)
{
- return(H5LD_get_dset_dims(did, cur_dims));
+ return (H5LD_get_dset_dims(did, cur_dims));
} /* H5LDget_dset_dims() */
-
-
/*-------------------------------------------------------------------------
* Function: H5LDget_dset_type_size
*
@@ -613,10 +609,9 @@ H5LDget_dset_dims(hid_t did, hsize_t *cur_dims)
size_t
H5LDget_dset_type_size(hid_t did, const char *fields)
{
- return(H5LD_get_dset_type_size(did, fields));
+ return (H5LD_get_dset_type_size(did, fields));
} /* H5LDget_dset_type_size() */
-
/*-------------------------------------------------------------------------
* Function: H5LDget_dset_elmts
*
@@ -630,8 +625,8 @@ H5LDget_dset_type_size(hid_t did, const char *fields)
*-------------------------------------------------------------------------
*/
herr_t
-H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf)
+H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields,
+ void *buf)
{
- return(H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf) );
+ return (H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf));
} /* H5LDget_dset_elmts() */
-
diff --git a/hl/src/H5LDprivate.h b/hl/src/H5LDprivate.h
index 203bcea..f499adc 100644
--- a/hl/src/H5LDprivate.h
+++ b/hl/src/H5LDprivate.h
@@ -26,7 +26,7 @@
typedef struct H5LD_memb_t {
size_t tot_offset;
size_t last_tsize;
- hid_t last_tid;
+ hid_t last_tid;
char **names;
} H5LD_memb_t;
@@ -44,11 +44,10 @@ extern "C" {
* Decide to do #3 at this point of time after some discussion.
*/
H5_HLDLL void H5LD_clean_vector(H5LD_memb_t *listv[]);
-H5_HLDLL int H5LD_construct_vector(char *fields, H5LD_memb_t *listv[], hid_t par_tid);
+H5_HLDLL int H5LD_construct_vector(char *fields, H5LD_memb_t *listv[], hid_t par_tid);
#ifdef __cplusplus
}
#endif
#endif /* end _H5LDprivate_H */
-
diff --git a/hl/src/H5LDpublic.h b/hl/src/H5LDpublic.h
index e2bb745..43ea97b 100644
--- a/hl/src/H5LDpublic.h
+++ b/hl/src/H5LDpublic.h
@@ -20,12 +20,11 @@ extern "C" {
H5_HLDLL herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims);
H5_HLDLL size_t H5LDget_dset_type_size(hid_t did, const char *fields);
-H5_HLDLL herr_t H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims,
- const hsize_t *cur_dims, const char *fields, void *buf);
+H5_HLDLL herr_t H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims,
+ const char *fields, void *buf);
#ifdef __cplusplus
}
#endif
#endif /* _H5LDpublic_H */
-
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index a631533..dce7421 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <assert.h>
#include <stdio.h>
@@ -19,15 +19,14 @@
#include "H5LTprivate.h"
/* For Lex and Yacc */
-#define COL 3
-#define LIMIT 512
-#define INCREMENT 1024
-#define TMP_LEN 256
-#define MAX(a,b) (((a)>(b)) ? (a) : (b))
-size_t input_len;
-char *myinput;
-size_t indent = 0;
-
+#define COL 3
+#define LIMIT 512
+#define INCREMENT 1024
+#define TMP_LEN 256
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+size_t input_len;
+char * myinput;
+size_t indent = 0;
/* File Image operations
@@ -63,58 +62,58 @@ size_t indent = 0;
/* Data structure to pass application data to callbacks. */
typedef struct {
- void *app_image_ptr; /* Pointer to application buffer */
- size_t app_image_size; /* Size of application buffer */
- void *fapl_image_ptr; /* Pointer to FAPL buffer */
- size_t fapl_image_size; /* Size of FAPL buffer */
- int fapl_ref_count; /* Reference counter for FAPL buffer */
- void *vfd_image_ptr; /* Pointer to VFD buffer */
- size_t vfd_image_size; /* Size of VFD buffer */
- int vfd_ref_count; /* Reference counter for VFD buffer */
- unsigned flags; /* Flags indicate how the file image will */
- /* be open */
- int ref_count; /* Reference counter on udata struct */
+ void * app_image_ptr; /* Pointer to application buffer */
+ size_t app_image_size; /* Size of application buffer */
+ void * fapl_image_ptr; /* Pointer to FAPL buffer */
+ size_t fapl_image_size; /* Size of FAPL buffer */
+ int fapl_ref_count; /* Reference counter for FAPL buffer */
+ void * vfd_image_ptr; /* Pointer to VFD buffer */
+ size_t vfd_image_size; /* Size of VFD buffer */
+ int vfd_ref_count; /* Reference counter for VFD buffer */
+ unsigned flags; /* Flags indicate how the file image will */
+ /* be open */
+ int ref_count; /* Reference counter on udata struct */
} H5LT_file_image_ud_t;
/* callbacks prototypes for file image ops */
-static void *image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata);
-static void *image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata);
-static void *image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata);
+static void * image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata);
+static void * image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op,
+ void *udata);
+static void * image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata);
static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *udata);
-static void *udata_copy(void *udata);
+static void * udata_copy(void *udata);
static herr_t udata_free(void *udata);
/* Definition of callbacks for file image operations. */
-
-/*-------------------------------------------------------------------------
-* Function: image_malloc
-*
-* Purpose: Simulates malloc() function to avoid copying file images.
-* The application buffer is set to the buffer on only one FAPL.
-* Then the FAPL buffer can be copied to other FAPL buffers or
-* to only one VFD buffer.
-*
-* Return: Address of "allocated" buffer, if successful. Otherwise, it returns
-* NULL.
-*
-* Programmer: Christian Chilan
-*
-* Date: October 3, 2011
-*
-*-------------------------------------------------------------------------
-*/
+/*-------------------------------------------------------------------------
+ * Function: image_malloc
+ *
+ * Purpose: Simulates malloc() function to avoid copying file images.
+ * The application buffer is set to the buffer on only one FAPL.
+ * Then the FAPL buffer can be copied to other FAPL buffers or
+ * to only one VFD buffer.
+ *
+ * Return: Address of "allocated" buffer, if successful. Otherwise, it returns
+ * NULL.
+ *
+ * Programmer: Christian Chilan
+ *
+ * Date: October 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
static void *
image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata)
{
- H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata;
- void * return_value = NULL;
+ H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata;
+ void * return_value = NULL;
/* callback is only used if the application buffer is not actually copied */
if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY))
goto out;
- switch ( file_image_op ) {
+ switch (file_image_op) {
/* the app buffer is "copied" to only one FAPL. Afterwards, FAPLs can be "copied" */
case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET:
if (udata->app_image_ptr == NULL)
@@ -128,13 +127,13 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata)
if (udata->fapl_ref_count != 0)
goto out;
- udata->fapl_image_ptr = udata->app_image_ptr;
+ udata->fapl_image_ptr = udata->app_image_ptr;
udata->fapl_image_size = udata->app_image_size;
- return_value = udata->fapl_image_ptr;
+ return_value = udata->fapl_image_ptr;
udata->fapl_ref_count++;
- break;
+ break;
- case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY:
+ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY:
if (udata->fapl_image_ptr == NULL)
goto out;
if (udata->fapl_image_size != size)
@@ -144,7 +143,7 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata)
return_value = udata->fapl_image_ptr;
udata->fapl_ref_count++;
- break;
+ break;
case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET:
goto out;
@@ -164,48 +163,46 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata)
if (udata->fapl_ref_count == 0)
goto out;
- udata->vfd_image_ptr = udata->fapl_image_ptr;
- udata->vfd_image_size = size;
+ udata->vfd_image_ptr = udata->fapl_image_ptr;
+ udata->vfd_image_size = size;
udata->vfd_ref_count++;
return_value = udata->vfd_image_ptr;
break;
- /* added unused labels to shut the compiler up */
- case H5FD_FILE_IMAGE_OP_NO_OP:
- case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE:
- case H5FD_FILE_IMAGE_OP_FILE_RESIZE:
- case H5FD_FILE_IMAGE_OP_FILE_CLOSE:
+ /* added unused labels to shut the compiler up */
+ case H5FD_FILE_IMAGE_OP_NO_OP:
+ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE:
+ case H5FD_FILE_IMAGE_OP_FILE_RESIZE:
+ case H5FD_FILE_IMAGE_OP_FILE_CLOSE:
default:
goto out;
} /* end switch */
- return(return_value);
+ return (return_value);
out:
return NULL;
} /* end image_malloc() */
-
-/*-------------------------------------------------------------------------
-* Function: image_memcpy
-*
-* Purpose: Simulates memcpy() function to avoid copying file images.
-* The image buffer can be set to only one FAPL buffer, and
-* "copied" to only one VFD buffer. The FAPL buffer can be
-* "copied" to other FAPLs buffers.
-*
-* Return: The address of the destination buffer, if successful. Otherwise, it
-* returns NULL.
-*
-* Programmer: Christian Chilan
-*
-* Date: October 3, 2011
-*
-*-------------------------------------------------------------------------
-*/
+/*-------------------------------------------------------------------------
+ * Function: image_memcpy
+ *
+ * Purpose: Simulates memcpy() function to avoid copying file images.
+ * The image buffer can be set to only one FAPL buffer, and
+ * "copied" to only one VFD buffer. The FAPL buffer can be
+ * "copied" to other FAPLs buffers.
+ *
+ * Return: The address of the destination buffer, if successful. Otherwise, it
+ * returns NULL.
+ *
+ * Programmer: Christian Chilan
+ *
+ * Date: October 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
static void *
-image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op,
- void *_udata)
+image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *_udata)
{
H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata;
@@ -213,7 +210,7 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file
if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY))
goto out;
- switch(file_image_op) {
+ switch (file_image_op) {
case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET:
if (dest != udata->fapl_image_ptr)
goto out;
@@ -256,42 +253,41 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file
goto out;
break;
- /* added unused labels to shut the compiler up */
- case H5FD_FILE_IMAGE_OP_NO_OP:
- case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE:
- case H5FD_FILE_IMAGE_OP_FILE_RESIZE:
- case H5FD_FILE_IMAGE_OP_FILE_CLOSE:
+ /* added unused labels to shut the compiler up */
+ case H5FD_FILE_IMAGE_OP_NO_OP:
+ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE:
+ case H5FD_FILE_IMAGE_OP_FILE_RESIZE:
+ case H5FD_FILE_IMAGE_OP_FILE_CLOSE:
default:
goto out;
} /* end switch */
- return(dest);
+ return (dest);
out:
return NULL;
} /* end image_memcpy() */
-
-/*-------------------------------------------------------------------------
-* Function: image_realloc
-*
-* Purpose: Reallocates the shared application image buffer and updates data
-* structures that manage buffer "copying".
-*
-* Return: Address of reallocated buffer, if successful. Otherwise, it returns
-* NULL.
-*
-* Programmer: Christian Chilan
-*
-* Date: October 3, 2011
-*
-*-------------------------------------------------------------------------
-*/
+/*-------------------------------------------------------------------------
+ * Function: image_realloc
+ *
+ * Purpose: Reallocates the shared application image buffer and updates data
+ * structures that manage buffer "copying".
+ *
+ * Return: Address of reallocated buffer, if successful. Otherwise, it returns
+ * NULL.
+ *
+ * Programmer: Christian Chilan
+ *
+ * Date: October 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
static void *
image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *_udata)
{
- H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata;
- void * return_value = NULL;
+ H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata;
+ void * return_value = NULL;
/* callback is only used if the application buffer is not actually copied */
if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY))
@@ -318,33 +314,32 @@ image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *
goto out;
udata->vfd_image_size = size;
- return_value = udata->vfd_image_ptr;
+ return_value = udata->vfd_image_ptr;
} /* end if */
else
goto out;
- return(return_value);
+ return (return_value);
out:
return NULL;
} /* end image_realloc() */
-
/*-------------------------------------------------------------------------
-* Function: image_free
-*
-* Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing
-* reference counters. Shared application buffer is actually
-* deallocated if there are no outstanding references.
-*
-* Return: SUCCEED or FAIL
-*
-* Programmer: Christian Chilan
-*
-* Date: October 3, 2011
-*
-*-------------------------------------------------------------------------
-*/
+ * Function: image_free
+ *
+ * Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing
+ * reference counters. Shared application buffer is actually
+ * deallocated if there are no outstanding references.
+ *
+ * Return: SUCCEED or FAIL
+ *
+ * Programmer: Christian Chilan
+ *
+ * Date: October 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata)
{
@@ -354,22 +349,23 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata)
if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY))
goto out;
- switch(file_image_op) {
+ switch (file_image_op) {
case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE:
- if (udata->fapl_image_ptr != ptr)
+ if (udata->fapl_image_ptr != ptr)
goto out;
if (udata->fapl_ref_count == 0)
goto out;
udata->fapl_ref_count--;
- /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */
+ /* release the shared buffer only if indicated by the respective flag and there are no outstanding
+ * references */
if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 &&
- !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) {
+ !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) {
HDfree(udata->fapl_image_ptr);
- udata->app_image_ptr = NULL;
+ udata->app_image_ptr = NULL;
udata->fapl_image_ptr = NULL;
- udata->vfd_image_ptr = NULL;
+ udata->vfd_image_ptr = NULL;
} /* end if */
break;
@@ -381,49 +377,49 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata)
udata->vfd_ref_count--;
- /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */
+ /* release the shared buffer only if indicated by the respective flag and there are no outstanding
+ * references */
if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 &&
- !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) {
+ !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) {
HDfree(udata->vfd_image_ptr);
- udata->app_image_ptr = NULL;
+ udata->app_image_ptr = NULL;
udata->fapl_image_ptr = NULL;
- udata->vfd_image_ptr = NULL;
+ udata->vfd_image_ptr = NULL;
} /* end if */
break;
- /* added unused labels to keep the compiler quite */
- case H5FD_FILE_IMAGE_OP_NO_OP:
- case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET:
- case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY:
- case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET:
- case H5FD_FILE_IMAGE_OP_FILE_OPEN:
- case H5FD_FILE_IMAGE_OP_FILE_RESIZE:
- default:
+ /* added unused labels to keep the compiler quite */
+ case H5FD_FILE_IMAGE_OP_NO_OP:
+ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET:
+ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY:
+ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET:
+ case H5FD_FILE_IMAGE_OP_FILE_OPEN:
+ case H5FD_FILE_IMAGE_OP_FILE_RESIZE:
+ default:
goto out;
} /* end switch */
- return(SUCCEED);
+ return (SUCCEED);
out:
- return(FAIL);
+ return (FAIL);
} /* end image_free() */
-
-/*-------------------------------------------------------------------------
-* Function: udata_copy
-*
-* Purpose: Simulates the copying of the user data structure utilized in the
-* management of the "copying" of file images.
-*
-* Return: Address of "newly allocated" structure, if successful. Otherwise, it
-* returns NULL.
-*
-* Programmer: Christian Chilan
-*
-* Date: October 3, 2011
-*
-*-------------------------------------------------------------------------
-*/
+/*-------------------------------------------------------------------------
+ * Function: udata_copy
+ *
+ * Purpose: Simulates the copying of the user data structure utilized in the
+ * management of the "copying" of file images.
+ *
+ * Return: Address of "newly allocated" structure, if successful. Otherwise, it
+ * returns NULL.
+ *
+ * Programmer: Christian Chilan
+ *
+ * Date: October 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
static void *
udata_copy(void *_udata)
{
@@ -437,28 +433,27 @@ udata_copy(void *_udata)
udata->ref_count++;
- return(udata);
+ return (udata);
out:
return NULL;
} /* end udata_copy */
-
/*-------------------------------------------------------------------------
-* Function: udata_free
-*
-* Purpose: Simulates deallocation of the user data structure utilized in the
-* management of the "copying" of file images. The data structure is
-* actually deallocated when there are no outstanding references.
-*
-* Return: SUCCEED or FAIL
-*
-* Programmer: Christian Chilan
-*
-* Date: October 3, 2011
-*
-*-------------------------------------------------------------------------
-*/
+ * Function: udata_free
+ *
+ * Purpose: Simulates deallocation of the user data structure utilized in the
+ * management of the "copying" of file images. The data structure is
+ * actually deallocated when there are no outstanding references.
+ *
+ * Return: SUCCEED or FAIL
+ *
+ * Programmer: Christian Chilan
+ *
+ * Date: October 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
udata_free(void *_udata)
{
@@ -473,409 +468,370 @@ udata_free(void *_udata)
udata->ref_count--;
/* checks that there are no references outstanding before deallocating udata */
- if (udata->ref_count == 0 && udata->fapl_ref_count == 0 &&
- udata->vfd_ref_count == 0)
+ if (udata->ref_count == 0 && udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0)
HDfree(udata);
- return(SUCCEED);
+ return (SUCCEED);
out:
- return(FAIL);
+ return (FAIL);
} /* end udata_free */
/* End of callbacks definitions for file image operations */
/*-------------------------------------------------------------------------
-*
-* 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
-*
-*-------------------------------------------------------------------------
-*/
+ *
+ * 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
+ *
+ * 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 )
+H5LT_make_dataset_numerical(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid,
+ const void *data)
{
- hid_t did = -1, sid = -1;
+ hid_t did = -1, sid = -1;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* Create the data space for the dataset. */
- if((sid = H5Screate_simple(rank, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
return -1;
/* Create the dataset. */
- if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* Write the dataset only if there is data to write */
- if(data)
- if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ if (data)
+ if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
goto out;
/* End access to the dataset and release resources used by it. */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
return -1;
/* Terminate access to the data space. */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
return -1;
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Sclose(sid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return -1;
}
/*-------------------------------------------------------------------------
-*
-* Public functions
-*
-*-------------------------------------------------------------------------
-*/
+ *
+ * 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:
-*
-*
-*-------------------------------------------------------------------------
-*/
+ * Function: H5LTmake_dataset
+ *
+ * Purpose: Creates and writes a dataset of a type tid
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * 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 )
+herr_t
+H5LTmake_dataset(hid_t loc_id, 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));
+ 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
+ *
+ * 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 )
+herr_t
+H5LTmake_dataset_char(hid_t loc_id, 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));
+ 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
+ *
+ * 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 )
+herr_t
+H5LTmake_dataset_short(hid_t loc_id, 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));
+ 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
+ *
+ * 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 )
+herr_t
+H5LTmake_dataset_int(hid_t loc_id, 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));
+ return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data));
}
-
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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 )
+herr_t
+H5LTmake_dataset_long(hid_t loc_id, 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));
+ 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
+ *
+ * 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 )
+herr_t
+H5LTmake_dataset_float(hid_t loc_id, 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));
+ return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data));
}
-
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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 )
+herr_t
+H5LTmake_dataset_double(hid_t loc_id, 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));
+ 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
+ *
+ * Date: October 05, 2004
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTmake_dataset_string(hid_t loc_id,
- const char *dset_name,
- const char *buf )
+herr_t
+H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf)
{
- hid_t did = -1;
- hid_t sid = -1;
- hid_t tid = -1;
- size_t size;
+ hid_t did = -1;
+ hid_t sid = -1;
+ hid_t tid = -1;
+ size_t size;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* create a string data type */
- if((tid = H5Tcopy(H5T_C_S1)) < 0 )
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
goto out;
size = HDstrlen(buf) + 1; /* extra null term */
- if(H5Tset_size(tid, size) < 0)
+ if (H5Tset_size(tid, size) < 0)
goto out;
- if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0)
+ if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0)
goto out;
/* Create the data space for the dataset. */
- if((sid = H5Screate(H5S_SCALAR)) < 0)
+ if ((sid = H5Screate(H5S_SCALAR)) < 0)
goto out;
/* Create the dataset. */
- if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* Write the dataset only if there is data to write */
- if(buf)
- if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if (buf)
+ if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
/* close*/
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
return -1;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
return -1;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Tclose(tid);
H5Sclose(sid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return -1;
}
-
-/*-------------------------------------------------------------------------
-* Function: H5LTopen_file_image
-*
-* Purpose: Open a user supplied file image using the core file driver.
-*
-* Return: File identifier, Failure: -1
-*
-* Programmer: Christian Chilan
-*
-* Date: October 3, 2011
-*
-*-------------------------------------------------------------------------
-*/
-hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags)
-{
- hid_t fapl=-1, file_id=-1; /* HDF5 identifiers */
- unsigned file_open_flags; /* Flags for image open */
- char file_name[64]; /* Filename buffer */
- size_t alloc_incr; /* Buffer allocation increment */
- size_t min_incr = 65536; /* Minimum buffer increment */
- double buf_prcnt = 0.1f; /* Percentage of buffer size to set
- as increment */
- static long file_name_counter;
- H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy,
- &image_realloc, &image_free,
- &udata_copy, &udata_free,
- (void *)NULL};
+/*-------------------------------------------------------------------------
+ * Function: H5LTopen_file_image
+ *
+ * Purpose: Open a user supplied file image using the core file driver.
+ *
+ * Return: File identifier, Failure: -1
+ *
+ * Programmer: Christian Chilan
+ *
+ * Date: October 3, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags)
+{
+ hid_t fapl = -1, file_id = -1; /* HDF5 identifiers */
+ unsigned file_open_flags; /* Flags for image open */
+ char file_name[64]; /* Filename buffer */
+ size_t alloc_incr; /* Buffer allocation increment */
+ size_t min_incr = 65536; /* Minimum buffer increment */
+ double buf_prcnt = 0.1f; /* Percentage of buffer size to set
+ as increment */
+ static long file_name_counter;
+ H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, &image_realloc, &image_free,
+ &udata_copy, &udata_free, (void *)NULL};
/* check arguments */
if (buf_ptr == NULL)
@@ -903,33 +859,33 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags)
/* Set callbacks for file image ops ONLY if the file image is NOT copied */
if (flags & H5LT_FILE_IMAGE_DONT_COPY) {
- H5LT_file_image_ud_t *udata; /* Pointer to udata structure */
+ H5LT_file_image_ud_t *udata; /* Pointer to udata structure */
/* Allocate buffer to communicate user data to callbacks */
if (NULL == (udata = (H5LT_file_image_ud_t *)HDmalloc(sizeof(H5LT_file_image_ud_t))))
goto out;
/* Initialize udata with info about app buffer containing file image and flags */
- udata->app_image_ptr = buf_ptr;
- udata->app_image_size = buf_size;
- udata->fapl_image_ptr = NULL;
+ udata->app_image_ptr = buf_ptr;
+ udata->app_image_size = buf_size;
+ udata->fapl_image_ptr = NULL;
udata->fapl_image_size = 0;
- udata->fapl_ref_count = 0;
- udata->vfd_image_ptr = NULL;
- udata->vfd_image_size = 0;
- udata->vfd_ref_count = 0;
- udata->flags = flags;
- udata->ref_count = 1; /* corresponding to the first FAPL */
+ udata->fapl_ref_count = 0;
+ udata->vfd_image_ptr = NULL;
+ udata->vfd_image_size = 0;
+ udata->vfd_ref_count = 0;
+ udata->flags = flags;
+ udata->ref_count = 1; /* corresponding to the first FAPL */
/* copy address of udata into callbacks */
callbacks.udata = (void *)udata;
/* Set file image callbacks */
- if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) {
+ if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) {
HDfree(udata);
goto out;
} /* end if */
- } /* end if */
+ } /* end if */
/* Assign file image in user buffer to FAPL */
if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0)
@@ -956,46 +912,47 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags)
return file_id;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(fapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return -1;
} /* end H5LTopen_file_image() */
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * Date: October 8, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data)
{
- hid_t did;
+ hid_t did;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
/* Read */
- if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
goto out;
/* End access to the dataset and release resources used by it. */
- if(H5Dclose(did))
+ if (H5Dclose(did))
return -1;
return 0;
@@ -1006,513 +963,497 @@ 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
+ *
+ * Date: June 13, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset(hid_t loc_id,
- const char *dset_name,
- hid_t tid,
- void *data)
+herr_t
+H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t tid, void *data)
{
- return(H5LT_read_dataset_numerical(loc_id, dset_name, tid, data));
+ return (H5LT_read_dataset_numerical(loc_id, dset_name, tid, data));
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * Date: November 5, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset_char( hid_t loc_id,
- const char *dset_name,
- char *data )
+herr_t
+H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *data)
{
- return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_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
+ *
+ * Date: November 5, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset_short( hid_t loc_id,
- const char *dset_name,
- short *data )
+herr_t
+H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *data)
{
- return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_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
+ *
+ * Date: November 5, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset_int( hid_t loc_id,
- const char *dset_name,
- int *data )
+herr_t
+H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *data)
{
- return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_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
+ *
+ * Date: November 5, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset_long( hid_t loc_id,
- const char *dset_name,
- long *data )
+herr_t
+H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *data)
{
- return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_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
+ *
+ * Date: November 5, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset_float( hid_t loc_id,
- const char *dset_name,
- float *data )
+herr_t
+H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *data)
{
- return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_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
+ *
+ * Date: November 5, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset_double( hid_t loc_id,
- const char *dset_name,
- double *data )
+herr_t
+H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *data)
{
- return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_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
+ *
+ * Date: October 05, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTread_dataset_string( hid_t loc_id,
- const char *dset_name,
- char *buf )
+herr_t
+H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf)
{
- hid_t did = -1;
- hid_t tid = -1;
+ hid_t did = -1;
+ hid_t tid = -1;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
/* Read */
- if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
/* close */
- if(H5Dclose(did))
+ if (H5Dclose(did))
goto out;
- if(H5Tclose(tid))
+ if (H5Tclose(tid))
return -1;
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Tclose(tid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return -1;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * Date: September 4, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTget_dataset_ndims( hid_t loc_id,
- const char *dset_name,
- int *rank )
+herr_t
+H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank)
{
- hid_t did = -1;
- hid_t sid = -1;
+ hid_t did = -1;
+ hid_t sid = -1;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* Open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
/* Get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* Get rank */
- if((*rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* Terminate access to the dataspace */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/* End access to the dataset */
- if(H5Dclose(did))
+ if (H5Dclose(did))
return -1;
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Sclose(sid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return -1;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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 )
+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)
{
- hid_t did = -1;
- hid_t tid = -1;
- hid_t sid = -1;
+ hid_t did = -1;
+ hid_t tid = -1;
+ hid_t sid = -1;
/* check the arguments */
if (dset_name == NULL)
- return -1;
+ return -1;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
/* get an identifier for the datatype. */
tid = H5Dget_type(did);
/* get the class. */
- if(type_class != NULL)
+ if (type_class != NULL)
*type_class = H5Tget_class(tid);
/* get the size. */
- if(type_size!=NULL)
+ if (type_size != NULL)
*type_size = H5Tget_size(tid);
- if(dims != NULL) {
+ if (dims != NULL) {
/* get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get dimensions */
- if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
/* terminate access to the dataspace */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
} /* end if */
/* release the datatype. */
- if(H5Tclose(tid))
+ if (H5Tclose(tid))
return -1;
/* end access to the dataset */
- if(H5Dclose(did))
+ if (H5Dclose(did))
return -1;
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(tid);
H5Sclose(sid);
H5Dclose(did);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return -1;
-
}
/*-------------------------------------------------------------------------
-* 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
+ *
+ * Date: June 21, 2001
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
find_dataset(hid_t loc_id, const char *name, const H5L_info2_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;
/* check the arguments */
if (name == NULL)
- return ret;
+ return ret;
/* Shut the compiler up */
loc_id = loc_id;
- linfo = linfo;
+ 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
- */
- if(HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0)
+ * cause the iterator to immediately return that positive value,
+ * indicating short-circuit success
+ */
+ if (HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0)
ret = 1;
return ret;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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.
+ *
+ *-------------------------------------------------------------------------
+ */
/* H5Literate wants a non-const pointer but we have a const pointer in the API
* call. It's safe to ignore this because we control the callback, don't
* modify the op_data buffer (i.e.: dset_name) during the traversal, and the
* library never modifies that buffer.
*/
-H5_GCC_DIAG_OFF(cast-qual)
+H5_GCC_DIAG_OFF("cast-qual")
herr_t
-H5LTfind_dataset( hid_t loc_id, const char *dset_name )
+H5LTfind_dataset(hid_t loc_id, const char *dset_name)
{
return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name);
}
-H5_GCC_DIAG_ON(cast-qual)
+H5_GCC_DIAG_ON("cast-qual")
/*-------------------------------------------------------------------------
-*
-* 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 )
+herr_t
+H5LTset_attribute_string(hid_t loc_id, 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;
/* check the arguments */
if (obj_name == NULL)
- return -1;
+ return -1;
if (attr_name == NULL)
- return -1;
+ return -1;
if (attr_data == NULL)
- return -1;
+ 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 )
+ if ((attr_type = H5Tcopy(H5T_C_S1)) < 0)
goto out;
- attr_size = HDstrlen( attr_data ) + 1; /* extra null term */
+ attr_size = HDstrlen(attr_data) + 1; /* extra null term */
- if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 )
+ if (H5Tset_size(attr_type, (size_t)attr_size) < 0)
goto out;
- if ( H5Tset_strpad( attr_type, H5T_STR_NULLTERM ) < 0 )
+ if (H5Tset_strpad(attr_type, H5T_STR_NULLTERM) < 0)
goto out;
- if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 )
+ 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);
/* The attribute already exists, delete it */
- if(has_attr == 1)
- if(H5Adelete(obj_id, attr_name) < 0)
+ if (has_attr == 1)
+ if (H5Adelete(obj_id, attr_name) < 0)
goto out;
/* Create and write the attribute */
- if((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ 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)
+ if (H5Awrite(attr_id, attr_type, attr_data) < 0)
goto out;
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
- if(H5Sclose(attr_space_id) < 0)
+ if (H5Sclose(attr_space_id) < 0)
goto out;
- if(H5Tclose(attr_type) < 0)
+ if (H5Tclose(attr_type) < 0)
goto out;
/* Close the object */
- if(H5Oclose(obj_id) < 0)
+ if (H5Oclose(obj_id) < 0)
return -1;
return 0;
@@ -1523,79 +1464,71 @@ out:
return -1;
}
-
-
-
-
/*-------------------------------------------------------------------------
-* 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 )
+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)
{
- 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;
/* check the arguments */
if (obj_name == NULL)
- return -1;
+ return -1;
if (attr_name == NULL)
- return -1;
+ 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 )
+ 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);
/* The attribute already exists, delete it */
- if(has_attr == 1)
- if(H5Adelete(obj_id, attr_name) < 0)
+ 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)
+ 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)
+ if (H5Awrite(attr_id, tid, data) < 0)
goto out;
/* Close the attribute. */
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
/* Close the dataspace. */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/* Close the object */
- if(H5Oclose(obj_id) < 0)
+ if (H5Oclose(obj_id) < 0)
return -1;
return 0;
@@ -1605,562 +1538,499 @@ out:
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
+ *
+ * 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 )
+herr_t
+H5LTset_attribute_char(hid_t loc_id, 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 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_CHAR, data) < 0)
return -1;
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
+ *
+ * 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 )
+herr_t
+H5LTset_attribute_uchar(hid_t loc_id, 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 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UCHAR, data) < 0)
return -1;
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
+ *
+ * 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 )
+herr_t
+H5LTset_attribute_short(hid_t loc_id, 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 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_SHORT, data) < 0)
return -1;
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
+ *
+ * Date: March 8, 2004
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTset_attribute_ushort( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned short *data,
- size_t size )
+herr_t
+H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const unsigned short *data, size_t size)
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_USHORT, data ) < 0 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_USHORT, data) < 0)
return -1;
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
+ *
+ * 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 )
+herr_t
+H5LTset_attribute_int(hid_t loc_id, 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 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_INT, data) < 0)
return -1;
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
+ *
+ * Date: March 8, 2004
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTset_attribute_uint( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned int *data,
- size_t size )
+herr_t
+H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned int *data,
+ size_t size)
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_UINT, data ) < 0 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UINT, data) < 0)
return -1;
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
+ *
+ * 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 )
+herr_t
+H5LTset_attribute_long(hid_t loc_id, 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 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LONG, data) < 0)
return -1;
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
+ *
+ * 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 )
+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)
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_LLONG, data ) < 0 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LLONG, data) < 0)
return -1;
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
+ *
+ * Date: March 8, 2004
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTset_attribute_ulong( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned long *data,
- size_t size )
+herr_t
+H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *data,
+ size_t size)
{
- if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size,
- H5T_NATIVE_ULONG, data ) < 0 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULONG, data) < 0)
return -1;
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
+ *
+ * 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 )
+herr_t
+H5LTset_attribute_float(hid_t loc_id, 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 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0)
return -1;
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
+ *
+ * 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 )
+herr_t
+H5LTset_attribute_double(hid_t loc_id, 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 )
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0)
return -1;
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
+ *
+ * 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)
+find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data)
{
int ret = H5_ITER_CONT;
/* check the arguments */
if (name == NULL)
- return H5_ITER_CONT;
+ return H5_ITER_CONT;
/* Shut compiler up */
- loc_id = loc_id; ainfo = 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(HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data),HDstrlen(name))) == 0)
+ if (HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data), HDstrlen(name))) == 0)
ret = H5_ITER_STOP;
return ret;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * Date: May 17, 2006
+ *
+ * Comments:
+ * Calls the private version of the function
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name )
+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
+ *
+ * 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.
+ *
+ *-------------------------------------------------------------------------
+ */
/* H5Aiterate wants a non-const pointer but we have a const pointer in the API
* call. It's safe to ignore this because we control the callback, don't
* modify the op_data buffer (i.e.: attr_name) during the traversal, and the
* library never modifies that buffer.
*/
-H5_GCC_DIAG_OFF(cast-qual)
+H5_GCC_DIAG_OFF("cast-qual")
herr_t
-H5LT_find_attribute( hid_t loc_id, const char* attr_name )
+H5LT_find_attribute(hid_t loc_id, const char *attr_name)
{
return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name);
}
-H5_GCC_DIAG_ON(cast-qual)
-
-
-/*-------------------------------------------------------------------------
-* 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
-*
-*-------------------------------------------------------------------------
-*/
+H5_GCC_DIAG_ON("cast-qual")
+
+/*-------------------------------------------------------------------------
+ * Function: H5LTget_attribute_ndims
+ *
+ * Purpose: Gets the dimensionality of an attribute.
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * Date: September 4, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LTget_attribute_ndims( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- int *rank )
+herr_t
+H5LTget_attribute_ndims(hid_t loc_id, 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;
/* check the arguments */
if (obj_name == NULL)
- return -1;
+ return -1;
if (attr_name == NULL)
- return -1;
+ return -1;
/* Open the object */
- if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ 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)
- {
+ 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)
+ if ((sid = H5Aget_space(attr_id)) < 0)
goto out;
/* Get rank */
- if((*rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* Terminate access to the attribute */
- if ( H5Sclose( sid ) < 0 )
+ if (H5Sclose(sid) < 0)
goto out;
/* End access to the attribute */
- if ( H5Aclose( attr_id ) )
- goto out;;
+ if (H5Aclose(attr_id))
+ goto out;
+ ;
/* Close the object */
- if(H5Oclose(obj_id) < 0 )
+ if (H5Oclose(obj_id) < 0)
return -1;
return 0;
out:
- H5Aclose( attr_id );
+ 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
+ *
+ * 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 )
+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)
{
- 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;
/* check the arguments */
if (obj_name == NULL)
- return -1;
+ return -1;
if (attr_name == NULL)
- return -1;
+ return -1;
/* Open the object */
- if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ 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)
- {
+ if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) {
H5Oclose(obj_id);
return -1;
}
@@ -2172,30 +2042,30 @@ herr_t H5LTget_attribute_info( hid_t loc_id,
*type_class = H5Tget_class(tid);
/* Get the size. */
- *type_size = H5Tget_size( tid );
+ *type_size = H5Tget_size(tid);
/* Get the dataspace handle */
- if ( (sid = H5Aget_space( attr_id )) < 0 )
+ if ((sid = H5Aget_space(attr_id)) < 0)
goto out;
/* Get dimensions */
- if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 )
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
/* Terminate access to the dataspace */
- if ( H5Sclose( sid ) < 0 )
+ if (H5Sclose(sid) < 0)
goto out;
/* Release the datatype. */
- if ( H5Tclose( tid ) )
+ if (H5Tclose(tid))
goto out;
/* End access to the attribute */
- if ( H5Aclose( attr_id ) )
+ if (H5Aclose(attr_id))
goto out;
/* Close the object */
- if(H5Oclose(obj_id) < 0 )
+ if (H5Oclose(obj_id) < 0)
return -1;
return 0;
@@ -2205,46 +2075,46 @@ out:
H5Aclose(attr_id);
H5Oclose(obj_id);
return -1;
-
}
/*-------------------------------------------------------------------------
-* 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)
+ * Function: H5LTtext_to_dtype
+ *
+ * Purpose: Convert DDL description to HDF5 data type.
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Raymond Lu
+ *
+ * Date: October 6, 2004
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type)
{
- hid_t type_id;
+ hid_t type_id;
/* check the arguments */
if (text == NULL)
- return -1;
+ return -1;
- if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG)
+ if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG)
goto out;
- if(lang_type != H5LT_DDL) {
+ if (lang_type != H5LT_DDL) {
HDfprintf(stderr, "only DDL is supported for now.\n");
goto out;
}
input_len = HDstrlen(text);
- myinput = HDstrdup(text);
+ myinput = HDstrdup(text);
- if((type_id = H5LTyyparse()) < 0) {
+ if ((type_id = H5LTyyparse()) < 0) {
HDfree(myinput);
goto out;
}
@@ -2259,57 +2129,60 @@ out:
}
/*-------------------------------------------------------------------------
-* Function: realloc_and_append
-*
-* Purpose: Expand the buffer and append a string to it.
-*
-* Return: void
-*
-* Programmer: Raymond Lu, songyulu@hdfgroup.org
-*
-* Date: 29 September 2011
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-static char*
+ * Function: realloc_and_append
+ *
+ * Purpose: Expand the buffer and append a string to it.
+ *
+ * Return: void
+ *
+ * Programmer: Raymond Lu
+ *
+ * Date: 29 September 2011
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static char *
realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str_to_add)
{
size_t size_str_to_add, size_str;
- if(_no_user_buf) {
+ if (_no_user_buf) {
/* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */
- if(str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) {
+ if (str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) {
*len += ((HDstrlen(buf) + HDstrlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT;
- buf = (char*)HDrealloc(buf, *len);
- } else if(!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) {
+ buf = (char *)HDrealloc(buf, *len);
+ }
+ else if (!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) {
*len += INCREMENT;
- buf = (char*)HDrealloc(buf, *len);
+ buf = (char *)HDrealloc(buf, *len);
}
}
- if(!buf)
- goto out;
-
- if(str_to_add) {
- /* find the size of the buffer to add */
- size_str_to_add = HDstrlen(str_to_add);
- /* find the size of the current buffer */
- size_str = HDstrlen(buf);
-
- /* Check to make sure the appended string does not
- * extend past the allocated buffer; if it does then truncate the string
- */
- if(size_str < *len - 1) {
- if( size_str + size_str_to_add < *len - 1) {
- HDstrncat(buf, str_to_add, size_str_to_add);
- } else {
- HDstrncat(buf, str_to_add, (*len - 1) - size_str);
- }
- } else {
- buf[*len-1] = '\0'; /* buffer is full, null terminate */
- }
+ if (!buf)
+ goto out;
+
+ if (str_to_add) {
+ /* find the size of the buffer to add */
+ size_str_to_add = HDstrlen(str_to_add);
+ /* find the size of the current buffer */
+ size_str = HDstrlen(buf);
+
+ /* Check to make sure the appended string does not
+ * extend past the allocated buffer; if it does then truncate the string
+ */
+ if (size_str < *len - 1) {
+ if (size_str + size_str_to_add < *len - 1) {
+ HDstrncat(buf, str_to_add, size_str_to_add);
+ }
+ else {
+ HDstrncat(buf, str_to_add, (*len - 1) - size_str);
+ }
+ }
+ else {
+ buf[*len - 1] = '\0'; /* buffer is full, null terminate */
+ }
}
return buf;
@@ -2319,32 +2192,33 @@ out:
}
/*-------------------------------------------------------------------------
-* Function: indentation
-*
-* Purpose: Print spaces for indentation
-*
-* Return: void
-*
-* Programmer: Raymond Lu, slu@ncsa.uiuc.edu
-*
-* Date: December 6, 2005
-*
-* Modifications:
-*
-*-------------------------------------------------------------------------
-*/
-static char*
-indentation(size_t x, char* str, hbool_t no_u_buf, size_t *s_len)
+ * Function: indentation
+ *
+ * Purpose: Print spaces for indentation
+ *
+ * Return: void
+ *
+ * Programmer: Raymond Lu
+ *
+ * Date: December 6, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static char *
+indentation(size_t x, char *str, hbool_t no_u_buf, size_t *s_len)
{
- char tmp_str[TMP_LEN];
+ char tmp_str[TMP_LEN];
if (x < 80) {
HDmemset(tmp_str, ' ', x);
- tmp_str[x]='\0';
- } else
+ tmp_str[x] = '\0';
+ }
+ else
HDsnprintf(tmp_str, TMP_LEN, "error: the indentation exceeds the number of cols.");
- if(!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str)))
+ if (!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str)))
goto out;
return str;
@@ -2354,98 +2228,99 @@ out:
}
/*-------------------------------------------------------------------------
-* Function: print_enum
-*
-* Purpose: prints the enum data
-*
-* Return: Success: 0, Failure: -1
-*
-* Programmer: Raymond Lu
-*
-* Modifications:
-*
-*-----------------------------------------------------------------------*/
-static char*
-print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt)
+ * Function: print_enum
+ *
+ * Purpose: prints the enum data
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Raymond Lu
+ *
+ * Modifications:
+ *
+ *-----------------------------------------------------------------------*/
+static char *
+print_enum(hid_t type, char *str, size_t *str_len, hbool_t no_ubuf, size_t indt)
{
- char **name = NULL; /*member names */
- unsigned char *value = NULL; /*value array */
- int nmembs; /*number of members */
- char tmp_str[TMP_LEN];
- int nchars; /*number of output characters */
- hid_t super = -1; /*enum base integer type */
- hid_t native = -1; /*native integer data type */
- size_t super_size; /*enum base type size */
- size_t dst_size; /*destination value type size */
- int i;
+ char ** name = NULL; /*member names */
+ unsigned char *value = NULL; /*value array */
+ int nmembs; /*number of members */
+ char tmp_str[TMP_LEN];
+ int nchars; /*number of output characters */
+ hid_t super = -1; /*enum base integer type */
+ hid_t native = -1; /*native integer data type */
+ size_t super_size; /*enum base type size */
+ size_t dst_size; /*destination value type size */
+ int i;
- if((nmembs = H5Tget_nmembers(type))<=0)
+ if ((nmembs = H5Tget_nmembers(type)) <= 0)
goto out;
- if((super = H5Tget_super(type)) < 0)
+ if ((super = H5Tget_super(type)) < 0)
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 {
+ }
+ else {
native = H5T_NATIVE_INT;
}
super_size = H5Tget_size(super);
- dst_size = H5Tget_size(native);
+ dst_size = H5Tget_size(native);
/* Get the names and raw values of all members */
- name = (char**)HDcalloc((size_t)nmembs, sizeof(char *));
- value = (unsigned char*)HDcalloc((size_t)nmembs, MAX(dst_size, super_size));
+ name = (char **)HDcalloc((size_t)nmembs, sizeof(char *));
+ value = (unsigned char *)HDcalloc((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 + (size_t)i * super_size) < 0)
+ if (H5Tget_member_value(type, (unsigned)i, value + (size_t)i * super_size) < 0)
goto out;
}
/* Convert values to native data type */
if (native > 0) {
- if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0)
+ if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0)
goto out;
}
/*
- * Sort members by increasing value
- * ***not implemented yet***
- */
+ * Sort members by increasing value
+ * ***not implemented yet***
+ */
/* Print members */
for (i = 0; i < nmembs; i++) {
- if(!(str = indentation(indt + COL, str, no_ubuf, str_len)))
+ if (!(str = indentation(indt + COL, str, no_ubuf, str_len)))
goto out;
nchars = HDsnprintf(tmp_str, TMP_LEN, "\"%s\"", name[i]);
- if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
+ if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
goto out;
HDmemset(tmp_str, ' ', (size_t)MAX(3, 19 - nchars) + 1);
tmp_str[MAX(3, 19 - nchars)] = '\0';
- if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
+ if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
goto out;
if (H5T_SGN_NONE == H5Tget_sign(native))
HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int *)((void *)(value + (size_t)i * dst_size))));
else
HDsnprintf(tmp_str, TMP_LEN, "%d", *((int *)((void *)(value + (size_t)i * dst_size))));
- if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
+ if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
goto out;
HDsnprintf(tmp_str, TMP_LEN, ";\n");
- if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
+ if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str)))
goto out;
}
/* Release resources */
- for(i = 0; i < nmembs; i++)
+ for (i = 0; i < nmembs; i++)
H5free_memory(name[i]);
HDfree(name);
@@ -2456,71 +2331,73 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt)
out:
- if(0 == nmembs) {
+ if (0 == nmembs) {
str = realloc_and_append(no_ubuf, str_len, str, "\n");
HDassert((indt + 4) < TMP_LEN);
HDmemset(tmp_str, ' ', (indt + 4) + 1);
tmp_str[(indt + 4)] = '\0';
- str = realloc_and_append(no_ubuf, str_len, str, tmp_str);
- str = realloc_and_append(no_ubuf, str_len, str, " <empty>");
+ str = realloc_and_append(no_ubuf, str_len, str, tmp_str);
+ str = realloc_and_append(no_ubuf, str_len, str, " <empty>");
} /* end if */
/* Release resources */
- if(name) {
- for(i = 0; i < nmembs; i++)
- if(name[i])
+ if (name) {
+ for (i = 0; i < nmembs; i++)
+ if (name[i])
HDfree(name[i]);
HDfree(name);
} /* end if */
- if(value)
+ if (value)
HDfree(value);
- if(super >= 0)
+ if (super >= 0)
H5Tclose(super);
return NULL;
}
/*-------------------------------------------------------------------------
-* 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)
+ * Function: H5LTdtype_to_text
+ *
+ * Purpose: Convert HDF5 data type to DDL description.
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Raymond Lu
+ *
+ * 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;
- char *text_str;
- herr_t ret = SUCCEED;
+ size_t str_len = INCREMENT;
+ char * text_str;
+ herr_t ret = SUCCEED;
- if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG)
+ if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG)
goto out;
- if(len && !str) {
- text_str = (char*)HDcalloc(str_len, sizeof(char));
- text_str[0]='\0';
- if(!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1)))
+ if (len && !str) {
+ text_str = (char *)HDcalloc(str_len, sizeof(char));
+ text_str[0] = '\0';
+ if (!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1)))
goto out;
*len = HDstrlen(text_str) + 1;
- if(text_str)
+ if (text_str)
HDfree(text_str);
text_str = NULL;
- } else if(len && str) {
- if(!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0)))
+ }
+ else if (len && str) {
+ if (!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0)))
goto out;
- str[*len-1] = '\0';
+ str[*len - 1] = '\0';
}
return ret;
@@ -2530,38 +2407,38 @@ 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:
-*
-*-------------------------------------------------------------------------
-*/
-char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen,
- hbool_t no_user_buf)
+ * Function: H5LT_dtype_to_text
+ *
+ * Purpose: Private function to convert HDF5 data type to DDL description.
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Raymond Lu
+ *
+ * Date: December 20, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hbool_t no_user_buf)
{
H5T_class_t tcls;
char tmp_str[TMP_LEN];
int i;
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL)))
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL)))
goto out;
- if(lang != H5LT_DDL) {
+ if (lang != H5LT_DDL) {
HDsnprintf(dt_str, *slen, "only DDL is supported for now");
goto out;
}
- if((tcls = H5Tget_class(dtype)) < 0)
+ if ((tcls = H5Tget_class(dtype)) < 0)
goto out;
switch (tcls) {
@@ -2569,57 +2446,83 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl
case H5T_BITFIELD:
if (H5Tequal(dtype, H5T_STD_I8BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I8BE");
- } else if (H5Tequal(dtype, H5T_STD_I8LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_I8LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I8LE");
- } else if (H5Tequal(dtype, H5T_STD_I16BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_I16BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I16BE");
- } else if (H5Tequal(dtype, H5T_STD_I16LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_I16LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I16LE");
- } else if (H5Tequal(dtype, H5T_STD_I32BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_I32BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I32BE");
- } else if (H5Tequal(dtype, H5T_STD_I32LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_I32LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I32LE");
- } else if (H5Tequal(dtype, H5T_STD_I64BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_I64BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I64BE");
- } else if (H5Tequal(dtype, H5T_STD_I64LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_I64LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_I64LE");
- } else if (H5Tequal(dtype, H5T_STD_U8BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U8BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U8BE");
- } else if (H5Tequal(dtype, H5T_STD_U8LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U8LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U8LE");
- } else if (H5Tequal(dtype, H5T_STD_U16BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U16BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U16BE");
- } else if (H5Tequal(dtype, H5T_STD_U16LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U16LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U16LE");
- } else if (H5Tequal(dtype, H5T_STD_U32BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U32BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U32BE");
- } else if (H5Tequal(dtype, H5T_STD_U32LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U32LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U32LE");
- } else if (H5Tequal(dtype, H5T_STD_U64BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U64BE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U64BE");
- } else if (H5Tequal(dtype, H5T_STD_U64LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_STD_U64LE)) {
HDsnprintf(dt_str, *slen, "H5T_STD_U64LE");
- } else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_SCHAR");
- } else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_UCHAR");
- } else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_SHORT");
- } else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_USHORT");
- } else if (H5Tequal(dtype, H5T_NATIVE_INT)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_INT)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_INT");
- } else if (H5Tequal(dtype, H5T_NATIVE_UINT)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_UINT)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_UINT");
- } else if (H5Tequal(dtype, H5T_NATIVE_LONG)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_LONG)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_LONG");
- } else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULONG");
- } else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_LLONG");
- } else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULLONG");
- } else {
+ }
+ else {
HDsnprintf(dt_str, *slen, "undefined integer");
}
@@ -2627,439 +2530,445 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl
case H5T_FLOAT:
if (H5Tequal(dtype, H5T_IEEE_F32BE)) {
HDsnprintf(dt_str, *slen, "H5T_IEEE_F32BE");
- } else if (H5Tequal(dtype, H5T_IEEE_F32LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_IEEE_F32LE)) {
HDsnprintf(dt_str, *slen, "H5T_IEEE_F32LE");
- } else if (H5Tequal(dtype, H5T_IEEE_F64BE)) {
+ }
+ else if (H5Tequal(dtype, H5T_IEEE_F64BE)) {
HDsnprintf(dt_str, *slen, "H5T_IEEE_F64BE");
- } else if (H5Tequal(dtype, H5T_IEEE_F64LE)) {
+ }
+ else if (H5Tequal(dtype, H5T_IEEE_F64LE)) {
HDsnprintf(dt_str, *slen, "H5T_IEEE_F64LE");
- } else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_FLOAT");
- } else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) {
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_DOUBLE");
-#if H5_SIZEOF_LONG_DOUBLE !=0
- } else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) {
+#if H5_SIZEOF_LONG_DOUBLE != 0
+ }
+ else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_LDOUBLE");
#endif
- } else {
+ }
+ else {
HDsnprintf(dt_str, *slen, "undefined float");
}
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;
+ 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;
- /* Print lead-in */
- HDsnprintf(dt_str, *slen, "H5T_STRING {\n");
- indent += COL;
+ /* Print lead-in */
+ HDsnprintf(dt_str, *slen, "H5T_STRING {\n");
+ indent += COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
- if(is_vlstr)
- HDsnprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n");
- else
- HDsnprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size);
+ if (is_vlstr)
+ HDsnprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n");
+ else
+ HDsnprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size);
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
- if (str_pad == H5T_STR_NULLTERM)
- HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n");
- else if (str_pad == H5T_STR_NULLPAD)
- HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n");
- else if (str_pad == H5T_STR_SPACEPAD)
- HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n");
- else
- HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n");
+ if (str_pad == H5T_STR_NULLTERM)
+ HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n");
+ else if (str_pad == H5T_STR_NULLPAD)
+ HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n");
+ else if (str_pad == H5T_STR_SPACEPAD)
+ HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n");
+ else
+ HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
- if (cset == H5T_CSET_ASCII)
- HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n");
- else if (cset == H5T_CSET_UTF8)
- HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n");
- else
- HDsnprintf(tmp_str, TMP_LEN, "CSET unknown;\n");
+ if (cset == H5T_CSET_ASCII)
+ HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n");
+ else if (cset == H5T_CSET_UTF8)
+ HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n");
+ else
+ HDsnprintf(tmp_str, TMP_LEN, "CSET unknown;\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
- /* 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)
- goto out;
- } else {
- if(H5Tset_size(str_type, size) < 0)
- goto out;
- }
- if(H5Tset_cset(str_type, cset) < 0)
+ /* 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)
goto out;
- if(H5Tset_strpad(str_type, str_pad) < 0)
+ }
+ 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(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
- /* Check C variable-length string first. Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- goto next;
- }
+ /* Check C variable-length string first. Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
+ goto next;
+ }
- /* Change the endianness and see if they're equal. */
- if((order = H5Tget_order(tmp_type)) < 0)
+ /* 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;
- 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)) {
- HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- 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)
+ }
+ else if (order == H5T_ORDER_BE) {
+ if (H5Tset_order(str_type, H5T_ORDER_BE) < 0)
goto out;
- if((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0)
+ }
+
+ if (H5Tequal(tmp_type, str_type)) {
+ HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
- if(H5Tset_cset(str_type, cset) < 0)
+ 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)) {
+ HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
- if(H5Tset_size(str_type, size) < 0)
+ 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)
goto out;
- if(H5Tset_strpad(str_type, str_pad) < 0)
+ }
+ 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)) {
- HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- 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)
- 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)) {
- HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- goto next;
- }
-
- /* Type doesn't match any of above. */
- HDsnprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ /* Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
+ goto next;
+ }
+
+ /* Type doesn't match any of above. */
+ HDsnprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
next:
- H5Tclose(str_type);
- H5Tclose(tmp_type);
+ H5Tclose(str_type);
+ H5Tclose(tmp_type);
- /* Print closing */
- indent -= COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
- HDsnprintf(tmp_str, TMP_LEN, "}");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ /* Print closing */
+ indent -= COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
+ HDsnprintf(tmp_str, TMP_LEN, "}");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
- break;
- }
- case H5T_OPAQUE:
- {
+ break;
+ }
+ case H5T_OPAQUE: {
char *tag = NULL;
/* Print lead-in */
HDsnprintf(dt_str, *slen, "H5T_OPAQUE {\n");
indent += COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
goto out;
HDsnprintf(tmp_str, TMP_LEN, "OPQ_SIZE %lu;\n", (unsigned long)H5Tget_size(dtype));
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
goto out;
tag = H5Tget_tag(dtype);
- if(tag) {
+ if (tag) {
HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag);
- if(tag)
+ if (tag)
H5free_memory(tag);
tag = NULL;
- } else
+ }
+ else
HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
/* Print closing */
indent -= COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
goto out;
HDsnprintf(tmp_str, TMP_LEN, "}");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
break;
- }
- case H5T_ENUM:
- {
- hid_t super;
- size_t super_len;
- char* stmp = NULL;
-
- /* Print lead-in */
- HDsnprintf(dt_str, *slen, "H5T_ENUM {\n");
- indent += COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
+ }
+ case H5T_ENUM: {
+ hid_t super;
+ size_t super_len;
+ char * stmp = NULL;
- if((super = H5Tget_super(dtype)) < 0)
- goto out;
- if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
- goto out;
- stmp = (char*)HDcalloc(super_len, sizeof(char));
- if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
- goto out;
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
- goto out;
+ /* Print lead-in */
+ HDsnprintf(dt_str, *slen, "H5T_ENUM {\n");
+ indent += COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
- if(stmp)
- HDfree(stmp);
- stmp = NULL;
+ if ((super = H5Tget_super(dtype)) < 0)
+ goto out;
+ if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
+ goto out;
+ stmp = (char *)HDcalloc(super_len, sizeof(char));
+ if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
+ goto out;
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
+ goto out;
- HDsnprintf(tmp_str, TMP_LEN, ";\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- H5Tclose(super);
+ if (stmp)
+ HDfree(stmp);
+ stmp = NULL;
- if(!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent)))
- goto out;
+ HDsnprintf(tmp_str, TMP_LEN, ";\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
+ H5Tclose(super);
- /* Print closing */
- indent -= COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
- HDsnprintf(tmp_str, TMP_LEN, "}");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ if (!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent)))
+ goto out;
- break;
- }
- case H5T_VLEN:
- {
- hid_t super;
- size_t super_len;
- char* stmp = NULL;
-
- /* Print lead-in */
- HDsnprintf(dt_str, *slen, "H5T_VLEN {\n");
- indent += COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
+ /* Print closing */
+ indent -= COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
+ HDsnprintf(tmp_str, TMP_LEN, "}");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
- if((super = H5Tget_super(dtype)) < 0)
- goto out;
- if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
- goto out;
- stmp = (char*)HDcalloc(super_len, sizeof(char));
- if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
- goto out;
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
- goto out;
+ break;
+ }
+ case H5T_VLEN: {
+ hid_t super;
+ size_t super_len;
+ char * stmp = NULL;
- if(stmp)
- HDfree(stmp);
- stmp = NULL;
- HDsnprintf(tmp_str, TMP_LEN, "\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- H5Tclose(super);
+ /* Print lead-in */
+ HDsnprintf(dt_str, *slen, "H5T_VLEN {\n");
+ indent += COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
- /* Print closing */
- indent -= COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
- HDsnprintf(tmp_str, TMP_LEN, "}");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ if ((super = H5Tget_super(dtype)) < 0)
+ goto out;
+ if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
+ goto out;
+ stmp = (char *)HDcalloc(super_len, sizeof(char));
+ if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
+ goto out;
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
+ goto out;
- break;
- }
- case H5T_ARRAY:
- {
- hid_t super;
- size_t super_len;
- char* stmp = NULL;
- hsize_t dims[H5S_MAX_RANK];
- int ndims;
-
- /* Print lead-in */
- HDsnprintf(dt_str, *slen, "H5T_ARRAY {\n");
- indent += COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ if (stmp)
+ HDfree(stmp);
+ stmp = NULL;
+ HDsnprintf(tmp_str, TMP_LEN, "\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
+ H5Tclose(super);
+
+ /* Print closing */
+ indent -= COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
+ HDsnprintf(tmp_str, TMP_LEN, "}");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
+
+ break;
+ }
+ case H5T_ARRAY: {
+ hid_t super;
+ size_t super_len;
+ char * stmp = NULL;
+ hsize_t dims[H5S_MAX_RANK];
+ int ndims;
+
+ /* Print lead-in */
+ HDsnprintf(dt_str, *slen, "H5T_ARRAY {\n");
+ indent += COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
+
+ /* 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++) {
+ HDsnprintf(tmp_str, TMP_LEN, "[%d]", (int)dims[i]);
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
+ }
+ HDsnprintf(tmp_str, TMP_LEN, " ");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
+
+ if ((super = H5Tget_super(dtype)) < 0)
+ goto out;
+ if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
+ goto out;
+ stmp = (char *)HDcalloc(super_len, sizeof(char));
+ if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
+ goto out;
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
+ goto out;
+ if (stmp)
+ HDfree(stmp);
+ stmp = NULL;
+ HDsnprintf(tmp_str, TMP_LEN, "\n");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
+ H5Tclose(super);
+
+ /* Print closing */
+ indent -= COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
+ HDsnprintf(tmp_str, TMP_LEN, "}");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
- /* Get array information */
- if((ndims = H5Tget_array_ndims(dtype)) < 0)
+ break;
+ }
+ case H5T_COMPOUND: {
+ char * mname = NULL;
+ hid_t mtype;
+ size_t moffset;
+ H5T_class_t mclass;
+ size_t mlen;
+ char * mtmp = NULL;
+ int nmembs;
+
+ if ((nmembs = H5Tget_nmembers(dtype)) < 0)
+ goto out;
+
+ HDsnprintf(dt_str, *slen, "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;
- if(H5Tget_array_dims2(dtype, dims) < 0)
+ moffset = H5Tget_member_offset(dtype, (unsigned)i);
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
goto out;
- /* Print array dimensions */
- for (i = 0; i < ndims; i++) {
- HDsnprintf(tmp_str, TMP_LEN, "[%d]", (int) dims[i]);
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- }
- HDsnprintf(tmp_str, TMP_LEN, " ");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
-
- if((super = H5Tget_super(dtype)) < 0)
+ if ((mclass = H5Tget_class(mtype)) < 0)
goto out;
- if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0)
+ if (H5T_COMPOUND == mclass)
+ indent += COL;
+
+ if (H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0)
goto out;
- stmp = (char*)HDcalloc(super_len, sizeof(char));
- if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0)
+ mtmp = (char *)HDcalloc(mlen, sizeof(char));
+ if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0)
goto out;
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp)))
- goto out;
- if(stmp)
- HDfree(stmp);
- stmp = NULL;
- HDsnprintf(tmp_str, TMP_LEN, "\n");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- H5Tclose(super);
-
- /* Print closing */
- indent -= COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp)))
goto out;
- HDsnprintf(tmp_str, TMP_LEN, "}");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ if (mtmp)
+ HDfree(mtmp);
+ mtmp = NULL;
- break;
- }
- case H5T_COMPOUND:
- {
- char *mname = NULL;
- hid_t mtype;
- size_t moffset;
- H5T_class_t mclass;
- size_t mlen;
- char* mtmp = NULL;
- int nmembs;
-
- if((nmembs = H5Tget_nmembers(dtype)) < 0)
- goto out;
+ if (H5T_COMPOUND == mclass)
+ indent -= COL;
- HDsnprintf(dt_str, *slen, "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);
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
- goto out;
-
- 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*)HDcalloc(mlen, sizeof(char));
- if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0)
- goto out;
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp)))
- goto out;
- if(mtmp)
- HDfree(mtmp);
- mtmp = NULL;
-
- if (H5T_COMPOUND == mclass)
- indent -= COL;
-
- HDsnprintf(tmp_str, TMP_LEN, " \"%s\"", mname);
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- if(mname)
- H5free_memory(mname);
- mname = NULL;
-
- HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset);
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
- }
-
- /* Print closing */
- indent -= COL;
- if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ HDsnprintf(tmp_str, TMP_LEN, " \"%s\"", mname);
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
- HDsnprintf(tmp_str, TMP_LEN, "}");
- if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
- goto out;
+ if (mname)
+ H5free_memory(mname);
+ mname = NULL;
- break;
+ HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset);
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
}
+
+ /* Print closing */
+ indent -= COL;
+ if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen)))
+ goto out;
+ HDsnprintf(tmp_str, TMP_LEN, "}");
+ if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
+ goto out;
+
+ break;
+ }
case H5T_TIME:
HDsnprintf(dt_str, *slen, "H5T_TIME: not yet implemented");
break;
@@ -3067,15 +2976,15 @@ next:
HDsnprintf(dt_str, *slen, "H5T_NO_CLASS");
break;
case H5T_REFERENCE:
- if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == TRUE) {
- HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }");
- }
- else {
- HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }");
- }
- break;
+ if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == TRUE) {
+ HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }");
+ }
+ else {
+ HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }");
+ }
+ break;
case H5T_NCLASSES:
- break;
+ break;
default:
HDsnprintf(dt_str, *slen, "unknown data type");
}
@@ -3087,747 +2996,701 @@ 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
+ *
+ * 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 )
+herr_t
+H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, char *data)
{
/* identifiers */
- hid_t obj_id;
+ hid_t obj_id;
/* check the arguments */
if (obj_name == NULL)
- return -1;
+ return -1;
if (attr_name == NULL)
- return -1;
+ return -1;
/* Open the object */
- if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0)
+ 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 )
- {
- H5Oclose(obj_id);
- return -1;
+ if (H5LT_get_attribute_disk(obj_id, attr_name, data) < 0) {
+ H5Oclose(obj_id);
+ return -1;
}
/* Close the object */
- if(H5Oclose(obj_id) < 0)
+ if (H5Oclose(obj_id) < 0)
return -1;
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:
-*
-*-------------------------------------------------------------------------
-*/
-herr_t H5LTget_attribute_char( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- char *data )
+ * Function: H5LTget_attribute_char
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * 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)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0)
return -1;
return 0;
}
/*-------------------------------------------------------------------------
-* 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 )
+ * Function: H5LTget_attribute_uchar
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * 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)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0)
return -1;
return 0;
}
-
-
/*-------------------------------------------------------------------------
-* 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 )
+ * Function: H5LTget_attribute_short
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * 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)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0)
return -1;
return 0;
}
/*-------------------------------------------------------------------------
-* 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,
- unsigned short *data )
+ * Function: H5LTget_attribute_ushort
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * Date: March 8, 2004
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned short *data)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0)
return -1;
return 0;
}
-
-
/*-------------------------------------------------------------------------
-* 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 )
+ * Function: H5LTget_attribute_int
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * 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)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0)
return -1;
return 0;
}
/*-------------------------------------------------------------------------
-* 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,
- unsigned int *data )
+ * Function: H5LTget_attribute_uint
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * Date: March 8, 2004
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned int *data)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0)
return -1;
return 0;
}
-
-
/*-------------------------------------------------------------------------
-* 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,
- long *data )
+ * Function: H5LTget_attribute_long
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * Date: September 19, 2002
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0)
return -1;
return 0;
}
/*-------------------------------------------------------------------------
-* 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 function was added to support 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 )
+ * Function: H5LTget_attribute_long_long
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Elena Pourmal
+ *
+ * Date: June 17, 2005
+ *
+ * Comments: This function was added to support 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)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0)
return -1;
return 0;
}
-
/*-------------------------------------------------------------------------
-* 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 )
+ * Function: H5LTget_attribute_ulong
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente
+ *
+ * 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)
{
/* Get the attribute */
- if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0)
return -1;
return 0;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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 )
+herr_t
+H5LTget_attribute_float(hid_t loc_id, 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)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0)
return -1;
return 0;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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 )
+herr_t
+H5LTget_attribute_double(hid_t loc_id, 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)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0)
return -1;
return 0;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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 )
+herr_t
+H5LTget_attribute(hid_t loc_id, 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)
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0)
return -1;
return 0;
}
-
/*-------------------------------------------------------------------------
-* 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
+ *
+ * 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)
+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)
{
/* identifiers */
- hid_t obj_id = -1;
+ hid_t obj_id = -1;
hid_t attr_id = -1;
/* check the arguments */
if (obj_name == NULL)
- return -1;
+ return -1;
if (attr_name == NULL)
- return -1;
+ return -1;
/* Open the object */
- if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
+ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0)
goto out;
- if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0)
+ if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0)
goto out;
- if(H5Aread(attr_id, mem_type_id, data) < 0)
+ if (H5Aread(attr_id, mem_type_id, data) < 0)
goto out;
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
attr_id = -1;
/* Close the object */
- if(H5Oclose(obj_id) < 0)
+ if (H5Oclose(obj_id) < 0)
goto out;
obj_id = -1;
return 0;
out:
- if(obj_id > 0)
+ if (obj_id > 0)
H5Oclose(obj_id);
- if(attr_id > 0)
+ if (attr_id > 0)
H5Aclose(attr_id);
return -1;
}
/*-------------------------------------------------------------------------
-* 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
+ *
+ * Date: September 19, 2002
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
-herr_t H5LT_get_attribute_disk( hid_t loc_id,
- const char *attr_name,
- void *attr_out )
+herr_t
+H5LT_get_attribute_disk(hid_t loc_id, const char *attr_name, void *attr_out)
{
/* identifiers */
hid_t attr_id;
hid_t attr_type;
- if(( attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0)
+ if ((attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0)
return -1;
- if((attr_type = H5Aget_type(attr_id)) < 0)
+ if ((attr_type = H5Aget_type(attr_id)) < 0)
goto out;
- if(H5Aread(attr_id, attr_type, attr_out) < 0)
+ if (H5Aread(attr_id, attr_type, attr_out) < 0)
goto out;
- if(H5Tclose(attr_type) < 0)
+ if (H5Tclose(attr_type) < 0)
goto out;
- if ( H5Aclose( attr_id ) < 0 )
- return -1;;
+ if (H5Aclose(attr_id) < 0)
+ return -1;
+ ;
return 0;
out:
- H5Tclose( attr_type );
- H5Aclose( attr_id );
+ 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:
-*
-*-------------------------------------------------------------------------
-*/
-herr_t H5LT_set_attribute_string(hid_t dset_id,
- const char *name,
- const char *buf )
+/*-------------------------------------------------------------------------
+ * 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: Pedro Vicente
+ *
+ * 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;
+ 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);
+ has_attr = H5LT_find_attribute(dset_id, name);
/* the attribute already exists, delete it */
- if(has_attr == 1)
- if(H5Adelete(dset_id, name) < 0)
+ if (has_attr == 1)
+ if (H5Adelete(dset_id, name) < 0)
return FAIL;
/*-------------------------------------------------------------------------
- * create the attribute type
- *-------------------------------------------------------------------------
- */
- if((tid = H5Tcopy(H5T_C_S1)) < 0)
+ * create the attribute type
+ *-------------------------------------------------------------------------
+ */
+ if ((tid = H5Tcopy(H5T_C_S1)) < 0)
return FAIL;
size = HDstrlen(buf) + 1; /* extra null term */
- if(H5Tset_size(tid,(size_t)size) < 0)
+ if (H5Tset_size(tid, (size_t)size) < 0)
goto out;
- if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0)
+ if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0)
goto out;
- if((sid = H5Screate(H5S_SCALAR)) < 0)
+ if ((sid = H5Screate(H5S_SCALAR)) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * create and write the attribute
- *-------------------------------------------------------------------------
- */
- if((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ * create and write the attribute
+ *-------------------------------------------------------------------------
+ */
+ if ((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if(H5Awrite(aid, tid, buf) < 0)
+ if (H5Awrite(aid, tid, buf) < 0)
goto out;
- if(H5Aclose(aid) < 0)
+ if (H5Aclose(aid) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
return SUCCEED;
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Aclose(aid);
H5Tclose(tid);
H5Sclose(sid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
-
}
htri_t
H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid)
- {
- char *tmp_path = NULL; /* Temporary copy of the path */
- char *curr_name; /* Pointer to current component of path name */
- char *delimit; /* Pointer to path delimiter during traversal */
- H5I_type_t obj_type;
- htri_t link_exists, obj_exists;
- size_t path_length;
- htri_t ret_value;
-
- /* Initialize */
- ret_value = FALSE;
-
- /* check the arguments */
- if (path == NULL) {
- ret_value = FAIL;
- goto done;
- }
-
- /* Find the type of loc_id */
- if((obj_type = H5Iget_type(loc_id)) == H5I_BADID) {
- ret_value = FAIL;
- goto done;
- }
-
- /* Find the length of the path */
- path_length = HDstrlen(path);
-
- /* Check if the identifier is the object itself, i.e. path is '.' */
- if(HDstrncmp(path, ".", path_length) == 0) {
- if(check_object_valid) {
- obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT);
- ret_value = obj_exists;
- goto done;
- } else {
- ret_value = TRUE; /* Since the object is the identifier itself,
- * we can only check if loc_id is a valid type */
- goto done;
- }
- }
-
- /* Duplicate the path to use */
- if(NULL == (tmp_path = HDstrdup(path))) {
- ret_value = FAIL;
- goto done;
- }
-
- curr_name = tmp_path;
-
- /* check if absolute pathname */
- if(HDstrncmp(path, "/", 1) == 0) curr_name++;
-
- /* check if relative path name starts with "./" */
- if(HDstrncmp(path, "./", 2) == 0) curr_name += 2;
-
- while((delimit=HDstrchr(curr_name,'/'))!=NULL) {
- /* Change the delimiter to terminate the string */
- *delimit='\0';
-
- obj_exists = FALSE;
- if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
- ret_value = FAIL;
- goto done;
- }
-
- /* If target link does not exist then no reason to
- * continue checking the path */
- if(link_exists != TRUE) {
- ret_value = FALSE;
- goto done;
- }
-
- /* Determine if link resolves to an actual object */
- if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
- ret_value = FAIL;
- goto done;
- }
-
- if(obj_exists != TRUE)
- break;
-
- /* Change the delimiter back to '/' */
- *delimit='/';
-
- /* Advance the pointer in the path to the start of the next component */
- curr_name = delimit + 1;
-
- } /* end while */
-
- /* Should be pointing to the last component in the path name now... */
-
- /* Check if link does not exist */
- if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
- ret_value = FAIL;
- } else {
- ret_value = link_exists;
- /* Determine if link resolves to an actual object for check_object_valid TRUE */
- if(check_object_valid == TRUE && link_exists == TRUE) {
- if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
- ret_value = FAIL;
- } else {
- ret_value = obj_exists;
- }
- }
- }
+{
+ char * tmp_path = NULL; /* Temporary copy of the path */
+ char * curr_name; /* Pointer to current component of path name */
+ char * delimit; /* Pointer to path delimiter during traversal */
+ H5I_type_t obj_type;
+ htri_t link_exists, obj_exists;
+ size_t path_length;
+ htri_t ret_value;
+
+ /* Initialize */
+ ret_value = FALSE;
+
+ /* check the arguments */
+ if (path == NULL) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ /* Find the type of loc_id */
+ if ((obj_type = H5Iget_type(loc_id)) == H5I_BADID) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ /* Find the length of the path */
+ path_length = HDstrlen(path);
+
+ /* Check if the identifier is the object itself, i.e. path is '.' */
+ if (HDstrncmp(path, ".", path_length) == 0) {
+ if (check_object_valid) {
+ obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT);
+ ret_value = obj_exists;
+ goto done;
+ }
+ else {
+ ret_value = TRUE; /* Since the object is the identifier itself,
+ * we can only check if loc_id is a valid type */
+ goto done;
+ }
+ }
+
+ /* Duplicate the path to use */
+ if (NULL == (tmp_path = HDstrdup(path))) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ curr_name = tmp_path;
+
+ /* check if absolute pathname */
+ if (HDstrncmp(path, "/", 1) == 0)
+ curr_name++;
+
+ /* check if relative path name starts with "./" */
+ if (HDstrncmp(path, "./", 2) == 0)
+ curr_name += 2;
+
+ while ((delimit = HDstrchr(curr_name, '/')) != NULL) {
+ /* Change the delimiter to terminate the string */
+ *delimit = '\0';
+
+ obj_exists = FALSE;
+ if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ /* If target link does not exist then no reason to
+ * continue checking the path */
+ if (link_exists != TRUE) {
+ ret_value = FALSE;
+ goto done;
+ }
+
+ /* Determine if link resolves to an actual object */
+ if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ if (obj_exists != TRUE)
+ break;
+
+ /* Change the delimiter back to '/' */
+ *delimit = '/';
+
+ /* Advance the pointer in the path to the start of the next component */
+ curr_name = delimit + 1;
+
+ } /* end while */
+
+ /* Should be pointing to the last component in the path name now... */
+
+ /* Check if link does not exist */
+ if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ }
+ else {
+ ret_value = link_exists;
+ /* Determine if link resolves to an actual object for check_object_valid TRUE */
+ if (check_object_valid == TRUE && link_exists == TRUE) {
+ if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ }
+ else {
+ ret_value = obj_exists;
+ }
+ }
+ }
done:
- if(tmp_path != NULL)
- HDfree(tmp_path);
+ if (tmp_path != NULL)
+ HDfree(tmp_path);
- return ret_value;
- }
+ return ret_value;
+}
diff --git a/hl/src/H5LTprivate.h b/hl/src/H5LTprivate.h
index 01c5ee6..0200725 100644
--- a/hl/src/H5LTprivate.h
+++ b/hl/src/H5LTprivate.h
@@ -25,26 +25,17 @@
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5LT_get_attribute_disk( hid_t obj_id,
- const char *attr_name,
- void *data );
+H5_HLDLL herr_t H5LT_get_attribute_disk(hid_t obj_id, const char *attr_name, void *data);
-H5_HLDLL herr_t H5LT_set_attribute_numerical( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- size_t size,
- hid_t type_id,
- const void *data );
+H5_HLDLL herr_t H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name,
+ size_t size, hid_t type_id, const void *data);
-H5_HLDLL herr_t H5LT_set_attribute_string( hid_t dset_id,
- const char *name,
- const char *buf );
+H5_HLDLL herr_t H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf);
-H5_HLDLL herr_t H5LT_find_attribute( hid_t loc_id, const char *name );
+H5_HLDLL herr_t H5LT_find_attribute(hid_t loc_id, const char *name);
-
-H5_HLDLL char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang,
- size_t *slen, hbool_t no_user_buf);
+H5_HLDLL char *H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen,
+ hbool_t no_user_buf);
H5_HLDLL hid_t H5LTyyparse(void);
diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h
index 6df7c4b..97129bf 100644
--- a/hl/src/H5LTpublic.h
+++ b/hl/src/H5LTpublic.h
@@ -15,13 +15,13 @@
#define _H5LTpublic_H
/* Flag definitions for H5LTopen_file_image() */
-#define H5LT_FILE_IMAGE_OPEN_RW 0x0001 /* Open image for read-write */
-#define H5LT_FILE_IMAGE_DONT_COPY 0x0002 /* The HDF5 lib won't copy */
+#define H5LT_FILE_IMAGE_OPEN_RW 0x0001 /* Open image for read-write */
+#define H5LT_FILE_IMAGE_DONT_COPY 0x0002 /* The HDF5 lib won't copy */
/* user supplied image buffer. The same image is open with the core driver. */
#define H5LT_FILE_IMAGE_DONT_RELEASE 0x0004 /* The HDF5 lib won't */
/* deallocate user supplied image buffer. The user application is reponsible */
/* for doing so. */
-#define H5LT_FILE_IMAGE_ALL 0x0007
+#define H5LT_FILE_IMAGE_ALL 0x0007
typedef enum H5LT_lang_t {
H5LT_LANG_ERR = -1, /*this is the first*/
@@ -42,53 +42,28 @@ extern "C" {
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5LTmake_dataset( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- hid_t type_id,
- const void *buffer );
-
-H5_HLDLL herr_t H5LTmake_dataset_char( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const char *buffer );
-
-H5_HLDLL herr_t H5LTmake_dataset_short( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const short *buffer );
-
-H5_HLDLL herr_t H5LTmake_dataset_int( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const int *buffer );
-
-H5_HLDLL herr_t H5LTmake_dataset_long( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const long *buffer );
-
-H5_HLDLL herr_t H5LTmake_dataset_float( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const float *buffer );
-
-H5_HLDLL herr_t H5LTmake_dataset_double( hid_t loc_id,
- const char *dset_name,
- int rank,
- const hsize_t *dims,
- const double *buffer );
-
-H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id,
- const char *dset_name,
- const char *buf );
+H5_HLDLL herr_t H5LTmake_dataset(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims,
+ hid_t type_id, const void *buffer);
+H5_HLDLL herr_t H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims,
+ const char *buffer);
+
+H5_HLDLL herr_t H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims,
+ const short *buffer);
+
+H5_HLDLL herr_t H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims,
+ const int *buffer);
+
+H5_HLDLL herr_t H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims,
+ const long *buffer);
+
+H5_HLDLL herr_t H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims,
+ const float *buffer);
+
+H5_HLDLL herr_t H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims,
+ const double *buffer);
+
+H5_HLDLL herr_t H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf);
/*-------------------------------------------------------------------------
*
@@ -97,38 +72,21 @@ H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id,
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5LTread_dataset( hid_t loc_id,
- const char *dset_name,
- hid_t type_id,
- void *buffer );
+H5_HLDLL herr_t H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t type_id, void *buffer);
-H5_HLDLL herr_t H5LTread_dataset_char( hid_t loc_id,
- const char *dset_name,
- char *buffer );
+H5_HLDLL herr_t H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *buffer);
-H5_HLDLL herr_t H5LTread_dataset_short( hid_t loc_id,
- const char *dset_name,
- short *buffer );
+H5_HLDLL herr_t H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *buffer);
-H5_HLDLL herr_t H5LTread_dataset_int( hid_t loc_id,
- const char *dset_name,
- int *buffer );
+H5_HLDLL herr_t H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *buffer);
-H5_HLDLL herr_t H5LTread_dataset_long( hid_t loc_id,
- const char *dset_name,
- long *buffer );
+H5_HLDLL herr_t H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *buffer);
-H5_HLDLL herr_t H5LTread_dataset_float( hid_t loc_id,
- const char *dset_name,
- float *buffer );
+H5_HLDLL herr_t H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *buffer);
-H5_HLDLL herr_t H5LTread_dataset_double( hid_t loc_id,
- const char *dset_name,
- double *buffer );
+H5_HLDLL herr_t H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *buffer);
-H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id,
- const char *dset_name,
- char *buf );
+H5_HLDLL herr_t H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf);
/*-------------------------------------------------------------------------
*
@@ -137,20 +95,12 @@ H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id,
*-------------------------------------------------------------------------
*/
+H5_HLDLL herr_t H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank);
-H5_HLDLL herr_t H5LTget_dataset_ndims( hid_t loc_id,
- const char *dset_name,
- int *rank );
-
-H5_HLDLL 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 );
-
-H5_HLDLL herr_t H5LTfind_dataset( hid_t loc_id, const char *name );
-
+H5_HLDLL 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);
+H5_HLDLL herr_t H5LTfind_dataset(hid_t loc_id, const char *name);
/*-------------------------------------------------------------------------
*
@@ -159,77 +109,41 @@ H5_HLDLL herr_t H5LTfind_dataset( hid_t loc_id, const char *name );
*-------------------------------------------------------------------------
*/
+H5_HLDLL herr_t H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const char *attr_data);
+
+H5_HLDLL herr_t H5LTset_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const char *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const unsigned char *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const short *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const unsigned short *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const int *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const unsigned int *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const long *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const long long *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const unsigned long *buffer, size_t size);
+
+H5_HLDLL herr_t H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const float *buffer, size_t size);
-H5_HLDLL herr_t H5LTset_attribute_string( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const char *attr_data );
-
-H5_HLDLL herr_t H5LTset_attribute_char( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const char *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_uchar( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned char *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_short( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const short *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_ushort( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned short *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_int( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const int *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_uint( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned int *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_long( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const long *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_long_long( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const long long *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_ulong( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const unsigned long *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_float( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const float *buffer,
- size_t size );
-
-H5_HLDLL herr_t H5LTset_attribute_double( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- const double *buffer,
- size_t size );
+H5_HLDLL herr_t H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const double *buffer, size_t size);
/*-------------------------------------------------------------------------
*
@@ -238,72 +152,41 @@ H5_HLDLL herr_t H5LTset_attribute_double( hid_t loc_id,
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5LTget_attribute( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- hid_t mem_type_id,
- void *data );
-
-H5_HLDLL herr_t H5LTget_attribute_string( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- char *data );
-
-H5_HLDLL herr_t H5LTget_attribute_char( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- char *data );
-
-H5_HLDLL herr_t H5LTget_attribute_uchar( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- unsigned char *data );
-
-H5_HLDLL herr_t H5LTget_attribute_short( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- short *data );
-
-H5_HLDLL herr_t H5LTget_attribute_ushort( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- unsigned short *data );
-
-H5_HLDLL herr_t H5LTget_attribute_int( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- int *data );
-
-H5_HLDLL herr_t H5LTget_attribute_uint( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- unsigned int *data );
-
-H5_HLDLL herr_t H5LTget_attribute_long( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- long *data );
-
-H5_HLDLL herr_t H5LTget_attribute_long_long( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- long long *data );
-
-H5_HLDLL herr_t H5LTget_attribute_ulong( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- unsigned long *data );
-
-H5_HLDLL herr_t H5LTget_attribute_float( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- float *data );
-
-H5_HLDLL herr_t H5LTget_attribute_double( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- double *data );
+H5_HLDLL herr_t H5LTget_attribute(hid_t loc_id, const char *obj_name, const char *attr_name,
+ hid_t mem_type_id, void *data);
+H5_HLDLL herr_t H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name,
+ char *data);
+
+H5_HLDLL herr_t H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data);
+
+H5_HLDLL herr_t H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name,
+ unsigned char *data);
+
+H5_HLDLL herr_t H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name,
+ short *data);
+
+H5_HLDLL herr_t H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name,
+ unsigned short *data);
+
+H5_HLDLL herr_t H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data);
+
+H5_HLDLL herr_t H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name,
+ unsigned int *data);
+
+H5_HLDLL herr_t H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data);
+
+H5_HLDLL herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name,
+ long long *data);
+
+H5_HLDLL herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name,
+ unsigned long *data);
+
+H5_HLDLL herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name,
+ float *data);
+
+H5_HLDLL herr_t H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name,
+ double *data);
/*-------------------------------------------------------------------------
*
@@ -312,22 +195,10 @@ H5_HLDLL herr_t H5LTget_attribute_double( hid_t loc_id,
*-------------------------------------------------------------------------
*/
+H5_HLDLL herr_t H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank);
-H5_HLDLL herr_t H5LTget_attribute_ndims( hid_t loc_id,
- const char *obj_name,
- const char *attr_name,
- int *rank );
-
-H5_HLDLL 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 );
-
-
-
-
+H5_HLDLL 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);
/*-------------------------------------------------------------------------
*
@@ -336,10 +207,9 @@ H5_HLDLL herr_t H5LTget_attribute_info( hid_t loc_id,
*-------------------------------------------------------------------------
*/
-H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type);
+H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type);
H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len);
-
/*-------------------------------------------------------------------------
*
* Utility functions
@@ -347,7 +217,7 @@ H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type,
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5LTfind_attribute( hid_t loc_id, const char *name );
+H5_HLDLL herr_t H5LTfind_attribute(hid_t loc_id, const char *name);
H5_HLDLL htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid);
@@ -365,4 +235,3 @@ H5_HLDLL hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flag
#endif
#endif
-
diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c
index f413bea..f397365 100644
--- a/hl/src/H5PT.c
+++ b/hl/src/H5PT.c
@@ -18,22 +18,21 @@
/* Packet Table private data */
-typedef struct
-{
- hid_t dset_id; /* The ID of the dataset containing this table */
- hid_t type_id; /* The ID of the packet table's native datatype */
- hsize_t current_index; /* The index of the packet that get_next_packet will read next */
- hsize_t size; /* The number of packets currently contained in this table */
+typedef struct {
+ hid_t dset_id; /* The ID of the dataset containing this table */
+ hid_t type_id; /* The ID of the packet table's native datatype */
+ hsize_t current_index; /* The index of the packet that get_next_packet will read next */
+ hsize_t size; /* The number of packets currently contained in this table */
} htbl_t;
-static hsize_t H5PT_ptable_count = 0;
+static hsize_t H5PT_ptable_count = 0;
static H5I_type_t H5PT_ptable_id_type = H5I_UNINIT;
#define H5PT_HASH_TABLE_SIZE 64
/* Packet Table private functions */
static herr_t H5PT_free_id(void *id);
-static herr_t H5PT_close( htbl_t* table );
+static herr_t H5PT_close(htbl_t *table);
static herr_t H5PT_create_index(htbl_t *table_id);
static herr_t H5PT_set_index(htbl_t *table_id, hsize_t pt_index);
static herr_t H5PT_get_index(htbl_t *table_id, hsize_t *pt_index);
@@ -71,109 +70,105 @@ static herr_t H5PT_get_index(htbl_t *table_id, hsize_t *pt_index);
*
*-------------------------------------------------------------------------
*/
-hid_t H5PTcreate(hid_t loc_id,
- const char *dset_name,
- hid_t dtype_id,
- hsize_t chunk_size,
- hid_t plist_id)
+hid_t
+H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, hid_t plist_id)
{
- htbl_t * table = NULL;
- hid_t dset_id = H5I_INVALID_HID;
- hid_t space_id = H5I_INVALID_HID;
- hid_t plistcopy_id = H5I_INVALID_HID;
- hsize_t dims[1];
- hsize_t dims_chunk[1];
- hsize_t maxdims[1];
- hid_t ret_value = H5I_INVALID_HID;
-
- /* check the arguments */
- if (dset_name == NULL) {
- goto error;
- }
-
- /* Register the packet table ID type if this is the first table created */
- if(H5PT_ptable_id_type < 0)
- if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0)
- goto error;
-
- /* Get memory for the table identifier */
- table = (htbl_t *)HDmalloc(sizeof(htbl_t));
- if ( table == NULL ) {
- goto error;
- }
- table->dset_id = H5I_INVALID_HID;
- table->type_id = H5I_INVALID_HID;
-
- /* Create a simple data space with unlimited size */
- dims[0] = 0;
- dims_chunk[0] = chunk_size;
- maxdims[0] = H5S_UNLIMITED;
- if((space_id = H5Screate_simple(1, dims, maxdims)) < 0)
- goto error;
-
- /* Modify dataset creation properties to enable chunking */
- if (plist_id == H5P_DEFAULT) {
- plistcopy_id = H5Pcreate(H5P_DATASET_CREATE);
- }
- else {
- plistcopy_id = H5Pcopy(plist_id);
- }
- if (chunk_size > 0)
- {
- if(H5Pset_chunk(plistcopy_id, 1, dims_chunk) < 0)
- goto error;
- }
-
- /* Create the dataset. */
- if((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plistcopy_id, H5P_DEFAULT)) < 0)
- goto error;
-
- /* Create the table identifier */
- table->dset_id = dset_id;
-
- /* Terminate access to the data space. */
- if(H5Sclose(space_id) < 0)
- goto error;
-
- /* End access to the property list */
- if(H5Pclose(plistcopy_id) < 0)
- goto error;
-
- /* Make a copy of caller's datatype and save it in the table structure.
- It will be closed when the table is closed */
- if((table->type_id = H5Tcopy(dtype_id)) < 0)
- goto error;
-
- H5PT_create_index(table);
- table->size = 0;
-
- /* Get an ID for this table */
- ret_value = H5Iregister(H5PT_ptable_id_type, table);
- if(ret_value != H5I_INVALID_HID)
- H5PT_ptable_count++;
- else
- H5PT_close(table);
-
- return ret_value;
+ htbl_t *table = NULL;
+ hid_t dset_id = H5I_INVALID_HID;
+ hid_t space_id = H5I_INVALID_HID;
+ hid_t plistcopy_id = H5I_INVALID_HID;
+ hsize_t dims[1];
+ hsize_t dims_chunk[1];
+ hsize_t maxdims[1];
+ hid_t ret_value = H5I_INVALID_HID;
+
+ /* check the arguments */
+ if (dset_name == NULL) {
+ goto error;
+ }
+
+ /* Register the packet table ID type if this is the first table created */
+ if (H5PT_ptable_id_type < 0)
+ if ((H5PT_ptable_id_type =
+ H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0)
+ goto error;
+
+ /* Get memory for the table identifier */
+ table = (htbl_t *)HDmalloc(sizeof(htbl_t));
+ if (table == NULL) {
+ goto error;
+ }
+ table->dset_id = H5I_INVALID_HID;
+ table->type_id = H5I_INVALID_HID;
+
+ /* Create a simple data space with unlimited size */
+ dims[0] = 0;
+ dims_chunk[0] = chunk_size;
+ maxdims[0] = H5S_UNLIMITED;
+ if ((space_id = H5Screate_simple(1, dims, maxdims)) < 0)
+ goto error;
+
+ /* Modify dataset creation properties to enable chunking */
+ if (plist_id == H5P_DEFAULT) {
+ plistcopy_id = H5Pcreate(H5P_DATASET_CREATE);
+ }
+ else {
+ plistcopy_id = H5Pcopy(plist_id);
+ }
+ if (chunk_size > 0) {
+ if (H5Pset_chunk(plistcopy_id, 1, dims_chunk) < 0)
+ goto error;
+ }
+
+ /* Create the dataset. */
+ if ((dset_id =
+ H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plistcopy_id, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create the table identifier */
+ table->dset_id = dset_id;
+
+ /* Terminate access to the data space. */
+ if (H5Sclose(space_id) < 0)
+ goto error;
+
+ /* End access to the property list */
+ if (H5Pclose(plistcopy_id) < 0)
+ goto error;
+
+ /* Make a copy of caller's datatype and save it in the table structure.
+ It will be closed when the table is closed */
+ if ((table->type_id = H5Tcopy(dtype_id)) < 0)
+ goto error;
+
+ H5PT_create_index(table);
+ table->size = 0;
+
+ /* Get an ID for this table */
+ ret_value = H5Iregister(H5PT_ptable_id_type, table);
+ if (ret_value != H5I_INVALID_HID)
+ H5PT_ptable_count++;
+ else
+ H5PT_close(table);
+
+ return ret_value;
error:
if (space_id != H5I_INVALID_HID)
- H5Sclose(space_id);
+ H5Sclose(space_id);
if (plistcopy_id != H5I_INVALID_HID)
- H5Pclose(plistcopy_id);
+ H5Pclose(plistcopy_id);
if (dset_id != H5I_INVALID_HID)
- H5Dclose(dset_id);
- if (table)
- {
+ H5Dclose(dset_id);
+ if (table) {
if (table->type_id != H5I_INVALID_HID)
- H5Tclose(table->type_id);
- HDfree(table);
+ H5Tclose(table->type_id);
+ HDfree(table);
}
return ret_value;
} /* H5PTcreate */
-
/*-------------------------------------------------------------------------
* Function: H5PTcreate_fl
*
@@ -196,98 +191,95 @@ error:
*-------------------------------------------------------------------------
*/
-hid_t H5PTcreate_fl ( hid_t loc_id,
- const char *dset_name,
- hid_t dtype_id,
- hsize_t chunk_size,
- int compression )
+hid_t
+H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, int compression)
{
- htbl_t * table = NULL;
- hid_t dset_id = H5I_INVALID_HID;
- hid_t space_id = H5I_INVALID_HID;
- hid_t plist_id = H5I_INVALID_HID;
- hsize_t dims[1];
- hsize_t dims_chunk[1];
- hsize_t maxdims[1];
- hid_t ret_value = H5I_INVALID_HID;
-
- /* check the arguments */
- if (dset_name == NULL) {
- goto error;
- }
-
- /* Register the packet table ID type if this is the first table created */
- if(H5PT_ptable_id_type < 0)
- if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0)
- goto error;
-
- /* Get memory for the table identifier */
- table = (htbl_t *)HDmalloc(sizeof(htbl_t));
- if ( table == NULL ) {
- goto error;
- }
- table->dset_id = H5I_INVALID_HID;
- table->type_id = H5I_INVALID_HID;
-
- /* Create a simple data space with unlimited size */
- dims[0] = 0;
- dims_chunk[0] = chunk_size;
- maxdims[0] = H5S_UNLIMITED;
- if((space_id = H5Screate_simple(1, dims, maxdims)) < 0)
- goto error;
-
- /* Modify dataset creation properties to enable chunking */
- plist_id = H5Pcreate(H5P_DATASET_CREATE);
- if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0)
- goto error;
- if(compression >= 0 && compression <= 9)
- if(H5Pset_deflate(plist_id, (unsigned)compression) < 0)
+ htbl_t *table = NULL;
+ hid_t dset_id = H5I_INVALID_HID;
+ hid_t space_id = H5I_INVALID_HID;
+ hid_t plist_id = H5I_INVALID_HID;
+ hsize_t dims[1];
+ hsize_t dims_chunk[1];
+ hsize_t maxdims[1];
+ hid_t ret_value = H5I_INVALID_HID;
+
+ /* check the arguments */
+ if (dset_name == NULL) {
goto error;
+ }
- /* Create the dataset. */
- if((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0)
- goto error;
+ /* Register the packet table ID type if this is the first table created */
+ if (H5PT_ptable_id_type < 0)
+ if ((H5PT_ptable_id_type =
+ H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0)
+ goto error;
- /* Create the table identifier */
- table->dset_id = dset_id;
+ /* Get memory for the table identifier */
+ table = (htbl_t *)HDmalloc(sizeof(htbl_t));
+ if (table == NULL) {
+ goto error;
+ }
+ table->dset_id = H5I_INVALID_HID;
+ table->type_id = H5I_INVALID_HID;
+
+ /* Create a simple data space with unlimited size */
+ dims[0] = 0;
+ dims_chunk[0] = chunk_size;
+ maxdims[0] = H5S_UNLIMITED;
+ if ((space_id = H5Screate_simple(1, dims, maxdims)) < 0)
+ goto error;
- /* Terminate access to the data space. */
- if(H5Sclose(space_id) < 0)
- goto error;
+ /* Modify dataset creation properties to enable chunking */
+ plist_id = H5Pcreate(H5P_DATASET_CREATE);
+ if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0)
+ goto error;
+ if (compression >= 0 && compression <= 9)
+ if (H5Pset_deflate(plist_id, (unsigned)compression) < 0)
+ goto error;
- /* End access to the property list */
- if(H5Pclose(plist_id) < 0)
- goto error;
+ /* Create the dataset. */
+ if ((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0)
+ goto error;
- /* Make a copy of caller's datatype and save it in the table structure.
- It will be closed when the table is closed */
- if((table->type_id = H5Tcopy(dtype_id)) < 0)
- goto error;
+ /* Create the table identifier */
+ table->dset_id = dset_id;
- H5PT_create_index(table);
- table->size = 0;
+ /* Terminate access to the data space. */
+ if (H5Sclose(space_id) < 0)
+ goto error;
+
+ /* End access to the property list */
+ if (H5Pclose(plist_id) < 0)
+ goto error;
+
+ /* Make a copy of caller's datatype and save it in the table structure.
+ It will be closed when the table is closed */
+ if ((table->type_id = H5Tcopy(dtype_id)) < 0)
+ goto error;
+
+ H5PT_create_index(table);
+ table->size = 0;
- /* Get an ID for this table */
- ret_value = H5Iregister(H5PT_ptable_id_type, table);
- if(ret_value != H5I_INVALID_HID)
- H5PT_ptable_count++;
- else
- H5PT_close(table);
+ /* Get an ID for this table */
+ ret_value = H5Iregister(H5PT_ptable_id_type, table);
+ if (ret_value != H5I_INVALID_HID)
+ H5PT_ptable_count++;
+ else
+ H5PT_close(table);
- return ret_value;
+ return ret_value;
error:
if (space_id != H5I_INVALID_HID)
- H5Sclose(space_id);
+ H5Sclose(space_id);
if (plist_id != H5I_INVALID_HID)
- H5Pclose(plist_id);
+ H5Pclose(plist_id);
if (dset_id != H5I_INVALID_HID)
- H5Dclose(dset_id);
- if (table)
- {
+ H5Dclose(dset_id);
+ if (table) {
if (table->type_id != H5I_INVALID_HID)
- H5Tclose(table->type_id);
- HDfree(table);
+ H5Tclose(table->type_id);
+ HDfree(table);
}
return ret_value;
@@ -317,87 +309,87 @@ error:
*
*-------------------------------------------------------------------------
*/
-hid_t H5PTopen( hid_t loc_id,
- const char *dset_name )
+hid_t
+H5PTopen(hid_t loc_id, const char *dset_name)
{
- hid_t type_id=H5I_INVALID_HID;
- hid_t space_id=H5I_INVALID_HID;
- htbl_t * table = NULL;
- hsize_t dims[1];
- hid_t ret_value = H5I_INVALID_HID;
-
- /* check the arguments */
- if (dset_name == NULL) {
- goto error;
- }
-
- /* Register the packet table ID type if this is the first table created */
- if( H5PT_ptable_id_type < 0)
- if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0)
- goto error;
-
- table = (htbl_t *)HDmalloc(sizeof(htbl_t));
- if ( table == NULL ) {
- goto error;
- }
- table->dset_id = H5I_INVALID_HID;
- table->type_id = H5I_INVALID_HID;
-
- /* Open the dataset */
- if((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
- goto error;
-
- /* Get the dataset's disk datatype */
- if((type_id = H5Dget_type(table->dset_id)) < 0)
- goto error;
-
- /* Make a copy of the datatype obtained and save it in the table structure.
- It will be closed when the table is closed */
- if((table->type_id = H5Tcopy(type_id)) < 0)
- goto error;
-
- /* Close the disk datatype */
- if(H5Tclose(type_id) < 0)
- goto error;
- type_id = H5I_INVALID_HID;
-
- /* Initialize the current record pointer */
- if((H5PT_create_index(table)) < 0)
- goto error;
-
- /* Get number of records in table */
- if((space_id=H5Dget_space(table->dset_id)) < 0)
- goto error;
- if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
- goto error;
- if(H5Sclose(space_id) < 0)
- goto error;
- space_id = H5I_INVALID_HID;
-
- table->size = dims[0];
-
- /* Get an ID for this table */
- ret_value = H5Iregister(H5PT_ptable_id_type, table);
-
- if(ret_value != H5I_INVALID_HID)
- H5PT_ptable_count++;
- else
- H5PT_close(table);
-
- return ret_value;
+ hid_t type_id = H5I_INVALID_HID;
+ hid_t space_id = H5I_INVALID_HID;
+ htbl_t *table = NULL;
+ hsize_t dims[1];
+ hid_t ret_value = H5I_INVALID_HID;
+
+ /* check the arguments */
+ if (dset_name == NULL) {
+ goto error;
+ }
+
+ /* Register the packet table ID type if this is the first table created */
+ if (H5PT_ptable_id_type < 0)
+ if ((H5PT_ptable_id_type =
+ H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0)
+ goto error;
+
+ table = (htbl_t *)HDmalloc(sizeof(htbl_t));
+ if (table == NULL) {
+ goto error;
+ }
+ table->dset_id = H5I_INVALID_HID;
+ table->type_id = H5I_INVALID_HID;
+
+ /* Open the dataset */
+ if ((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Get the dataset's disk datatype */
+ if ((type_id = H5Dget_type(table->dset_id)) < 0)
+ goto error;
+
+ /* Make a copy of the datatype obtained and save it in the table structure.
+ It will be closed when the table is closed */
+ if ((table->type_id = H5Tcopy(type_id)) < 0)
+ goto error;
+
+ /* Close the disk datatype */
+ if (H5Tclose(type_id) < 0)
+ goto error;
+ type_id = H5I_INVALID_HID;
+
+ /* Initialize the current record pointer */
+ if ((H5PT_create_index(table)) < 0)
+ goto error;
+
+ /* Get number of records in table */
+ if ((space_id = H5Dget_space(table->dset_id)) < 0)
+ goto error;
+ if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
+ goto error;
+ if (H5Sclose(space_id) < 0)
+ goto error;
+ space_id = H5I_INVALID_HID;
+
+ table->size = dims[0];
+
+ /* Get an ID for this table */
+ ret_value = H5Iregister(H5PT_ptable_id_type, table);
+
+ if (ret_value != H5I_INVALID_HID)
+ H5PT_ptable_count++;
+ else
+ H5PT_close(table);
+
+ return ret_value;
error:
if (type_id != H5I_INVALID_HID)
- H5Dclose(type_id);
+ H5Dclose(type_id);
if (space_id != H5I_INVALID_HID)
- H5Sclose(space_id);
- if(table)
- {
+ H5Sclose(space_id);
+ if (table) {
if (table->type_id != H5I_INVALID_HID)
- H5Tclose(table->type_id);
- if (table->dset_id != H5I_INVALID_HID)
- H5Dclose(table->dset_id);
- HDfree(table);
+ H5Tclose(table->type_id);
+ if (table->dset_id != H5I_INVALID_HID)
+ H5Dclose(table->dset_id);
+ HDfree(table);
}
return ret_value;
@@ -438,33 +430,32 @@ H5PT_free_id(void *id)
*-------------------------------------------------------------------------
*/
static herr_t
-H5PT_close( htbl_t* table)
+H5PT_close(htbl_t *table)
{
- if(table == NULL)
- goto error;
+ if (table == NULL)
+ goto error;
- /* Close the dataset */
- if(H5Dclose(table->dset_id) < 0)
- goto error;
+ /* Close the dataset */
+ if (H5Dclose(table->dset_id) < 0)
+ goto error;
- /* Close the memory datatype */
- if(H5Tclose(table->type_id) < 0)
- goto error;
+ /* Close the memory datatype */
+ if (H5Tclose(table->type_id) < 0)
+ goto error;
- HDfree(table);
+ HDfree(table);
- return SUCCEED;
+ return SUCCEED;
error:
- if(table)
- {
- H5E_BEGIN_TRY
- H5Dclose(table->dset_id);
- H5Tclose(table->type_id);
- H5E_END_TRY
- HDfree(table);
- }
- return FAIL;
+ if (table) {
+ H5E_BEGIN_TRY
+ H5Dclose(table->dset_id);
+ H5Tclose(table->type_id);
+ H5E_END_TRY
+ HDfree(table);
+ }
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -486,36 +477,35 @@ error:
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTclose( hid_t table_id )
+herr_t
+H5PTclose(hid_t table_id)
{
- htbl_t * table;
+ htbl_t *table;
- /* Remove the ID from the library */
- if((table = (htbl_t *)H5Iremove_verify(table_id, H5PT_ptable_id_type)) ==NULL)
- goto error;
+ /* Remove the ID from the library */
+ if ((table = (htbl_t *)H5Iremove_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- /* If the library found the table, remove it */
- if( H5PT_close(table) < 0)
- goto error;
+ /* If the library found the table, remove it */
+ if (H5PT_close(table) < 0)
+ goto error;
- /* One less packet table open */
- H5PT_ptable_count--;
+ /* One less packet table open */
+ H5PT_ptable_count--;
- /* Remove the packet table type ID if no more packet */
- /* tables are open */
- if(H5PT_ptable_count == 0)
- {
- H5Idestroy_type(H5PT_ptable_id_type);
- H5PT_ptable_id_type = H5I_UNINIT;
- }
+ /* Remove the packet table type ID if no more packet */
+ /* tables are open */
+ if (H5PT_ptable_count == 0) {
+ H5Idestroy_type(H5PT_ptable_id_type);
+ H5PT_ptable_id_type = H5I_UNINIT;
+ }
- return SUCCEED;
+ return SUCCEED;
error:
- return FAIL;
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
*
* Write functions
@@ -541,30 +531,28 @@ error:
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTappend( hid_t table_id,
- size_t nrecords,
- const void * data )
+herr_t
+H5PTappend(hid_t table_id, size_t nrecords, const void *data)
{
- htbl_t * table;
+ htbl_t *table;
- /* Find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- goto error;
+ /* Find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- /* If we are asked to write 0 records, just do nothing */
- if(nrecords == 0)
- return SUCCEED;
+ /* If we are asked to write 0 records, just do nothing */
+ if (nrecords == 0)
+ return SUCCEED;
- if((H5TB_common_append_records(table->dset_id, table->type_id,
- nrecords, table->size, data)) < 0)
- goto error;
+ if ((H5TB_common_append_records(table->dset_id, table->type_id, nrecords, table->size, data)) < 0)
+ goto error;
- /* Update table size */
- table->size += nrecords;
- return SUCCEED;
+ /* Update table size */
+ table->size += nrecords;
+ return SUCCEED;
error:
- return FAIL;
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -574,7 +562,6 @@ error:
*-------------------------------------------------------------------------
*/
-
/*-------------------------------------------------------------------------
* Function: H5PTget_next
*
@@ -595,30 +582,29 @@ error:
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTget_next( hid_t table_id,
- size_t nrecords,
- void * data)
+herr_t
+H5PTget_next(hid_t table_id, size_t nrecords, void *data)
{
- htbl_t * table;
+ htbl_t *table;
- /* Find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- goto error;
+ /* Find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- /* If nrecords == 0, do nothing */
- if(nrecords == 0)
- return SUCCEED;
+ /* If nrecords == 0, do nothing */
+ if (nrecords == 0)
+ return SUCCEED;
- if((H5TB_common_read_records(table->dset_id, table->type_id,
- table->current_index, nrecords, table->size, data)) < 0)
- goto error;
+ if ((H5TB_common_read_records(table->dset_id, table->type_id, table->current_index, nrecords, table->size,
+ data)) < 0)
+ goto error;
- /* Update the current index */
- table->current_index += nrecords;
- return SUCCEED;
+ /* Update the current index */
+ table->current_index += nrecords;
+ return SUCCEED;
error:
- return FAIL;
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -640,30 +626,27 @@ error:
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTread_packets( hid_t table_id,
- hsize_t start,
- size_t nrecords,
- void *data)
+herr_t
+H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, void *data)
{
- htbl_t * table;
+ htbl_t *table;
- /* find the table struct from its ID */
- table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type);
- if(table == NULL)
- goto error;
+ /* find the table struct from its ID */
+ table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type);
+ if (table == NULL)
+ goto error;
- /* If nrecords == 0, do nothing */
- if(nrecords == 0)
- return SUCCEED;
+ /* If nrecords == 0, do nothing */
+ if (nrecords == 0)
+ return SUCCEED;
- if( H5TB_common_read_records(table->dset_id, table->type_id,
- start, nrecords, table->size, data) < 0)
- goto error;
+ if (H5TB_common_read_records(table->dset_id, table->type_id, start, nrecords, table->size, data) < 0)
+ goto error;
- return SUCCEED;
+ return SUCCEED;
error:
- return FAIL;
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -694,40 +677,36 @@ error:
static herr_t
H5PT_create_index(htbl_t *table)
{
- if( table != NULL)
- {
- table->current_index = 0;
- return SUCCEED;
- }
- return FAIL;
+ if (table != NULL) {
+ table->current_index = 0;
+ return SUCCEED;
+ }
+ return FAIL;
}
static herr_t
H5PT_set_index(htbl_t *table, hsize_t pt_index)
{
- /* Ensure index is valid */
- if( table != NULL )
- {
- if( pt_index < table->size )
- {
- table->current_index = pt_index;
- return SUCCEED;
+ /* Ensure index is valid */
+ if (table != NULL) {
+ if (pt_index < table->size) {
+ table->current_index = pt_index;
+ return SUCCEED;
+ }
}
- }
- return FAIL;
+ return FAIL;
}
static herr_t
H5PT_get_index(htbl_t *table, hsize_t *pt_index)
{
- /* Ensure index is valid */
- if( table != NULL )
- {
- if(pt_index)
- *pt_index = table->current_index;
- return SUCCEED;
- }
- return FAIL;
+ /* Ensure index is valid */
+ if (table != NULL) {
+ if (pt_index)
+ *pt_index = table->current_index;
+ return SUCCEED;
+ }
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -748,37 +727,40 @@ H5PT_get_index(htbl_t *table, hsize_t *pt_index)
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTcreate_index(hid_t table_id)
+herr_t
+H5PTcreate_index(hid_t table_id)
{
- htbl_t * table;
+ htbl_t *table;
- /* find the table struct from its ID */
- if((table = (htbl_t *) (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- return FAIL;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)(htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ return FAIL;
- return H5PT_create_index(table);
+ return H5PT_create_index(table);
}
-herr_t H5PTset_index(hid_t table_id, hsize_t pt_index)
+herr_t
+H5PTset_index(hid_t table_id, hsize_t pt_index)
{
- htbl_t * table;
+ htbl_t *table;
- /* find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- return FAIL;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ return FAIL;
- return H5PT_set_index(table, pt_index);
+ return H5PT_set_index(table, pt_index);
}
-herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index)
+herr_t
+H5PTget_index(hid_t table_id, hsize_t *pt_index)
{
- htbl_t * table;
+ htbl_t *table;
- /* find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- return FAIL;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ return FAIL;
- return H5PT_get_index(table, pt_index);
+ return H5PT_get_index(table, pt_index);
}
/*-------------------------------------------------------------------------
@@ -807,24 +789,24 @@ herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index)
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTget_num_packets( hid_t table_id, hsize_t *nrecords)
+herr_t
+H5PTget_num_packets(hid_t table_id, hsize_t *nrecords)
{
- htbl_t * table;
+ htbl_t *table;
- /* find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- goto error;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- if(nrecords)
- *nrecords = table->size;
+ if (nrecords)
+ *nrecords = table->size;
- return SUCCEED;
+ return SUCCEED;
error:
- return FAIL;
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
* Function: H5PTis_valid
*
@@ -844,13 +826,14 @@ error:
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTis_valid(hid_t table_id)
+herr_t
+H5PTis_valid(hid_t table_id)
{
- /* find the table struct from its ID */
- if(H5Iobject_verify(table_id, H5PT_ptable_id_type) ==NULL)
- return FAIL;
+ /* find the table struct from its ID */
+ if (H5Iobject_verify(table_id, H5PT_ptable_id_type) == NULL)
+ return FAIL;
- return SUCCEED;
+ return SUCCEED;
}
/*-------------------------------------------------------------------------
@@ -873,25 +856,26 @@ herr_t H5PTis_valid(hid_t table_id)
*
*-------------------------------------------------------------------------
*/
-herr_t H5PTis_varlen(hid_t table_id)
+herr_t
+H5PTis_varlen(hid_t table_id)
{
- H5T_class_t type;
- htbl_t * table;
+ H5T_class_t type;
+ htbl_t * table;
- /* find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- goto error;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- if((type = H5Tget_class( table->type_id )) == H5T_NO_CLASS)
- goto error;
+ if ((type = H5Tget_class(table->type_id)) == H5T_NO_CLASS)
+ goto error;
- if( type == H5T_VLEN )
- return 1;
- else
- return 0;
+ if (type == H5T_VLEN)
+ return 1;
+ else
+ return 0;
error:
- return FAIL;
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -923,38 +907,37 @@ error:
*-------------------------------------------------------------------------
*/
-herr_t H5PTfree_vlen_buff( hid_t table_id,
- size_t _bufflen,
- void * buff )
+herr_t
+H5PTfree_vlen_buff(hid_t table_id, size_t _bufflen, void *buff)
{
- hid_t space_id = H5I_INVALID_HID;
- htbl_t * table;
- hsize_t bufflen = _bufflen;
- herr_t ret_value;
+ hid_t space_id = H5I_INVALID_HID;
+ htbl_t *table;
+ hsize_t bufflen = _bufflen;
+ herr_t ret_value;
- /* find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- goto error;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- if((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0)
- goto error;
+ if ((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0)
+ goto error;
- /* Free the memory. If this succeeds, ret_value should be 0. */
- if((ret_value = H5Treclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0)
- goto error;
+ /* Free the memory. If this succeeds, ret_value should be 0. */
+ if ((ret_value = H5Treclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0)
+ goto error;
- /* If the dataspace cannot be closed, return -2 to indicate that memory */
- /* was freed successfully but an error still occurred. */
- if(H5Sclose(space_id) < 0)
- return -2;
+ /* If the dataspace cannot be closed, return -2 to indicate that memory */
+ /* was freed successfully but an error still occurred. */
+ if (H5Sclose(space_id) < 0)
+ return -2;
- return ret_value;
+ return ret_value;
error:
- H5E_BEGIN_TRY
+ H5E_BEGIN_TRY
H5Sclose(space_id);
- H5E_END_TRY
- return FAIL;
+ H5E_END_TRY
+ return FAIL;
} /* H5PTfree_vlen_buff */
/*-------------------------------------------------------------------------
@@ -981,20 +964,21 @@ error:
*
*-------------------------------------------------------------------------
*/
-hid_t H5PTget_dataset(hid_t table_id)
+hid_t
+H5PTget_dataset(hid_t table_id)
{
- htbl_t * table;
- hid_t ret_value = H5I_INVALID_HID;
+ htbl_t *table;
+ hid_t ret_value = H5I_INVALID_HID;
- /* find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- goto error;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- ret_value = table->dset_id;
+ ret_value = table->dset_id;
error:
- return ret_value;
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1015,18 +999,19 @@ error:
*
*-------------------------------------------------------------------------
*/
-hid_t H5PTget_type( hid_t table_id)
+hid_t
+H5PTget_type(hid_t table_id)
{
- htbl_t * table;
- hid_t ret_value = H5I_INVALID_HID;
+ htbl_t *table;
+ hid_t ret_value = H5I_INVALID_HID;
- /* find the table struct from its ID */
- if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
- goto error;
+ /* find the table struct from its ID */
+ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL)
+ goto error;
- ret_value = table->type_id;
+ ret_value = table->type_id;
error:
- return ret_value;
+ return ret_value;
}
diff --git a/hl/src/H5PTprivate.h b/hl/src/H5PTprivate.h
index eec9df7..18ea3c2 100644
--- a/hl/src/H5PTprivate.h
+++ b/hl/src/H5PTprivate.h
@@ -21,4 +21,3 @@
#include "H5PTpublic.h"
#endif
-
diff --git a/hl/src/H5PTpublic.h b/hl/src/H5PTpublic.h
index 8a12c8c..a94e81c 100644
--- a/hl/src/H5PTpublic.h
+++ b/hl/src/H5PTpublic.h
@@ -14,7 +14,6 @@
#ifndef _H5PTpublic_H
#define _H5PTpublic_H
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -25,17 +24,16 @@ extern "C" {
*/
/* NOTE: H5PTcreate is replacing H5PTcreate_fl for better name due to the
removal of H5PTcreate_vl. H5PTcreate_fl may be retired in 1.8.19. */
-H5_HLDLL hid_t H5PTcreate(hid_t loc_id, const char *dset_name,
- hid_t dtype_id, hsize_t chunk_size, hid_t plist_id);
+H5_HLDLL hid_t H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size,
+ hid_t plist_id);
H5_HLDLL hid_t H5PTopen(hid_t loc_id, const char *dset_name);
H5_HLDLL herr_t H5PTclose(hid_t table_id);
/* This function may be removed from the packet table in release 1.8.19. */
-H5_HLDLL hid_t H5PTcreate_fl(hid_t loc_id, const char *dset_name,
- hid_t dtype_id, hsize_t chunk_size, int compression);
-
+H5_HLDLL hid_t H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size,
+ int compression);
/*-------------------------------------------------------------------------
* Write functions
@@ -47,10 +45,9 @@ H5_HLDLL herr_t H5PTappend(hid_t table_id, size_t nrecords, const void *data);
* Read functions
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5PTget_next(hid_t table_id, size_t nrecords, void * data);
+H5_HLDLL herr_t H5PTget_next(hid_t table_id, size_t nrecords, void *data);
-H5_HLDLL herr_t H5PTread_packets(hid_t table_id, hsize_t start,
- size_t nrecords, void *data);
+H5_HLDLL herr_t H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, void *data);
/*-------------------------------------------------------------------------
* Inquiry functions
@@ -80,13 +77,11 @@ H5_HLDLL hid_t H5PTget_type(hid_t table_id);
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5PTcreate_index( hid_t table_id );
+H5_HLDLL herr_t H5PTcreate_index(hid_t table_id);
-H5_HLDLL herr_t H5PTset_index( hid_t table_id,
- hsize_t pt_index );
+H5_HLDLL herr_t H5PTset_index(hid_t table_id, hsize_t pt_index);
-H5_HLDLL herr_t H5PTget_index( hid_t table_id,
- hsize_t *pt_index );
+H5_HLDLL herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index);
/*-------------------------------------------------------------------------
*
@@ -95,13 +90,10 @@ H5_HLDLL herr_t H5PTget_index( hid_t table_id,
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5PTfree_vlen_buff( hid_t table_id,
- size_t bufflen,
- void * buff );
+H5_HLDLL herr_t H5PTfree_vlen_buff(hid_t table_id, size_t bufflen, void *buff);
#ifdef __cplusplus
}
#endif
#endif
-
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c
index c54c41f..5d51856 100644
--- a/hl/src/H5TB.c
+++ b/hl/src/H5TB.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -17,178 +17,160 @@
#include "H5LTprivate.h"
#include "H5TBprivate.h"
-
/*-------------------------------------------------------------------------
-*
-* internal functions
-*
-*-------------------------------------------------------------------------
-*/
-
-static hbool_t H5TB_find_field(const char *field,
- const char *field_list);
-
-static herr_t H5TB_attach_attributes(const char *table_title,
- hid_t loc_id,
- const char *dset_name,
- hsize_t nfields,
- hid_t tid);
-
-static hid_t H5TB_create_type(hid_t loc_id,
- const char *dset_name,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- hid_t ftype_id);
+ *
+ * internal functions
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static hbool_t H5TB_find_field(const char *field, const char *field_list);
+
+static herr_t H5TB_attach_attributes(const char *table_title, hid_t loc_id, const char *dset_name,
+ hsize_t nfields, hid_t tid);
+
+static hid_t H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size,
+ const size_t *field_offset, const size_t *field_sizes, 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:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+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 did = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t mem_type_id = H5I_BADID;
- hid_t plist_id = H5I_BADID;
- hid_t attr_id = H5I_BADID;
- hsize_t dims[1];
- hsize_t dims_chunk[1];
- hsize_t maxdims[1] = {H5S_UNLIMITED};
- char attr_name[255];
- char *member_name = NULL;
- unsigned char *tmp_buf = NULL;
- hsize_t i;
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t mem_type_id = H5I_BADID;
+ hid_t plist_id = H5I_BADID;
+ hid_t attr_id = H5I_BADID;
+ hsize_t dims[1];
+ hsize_t dims_chunk[1];
+ hsize_t maxdims[1] = {H5S_UNLIMITED};
+ char attr_name[255];
+ char * member_name = NULL;
+ unsigned char *tmp_buf = NULL;
+ hsize_t i;
+ herr_t ret_val = -1;
/* check the arguments */
if (table_title == NULL) {
- goto out;
+ goto out;
}
if (dset_name == NULL) {
- goto out;
+ goto out;
}
if (field_names == NULL) {
- goto out;
+ goto out;
}
dims[0] = nrecords;
dims_chunk[0] = chunk_size;
/* create the memory data type. */
- if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
+ if ((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
goto out;
/* insert fields. */
- for(i = 0; i < nfields; i++)
- if(H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i] ) < 0)
+ for (i = 0; i < nfields; i++)
+ if (H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i]) < 0)
goto out;
/* create a simple data space with unlimited size */
- if((sid = H5Screate_simple(1, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(1, dims, maxdims)) < 0)
goto out;
/* modify dataset creation properties, i.e. enable chunking */
- if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
- if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0)
+ if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0)
goto out;
/* 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)
+ if (fill_data)
+ if (H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0)
goto out;
/*
dataset creation property list is modified to use
GZIP compression with the compression effort set to 6.
*/
- if(compress)
- if(H5Pset_deflate(plist_id, 6) < 0)
+ if (compress)
+ if (H5Pset_deflate(plist_id, 6) < 0)
goto out;
/* create the dataset. */
- if((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0)
+ 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)
- if(H5Dwrite(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if (buf)
+ 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)
+ if (H5Sclose(sid) < 0)
goto out;
sid = H5I_BADID;
/* end access to the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
did = H5I_BADID;
/* end access to the property list */
- if(H5Pclose(plist_id) < 0)
+ if (H5Pclose(plist_id) < 0)
goto out;
plist_id = H5I_BADID;
/*-------------------------------------------------------------------------
- * set the conforming table attributes
- *-------------------------------------------------------------------------
- */
+ * set the conforming table attributes
+ *-------------------------------------------------------------------------
+ */
/* attach the CLASS attribute */
- if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0)
+ 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)
+ 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)
+ 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++) {
+ for (i = 0; i < nfields; i++) {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(mem_type_id, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(mem_type_id, (unsigned)i)))
goto out;
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_NAME", (int)i);
/* attach the attribute */
- if(H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0)
+ if (H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0)
goto out;
H5free_memory(member_name);
@@ -196,283 +178,269 @@ herr_t H5TBmake_table(const char *table_title,
} /* end for */
/* attach the FIELD_ fill value attribute */
- if(fill_data) {
+ if (fill_data) {
tmp_buf = (unsigned char *)fill_data;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
- if((sid = H5Screate(H5S_SCALAR)) < 0)
+ if ((sid = H5Screate(H5S_SCALAR)) < 0)
goto out;
- for(i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++) {
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i);
- if((attr_id = H5Acreate2(did, attr_name, field_types[i], sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ 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)
+ if (H5Awrite(attr_id, field_types[i], tmp_buf + field_offset[i]) < 0)
goto out;
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
attr_id = H5I_BADID;
} /* end for */
/* terminate access to the data space. */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
sid = H5I_BADID;
/* end access to the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
did = H5I_BADID;
} /* end if */
/* release the datatype. */
- if(H5Tclose(mem_type_id) < 0)
+ if (H5Tclose(mem_type_id) < 0)
goto out;
mem_type_id = H5I_BADID;
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
- if(attr_id > 0)
- if(H5Aclose(attr_id) < 0)
+ if (attr_id > 0)
+ if (H5Aclose(attr_id) < 0)
ret_val = -1;
- if(plist_id > 0)
- if(H5Pclose(plist_id) < 0)
+ if (plist_id > 0)
+ if (H5Pclose(plist_id) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBmake_table() */
/*-------------------------------------------------------------------------
-*
-* 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
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t mem_type_id = H5I_BADID;
- hsize_t nrecords_orig;
- hsize_t nfields;
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t mem_type_id = H5I_BADID;
+ hsize_t nrecords_orig;
+ hsize_t nfields;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* get the original number of records and fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatypes */
- if((tid = H5Dget_type(did)) < 0)
+ 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)
+ 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)
+ if ((H5TB_common_append_records(did, mem_type_id, (size_t)nrecords, nrecords_orig, buf)) < 0)
goto out;
ret_val = 0;
out:
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBappend_records() */
/*-------------------------------------------------------------------------
-* 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
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hid_t mem_type_id = H5I_BADID;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t mem_size[1];
- hsize_t dims[1];
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hid_t mem_type_id = H5I_BADID;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t mem_size[1];
+ hsize_t dims[1];
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ 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)
+ 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)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get records */
- if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
- if(start + nrecords > dims[0])
+ 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)
+ 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)
+ 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)
+ if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0)
goto out;
ret_val = 0;
out:
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBwrite_records() */
/*-------------------------------------------------------------------------
-* Function: H5TBwrite_fields_name
-*
-* Purpose: Writes fields
-*
-* Return: Success: 0, Failure: -1
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: November 21, 2001
-*
-* Comments:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * Function: H5TBwrite_fields_name
+ *
+ * Purpose: Writes fields
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 21, 2001
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t write_type_id = H5I_BADID;
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t write_type_id = H5I_BADID;
hid_t member_type_id = H5I_BADID;
- hid_t nmtype_id = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hid_t file_space_id = H5I_BADID;
- hid_t preserve_id = H5I_BADID;
+ hid_t nmtype_id = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hid_t file_space_id = H5I_BADID;
+ hid_t preserve_id = H5I_BADID;
hssize_t nfields;
hssize_t i, j;
hsize_t count[1];
hsize_t offset[1];
- char *member_name = NULL;
+ char * member_name = NULL;
size_t size_native;
herr_t ret_val = -1;
@@ -483,70 +451,70 @@ herr_t H5TBwrite_fields_name(hid_t loc_id,
goto out;
/* create xfer properties to preserve initialized data */
- if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto out;
- if(H5Pset_preserve(preserve_id, 1) < 0)
+ if (H5Pset_preserve(preserve_id, 1) < 0)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
/* get the number of fields */
- if((nfields = H5Tget_nmembers(tid)) < 0)
+ if ((nfields = H5Tget_nmembers(tid)) < 0)
goto out;
/* create a write id */
- if((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
+ if ((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
goto out;
j = 0;
/* iterate though the members */
- for(i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++) {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i)))
goto out;
- if(H5TB_find_field(member_name, field_names)) {
+ if (H5TB_find_field(member_name, field_names)) {
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid, (unsigned)i)) < 0)
+ 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)
+ if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0)
goto out;
- if(0 == (size_native = H5Tget_size(nmtype_id)))
+ if (0 == (size_native = H5Tget_size(nmtype_id)))
goto out;
/* adjust, if necessary */
- if(field_sizes[j] != size_native)
- if(H5Tset_size(nmtype_id, field_sizes[j]) < 0)
+ 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) {
- if(H5Tinsert(write_type_id, member_name, field_offset[j], nmtype_id) < 0)
+ if (field_offset) {
+ if (H5Tinsert(write_type_id, member_name, field_offset[j], nmtype_id) < 0)
goto out;
} /* end if */
/* only one field */
else {
- if(H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0)
+ if (H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0)
goto out;
} /* end else */
j++;
/* close */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
- if(H5Tclose(nmtype_id) < 0)
+ if (H5Tclose(nmtype_id) < 0)
goto out;
nmtype_id = H5I_BADID;
} /* end if */
@@ -556,156 +524,150 @@ herr_t H5TBwrite_fields_name(hid_t loc_id,
} /* end for */
/* get the dataspace handle */
- if((file_space_id = H5Dget_space(did)) < 0)
+ if ((file_space_id = H5Dget_space(did)) < 0)
goto out;
- if((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0)
+ 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)
+ 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)
+ if (H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0)
goto out;
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
- if(preserve_id > 0)
- if(H5Pclose(preserve_id) < 0)
+ if (preserve_id > 0)
+ if (H5Pclose(preserve_id) < 0)
ret_val = -1;
- if(write_type_id > 0)
- if(H5Tclose(write_type_id) < 0)
+ if (write_type_id > 0)
+ if (H5Tclose(write_type_id) < 0)
ret_val = -1;
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(file_space_id > 0)
- if(H5Sclose(file_space_id) < 0)
+ if (file_space_id > 0)
+ if (H5Sclose(file_space_id) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBwrite_fields_name() */
/*-------------------------------------------------------------------------
-* 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
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t write_type_id = H5I_BADID;
- hid_t member_type_id = H5I_BADID;
- hid_t nmtype_id = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hid_t file_space_id = H5I_BADID;
- hid_t preserve_id = H5I_BADID;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t i;
- size_t size_native;
- char *member_name = NULL;
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t write_type_id = H5I_BADID;
+ hid_t member_type_id = H5I_BADID;
+ hid_t nmtype_id = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hid_t file_space_id = H5I_BADID;
+ hid_t preserve_id = H5I_BADID;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t i;
+ size_t size_native;
+ char * member_name = NULL;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* create xfer properties to preserve initialized data */
- if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto out;
- if(H5Pset_preserve(preserve_id, 1) < 0)
+ if (H5Pset_preserve(preserve_id, 1) < 0)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
/* create a write id */
- if((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
+ if ((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
goto out;
/* iterate tru the members */
- for(i = 0; i < nfields; i++) {
- unsigned j;
+ for (i = 0; i < nfields; i++) {
+ unsigned j;
/* Range check value */
- if(field_index[i] < 0)
+ if (field_index[i] < 0)
goto out;
j = (unsigned)field_index[i];
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid, j)))
+ if (NULL == (member_name = H5Tget_member_name(tid, j)))
goto out;
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid, j)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid, j)) < 0)
goto out;
/* convert to native type */
- if((nmtype_id = H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0)
+ if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0)
goto out;
- if(0 == (size_native = H5Tget_size(nmtype_id)))
+ if (0 == (size_native = H5Tget_size(nmtype_id)))
goto out;
- if(field_sizes[i] != size_native)
- if(H5Tset_size(nmtype_id, field_sizes[i]) < 0)
+ 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) {
- if(H5Tinsert(write_type_id, member_name, field_offset[i], nmtype_id) < 0)
+ if (field_offset) {
+ if (H5Tinsert(write_type_id, member_name, field_offset[i], nmtype_id) < 0)
goto out;
} /* end if */
/* only one field */
else {
- if(H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0)
+ if (H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0)
goto out;
} /* end else */
/* close */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
- if(H5Tclose(nmtype_id) < 0)
+ if (H5Tclose(nmtype_id) < 0)
goto out;
nmtype_id = H5I_BADID;
@@ -714,250 +676,236 @@ herr_t H5TBwrite_fields_index(hid_t loc_id,
} /* end for */
/* get the dataspace handles */
- if((file_space_id = H5Dget_space(did)) < 0)
+ if ((file_space_id = H5Dget_space(did)) < 0)
goto out;
- if((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0)
+ 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)
+ 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)
+ if (H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0)
goto out;
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
- if(preserve_id > 0)
- if(H5Pclose(preserve_id) < 0)
+ if (preserve_id > 0)
+ if (H5Pclose(preserve_id) < 0)
ret_val = -1;
- if(write_type_id > 0)
- if(H5Tclose(write_type_id) < 0)
+ if (write_type_id > 0)
+ if (H5Tclose(write_type_id) < 0)
ret_val = -1;
- if(member_type_id > 0)
- if(H5Tclose(member_type_id) < 0)
+ if (member_type_id > 0)
+ if (H5Tclose(member_type_id) < 0)
ret_val = -1;
- if(nmtype_id > 0)
- if(H5Tclose(nmtype_id) < 0)
+ if (nmtype_id > 0)
+ if (H5Tclose(nmtype_id) < 0)
ret_val = -1;
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(file_space_id > 0)
- if(H5Sclose(file_space_id) < 0)
+ if (file_space_id > 0)
+ if (H5Sclose(file_space_id) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBwrite_fields_index() */
-
/*-------------------------------------------------------------------------
-*
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * Function: H5TBread_table
+ *
+ * Purpose: Reads a table
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 20, 2001
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t ftype_id = H5I_BADID;
- hid_t mem_type_id = H5I_BADID;
- hid_t sid = H5I_BADID;
- hsize_t dims[1];
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t ftype_id = H5I_BADID;
+ hid_t mem_type_id = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hsize_t dims[1];
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get dimensions */
- if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
/* get the datatypes */
- if((ftype_id = H5Dget_type (did)) < 0)
+ 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)
+ 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)
+ if (H5Dread(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, dst_buf) < 0)
goto out;
ret_val = 0;
out:
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
- if(ftype_id > 0)
- if(H5Tclose(ftype_id) < 0)
+ if (ftype_id > 0)
+ if (H5Tclose(ftype_id) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBread_table() */
/*-------------------------------------------------------------------------
-* Function: H5TBread_records
-*
-* Purpose: Reads records
-*
-* Return: Success: 0, Failure: -1
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: November 19, 2001
-*
-* Comments:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * Function: H5TBread_records
+ *
+ * Purpose: Reads records
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 19, 2001
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t ftype_id = H5I_BADID;
- hid_t mem_type_id = H5I_BADID;
- hsize_t nrecords_orig;
- hsize_t nfields;
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t ftype_id = H5I_BADID;
+ hid_t mem_type_id = H5I_BADID;
+ hsize_t nrecords_orig;
+ hsize_t nfields;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* get the number of records and fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0)
goto out;
/* open the dataset */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatypes */
- if((ftype_id = H5Dget_type(did)) < 0)
+ 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)
+ 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)
+ if ((H5TB_common_read_records(did, mem_type_id, start, (size_t)nrecords, nrecords_orig, buf)) < 0)
goto out;
ret_val = 0;
out:
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
- if(ftype_id > 0)
- if(H5Tclose(ftype_id) < 0)
+ if (ftype_id > 0)
+ if (H5Tclose(ftype_id) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBread_records() */
/*-------------------------------------------------------------------------
-* Function: H5TBread_fields_name
-*
-* Purpose: Reads fields
-*
-* Return: Success: 0, Failure: -1
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: November 19, 2001
-*
-* Comments:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * Function: H5TBread_fields_name
+ *
+ * Purpose: Reads fields
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 19, 2001
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t ftype_id = H5I_BADID;
+ hid_t did = H5I_BADID;
+ hid_t ftype_id = H5I_BADID;
hid_t mem_type_id = H5I_BADID;
- hid_t mtype_id = H5I_BADID;
- hid_t nmtype_id = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
+ hid_t mtype_id = H5I_BADID;
+ hid_t nmtype_id = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
hssize_t nfields;
hsize_t count[1];
hsize_t offset[1];
hsize_t mem_size[1];
size_t size_native;
- char *member_name = NULL;
+ char * member_name = NULL;
hssize_t i, j;
herr_t ret_val = -1;
-
/* check the arguments */
if (dset_name == NULL)
goto out;
@@ -965,58 +913,58 @@ herr_t H5TBread_fields_name(hid_t loc_id,
goto out;
/* open the dataset */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((ftype_id = H5Dget_type(did)) < 0)
+ if ((ftype_id = H5Dget_type(did)) < 0)
goto out;
/* get the number of fields */
- if((nfields = H5Tget_nmembers(ftype_id)) < 0)
+ if ((nfields = H5Tget_nmembers(ftype_id)) < 0)
goto out;
/* create a memory read id */
- if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
+ if ((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
goto out;
/* iterate through the members */
- for(i = 0, j = 0; i < nfields; i++) {
+ for (i = 0, j = 0; i < nfields; i++) {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i)))
goto out;
- if(H5TB_find_field(member_name, field_names)) {
+ if (H5TB_find_field(member_name, field_names)) {
/* get the member type */
- if((mtype_id = H5Tget_member_type(ftype_id, (unsigned)i)) < 0)
+ 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)
+ if ((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0)
goto out;
- if(0 == (size_native = H5Tget_size(nmtype_id)))
+ if (0 == (size_native = H5Tget_size(nmtype_id)))
goto out;
- if(field_sizes[j] != size_native)
- if(H5Tset_size(nmtype_id, field_sizes[j]) < 0)
+ 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) {
- if(H5Tinsert(mem_type_id, member_name, field_offset[j], nmtype_id) < 0)
+ if (field_offset) {
+ if (H5Tinsert(mem_type_id, member_name, field_offset[j], nmtype_id) < 0)
goto out;
} /* end if */
else {
- if(H5Tinsert(mem_type_id, member_name, (size_t)0, nmtype_id) < 0)
+ if (H5Tinsert(mem_type_id, member_name, (size_t)0, nmtype_id) < 0)
goto out;
} /* end else */
/* close */
- if(H5Tclose(mtype_id) < 0)
+ if (H5Tclose(mtype_id) < 0)
goto out;
mtype_id = H5I_BADID;
- if(H5Tclose(nmtype_id) < 0)
+ if (H5Tclose(nmtype_id) < 0)
goto out;
nmtype_id = H5I_BADID;
j++;
@@ -1027,159 +975,153 @@ herr_t H5TBread_fields_name(hid_t loc_id,
} /* end for */
/* check to make sure field was found, no reason to continue if it does not exist */
- if(j == 0)
- goto out;
+ if (j == 0)
+ goto out;
/* get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ 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)
+ 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)
+ 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)
+ if (H5Dread(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0)
goto out;
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
- if(mtype_id > 0)
- if(H5Tclose(mtype_id) < 0)
+ if (mtype_id > 0)
+ if (H5Tclose(mtype_id) < 0)
ret_val = -1;
- if(nmtype_id > 0)
- if(H5Tclose(nmtype_id) < 0)
+ if (nmtype_id > 0)
+ if (H5Tclose(nmtype_id) < 0)
ret_val = -1;
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
- if(ftype_id > 0)
- if(H5Tclose(ftype_id) < 0)
+ if (ftype_id > 0)
+ if (H5Tclose(ftype_id) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBread_fields_name() */
/*-------------------------------------------------------------------------
-* Function: H5TBread_fields_index
-*
-* Purpose: Reads fields
-*
-* Return: Success: 0, Failure: -1
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: November 19, 2001
-*
-* Comments:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * Function: H5TBread_fields_index
+ *
+ * Purpose: Reads fields
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 19, 2001
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t read_type_id = H5I_BADID;
- hid_t member_type_id = H5I_BADID;
- hid_t nmtype_id = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t mem_size[1];
- hsize_t i;
- size_t size_native;
- char *member_name = NULL;
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t read_type_id = H5I_BADID;
+ hid_t member_type_id = H5I_BADID;
+ hid_t nmtype_id = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t mem_size[1];
+ hsize_t i;
+ size_t size_native;
+ char * member_name = NULL;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
/* create a read id */
- if((read_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
+ if ((read_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
goto out;
/* iterate tru the members */
- for(i = 0; i < nfields; i++) {
- unsigned j;
+ for (i = 0; i < nfields; i++) {
+ unsigned j;
/* Range check */
- if(field_index[i] < 0)
+ if (field_index[i] < 0)
goto out;
j = (unsigned)field_index[i];
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)j)))
+ if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)j)))
goto out;
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid, (unsigned)j)) < 0)
+ 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)
+ if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0)
goto out;
- if(0 == (size_native = H5Tget_size(nmtype_id)))
+ if (0 == (size_native = H5Tget_size(nmtype_id)))
goto out;
- if(field_sizes[i] != size_native)
- if(H5Tset_size(nmtype_id, field_sizes[i]) < 0)
+ 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) {
- if(H5Tinsert(read_type_id, member_name, field_offset[i], nmtype_id) < 0)
+ if (field_offset) {
+ if (H5Tinsert(read_type_id, member_name, field_offset[i], nmtype_id) < 0)
goto out;
} /* end if */
else {
- if(H5Tinsert(read_type_id, member_name, (size_t)0, nmtype_id) < 0)
+ if (H5Tinsert(read_type_id, member_name, (size_t)0, nmtype_id) < 0)
goto out;
} /* end else */
/* close the member type */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
- if(H5Tclose(nmtype_id) < 0)
+ if (H5Tclose(nmtype_id) < 0)
goto out;
nmtype_id = H5I_BADID;
@@ -1188,683 +1130,671 @@ herr_t H5TBread_fields_index(hid_t loc_id,
} /* end for */
/* get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ 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)
+ 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)
+ 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)
+ if (H5Dread(did, read_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0)
goto out;
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
- if(read_type_id > 0)
- if(H5Tclose(read_type_id) < 0)
+ if (read_type_id > 0)
+ if (H5Tclose(read_type_id) < 0)
ret_val = -1;
- if(member_type_id > 0)
- if(H5Tclose(member_type_id) < 0)
+ if (member_type_id > 0)
+ if (H5Tclose(member_type_id) < 0)
ret_val = -1;
- if(nmtype_id > 0)
- if(H5Tclose(nmtype_id) < 0)
+ if (nmtype_id > 0)
+ if (H5Tclose(nmtype_id) < 0)
ret_val = -1;
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBread_fields_index() */
-
/*-------------------------------------------------------------------------
-*
-* 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
-*
-*-------------------------------------------------------------------------
-*/
-herr_t H5TBdelete_record(hid_t loc_id,
- const char *dset_name,
- hsize_t start,
- hsize_t nrecords)
+ * 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
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hid_t mem_type_id = H5I_BADID;
- hsize_t nfields;
- hsize_t ntotal_records;
- hsize_t read_start;
- hsize_t read_nrecords;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t mem_size[1];
- hsize_t dims[1];
- size_t src_size;
- size_t *src_offset = NULL;
- size_t *src_sizes = NULL;
- unsigned char *tmp_buf = NULL;
- herr_t ret_val = -1;
-
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hid_t mem_type_id = H5I_BADID;
+ hsize_t nfields;
+ hsize_t ntotal_records;
+ hsize_t read_start;
+ hsize_t read_nrecords;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t mem_size[1];
+ hsize_t dims[1];
+ size_t src_size;
+ size_t * src_offset = NULL;
+ size_t * src_sizes = NULL;
+ unsigned char *tmp_buf = NULL;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/*-------------------------------------------------------------------------
- * first we get information about type size and offsets on disk
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0)
goto out;
- if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
goto out;
- if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
goto out;
/* get field info */
- if(H5TBget_field_info(loc_id, dset_name, NULL, src_sizes, src_offset, &src_size) < 0)
+ if (H5TBget_field_info(loc_id, dset_name, NULL, src_sizes, src_offset, &src_size) < 0)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * read the records after the deleted one(s)
- *-------------------------------------------------------------------------
- */
+ * read the records after the deleted one(s)
+ *-------------------------------------------------------------------------
+ */
- read_start = start + nrecords;
+ read_start = start + nrecords;
read_nrecords = ntotal_records - read_start;
- if(read_nrecords) {
- if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, src_size)))
+ if (read_nrecords) {
+ if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, src_size)))
goto out;
/* 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)
+ if (H5TBread_records(loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes,
+ tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
- * write the records in another position
- *-------------------------------------------------------------------------
- */
+ * write the records in another position
+ *-------------------------------------------------------------------------
+ */
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
/* get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
- /* create the memory data type. */
- if((mem_type_id = H5TB_create_type( loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0)
- goto out;
+ /* create the memory data type. */
+ if ((mem_type_id = H5TB_create_type(loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 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)
+ 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)
+ if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0)
goto out;
- if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0)
+ if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0)
goto out;
/* close */
- if(H5Sclose(m_sid) < 0)
+ if (H5Sclose(m_sid) < 0)
goto out;
m_sid = H5I_BADID;
- if(H5Tclose(mem_type_id) < 0)
- goto out;
+ if (H5Tclose(mem_type_id) < 0)
+ goto out;
mem_type_id = H5I_BADID;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
sid = H5I_BADID;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
tid = H5I_BADID;
} /* read_nrecords */
/*-------------------------------------------------------------------------
- * change the dataset dimension
- *-------------------------------------------------------------------------
- */
+ * change the dataset dimension
+ *-------------------------------------------------------------------------
+ */
dims[0] = ntotal_records - nrecords;
- if(H5Dset_extent(did, dims) < 0)
+ if (H5Dset_extent(did, dims) < 0)
goto out;
ret_val = 0;
out:
- if(tmp_buf)
+ if (tmp_buf)
HDfree(tmp_buf);
- if(src_offset)
+ if (src_offset)
HDfree(src_offset);
- if(src_sizes)
+ if (src_sizes)
HDfree(src_sizes);
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBdelete_record() */
/*-------------------------------------------------------------------------
-* 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
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t mem_type_id = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hsize_t nfields;
- hsize_t ntotal_records;
- hsize_t read_nrecords;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t dims[1];
- hsize_t mem_dims[1];
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t mem_type_id = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hsize_t nfields;
+ hsize_t ntotal_records;
+ hsize_t read_nrecords;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t dims[1];
+ hsize_t mem_dims[1];
unsigned char *tmp_buf = NULL;
- herr_t ret_val = -1;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/*-------------------------------------------------------------------------
- * read the records after the inserted one(s)
- *-------------------------------------------------------------------------
- */
+ * read the records after the inserted one(s)
+ *-------------------------------------------------------------------------
+ */
/* get the dimensions */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ 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)
+ 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;
- if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t) read_nrecords, type_size)))
+ if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, type_size)))
goto out;
/* 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)
+ if (H5TBread_records(loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes,
+ tmp_buf) < 0)
goto out;
/* extend the dataset */
dims[0] = ntotal_records + nrecords;
- if(H5Dset_extent(did, dims) < 0)
+ if (H5Dset_extent(did, dims) < 0)
goto out;
/*-------------------------------------------------------------------------
- * write the inserted records
- *-------------------------------------------------------------------------
- */
+ * write the inserted records
+ *-------------------------------------------------------------------------
+ */
/* create a simple memory data space */
mem_dims[0] = nrecords;
- if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0)
+ if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0)
goto out;
/* get the file data space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* 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)
+ 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)
+ 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)
+ if (H5Sclose(m_sid) < 0)
goto out;
m_sid = H5I_BADID;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
sid = H5I_BADID;
/*-------------------------------------------------------------------------
- * write the "pushed down" records
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0)
goto out;
/* get the file data space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* 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)
+ 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)
+ if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0)
goto out;
ret_val = 0;
out:
- if(tmp_buf)
+ if (tmp_buf)
HDfree(tmp_buf);
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(mem_type_id > 0)
- if(H5Tclose(mem_type_id) < 0)
+ if (mem_type_id > 0)
+ if (H5Tclose(mem_type_id) < 0)
ret_val = -1;
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBinsert_record() */
/*-------------------------------------------------------------------------
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID;
- hid_t tid = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t mem_size[1];
- hsize_t nfields;
- hsize_t ntotal_records;
- size_t type_size1;
- size_t src_size;
- size_t *src_offset = NULL;
- size_t *src_sizes = NULL;
- unsigned char *tmp_buf = NULL;
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID;
+ hid_t tid = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t mem_size[1];
+ hsize_t nfields;
+ hsize_t ntotal_records;
+ size_t type_size1;
+ size_t src_size;
+ size_t * src_offset = NULL;
+ size_t * src_sizes = NULL;
+ unsigned char *tmp_buf = NULL;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name1 == NULL)
- goto out;
+ goto out;
if (dset_name2 == NULL)
- goto out;
+ goto out;
/*-------------------------------------------------------------------------
- * first we get information about type size and offsets on disk
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if (H5TBget_table_info(loc_id, dset_name1, &nfields, &ntotal_records) < 0)
goto out;
- if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
goto out;
- if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
goto out;
/* get field info */
- if(H5TBget_field_info(loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0)
+ if (H5TBget_field_info(loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0)
goto out;
/*-------------------------------------------------------------------------
- * Get information about the first table and read it
- *-------------------------------------------------------------------------
- */
+ * Get information about the first table and read it
+ *-------------------------------------------------------------------------
+ */
/* open the 1st dataset. */
- if((did = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
/* get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get the size of the datatype */
- if(0 == (type_size1 = H5Tget_size(tid)))
+ if (0 == (type_size1 = H5Tget_size(tid)))
goto out;
- if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size1)))
+ if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size1)))
goto out;
/* define a hyperslab in the dataset of the size of the records */
offset[0] = start1;
count[0] = nrecords;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
+ 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)
+ if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0)
goto out;
- if(H5Dread(did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0)
+ if (H5Dread(did, tid, m_sid, sid, 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)
+ * 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;
ret_val = 0;
out:
- if(tmp_buf)
+ if (tmp_buf)
HDfree(tmp_buf);
- if(src_offset)
+ if (src_offset)
HDfree(src_offset);
- if(src_sizes)
+ if (src_sizes)
HDfree(src_sizes);
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBadd_records_from() */
/*-------------------------------------------------------------------------
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-herr_t H5TBcombine_tables(hid_t loc_id1,
- const char *dset_name1,
- hid_t loc_id2,
- const char *dset_name2,
- const char *dset_name3)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5TBcombine_tables(hid_t loc_id1, 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 = H5I_BADID;
- hid_t tid_1 = H5I_BADID;
- hid_t sid_1 = H5I_BADID;
- hid_t pid_1 = H5I_BADID;
+ hid_t did_1 = H5I_BADID;
+ hid_t tid_1 = H5I_BADID;
+ hid_t sid_1 = H5I_BADID;
+ hid_t pid_1 = H5I_BADID;
/* identifiers for the 2nd dataset. */
- hid_t did_2 = H5I_BADID;
- hid_t tid_2 = H5I_BADID;
- hid_t sid_2 = H5I_BADID;
- hid_t pid_2 = H5I_BADID;
+ hid_t did_2 = H5I_BADID;
+ hid_t tid_2 = H5I_BADID;
+ hid_t sid_2 = H5I_BADID;
+ hid_t pid_2 = H5I_BADID;
/* identifiers for the 3rd dataset. */
- hid_t did_3 = H5I_BADID;
- hid_t tid_3 = H5I_BADID;
- hid_t sid_3 = H5I_BADID;
- hid_t pid_3 = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hid_t member_type_id = H5I_BADID;
- hid_t attr_id = H5I_BADID;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t mem_size[1];
- hsize_t nfields;
- hsize_t nrecords;
- hsize_t dims[1];
- hsize_t maxdims[1] = {H5S_UNLIMITED};
- hsize_t i;
- size_t type_size;
- size_t member_offset;
- size_t src_size;
- size_t *src_offset = NULL;
- size_t *src_sizes = NULL;
- char attr_name[255];
- unsigned char *tmp_buf = NULL;
+ hid_t did_3 = H5I_BADID;
+ hid_t tid_3 = H5I_BADID;
+ hid_t sid_3 = H5I_BADID;
+ hid_t pid_3 = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hid_t member_type_id = H5I_BADID;
+ hid_t attr_id = H5I_BADID;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t mem_size[1];
+ hsize_t nfields;
+ hsize_t nrecords;
+ hsize_t dims[1];
+ hsize_t maxdims[1] = {H5S_UNLIMITED};
+ hsize_t i;
+ size_t type_size;
+ size_t member_offset;
+ size_t src_size;
+ size_t * src_offset = NULL;
+ size_t * src_sizes = NULL;
+ char attr_name[255];
+ unsigned char *tmp_buf = NULL;
unsigned char *tmp_fill_buf = NULL;
- htri_t has_fill;
- herr_t ret_val = -1;
+ htri_t has_fill;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name1 == NULL)
- goto out;
+ goto out;
if (dset_name2 == NULL)
- goto out;
+ goto out;
if (dset_name3 == NULL)
- goto out;
+ goto out;
/*-------------------------------------------------------------------------
- * first we get information about type size and offsets on disk
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if (H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0)
goto out;
- if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
goto out;
- if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
goto out;
/* get field info */
- if(H5TBget_field_info(loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0)
+ if (H5TBget_field_info(loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get information about the first table
- *-------------------------------------------------------------------------
- */
+ * get information about the first table
+ *-------------------------------------------------------------------------
+ */
/* open the 1st dataset. */
- if((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0)
+ if ((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid_1 = H5Dget_type(did_1)) < 0)
+ if ((tid_1 = H5Dget_type(did_1)) < 0)
goto out;
/* get the dataspace handle */
- if((sid_1 = H5Dget_space(did_1)) < 0)
+ if ((sid_1 = H5Dget_space(did_1)) < 0)
goto out;
/* get creation properties list */
- if((pid_1 = H5Dget_create_plist(did_1)) < 0)
+ 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)
+ if (H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0)
goto out;
/*-------------------------------------------------------------------------
- * make the merged table with no data originally
- *-------------------------------------------------------------------------
- */
+ * make the merged table with no data originally
+ *-------------------------------------------------------------------------
+ */
/* clone the property list */
- if((pid_3 = H5Pcopy(pid_1)) < 0)
+ if ((pid_3 = H5Pcopy(pid_1)) < 0)
goto out;
/* clone the type id */
- if((tid_3 = H5Tcopy(tid_1)) < 0)
+ 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.
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if ((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0)
goto out;
/* create the dataset */
- if((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0)
+ 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)
+ * attach the conforming table attributes
+ *-------------------------------------------------------------------------
+ */
+ if (H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get attributes
- *-------------------------------------------------------------------------
- */
- if(0 == (type_size = H5Tget_size(tid_3)))
+ * get attributes
+ *-------------------------------------------------------------------------
+ */
+ if (0 == (type_size = H5Tget_size(tid_3)))
goto out;
/* alloc fill value attribute buffer */
- if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(type_size)))
+ if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(type_size)))
goto out;
/* get the fill value attributes */
- if((has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf)) < 0)
+ if ((has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the fill attributes from previous table
- *-------------------------------------------------------------------------
- */
- if(has_fill) {
- if((sid = H5Screate(H5S_SCALAR)) < 0)
+ * attach the fill attributes from previous table
+ *-------------------------------------------------------------------------
+ */
+ if (has_fill) {
+ if ((sid = H5Screate(H5S_SCALAR)) < 0)
goto out;
- for(i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++) {
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0)
goto out;
/* get the member offset */
@@ -1872,249 +1802,245 @@ herr_t H5TBcombine_tables(hid_t loc_id1,
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i);
- if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ 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)
+ if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0)
goto out;
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
attr_id = H5I_BADID;
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
} /* end for */
/* close data space. */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
sid = H5I_BADID;
} /* end if */
/*-------------------------------------------------------------------------
- * read data from 1st table
- *-------------------------------------------------------------------------
- */
- if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size)))
+ * read data from 1st table
+ *-------------------------------------------------------------------------
+ */
+ if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size)))
goto out;
/* 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)
+ 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)
+ 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)
+ 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
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if (H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
- * release temporary resources
- *-------------------------------------------------------------------------
- */
- if(H5Sclose(m_sid) < 0)
+ * release temporary resources
+ *-------------------------------------------------------------------------
+ */
+ if (H5Sclose(m_sid) < 0)
goto out;
m_sid = H5I_BADID;
HDfree(tmp_buf);
tmp_buf = NULL;
/*-------------------------------------------------------------------------
- * get information about the 2nd table
- *-------------------------------------------------------------------------
- */
+ * get information about the 2nd table
+ *-------------------------------------------------------------------------
+ */
/* open the dataset. */
- if((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0)
+ if ((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid_2 = H5Dget_type(did_2)) < 0)
+ if ((tid_2 = H5Dget_type(did_2)) < 0)
goto out;
/* get the dataspace handle */
- if((sid_2 = H5Dget_space(did_2)) < 0)
+ if ((sid_2 = H5Dget_space(did_2)) < 0)
goto out;
/* get the property list handle */
- if((pid_2 = H5Dget_create_plist(did_2)) < 0)
+ 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)
+ if (H5TBget_table_info(loc_id2, dset_name2, &nfields, &nrecords) < 0)
goto out;
/*-------------------------------------------------------------------------
- * read data from 2nd table
- *-------------------------------------------------------------------------
- */
+ * read data from 2nd table
+ *-------------------------------------------------------------------------
+ */
- if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size)))
+ if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size)))
goto out;
/* 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)
+ 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)
+ 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)
+ 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
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if (H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0)
goto out;
ret_val = 0;
out:
- if(tmp_buf)
+ if (tmp_buf)
HDfree(tmp_buf);
- if(tmp_fill_buf)
+ if (tmp_fill_buf)
HDfree(tmp_fill_buf);
- if(src_offset)
+ if (src_offset)
HDfree(src_offset);
- if(src_sizes)
+ if (src_sizes)
HDfree(src_sizes);
- if(member_type_id > 0)
- if(H5Tclose(member_type_id) < 0)
+ if (member_type_id > 0)
+ if (H5Tclose(member_type_id) < 0)
ret_val = -1;
- if(attr_id > 0)
- if(H5Aclose(attr_id) < 0)
+ if (attr_id > 0)
+ if (H5Aclose(attr_id) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(sid_1 > 0)
- if(H5Sclose(sid_1) < 0)
+ if (sid_1 > 0)
+ if (H5Sclose(sid_1) < 0)
ret_val = -1;
- if(tid_1 > 0)
- if(H5Tclose(tid_1) < 0)
+ if (tid_1 > 0)
+ if (H5Tclose(tid_1) < 0)
ret_val = -1;
- if(pid_1 > 0)
- if(H5Pclose(pid_1) < 0)
+ if (pid_1 > 0)
+ if (H5Pclose(pid_1) < 0)
ret_val = -1;
- if(did_1 > 0)
- if(H5Dclose(did_1) < 0)
+ if (did_1 > 0)
+ if (H5Dclose(did_1) < 0)
ret_val = -1;
- if(sid_2 > 0)
- if(H5Sclose(sid_2) < 0)
+ if (sid_2 > 0)
+ if (H5Sclose(sid_2) < 0)
ret_val = -1;
- if(tid_2 > 0)
- if(H5Tclose(tid_2) < 0)
+ if (tid_2 > 0)
+ if (H5Tclose(tid_2) < 0)
ret_val = -1;
- if(pid_2 > 0)
- if(H5Pclose(pid_2) < 0)
+ if (pid_2 > 0)
+ if (H5Pclose(pid_2) < 0)
ret_val = -1;
- if(did_2 > 0)
- if(H5Dclose(did_2) < 0)
+ if (did_2 > 0)
+ if (H5Dclose(did_2) < 0)
ret_val = -1;
- if(sid_3 > 0)
- if(H5Sclose(sid_3) < 0)
+ if (sid_3 > 0)
+ if (H5Sclose(sid_3) < 0)
ret_val = -1;
- if(tid_3 > 0)
- if(H5Tclose(tid_3) < 0)
+ if (tid_3 > 0)
+ if (H5Tclose(tid_3) < 0)
ret_val = -1;
- if(pid_3 > 0)
- if(H5Pclose(pid_3) < 0)
+ if (pid_3 > 0)
+ if (H5Pclose(pid_3) < 0)
ret_val = -1;
- if(did_3 > 0)
- if(H5Dclose(did_3) < 0)
+ if (did_3 > 0)
+ if (H5Dclose(did_3) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBcombine_tables() */
/*-------------------------------------------------------------------------
-* Function: H5TBinsert_field
-*
-* Purpose: Inserts a field
-*
-* Return: Success: 0, Failure: -1
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: January 30, 2002
-*
-* Comments:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * Function: H5TBinsert_field
+ *
+ * Purpose: Inserts a field
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: January 30, 2002
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
/* identifiers for the 1st, original dataset */
- hid_t did_1 = H5I_BADID;
- hid_t tid_1 = H5I_BADID;
- hid_t sid_1 = H5I_BADID;
- hid_t pid_1 = H5I_BADID;
- hid_t msid_1 = H5I_BADID;
+ hid_t did_1 = H5I_BADID;
+ hid_t tid_1 = H5I_BADID;
+ hid_t sid_1 = H5I_BADID;
+ hid_t pid_1 = H5I_BADID;
+ hid_t msid_1 = H5I_BADID;
/* identifiers for the 2nd, new dataset */
- hid_t did_2 = H5I_BADID;
- hid_t tid_2 = H5I_BADID;
- hid_t sid_2 = H5I_BADID;
- hid_t pid_2 = H5I_BADID;
- hid_t msid_2 = H5I_BADID;
+ hid_t did_2 = H5I_BADID;
+ hid_t tid_2 = H5I_BADID;
+ hid_t sid_2 = H5I_BADID;
+ hid_t pid_2 = H5I_BADID;
+ hid_t msid_2 = H5I_BADID;
/* identifiers for the 3rd, final dataset */
- hid_t did_3 = H5I_BADID;
- hid_t tid_3 = H5I_BADID;
- hid_t sid_3 = H5I_BADID;
- hid_t member_type_id = H5I_BADID;
- hid_t write_type_id = H5I_BADID;
- hid_t preserve_id = H5I_BADID;
- hid_t attr_id = H5I_BADID;
- size_t member_size;
- size_t new_member_size = 0;
- size_t total_size;
- size_t curr_offset;
- hsize_t nfields;
- hsize_t nrecords;
- hsize_t dims_chunk[1];
- hsize_t dims[1];
- hsize_t maxdims[1] = { H5S_UNLIMITED };
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t mem_size[1];
- hsize_t i;
- char table_title[255];
- char attr_name[255];
- char *member_name = NULL;
- unsigned char *tmp_buf = NULL;
+ hid_t did_3 = H5I_BADID;
+ hid_t tid_3 = H5I_BADID;
+ hid_t sid_3 = H5I_BADID;
+ hid_t member_type_id = H5I_BADID;
+ hid_t write_type_id = H5I_BADID;
+ hid_t preserve_id = H5I_BADID;
+ hid_t attr_id = H5I_BADID;
+ size_t member_size;
+ size_t new_member_size = 0;
+ size_t total_size;
+ size_t curr_offset;
+ hsize_t nfields;
+ hsize_t nrecords;
+ hsize_t dims_chunk[1];
+ hsize_t dims[1];
+ hsize_t maxdims[1] = {H5S_UNLIMITED};
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t mem_size[1];
+ hsize_t i;
+ char table_title[255];
+ char attr_name[255];
+ char * member_name = NULL;
+ unsigned char *tmp_buf = NULL;
unsigned char *tmp_fill_buf = NULL;
- hbool_t inserted;
- herr_t ret_val = -1;
+ hbool_t inserted;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
@@ -2123,7 +2049,7 @@ herr_t H5TBinsert_field(hid_t loc_id,
goto out;
/* get the number of records and fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2132,27 +2058,27 @@ herr_t H5TBinsert_field(hid_t loc_id,
*/
/* open the dataset. */
- if((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get creation properties list */
- if((pid_1 = H5Dget_create_plist(did_1)) < 0)
+ if ((pid_1 = H5Dget_create_plist(did_1)) < 0)
goto out;
/* get the datatype */
- if((tid_1 = H5Dget_type(did_1)) < 0)
+ if ((tid_1 = H5Dget_type(did_1)) < 0)
goto out;
/* get the size of the datatype */
- if(0 == (total_size = H5Tget_size(tid_1)))
+ if (0 == (total_size = H5Tget_size(tid_1)))
goto out;
/* get the dataspace handle */
- if((sid_1 = H5Dget_space(did_1)) < 0)
+ if ((sid_1 = H5Dget_space(did_1)) < 0)
goto out;
/* get dimension */
- if(H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2161,15 +2087,15 @@ herr_t H5TBinsert_field(hid_t loc_id,
*/
/* get the table title */
- if((H5TBAget_title(did_1, table_title)) < 0)
+ if ((H5TBAget_title(did_1, table_title)) < 0)
goto out;
/* alloc fill value attribute buffer */
- if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(total_size)))
+ if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(total_size)))
goto out;
/* get the fill value attributes */
- if((H5TBAget_fill(loc_id, dset_name, did_1, tmp_fill_buf)) < 0)
+ if ((H5TBAget_fill(loc_id, dset_name, did_1, tmp_fill_buf)) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2178,31 +2104,31 @@ herr_t H5TBinsert_field(hid_t loc_id,
*/
/* get the new member size */
- if(0 == (member_size = H5Tget_size(field_type)))
+ if (0 == (member_size = H5Tget_size(field_type)))
goto out;
/* create the data type. */
- if((tid_2 = H5Tcreate(H5T_COMPOUND, (size_t)(total_size + member_size))) < 0)
+ if ((tid_2 = H5Tcreate(H5T_COMPOUND, (size_t)(total_size + member_size))) < 0)
goto out;
curr_offset = 0;
inserted = FALSE;
/* insert the old fields, counting with the new one */
- for(i = 0; i < nfields + 1; i++) {
- hsize_t idx;
+ for (i = 0; i < nfields + 1; i++) {
+ hsize_t idx;
idx = i;
- if(inserted)
+ if (inserted)
idx = i - 1;
- if(i == position) {
+ if (i == position) {
/* get the new member size */
- if(0 == (new_member_size = H5Tget_size(field_type)))
+ if (0 == (new_member_size = H5Tget_size(field_type)))
goto out;
/* insert the new field type */
- if(H5Tinsert(tid_2, field_name, curr_offset, field_type) < 0)
+ if (H5Tinsert(tid_2, field_name, curr_offset, field_type) < 0)
goto out;
curr_offset += new_member_size;
@@ -2211,19 +2137,19 @@ herr_t H5TBinsert_field(hid_t loc_id,
} /* end if */
else {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)idx)))
+ if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)idx)))
goto out;
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_1, (unsigned)idx)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)idx)) < 0)
goto out;
/* get the member size */
- if(0 == (member_size = H5Tget_size(member_type_id)))
+ if (0 == (member_size = H5Tget_size(member_type_id)))
goto out;
/* insert it into the new type */
- if(H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0)
+ if (H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0)
goto out;
curr_offset += member_size;
@@ -2232,11 +2158,11 @@ herr_t H5TBinsert_field(hid_t loc_id,
member_name = NULL;
/* close the member type */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
} /* end else */
- } /* end for */
+ } /* end for */
/*-------------------------------------------------------------------------
* create a new temporary dataset
@@ -2244,21 +2170,21 @@ herr_t H5TBinsert_field(hid_t loc_id,
*/
/* retrieve the size of chunk */
- if(H5Pget_chunk(pid_1, 1, dims_chunk) < 0)
+ 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)
+ if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0)
goto out;
/* modify dataset creation properties, i.e. enable chunking */
- if((pid_2 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((pid_2 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
- if(H5Pset_chunk(pid_2, 1, dims_chunk) < 0)
+ if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0)
goto out;
/* create the dataset. */
- if((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0)
+ if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2266,21 +2192,21 @@ herr_t H5TBinsert_field(hid_t loc_id,
*-------------------------------------------------------------------------
*/
- if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, (size_t)total_size)))
+ if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, (size_t)total_size)))
goto out;
/* 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)
+ 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)
+ 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)
+ if (H5Dread(did_1, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2289,7 +2215,7 @@ herr_t H5TBinsert_field(hid_t loc_id,
*/
/* write */
- if(H5Dwrite(did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0)
+ if (H5Dwrite(did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2298,27 +2224,27 @@ herr_t H5TBinsert_field(hid_t loc_id,
*/
/* create a write id */
- if((write_type_id = H5Tcreate(H5T_COMPOUND, (size_t)new_member_size)) < 0)
+ 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)
+ 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)
+ if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto out;
- if(H5Pset_preserve(preserve_id, 1) < 0)
+ if (H5Pset_preserve(preserve_id, 1) < 0)
goto out;
/* only write if there is something to write */
- if(buf) {
+ if (buf) {
/* create a memory dataspace handle */
- if((msid_2 = H5Screate_simple(1, mem_size, NULL)) < 0)
+ 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)
+ if (H5Dwrite(did_2, write_type_id, msid_2, sid_2, preserve_id, buf) < 0)
goto out;
} /* end if */
@@ -2326,14 +2252,14 @@ herr_t H5TBinsert_field(hid_t loc_id,
* delete 1st table
*-------------------------------------------------------------------------
*/
- if(H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0)
+ if (H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0)
goto out;
/*-------------------------------------------------------------------------
* rename 2nd table
*-------------------------------------------------------------------------
*/
- if(H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if (H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -2342,33 +2268,33 @@ herr_t H5TBinsert_field(hid_t loc_id,
*/
/* get the number of records and fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
/* open the dataset. */
- if((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid_3 = H5Dget_type(did_3)) < 0)
+ if ((tid_3 = H5Dget_type(did_3)) < 0)
goto out;
/* set the attributes */
- if(H5TB_attach_attributes(table_title, loc_id, dset_name, (hsize_t)nfields, tid_3) < 0)
+ if (H5TB_attach_attributes(table_title, loc_id, dset_name, (hsize_t)nfields, tid_3) < 0)
goto out;
/*-------------------------------------------------------------------------
* attach the fill attributes from previous table
*-------------------------------------------------------------------------
*/
- if((sid_3 = H5Screate(H5S_SCALAR)) < 0)
+ if ((sid_3 = H5Screate(H5S_SCALAR)) < 0)
goto out;
- for(i = 0; i < (nfields - 1); i++) {
- size_t member_offset;
+ for (i = 0; i < (nfields - 1); i++) {
+ size_t member_offset;
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0)
goto out;
/* get the member offset */
@@ -2376,18 +2302,18 @@ herr_t H5TBinsert_field(hid_t loc_id,
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i);
- if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0)
+ if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0)
goto out;
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
attr_id = H5I_BADID;
/* close the member type */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
} /* end for */
@@ -2396,24 +2322,24 @@ herr_t H5TBinsert_field(hid_t loc_id,
* attach the fill attribute from the new field, if present
*-------------------------------------------------------------------------
*/
- if(fill_data) {
+ if (fill_data) {
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)(nfields - 1));
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_3, (unsigned)nfields - 1)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)nfields - 1)) < 0)
goto out;
- if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if(H5Awrite(attr_id, member_type_id, fill_data) < 0)
+ if (H5Awrite(attr_id, member_type_id, fill_data) < 0)
goto out;
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
attr_id = H5I_BADID;
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
} /* end fill_data */
@@ -2421,115 +2347,113 @@ herr_t H5TBinsert_field(hid_t loc_id,
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
- if(tmp_buf)
+ if (tmp_buf)
HDfree(tmp_buf);
- if(tmp_fill_buf)
+ if (tmp_fill_buf)
HDfree(tmp_fill_buf);
- if(preserve_id > 0)
- if(H5Pclose(preserve_id) < 0)
+ if (preserve_id > 0)
+ if (H5Pclose(preserve_id) < 0)
ret_val = -1;
- if(msid_1 > 0)
- if(H5Sclose(msid_1) < 0)
+ if (msid_1 > 0)
+ if (H5Sclose(msid_1) < 0)
ret_val = -1;
- if(tid_1 > 0)
- if(H5Tclose(tid_1) < 0)
+ if (tid_1 > 0)
+ if (H5Tclose(tid_1) < 0)
ret_val = -1;
- if(pid_1 > 0)
- if(H5Pclose(pid_1) < 0)
+ if (pid_1 > 0)
+ if (H5Pclose(pid_1) < 0)
ret_val = -1;
- if(sid_1 > 0)
- if(H5Sclose(sid_1) < 0)
+ if (sid_1 > 0)
+ if (H5Sclose(sid_1) < 0)
ret_val = -1;
- if(did_1 > 0)
- if(H5Dclose(did_1) < 0)
+ if (did_1 > 0)
+ if (H5Dclose(did_1) < 0)
ret_val = -1;
- if(msid_2 > 0)
- if(H5Sclose(msid_2) < 0)
+ if (msid_2 > 0)
+ if (H5Sclose(msid_2) < 0)
ret_val = -1;
- if(sid_2 > 0)
- if(H5Sclose(sid_2) < 0)
+ if (sid_2 > 0)
+ if (H5Sclose(sid_2) < 0)
ret_val = -1;
- if(tid_2 > 0)
- if(H5Tclose(tid_2) < 0)
+ if (tid_2 > 0)
+ if (H5Tclose(tid_2) < 0)
ret_val = -1;
- if(pid_2 > 0)
- if(H5Pclose(pid_2) < 0)
+ if (pid_2 > 0)
+ if (H5Pclose(pid_2) < 0)
ret_val = -1;
- if(did_2 > 0)
- if(H5Dclose(did_2) < 0)
+ if (did_2 > 0)
+ if (H5Dclose(did_2) < 0)
ret_val = -1;
- if(sid_3 > 0)
- if(H5Sclose(sid_3) < 0)
+ if (sid_3 > 0)
+ if (H5Sclose(sid_3) < 0)
ret_val = -1;
- if(tid_3 > 0)
- if(H5Tclose(tid_3) < 0)
+ if (tid_3 > 0)
+ if (H5Tclose(tid_3) < 0)
ret_val = -1;
- if(did_3 > 0)
- if(H5Dclose(did_3) < 0)
+ if (did_3 > 0)
+ if (H5Dclose(did_3) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBinsert_field() */
/*-------------------------------------------------------------------------
-* Function: H5TBdelete_field
-*
-* Purpose: Deletes a field
-*
-* Return: Success: 0, Failure: -1
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: January 30, 2002
-*
-* Comments:
-*
-*-------------------------------------------------------------------------
-*/
-herr_t H5TBdelete_field(hid_t loc_id,
- const char *dset_name,
- const char *field_name)
+ * Function: H5TBdelete_field
+ *
+ * Purpose: Deletes a field
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: January 30, 2002
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name)
{
/* identifiers for the 1st original dataset */
- hid_t did_1 = H5I_BADID;
- hid_t tid_1 = H5I_BADID;
- hid_t sid_1 = H5I_BADID;
- hid_t pid_1 = H5I_BADID;
+ hid_t did_1 = H5I_BADID;
+ hid_t tid_1 = H5I_BADID;
+ hid_t sid_1 = H5I_BADID;
+ hid_t pid_1 = H5I_BADID;
/* identifiers for the 2nd new dataset */
- hid_t did_2 = H5I_BADID;
- hid_t tid_2 = H5I_BADID;
- hid_t sid_2 = H5I_BADID;
- hid_t pid_2 = H5I_BADID;
+ hid_t did_2 = H5I_BADID;
+ hid_t tid_2 = H5I_BADID;
+ hid_t sid_2 = H5I_BADID;
+ hid_t pid_2 = H5I_BADID;
/* identifiers for the 3rd final dataset */
- hid_t did_3 = H5I_BADID;
- hid_t tid_3 = H5I_BADID;
- hid_t member_type_id = H5I_BADID;
- hid_t preserve_id = H5I_BADID;
- hid_t read_type_id = H5I_BADID;
- hid_t write_type_id = H5I_BADID;
- hid_t attr_id = H5I_BADID;
- size_t member_size;
- size_t type_size1;
- size_t type_size2;
- size_t curr_offset;
- size_t delete_member_size = 0;
- size_t member_offset;
- hsize_t nfields;
- hsize_t nrecords;
- hsize_t dims_chunk[1];
- hsize_t dims[1];
- hsize_t maxdims[1] = { H5S_UNLIMITED };
- hsize_t i;
- char attr_name[255];
- char table_title[255];
- char *member_name = NULL;
- unsigned char *tmp_buf = NULL;
+ hid_t did_3 = H5I_BADID;
+ hid_t tid_3 = H5I_BADID;
+ hid_t member_type_id = H5I_BADID;
+ hid_t preserve_id = H5I_BADID;
+ hid_t read_type_id = H5I_BADID;
+ hid_t write_type_id = H5I_BADID;
+ hid_t attr_id = H5I_BADID;
+ size_t member_size;
+ size_t type_size1;
+ size_t type_size2;
+ size_t curr_offset;
+ size_t delete_member_size = 0;
+ size_t member_offset;
+ hsize_t nfields;
+ hsize_t nrecords;
+ hsize_t dims_chunk[1];
+ hsize_t dims[1];
+ hsize_t maxdims[1] = {H5S_UNLIMITED};
+ hsize_t i;
+ char attr_name[255];
+ char table_title[255];
+ char * member_name = NULL;
+ unsigned char *tmp_buf = NULL;
unsigned char *tmp_fill_buf = NULL;
- htri_t has_fill = FALSE;
- herr_t ret_val = -1;
-
+ htri_t has_fill = FALSE;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
@@ -2538,61 +2462,61 @@ herr_t H5TBdelete_field(hid_t loc_id,
goto out;
/* get the number of records and fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get information about the old data type
- *-------------------------------------------------------------------------
- */
+ * get information about the old data type
+ *-------------------------------------------------------------------------
+ */
/* open the dataset. */
- if((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get creation properties list */
- if((pid_1 = H5Dget_create_plist(did_1)) < 0)
+ if ((pid_1 = H5Dget_create_plist(did_1)) < 0)
goto out;
/* get the datatype */
- if((tid_1 = H5Dget_type(did_1)) < 0)
+ if ((tid_1 = H5Dget_type(did_1)) < 0)
goto out;
/* get the size of the datatype */
- if(0 == (type_size1 = H5Tget_size(tid_1)))
+ if (0 == (type_size1 = H5Tget_size(tid_1)))
goto out;
/* get the dataspace handle */
- if((sid_1 = H5Dget_space(did_1)) < 0)
+ if ((sid_1 = H5Dget_space(did_1)) < 0)
goto out;
/* get dimension */
- if(H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0)
+ 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
- *-------------------------------------------------------------------------
- */
+ * 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++) {
+ for (i = 0; i < nfields; i++) {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i)))
goto out;
/* we want to find the field to delete */
- if(H5TB_find_field(member_name, field_name)) {
+ if (H5TB_find_field(member_name, field_name)) {
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0)
goto out;
/* get the member size */
- if(0 == (delete_member_size = H5Tget_size(member_type_id)))
+ if (0 == (delete_member_size = H5Tget_size(member_type_id)))
goto out;
/* close the member type */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
@@ -2607,75 +2531,75 @@ herr_t H5TBdelete_field(hid_t loc_id,
} /* end for */
/* no field to delete was found */
- if(delete_member_size == 0)
+ if (delete_member_size == 0)
goto out;
/*-------------------------------------------------------------------------
- * create a new data type; we now insert all the fields into the new type
- *-------------------------------------------------------------------------
- */
+ * 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)
+ if ((tid_2 = H5Tcreate(H5T_COMPOUND, type_size2)) < 0)
goto out;
curr_offset = 0;
/* alloc fill value attribute buffer */
- if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc((size_t)type_size2)))
+ if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc((size_t)type_size2)))
goto out;
/*-------------------------------------------------------------------------
- * get attributes from previous table in the process
- *-------------------------------------------------------------------------
- */
+ * get attributes from previous table in the process
+ *-------------------------------------------------------------------------
+ */
/* get the table title */
- if((H5TBAget_title(did_1, table_title)) < 0)
+ 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++) {
+ for (i = 0; i < nfields; i++) {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i)))
goto out;
/* we want to skip the field to delete */
- if(!H5TB_find_field(member_name, field_name)) {
+ if (!H5TB_find_field(member_name, field_name)) {
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0)
goto out;
/* get the member size */
- if(0 == (member_size = H5Tget_size(member_type_id)))
+ if (0 == (member_size = H5Tget_size(member_type_id)))
goto out;
/* insert it into the new type */
- if(H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0)
+ if (H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get the fill value information
- *-------------------------------------------------------------------------
- */
+ * get the fill value information
+ *-------------------------------------------------------------------------
+ */
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i);
/* check if we have the _FILL attribute */
- if((has_fill = H5LT_find_attribute(did_1, attr_name)) < 0)
+ if ((has_fill = H5LT_find_attribute(did_1, attr_name)) < 0)
goto out;
/* get it */
- if(has_fill)
- if(H5LT_get_attribute_disk(did_1, attr_name, tmp_fill_buf + curr_offset) < 0)
+ if (has_fill)
+ if (H5LT_get_attribute_disk(did_1, attr_name, tmp_fill_buf + curr_offset) < 0)
goto out;
curr_offset += member_size;
/* close the member type */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
} /* end if */
@@ -2685,96 +2609,96 @@ herr_t H5TBdelete_field(hid_t loc_id,
} /* end for */
/*-------------------------------------------------------------------------
- * create a new temporary dataset
- *-------------------------------------------------------------------------
- */
+ * create a new temporary dataset
+ *-------------------------------------------------------------------------
+ */
/* retrieve the size of chunk */
- if(H5Pget_chunk(pid_1, 1, dims_chunk) < 0)
+ 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)
+ if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0)
goto out;
/* modify dataset creation properties, i.e. enable chunking */
pid_2 = H5Pcreate(H5P_DATASET_CREATE);
- if(H5Pset_chunk(pid_2, 1, dims_chunk) < 0)
+ if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0)
goto out;
/* create the dataset. */
- if((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0)
+ 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
- *-------------------------------------------------------------------------
- */
- for(i = 0; i < nfields; i++) {
+ * we have to read field by field of the old dataset and save it into the new one
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0; i < nfields; i++) {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i)))
goto out;
/* skip the field to delete */
- if(!H5TB_find_field(member_name, field_name)) {
+ if (!H5TB_find_field(member_name, field_name)) {
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0)
goto out;
/* get the member size */
- if(0 == (member_size = H5Tget_size(member_type_id)))
+ if (0 == (member_size = H5Tget_size(member_type_id)))
goto out;
/* create a read id */
- if((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0)
+ 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)
+ if (H5Tinsert(read_type_id, member_name, (size_t)0, member_type_id) < 0)
goto out;
- if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, member_size)))
+ if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, member_size)))
goto out;
/* read */
- if(H5Dread(did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0)
+ 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)
+ 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)
+ 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)
+ if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto out;
- if(H5Pset_preserve(preserve_id, 1) < 0)
+ 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)
+ 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)
+ if (H5Pclose(preserve_id) < 0)
goto out;
preserve_id = H5I_BADID;
/* close the member type */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
/* close the read type */
- if(H5Tclose(read_type_id) < 0)
+ if (H5Tclose(read_type_id) < 0)
goto out;
read_type_id = H5I_BADID;
/* close the write type */
- if(H5Tclose(write_type_id) < 0)
+ if (H5Tclose(write_type_id) < 0)
goto out;
write_type_id = H5I_BADID;
@@ -2788,51 +2712,51 @@ herr_t H5TBdelete_field(hid_t loc_id,
} /* end for */
/*-------------------------------------------------------------------------
- * delete 1st table
- *-------------------------------------------------------------------------
- */
- if(H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0)
+ * delete 1st table
+ *-------------------------------------------------------------------------
+ */
+ if (H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0)
goto out;
/*-------------------------------------------------------------------------
- * rename 2nd table
- *-------------------------------------------------------------------------
- */
- if(H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ * rename 2nd table
+ *-------------------------------------------------------------------------
+ */
+ if (H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the conforming table attributes
- *-------------------------------------------------------------------------
- */
+ * attach the conforming table attributes
+ *-------------------------------------------------------------------------
+ */
/* get the number of records and fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
/* open the dataset. */
- if((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid_3 = H5Dget_type(did_3)) < 0)
+ if ((tid_3 = H5Dget_type(did_3)) < 0)
goto out;
/* set the attributes */
- if(H5TB_attach_attributes(table_title, loc_id, dset_name, nfields, tid_3) < 0)
+ if (H5TB_attach_attributes(table_title, loc_id, dset_name, nfields, tid_3) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the fill attributes from previous table
- *-------------------------------------------------------------------------
- */
- if(has_fill) {
- if((sid_1 = H5Screate(H5S_SCALAR)) < 0)
+ * attach the fill attributes from previous table
+ *-------------------------------------------------------------------------
+ */
+ if (has_fill) {
+ if ((sid_1 = H5Screate(H5S_SCALAR)) < 0)
goto out;
- for(i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++) {
/* get the member type */
- if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0)
+ if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0)
goto out;
/* get the member offset */
@@ -2840,24 +2764,24 @@ herr_t H5TBdelete_field(hid_t loc_id,
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i);
- if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((attr_id = H5Acreate2(did_3, 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)
+ if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0)
goto out;
- if(H5Aclose(attr_id) < 0)
+ if (H5Aclose(attr_id) < 0)
goto out;
attr_id = H5I_BADID;
/* close the member type */
- if(H5Tclose(member_type_id) < 0)
+ if (H5Tclose(member_type_id) < 0)
goto out;
member_type_id = H5I_BADID;
} /* end for */
/* close data space. */
- if(H5Sclose(sid_1) < 0)
+ if (H5Sclose(sid_1) < 0)
goto out;
sid_1 = H5I_BADID;
} /* end if */
@@ -2865,232 +2789,227 @@ herr_t H5TBdelete_field(hid_t loc_id,
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
- if(tmp_fill_buf)
+ if (tmp_fill_buf)
HDfree(tmp_fill_buf);
- if(tmp_buf)
+ if (tmp_buf)
HDfree(tmp_buf);
- if(attr_id > 0)
- if(H5Aclose(attr_id) < 0)
+ if (attr_id > 0)
+ if (H5Aclose(attr_id) < 0)
ret_val = -1;
- if(preserve_id > 0)
- if(H5Pclose(preserve_id) < 0)
+ if (preserve_id > 0)
+ if (H5Pclose(preserve_id) < 0)
ret_val = -1;
- if(member_type_id > 0)
- if(H5Tclose(member_type_id) < 0)
+ if (member_type_id > 0)
+ if (H5Tclose(member_type_id) < 0)
ret_val = -1;
- if(read_type_id > 0)
- if(H5Tclose(read_type_id) < 0)
+ if (read_type_id > 0)
+ if (H5Tclose(read_type_id) < 0)
ret_val = -1;
- if(write_type_id > 0)
- if(H5Tclose(write_type_id) < 0)
+ if (write_type_id > 0)
+ if (H5Tclose(write_type_id) < 0)
ret_val = -1;
- if(tid_1 > 0)
- if(H5Tclose(tid_1) < 0)
+ if (tid_1 > 0)
+ if (H5Tclose(tid_1) < 0)
ret_val = -1;
- if(pid_1 > 0)
- if(H5Pclose(pid_1) < 0)
+ if (pid_1 > 0)
+ if (H5Pclose(pid_1) < 0)
ret_val = -1;
- if(sid_1 > 0)
- if(H5Sclose(sid_1) < 0)
+ if (sid_1 > 0)
+ if (H5Sclose(sid_1) < 0)
ret_val = -1;
- if(did_1 > 0)
- if(H5Dclose(did_1) < 0)
+ if (did_1 > 0)
+ if (H5Dclose(did_1) < 0)
ret_val = -1;
- if(sid_2 > 0)
- if(H5Sclose(sid_2) < 0)
+ if (sid_2 > 0)
+ if (H5Sclose(sid_2) < 0)
ret_val = -1;
- if(tid_2 > 0)
- if(H5Tclose(tid_2) < 0)
+ if (tid_2 > 0)
+ if (H5Tclose(tid_2) < 0)
ret_val = -1;
- if(pid_2 > 0)
- if(H5Pclose(pid_2) < 0)
+ if (pid_2 > 0)
+ if (H5Pclose(pid_2) < 0)
ret_val = -1;
- if(did_2 > 0)
- if(H5Dclose(did_2) < 0)
+ if (did_2 > 0)
+ if (H5Dclose(did_2) < 0)
ret_val = -1;
- if(tid_3 > 0)
- if(H5Tclose(tid_3) < 0)
+ if (tid_3 > 0)
+ if (H5Tclose(tid_3) < 0)
ret_val = -1;
- if(did_3 > 0)
- if(H5Dclose(did_3) < 0)
+ if (did_3 > 0)
+ if (H5Dclose(did_3) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBdelete_field() */
/*-------------------------------------------------------------------------
-*
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-herr_t H5TBAget_title(hid_t loc_id,
- char *table_title)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5TBAget_title(hid_t loc_id, char *table_title)
{
/* Get the TITLE attribute */
- if(H5LT_get_attribute_disk(loc_id, "TITLE", table_title) < 0)
+ 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: TRUE/FALSE, Failure: -1
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: January 30, 2002
-*
-* Comments:
-*
-*-------------------------------------------------------------------------
-*/
-htri_t H5TBAget_fill(hid_t loc_id,
- const char *dset_name,
- hid_t dset_id,
- unsigned char *dst_buf)
+ * Function: H5TBAget_fill
+ *
+ * Purpose: Read the table attribute fill values
+ *
+ * Return: Success: TRUE/FALSE, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: January 30, 2002
+ *
+ * Comments:
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char *dst_buf)
{
- hsize_t nfields;
- hsize_t nrecords;
- hsize_t i;
- size_t *src_offset = NULL;
- char attr_name[255];
- htri_t has_fill = FALSE;
- htri_t ret_val = -1;
+ hsize_t nfields;
+ hsize_t nrecords;
+ hsize_t i;
+ size_t *src_offset = NULL;
+ char attr_name[255];
+ htri_t has_fill = FALSE;
+ htri_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* get the number of records and fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
- if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
+ if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t))))
goto out;
/* get field info */
- if(H5TBget_field_info(loc_id, dset_name, NULL, NULL, src_offset, NULL) < 0)
+ if (H5TBget_field_info(loc_id, dset_name, NULL, NULL, src_offset, NULL) < 0)
goto out;
- for(i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++) {
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i);
/* check if we have the _FILL attribute */
- if((has_fill = H5LT_find_attribute(dset_id, attr_name)) < 0)
+ if ((has_fill = H5LT_find_attribute(dset_id, attr_name)) < 0)
goto out;
/* get it */
- if(has_fill)
- if(H5LT_get_attribute_disk(dset_id, attr_name, dst_buf + src_offset[i]) < 0)
+ if (has_fill)
+ if (H5LT_get_attribute_disk(dset_id, attr_name, dst_buf + src_offset[i]) < 0)
goto out;
} /* end for */
ret_val = has_fill;
out:
- if(src_offset)
+ if (src_offset)
HDfree(src_offset);
return ret_val;
} /* end H5TBAget_fill() */
-
/*-------------------------------------------------------------------------
-*
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-herr_t H5TBget_table_info(hid_t loc_id,
- const char *dset_name,
- hsize_t *nfields,
- hsize_t *nrecords)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords)
{
- hid_t tid = H5I_BADID;
- hid_t sid = H5I_BADID;
- hid_t did = H5I_BADID;
- hsize_t dims[1];
- int num_members;
- herr_t ret_val = -1;
+ hid_t tid = H5I_BADID;
+ hid_t sid = H5I_BADID;
+ hid_t did = H5I_BADID;
+ hsize_t dims[1];
+ int num_members;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
/* get the number of members */
- if((num_members = H5Tget_nmembers(tid)) < 0)
+ if ((num_members = H5Tget_nmembers(tid)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get number of nfields
- *-------------------------------------------------------------------------
- */
- if(nfields)
+ * get number of nfields
+ *-------------------------------------------------------------------------
+ */
+ if (nfields)
*nfields = (hsize_t)num_members;
/*-------------------------------------------------------------------------
- * get number of records
- *-------------------------------------------------------------------------
- */
- if(nrecords) {
+ * get number of records
+ *-------------------------------------------------------------------------
+ */
+ if (nrecords) {
/* get the dataspace handle */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get dimension */
- if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
/* terminate access to the dataspace */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
sid = H5I_BADID;
@@ -3100,106 +3019,103 @@ herr_t H5TBget_table_info(hid_t loc_id,
ret_val = 0;
out:
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBget_table_info() */
/*-------------------------------------------------------------------------
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+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)
{
- hid_t did = H5I_BADID; /* dataset ID */
- hid_t tid = H5I_BADID; /* file type ID */
- hid_t n_tid = H5I_BADID; /* native type ID */
- hid_t m_tid = H5I_BADID; /* member type ID */
- hid_t nm_tid = H5I_BADID; /* native member ID */
- hssize_t nfields;
- hssize_t i;
- herr_t ret_val = -1;
+ hid_t did = H5I_BADID; /* dataset ID */
+ hid_t tid = H5I_BADID; /* file type ID */
+ hid_t n_tid = H5I_BADID; /* native type ID */
+ hid_t m_tid = H5I_BADID; /* member type ID */
+ hid_t nm_tid = H5I_BADID; /* native member ID */
+ hssize_t nfields;
+ hssize_t i;
+ herr_t ret_val = -1;
/* check the arguments */
if (dset_name == NULL)
goto out;
/* open the dataset. */
- if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
/* get the datatype */
- if((tid = H5Dget_type(did)) < 0)
+ if ((tid = H5Dget_type(did)) < 0)
goto out;
- if((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0)
+ if ((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0)
goto out;
/* get the type size */
- if(type_size)
- if(0 == (*type_size = H5Tget_size(n_tid)))
+ if (type_size)
+ if (0 == (*type_size = H5Tget_size(n_tid)))
goto out;
/* get the number of members */
- if((nfields = H5Tget_nmembers(tid)) < 0)
+ if ((nfields = H5Tget_nmembers(tid)) < 0)
goto out;
/* iterate tru the members */
- for(i = 0; i < nfields; i++) {
+ for (i = 0; i < nfields; i++) {
/* get the member name */
- if(field_names) {
- char *member_name;
+ if (field_names) {
+ char *member_name;
- if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i)))
goto out;
strcpy(field_names[i], member_name);
H5free_memory(member_name);
} /* end if */
/* get the member type */
- if((m_tid = H5Tget_member_type(tid, (unsigned)i)) < 0)
+ if ((m_tid = H5Tget_member_type(tid, (unsigned)i)) < 0)
goto out;
- if((nm_tid = H5Tget_native_type(m_tid, H5T_DIR_DEFAULT)) < 0)
+ if ((nm_tid = H5Tget_native_type(m_tid, H5T_DIR_DEFAULT)) < 0)
goto out;
/* get the member size */
- if(field_sizes)
- if(0 == (field_sizes[i] = H5Tget_size(nm_tid)))
+ if (field_sizes)
+ if (0 == (field_sizes[i] = H5Tget_size(nm_tid)))
goto out;
/* get the member offset */
- if(field_offsets)
- field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned) i);
+ if (field_offsets)
+ field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned)i);
/* close the member types */
- if(H5Tclose(m_tid) < 0)
+ if (H5Tclose(m_tid) < 0)
goto out;
m_tid = H5I_BADID;
- if(H5Tclose(nm_tid) < 0)
+ if (H5Tclose(nm_tid) < 0)
goto out;
nm_tid = H5I_BADID;
} /* end for */
@@ -3207,122 +3123,119 @@ herr_t H5TBget_field_info(hid_t loc_id,
ret_val = 0;
out:
- if(tid > 0)
- if(H5Tclose(tid) < 0)
+ if (tid > 0)
+ if (H5Tclose(tid) < 0)
ret_val = -1;
- if(n_tid > 0)
- if(H5Tclose(n_tid) < 0)
+ if (n_tid > 0)
+ if (H5Tclose(n_tid) < 0)
ret_val = -1;
- if(m_tid > 0)
- if(H5Tclose(m_tid) < 0)
+ if (m_tid > 0)
+ if (H5Tclose(m_tid) < 0)
ret_val = -1;
- if(nm_tid > 0)
- if(H5Tclose(nm_tid) < 0)
+ if (nm_tid > 0)
+ if (H5Tclose(nm_tid) < 0)
ret_val = -1;
- if(did > 0)
- if(H5Dclose(did) < 0)
+ if (did > 0)
+ if (H5Dclose(did) < 0)
ret_val = -1;
return ret_val;
} /* end H5TBget_field_info() */
/*-------------------------------------------------------------------------
-*
-* internal functions
-*
-*-------------------------------------------------------------------------
-*/
+ *
+ * internal functions
+ *
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
-* Function: H5TB_find_field
-*
-* Purpose: Find a string field
-*
-* Return: Success: TRUE/FALSE, Failure: N/A
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: November 19, 2001
-*
-*-------------------------------------------------------------------------
-*/
-H5_ATTR_PURE static
-hbool_t H5TB_find_field(const char *field, const char *field_list)
+ * Function: H5TB_find_field
+ *
+ * Purpose: Find a string field
+ *
+ * Return: Success: TRUE/FALSE, Failure: N/A
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 19, 2001
+ *
+ *-------------------------------------------------------------------------
+ */
+H5_ATTR_PURE static hbool_t
+H5TB_find_field(const char *field, const char *field_list)
{
const char *start = field_list;
const char *end;
/* check the arguments */
if (field == NULL)
- return FALSE;
+ return FALSE;
if (field_list == NULL)
- return FALSE;
+ return FALSE;
- while((end = HDstrstr(start, ",")) != 0) {
+ while ((end = HDstrstr(start, ",")) != 0) {
ptrdiff_t count = end - start;
- if(HDstrncmp(start, field, (size_t)count) == 0 && (size_t)count == HDstrlen(field))
+ if (HDstrncmp(start, field, (size_t)count) == 0 && (size_t)count == HDstrlen(field))
return TRUE;
start = end + 1;
} /* end while */
- if(HDstrncmp(start, field, HDstrlen(field)) == 0)
+ if (HDstrncmp(start, field, HDstrlen(field)) == 0)
return TRUE;
return FALSE;
} /* end H5TB_find_field() */
/*-------------------------------------------------------------------------
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-static
-herr_t H5TB_attach_attributes(const char *table_title,
- hid_t loc_id,
- const char *dset_name,
- hsize_t nfields,
- hid_t tid)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5TB_attach_attributes(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields,
+ hid_t tid)
{
- char attr_name[255];
- char *member_name = NULL;
- hsize_t i;
- herr_t ret_val = -1;
+ char attr_name[255];
+ char * member_name = NULL;
+ hsize_t i;
+ herr_t ret_val = -1;
/* attach the CLASS attribute */
- if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0)
+ 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)
+ 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)
+ 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++) {
+ for (i = 0; i < nfields; i++) {
/* get the member name */
- if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i)))
+ if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i)))
goto out;
HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_NAME", (int)i);
/* attach the attribute */
- if(H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0)
+ if (H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0)
goto out;
H5free_memory(member_name);
@@ -3332,57 +3245,53 @@ herr_t H5TB_attach_attributes(const char *table_title,
ret_val = 0;
out:
- if(member_name)
+ if (member_name)
H5free_memory(member_name);
return ret_val;
} /* end H5TB_attach_attributes() */
/*-------------------------------------------------------------------------
-* 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:
-*
-*-------------------------------------------------------------------------
-*/
-static
-hid_t H5TB_create_type(hid_t loc_id,
- const char *dset_name,
- size_t type_size,
- const size_t *field_offset,
- const size_t *field_sizes,
- hid_t ftype_id)
+ * 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:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, const size_t *field_offset,
+ const size_t *field_sizes, hid_t ftype_id)
{
hid_t mem_type_id = H5I_BADID;
- hid_t mtype_id = H5I_BADID;
- hid_t nmtype_id = H5I_BADID;
+ hid_t mtype_id = H5I_BADID;
+ hid_t nmtype_id = H5I_BADID;
size_t size_native;
hsize_t nfields = 0;
- char **fnames = NULL;
+ char ** fnames = NULL;
unsigned i;
- hid_t ret_val = -1;
+ hid_t ret_val = -1;
/* get the number of fields */
- if(H5TBget_table_info(loc_id, dset_name, &nfields, NULL) < 0)
+ if (H5TBget_table_info(loc_id, dset_name, &nfields, NULL) < 0)
goto out;
- if(NULL == (fnames = (char**)HDcalloc(sizeof(char*), (size_t)nfields)))
+ if (NULL == (fnames = (char **)HDcalloc(sizeof(char *), (size_t)nfields)))
goto out;
- for(i = 0; i < nfields; i++)
- if(NULL == (fnames[i] = (char*)HDmalloc(HLTB_MAX_FIELD_LEN)))
+ for (i = 0; i < nfields; i++)
+ if (NULL == (fnames[i] = (char *)HDmalloc(HLTB_MAX_FIELD_LEN)))
goto out;
/* get field info */
- if(H5TBget_field_info(loc_id, dset_name, fnames, NULL, NULL, NULL) < 0)
+ if (H5TBget_field_info(loc_id, dset_name, fnames, NULL, NULL, NULL) < 0)
goto out;
/* create the memory data type */
@@ -3390,22 +3299,22 @@ hid_t H5TB_create_type(hid_t loc_id,
goto out;
/* get each field ID and adjust its size, if necessary */
- for(i = 0; i < nfields; i++) {
- if((mtype_id = H5Tget_member_type(ftype_id, i)) < 0)
+ for (i = 0; i < nfields; i++) {
+ if ((mtype_id = H5Tget_member_type(ftype_id, i)) < 0)
goto out;
- if((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0)
+ if ((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0)
goto out;
- if(0 == (size_native = H5Tget_size(nmtype_id)))
+ if (0 == (size_native = H5Tget_size(nmtype_id)))
goto out;
- if(field_sizes[i] != size_native)
- if(H5Tset_size(nmtype_id, field_sizes[i]) < 0)
+ if (field_sizes[i] != size_native)
+ if (H5Tset_size(nmtype_id, field_sizes[i]) < 0)
goto out;
- if(H5Tinsert(mem_type_id, fnames[i], field_offset[i], nmtype_id) < 0)
+ if (H5Tinsert(mem_type_id, fnames[i], field_offset[i], nmtype_id) < 0)
goto out;
- if(H5Tclose(mtype_id) < 0)
+ if (H5Tclose(mtype_id) < 0)
goto out;
mtype_id = H5I_BADID;
- if(H5Tclose(nmtype_id) < 0)
+ if (H5Tclose(nmtype_id) < 0)
goto out;
nmtype_id = H5I_BADID;
} /* end for */
@@ -3413,159 +3322,153 @@ hid_t H5TB_create_type(hid_t loc_id,
ret_val = mem_type_id;
out:
- if(fnames) {
- for(i = 0; i < nfields; i++)
- if(fnames[i])
+ if (fnames) {
+ for (i = 0; i < nfields; i++)
+ if (fnames[i])
HDfree(fnames[i]);
HDfree(fnames);
} /* end if */
- if(mtype_id > 0)
- if(H5Tclose(mtype_id) < 0)
+ if (mtype_id > 0)
+ if (H5Tclose(mtype_id) < 0)
ret_val = -1;
- if(nmtype_id > 0)
- if(H5Tclose(nmtype_id) < 0)
+ if (nmtype_id > 0)
+ if (H5Tclose(nmtype_id) < 0)
ret_val = -1;
- if(ret_val < 0 && mem_type_id > 0)
+ if (ret_val < 0 && mem_type_id > 0)
H5Tclose(mem_type_id);
return ret_val;
} /* end H5TB_create_type() */
/*-------------------------------------------------------------------------
-*
-* 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
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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
+ *
+ *-------------------------------------------------------------------------
+ */
+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 sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t dims[1];
- hsize_t mem_dims[1];
- herr_t ret_val = -1;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t dims[1];
+ hsize_t mem_dims[1];
+ herr_t ret_val = -1;
/* extend the dataset */
dims[0] = nrecords + orig_table_size;
- if(H5Dset_extent(dataset_id, dims) < 0)
+ 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)
+ 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)
+ 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)
+ 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)
+ if (H5Dwrite(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0)
goto out;
ret_val = 0;
out:
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
return ret_val;
} /* end H5TB_common_append_records() */
/*-------------------------------------------------------------------------
-* 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
-*
-*-------------------------------------------------------------------------
-*/
-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)
+ * 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
+ *
+ *-------------------------------------------------------------------------
+ */
+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 sid = H5I_BADID;
- hid_t m_sid = H5I_BADID;
- hsize_t count[1];
- hsize_t offset[1];
- hsize_t mem_size[1];
- herr_t ret_val = -1;
+ hid_t sid = H5I_BADID;
+ hid_t m_sid = H5I_BADID;
+ hsize_t count[1];
+ hsize_t offset[1];
+ hsize_t mem_size[1];
+ herr_t ret_val = -1;
/* make sure the read request is in bounds */
- if(start + nrecords > table_size)
+ if (start + nrecords > table_size)
goto out;
/* get the dataspace handle */
- if((sid = H5Dget_space(dataset_id)) < 0)
+ 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)
+ 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)
+ 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)
+ if ((H5Dread(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf)) < 0)
goto out;
ret_val = 0;
out:
- if(m_sid > 0)
- if(H5Sclose(m_sid) < 0)
+ if (m_sid > 0)
+ if (H5Sclose(m_sid) < 0)
ret_val = -1;
- if(sid > 0)
- if(H5Sclose(sid) < 0)
+ if (sid > 0)
+ if (H5Sclose(sid) < 0)
ret_val = -1;
return ret_val;
} /* end H5TB_common_read_records() */
-
diff --git a/hl/src/H5TBprivate.h b/hl/src/H5TBprivate.h
index 17306fb..cdddfbc 100644
--- a/hl/src/H5TBprivate.h
+++ b/hl/src/H5TBprivate.h
@@ -20,10 +20,9 @@
/* public TB prototypes */
#include "H5TBpublic.h"
-
-#define TABLE_CLASS "TABLE"
-#define TABLE_VERSION "3.0"
-#define HLTB_MAX_FIELD_LEN 255
+#define TABLE_CLASS "TABLE"
+#define TABLE_VERSION "3.0"
+#define HLTB_MAX_FIELD_LEN 255
/*-------------------------------------------------------------------------
*
@@ -32,11 +31,8 @@
*-------------------------------------------------------------------------
*/
-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 * data);
+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 *data);
/*-------------------------------------------------------------------------
*
@@ -45,16 +41,7 @@ herr_t H5TB_common_append_records( hid_t dataset_id,
*-------------------------------------------------------------------------
*/
-
-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 *data);
-
-
-
+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 *data);
#endif
-
diff --git a/hl/src/H5TBpublic.h b/hl/src/H5TBpublic.h
index 56aa915..3649225 100644
--- a/hl/src/H5TBpublic.h
+++ b/hl/src/H5TBpublic.h
@@ -14,12 +14,10 @@
#ifndef _H5TBpublic_H
#define _H5TBpublic_H
-
#ifdef __cplusplus
extern "C" {
#endif
-
/*-------------------------------------------------------------------------
*
* Create functions
@@ -27,20 +25,10 @@ extern "C" {
*-------------------------------------------------------------------------
*/
-H5_HLDLL 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 );
-
+H5_HLDLL 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);
/*-------------------------------------------------------------------------
*
@@ -49,45 +37,21 @@ H5_HLDLL herr_t H5TBmake_table( const char *table_title,
*-------------------------------------------------------------------------
*/
-H5_HLDLL 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 *dst_sizes,
- const void *buf );
-
-H5_HLDLL 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 *dst_sizes,
- const void *buf );
-
-
-H5_HLDLL 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 *dst_sizes,
- const void *buf );
-
-H5_HLDLL 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 *dst_sizes,
- const void *buf );
+H5_HLDLL 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 *dst_sizes, const void *buf);
+
+H5_HLDLL 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 *dst_sizes,
+ const void *buf);
+H5_HLDLL 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 *dst_sizes, const void *buf);
+
+H5_HLDLL 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 *dst_sizes,
+ const void *buf);
/*-------------------------------------------------------------------------
*
@@ -96,46 +60,21 @@ H5_HLDLL herr_t H5TBwrite_fields_index( hid_t loc_id,
*-------------------------------------------------------------------------
*/
+H5_HLDLL herr_t H5TBread_table(hid_t loc_id, const char *dset_name, size_t dst_size, const size_t *dst_offset,
+ const size_t *dst_sizes, void *dst_buf);
+
+H5_HLDLL 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 *dst_sizes, void *buf);
+H5_HLDLL 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 *dst_sizes,
+ void *buf);
-H5_HLDLL herr_t H5TBread_table( hid_t loc_id,
- const char *dset_name,
- size_t dst_size,
- const size_t *dst_offset,
- const size_t *dst_sizes,
- void *dst_buf );
-
-
-H5_HLDLL 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 *dst_sizes,
- void *buf );
-
-H5_HLDLL 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 *dst_sizes,
- void *buf );
-
-
-H5_HLDLL 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 *dst_offset,
- const size_t *dst_sizes,
- void *buf );
+H5_HLDLL 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 *dst_offset, const size_t *dst_sizes,
+ void *buf);
/*-------------------------------------------------------------------------
*
@@ -144,19 +83,10 @@ H5_HLDLL herr_t H5TBread_records( hid_t loc_id,
*-------------------------------------------------------------------------
*/
+H5_HLDLL herr_t H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords);
-H5_HLDLL herr_t H5TBget_table_info ( hid_t loc_id,
- const char *dset_name,
- hsize_t *nfields,
- hsize_t *nrecords );
-
-H5_HLDLL 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 );
-
+H5_HLDLL 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);
/*-------------------------------------------------------------------------
*
@@ -165,47 +95,22 @@ H5_HLDLL herr_t H5TBget_field_info( hid_t loc_id,
*-------------------------------------------------------------------------
*/
+H5_HLDLL herr_t H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords);
-H5_HLDLL herr_t H5TBdelete_record( hid_t loc_id,
- const char *dset_name,
- hsize_t start,
- hsize_t nrecords );
-
-
-H5_HLDLL herr_t H5TBinsert_record( hid_t loc_id,
- const char *dset_name,
- hsize_t start,
- hsize_t nrecords,
- size_t dst_size,
- const size_t *dst_offset,
- const size_t *dst_sizes,
- void *buf );
+H5_HLDLL herr_t H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords,
+ size_t dst_size, const size_t *dst_offset, const size_t *dst_sizes,
+ void *buf);
-H5_HLDLL 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 );
+H5_HLDLL 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);
-H5_HLDLL herr_t H5TBcombine_tables( hid_t loc_id1,
- const char *dset_name1,
- hid_t loc_id2,
- const char *dset_name2,
- const char *dset_name3 );
+H5_HLDLL herr_t H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2,
+ const char *dset_name2, const char *dset_name3);
-H5_HLDLL 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 );
-
-H5_HLDLL herr_t H5TBdelete_field( hid_t loc_id,
- const char *dset_name,
- const char *field_name );
+H5_HLDLL 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);
+H5_HLDLL herr_t H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name);
/*-------------------------------------------------------------------------
*
@@ -214,18 +119,12 @@ H5_HLDLL herr_t H5TBdelete_field( hid_t loc_id,
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5TBAget_title( hid_t loc_id,
- char *table_title );
+H5_HLDLL herr_t H5TBAget_title(hid_t loc_id, char *table_title);
-H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id,
- const char *dset_name,
- hid_t dset_id,
- unsigned char *dst_buf);
+H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char *dst_buf);
#ifdef __cplusplus
}
#endif
-
#endif
-
diff --git a/hl/src/hdf5_hl.h b/hl/src/hdf5_hl.h
index 3a7b8ee..51f8ab9 100644
--- a/hl/src/hdf5_hl.h
+++ b/hl/src/hdf5_hl.h
@@ -29,4 +29,3 @@
#include "H5LDpublic.h" /* lite dataset */
#endif /*H5_INCLUDE_HL*/
-