summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-07-12 20:30:30 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-07-12 20:30:30 (GMT)
commit210d04b05f1ea3a172acf531519a36ee39c982b3 (patch)
tree62bb19366bb46b2c417130d10a6e91d1b8b735ae /tools/h5dump
parent1942f47bcfa0739e97efba02197136e1ecbb4a29 (diff)
downloadhdf5-210d04b05f1ea3a172acf531519a36ee39c982b3.zip
hdf5-210d04b05f1ea3a172acf531519a36ee39c982b3.tar.gz
hdf5-210d04b05f1ea3a172acf531519a36ee39c982b3.tar.bz2
[svn-r22567] HDFFV-7784: add attributes to the list of file contents option for h5dump. This is accomplished by adding an optional value to the option (-n)
Created test and reference files. Tested: local linux with cmake
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/CMakeLists.txt14
-rw-r--r--tools/h5dump/h5dump.c8
-rw-r--r--tools/h5dump/h5dump_ddl.c129
-rw-r--r--tools/h5dump/testh5dump.sh.in4
4 files changed, 80 insertions, 75 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index b8a2d4c..88d28c4 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -69,6 +69,8 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr-2.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr-3.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr-4_be.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tattrcontents1.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tattrcontents2.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattrintsize.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattrreg.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattrregR.ddl
@@ -854,6 +856,10 @@ IF (BUILD_TESTING)
tattr-3.out.err
tattr-4_be.out
tattr-4_be.out.err
+ tattrcontents1.out
+ tattrcontents1.out.err
+ tattrcontents2.out
+ tattrcontents2.out.err
tattrintsize.out
tattrintsize.out.err
tattrreg.out
@@ -1010,6 +1016,10 @@ IF (BUILD_TESTING)
tordercontents1.out.err
tordercontents2.out
tordercontents2.out.err
+ torderlinks1.out
+ torderlinks1.out.err
+ torderlinks2.out
+ torderlinks2.out.err
tperror.out
tperror.out.err
treference.out
@@ -1060,6 +1070,8 @@ IF (BUILD_TESTING)
tvlstr.out.err
tvms.out
tvms.out.err
+ twidedisplay.out
+ twidedisplay.out.err
)
SET_TESTS_PROPERTIES (H5DUMP-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
IF (NOT "${last_test}" STREQUAL "")
@@ -1218,6 +1230,8 @@ IF (BUILD_TESTING)
ADD_H5_TEST (tcontents 0 --enable-error-stack -n tfcontents1.h5)
ADD_H5_TEST (tordercontents1 0 --enable-error-stack -n --sort_by=name --sort_order=ascending tfcontents1.h5)
ADD_H5_TEST (tordercontents2 0 --enable-error-stack -n --sort_by=name --sort_order=descending tfcontents1.h5)
+ ADD_H5_TEST (tattrcontents1 0 --enable-error-stack -n 1 --sort_order=ascending tall.h5)
+ ADD_H5_TEST (tattrcontents2 0 --enable-error-stack -n 1 --sort_order=descending tall.h5)
# tests for storage layout
# compact
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index cd52743..15d862e 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -71,11 +71,11 @@ struct handler_t {
*/
/* The following initialization makes use of C language cancatenating */
/* "xxx" "yyy" into "xxxyyy". */
-static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:RECM:";
+static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:RECM:";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h' },
- { "contents", no_arg, 'n' },
+ { "contents", optional_arg, 'n' },
{ "properties", no_arg, 'p' },
{ "boot-block", no_arg, 'B' },
{ "boot-bloc", no_arg, 'B' },
@@ -235,6 +235,7 @@ usage(const char *prog)
HDfprintf(rawoutstream, " OPTIONS\n");
HDfprintf(rawoutstream, " -h, --help Print a usage message and exit\n");
HDfprintf(rawoutstream, " -n, --contents Print a list of the file contents and exit\n");
+ HDfprintf(rawoutstream, " Optional value 1 also prints attributes.\n");
HDfprintf(rawoutstream, " -B, --superblock Print the content of the super block\n");
HDfprintf(rawoutstream, " -H, --header Print the header only; no data is displayed\n");
HDfprintf(rawoutstream, " -A, --onlyattr Print the header and value of attributes\n");
@@ -999,6 +1000,9 @@ parse_start:
case 'n':
display_fi = TRUE;
last_was_dset = FALSE;
+ if ( opt_arg != NULL) {
+ h5trav_set_verbose(HDatoi(opt_arg));
+ }
break;
case 'p':
display_dcpl = TRUE;
diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c
index 22d2a2b..6f5fd3f 100644
--- a/tools/h5dump/h5dump_ddl.c
+++ b/tools/h5dump/h5dump_ddl.c
@@ -543,6 +543,56 @@ done:
}
/*-------------------------------------------------------------------------
+ * Function: attr_iteration
+ *
+ * Purpose: Iterate and display attributes within the specified group
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+attr_iteration(hid_t gid, unsigned attr_crt_order_flags)
+{
+ /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
+ in the group for attributes, then, sort by creation order, otherwise by name */
+
+ if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
+ if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end if */
+ else {
+ if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end else */
+}
+
+/*-------------------------------------------------------------------------
+ * Function: link_iteration
+ *
+ * Purpose: Iterate and display links within the specified group
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+link_iteration(hid_t gid, unsigned crt_order_flags)
+{
+
+ /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
+ in the group, then, sort by creation order, otherwise by name */
+ if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
+ H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL);
+ else
+ H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL);
+}
+
+/*-------------------------------------------------------------------------
* Function: dump_named_datatype
*
* Purpose: Dump named datatype
@@ -659,21 +709,7 @@ dump_named_datatype(hid_t tid, const char *name)
/* print attributes */
dump_indent += COL;
- /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the datatype's create property list for attributes, then, sort by creation order, otherwise by name */
-
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end if */
- else {
- if(H5Aiterate2(tid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
+ attr_iteration(tid, attr_crt_order_flags);
dump_indent -= COL;
@@ -829,53 +865,13 @@ dump_group(hid_t gid, const char *name)
}
else {
found_obj->displayed = TRUE;
- /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the group for attributes, then, sort by creation order, otherwise by name */
-
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end if */
- else {
- if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
-
- /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the group, then, sort by creation order, otherwise by name */
- if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
- H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL);
- else
- H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL);
+ attr_iteration(gid, attr_crt_order_flags);
+ link_iteration(gid, crt_order_flags);
}
}
else {
- /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the group for attributes, then, sort by creation order, otherwise by name */
-
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end if */
- else {
- if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
-
- /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the group, then, sort by creation order, otherwise by name */
- if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
- H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL);
- else
- H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL);
+ attr_iteration(gid, attr_crt_order_flags);
+ link_iteration(gid, crt_order_flags);
}
dump_indent -= COL;
@@ -1050,20 +1046,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
H5Tclose(type);
if (!bin_output) {
- /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the group for attributes, then, sort by creation order, otherwise by name */
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end if */
- else {
- if(H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
+ attr_iteration(did, attr_crt_order_flags);
}
ctx.indent_level--;
dump_indent -= COL;
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 612b9ab..8d2fb20 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -194,6 +194,8 @@ $SRC_H5DUMP_TESTFILES/tattr-1.ddl
$SRC_H5DUMP_TESTFILES/tattr-2.ddl
$SRC_H5DUMP_TESTFILES/tattr-3.ddl
$SRC_H5DUMP_TESTFILES/tattr-4_be.ddl
+$SRC_H5DUMP_TESTFILES/tattrcontents1.ddl
+$SRC_H5DUMP_TESTFILES/tattrcontents2.ddl
$SRC_H5DUMP_TESTFILES/tattrintsize.ddl
$SRC_H5DUMP_TESTFILES/tattrreg.ddl
$SRC_H5DUMP_TESTFILES/tattrregR.ddl
@@ -818,6 +820,8 @@ TOOLTEST4 tperror.ddl --enable-error-stack -p -d bogus tfcontents1.h5
TOOLTEST tcontents.ddl --enable-error-stack -n tfcontents1.h5
TOOLTEST tordercontents1.ddl --enable-error-stack -n --sort_by=name --sort_order=ascending tfcontents1.h5
TOOLTEST tordercontents2.ddl --enable-error-stack -n --sort_by=name --sort_order=descending tfcontents1.h5
+TOOLTEST tattrcontents1.ddl --enable-error-stack -n 1 --sort_order=ascending tall.h5
+TOOLTEST tattrcontents2.ddl --enable-error-stack -n 1 --sort_order=descending tall.h5
# tests for storage layout
# compact