summaryrefslogtreecommitdiffstats
path: root/tools/test/h5copy
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /tools/test/h5copy
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'tools/test/h5copy')
-rw-r--r--tools/test/h5copy/dynlib_copy.c54
-rw-r--r--tools/test/h5copy/h5copygentest.c465
2 files changed, 253 insertions, 266 deletions
diff --git a/tools/test/h5copy/dynlib_copy.c b/tools/test/h5copy/dynlib_copy.c
index 571452e..97bd1f5 100644
--- a/tools/test/h5copy/dynlib_copy.c
+++ b/tools/test/h5copy/dynlib_copy.c
@@ -17,25 +17,33 @@
#include <stdio.h>
#include "H5PLextern.h"
-#define H5Z_FILTER_DYNLIBUD 300
-#define MULTIPLIER 3
+#define H5Z_FILTER_DYNLIBUD 300
+#define MULTIPLIER 3
-static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values,
+ size_t nbytes, size_t *buf_size, void **buf);
/* This message derives from H5Z */
const H5Z_class2_t H5Z_DYNLIBUD[1] = {{
H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_DYNLIBUD, /* Filter id number */
1, 1, /* Encoding and decoding enabled */
- "dynlibud", /* Filter name for debugging */
+ "dynlibud", /* Filter name for debugging */
NULL, /* The "can apply" callback */
NULL, /* The "set local" callback */
- (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */
+ (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */
}};
-H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
-const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;}
+H5PL_type_t
+H5PLget_plugin_type(void)
+{
+ return H5PL_TYPE_FILTER;
+}
+const void *
+H5PLget_plugin_info(void)
+{
+ return H5Z_DYNLIBUD;
+}
/*-------------------------------------------------------------------------
* Function: H5Z_filter_dynlibud
@@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;}
*-------------------------------------------------------------------------
*/
static size_t
-H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes,
- size_t *buf_size, void **buf)
+H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes,
+ size_t *buf_size, void **buf)
{
- char *int_ptr = (char *)*buf; /* Pointer to the data values */
- size_t buf_left = *buf_size; /* Amount of data buffer left to process */
+ char * int_ptr = (char *)*buf; /* Pointer to the data values */
+ size_t buf_left = *buf_size; /* Amount of data buffer left to process */
/* Check for the correct number of parameters */
- if(cd_nelmts > 0)
- return(0);
+ if (cd_nelmts > 0)
+ return (0);
/* Assignment to eliminate unused parameter warning. */
cd_values = cd_values;
- if(flags & H5Z_FLAG_REVERSE) { /*read*/
+ if (flags & H5Z_FLAG_REVERSE) { /*read*/
/* Subtract the original value with MULTIPLIER */
- while(buf_left > 0) {
+ while (buf_left > 0) {
char temp = *int_ptr;
- *int_ptr = temp - MULTIPLIER;
+ *int_ptr = temp - MULTIPLIER;
int_ptr++;
buf_left -= sizeof(*int_ptr);
- } /* end while */
- } /* end if */
+ } /* end while */
+ } /* end if */
else { /*write*/
/* Add the original value with MULTIPLIER */
- while(buf_left > 0) {
+ while (buf_left > 0) {
char temp = *int_ptr;
- *int_ptr = temp + MULTIPLIER;
+ *int_ptr = temp + MULTIPLIER;
int_ptr++;
buf_left -= sizeof(*int_ptr);
} /* end while */
- } /* end else */
+ } /* end else */
return nbytes;
} /* end H5Z_filter_dynlibud() */
-
diff --git a/tools/test/h5copy/h5copygentest.c b/tools/test/h5copy/h5copygentest.c
index 2a8a575..1327e0f 100644
--- a/tools/test/h5copy/h5copygentest.c
+++ b/tools/test/h5copy/h5copygentest.c
@@ -18,35 +18,34 @@
#include "H5private.h"
/* HDF file names */
-#define HDF_FILE1 "h5copytst.h5"
-#define HDF_FILE1_NEW "h5copytst_new.h5"
-#define HDF_FILE2 "h5copy_ref.h5"
-#define HDF_EXT_SRC_FILE "h5copy_extlinks_src.h5"
-#define HDF_EXT_TRG_FILE "h5copy_extlinks_trg.h5"
+#define HDF_FILE1 "h5copytst.h5"
+#define HDF_FILE1_NEW "h5copytst_new.h5"
+#define HDF_FILE2 "h5copy_ref.h5"
+#define HDF_EXT_SRC_FILE "h5copy_extlinks_src.h5"
+#define HDF_EXT_TRG_FILE "h5copy_extlinks_trg.h5"
/* objects in HDF_FILE1 */
-#define DATASET_SIMPLE "simple"
-#define DATASET_CHUNK "chunk"
-#define DATASET_COMPACT "compact"
-#define DATASET_COMPOUND "compound"
-#define DATASET_COMPRESSED "compressed"
-#define DATASET_NAMED_VL "named_vl"
-#define DATASET_NESTED_VL "nested_vl"
-#define DATASET_ATTR "dset_attr"
-#define ATTR "attr"
-#define GROUP_EMPTY "grp_empty"
-#define GROUP_DATASETS "grp_dsets"
-#define GROUP_NESTED "grp_nested"
-#define GROUP_ATTR "grp_attr"
+#define DATASET_SIMPLE "simple"
+#define DATASET_CHUNK "chunk"
+#define DATASET_COMPACT "compact"
+#define DATASET_COMPOUND "compound"
+#define DATASET_COMPRESSED "compressed"
+#define DATASET_NAMED_VL "named_vl"
+#define DATASET_NESTED_VL "nested_vl"
+#define DATASET_ATTR "dset_attr"
+#define ATTR "attr"
+#define GROUP_EMPTY "grp_empty"
+#define GROUP_DATASETS "grp_dsets"
+#define GROUP_NESTED "grp_nested"
+#define GROUP_ATTR "grp_attr"
/* Obj reference */
-#define OBJ_REF_DS "Dset1"
+#define OBJ_REF_DS "Dset1"
#define OBJ_REF_GRP "Group"
/* Region reference */
#define REG_REF_DS1 "Dset_REGREF"
#define REG_REF_DS2 "Dset2"
-
/*-------------------------------------------------------------------------
* Function: gent_simple
*
@@ -54,11 +53,12 @@
*
*-------------------------------------------------------------------------
*/
-static void gent_simple(hid_t loc_id)
+static void
+gent_simple(hid_t loc_id)
{
hid_t sid, did;
hsize_t dims[1] = {6};
- int buf[6] = {1,2,3,4,5,6};
+ int buf[6] = {1, 2, 3, 4, 5, 6};
/* create dataspace */
sid = H5Screate_simple(1, dims, NULL);
@@ -81,12 +81,13 @@ static void gent_simple(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_chunked(hid_t loc_id)
+static void
+gent_chunked(hid_t loc_id)
{
hid_t sid, did, pid;
- hsize_t dims[1] = {6};
+ hsize_t dims[1] = {6};
hsize_t chunk_dims[1] = {2};
- int buf[6] = {1,2,3,4,5,6};
+ int buf[6] = {1, 2, 3, 4, 5, 6};
/* create dataspace */
sid = H5Screate_simple(1, dims, NULL);
@@ -107,7 +108,6 @@ static void gent_chunked(hid_t loc_id)
H5Pclose(pid);
}
-
/*-------------------------------------------------------------------------
* Function: gent_compact
*
@@ -115,18 +115,19 @@ static void gent_chunked(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_compact(hid_t loc_id)
+static void
+gent_compact(hid_t loc_id)
{
hid_t sid, did, pid;
hsize_t dims[1] = {6};
- int buf[6] = {1,2,3,4,5,6};
+ int buf[6] = {1, 2, 3, 4, 5, 6};
/* create dataspace */
sid = H5Screate_simple(1, dims, NULL);
/* create property plist */
pid = H5Pcreate(H5P_DATASET_CREATE);
- H5Pset_layout (pid,H5D_COMPACT);
+ H5Pset_layout(pid, H5D_COMPACT);
/* create dataset */
did = H5Dcreate2(loc_id, DATASET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT);
@@ -140,7 +141,6 @@ static void gent_compact(hid_t loc_id)
H5Pclose(pid);
}
-
/*-------------------------------------------------------------------------
* Function: gent_compound
*
@@ -148,10 +148,10 @@ static void gent_compact(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_compound(hid_t loc_id)
+static void
+gent_compound(hid_t loc_id)
{
- typedef struct s_t
- {
+ typedef struct s_t {
char str1[20];
char str2[20];
} s_t;
@@ -167,8 +167,8 @@ static void gent_compound(hid_t loc_id)
tid_s = H5Tcopy(H5T_C_S1);
H5Tset_size(tid_s, 20);
- H5Tinsert(tid_c, "str1", HOFFSET(s_t,str1), tid_s);
- H5Tinsert(tid_c, "str2", HOFFSET(s_t,str2), tid_s);
+ H5Tinsert(tid_c, "str1", HOFFSET(s_t, str1), tid_s);
+ H5Tinsert(tid_c, "str2", HOFFSET(s_t, str2), tid_s);
/* create dataset */
did = H5Dcreate2(loc_id, DATASET_COMPOUND, tid_c, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -190,12 +190,13 @@ static void gent_compound(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_compressed(hid_t loc_id)
+static void
+gent_compressed(hid_t loc_id)
{
hid_t sid, did, pid;
- hsize_t dims[1] = {6};
+ hsize_t dims[1] = {6};
hsize_t chunk_dims[1] = {2};
- int buf[6] = {1,2,3,4,5,6};
+ int buf[6] = {1, 2, 3, 4, 5, 6};
/* create dataspace */
sid = H5Screate_simple(1, dims, NULL);
@@ -205,7 +206,7 @@ static void gent_compressed(hid_t loc_id)
H5Pset_chunk(pid, 1, chunk_dims);
/* set the deflate filter */
-#if defined (H5_HAVE_FILTER_DEFLATE)
+#if defined(H5_HAVE_FILTER_DEFLATE)
H5Pset_deflate(pid, 1);
#endif
@@ -221,7 +222,6 @@ static void gent_compressed(hid_t loc_id)
H5Pclose(pid);
}
-
/*-------------------------------------------------------------------------
* Function: gent_named_vl
*
@@ -230,20 +230,21 @@ static void gent_compressed(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_named_vl(hid_t loc_id)
+static void
+gent_named_vl(hid_t loc_id)
{
hid_t sid, did, tid;
hsize_t dims[1] = {2};
hvl_t buf[2];
/* allocate and initialize VL dataset to write */
- buf[0].len = 1;
- buf[0].p = HDmalloc( 1 * sizeof(int));
- ((int *)buf[0].p)[0]=1;
- buf[1].len = 2;
- buf[1].p = HDmalloc( 2 * sizeof(int));
- ((int *)buf[1].p)[0]=2;
- ((int *)buf[1].p)[1]=3;
+ buf[0].len = 1;
+ buf[0].p = HDmalloc(1 * sizeof(int));
+ ((int *)buf[0].p)[0] = 1;
+ buf[1].len = 2;
+ buf[1].p = HDmalloc(2 * sizeof(int));
+ ((int *)buf[1].p)[0] = 2;
+ ((int *)buf[1].p)[1] = 3;
/* create dataspace */
sid = H5Screate_simple(1, dims, NULL);
@@ -261,13 +262,12 @@ static void gent_named_vl(hid_t loc_id)
H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
/* close */
- H5Treclaim(tid,sid,H5P_DEFAULT,buf);
+ H5Treclaim(tid, sid, H5P_DEFAULT, buf);
H5Sclose(sid);
H5Dclose(did);
H5Tclose(tid);
}
-
/*-------------------------------------------------------------------------
* Function: gent_nested_vl
*
@@ -275,28 +275,29 @@ static void gent_named_vl(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_nested_vl(hid_t loc_id)
+static void
+gent_nested_vl(hid_t loc_id)
{
hid_t sid, did, tid1, tid2;
hsize_t dims[1] = {2};
hvl_t buf[2];
- hvl_t *tvl;
+ hvl_t * tvl;
/* allocate and initialize VL dataset to write */
- buf[0].len = 1;
- buf[0].p = HDmalloc( 1 * sizeof(hvl_t));
- tvl = (hvl_t *)buf[0].p;
- tvl->p = HDmalloc( 1 * sizeof(int) );
- tvl->len = 1;
- ((int *)tvl->p)[0]=1;
-
- buf[1].len = 1;
- buf[1].p = HDmalloc( 1 * sizeof(hvl_t));
- tvl = (hvl_t *)buf[1].p;
- tvl->p = HDmalloc( 2 * sizeof(int) );
- tvl->len = 2;
- ((int *)tvl->p)[0]=2;
- ((int *)tvl->p)[1]=3;
+ buf[0].len = 1;
+ buf[0].p = HDmalloc(1 * sizeof(hvl_t));
+ tvl = (hvl_t *)buf[0].p;
+ tvl->p = HDmalloc(1 * sizeof(int));
+ tvl->len = 1;
+ ((int *)tvl->p)[0] = 1;
+
+ buf[1].len = 1;
+ buf[1].p = HDmalloc(1 * sizeof(hvl_t));
+ tvl = (hvl_t *)buf[1].p;
+ tvl->p = HDmalloc(2 * sizeof(int));
+ tvl->len = 2;
+ ((int *)tvl->p)[0] = 2;
+ ((int *)tvl->p)[1] = 3;
/* create dataspace */
sid = H5Screate_simple(1, dims, NULL);
@@ -314,14 +315,13 @@ static void gent_nested_vl(hid_t loc_id)
H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
/* close */
- H5Treclaim(tid2,sid,H5P_DEFAULT,buf);
+ H5Treclaim(tid2, sid, H5P_DEFAULT, buf);
H5Sclose(sid);
H5Dclose(did);
H5Tclose(tid1);
H5Tclose(tid2);
}
-
/*-------------------------------------------------------------------------
* Function: gent_att_compound_vlstr
*
@@ -331,22 +331,23 @@ static void gent_nested_vl(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_att_compound_vlstr(hid_t loc_id)
+static void
+gent_att_compound_vlstr(hid_t loc_id)
{
typedef struct { /* Compound structure for the attribute */
- int i;
+ int i;
const char *v;
} s1;
- hsize_t dim[1] = {1}; /* Dimension size */
- hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
- hid_t tid = H5I_INVALID_HID; /* Datatype ID */
- hid_t aid = H5I_INVALID_HID; /* Attribute ID */
- hid_t did = H5I_INVALID_HID; /* Dataset ID */
- hid_t gid = H5I_INVALID_HID; /* Group ID */
- hid_t vl_str_tid = H5I_INVALID_HID; /* Variable length datatype ID */
- hid_t cmpd_tid = H5I_INVALID_HID; /* Compound datatype ID */
- hid_t null_sid = H5I_INVALID_HID; /* Null dataspace ID */
- s1 buf; /* Buffer */
+ hsize_t dim[1] = {1}; /* Dimension size */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t tid = H5I_INVALID_HID; /* Datatype ID */
+ hid_t aid = H5I_INVALID_HID; /* Attribute ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
+ hid_t gid = H5I_INVALID_HID; /* Group ID */
+ hid_t vl_str_tid = H5I_INVALID_HID; /* Variable length datatype ID */
+ hid_t cmpd_tid = H5I_INVALID_HID; /* Compound datatype ID */
+ hid_t null_sid = H5I_INVALID_HID; /* Null dataspace ID */
+ s1 buf; /* Buffer */
buf.i = 9;
buf.v = "ThisIsAString";
@@ -409,7 +410,8 @@ static void gent_att_compound_vlstr(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_datasets(hid_t loc_id)
+static void
+gent_datasets(hid_t loc_id)
{
gent_simple(loc_id);
gent_chunked(loc_id);
@@ -427,9 +429,10 @@ static void gent_datasets(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_empty_group(hid_t loc_id)
+static void
+gent_empty_group(hid_t loc_id)
{
- hid_t gid;
+ hid_t gid;
/* Create group in location */
gid = H5Gcreate2(loc_id, GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -446,9 +449,10 @@ static void gent_empty_group(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_nested_datasets(hid_t loc_id)
+static void
+gent_nested_datasets(hid_t loc_id)
{
- hid_t gid;
+ hid_t gid;
/* Create group in location */
gid = H5Gcreate2(loc_id, GROUP_DATASETS, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -468,9 +472,10 @@ static void gent_nested_datasets(hid_t loc_id)
*
*-------------------------------------------------------------------------
*/
-static void gent_nested_group(hid_t loc_id)
+static void
+gent_nested_group(hid_t loc_id)
{
- hid_t gid;
+ hid_t gid;
/* Create group in location */
gid = H5Gcreate2(loc_id, GROUP_NESTED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -482,7 +487,6 @@ static void gent_nested_group(hid_t loc_id)
H5Gclose(gid);
}
-
/*-------------------------------------------------------------------------
* Function: gen_obj_ref
*
@@ -490,41 +494,39 @@ static void gent_nested_group(hid_t loc_id)
*
* Programmer: Jonathan Kim (Feb 23, 2010)
*------------------------------------------------------------------------*/
-static herr_t gen_obj_ref(hid_t loc_id)
+static herr_t
+gen_obj_ref(hid_t loc_id)
{
- hid_t sid=0, oid=0;
- hsize_t dims1[1]={3};
- hsize_t dims2[1]={2};
- int data[3] = {10,20,30};
- int status;
+ hid_t sid = 0, oid = 0;
+ hsize_t dims1[1] = {3};
+ hsize_t dims2[1] = {2};
+ int data[3] = {10, 20, 30};
+ int status;
/*---------------------
* create obj references to the previously created objects.
* Passing -1 as reference is an object.*/
- hobj_ref_t or_data[2]; /* write buffer */
- herr_t ret = SUCCEED;
+ hobj_ref_t or_data[2]; /* write buffer */
+ herr_t ret = SUCCEED;
/*--------------
* add dataset */
sid = H5Screate_simple(1, dims1, NULL);
- if (sid < 0)
- {
+ if (sid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
- oid = H5Dcreate2 (loc_id, OBJ_REF_DS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (oid < 0)
- {
+ oid = H5Dcreate2(loc_id, OBJ_REF_DS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (oid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
status = H5Dwrite(oid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
- if (status < 0)
- {
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
@@ -535,64 +537,57 @@ static herr_t gen_obj_ref(hid_t loc_id)
/*--------------
* add group */
- oid = H5Gcreate2 (loc_id, OBJ_REF_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (oid < 0)
- {
+ oid = H5Gcreate2(loc_id, OBJ_REF_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (oid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
H5Gclose(oid);
- status = H5Rcreate (&or_data[0], loc_id, OBJ_REF_DS, H5R_OBJECT, (hid_t)-1);
- if (status < 0)
- {
+ status = H5Rcreate(&or_data[0], loc_id, OBJ_REF_DS, H5R_OBJECT, (hid_t)-1);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
- status = H5Rcreate (&or_data[1], loc_id, OBJ_REF_GRP, H5R_OBJECT, (hid_t)-1);
- if (status < 0)
- {
+ status = H5Rcreate(&or_data[1], loc_id, OBJ_REF_GRP, H5R_OBJECT, (hid_t)-1);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
- sid = H5Screate_simple (1, dims2, NULL);
- if (sid < 0)
- {
+ sid = H5Screate_simple(1, dims2, NULL);
+ if (sid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
- oid = H5Dcreate2 (loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
- if (oid < 0)
- {
+ oid = H5Dcreate2(loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (oid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
status = H5Dwrite(oid, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, or_data);
- if (status < 0)
- {
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
out:
- if(oid > 0)
+ if (oid > 0)
H5Dclose(oid);
- if(sid > 0)
+ if (sid > 0)
H5Sclose(sid);
return ret;
}
-
/*-------------------------------------------------------------------------
* Function: gen_region_ref
*
@@ -600,107 +595,98 @@ out:
*
* Programmer: Jonathan Kim (Feb 23, 2010)
*------------------------------------------------------------------------*/
-static herr_t gen_region_ref(hid_t loc_id)
+static herr_t
+gen_region_ref(hid_t loc_id)
{
- hid_t sid=0, oid1=0, oid2=0;
- int status;
- herr_t ret = SUCCEED;
- char data[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"};
- hsize_t dims2[2] = {3,16};
- hsize_t coords[4][2] = { {0,1}, {2,11}, {1,0}, {2,4} };
- hdset_reg_ref_t rr_data[2];
- hsize_t start[2] = {0,0};
- hsize_t stride[2] = {2,11};
- hsize_t count[2] = {2,2};
- hsize_t block[2] = {1,3};
- hsize_t dims1[1] = {2};
-
- sid = H5Screate_simple (2, dims2, NULL);
- if (sid < 0)
- {
+ hid_t sid = 0, oid1 = 0, oid2 = 0;
+ int status;
+ herr_t ret = SUCCEED;
+ char data[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"};
+ hsize_t dims2[2] = {3, 16};
+ hsize_t coords[4][2] = {{0, 1}, {2, 11}, {1, 0}, {2, 4}};
+ hdset_reg_ref_t rr_data[2];
+ hsize_t start[2] = {0, 0};
+ hsize_t stride[2] = {2, 11};
+ hsize_t count[2] = {2, 2};
+ hsize_t block[2] = {1, 3};
+ hsize_t dims1[1] = {2};
+
+ sid = H5Screate_simple(2, dims2, NULL);
+ if (sid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* create normal dataset which is refered */
- oid2 = H5Dcreate2 (loc_id, REG_REF_DS2, H5T_STD_I8LE, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
- if (oid2 < 0)
- {
+ oid2 = H5Dcreate2(loc_id, REG_REF_DS2, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (oid2 < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* write values to dataset */
- status = H5Dwrite (oid2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
- if (status < 0)
- {
+ status = H5Dwrite(oid2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* select elements space for reference */
- status = H5Sselect_elements (sid, H5S_SELECT_SET, 4, coords[0]);
- if (status < 0)
- {
+ status = H5Sselect_elements(sid, H5S_SELECT_SET, 4, coords[0]);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* create region reference from elements space */
- status = H5Rcreate (&rr_data[0], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid);
- if (status < 0)
- {
+ status = H5Rcreate(&rr_data[0], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* select hyperslab space for reference */
- status = H5Sselect_hyperslab (sid, H5S_SELECT_SET, start, stride, count, block);
- if (status < 0)
- {
+ status = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Sselect_hyperslab failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* create region reference from hyperslab space */
- status = H5Rcreate (&rr_data[1], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid);
- if (status < 0)
- {
+ status = H5Rcreate(&rr_data[1], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
- H5Sclose (sid);
+ H5Sclose(sid);
/* Create dataspace. */
- sid = H5Screate_simple (1, dims1, NULL);
- if (sid < 0)
- {
+ sid = H5Screate_simple(1, dims1, NULL);
+ if (sid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* create region reference dataset */
- oid1 = H5Dcreate2 (loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
- if (oid1 < 0)
- {
+ oid1 = H5Dcreate2(loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (oid1 < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* write data as region references */
- status = H5Dwrite (oid1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data);
- if (status < 0)
- {
+ status = H5Dwrite(oid1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
@@ -708,11 +694,11 @@ static herr_t gen_region_ref(hid_t loc_id)
out:
if (oid1 > 0)
- H5Dclose (oid1);
+ H5Dclose(oid1);
if (oid2 > 0)
- H5Dclose (oid2);
+ H5Dclose(oid2);
if (sid > 0)
- H5Sclose (sid);
+ H5Sclose(sid);
return ret;
}
@@ -723,31 +709,32 @@ out:
* Purpose: Testing with various objects
*
*------------------------------------------------------------------------*/
-static void Test_Obj_Copy(void)
+static void
+Test_Obj_Copy(void)
{
- hid_t fid = H5I_INVALID_HID; /* File id */
- hid_t fapl_new = (-1); /* File access property id */
- unsigned new_format; /* New format or old format */
+ hid_t fid = H5I_INVALID_HID; /* File id */
+ hid_t fapl_new = (-1); /* File access property id */
+ unsigned new_format; /* New format or old format */
- if((fapl_new = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((fapl_new = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
HDfprintf(stderr, "Error: H5Pcreate failed.\n");
goto out;
}
- if(H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ if (H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
HDfprintf(stderr, "Error: H5Pset_libver_bounds failed.\n");
goto out;
}
/* Test with old & new format groups */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ for (new_format = FALSE; new_format <= TRUE; new_format++) {
/* Set the FAPL for the type of format */
/* Create source file */
- if(new_format)
+ if (new_format)
fid = H5Fcreate(HDF_FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_new);
else
fid = H5Fcreate(HDF_FILE1_NEW, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if(fid < 0) {
+ if (fid < 0) {
HDfprintf(stderr, "Error: H5Fcreate failed.\n");
goto out;
}
@@ -764,11 +751,11 @@ static void Test_Obj_Copy(void)
out:
/*-----------------------------------------------------------------------
- * Close
- *------------------------------------------------------------------------*/
- if(fid > 0)
+ * Close
+ *------------------------------------------------------------------------*/
+ if (fid > 0)
H5Fclose(fid);
- if(fapl_new > 0)
+ if (fapl_new > 0)
H5Pclose(fapl_new);
}
@@ -778,14 +765,14 @@ out:
* Purpose: Testing with various references
*
*------------------------------------------------------------------------*/
-static void Test_Ref_Copy(void)
+static void
+Test_Ref_Copy(void)
{
- hid_t fid=0;
+ hid_t fid = 0;
herr_t status;
- fid = H5Fcreate (HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (fid < 0)
- {
+ fid = H5Fcreate(HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if (fid < 0) {
HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_FILE2);
goto out;
}
@@ -802,9 +789,9 @@ static void Test_Ref_Copy(void)
out:
/*-----------------------------------------------------------------------
- * Close
- *------------------------------------------------------------------------*/
- if(fid > 0)
+ * Close
+ *------------------------------------------------------------------------*/
+ if (fid > 0)
H5Fclose(fid);
}
@@ -815,20 +802,20 @@ out:
*
* Programmer: Jonathan Kim (March 03, 2010)
*------------------------------------------------------------------------*/
-static herr_t gen_extlink_trg(hid_t loc_id)
+static herr_t
+gen_extlink_trg(hid_t loc_id)
{
- hid_t gid=0, tid=0;
- int status;
+ hid_t gid = 0, tid = 0;
+ int status;
herr_t ret = SUCCEED;
/*-----------------------------------------------------------------------
- * Groups
- *------------------------------------------------------------------------*/
+ * Groups
+ *------------------------------------------------------------------------*/
/*--------------
* target file */
gid = H5Gcreate2(loc_id, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (gid < 0)
- {
+ if (gid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
@@ -836,24 +823,23 @@ static herr_t gen_extlink_trg(hid_t loc_id)
/*--------------
* add dataset */
- gent_simple(loc_id);
+ gent_simple(loc_id);
/*--------------------
* add named datatype
*/
- tid = H5Tcopy(H5T_NATIVE_INT);
- status = H5Tcommit2(loc_id, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0)
- {
+ tid = H5Tcopy(H5T_NATIVE_INT);
+ status = H5Tcommit2(loc_id, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
out:
- if(gid > 0)
+ if (gid > 0)
H5Gclose(gid);
- if(tid > 0)
+ if (tid > 0)
H5Tclose(tid);
return ret;
@@ -866,30 +852,29 @@ out:
*
* Programmer: Jonathan Kim (March 03, 2010)
*------------------------------------------------------------------------*/
-static herr_t gen_extlink_src(hid_t loc_id)
+static herr_t
+gen_extlink_src(hid_t loc_id)
{
- hid_t gid=0;
- int status;
+ hid_t gid = 0;
+ int status;
herr_t ret = SUCCEED;
/*-----------------------------------------------------------------------
- * Groups
- *------------------------------------------------------------------------*/
+ * Groups
+ *------------------------------------------------------------------------*/
gid = H5Gcreate2(loc_id, "/group_ext", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (gid < 0)
- {
+ if (gid < 0) {
HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/*-----------------------------------------------------------------------
- * External links
- *------------------------------------------------------------------------*/
+ * External links
+ *------------------------------------------------------------------------*/
/* link to dataset */
status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/simple", gid, "extlink_dset", H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0)
- {
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
@@ -897,17 +882,16 @@ static herr_t gen_extlink_src(hid_t loc_id)
/* link to group */
status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/group", gid, "extlink_grp", H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0)
- {
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
/* link to datatype */
- status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/datatype", gid, "extlink_datatype", H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0)
- {
+ status =
+ H5Lcreate_external(HDF_EXT_TRG_FILE, "/datatype", gid, "extlink_datatype", H5P_DEFAULT, H5P_DEFAULT);
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
@@ -915,8 +899,7 @@ static herr_t gen_extlink_src(hid_t loc_id)
/* dangling link - no obj*/
status = H5Lcreate_external(HDF_EXT_TRG_FILE, "notyet", gid, "extlink_notyet1", H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0)
- {
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
@@ -924,15 +907,14 @@ static herr_t gen_extlink_src(hid_t loc_id)
/* dangling link - no file */
status = H5Lcreate_external("notyet_file.h5", "notyet", gid, "extlink_notyet2", H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0)
- {
+ if (status < 0) {
HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__);
ret = FAIL;
goto out;
}
out:
- if(gid > 0)
+ if (gid > 0)
H5Gclose(gid);
return ret;
@@ -944,22 +926,21 @@ out:
* Purpose: gerenate external link files
*
*------------------------------------------------------------------------*/
-static void Test_Extlink_Copy(void)
+static void
+Test_Extlink_Copy(void)
{
- hid_t fid1=0;
- hid_t fid2=0;
+ hid_t fid1 = 0;
+ hid_t fid2 = 0;
herr_t status;
- fid1 = H5Fcreate (HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (fid1 < 0)
- {
+ fid1 = H5Fcreate(HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if (fid1 < 0) {
HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_SRC_FILE);
goto out;
}
- fid2 = H5Fcreate (HDF_EXT_TRG_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (fid2 < 0)
- {
+ fid2 = H5Fcreate(HDF_EXT_TRG_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if (fid2 < 0) {
HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_TRG_FILE);
goto out;
}
@@ -976,11 +957,11 @@ static void Test_Extlink_Copy(void)
out:
/*-----------------------------------------------------------------------
- * Close
- *------------------------------------------------------------------------*/
- if(fid1 > 0)
+ * Close
+ *------------------------------------------------------------------------*/
+ if (fid1 > 0)
H5Fclose(fid1);
- if(fid2 > 0)
+ if (fid2 > 0)
H5Fclose(fid2);
}
@@ -990,7 +971,8 @@ out:
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
Test_Obj_Copy();
Test_Ref_Copy();
@@ -998,4 +980,3 @@ int main(void)
return 0;
}
-