summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-09-06 15:54:22 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-09-06 15:54:22 (GMT)
commit3bed8703631cbcffb215ccd82235fcc293e14218 (patch)
treebf56b0bcd4f41986f17138059f6349df78f0c059
parent3eb8c81b8046d282ced9c2d94e7132058243013e (diff)
downloadhdf5-3bed8703631cbcffb215ccd82235fcc293e14218.zip
hdf5-3bed8703631cbcffb215ccd82235fcc293e14218.tar.gz
hdf5-3bed8703631cbcffb215ccd82235fcc293e14218.tar.bz2
[svn-r14136] Description:
Move H5Gget_num_objs() and several minor macros, etc. to deprecated symbols section, replacing it with H5Gget_info(). Tested on: FreeBSD/32 6.2 (duty) FreeBSD/64 6.2 (liberty) Linux/32 2.6 (kagiso) Linux/64 2.6 (smirom) AIX/32 5.3 (copper) Solaris/32 5.10 (linew) Mac OS X/32 10.4.10 (amazon)
-rw-r--r--c++/examples/h5group.cpp2
-rw-r--r--c++/src/H5CommonFG.cpp10
-rw-r--r--fortran/src/H5Gf.c19
-rw-r--r--src/H5Gdeprec.c99
-rw-r--r--src/H5Gpublic.h2
-rw-r--r--test/dt_arith.c4
-rw-r--r--test/links.c9
-rwxr-xr-xtest/objcopy.c16
-rw-r--r--test/th5o.c16
-rw-r--r--test/titerate.c52
-rw-r--r--test/trefer.c10
-rw-r--r--tools/h5dump/h5dump.c2
-rw-r--r--tools/h5repack/h5repack_copy.c33
-rw-r--r--tools/h5repack/h5repack_refs.c24
-rw-r--r--tools/h5stat/h5stat.c26
-rw-r--r--tools/lib/h5diff.c316
-rw-r--r--tools/lib/h5diff.h4
-rw-r--r--tools/lib/h5diff_dset.c4
-rw-r--r--tools/lib/h5trav.c1305
-rw-r--r--tools/lib/h5trav.h57
-rw-r--r--tools/testfiles/h5diff_100.txt5
-rw-r--r--tools/testfiles/h5diff_17.txt5
-rw-r--r--tools/testfiles/h5diff_70.txt349
-rw-r--r--tools/testfiles/h5diff_80.txt5
-rw-r--r--tools/testfiles/tcontents.ddl3
25 files changed, 1174 insertions, 1203 deletions
diff --git a/c++/examples/h5group.cpp b/c++/examples/h5group.cpp
index bcaf2c0..19245ae 100644
--- a/c++/examples/h5group.cpp
+++ b/c++/examples/h5group.cpp
@@ -142,7 +142,7 @@ int main(void)
/*
* Create hard link to the Data group.
*/
- file->link( H5G_LINK_HARD, "Data", "Data_new" );
+ file->link( H5L_TYPE_HARD, "Data", "Data_new" );
/*
* We can access "Compressed_Data" dataset using created
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 7b8c5ac..0ea3923 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -981,13 +981,14 @@ int CommonFG::iterateElems( const H5std_string& name, int *idx, H5G_iterate_t op
//--------------------------------------------------------------------------
hsize_t CommonFG::getNumObjs() const
{
- hsize_t num_objs;
- herr_t ret_value = H5Gget_num_objs(getLocId(), &num_objs);
+ H5G_info_t ginfo; /* Group information */
+
+ herr_t ret_value = H5Gget_info(getLocId(), ".", &ginfo, H5P_DEFAULT);
if(ret_value < 0)
{
- throwException("getNumObjs", "H5Gget_num_objs failed");
+ throwException("getNumObjs", "H5Gget_info failed");
}
- return (num_objs);
+ return (ginfo.nlinks);
}
//--------------------------------------------------------------------------
@@ -1118,3 +1119,4 @@ CommonFG::~CommonFG() {}
#ifndef H5_NO_NAMESPACE
}
#endif
+
diff --git a/fortran/src/H5Gf.c b/fortran/src/H5Gf.c
index 3796b73..5fbaec27 100644
--- a/fortran/src/H5Gf.c
+++ b/fortran/src/H5Gf.c
@@ -197,7 +197,7 @@ DONE:
/*----------------------------------------------------------------------------
* Name: h5gn_members_c
- * Purpose: Call H5Gn_members to find number of objects in the group
+ * Purpose: Call H5Gget_num_objs to find number of objects in the group
* Inputs: loc_id - file or group identifier
* name - name of the group
* namelen - name length
@@ -211,8 +211,7 @@ int_f
nh5gn_members_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *nmembers)
{
char *c_name = NULL;
- hsize_t c_nmembers;
- hid_t gid = (-1);
+ H5G_info_t ginfo;
int ret_value = -1;
/*
@@ -221,22 +220,14 @@ nh5gn_members_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *nmembers)
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
goto DONE;
- /* Get a temporary group ID for the group to query */
- if((gid = H5Gopen2((hid_t)*loc_id, c_name, H5P_DEFAULT)) < 0)
- goto DONE;
-
- /* Call H5Gget_num_objs() for the number of objects in the group */
- if(H5Gget_num_objs(gid, &c_nmembers) < 0)
+ /* Call H5Gget_info() for the number of objects in the group */
+ if(H5Gget_info((hid_t)*loc_id, c_name, &ginfo, H5P_DEFAULT) < 0)
goto DONE;
- *nmembers = (int_f)c_nmembers;
+ *nmembers = (int_f)ginfo.nlinks;
ret_value = 0;
DONE:
- /* Close the temporary group, if it was opened */
- if(gid > 0)
- H5Gclose(gid);
-
if(c_name)
HDfree(c_name);
return ret_value;
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index 9145b3b..bf90f1e 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -787,6 +787,56 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Giterate() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Gget_num_objs
+ *
+ * Purpose: Returns the number of objects in the group. It iterates
+ * all B-tree leaves and sum up total number of group members.
+ *
+ * Note: Deprecated in favor of H5Gget_info
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Raymond Lu
+ * Nov 20, 2002
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs)
+{
+ H5G_loc_t loc; /* Location of object */
+ H5G_info_t grp_info; /* Group information */
+ H5O_type_t obj_type; /* Type of object at location */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_API(H5Gget_num_objs, FAIL)
+ H5TRACE2("e", "i*h", loc_id, num_objs);
+
+ /* Check args */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
+ if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
+ if(obj_type != H5O_TYPE_GROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
+ if(!num_objs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects")
+
+ /* Retrieve information about the group */
+ if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine")
+
+ /* Set the number of objects [sic: links] in the group */
+ *num_objs = grp_info.nlinks;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gget_num_objs() */
+
#endif /* H5_NO_DEPRECATED_SYMBOLS */
@@ -1022,52 +1072,3 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_get_objinfo() */
-
-/*-------------------------------------------------------------------------
- * Function: H5Gget_num_objs
- *
- * Purpose: Returns the number of objects in the group. It iterates
- * all B-tree leaves and sum up total number of group members.
- *
- * Note: Deprecated in favor of H5Gget_info
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Raymond Lu
- * Nov 20, 2002
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs)
-{
- H5G_loc_t loc; /* Location of object */
- H5G_info_t grp_info; /* Group information */
- H5O_type_t obj_type; /* Type of object at location */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_API(H5Gget_num_objs, FAIL)
- H5TRACE2("e", "i*h", loc_id, num_objs);
-
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
- if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_GROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
- if(!num_objs)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects")
-
- /* Retrieve information about the group */
- if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine")
-
- /* Set the number of objects [sic: links] in the group */
- *num_objs = grp_info.nlinks;
-
-done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Gget_num_objs() */
-
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index 6e6560c..6f4bc00 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -133,7 +133,6 @@ H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name,
H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx);
H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name,
hbool_t follow_link, H5G_stat_t *statbuf/*out*/);
-H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs);
/* Symbols defined for compatibility with previous versions of the HDF5 API.
*
* Use of these symbols is deprecated.
@@ -175,6 +174,7 @@ H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize,
char *buf);
H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx,
H5G_iterate_t op, void *op_data);
+H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/test/dt_arith.c b/test/dt_arith.c
index 1932e3d..52fd5bf 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -4947,7 +4947,7 @@ run_int_fp_conv(const char *name)
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_LDOUBLE);
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_LDOUBLE);
#endif
-#ifdef H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
+#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
#if H5_LLONG_TO_LDOUBLE_CORRECT
nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_LDOUBLE);
#else /* H5_LLONG_TO_LDOUBLE_CORRECT */
@@ -5071,7 +5071,7 @@ run_fp_int_conv(const char *name)
nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG);
#endif
-#ifdef H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
+#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
if(!strcmp(name, "hw")) { /* Hardware conversion */
/* Windows .NET 2003 doesn't work for hardware conversion of this case.
* .NET should define this macro H5_HW_FP_TO_LLONG_NOT_WORKS. */
diff --git a/test/links.c b/test/links.c
index 96aa255..fb6fdb6 100644
--- a/test/links.c
+++ b/test/links.c
@@ -1476,6 +1476,7 @@ test_compat(hid_t fapl, hbool_t new_format)
hid_t group1_id = -1;
hid_t group2_id = -1;
H5G_stat_t sb_hard1, sb_hard2, sb_soft1;
+ hsize_t num_objs; /* Number of objects in a group */
char filename[1024];
char linkval[1024];
@@ -1503,6 +1504,12 @@ test_compat(hid_t fapl, hbool_t new_format)
if(H5Glink2(file_id, "group1", H5G_LINK_HARD, group2_id, "link_to_group1") < 0) FAIL_STACK_ERROR
if(H5Glink2(file_id, "link_to_group1", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/soft_link_to_group1") < 0) FAIL_STACK_ERROR
+ /* Test getting the number of objects in a group */
+ if(H5Gget_num_objs(file_id, &num_objs) < 0) FAIL_STACK_ERROR
+ if(num_objs != 2) TEST_ERROR
+ if(H5Gget_num_objs(group1_id, &num_objs) < 0) FAIL_STACK_ERROR
+ if(num_objs != 1) TEST_ERROR
+
/* Test that H5Glink created hard links properly */
if(H5Gget_objinfo(file_id, "/group2", TRUE, &sb_hard1) < 0) FAIL_STACK_ERROR
if(H5Gget_objinfo(file_id, "/group1/link_to_group2", TRUE, &sb_hard2) < 0) FAIL_STACK_ERROR
@@ -1556,7 +1563,7 @@ test_compat(hid_t fapl, hbool_t new_format)
if(H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT) >=0) TEST_ERROR
} H5E_END_TRY;
- if(H5Fclose(file_id) < 0) TEST_ERROR
+ if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
diff --git a/test/objcopy.c b/test/objcopy.c
index 3c6e03f..331add3 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -1242,8 +1242,8 @@ error:
static int
compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
{
- hsize_t num_objs; /* Number of objects in group */
- hsize_t num_objs2; /* Number of objects in group */
+ H5G_info_t ginfo; /* Group info struct */
+ H5G_info_t ginfo2; /* Group info struct */
hsize_t idx; /* Index over the objects in group */
unsigned cpy_flags; /* Object copy flags */
@@ -1255,17 +1255,17 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
cpy_flags = 0;
/* Check if both groups have the same # of objects */
- if(H5Gget_num_objs(gid, &num_objs) < 0) TEST_ERROR
- if(H5Gget_num_objs(gid2, &num_objs2) < 0) TEST_ERROR
+ if(H5Gget_info(gid, ".", &ginfo, H5P_DEFAULT) < 0) TEST_ERROR
+ if(H5Gget_info(gid2, ".", &ginfo2, H5P_DEFAULT) < 0) TEST_ERROR
if((cpy_flags & H5O_COPY_SHALLOW_HIERARCHY_FLAG) && depth == 0) {
- if(num_objs2 != 0) TEST_ERROR
+ if(ginfo2.nlinks != 0) TEST_ERROR
} /* end if */
else {
- if(num_objs != num_objs2) TEST_ERROR
+ if(ginfo.nlinks != ginfo2.nlinks) TEST_ERROR
} /* end if */
/* Check contents of groups */
- if(num_objs2 > 0) {
+ if(ginfo2.nlinks > 0) {
char objname[NAME_BUF_SIZE]; /* Name of object in group */
char objname2[NAME_BUF_SIZE]; /* Name of object in group */
H5G_obj_t objtype; /* Type of object in group */
@@ -1277,7 +1277,7 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
hid_t oid, oid2; /* IDs of objects within group */
/* Loop over contents of groups */
- for(idx = 0; idx < num_objs; idx++) {
+ for(idx = 0; idx < ginfo.nlinks; idx++) {
/* Check name of objects */
if(H5Gget_objname_by_idx(gid, idx, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
if(H5Gget_objname_by_idx(gid2, idx, objname2, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR
diff --git a/test/th5o.c b/test/th5o.c
index 86c8c84..ff434d6 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -47,7 +47,7 @@ test_h5o_open(void)
hid_t grp, dset, dtype, dspace; /* Object identifiers */
hsize_t dims[RANK];
H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
- hsize_t num_objs = 0; /* Number of objects in the group */
+ H5G_info_t ginfo; /* Group info struct */
H5T_class_t type_class; /* Class of the datatype */
herr_t ret; /* Value returned from API calls */
@@ -102,9 +102,9 @@ test_h5o_open(void)
VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID");
/* Do something more complex with each of the IDs to make sure they "work" */
- ret = H5Gget_num_objs(grp, &num_objs);
- CHECK(ret, FAIL, "H5Gget_num_objs");
- VERIFY(num_objs, 1, "H5Gget_num_objs"); /* There should be one object, the datatype */
+ ret = H5Gget_info(grp, ".", &ginfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Gget_info");
+ VERIFY(ginfo.nlinks, 1, "H5Gget_info"); /* There should be one object, the datatype */
type_class = H5Tget_class(dtype);
VERIFY(type_class, H5T_INTEGER, "H5Tget_class");
@@ -249,7 +249,7 @@ test_h5o_open_by_addr(void)
haddr_t dtype_addr;
hsize_t dims[RANK];
H5I_type_t id_type; /* Type of IDs returned from H5Oopen */
- hsize_t num_objs = 0; /* Number of objects in the group */
+ H5G_info_t ginfo; /* Group info struct */
H5T_class_t type_class; /* Class of the datatype */
herr_t ret; /* Value returned from API calls */
@@ -315,9 +315,9 @@ test_h5o_open_by_addr(void)
VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID");
/* Do something more complex with each of the IDs to make sure they "work" */
- ret = H5Gget_num_objs(grp, &num_objs);
- CHECK(ret, FAIL, "H5Gget_num_objs");
- VERIFY(num_objs, 1, "H5Gget_num_objs"); /* There should be one object, the datatype */
+ ret = H5Gget_info(grp, ".", &ginfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Gget_info");
+ VERIFY(ginfo.nlinks, 1, "H5Gget_info"); /* There should be one object, the datatype */
type_class = H5Tget_class(dtype);
VERIFY(type_class, H5T_INTEGER, "H5Tget_class");
diff --git a/test/titerate.c b/test/titerate.c
index 3c27bdd..99f099c 100644
--- a/test/titerate.c
+++ b/test/titerate.c
@@ -132,7 +132,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
char *lnames[NDATASETS + 2];/* Names of the links created */
char dataset_name[NAMELEN]; /* dataset name */
iter_info info; /* Custom iteration information */
- hsize_t num_membs; /* Number of group members */
+ H5G_info_t ginfo; /* Buffer for querying object's info */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -203,18 +203,18 @@ test_iter_group(hid_t fapl, hbool_t new_format)
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
CHECK(file, FAIL, "H5Fopen");
- /* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
+ /* These two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx, actually
* iterate through B-tree for group members in internal library design.
*/
{
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
CHECK(root_group, FAIL, "H5Gopen2");
- ret = H5Gget_num_objs(root_group, &num_membs);
- CHECK(ret, FAIL, "H5Gget_num_objs");
- VERIFY(num_membs, (NDATASETS + 2), "H5Gget_num_objs");
+ ret = H5Gget_info(root_group, ".", &ginfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Gget_info");
+ VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info");
- for(i = 0; i< (int)num_membs; i++) {
+ for(i = 0; i< (int)ginfo.nlinks; i++) {
H5G_obj_t obj_type; /* Type of object in file */
ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)NAMELEN);
@@ -233,16 +233,16 @@ test_iter_group(hid_t fapl, hbool_t new_format)
CHECK(ret, FAIL, "H5Gclose");
}
- /* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
+ /* These two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx, actually
* iterate through B-tree for group members in internal library design.
* (Same as test above, but with the file ID instead of opening the root group)
*/
{
- ret = H5Gget_num_objs(file, &num_membs);
- CHECK(ret, FAIL, "H5Gget_num_objs");
- VERIFY(num_membs, NDATASETS + 2, "H5Gget_num_objs");
+ ret = H5Gget_info(file, ".", &ginfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Gget_info");
+ VERIFY(ginfo.nlinks, NDATASETS + 2, "H5Gget_info");
- for(i = 0; i< (int)num_membs; i++) {
+ for(i = 0; i< (int)ginfo.nlinks; i++) {
H5G_obj_t obj_type; /* Type of object in file */
ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)i, dataset_name, (size_t)NAMELEN);
@@ -708,7 +708,7 @@ static void test_grp_memb_funcs(hid_t fapl)
char *obj_names[NDATASETS+2];/* Names of the objects in group */
char dataset_name[NAMELEN]; /* dataset name */
ssize_t name_len; /* Length of object's name */
- hsize_t num_membs; /* Number of group members */
+ H5G_info_t ginfo; /* Buffer for querying object's info */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -772,17 +772,17 @@ static void test_grp_memb_funcs(hid_t fapl)
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
CHECK(file, FAIL, "H5Fopen");
- /* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
+ /* These two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx, actually
* iterate through B-tree for group members in internal library design.
*/
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
CHECK(root_group, FAIL, "H5Gopen2");
- ret = H5Gget_num_objs(root_group, &num_membs);
- CHECK(ret, FAIL, "H5Gget_num_objs");
- VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs");
+ ret = H5Gget_info(root_group, ".", &ginfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Gget_info");
+ VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info");
- for(i=0; i< (int)num_membs; i++) {
+ for(i=0; i< (int)ginfo.nlinks; i++) {
H5G_obj_t obj_type; /* Type of object in file */
/* Test with NULL for name, to query length */
@@ -819,7 +819,7 @@ static void test_grp_memb_funcs(hid_t fapl)
HDqsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
/* Compare object names */
- for(i = 0; i< (int)num_membs; i++) {
+ for(i = 0; i< (int)ginfo.nlinks; i++) {
ret = HDstrcmp(dnames[i], obj_names[i]);
VERIFY(ret, 0, "HDstrcmp");
} /* end for */
@@ -848,11 +848,11 @@ static void test_links(hid_t fapl)
hid_t file; /* File ID */
char obj_name[NAMELEN]; /* Names of the object in group */
ssize_t name_len; /* Length of object's name */
- herr_t ret; /* Generic return value */
hid_t gid, gid1;
- hsize_t i;
H5G_obj_t obj_type; /* Type of object */
- hsize_t nobjs; /* Number of objects */
+ H5G_info_t ginfo; /* Buffer for querying object's info */
+ hsize_t i;
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Soft and Hard Link Iteration Functionality\n"));
@@ -875,12 +875,12 @@ static void test_links(hid_t fapl)
ret = H5Lcreate_hard(gid, "/g1", H5L_SAME_LOC, "hardlink", H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lcreate_hard");
- ret = H5Gget_num_objs(gid, &nobjs);
- CHECK(ret, FAIL, "H5Gget_num_objs");
- VERIFY(nobjs,3,"H5Gget_num_objs");
+ ret = H5Gget_info(gid, ".", &ginfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Gget_info");
+ VERIFY(ginfo.nlinks, 3, "H5Gget_info");
- /* Test these two functions, H5Gget_num_objs and H5Gget_objname_by_idx */
- for(i = 0; i < nobjs; i++) {
+ /* Test these two functions, H5Gget_objtype_by_idx and H5Gget_objname_by_idx */
+ for(i = 0; i < ginfo.nlinks; i++) {
/* Get object name */
name_len = H5Gget_objname_by_idx(gid, i, obj_name, (size_t)NAMELEN);
CHECK(name_len, FAIL, "H5Gget_objname_by_idx");
diff --git a/test/trefer.c b/test/trefer.c
index 318858e..ad4b219 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -985,7 +985,7 @@ test_reference_group(void)
hid_t sid; /* Dataspace ID */
hobj_ref_t wref; /* Reference to write */
hobj_ref_t rref; /* Reference to read */
- hsize_t nobjs;
+ H5G_info_t ginfo; /* Group info struct */
char objname[NAME_SIZE]; /* Buffer to store name */
H5G_obj_t objtype; /* Object type */
int count = 0; /* Count within iterated group */
@@ -1065,14 +1065,12 @@ test_reference_group(void)
CHECK(ret, FAIL, "H5Literate");
/* Various queries on the group opened */
- ret = H5Gget_num_objs(gid, &nobjs);
- CHECK(ret, FAIL, "H5Gget_num_objs");
-
- VERIFY(nobjs, 3, "H5Gget_num_objs");
+ ret = H5Gget_info(gid, ".", &ginfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Gget_info");
+ VERIFY(ginfo.nlinks, 3, "H5Gget_info");
ret = H5Gget_objname_by_idx(gid, (hsize_t)0, objname, (size_t)NAME_SIZE);
CHECK(ret, FAIL, "H5Gget_objname_by_idx");
-
VERIFY_STR(objname, DSETNAME2, "H5Gget_objname_by_idx");
objtype = H5Gget_objtype_by_idx(gid, (hsize_t)0);
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 6f77ba3..0a2ca3b 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -2792,7 +2792,7 @@ static void dump_fcontents(hid_t fid)
}
/* print objects in the files */
- h5trav_getinfo(fid, NULL, 1);
+ h5trav_print(fid);
printf(" %s\n",END);
}
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index f32d15d..c710bce 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -329,9 +329,18 @@ int do_copy_objects(hid_t fidin,
*/
case H5G_GROUP:
if (options->verbose)
- printf(FORMAT_OBJ,"group",travt->objs[i].name );
+ printf(FORMAT_OBJ,"group",travt->objs[i].name );
- if (options->grp_compact>0 || options->grp_indexed>0) {
+ /*-------------------------------------------------------------------------
+ * the root is a special case, we get an ID for the root group
+ * and copy its attributes using that ID
+ *-------------------------------------------------------------------------
+ */
+ if(HDstrcmp(travt->objs[i].name, "/") == 0) {
+ if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
+ goto error;
+ }
+ else if (options->grp_compact>0 || options->grp_indexed>0) {
/* Set up group creation property list */
if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
goto error;
@@ -780,26 +789,6 @@ int do_copy_objects(hid_t fidin,
} /* i */
- /*-------------------------------------------------------------------------
- * the root is a special case, we get an ID for the root group
- * and copy its attributes using that ID
- *-------------------------------------------------------------------------
- */
-
- if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
- goto error;
-
- if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
- goto error;
-
- if (copy_attr(grp_in,grp_out,options)<0)
- goto error;
-
- if (H5Gclose(grp_out)<0)
- goto error;
- if (H5Gclose(grp_in)<0)
- goto error;
-
return 0;
error:
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index e8799f8..8a549cd 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -397,30 +397,6 @@ int do_copy_refobjs(hid_t fidin,
}
}
-
-
- /*-------------------------------------------------------------------------
- * the root is a special case, we get an ID for the root group
- * and copy its attributes using that ID
- * it must be done last, because the attributes might contain references to
- * objects in the object list
- *-------------------------------------------------------------------------
- */
-
- if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
- goto error;
-
- if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
- goto error;
-
- if (copy_refs_attr(grp_in, grp_out, options, travt, fidout) < 0)
- goto error;
-
- if (H5Gclose(grp_out) < 0)
- goto error;
- if (H5Gclose(grp_in) < 0)
- goto error;
-
return 0;
error:
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index 6c4f1af..54c517d 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -461,9 +461,8 @@ static herr_t
group_stats(hid_t group, const char *name, const char *fullname,
const H5O_info_t *oi, H5L_iterate_t walk, iter_t *iter)
{
- hid_t gid; /* Group ID */
const char *last_container;
- hsize_t num_objs;
+ H5G_info_t ginfo; /* Group information */
unsigned bin; /* "bin" the number of objects falls in */
herr_t ret;
@@ -476,21 +475,18 @@ group_stats(hid_t group, const char *name, const char *fullname,
iter->group_ohdr_info.total_size += oi->hdr.space.total;
iter->group_ohdr_info.free_size += oi->hdr.space.free;
- gid = H5Gopen2(group, name, H5P_DEFAULT);
- assert(gid > 0);
-
- /* Get number of links in this group */
- ret = H5Gget_num_objs(gid, &num_objs);
+ /* Get group information */
+ ret = H5Gget_info(group, name, &ginfo, H5P_DEFAULT);
assert(ret >= 0);
/* Update link stats */
- if(num_objs < SIZE_SMALL_GROUPS)
- (iter->num_small_groups[(size_t)num_objs])++;
- if(num_objs > iter->max_fanout)
- iter->max_fanout = num_objs;
+ if(ginfo.nlinks < SIZE_SMALL_GROUPS)
+ (iter->num_small_groups[(size_t)ginfo.nlinks])++;
+ if(ginfo.nlinks > iter->max_fanout)
+ iter->max_fanout = ginfo.nlinks;
/* Add group count to proper bin */
- bin = ceil_log10((unsigned long)num_objs);
+ bin = ceil_log10((unsigned long)ginfo.nlinks);
if((bin + 1) > iter->group_nbins) {
/* Allocate more storage for info about dataset's datatype */
iter->group_bins = realloc(iter->group_bins, (bin + 1) * sizeof(unsigned long));
@@ -515,10 +511,6 @@ group_stats(hid_t group, const char *name, const char *fullname,
ret = attribute_stats(iter, oi);
assert(ret >= 0);
- /* Close current group */
- ret = H5Gclose(gid);
- assert(ret >= 0);
-
/* Update current container info */
last_container = iter->container;
iter->container = fullname;
@@ -742,7 +734,7 @@ dataset_stats(hid_t group, const char *name, const H5O_info_t *oi, iter_t *iter)
*-------------------------------------------------------------------------
*/
static herr_t
-walk(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter)
+walk(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *_iter)
{
iter_t *iter = (iter_t *)_iter;
H5O_info_t oi;
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 1710347..2d7cc7d 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -186,180 +186,156 @@ hsize_t h5diff(const char *fname1,
const char *objname2,
diff_opt_t *options)
{
- int nobjects1, nobjects2;
- trav_info_t *info1 = NULL;
- trav_info_t *info2 = NULL;
- hid_t file1_id=(-1), file2_id=(-1);
- char filenames[2][1024];
- hsize_t nfound = 0;
+ trav_info_t *info1;
+ trav_info_t *info2;
+ hid_t file1_id = (-1), file2_id = (-1);
+ char filenames[2][1024];
+ hsize_t nfound = 0;
- memset(filenames, 0, 1024*2);
+ memset(filenames, 0, 1024*2);
- if (options->m_quiet &&
- (options->m_verbose || options->m_report))
- {
- printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
- options->err_stat=1;
- return 0;
- }
+ if(options->m_quiet &&
+ (options->m_verbose || options->m_report))
+ {
+ printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
+ options->err_stat=1;
+ return 0;
+ }
-/*-------------------------------------------------------------------------
- * open the files first; if they are not valid, no point in continuing
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * open the files first; if they are not valid, no point in continuing
+ *-------------------------------------------------------------------------
+ */
- /* disable error reporting */
- H5E_BEGIN_TRY
- {
- /* Open the files */
- if ((file1_id = H5Fopen (fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- {
- printf ("h5diff: <%s>: unable to open file\n", fname1);
- options->err_stat = 1;
+ /* disable error reporting */
+ H5E_BEGIN_TRY
+ {
+ /* Open the files */
+ if ((file1_id = H5Fopen (fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ {
+ printf ("h5diff: <%s>: unable to open file\n", fname1);
+ options->err_stat = 1;
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- /* Let tasks know that they won't be needed */
- phdiff_dismiss_workers();
- }
+ if(g_Parallel)
+ {
+ /* Let tasks know that they won't be needed */
+ phdiff_dismiss_workers();
+ }
#endif
- goto out;
- }
- if ((file2_id = H5Fopen (fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- {
- printf ("h5diff: <%s>: unable to open file\n", fname2);
- options->err_stat = 1;
+ goto out;
+ }
+ if ((file2_id = H5Fopen (fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ {
+ printf ("h5diff: <%s>: unable to open file\n", fname2);
+ options->err_stat = 1;
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- /* Let tasks know that they won't be needed */
- phdiff_dismiss_workers();
- }
+ if(g_Parallel)
+ {
+ /* Let tasks know that they won't be needed */
+ phdiff_dismiss_workers();
+ }
#endif
- goto out;
- }
- /* enable error reporting */
- }
- H5E_END_TRY;
-
-/*-------------------------------------------------------------------------
- * get the number of objects in the files
- *-------------------------------------------------------------------------
- */
- nobjects1 = h5trav_getinfo (file1_id, NULL, 0);
- nobjects2 = h5trav_getinfo (file2_id, NULL, 0);
-
- if (nobjects1 < 0 || nobjects2 < 0)
- {
- printf ("Error: Could not get file contents\n");
- options->err_stat = 1;
-#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- /* Let tasks know that they won't be needed */
- phdiff_dismiss_workers();
- }
-#endif
- goto out;
- }
+ goto out;
+ }
+ /* enable error reporting */
+ }
+ H5E_END_TRY;
-/*-------------------------------------------------------------------------
- * get the list of objects in the files
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Initialize the info structs
+ *-------------------------------------------------------------------------
+ */
+ trav_info_init(&info1);
+ trav_info_init(&info2);
- info1 = (trav_info_t *) malloc (nobjects1 * sizeof (trav_info_t));
- info2 = (trav_info_t *) malloc (nobjects2 * sizeof (trav_info_t));
- if (info1 == NULL || info2 == NULL)
- {
- printf ("Error: Not enough memory for object list\n");
- options->err_stat = 1;
- if (info1) h5trav_freeinfo (info1, nobjects1);
- if (info2) h5trav_freeinfo (info2, nobjects1);
+ /*-------------------------------------------------------------------------
+ * get the list of objects in the files
+ *-------------------------------------------------------------------------
+ */
+ if(h5trav_getinfo(file1_id, info1) < 0 || h5trav_getinfo(file2_id, info2) < 0)
+ {
+ printf("Error: Could not get file contents\n");
+ options->err_stat = 1;
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- /* Let tasks know that they won't be needed */
- phdiff_dismiss_workers();
- }
+ if(g_Parallel)
+ {
+ /* Let tasks know that they won't be needed */
+ phdiff_dismiss_workers();
+ }
#endif
- goto out;
- }
-
- h5trav_getinfo (file1_id, info1, 0);
- h5trav_getinfo (file2_id, info2, 0);
+ goto out;
+ }
-/*-------------------------------------------------------------------------
- * object name was supplied
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * object name was supplied
+ *-------------------------------------------------------------------------
+ */
- if (objname1)
- {
+ if (objname1)
+ {
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- /* Let tasks know that they won't be needed */
- phdiff_dismiss_workers();
- }
+ if(g_Parallel)
+ {
+ /* Let tasks know that they won't be needed */
+ phdiff_dismiss_workers();
+ }
#endif
- assert (objname2);
- options->cmn_objs = 1; /* eliminate warning */
- nfound = diff_compare (file1_id, fname1, objname1, nobjects1, info1,
- file2_id, fname2, objname2, nobjects2, info2,
- options);
- }
+ assert (objname2);
+ options->cmn_objs = 1; /* eliminate warning */
+ nfound = diff_compare (file1_id, fname1, objname1, info1,
+ file2_id, fname2, objname2, info2,
+ options);
+ }
-/*-------------------------------------------------------------------------
- * compare all
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * compare all
+ *-------------------------------------------------------------------------
+ */
- else
- {
+ else
+ {
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- int i;
+ if(g_Parallel)
+ {
+ int i;
- if( (strlen(fname1) > 1024) || (strlen(fname2) > 1024))
- {
- fprintf(stderr, "The parallel diff only supports path names up to 1024 characters\n");
- MPI_Abort(MPI_COMM_WORLD, 0);
- }
+ if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024))
+ {
+ fprintf(stderr, "The parallel diff only supports path names up to 1024 characters\n");
+ MPI_Abort(MPI_COMM_WORLD, 0);
+ }
- strcpy(filenames[0], fname1);
- strcpy(filenames[1], fname2);
+ HDstrcpy(filenames[0], fname1);
+ HDstrcpy(filenames[1], fname2);
- /* Alert the worker tasks that there's going to be work. */
+ /* Alert the worker tasks that there's going to be work. */
- for(i=1; i<g_nTasks; i++)
- MPI_Send(filenames, 1024*2, MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD);
- }
+ for(i = 1; i < g_nTasks; i++)
+ MPI_Send(filenames, 1024 * 2, MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD);
+ }
#endif
- nfound = diff_match (file1_id, nobjects1, info1,
- file2_id, nobjects2, info2, options);
- }
+ nfound = diff_match(file1_id, info1, file2_id, info2, options);
+ }
- h5trav_freeinfo (info1, nobjects1);
- h5trav_freeinfo (info2, nobjects2);
+ trav_info_free(info1);
+ trav_info_free(info2);
out:
- /* close */
- H5E_BEGIN_TRY
- {
- H5Fclose (file1_id);
- H5Fclose (file2_id);
- }
- H5E_END_TRY;
+ /* close */
+ H5E_BEGIN_TRY
+ {
+ H5Fclose(file1_id);
+ H5Fclose(file2_id);
+ }
+ H5E_END_TRY;
- return nfound;
+ return nfound;
}
@@ -383,18 +359,16 @@ out:
*-------------------------------------------------------------------------
*/
hsize_t diff_match (hid_t file1_id,
- int nobjects1,
trav_info_t * info1,
hid_t file2_id,
- int nobjects2,
trav_info_t * info2,
diff_opt_t * options)
{
- int more_names_exist = (nobjects1 > 0 && nobjects2 > 0) ? 1 : 0;
+ int more_names_exist = (info1->nused > 0 && info2->nused > 0) ? 1 : 0;
trav_table_t *table = NULL;
int cmp;
- int curr1 = 0;
- int curr2 = 0;
+ size_t curr1 = 0;
+ size_t curr2 = 0;
unsigned infile[2];
char c1, c2;
hsize_t nfound = 0;
@@ -409,12 +383,12 @@ hsize_t diff_match (hid_t file1_id,
while (more_names_exist)
{
/* criteria is string compare */
- cmp = strcmp (info1[curr1].name, info2[curr2].name);
+ cmp = HDstrcmp(info1->paths[curr1].path, info2->paths[curr2].path);
if (cmp == 0)
{
infile[0] = 1;
infile[1] = 1;
- trav_table_addflags (infile, info1[curr1].name, info1[curr1].type,
+ trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type,
table);
curr1++;
@@ -424,7 +398,7 @@ hsize_t diff_match (hid_t file1_id,
{
infile[0] = 1;
infile[1] = 0;
- trav_table_addflags (infile, info1[curr1].name, info1[curr1].type,
+ trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type,
table);
curr1++;
}
@@ -432,37 +406,36 @@ hsize_t diff_match (hid_t file1_id,
{
infile[0] = 0;
infile[1] = 1;
- trav_table_addflags (infile, info2[curr2].name, info2[curr2].type,
+ trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type,
table);
curr2++;
}
- more_names_exist = (curr1 < nobjects1 && curr2 < nobjects2) ? 1 : 0;
-
+ more_names_exist = (curr1 < info1->nused && curr2 < info2->nused) ? 1 : 0;
} /* end while */
/* list1 did not end */
- if (curr1 < nobjects1)
+ if (curr1 < info1->nused)
{
- while (curr1 < nobjects1)
+ while (curr1 < info1->nused)
{
infile[0] = 1;
infile[1] = 0;
- trav_table_addflags (infile, info1[curr1].name, info1[curr1].type,
+ trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type,
table);
curr1++;
}
}
/* list2 did not end */
- if (curr2 < nobjects2)
+ if (curr2 < info2->nused)
{
- while (curr2 < nobjects2)
+ while (curr2 < info2->nused)
{
infile[0] = 0;
infile[1] = 1;
- trav_table_addflags (infile, info2[curr2].name, info2[curr2].type,
+ trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type,
table);
curr2++;
}
@@ -789,17 +762,6 @@ hsize_t diff_match (hid_t file1_id,
/* free table */
trav_table_free (table);
-
-/*-------------------------------------------------------------------------
- * do the diff for the root.
- * this is a special case, we get an ID for the root group and call diff()
- * with this ID; it compares only the root group attributes
- *-------------------------------------------------------------------------
- */
-
- /* the manager can do this. */
- nfound += diff (file1_id, "/", file2_id, "/", options, H5G_GROUP);
-
return nfound;
}
@@ -821,20 +783,18 @@ hsize_t diff_match (hid_t file1_id,
hsize_t diff_compare (hid_t file1_id,
const char *file1_name,
const char *obj1_name,
- int nobjects1,
trav_info_t * info1,
hid_t file2_id,
const char *file2_name,
const char *obj2_name,
- int nobjects2,
trav_info_t * info2,
diff_opt_t * options)
{
int f1 = 0, f2 = 0;
hsize_t nfound = 0;
- int i = h5trav_getindex (obj1_name, nobjects1, info1);
- int j = h5trav_getindex (obj2_name, nobjects2, info2);
+ ssize_t i = h5trav_getindex (info1, obj1_name);
+ ssize_t j = h5trav_getindex (info2, obj2_name);
if (i == -1)
{
@@ -855,23 +815,23 @@ hsize_t diff_compare (hid_t file1_id,
}
/* use the name with "/" first, as obtained by iterator function */
- obj1_name = info1[i].name;
- obj2_name = info2[j].name;
+ obj1_name = info1->paths[i].path;
+ obj2_name = info2->paths[j].path;
/* objects are not the same type */
- if (info1[i].type != info2[j].type)
+ if (info1->paths[i].type != info2->paths[j].type)
{
if (options->m_verbose)
parallel_print
("Comparison not possible: <%s> is of type %s and <%s> is of type %s\n",
- obj1_name, get_type (info1[i].type), obj2_name,
- get_type (info2[j].type));
+ obj1_name, get_type (info1->paths[i].type), obj2_name,
+ get_type (info2->paths[j].type));
options->not_cmp=1;
return 0;
}
nfound =
- diff (file1_id, obj1_name, file2_id, obj2_name, options, info1[i].type);
+ diff (file1_id, obj1_name, file2_id, obj2_name, options, info1->paths[i].type);
return nfound;
}
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 9125d7c..e22502f 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -94,20 +94,16 @@ hsize_t diff( hid_t file1_id,
hsize_t diff_compare( hid_t file1_id,
const char *file1_name,
const char *obj1_name,
- int nobjects1,
trav_info_t *info1,
hid_t file2_id,
const char *file2_name,
const char *obj2_name,
- int nobjects2,
trav_info_t *info2,
diff_opt_t *options );
hsize_t diff_match( hid_t file1_id,
- int nobjects1,
trav_info_t *info1,
hid_t file2_id,
- int nobjects2,
trav_info_t *info2,
diff_opt_t *options );
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index b5a2872..d3a7078 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -25,6 +25,7 @@
*
*-------------------------------------------------------------------------
*/
+#if defined (H5DIFF_DEBUG)
static void
print_size (int rank, hsize_t *dims)
{
@@ -40,6 +41,7 @@ print_size (int rank, hsize_t *dims)
parallel_print("]\n" );
}
+#endif /* H5DIFF_DEBUG */
@@ -279,8 +281,6 @@ hsize_t diff_datasetid( hid_t did1,
storage_size1=H5Dget_storage_size(did1);
storage_size2=H5Dget_storage_size(did2);
- if (storage_size1<0 || storage_size2<0)
- goto error;
if (storage_size1==0 || storage_size2==0)
{
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 6ff68d5..65cca66 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -18,255 +18,357 @@
#include "H5private.h"
/*-------------------------------------------------------------------------
- * local functions
+ * local typedefs
*-------------------------------------------------------------------------
*/
-static int traverse( hid_t loc_id,
- const char *group_name,
- trav_table_t *table,
- trav_info_t *info,
- int *idx,
- int print);
+typedef struct trav_addr_t {
+ size_t nalloc;
+ size_t nused;
+ haddr_t *addrs;
+} trav_addr_t;
+
+typedef struct {
+ herr_t (*visit_obj)(const char *path_name, const H5O_info_t *oinfo, hbool_t already_visited, void *udata);
+ herr_t (*visit_lnk)(const char *path_name, const H5L_info_t *linfo, void *udata);
+ void *udata; /* User data to pass to callbacks */
+} trav_visitor_t;
+
+typedef struct {
+ trav_addr_t *seen; /* List of addresses seen already */
+ const char *curr_path; /* Current path to parent group */
+ const trav_visitor_t *visitor; /* Information for visiting each link/object */
+} trav_ud_traverse_t;
+
+typedef struct {
+ hid_t fid; /* File ID being traversed */
+ trav_table_t *table; /* Table for tracking name of objects with >1 hard link */
+} trav_print_udata_t;
-static hssize_t get_nnames( hid_t loc_id,
- const char *group_name );
+/*-------------------------------------------------------------------------
+ * local functions
+ *-------------------------------------------------------------------------
+ */
+static void trav_table_add(trav_table_t *table,
+ const char *objname,
+ const H5O_info_t *oinfo);
-static herr_t get_name_type( hid_t loc_id,
- const char *group_name,
- int idx,
- char **name,
- H5G_obj_t *type );
+static size_t trav_table_search(const trav_table_t *table, haddr_t objno);
+static void trav_table_addlink(trav_table_t *table,
+ size_t j /* the object index */,
+ const char *path);
/*-------------------------------------------------------------------------
* "h5trav info" public functions. used in h5diff
*-------------------------------------------------------------------------
*/
+
/*-------------------------------------------------------------------------
- * Function: h5trav_getinfo
+ * Function: trav_addr_add
*
- * Purpose: get an array of "trav_info_t" , containing the name and type of
- * objects in the file
+ * Purpose: Add a hardlink address to visited data structure
*
- * Return: number of object names in file
+ * Return: void
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
*
- * Date: November 6, 2002
+ * Date: September 1, 2007
*
*-------------------------------------------------------------------------
*/
-
-int h5trav_getinfo(hid_t file_id,
- trav_info_t *info,
- int print )
+static void
+trav_addr_add(trav_addr_t *visited, haddr_t addr)
{
- trav_table_t *table = NULL;
- int nnames = 0;
-
- /* init table */
- trav_table_init(&table);
+ size_t idx; /* Index of address to use */
- /* iterate starting on the root group */
- if((nnames = traverse(file_id, "/", table, info, &nnames, print)) < 0)
- return -1;
+ /* Allocate space if necessary */
+ if(visited->nused == visited->nalloc) {
+ visited->nalloc = MAX(1, visited->nalloc * 2);;
+ visited->addrs = (haddr_t *)HDrealloc(visited->addrs, visited->nalloc * sizeof(haddr_t));
+ } /* end if */
- /* free table */
- trav_table_free(table);
-
- return nnames;
-}
+ /* Append it */
+ idx = visited->nused++;
+ visited->addrs[idx] = addr;
+} /* end trav_addr_add() */
+
/*-------------------------------------------------------------------------
- * Function: h5trav_getindex
+ * Function: trav_addr_visited
*
- * Purpose: get index of OBJ in list
+ * Purpose: Check if an address has already been visited
*
- * Return: index, -1 if not found
+ * Return: TRUE/FALSE
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
*
- * Date: May 9, 2003
+ * Date: September 1, 2007
*
*-------------------------------------------------------------------------
*/
-
-int h5trav_getindex( const char *obj, int nobjs, trav_info_t *info )
+static hbool_t
+trav_addr_visited(trav_addr_t *visited, haddr_t addr)
{
- char *pdest;
- int result;
- int i;
-
- for ( i = 0; i < nobjs; i++)
- {
- if ( strcmp(obj,info[i].name)==0 )
- return i;
-
- pdest = strstr( info[i].name, obj );
- result = (int)(pdest - info[i].name);
-
- /* found at position 1, meaning without '/' */
- if( pdest != NULL && result==1 )
- return i;
- }
- return -1;
-}
+ size_t u; /* Local index variable */
+
+ /* Look for address */
+ for(u = 0; u < visited->nused; u++)
+ /* Check for address already in array */
+ if(visited->addrs[u] == addr)
+ return(TRUE);
+
+ /* Didn't find address */
+ return(FALSE);
+} /* end trav_addr_visited() */
+
/*-------------------------------------------------------------------------
- * Function: h5trav_freeinfo
+ * Function: traverse_cb
*
- * Purpose: free info memory
+ * Purpose: Iterator callback for traversing objects in file
+ *
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ *
+ * Date: September 1, 2007
*
*-------------------------------------------------------------------------
*/
+static herr_t
+traverse_cb(hid_t loc_id, const char *link_name, const H5L_info_t *linfo,
+ void *_udata)
+{
+ trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */
+ hbool_t is_group = FALSE; /* If the object is a group */
+ hbool_t already_visited = FALSE; /* Whether the link/object was already visited */
+ char *link_path; /* Full path name of a link */
+
+ /* Construct the full path name of this link */
+ link_path = (char*)HDmalloc(HDstrlen(udata->curr_path) + HDstrlen(link_name) + 2);
+ HDassert(link_path);
+ HDstrcpy(link_path, udata->curr_path);
+ HDstrcat(link_path, "/");
+ HDstrcat(link_path, link_name);
+
+ /* Perform the correct action for different types of links */
+ if(linfo->type == H5L_TYPE_HARD) {
+ H5O_info_t oinfo;
+
+ /* Get information about the object */
+ if(H5Oget_info(loc_id, link_name, &oinfo, H5P_DEFAULT) < 0)
+ return(H5_ITER_ERROR);
+
+ /* If the object has multiple links, add it to the list of addresses
+ * already visited, if it isn't there already
+ */
+ if(oinfo.rc > 1) {
+ already_visited = trav_addr_visited(udata->seen, oinfo.addr);
+ if(!already_visited)
+ trav_addr_add(udata->seen, oinfo.addr);
+ } /* end if */
+
+ /* Check if object is a group, for later */
+ is_group = (oinfo.type == H5O_TYPE_GROUP) ? TRUE : FALSE;
+
+ /* Make 'visit object' callback */
+ (*udata->visitor->visit_obj)(link_path, &oinfo, already_visited, udata->visitor->udata);
+ } /* end if */
+ else {
+ /* Make 'visit link' callback */
+ (*udata->visitor->visit_lnk)(link_path, linfo, udata->visitor->udata);
+ } /* end else */
+
+ /* Check for group that we haven't visited yet & recurse */
+ if(is_group && !already_visited) {
+ const char *prev_path = udata->curr_path; /* Previous path to link's parent group */
+
+ /* Set current path to this object */
+ udata->curr_path = link_path;
+
+ /* Iterate over all links in group object */
+ if(H5Literate(loc_id, link_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, udata, H5P_DEFAULT) < 0)
+ return(H5_ITER_ERROR);
+
+ /* Restore path in udata */
+ udata->curr_path = prev_path;
+ } /* end if */
+
+ /* Free path name for current link/object */
+ HDfree(link_path);
+
+ return(H5_ITER_CONT);
+} /* end traverse_cb() */
-void h5trav_freeinfo( trav_info_t *info, int nobjs )
+
+/*-------------------------------------------------------------------------
+ * Function: traverse
+ *
+ * Purpose: Iterate over all the objects/links in a file. Conforms to the
+ * "visitor" pattern.
+ *
+ * Return: 0 on success, -1 on failure
+ *
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ *
+ * Date: September 1, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+traverse(hid_t file_id, const trav_visitor_t *visitor)
{
- int i;
- if ( info )
- {
- for ( i = 0; i < nobjs; i++)
- {
- if (info[i].name)
- HDfree( info[i].name );
- }
- HDfree(info);
- }
+ H5O_info_t oinfo; /* Object info for root group */
+ trav_addr_t seen; /* List of addresses seen */
+ trav_ud_traverse_t udata; /* User data for iteration callback */
+
+ /* Get info for root group */
+ if(H5Oget_info(file_id, "/", &oinfo, H5P_DEFAULT) < 0)
+ return -1;
+
+ /* Visit the root group of the file */
+ (*visitor->visit_obj)("/", &oinfo, FALSE, visitor->udata);
+
+ /* Init addresses seen */
+ seen.nused = seen.nalloc = 0;
+ seen.addrs = NULL;
+
+ /* Check for multiple links to root group */
+ if(oinfo.rc > 1)
+ trav_addr_add(&seen, oinfo.addr);
+
+ /* Set up user data structure */
+ udata.seen = &seen;
+ udata.curr_path = "";
+ udata.visitor = visitor;
+
+ /* Iterate over all links in root group */
+ if(H5Literate(file_id, "/", H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
+ return -1;
+
+ /* Free visited addresses table */
+ if(seen.addrs)
+ HDfree(seen.addrs);
+
+ return 0;
}
+
/*-------------------------------------------------------------------------
- * Function: h5trav_printinfo
+ * Function: trav_info_add
*
- * Purpose: print list of names in file
+ * Purpose: Add a link path & type to info struct
*
* Return: void
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
*
- * Date: May 9, 2003
+ * Date: September 1, 2007
*
*-------------------------------------------------------------------------
*/
-void h5trav_printinfo(int nobjs, trav_info_t *travi)
+static void
+trav_info_add(trav_info_t *info, const char *path, H5G_obj_t obj_type)
{
- int i;
- for ( i = 0; i < nobjs; i++)
- {
- switch ( travi[i].type )
- {
- case H5G_GROUP:
- printf(" %-10s %s\n", "group", travi[i].name );
- break;
- case H5G_DATASET:
- printf(" %-10s %s\n", "dataset", travi[i].name );
- break;
- case H5G_TYPE:
- printf(" %-10s %s\n", "datatype", travi[i].name );
- break;
- case H5G_LINK:
- printf(" %-10s %s\n", "link", travi[i].name );
- break;
- case H5G_UDLINK:
- printf(" %-10s %s\n", "User defined link", travi[i].name );
- break;
- default:
- printf(" %-10s %s\n", "User defined object", travi[i].name );
- break;
- }
- }
-}
+ size_t idx; /* Index of address to use */
+ /* Allocate space if necessary */
+ if(info->nused == info->nalloc) {
+ info->nalloc = MAX(1, info->nalloc * 2);;
+ info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t));
+ } /* end if */
+
+ /* Append it */
+ idx = info->nused++;
+ info->paths[idx].path = HDstrdup(path);
+ info->paths[idx].type = obj_type;
+} /* end trav_info_add() */
+
+
/*-------------------------------------------------------------------------
- * "h5trav table" public functions. used in h5repack
+ * Function: trav_info_visit_obj
+ *
+ * Purpose: Callback for visiting object, with 'info' structure
+ *
+ * Return: 0 on success, -1 on failure
+ *
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ *
+ * Date: September 1, 2007
+ *
*-------------------------------------------------------------------------
*/
+static int
+trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
+ hbool_t UNUSED already_visited, void *udata)
+{
+ /* Add the object to the 'info' struct */
+ /* (object types map directly to "group" types) */
+ trav_info_add((trav_info_t *)udata, path, (H5G_obj_t)oinfo->type);
+
+ return(0);
+} /* end trav_info_visit_obj() */
+
/*-------------------------------------------------------------------------
- * Function: h5trav_getindext
+ * Function: trav_info_visit_lnk
*
- * Purpose: get index of NAME in list
+ * Purpose: Callback for visiting link, with 'info' structure
*
- * Return: index, -1 if not found
+ * Return: 0 on success, -1 on failure
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
*
- * Date: December 18, 2003
+ * Date: September 1, 2007
*
*-------------------------------------------------------------------------
*/
-
-int h5trav_getindext(const char *name, trav_table_t *table)
+static int
+trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
{
- char *pdest;
- int result;
- unsigned int i, j;
-
- for ( i = 0; i < table->nobjs; i++)
- {
- if ( strcmp(name,table->objs[i].name)==0 )
- return i;
-
- pdest = strstr( table->objs[i].name, name );
- result = (int)(pdest - table->objs[i].name);
-
- /* found at position 1, meaning without '/' */
- if( pdest != NULL && result==1 && strlen(table->objs[i].name)-1==strlen(name))
- return i;
-
- /* search also in the list of links */
- if (table->objs[i].nlinks)
- {
- for ( j=0; j<table->objs[i].nlinks; j++)
- {
- if ( strcmp(name,table->objs[i].links[j].new_name)==0 )
- return i;
-
- pdest = strstr( table->objs[i].links[j].new_name, name );
- result = (int)(pdest - table->objs[i].links[j].new_name);
-
- /* found at position 1, meaning without '/' */
- if( pdest != NULL && result==1 )
- return i;
-
- }
- }
-
- }
- return -1;
-}
+ /* Add the link to the 'info' struct */
+ trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5G_LINK : H5G_UDLINK));
+ return(0);
+} /* end trav_info_visit_lnk() */
+
+
/*-------------------------------------------------------------------------
- * Function: h5trav_gettable
+ * Function: h5trav_getinfo
*
- * Purpose: get the trav_table_t struct
+ * Purpose: get an array of "trav_info_t" , containing the name and type of
+ * objects in the file
*
- * Return: 0, -1 on error
+ * Return: number of object names in file
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
- * Date: December 17, 2003
+ * Date: November 6, 2002
*
*-------------------------------------------------------------------------
*/
-
-int h5trav_gettable(hid_t fid, trav_table_t *travt)
+int
+h5trav_getinfo(hid_t file_id, trav_info_t *info)
{
- int nnames = 0;
+ trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */
- /* iterate starting on the root group */
- if((nnames = traverse(fid, "/", travt, NULL, &nnames, 0)) < 0)
+ /* Init visitor structure */
+ info_visitor.visit_obj = trav_info_visit_obj;
+ info_visitor.visit_lnk = trav_info_visit_lnk;
+ info_visitor.udata = info;
+
+ /* Traverse all objects in the file, visiting each object & link */
+ if(traverse(file_id, &info_visitor) < 0)
return -1;
return 0;
}
/*-------------------------------------------------------------------------
- * Function: h5trav_printtable
+ * Function: h5trav_getindex
*
- * Purpose: print list of objects in file
+ * Purpose: get index of OBJ in list
*
- * Return: void
+ * Return: index, -1 if not found
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -274,403 +376,219 @@ int h5trav_gettable(hid_t fid, trav_table_t *travt)
*
*-------------------------------------------------------------------------
*/
-void h5trav_printtable(trav_table_t *table)
+
+ssize_t
+h5trav_getindex(const trav_info_t *info, const char *obj)
{
- unsigned int i, j;
-
- for ( i = 0; i < table->nobjs; i++)
- {
- switch ( table->objs[i].type )
- {
- case H5G_GROUP:
- printf(" %-10s %s\n", "group", table->objs[i].name );
- break;
- case H5G_DATASET:
- printf(" %-10s %s\n", "dataset", table->objs[i].name );
- break;
- case H5G_TYPE:
- printf(" %-10s %s\n", "datatype", table->objs[i].name );
- break;
- case H5G_LINK:
- printf(" %-10s %s\n", "link", table->objs[i].name );
- break;
- default:
- printf(" %-10s %s\n", "User defined object", table->objs[i].name );
- break;
- }
-
- if (table->objs[i].nlinks)
- {
- for ( j=0; j<table->objs[i].nlinks; j++)
- {
- printf(" %-10s %s\n", " hardlink", table->objs[i].links[j].new_name );
- }
- }
-
- }
-}
+ size_t u; /* Local index variable */
+
+ /* Loop over all paths in 'info' struct, looking for object */
+ for(u = 0; u < info->nused; u++) {
+ /* Check for object name having full path (with leading '/') */
+ if(HDstrcmp(obj, info->paths[u].path) == 0)
+ return((ssize_t)u);
+
+ /* Check for object name without leading '/' */
+ if(HDstrcmp(obj, (info->paths[u].path + 1)) == 0)
+ return((ssize_t)u);
+ } /* end for */
+
+ return((ssize_t)-1);
+} /* end h5trav_getindex() */
/*-------------------------------------------------------------------------
- * Function: get_nnames
+ * Function: trav_info_init
*
- * Purpose: Counts the number of names in the group GROUP_NAME
+ * Purpose: Initialize the info
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 10, 2002
+ * Return: void
*
- * 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.
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
*
- * Failure: Negative if something goes wrong within the
- * library, or the negative value returned by one
- * of the operators.
+ * Date: September 6, 2007
*
*-------------------------------------------------------------------------
*/
-static hssize_t get_nnames( hid_t loc_id, const char *group_name )
+void
+trav_info_init(trav_info_t **_info)
{
- hid_t gid;
- hsize_t nobjs = 0;
+ trav_info_t *info = (trav_info_t *)HDmalloc(sizeof(trav_info_t));
- /* Open the group */
- if((gid = H5Gopen2(loc_id, group_name, H5P_DEFAULT)) < 0)
- return(-1);
+ /* Init info structure */
+ info->nused = info->nalloc = 0;
+ info->paths = NULL;
- /* Retrieve the number of objects in it */
- if(H5Gget_num_objs(gid, &nobjs) < 0)
- return(-1);
+ *_info = info;
+} /* end trav_info_init() */
- /* Close the group */
- if(H5Gclose(gid) < 0)
- return(-1);
+
+/*-------------------------------------------------------------------------
+ * Function: trav_info_free
+ *
+ * Purpose: free info memory
+ *
+ *-------------------------------------------------------------------------
+ */
- return((hssize_t)nobjs);
-}
+void
+trav_info_free(trav_info_t *info)
+{
+ size_t u; /* Local index variable */
+
+ if(info) {
+ /* Free path names */
+ for(u = 0; u < info->nused; u++)
+ HDfree(info->paths[u].path);
+ HDfree(info->paths);
+ HDfree(info);
+ } /* end if */
+} /* end trav_info_free() */
/*-------------------------------------------------------------------------
- * Function: opget_info
- *
- * Purpose: operator function
+ * "h5trav table" public functions. used in h5repack
+ *-------------------------------------------------------------------------
+ */
+
+
+/*-------------------------------------------------------------------------
+ * Function: trav_table_visit_obj
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Purpose: Callback for visiting object, with 'table' sructure
*
- * Date: October 10, 2002
+ * Return: 0 on success, -1 on failure
*
- * Comments:
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
*
- * Modifications:
+ * Date: September 1, 2007
*
*-------------------------------------------------------------------------
*/
-
-static herr_t
-opget_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_data)
+static int
+trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
+ hbool_t already_visited, void *udata)
{
- H5G_stat_t statbuf;
+ trav_table_t *table = (trav_table_t *)udata;
- if(H5Gget_objinfo(loc_id, name, FALSE, &statbuf) < 0)
- return -1;
+ /* Check if we've already seen this object */
+ if(!already_visited)
+ /* add object to table */
+ trav_table_add(table, path, oinfo);
+ else {
+ size_t found; /* Index of original object seen */
- ((trav_info_t *)op_data)->type = statbuf.type;
- ((trav_info_t *)op_data)->name = (char *)HDstrdup(name);
+ /* Look for object in existing table */
+ found = trav_table_search(table, oinfo->addr);
+ HDassert(found < table->nobjs);
- /* Define 1 for return. This will cause the iterator to stop */
- return 1;
-}
+ /* Add alias for object to table */
+ trav_table_addlink(table, found, path);
+ } /* end else */
+ return(0);
+} /* end trav_table_visit_obj() */
+
/*-------------------------------------------------------------------------
- * Function: get_name_type
+ * Function: trav_table_visit_lnk
*
- * Purpose:
+ * Purpose: Callback for visiting link, with 'table' sructure
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Return: 0 on success, -1 on failure
+ *
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ *
+ * Date: September 1, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+trav_table_visit_lnk(const char *path, const H5L_info_t UNUSED *linfo, void *udata)
+{
+ /* Add the link to the 'table' struct */
+ trav_table_add((trav_table_t *)udata, path, NULL);
+
+ return(0);
+} /* end trav_table_visit_lnk() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5trav_gettable
*
- * Date: October 10, 2002
+ * Purpose: get the trav_table_t struct
*
- * 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.
+ * Return: 0, -1 on error
*
- * Failure: Negative if something goes wrong within the
- * library, or the negative value returned by one
- * of the operators.
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: December 17, 2003
*
*-------------------------------------------------------------------------
*/
-static herr_t get_name_type( hid_t loc_id,
- const char *group_name,
- int _idx,
- char **name,
- H5G_obj_t *type )
+int
+h5trav_gettable(hid_t fid, trav_table_t *table)
{
- trav_info_t info;
- hsize_t idx = (hsize_t)_idx;
-
- if(H5Literate(loc_id, group_name, H5_INDEX_NAME, H5_ITER_INC, &idx, opget_info, (void *)&info, H5P_DEFAULT) < 0)
- return -1;
+ trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */
- *name = info.name;
- *type = info.type;
+ /* Init visitor structure */
+ table_visitor.visit_obj = trav_table_visit_obj;
+ table_visitor.visit_lnk = trav_table_visit_lnk;
+ table_visitor.udata = table;
+ /* Traverse all objects in the file, visiting each object & link */
+ if(traverse(fid, &table_visitor) < 0)
+ return -1;
return 0;
}
/*-------------------------------------------------------------------------
- * Function: traverse
+ * Function: h5trav_getindext
*
- * Purpose: recursive function that searches HDF5 objects in LOC_ID
+ * Purpose: get index of NAME in list
*
- * Return: number of objects found in LOC_ID
+ * Return: index, -1 if not found
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
- * Date: November 4, 2002
+ * Date: December 18, 2003
*
*-------------------------------------------------------------------------
*/
-static int traverse(hid_t loc_id,
- const char *group_name,
- trav_table_t *table,
- trav_info_t *info,
- int *idx,
- int print)
+int
+h5trav_getindext(const char *name, const trav_table_t *table)
{
- haddr_t objno; /* Compact form of object's location */
- char *name = NULL;
- H5G_obj_t type;
- int n_names;
- char *path = NULL;
- H5G_stat_t statbuf;
- int inserted_objs = 0;
- int i, j;
-
- /* get the number of names */
- if((n_names = (int)get_nnames(loc_id, group_name)) < 0)
- return -1;
-
- for(i = 0; i < n_names; i++) {
- if(get_name_type(loc_id, group_name, i, &name, &type) < 0)
- return -1;
-
- /* allocate path buffer */
- path = (char*) HDmalloc(HDstrlen(group_name) + HDstrlen(name) + 2);
-
- /* initialize path */
- HDstrcpy( path, group_name );
- if(HDstrcmp(group_name, "/") != 0)
- HDstrcat( path, "/" );
- HDstrcat(path, name);
-
- /* disable error reporting */
- H5E_BEGIN_TRY {
- /* get info */
- H5Gget_objinfo( loc_id, path, FALSE, &statbuf);
- } H5E_END_TRY;
- objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long)));
-
- /* add to array */
- if(info) {
- info[*idx].name = (char *)HDstrdup(path);
- info[*idx].type = type;
- (*idx)++;
+ unsigned int i;
+
+ for(i = 0; i < table->nobjs; i++) {
+ /* Check for object name having full path (with leading '/') */
+ if(HDstrcmp(name, table->objs[i].name) == 0)
+ return(i);
+
+ /* Check for object name without leading '/' */
+ if(HDstrcmp(name, table->objs[i].name + 1) == 0)
+ return(i);
+
+ /* search also in the list of links */
+ if(table->objs[i].nlinks) {
+ unsigned int j;
+
+ for ( j=0; j<table->objs[i].nlinks; j++) {
+ /* Check for object name having full path (with leading '/') */
+ if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0)
+ return(i);
+
+ /* Check for object name without leading '/' */
+ if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0)
+ return(i);
+ } /* end for */
} /* end if */
+ } /* end for */
- switch(type) {
- /*-------------------------------------------------------------------------
- * H5G_GROUP
- *-------------------------------------------------------------------------
- */
- case H5G_GROUP:
- /* increment */
- inserted_objs++;
-
- /* nlink is number of hard links to object */
- if(statbuf.nlink > 0 && trav_table_search(objno, table) == -1) {
- /* add object to table */
- trav_table_add(objno, path, H5G_GROUP, table);
-
- /* print it */
- if(print)
- printf(" %-10s %s\n", "group", path);
-
- /* recurse with the absolute name */
- inserted_objs += traverse(loc_id, path, table, info, idx, print);
- } /* end if */
-
- /* search table group with more than one link to it */
- if(statbuf.nlink > 1) {
- if((j = trav_table_search(objno, table)) < 0)
- return -1;
-
- trav_table_addlink(table, j, path);
-
- if(table->objs[j].displayed == 0) {
- table->objs[j].displayed = 1;
- }
- else {
- /* print it */
- if (print)
- printf(" %-10s %s %s %s\n", "group", path, "->", table->objs[j].name );
- }
- } /* end if */
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_DATASET
- *-------------------------------------------------------------------------
- */
- case H5G_DATASET:
- /* increment */
- inserted_objs++;
-
- /* nlink is number of hard links to object */
- if(statbuf.nlink > 0 && trav_table_search(objno, table) == -1) {
- /* add object to table */
- trav_table_add(objno, path, H5G_DATASET, table );
-
- /* print it */
- if(print)
- printf(" %-10s %s\n", "dataset", path );
- } /* end if */
-
- /* search table dataset with more than one link to it */
- if(statbuf.nlink > 1) {
- if((j = trav_table_search(objno, table)) < 0)
- return -1;
-
- trav_table_addlink(table, j, path);
-
- if(table->objs[j].displayed == 0) {
- table->objs[j].displayed = 1;
- }
- else {
- /* print it */
- if(print)
- printf(" %-10s %s %s %s\n", "dataset", path, "->", table->objs[j].name);
- } /* displayed==1 */
- } /* nlink>1 */
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_TYPE
- *-------------------------------------------------------------------------
- */
-
- case H5G_TYPE:
- /* increment */
- inserted_objs++;
-
- /* nlink is number of hard links to object */
- if(statbuf.nlink > 0 && trav_table_search(objno, table) == -1) {
- /* add object to table */
- trav_table_add(objno, path, H5G_TYPE, table);
-
- /* print it */
- if(print)
- printf(" %-10s %s\n", "datatype", path );
- } /* end if */
- break;
-
-
- /*-------------------------------------------------------------------------
- * H5G_LINK
- *-------------------------------------------------------------------------
- */
-
- case H5G_LINK:
- /* increment */
- inserted_objs++;
-
- /* add object to table */
- trav_table_add(HADDR_UNDEF, path, H5G_LINK, table);
-
- if(statbuf.linklen > 0) {
- char *targbuf;
-
- targbuf = HDmalloc(statbuf.linklen);
- assert(targbuf);
- H5Lget_val(loc_id, path, targbuf, statbuf.linklen, H5P_DEFAULT);
- if(print)
- printf(" %-10s %s -> %s\n", "link", path, targbuf);
- free(targbuf);
- }
- else {
- if(print)
- printf(" %-10s %s ->\n", "link", path);
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_UDLINK
- *-------------------------------------------------------------------------
- */
-
- case H5G_UDLINK:
- {
- H5L_info_t linkbuf;
-
- /* increment */
- inserted_objs++;
-
- /* add object to table */
- trav_table_add(HADDR_UNDEF, path, H5G_UDLINK, table);
-
- /* Get type of link */
- H5E_BEGIN_TRY {
- /* get link class info */
- H5Lget_info(loc_id, path, &linkbuf, H5P_DEFAULT);
- } H5E_END_TRY;
-
- if(linkbuf.type == H5L_TYPE_EXTERNAL) {
- if(statbuf.linklen > 0) {
- char *targbuf;
- const char *filename;
- const char *objname;
-
- targbuf = HDmalloc(statbuf.linklen);
- assert(targbuf);
- H5Lget_val(loc_id, path, targbuf, statbuf.linklen, H5P_DEFAULT);
- H5Lunpack_elink_val(targbuf, statbuf.linklen, NULL, &filename, &objname);
- if(print)
- printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
- free(targbuf);
- } /* end if */
- else {
- if(print)
- printf(" %-10s %s ->\n", "udlink", path);
- } /* end else */
- } /* end if */
- else { /* Unknown user-defined type */
- if(print)
- printf(" %-10s %s ->\n", "UD link type", path);
- } /* end else */
- }
- break;
-
-
- default:
- HDfprintf(stderr, "traverse: Unknown object %d!\n", type);
- return(-1);
- break;
- } /* end switch */
-
- if(name)
- HDfree(name);
- if(path)
- HDfree(path);
- } /* i */
-
- return inserted_objs;
+ return -1;
}
/*-------------------------------------------------------------------------
@@ -687,15 +605,15 @@ static int traverse(hid_t loc_id,
*-------------------------------------------------------------------------
*/
-int trav_table_search(haddr_t objno, trav_table_t *table )
+static size_t
+trav_table_search(const trav_table_t *table, haddr_t objno)
{
- unsigned int i;
+ size_t i;
- for (i = 0; i < table->nobjs; i++)
- if (table->objs[i].objno == objno)
- return i;
-
- return -1;
+ for(i = 0; i < table->nobjs; i++)
+ if(table->objs[i].objno == objno)
+ return(i);
+ return(i);
}
@@ -713,41 +631,66 @@ int trav_table_search(haddr_t objno, trav_table_t *table )
*-------------------------------------------------------------------------
*/
-void trav_table_add(haddr_t objno,
- char *name,
- H5G_obj_t type,
- trav_table_t *table)
+static void
+trav_table_add(trav_table_t *table,
+ const char *path,
+ const H5O_info_t *oinfo)
{
- unsigned int i;
-
- if (table->nobjs == table->size) {
- table->size *= 2;
- table->objs =
- (trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
-
- for (i = table->nobjs; i < table->size; i++) {
- table->objs[i].objno = 0;
- table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
- table->objs[i].displayed = 0;
- table->objs[i].type = H5G_UNKNOWN;
- table->objs[i].name = NULL;
- table->objs[i].links = NULL;
- table->objs[i].nlinks = 0;
- table->objs[i].sizelinks = 0;
- }
- }
-
- i = table->nobjs++;
- table->objs[i].objno = objno;
- table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
- HDfree(table->objs[i].name);
- table->objs[i].name = (char *)HDstrdup(name);
- table->objs[i].type = type;
- table->objs[i].links = NULL;
- table->objs[i].nlinks = 0;
+ size_t new;
+
+ if(table->nobjs == table->size) {
+ table->size = MAX(1, table->size * 2);
+ table->objs = (trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
+ } /* end if */
+
+ new = table->nobjs++;
+ table->objs[new].objno = oinfo ? oinfo->addr : HADDR_UNDEF;
+ table->objs[new].flags[0] = table->objs[new].flags[1] = 0;
+ table->objs[new].name = (char *)HDstrdup(path);
+ table->objs[new].type = oinfo ? (H5G_obj_t)oinfo->type : H5G_LINK;
+ table->objs[new].nlinks = 0;
+ table->objs[new].sizelinks = 0;
+ table->objs[new].links = NULL;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: trav_table_addlink
+ *
+ * Purpose: Add a hardlink name to the object
+ *
+ * Return: void
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: December 17, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static void
+trav_table_addlink(trav_table_t *table,
+ size_t j /* the object index */,
+ const char *path)
+{
+ size_t new;
+
+ /* already inserted */
+ if(HDstrcmp(table->objs[j].name, path) == 0)
+ return;
+
+ /* allocate space if necessary */
+ if(table->objs[j].nlinks == (unsigned)table->objs[j].sizelinks) {
+ table->objs[j].sizelinks = MAX(1, table->objs[j].sizelinks * 2);
+ table->objs[j].links = (trav_link_t*)HDrealloc(table->objs[j].links, table->objs[j].sizelinks * sizeof(trav_link_t));
+ } /* end if */
+
+ /* insert it */
+ new = table->objs[j].nlinks++;
+ table->objs[j].links[new].new_name = (char *)HDstrdup(path);
}
+
/*-------------------------------------------------------------------------
* Function: trav_table_addflags
*
@@ -767,34 +710,22 @@ void trav_table_addflags(unsigned *flags,
H5G_obj_t type,
trav_table_t *table)
{
- unsigned int i;
-
- if (table->nobjs == table->size) {
- table->size *= 2;
- table->objs =
- (trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
-
- for (i = table->nobjs; i < table->size; i++) {
- table->objs[i].objno = 0;
- table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
- table->objs[i].displayed = 0;
- table->objs[i].type = H5G_UNKNOWN;
- table->objs[i].name = NULL;
- table->objs[i].links = NULL;
- table->objs[i].nlinks = 0;
- table->objs[i].sizelinks = 0;
- }
- }
-
- i = table->nobjs++;
- table->objs[i].objno = 0;
- table->objs[i].flags[0] = flags[0];
- table->objs[i].flags[1] = flags[1];
- HDfree(table->objs[i].name);
- table->objs[i].name = (char *)HDstrdup(name);
- table->objs[i].type = type;
- table->objs[i].links = NULL;
- table->objs[i].nlinks = 0;
+ unsigned int new;
+
+ if(table->nobjs == table->size) {
+ table->size = MAX(1, table->size * 2);
+ table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
+ }
+
+ new = table->nobjs++;
+ table->objs[new].objno = 0;
+ table->objs[new].flags[0] = flags[0];
+ table->objs[new].flags[1] = flags[1];
+ table->objs[new].name = (char *)HDstrdup(name);
+ table->objs[new].type = type;
+ table->objs[new].nlinks = 0;
+ table->objs[new].sizelinks = 0;
+ table->objs[new].links = NULL;
}
@@ -812,28 +743,15 @@ void trav_table_addflags(unsigned *flags,
*-------------------------------------------------------------------------
*/
-void trav_table_init( trav_table_t **tbl )
+void trav_table_init(trav_table_t **tbl)
{
- unsigned int i;
- trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t));
-
- table->size = 20;
- table->nobjs = 0;
- table->objs =
- (trav_obj_t*)HDmalloc(table->size * sizeof(trav_obj_t));
-
- for (i = 0; i < table->size; i++) {
- table->objs[i].objno = 0;
- table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
- table->objs[i].displayed = 0;
- table->objs[i].type = H5G_UNKNOWN;
- table->objs[i].name = NULL;
- table->objs[i].links = NULL;
- table->objs[i].nlinks = 0;
- table->objs[i].sizelinks = 0;
- }
-
- *tbl = table;
+ trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t));
+
+ table->size = 0;
+ table->nobjs = 0;
+ table->objs = NULL;
+
+ *tbl = table;
}
@@ -854,60 +772,193 @@ void trav_table_init( trav_table_t **tbl )
void trav_table_free( trav_table_t *table )
{
- unsigned int i, j;
-
- for ( i = 0; i < table->nobjs; i++)
- {
- HDfree( table->objs[i].name );
- if (table->objs[i].nlinks)
- {
- for ( j=0; j<table->objs[i].nlinks; j++)
- HDfree( table->objs[i].links[j].new_name );
-
- HDfree(table->objs[i].links);
- }
- }
- HDfree(table->objs);
- HDfree(table);
-
+ if(table->objs) {
+ unsigned int i;
+
+ for(i = 0; i < table->nobjs; i++) {
+ HDfree(table->objs[i].name );
+ if(table->objs[i].nlinks) {
+ unsigned int j;
+
+ for(j = 0; j < table->objs[i].nlinks; j++)
+ HDfree(table->objs[i].links[j].new_name);
+
+ HDfree(table->objs[i].links);
+ } /* end if */
+ } /* end for */
+ HDfree(table->objs);
+ } /* end if */
+ HDfree(table);
}
+
+/*-------------------------------------------------------------------------
+ * Function: trav_print_visit_obj
+ *
+ * Purpose: Callback for visiting object, when printing info
+ *
+ * Return: 0 on success, -1 on failure
+ *
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ *
+ * Date: September 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
+ hbool_t already_visited, void *udata)
+{
+ trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
+
+ /* Print the name of the object */
+ /* (no new-line, so that objects that we've encountered before can print
+ * the name of the original object)
+ */
+ switch(oinfo->type) {
+ case H5O_TYPE_GROUP:
+ printf(" %-10s %s", "group", path);
+ break;
+
+ case H5O_TYPE_DATASET:
+ printf(" %-10s %s", "dataset", path);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ printf(" %-10s %s", "datatype", path);
+ break;
+
+ default:
+ printf(" %-10s %s", "unknown object type", path);
+ break;
+ } /* end switch */
+
+ /* Check if we've already seen this object */
+ if(!already_visited) {
+ /* Finish printing line about object */
+ printf("\n");
+
+ /* Check if we will encounter another hard link to this object */
+ if(oinfo->rc > 1) {
+ /* Add object to table */
+ trav_table_add(print_udata->table, path, oinfo);
+ } /* end if */
+ } /* end if */
+ else {
+ size_t found; /* Index of original object seen */
+
+ /* Locate object in table */
+ found = trav_table_search(print_udata->table, oinfo->addr);
+ HDassert(found < print_udata->table->nobjs);
+
+ /* Print the link's destination */
+ printf(" -> %s\n", print_udata->table->objs[found].name);
+ } /* end else */
+ return(0);
+} /* end trav_print_visit_obj() */
+
+
/*-------------------------------------------------------------------------
- * Function: trav_table_addlink
+ * Function: trav_print_visit_lnk
*
- * Purpose: Add a hardlink name to the object
+ * Purpose: Callback for visiting link, when printing info
*
- * Return: void
+ * Return: 0 on success, -1 on failure
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
*
- * Date: December 17, 2003
+ * Date: September 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
+{
+ trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
+
+ /* Print appropriate information for the type of link */
+ switch(linfo->type) {
+ case H5L_TYPE_SOFT:
+ if(linfo->u.val_size > 0) {
+ char *targbuf = HDmalloc(linfo->u.val_size + 1);
+ HDassert(targbuf);
+
+ H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT);
+ printf(" %-10s %s -> %s\n", "link", path, targbuf);
+ free(targbuf);
+ } /* end if */
+ else
+ printf(" %-10s %s ->\n", "link", path);
+ break;
+
+ case H5L_TYPE_EXTERNAL:
+ if(linfo->u.val_size > 0) {
+ char *targbuf;
+ const char *filename;
+ const char *objname;
+
+ targbuf = HDmalloc(linfo->u.val_size + 1);
+ assert(targbuf);
+
+ H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT);
+ H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname);
+ printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
+ free(targbuf);
+ } /* end if */
+ else
+ printf(" %-10s %s ->\n", "ext link", path);
+ break;
+
+ default:
+ printf(" %-10s %s -> ???\n", "unknown type of UD link", path);
+ break;
+ } /* end switch() */
+
+ return(0);
+} /* end trav_print_visit_lnk() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5trav_print
+ *
+ * Purpose: Print information about the objects & links in the file
+ *
+ * Return: 0, -1 on error
+ *
+ * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ *
+ * Date: September 6, 2007
*
*-------------------------------------------------------------------------
*/
-void trav_table_addlink(trav_table_t *table,
- int j /* the object index */,
- char *path )
+int
+h5trav_print(hid_t fid)
{
- unsigned int k;
-
- /* already inserted */
- if (strcmp(table->objs[j].name,path)==0)
- return;
-
- /* allocate space if necessary */
- if (table->objs[j].nlinks == (unsigned)table->objs[j].sizelinks) {
- table->objs[j].sizelinks += 2;
- table->objs[j].links =
- (trav_link_t*)HDrealloc(table->objs[j].links,
- table->objs[j].sizelinks * sizeof(trav_link_t));
- }
-
- /* insert it */
- k=table->objs[j].nlinks++;
- table->objs[j].links[k].new_name = (char*)HDstrdup(path);
-}
+ trav_table_t *table = NULL; /* Table for objects w/multiple hard links */
+ trav_print_udata_t print_udata; /* User data for traversal */
+ trav_visitor_t print_visitor; /* Visitor structure for printing objects */
+
+ /* Initialize the table */
+ trav_table_init(&table);
+
+ /* Init user data for printing */
+ print_udata.fid = fid;
+ print_udata.table = table;
+
+ /* Init visitor structure */
+ print_visitor.visit_obj = trav_print_visit_obj;
+ print_visitor.visit_lnk = trav_print_visit_lnk;
+ print_visitor.udata = &print_udata;
+ /* Traverse all objects in the file, visiting each object & link */
+ if(traverse(fid, &print_visitor) < 0)
+ return -1;
+
+ /* Free table */
+ trav_table_free(table);
+
+ return 0;
+}
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index c11d835..4218013 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -32,9 +32,15 @@
typedef H5G_obj_t H5G_obj_t1;
-typedef struct trav_info_t {
- char *name;
+typedef struct trav_path_t {
+ char *path;
H5G_obj_t type;
+} trav_path_t;
+
+typedef struct trav_info_t {
+ size_t nalloc;
+ size_t nused;
+ trav_path_t *paths;
} trav_info_t;
@@ -56,11 +62,10 @@ typedef struct trav_obj_t {
haddr_t objno; /* object number from H5Gget_objinfo */
unsigned flags[2]; /* h5diff.object is present or not in both files*/
char *name; /* name */
- int displayed; /* hard link already traversed once */
H5G_obj_t type; /* type of object */
trav_link_t *links; /* array of possible link names */
- int sizelinks; /* size of links array */
- unsigned nlinks; /* number of links */
+ size_t sizelinks; /* size of links array */
+ size_t nlinks; /* number of links */
} trav_obj_t;
@@ -70,8 +75,8 @@ typedef struct trav_obj_t {
*/
typedef struct trav_table_t {
- unsigned size;
- unsigned nobjs;
+ size_t size;
+ size_t nobjs;
trav_obj_t *objs;
} trav_table_t;
@@ -89,25 +94,37 @@ extern "C" {
* "h5trav info" public functions
*-------------------------------------------------------------------------
*/
-int h5trav_getinfo( hid_t fid, trav_info_t *info, int print );
-int h5trav_getindex( const char *obj, int nobjs, trav_info_t *info );
-void h5trav_freeinfo( trav_info_t *info, int nobjs );
-void h5trav_printinfo(int nobjs, trav_info_t *info);
+int h5trav_getinfo(hid_t file_id, trav_info_t *info);
+ssize_t h5trav_getindex(const trav_info_t *info, const char *obj);
/*-------------------------------------------------------------------------
* "h5trav table" public functions
*-------------------------------------------------------------------------
*/
-int h5trav_getindext(const char *obj,trav_table_t *travt);
int h5trav_gettable(hid_t fid, trav_table_t *travt);
-void h5trav_printtable(trav_table_t *table);
+int h5trav_getindext(const char *obj, const trav_table_t *travt);
+
+/*-------------------------------------------------------------------------
+ * "h5trav print" public functions
+ *-------------------------------------------------------------------------
+ */
+int h5trav_print(hid_t fid);
#ifdef __cplusplus
}
#endif
/*-------------------------------------------------------------------------
+ * info private functions
+ *-------------------------------------------------------------------------
+ */
+
+void trav_info_init(trav_info_t **info);
+
+void trav_info_free(trav_info_t *info);
+
+/*-------------------------------------------------------------------------
* table private functions
*-------------------------------------------------------------------------
*/
@@ -116,25 +133,11 @@ void trav_table_init(trav_table_t **table);
void trav_table_free(trav_table_t *table);
-int trav_table_search(haddr_t objno,
- trav_table_t *table );
-
-void trav_table_add(haddr_t objno,
- char *objname,
- H5G_obj_t type,
- trav_table_t *table);
-
void trav_table_addflags(unsigned *flags,
char *objname,
H5G_obj_t type,
trav_table_t *table);
-
-void trav_table_addlink(trav_table_t *table,
- int j /* the object index */,
- char *path );
-
-
#endif /* H5TRAV_H__ */
diff --git a/tools/testfiles/h5diff_100.txt b/tools/testfiles/h5diff_100.txt
index a2186a7..5cf8868 100644
--- a/tools/testfiles/h5diff_100.txt
+++ b/tools/testfiles/h5diff_100.txt
@@ -4,8 +4,11 @@ Expected output for 'h5diff h5diff_hyper1.h5 h5diff_hyper2.h5 -v'
file1 file2
---------------------------------------
+ x x /
x x /big
+group : </> and </>
+0 differences found
dataset: </big> and </big>
size: [1073741824] [1073741824]
position big big difference
@@ -1035,5 +1038,3 @@ position big big difference
[ 268436478 ] 31 0 31
[ 268436479 ] 31 0 31
1024 differences found
-group : </> and </>
-0 differences found
diff --git a/tools/testfiles/h5diff_17.txt b/tools/testfiles/h5diff_17.txt
index f7fff96..ec787b8 100644
--- a/tools/testfiles/h5diff_17.txt
+++ b/tools/testfiles/h5diff_17.txt
@@ -4,6 +4,7 @@ Expected output for 'h5diff h5diff_basic1.h5 h5diff_basic2.h5 -v'
file1 file2
---------------------------------------
+ x x /
x x /g1
x /g1/d1
x /g1/d2
@@ -23,6 +24,8 @@ file1 file2
x /g1/fp2
x /g2
+group : </> and </>
+0 differences found
group : </g1> and </g1>
0 differences found
dataset: </g1/dset1> and </g1/dset1>
@@ -35,5 +38,3 @@ position dset1 dset1 difference
[ 1 1 ] 1 1.001 0.001
[ 2 1 ] 0 1 1
5 differences found
-group : </> and </>
-0 differences found
diff --git a/tools/testfiles/h5diff_70.txt b/tools/testfiles/h5diff_70.txt
index 3e7e37c..db01d50 100644
--- a/tools/testfiles/h5diff_70.txt
+++ b/tools/testfiles/h5diff_70.txt
@@ -4,63 +4,62 @@ Expected output for 'h5diff h5diff_attr1.h5 h5diff_attr2.h5 -v'
file1 file2
---------------------------------------
+ x x /
x x /dset
x x /g1
-dataset: </dset> and </dset>
-</dset> or </dset> are empty datasets
-attribute: <string of </dset>> and <string of </dset>>
+group : </> and </>
+0 differences found
+attribute: <string of </>> and <string of </>>
size: [2] [2]
-position string of </dset> string of </dset> difference
+position string of </> string of </> difference
------------------------------------------------------------
[ 0 ] a z
[ 0 ] b z
[ 1 ] d z
[ 1 ] e z
4 differences found
-attribute: <bitfield of </dset>> and <bitfield of </dset>>
+attribute: <bitfield of </>> and <bitfield of </>>
size: [2] [2]
-position bitfield of </dset> bitfield of </dset> difference
+position bitfield of </> bitfield of </> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <opaque of </dset>> and <opaque of </dset>>
+attribute: <opaque of </>> and <opaque of </>>
size: [2] [2]
-position opaque of </dset> opaque of </dset> difference
+position opaque of </> opaque of </> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <compound of </dset>> and <compound of </dset>>
+attribute: <compound of </>> and <compound of </>>
size: [2] [2]
-position compound of </dset> compound of </dset> difference
+position compound of </> compound of </> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 0 ] 2 0 2
[ 1 ] 3 0 3
[ 1 ] 4 0 4
4 differences found
-attribute: <reference of </dset>> and <reference of </dset>>
-0 differences found
-attribute: <enum of </dset>> and <enum of </dset>>
+attribute: <enum of </>> and <enum of </>>
size: [2] [2]
-position enum of </dset> enum of </dset> difference
+position enum of </> enum of </> difference
------------------------------------------------------------
[ 0 ] RED GREEN
[ 1 ] RED GREEN
2 differences found
-attribute: <vlen of </dset>> and <vlen of </dset>>
+attribute: <vlen of </>> and <vlen of </>>
size: [2] [2]
-position vlen of </dset> vlen of </dset> difference
+position vlen of </> vlen of </> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
[ 1 ] 3 0 3
3 differences found
-attribute: <array of </dset>> and <array of </dset>>
+attribute: <array of </>> and <array of </>>
size: [2] [2]
-position array of </dset> array of </dset> difference
+position array of </> array of </> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 0 ] 2 0 2
@@ -69,23 +68,23 @@ position array of </dset> array of </dset> difference
[ 1 ] 5 0 5
[ 1 ] 6 0 6
6 differences found
-attribute: <integer of </dset>> and <integer of </dset>>
+attribute: <integer of </>> and <integer of </>>
size: [2] [2]
-position integer of </dset> integer of </dset> difference
+position integer of </> integer of </> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <float of </dset>> and <float of </dset>>
+attribute: <float of </>> and <float of </>>
size: [2] [2]
-position float of </dset> float of </dset> difference
+position float of </> float of </> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <string2D of </dset>> and <string2D of </dset>>
+attribute: <string2D of </>> and <string2D of </>>
size: [3x2] [3x2]
-position string2D of </dset> string2D of </dset> difference
+position string2D of </> string2D of </> difference
------------------------------------------------------------
[ 0 0 ] a z
[ 0 0 ] b z
@@ -100,9 +99,9 @@ position string2D of </dset> string2D of </dset> difference
[ 2 1 ] k z
[ 2 1 ] l z
12 differences found
-attribute: <bitfield2D of </dset>> and <bitfield2D of </dset>>
+attribute: <bitfield2D of </>> and <bitfield2D of </>>
size: [3x2] [3x2]
-position bitfield2D of </dset> bitfield2D of </dset> difference
+position bitfield2D of </> bitfield2D of </> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -111,9 +110,9 @@ position bitfield2D of </dset> bitfield2D of </dset> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <opaque2D of </dset>> and <opaque2D of </dset>>
+attribute: <opaque2D of </>> and <opaque2D of </>>
size: [3x2] [3x2]
-position opaque2D of </dset> opaque2D of </dset> difference
+position opaque2D of </> opaque2D of </> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -122,9 +121,9 @@ position opaque2D of </dset> opaque2D of </dset> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <compound2D of </dset>> and <compound2D of </dset>>
+attribute: <compound2D of </>> and <compound2D of </>>
size: [3x2] [3x2]
-position compound2D of </dset> compound2D of </dset> difference
+position compound2D of </> compound2D of </> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 0 ] 2 0 2
@@ -139,11 +138,9 @@ position compound2D of </dset> compound2D of </dset> difference
[ 2 1 ] 11 0 11
[ 2 1 ] 12 0 12
12 differences found
-attribute: <reference2D of </dset>> and <reference2D of </dset>>
-0 differences found
-attribute: <enum2D of </dset>> and <enum2D of </dset>>
+attribute: <enum2D of </>> and <enum2D of </>>
size: [3x2] [3x2]
-position enum2D of </dset> enum2D of </dset> difference
+position enum2D of </> enum2D of </> difference
------------------------------------------------------------
[ 0 0 ] RED GREEN
[ 0 1 ] RED GREEN
@@ -152,9 +149,9 @@ position enum2D of </dset> enum2D of </dset> difference
[ 2 0 ] RED GREEN
[ 2 1 ] RED GREEN
6 differences found
-attribute: <vlen2D of </dset>> and <vlen2D of </dset>>
+attribute: <vlen2D of </>> and <vlen2D of </>>
size: [3x2] [3x2]
-position vlen2D of </dset> vlen2D of </dset> difference
+position vlen2D of </> vlen2D of </> difference
------------------------------------------------------------
[ 0 1 ] 1 0 1
[ 1 0 ] 2 0 2
@@ -168,9 +165,9 @@ position vlen2D of </dset> vlen2D of </dset> difference
[ 2 1 ] 10 0 10
[ 2 1 ] 11 0 11
11 differences found
-attribute: <array2D of </dset>> and <array2D of </dset>>
+attribute: <array2D of </>> and <array2D of </>>
size: [3x2] [3x2]
-position array2D of </dset> array2D of </dset> difference
+position array2D of </> array2D of </> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 0 ] 2 0 2
@@ -191,9 +188,9 @@ position array2D of </dset> array2D of </dset> difference
[ 2 1 ] 17 0 17
[ 2 1 ] 18 0 18
18 differences found
-attribute: <integer2D of </dset>> and <integer2D of </dset>>
+attribute: <integer2D of </>> and <integer2D of </>>
size: [3x2] [3x2]
-position integer2D of </dset> integer2D of </dset> difference
+position integer2D of </> integer2D of </> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -202,9 +199,9 @@ position integer2D of </dset> integer2D of </dset> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <float2D of </dset>> and <float2D of </dset>>
+attribute: <float2D of </>> and <float2D of </>>
size: [3x2] [3x2]
-position float2D of </dset> float2D of </dset> difference
+position float2D of </> float2D of </> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -213,9 +210,9 @@ position float2D of </dset> float2D of </dset> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <string3D of </dset>> and <string3D of </dset>>
+attribute: <string3D of </>> and <string3D of </>>
size: [4x3x2] [4x3x2]
-position string3D of </dset> string3D of </dset> difference
+position string3D of </> string3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] a z
[ 0 0 0 ] b z
@@ -265,9 +262,9 @@ position string3D of </dset> string3D of </dset> difference
[ 3 2 1 ] X z
[ 3 2 1 ] Z z
47 differences found
-attribute: <bitfield3D of </dset>> and <bitfield3D of </dset>>
+attribute: <bitfield3D of </>> and <bitfield3D of </>>
size: [4x3x2] [4x3x2]
-position bitfield3D of </dset> bitfield3D of </dset> difference
+position bitfield3D of </> bitfield3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -294,9 +291,9 @@ position bitfield3D of </dset> bitfield3D of </dset> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <opaque3D of </dset>> and <opaque3D of </dset>>
+attribute: <opaque3D of </>> and <opaque3D of </>>
size: [4x3x2] [4x3x2]
-position opaque3D of </dset> opaque3D of </dset> difference
+position opaque3D of </> opaque3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -323,9 +320,9 @@ position opaque3D of </dset> opaque3D of </dset> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <compound3D of </dset>> and <compound3D of </dset>>
+attribute: <compound3D of </>> and <compound3D of </>>
size: [4x3x2] [4x3x2]
-position compound3D of </dset> compound3D of </dset> difference
+position compound3D of </> compound3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 0 ] 2 0 2
@@ -376,11 +373,9 @@ position compound3D of </dset> compound3D of </dset> difference
[ 3 2 1 ] 47 0 47
[ 3 2 1 ] 48 0 48
48 differences found
-attribute: <reference3D of </dset>> and <reference3D of </dset>>
-0 differences found
-attribute: <enum3D of </dset>> and <enum3D of </dset>>
+attribute: <enum3D of </>> and <enum3D of </>>
size: [4x3x2] [4x3x2]
-position enum3D of </dset> enum3D of </dset> difference
+position enum3D of </> enum3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] GREEN RED
[ 0 0 1 ] GREEN RED
@@ -407,9 +402,9 @@ position enum3D of </dset> enum3D of </dset> difference
[ 3 2 0 ] GREEN RED
[ 3 2 1 ] GREEN RED
24 differences found
-attribute: <vlen3D of </dset>> and <vlen3D of </dset>>
+attribute: <vlen3D of </>> and <vlen3D of </>>
size: [4x3x2] [4x3x2]
-position vlen3D of </dset> vlen3D of </dset> difference
+position vlen3D of </> vlen3D of </> difference
------------------------------------------------------------
[ 0 0 1 ] 1 0 1
[ 0 1 0 ] 2 0 2
@@ -471,9 +466,9 @@ position vlen3D of </dset> vlen3D of </dset> difference
[ 3 2 1 ] 58 0 58
[ 3 2 1 ] 59 0 59
59 differences found
-attribute: <array3D of </dset>> and <array3D of </dset>>
+attribute: <array3D of </>> and <array3D of </>>
size: [4x3x2] [4x3x2]
-position array3D of </dset> array3D of </dset> difference
+position array3D of </> array3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 0 ] 2 0 2
@@ -548,9 +543,9 @@ position array3D of </dset> array3D of </dset> difference
[ 3 2 1 ] 71 0 71
[ 3 2 1 ] 72 0 72
72 differences found
-attribute: <integer3D of </dset>> and <integer3D of </dset>>
+attribute: <integer3D of </>> and <integer3D of </>>
size: [4x3x2] [4x3x2]
-position integer3D of </dset> integer3D of </dset> difference
+position integer3D of </> integer3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -577,9 +572,9 @@ position integer3D of </dset> integer3D of </dset> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <float3D of </dset>> and <float3D of </dset>>
+attribute: <float3D of </>> and <float3D of </>>
size: [4x3x2] [4x3x2]
-position float3D of </dset> float3D of </dset> difference
+position float3D of </> float3D of </> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -606,59 +601,60 @@ position float3D of </dset> float3D of </dset> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-456 differences found
-group : </g1> and </g1>
-0 differences found
-attribute: <string of </g1>> and <string of </g1>>
+dataset: </dset> and </dset>
+</dset> or </dset> are empty datasets
+attribute: <string of </dset>> and <string of </dset>>
size: [2] [2]
-position string of </g1> string of </g1> difference
+position string of </dset> string of </dset> difference
------------------------------------------------------------
[ 0 ] a z
[ 0 ] b z
[ 1 ] d z
[ 1 ] e z
4 differences found
-attribute: <bitfield of </g1>> and <bitfield of </g1>>
+attribute: <bitfield of </dset>> and <bitfield of </dset>>
size: [2] [2]
-position bitfield of </g1> bitfield of </g1> difference
+position bitfield of </dset> bitfield of </dset> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <opaque of </g1>> and <opaque of </g1>>
+attribute: <opaque of </dset>> and <opaque of </dset>>
size: [2] [2]
-position opaque of </g1> opaque of </g1> difference
+position opaque of </dset> opaque of </dset> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <compound of </g1>> and <compound of </g1>>
+attribute: <compound of </dset>> and <compound of </dset>>
size: [2] [2]
-position compound of </g1> compound of </g1> difference
+position compound of </dset> compound of </dset> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 0 ] 2 0 2
[ 1 ] 3 0 3
[ 1 ] 4 0 4
4 differences found
-attribute: <enum of </g1>> and <enum of </g1>>
+attribute: <reference of </dset>> and <reference of </dset>>
+0 differences found
+attribute: <enum of </dset>> and <enum of </dset>>
size: [2] [2]
-position enum of </g1> enum of </g1> difference
+position enum of </dset> enum of </dset> difference
------------------------------------------------------------
[ 0 ] RED GREEN
[ 1 ] RED GREEN
2 differences found
-attribute: <vlen of </g1>> and <vlen of </g1>>
+attribute: <vlen of </dset>> and <vlen of </dset>>
size: [2] [2]
-position vlen of </g1> vlen of </g1> difference
+position vlen of </dset> vlen of </dset> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
[ 1 ] 3 0 3
3 differences found
-attribute: <array of </g1>> and <array of </g1>>
+attribute: <array of </dset>> and <array of </dset>>
size: [2] [2]
-position array of </g1> array of </g1> difference
+position array of </dset> array of </dset> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 0 ] 2 0 2
@@ -667,23 +663,23 @@ position array of </g1> array of </g1> difference
[ 1 ] 5 0 5
[ 1 ] 6 0 6
6 differences found
-attribute: <integer of </g1>> and <integer of </g1>>
+attribute: <integer of </dset>> and <integer of </dset>>
size: [2] [2]
-position integer of </g1> integer of </g1> difference
+position integer of </dset> integer of </dset> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <float of </g1>> and <float of </g1>>
+attribute: <float of </dset>> and <float of </dset>>
size: [2] [2]
-position float of </g1> float of </g1> difference
+position float of </dset> float of </dset> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <string2D of </g1>> and <string2D of </g1>>
+attribute: <string2D of </dset>> and <string2D of </dset>>
size: [3x2] [3x2]
-position string2D of </g1> string2D of </g1> difference
+position string2D of </dset> string2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] a z
[ 0 0 ] b z
@@ -698,9 +694,9 @@ position string2D of </g1> string2D of </g1> difference
[ 2 1 ] k z
[ 2 1 ] l z
12 differences found
-attribute: <bitfield2D of </g1>> and <bitfield2D of </g1>>
+attribute: <bitfield2D of </dset>> and <bitfield2D of </dset>>
size: [3x2] [3x2]
-position bitfield2D of </g1> bitfield2D of </g1> difference
+position bitfield2D of </dset> bitfield2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -709,9 +705,9 @@ position bitfield2D of </g1> bitfield2D of </g1> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <opaque2D of </g1>> and <opaque2D of </g1>>
+attribute: <opaque2D of </dset>> and <opaque2D of </dset>>
size: [3x2] [3x2]
-position opaque2D of </g1> opaque2D of </g1> difference
+position opaque2D of </dset> opaque2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -720,9 +716,9 @@ position opaque2D of </g1> opaque2D of </g1> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <compound2D of </g1>> and <compound2D of </g1>>
+attribute: <compound2D of </dset>> and <compound2D of </dset>>
size: [3x2] [3x2]
-position compound2D of </g1> compound2D of </g1> difference
+position compound2D of </dset> compound2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 0 ] 2 0 2
@@ -737,9 +733,11 @@ position compound2D of </g1> compound2D of </g1> difference
[ 2 1 ] 11 0 11
[ 2 1 ] 12 0 12
12 differences found
-attribute: <enum2D of </g1>> and <enum2D of </g1>>
+attribute: <reference2D of </dset>> and <reference2D of </dset>>
+0 differences found
+attribute: <enum2D of </dset>> and <enum2D of </dset>>
size: [3x2] [3x2]
-position enum2D of </g1> enum2D of </g1> difference
+position enum2D of </dset> enum2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] RED GREEN
[ 0 1 ] RED GREEN
@@ -748,9 +746,9 @@ position enum2D of </g1> enum2D of </g1> difference
[ 2 0 ] RED GREEN
[ 2 1 ] RED GREEN
6 differences found
-attribute: <vlen2D of </g1>> and <vlen2D of </g1>>
+attribute: <vlen2D of </dset>> and <vlen2D of </dset>>
size: [3x2] [3x2]
-position vlen2D of </g1> vlen2D of </g1> difference
+position vlen2D of </dset> vlen2D of </dset> difference
------------------------------------------------------------
[ 0 1 ] 1 0 1
[ 1 0 ] 2 0 2
@@ -764,9 +762,9 @@ position vlen2D of </g1> vlen2D of </g1> difference
[ 2 1 ] 10 0 10
[ 2 1 ] 11 0 11
11 differences found
-attribute: <array2D of </g1>> and <array2D of </g1>>
+attribute: <array2D of </dset>> and <array2D of </dset>>
size: [3x2] [3x2]
-position array2D of </g1> array2D of </g1> difference
+position array2D of </dset> array2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 0 ] 2 0 2
@@ -787,9 +785,9 @@ position array2D of </g1> array2D of </g1> difference
[ 2 1 ] 17 0 17
[ 2 1 ] 18 0 18
18 differences found
-attribute: <integer2D of </g1>> and <integer2D of </g1>>
+attribute: <integer2D of </dset>> and <integer2D of </dset>>
size: [3x2] [3x2]
-position integer2D of </g1> integer2D of </g1> difference
+position integer2D of </dset> integer2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -798,9 +796,9 @@ position integer2D of </g1> integer2D of </g1> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <float2D of </g1>> and <float2D of </g1>>
+attribute: <float2D of </dset>> and <float2D of </dset>>
size: [3x2] [3x2]
-position float2D of </g1> float2D of </g1> difference
+position float2D of </dset> float2D of </dset> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -809,9 +807,9 @@ position float2D of </g1> float2D of </g1> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <string3D of </g1>> and <string3D of </g1>>
+attribute: <string3D of </dset>> and <string3D of </dset>>
size: [4x3x2] [4x3x2]
-position string3D of </g1> string3D of </g1> difference
+position string3D of </dset> string3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] a z
[ 0 0 0 ] b z
@@ -861,9 +859,9 @@ position string3D of </g1> string3D of </g1> difference
[ 3 2 1 ] X z
[ 3 2 1 ] Z z
47 differences found
-attribute: <bitfield3D of </g1>> and <bitfield3D of </g1>>
+attribute: <bitfield3D of </dset>> and <bitfield3D of </dset>>
size: [4x3x2] [4x3x2]
-position bitfield3D of </g1> bitfield3D of </g1> difference
+position bitfield3D of </dset> bitfield3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -890,9 +888,9 @@ position bitfield3D of </g1> bitfield3D of </g1> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <opaque3D of </g1>> and <opaque3D of </g1>>
+attribute: <opaque3D of </dset>> and <opaque3D of </dset>>
size: [4x3x2] [4x3x2]
-position opaque3D of </g1> opaque3D of </g1> difference
+position opaque3D of </dset> opaque3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -919,9 +917,9 @@ position opaque3D of </g1> opaque3D of </g1> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <compound3D of </g1>> and <compound3D of </g1>>
+attribute: <compound3D of </dset>> and <compound3D of </dset>>
size: [4x3x2] [4x3x2]
-position compound3D of </g1> compound3D of </g1> difference
+position compound3D of </dset> compound3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 0 ] 2 0 2
@@ -972,9 +970,11 @@ position compound3D of </g1> compound3D of </g1> difference
[ 3 2 1 ] 47 0 47
[ 3 2 1 ] 48 0 48
48 differences found
-attribute: <enum3D of </g1>> and <enum3D of </g1>>
+attribute: <reference3D of </dset>> and <reference3D of </dset>>
+0 differences found
+attribute: <enum3D of </dset>> and <enum3D of </dset>>
size: [4x3x2] [4x3x2]
-position enum3D of </g1> enum3D of </g1> difference
+position enum3D of </dset> enum3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] GREEN RED
[ 0 0 1 ] GREEN RED
@@ -1001,9 +1001,9 @@ position enum3D of </g1> enum3D of </g1> difference
[ 3 2 0 ] GREEN RED
[ 3 2 1 ] GREEN RED
24 differences found
-attribute: <vlen3D of </g1>> and <vlen3D of </g1>>
+attribute: <vlen3D of </dset>> and <vlen3D of </dset>>
size: [4x3x2] [4x3x2]
-position vlen3D of </g1> vlen3D of </g1> difference
+position vlen3D of </dset> vlen3D of </dset> difference
------------------------------------------------------------
[ 0 0 1 ] 1 0 1
[ 0 1 0 ] 2 0 2
@@ -1065,9 +1065,9 @@ position vlen3D of </g1> vlen3D of </g1> difference
[ 3 2 1 ] 58 0 58
[ 3 2 1 ] 59 0 59
59 differences found
-attribute: <array3D of </g1>> and <array3D of </g1>>
+attribute: <array3D of </dset>> and <array3D of </dset>>
size: [4x3x2] [4x3x2]
-position array3D of </g1> array3D of </g1> difference
+position array3D of </dset> array3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 0 ] 2 0 2
@@ -1142,9 +1142,9 @@ position array3D of </g1> array3D of </g1> difference
[ 3 2 1 ] 71 0 71
[ 3 2 1 ] 72 0 72
72 differences found
-attribute: <integer3D of </g1>> and <integer3D of </g1>>
+attribute: <integer3D of </dset>> and <integer3D of </dset>>
size: [4x3x2] [4x3x2]
-position integer3D of </g1> integer3D of </g1> difference
+position integer3D of </dset> integer3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -1171,9 +1171,9 @@ position integer3D of </g1> integer3D of </g1> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <float3D of </g1>> and <float3D of </g1>>
+attribute: <float3D of </dset>> and <float3D of </dset>>
size: [4x3x2] [4x3x2]
-position float3D of </g1> float3D of </g1> difference
+position float3D of </dset> float3D of </dset> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -1200,58 +1200,59 @@ position float3D of </g1> float3D of </g1> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-group : </> and </>
+456 differences found
+group : </g1> and </g1>
0 differences found
-attribute: <string of </>> and <string of </>>
+attribute: <string of </g1>> and <string of </g1>>
size: [2] [2]
-position string of </> string of </> difference
+position string of </g1> string of </g1> difference
------------------------------------------------------------
[ 0 ] a z
[ 0 ] b z
[ 1 ] d z
[ 1 ] e z
4 differences found
-attribute: <bitfield of </>> and <bitfield of </>>
+attribute: <bitfield of </g1>> and <bitfield of </g1>>
size: [2] [2]
-position bitfield of </> bitfield of </> difference
+position bitfield of </g1> bitfield of </g1> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <opaque of </>> and <opaque of </>>
+attribute: <opaque of </g1>> and <opaque of </g1>>
size: [2] [2]
-position opaque of </> opaque of </> difference
+position opaque of </g1> opaque of </g1> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <compound of </>> and <compound of </>>
+attribute: <compound of </g1>> and <compound of </g1>>
size: [2] [2]
-position compound of </> compound of </> difference
+position compound of </g1> compound of </g1> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 0 ] 2 0 2
[ 1 ] 3 0 3
[ 1 ] 4 0 4
4 differences found
-attribute: <enum of </>> and <enum of </>>
+attribute: <enum of </g1>> and <enum of </g1>>
size: [2] [2]
-position enum of </> enum of </> difference
+position enum of </g1> enum of </g1> difference
------------------------------------------------------------
[ 0 ] RED GREEN
[ 1 ] RED GREEN
2 differences found
-attribute: <vlen of </>> and <vlen of </>>
+attribute: <vlen of </g1>> and <vlen of </g1>>
size: [2] [2]
-position vlen of </> vlen of </> difference
+position vlen of </g1> vlen of </g1> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
[ 1 ] 3 0 3
3 differences found
-attribute: <array of </>> and <array of </>>
+attribute: <array of </g1>> and <array of </g1>>
size: [2] [2]
-position array of </> array of </> difference
+position array of </g1> array of </g1> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 0 ] 2 0 2
@@ -1260,23 +1261,23 @@ position array of </> array of </> difference
[ 1 ] 5 0 5
[ 1 ] 6 0 6
6 differences found
-attribute: <integer of </>> and <integer of </>>
+attribute: <integer of </g1>> and <integer of </g1>>
size: [2] [2]
-position integer of </> integer of </> difference
+position integer of </g1> integer of </g1> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <float of </>> and <float of </>>
+attribute: <float of </g1>> and <float of </g1>>
size: [2] [2]
-position float of </> float of </> difference
+position float of </g1> float of </g1> difference
------------------------------------------------------------
[ 0 ] 1 0 1
[ 1 ] 2 0 2
2 differences found
-attribute: <string2D of </>> and <string2D of </>>
+attribute: <string2D of </g1>> and <string2D of </g1>>
size: [3x2] [3x2]
-position string2D of </> string2D of </> difference
+position string2D of </g1> string2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] a z
[ 0 0 ] b z
@@ -1291,9 +1292,9 @@ position string2D of </> string2D of </> difference
[ 2 1 ] k z
[ 2 1 ] l z
12 differences found
-attribute: <bitfield2D of </>> and <bitfield2D of </>>
+attribute: <bitfield2D of </g1>> and <bitfield2D of </g1>>
size: [3x2] [3x2]
-position bitfield2D of </> bitfield2D of </> difference
+position bitfield2D of </g1> bitfield2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -1302,9 +1303,9 @@ position bitfield2D of </> bitfield2D of </> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <opaque2D of </>> and <opaque2D of </>>
+attribute: <opaque2D of </g1>> and <opaque2D of </g1>>
size: [3x2] [3x2]
-position opaque2D of </> opaque2D of </> difference
+position opaque2D of </g1> opaque2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -1313,9 +1314,9 @@ position opaque2D of </> opaque2D of </> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <compound2D of </>> and <compound2D of </>>
+attribute: <compound2D of </g1>> and <compound2D of </g1>>
size: [3x2] [3x2]
-position compound2D of </> compound2D of </> difference
+position compound2D of </g1> compound2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 0 ] 2 0 2
@@ -1330,9 +1331,9 @@ position compound2D of </> compound2D of </> difference
[ 2 1 ] 11 0 11
[ 2 1 ] 12 0 12
12 differences found
-attribute: <enum2D of </>> and <enum2D of </>>
+attribute: <enum2D of </g1>> and <enum2D of </g1>>
size: [3x2] [3x2]
-position enum2D of </> enum2D of </> difference
+position enum2D of </g1> enum2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] RED GREEN
[ 0 1 ] RED GREEN
@@ -1341,9 +1342,9 @@ position enum2D of </> enum2D of </> difference
[ 2 0 ] RED GREEN
[ 2 1 ] RED GREEN
6 differences found
-attribute: <vlen2D of </>> and <vlen2D of </>>
+attribute: <vlen2D of </g1>> and <vlen2D of </g1>>
size: [3x2] [3x2]
-position vlen2D of </> vlen2D of </> difference
+position vlen2D of </g1> vlen2D of </g1> difference
------------------------------------------------------------
[ 0 1 ] 1 0 1
[ 1 0 ] 2 0 2
@@ -1357,9 +1358,9 @@ position vlen2D of </> vlen2D of </> difference
[ 2 1 ] 10 0 10
[ 2 1 ] 11 0 11
11 differences found
-attribute: <array2D of </>> and <array2D of </>>
+attribute: <array2D of </g1>> and <array2D of </g1>>
size: [3x2] [3x2]
-position array2D of </> array2D of </> difference
+position array2D of </g1> array2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 0 ] 2 0 2
@@ -1380,9 +1381,9 @@ position array2D of </> array2D of </> difference
[ 2 1 ] 17 0 17
[ 2 1 ] 18 0 18
18 differences found
-attribute: <integer2D of </>> and <integer2D of </>>
+attribute: <integer2D of </g1>> and <integer2D of </g1>>
size: [3x2] [3x2]
-position integer2D of </> integer2D of </> difference
+position integer2D of </g1> integer2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -1391,9 +1392,9 @@ position integer2D of </> integer2D of </> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <float2D of </>> and <float2D of </>>
+attribute: <float2D of </g1>> and <float2D of </g1>>
size: [3x2] [3x2]
-position float2D of </> float2D of </> difference
+position float2D of </g1> float2D of </g1> difference
------------------------------------------------------------
[ 0 0 ] 1 0 1
[ 0 1 ] 2 0 2
@@ -1402,9 +1403,9 @@ position float2D of </> float2D of </> difference
[ 2 0 ] 5 0 5
[ 2 1 ] 6 0 6
6 differences found
-attribute: <string3D of </>> and <string3D of </>>
+attribute: <string3D of </g1>> and <string3D of </g1>>
size: [4x3x2] [4x3x2]
-position string3D of </> string3D of </> difference
+position string3D of </g1> string3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] a z
[ 0 0 0 ] b z
@@ -1454,9 +1455,9 @@ position string3D of </> string3D of </> difference
[ 3 2 1 ] X z
[ 3 2 1 ] Z z
47 differences found
-attribute: <bitfield3D of </>> and <bitfield3D of </>>
+attribute: <bitfield3D of </g1>> and <bitfield3D of </g1>>
size: [4x3x2] [4x3x2]
-position bitfield3D of </> bitfield3D of </> difference
+position bitfield3D of </g1> bitfield3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -1483,9 +1484,9 @@ position bitfield3D of </> bitfield3D of </> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <opaque3D of </>> and <opaque3D of </>>
+attribute: <opaque3D of </g1>> and <opaque3D of </g1>>
size: [4x3x2] [4x3x2]
-position opaque3D of </> opaque3D of </> difference
+position opaque3D of </g1> opaque3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -1512,9 +1513,9 @@ position opaque3D of </> opaque3D of </> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <compound3D of </>> and <compound3D of </>>
+attribute: <compound3D of </g1>> and <compound3D of </g1>>
size: [4x3x2] [4x3x2]
-position compound3D of </> compound3D of </> difference
+position compound3D of </g1> compound3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 0 ] 2 0 2
@@ -1565,9 +1566,9 @@ position compound3D of </> compound3D of </> difference
[ 3 2 1 ] 47 0 47
[ 3 2 1 ] 48 0 48
48 differences found
-attribute: <enum3D of </>> and <enum3D of </>>
+attribute: <enum3D of </g1>> and <enum3D of </g1>>
size: [4x3x2] [4x3x2]
-position enum3D of </> enum3D of </> difference
+position enum3D of </g1> enum3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] GREEN RED
[ 0 0 1 ] GREEN RED
@@ -1594,9 +1595,9 @@ position enum3D of </> enum3D of </> difference
[ 3 2 0 ] GREEN RED
[ 3 2 1 ] GREEN RED
24 differences found
-attribute: <vlen3D of </>> and <vlen3D of </>>
+attribute: <vlen3D of </g1>> and <vlen3D of </g1>>
size: [4x3x2] [4x3x2]
-position vlen3D of </> vlen3D of </> difference
+position vlen3D of </g1> vlen3D of </g1> difference
------------------------------------------------------------
[ 0 0 1 ] 1 0 1
[ 0 1 0 ] 2 0 2
@@ -1658,9 +1659,9 @@ position vlen3D of </> vlen3D of </> difference
[ 3 2 1 ] 58 0 58
[ 3 2 1 ] 59 0 59
59 differences found
-attribute: <array3D of </>> and <array3D of </>>
+attribute: <array3D of </g1>> and <array3D of </g1>>
size: [4x3x2] [4x3x2]
-position array3D of </> array3D of </> difference
+position array3D of </g1> array3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 0 ] 2 0 2
@@ -1735,9 +1736,9 @@ position array3D of </> array3D of </> difference
[ 3 2 1 ] 71 0 71
[ 3 2 1 ] 72 0 72
72 differences found
-attribute: <integer3D of </>> and <integer3D of </>>
+attribute: <integer3D of </g1>> and <integer3D of </g1>>
size: [4x3x2] [4x3x2]
-position integer3D of </> integer3D of </> difference
+position integer3D of </g1> integer3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
@@ -1764,9 +1765,9 @@ position integer3D of </> integer3D of </> difference
[ 3 2 0 ] 23 0 23
[ 3 2 1 ] 24 0 24
24 differences found
-attribute: <float3D of </>> and <float3D of </>>
+attribute: <float3D of </g1>> and <float3D of </g1>>
size: [4x3x2] [4x3x2]
-position float3D of </> float3D of </> difference
+position float3D of </g1> float3D of </g1> difference
------------------------------------------------------------
[ 0 0 0 ] 1 0 1
[ 0 0 1 ] 2 0 2
diff --git a/tools/testfiles/h5diff_80.txt b/tools/testfiles/h5diff_80.txt
index 9e31e88..0093870 100644
--- a/tools/testfiles/h5diff_80.txt
+++ b/tools/testfiles/h5diff_80.txt
@@ -4,6 +4,7 @@ Expected output for 'h5diff h5diff_dset1.h5 h5diff_dset2.h5 -v'
file1 file2
---------------------------------------
+ x x /
x x /dset
x x /dsetref
x x /g1
@@ -39,6 +40,8 @@ file1 file2
x x /g1/vlen3D
x x /refreg
+group : </> and </>
+0 differences found
dataset: </dset> and </dset>
size: [2] [2]
position dset dset difference
@@ -782,8 +785,6 @@ point #1 (2,2) (3,3)
point #3 (1,6) (2,5)
point #4 (2,8) (1,7)
4 differences found
-group : </> and </>
-0 differences found
--------------------------------
Some objects are not comparable
--------------------------------
diff --git a/tools/testfiles/tcontents.ddl b/tools/testfiles/tcontents.ddl
index 905bac5..2bb59b9 100644
--- a/tools/testfiles/tcontents.ddl
+++ b/tools/testfiles/tcontents.ddl
@@ -4,6 +4,7 @@ Expected output for 'h5dump -n tfcontents1.h5'
HDF5 "tfcontents1.h5" {
FILE_CONTENTS {
datatype /#5616
+ group /
dataset /dset
dataset /dset3 -> /dset
dataset /dset4 -> /dset
@@ -17,6 +18,6 @@ FILE_CONTENTS {
link /mylink -> mylink
datatype /mytype
link /softlink -> /dset
- UD link type /udlink ->
+ unknown type of UD link /udlink -> ???
}
}