summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2021-02-22 04:05:43 (GMT)
committerGitHub <noreply@github.com>2021-02-22 04:05:43 (GMT)
commitdf1a4af96126682ea4a05c2b26bf6b7c916579ff (patch)
tree993205ed1edde76001a811532f91997138b46744 /tools/h5dump
parent88960489604861813b3676bc234f49ca8ee937d3 (diff)
downloadhdf5-df1a4af96126682ea4a05c2b26bf6b7c916579ff.zip
hdf5-df1a4af96126682ea4a05c2b26bf6b7c916579ff.tar.gz
hdf5-df1a4af96126682ea4a05c2b26bf6b7c916579ff.tar.bz2
HDF5 1 8 merge of recent changes and tools (#353)
* Update supported platforms * Merge PR#3 changes from develop * # WARNING: head commit changed in the meantime Merge gcc 10 diagnostics option from develop Merge CMake changes from develop Merge warnings from develop Merge #318 OSX changes from develop Merge tools changes from develop Merge test macros from develop * Format updates * Fix missing semicolon and format fix * Format update * Correct actions, remove java option * Update autotools build files * Add testfiles * Fix configure issue with make flags * Init fapls to default * Update generated files and fix h5repack id closure * update format
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/CMakeLists.txt2
-rw-r--r--tools/h5dump/Makefile.am7
-rw-r--r--tools/h5dump/Makefile.in42
-rw-r--r--tools/h5dump/h5dump.c504
-rw-r--r--tools/h5dump/h5dump.h47
-rw-r--r--tools/h5dump/h5dump_ddl.c54
-rw-r--r--tools/h5dump/h5dump_extern.h39
-rw-r--r--tools/h5dump/h5dump_xml.c52
-rw-r--r--tools/h5dump/h5dumpgentest.c63
9 files changed, 376 insertions, 434 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index bedf172..5194f22 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -101,7 +101,7 @@ if (BUILD_TESTING)
# --------------------------------------------------------------------
if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS)
add_executable (h5dumpgentest ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dumpgentest.c)
- target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5dumpgentest STATIC)
target_link_libraries (h5dumpgentest PRIVATE ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
set_target_properties (h5dumpgentest PROPERTIES FOLDER generator/tools)
diff --git a/tools/h5dump/Makefile.am b/tools/h5dump/Makefile.am
index 4c77476..52ff59b 100644
--- a/tools/h5dump/Makefile.am
+++ b/tools/h5dump/Makefile.am
@@ -19,7 +19,7 @@
include $(top_srcdir)/config/commence.am
# Include files in /src directory and /tools/lib directory
-AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib
+AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib
# Test programs and scripts
if BUILD_TESTS_CONDITIONAL
@@ -56,15 +56,16 @@ if HAVE_SHARED_CONDITIONAL
# Build it as shared library if configure is enabled for shared library.
noinst_LTLIBRARIES=libdynlibdump.la
libdynlibdump_la_SOURCES=dynlib_dump.c
- libdynlibdump_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
+ libdynlibdump_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere
libdynlibdump.la: $(libdynlibdump_la_OBJECTS) $(libdynlibdump_la_DEPENDENCIES) $(EXTRA_libdynlibdump_la_DEPENDENCIES)
$(AM_V_CCLD)$(libdynlibdump_la_LINK) $(am_libdynlibdump_la_rpath) $(libdynlibdump_la_OBJECTS) $(libdynlibdump_la_LIBADD)
endif
endif
+
# Temporary files. *.h5 are generated by h5dumpgentest. They should
# copied to the testfiles/ directory if update is required.
CHECK_CLEANFILES+=*.h5 *.bin
-DISTCLEANFILES=testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh
+DISTCLEANFILES=testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh h5dump_plugin.sh
include $(top_srcdir)/config/conclude.am
diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in
index 3627e41..13a3c8f 100644
--- a/tools/h5dump/Makefile.in
+++ b/tools/h5dump/Makefile.in
@@ -433,19 +433,18 @@ AMTAR = @AMTAR@
# H5_CFLAGS holds flags that should be used when building hdf5,
# but which should not be exported to h5cc for building other programs.
-# AM_CFLAGS is an automake construct which should be used by Makefiles
+# AM_CFLAGS is an automake construct which should be used by Makefiles
# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
# This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well.
-AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@
+AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@
# Include files in /src directory and /tools/lib directory
AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \
- -I$(top_srcdir)/tools/lib
-AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@
+ -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib
+AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@
-AM_MAKEFLAGS = @AM_MAKEFLAGS@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -476,6 +475,7 @@ DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
DEV_WARNINGS = @DEV_WARNINGS@
+DIAGS = @DIAGS@
DIRECT_VFD = @DIRECT_VFD@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
@@ -503,8 +503,6 @@ GREP = @GREP@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
-H5_ECFLAGS = @H5_ECFLAGS@
-H5_ECXXFLAGS = @H5_ECXXFLAGS@
H5_FCFLAGS = @H5_FCFLAGS@
H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@
H5_LDFLAGS = @H5_LDFLAGS@
@@ -683,15 +681,15 @@ LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la
LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la
LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la
-# Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below
-# has been removed. According to the official description of DESTDIR by Gnu at
-# http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is
-# prepended to the normal and complete install path that it precedes for the
-# purpose of installing in a temporary directory which is useful for building
-# rpms and other packages. The '/' after ${DESTDIR} will be followed by another
-# '/' at the beginning of the normal install path. When DESTDIR is empty the
-# path then begins with '//', which is incorrect and causes problems at least for
-# Cygwin.
+# Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below
+# has been removed. According to the official description of DESTDIR by Gnu at
+# http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is
+# prepended to the normal and complete install path that it precedes for the
+# purpose of installing in a temporary directory which is useful for building
+# rpms and other packages. The '/' after ${DESTDIR} will be followed by another
+# '/' at the beginning of the normal install path. When DESTDIR is empty the
+# path then begins with '//', which is incorrect and causes problems at least for
+# Cygwin.
# Scripts used to build examples
# If only shared libraries have been installed, have h5cc build examples with
@@ -710,6 +708,7 @@ TRACE = perl $(top_srcdir)/bin/trace
# .chkexe files are used to mark tests that have run successfully.
# .chklog files are output from those tests.
# *.clog and *.clog2 are from the MPE option.
+
# Temporary files. *.h5 are generated by h5dumpgentest. They should
# copied to the testfiles/ directory if update is required.
CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 *.h5 *.bin
@@ -734,8 +733,8 @@ LDADD = $(LIBH5TOOLS) $(LIBHDF5)
h5dump_SOURCES = h5dump.c h5dump_ddl.c h5dump_xml.c
@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@noinst_LTLIBRARIES = libdynlibdump.la
@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibdump_la_SOURCES = dynlib_dump.c
-@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibdump_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere
-DISTCLEANFILES = testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh
+@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibdump_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere
+DISTCLEANFILES = testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh h5dump_plugin.sh
# Automake needs to be taught how to build lib, progs and tests targets.
# These will be filled in automatically for the most part (e.g.,
@@ -748,7 +747,7 @@ LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \
PROGS = $(bin_PROGRAMS) $(bin_SCRIPTS) $(noinst_PROGRAMS) $(noinst_SCRIPTS) \
$(EXTRA_PROG)
-chk_TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(EXTRA_TEST)
+chk_TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(EXTRA_TEST)
TEST_EXTENSIONS = .sh
SH_LOG_COMPILER = $(SHELL)
AM_SH_LOG_FLAGS =
@@ -1301,8 +1300,9 @@ uninstall-am: uninstall-binPROGRAMS
# commands that should be executed even if a file with the same name already
# exists.
.PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \
- build-tests check-clean check-install check-p check-s check-vfd \
- install-doc lib progs tests uninstall-doc _exec_check-s _test help
+ build-tests check-clean check-install check-p check-s check-vfd \
+ install-doc lib progs tests uninstall-doc \
+ _exec_check-s _test help
help:
@$(top_srcdir)/bin/makehelp
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index fd65a95..6382c9b 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -18,30 +18,32 @@
/* Name of tool */
#define PROGRAMNAME "h5dump"
-static const char *driver = NULL; /* The driver to open the file with. */
-const char * outfname = NULL;
-static int doxml = 0;
-static int useschema = 1;
-static const char *xml_dtd_uri = NULL;
+static const char *driver_name_g = NULL; /* The driver to open the file with. */
+const char * outfname_g = NULL;
+static hbool_t doxml_g = FALSE;
+static hbool_t useschema_g = TRUE;
+static const char *xml_dtd_uri_g = NULL;
#ifdef H5_HAVE_ROS3_VFD
-static H5FD_ros3_fapl_t ros3_fa = {
- 1, /* version */
- FALSE, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+/* Default "anonymous" S3 configuration */
+static H5FD_ros3_fapl_t ros3_fa_g = {
+ 1, /* Structure Version */
+ FALSE, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
-static H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+/* "Default" HDFS configuration */
+static H5FD_hdfs_fapl_t hdfs_fa_g = {
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
@@ -75,39 +77,8 @@ struct handler_t {
*/
/* The following initialization makes use of C language concatenating */
/* "xxx" "yyy" into "xxxyyy". */
-static const char * s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RE*CM:O*N:";
-static struct long_options l_opts[] = {{"help", no_arg, 'h'},
- {"hel", no_arg, 'h'},
- {"contents", optional_arg, 'n'},
- {"properties", no_arg, 'p'},
- {"superblock", no_arg, 'B'},
- {"boot-block", no_arg, 'B'},
- {"boot-bloc", no_arg, 'B'},
- {"boot-blo", no_arg, 'B'},
- {"boot-bl", no_arg, 'B'},
- {"boot-b", no_arg, 'B'},
- {"boot", no_arg, 'B'},
- {"boo", no_arg, 'B'},
- {"bo", no_arg, 'B'},
- {"header", no_arg, 'H'},
- {"heade", no_arg, 'H'},
- {"head", no_arg, 'H'},
- {"hea", no_arg, 'H'},
- {"object-ids", no_arg, 'i'},
- {"object-id", no_arg, 'i'},
- {"object-i", no_arg, 'i'},
- {"object", no_arg, 'i'},
- {"objec", no_arg, 'i'},
- {"obje", no_arg, 'i'},
- {"obj", no_arg, 'i'},
- {"ob", no_arg, 'i'},
- {"version", no_arg, 'V'},
- {"versio", no_arg, 'V'},
- {"versi", no_arg, 'V'},
- {"vers", no_arg, 'V'},
- {"ver", no_arg, 'V'},
- {"ve", no_arg, 'V'},
- {"attribute", require_arg, 'a'},
+static const char * s_opts = "a:b*c:d:ef:g:hik:l:m:n*o*pq:rs:t:uvw:xyz:A*BCD:E*F:G:HM:N:O*RS:VX:";
+static struct long_options l_opts[] = {{"attribute", require_arg, 'a'},
{"attribut", require_arg, 'a'},
{"attribu", require_arg, 'a'},
{"attrib", require_arg, 'a'},
@@ -115,10 +86,7 @@ static struct long_options l_opts[] = {{"help", no_arg, 'h'},
{"attr", require_arg, 'a'},
{"att", require_arg, 'a'},
{"at", require_arg, 'a'},
- {"block", require_arg, 'k'},
- {"bloc", require_arg, 'k'},
- {"blo", require_arg, 'k'},
- {"bl", require_arg, 'k'},
+ {"binary", optional_arg, 'b'},
{"count", require_arg, 'c'},
{"coun", require_arg, 'c'},
{"cou", require_arg, 'c'},
@@ -126,10 +94,7 @@ static struct long_options l_opts[] = {{"help", no_arg, 'h'},
{"dataset", require_arg, 'd'},
{"datase", require_arg, 'd'},
{"datas", require_arg, 'd'},
- {"datatype", require_arg, 't'},
- {"datatyp", require_arg, 't'},
- {"dataty", require_arg, 't'},
- {"datat", require_arg, 't'},
+ {"escape", no_arg, 'e'},
{"filedriver", require_arg, 'f'},
{"filedrive", require_arg, 'f'},
{"filedriv", require_arg, 'f'},
@@ -143,24 +108,44 @@ static struct long_options l_opts[] = {{"help", no_arg, 'h'},
{"grou", require_arg, 'g'},
{"gro", require_arg, 'g'},
{"gr", require_arg, 'g'},
- {"output", optional_arg, 'o'},
- {"outpu", optional_arg, 'o'},
- {"outp", optional_arg, 'o'},
- {"out", optional_arg, 'o'},
- {"ou", optional_arg, 'o'},
+ {"help", no_arg, 'h'},
+ {"hel", no_arg, 'h'},
+ {"object-ids", no_arg, 'i'},
+ {"object-id", no_arg, 'i'},
+ {"object-i", no_arg, 'i'},
+ {"object", no_arg, 'i'},
+ {"objec", no_arg, 'i'},
+ {"obje", no_arg, 'i'},
+ {"obj", no_arg, 'i'},
+ {"ob", no_arg, 'i'},
+ {"block", require_arg, 'k'},
+ {"bloc", require_arg, 'k'},
+ {"blo", require_arg, 'k'},
+ {"bl", require_arg, 'k'},
{"soft-link", require_arg, 'l'},
{"soft-lin", require_arg, 'l'},
{"soft-li", require_arg, 'l'},
{"soft-l", require_arg, 'l'},
{"soft", require_arg, 'l'},
{"sof", require_arg, 'l'},
+ {"format", require_arg, 'm'},
+ {"contents", optional_arg, 'n'},
+ {"output", optional_arg, 'o'},
+ {"outpu", optional_arg, 'o'},
+ {"outp", optional_arg, 'o'},
+ {"out", optional_arg, 'o'},
+ {"ou", optional_arg, 'o'},
+ {"properties", no_arg, 'p'},
+ {"sort_by", require_arg, 'q'},
+ {"string", no_arg, 'r'},
+ {"strin", no_arg, 'r'},
{"start", require_arg, 's'},
{"star", require_arg, 's'},
{"sta", require_arg, 's'},
- {"stride", require_arg, 'S'},
- {"strid", require_arg, 'S'},
- {"string", no_arg, 'r'},
- {"strin", no_arg, 'r'},
+ {"datatype", require_arg, 't'},
+ {"datatyp", require_arg, 't'},
+ {"dataty", require_arg, 't'},
+ {"datat", require_arg, 't'},
{"use-dtd", no_arg, 'u'},
{"use-dt", no_arg, 'u'},
{"use-d", no_arg, 'u'},
@@ -172,27 +157,44 @@ static struct long_options l_opts[] = {{"help", no_arg, 'h'},
{"widt", require_arg, 'w'},
{"wid", require_arg, 'w'},
{"wi", require_arg, 'w'},
- {"xml-dtd", require_arg, 'D'},
- {"xml-dt", require_arg, 'D'},
- {"xml-d", require_arg, 'D'},
- {"xml-ns", require_arg, 'X'},
- {"xml-n", require_arg, 'X'},
{"xml", no_arg, 'x'},
{"xm", no_arg, 'x'},
- {"onlyattr", optional_arg, 'A'},
- {"escape", no_arg, 'e'},
{"noindex", no_arg, 'y'},
- {"binary", optional_arg, 'b'},
- {"form", require_arg, 'F'},
- {"sort_by", require_arg, 'q'},
{"sort_order", require_arg, 'z'},
- {"format", require_arg, 'm'},
- {"region", no_arg, 'R'},
+ {"onlyattr", optional_arg, 'A'},
+ {"superblock", no_arg, 'B'},
+ {"boot-block", no_arg, 'B'},
+ {"boot-bloc", no_arg, 'B'},
+ {"boot-blo", no_arg, 'B'},
+ {"boot-bl", no_arg, 'B'},
+ {"boot-b", no_arg, 'B'},
+ {"boot", no_arg, 'B'},
+ {"boo", no_arg, 'B'},
+ {"bo", no_arg, 'B'},
+ {"no-compact-subset", no_arg, 'C'},
+ {"xml-dtd", require_arg, 'D'},
+ {"xml-dt", require_arg, 'D'},
+ {"xml-d", require_arg, 'D'},
{"enable-error-stack", optional_arg, 'E'},
+ {"form", require_arg, 'F'},
+ {"header", no_arg, 'H'},
+ {"heade", no_arg, 'H'},
+ {"head", no_arg, 'H'},
+ {"hea", no_arg, 'H'},
{"packed-bits", require_arg, 'M'},
- {"no-compact-subset", no_arg, 'C'},
- {"ddl", optional_arg, 'O'},
{"any_path", require_arg, 'N'},
+ {"ddl", optional_arg, 'O'},
+ {"region", no_arg, 'R'},
+ {"stride", require_arg, 'S'},
+ {"strid", require_arg, 'S'},
+ {"version", no_arg, 'V'},
+ {"versio", no_arg, 'V'},
+ {"versi", no_arg, 'V'},
+ {"vers", no_arg, 'V'},
+ {"ver", no_arg, 'V'},
+ {"ve", no_arg, 'V'},
+ {"xml-ns", require_arg, 'X'},
+ {"xml-n", require_arg, 'X'},
{"s3-cred", require_arg, '$'},
{"hdfs-attrs", require_arg, '#'},
{NULL, 0, '\0'}};
@@ -664,12 +666,12 @@ parse_hsize_list(const char *h_list, subset_d *d)
*-------------------------------------------------------------------------
*/
static struct subset_t *
-parse_subset_params(char *dset)
+parse_subset_params(const char *dset)
{
struct subset_t *s = NULL;
char * brace;
- if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
+ if (!dump_opts.disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
*brace++ = '\0';
s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
@@ -898,50 +900,50 @@ parse_command_line(int argc, const char *argv[])
parse_start:
switch ((char)opt) {
case 'R':
- display_region = TRUE;
- region_output = TRUE;
+ dump_opts.display_region = TRUE;
+ region_output = TRUE;
break;
case 'B':
- display_bb = TRUE;
- last_was_dset = FALSE;
+ dump_opts.display_bb = TRUE;
+ last_was_dset = FALSE;
break;
case 'n':
- display_fi = TRUE;
- last_was_dset = FALSE;
+ dump_opts.display_fi = TRUE;
+ last_was_dset = FALSE;
if (opt_arg != NULL)
h5trav_set_verbose(HDatoi(opt_arg));
break;
case 'p':
- display_dcpl = TRUE;
+ dump_opts.display_dcpl = TRUE;
break;
case 'y':
- display_ai = FALSE;
+ dump_opts.display_ai = FALSE;
break;
case 'e':
- display_escape = TRUE;
+ dump_opts.display_escape = TRUE;
break;
case 'H':
- display_data = FALSE;
- display_attr_data = FALSE;
- last_was_dset = FALSE;
+ dump_opts.display_data = FALSE;
+ dump_opts.display_attr_data = FALSE;
+ last_was_dset = FALSE;
break;
case 'A':
if (opt_arg != NULL) {
if (0 == HDatoi(opt_arg))
- include_attrs = FALSE;
+ dump_opts.include_attrs = FALSE;
}
else {
- display_data = FALSE;
- display_attr_data = TRUE;
- last_was_dset = FALSE;
+ dump_opts.display_data = FALSE;
+ dump_opts.display_attr_data = TRUE;
+ last_was_dset = FALSE;
}
break;
case 'i':
- display_oid = TRUE;
- last_was_dset = FALSE;
+ dump_opts.display_oid = TRUE;
+ last_was_dset = FALSE;
break;
case 'r':
- display_char = TRUE;
+ dump_opts.display_char = TRUE;
break;
case 'V':
print_version(h5tools_getprogname());
@@ -960,7 +962,7 @@ parse_start:
last_was_dset = FALSE;
} break;
case 'N':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -972,7 +974,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 'a':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -984,7 +986,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 'd':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -998,10 +1000,10 @@ parse_start:
last_was_dset = TRUE;
break;
case 'f':
- driver = opt_arg;
+ driver_name_g = opt_arg;
break;
case 'g':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -1013,7 +1015,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 'l':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -1025,7 +1027,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 't':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -1052,13 +1054,13 @@ parse_start:
}
}
else {
- if (display_attr_data && !display_data) {
+ if (dump_opts.display_attr_data && !dump_opts.display_data) {
if (h5tools_set_attr_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
}
}
- if (display_data || display_all) {
+ if (dump_opts.display_data || dump_opts.display_all) {
if (h5tools_set_data_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
@@ -1066,9 +1068,9 @@ parse_start:
}
}
- usingdasho = TRUE;
- last_was_dset = FALSE;
- outfname = opt_arg;
+ dump_opts.usingdasho = TRUE;
+ last_was_dset = FALSE;
+ outfname_g = opt_arg;
break;
case 'b':
@@ -1080,8 +1082,8 @@ parse_start:
}
}
bin_output = TRUE;
- if (outfname != NULL) {
- if (h5tools_set_data_output_file(outfname, 1) < 0) {
+ if (outfname_g != NULL) {
+ if (h5tools_set_data_output_file(outfname_g, 1) < 0) {
/* failed to set output file */
usage(h5tools_getprogname());
goto error;
@@ -1116,21 +1118,21 @@ parse_start:
usage(h5tools_getprogname());
goto error;
}
- display_packed_bits = TRUE;
+ dump_opts.display_packed_bits = TRUE;
break;
/** begin XML parameters **/
case 'x':
/* select XML output */
- doxml = TRUE;
- useschema = TRUE;
+ doxml_g = TRUE;
+ useschema_g = TRUE;
h5tools_dump_header_format = NULL;
dump_function_table = &xml_function_table;
h5tools_nCols = 0;
break;
case 'u':
- doxml = TRUE;
- useschema = FALSE;
+ doxml_g = TRUE;
+ useschema_g = FALSE;
xmlnsprefix = "";
h5tools_dump_header_format = NULL;
dump_function_table = &xml_function_table;
@@ -1139,7 +1141,7 @@ parse_start:
case 'D':
/* specify alternative XML DTD or schema */
/* To Do: check format of this value? */
- xml_dtd_uri = opt_arg;
+ xml_dtd_uri_g = opt_arg;
h5tools_nCols = 0;
break;
@@ -1152,7 +1154,7 @@ parse_start:
case 'X':
/* specify XML namespace (default="hdf5:"), or none */
/* To Do: check format of this value? */
- if (!useschema) {
+ if (!useschema_g) {
usage(h5tools_getprogname());
goto error;
}
@@ -1250,7 +1252,7 @@ end_collect:
enable_error_stack = 1;
break;
case 'C':
- disable_compact_subset = TRUE;
+ dump_opts.disable_compact_subset = TRUE;
break;
case 'h':
usage(h5tools_getprogname());
@@ -1260,106 +1262,37 @@ end_collect:
goto done;
case '$':
-#ifndef H5_HAVE_ROS3_VFD
+#ifdef H5_HAVE_ROS3_VFD
+ if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa_g) < 0) {
+ error_msg("failed to parse S3 VFD credential info\n");
+ usage(h5tools_getprogname());
+ free_handler(hand, argc);
+ hand = NULL;
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- /* s3 credential */
- {
- char ** s3_cred = NULL;
- char * s3_cred_string = NULL;
- const char *ccred[3];
- unsigned nelems = 0;
- if (FAIL == parse_tuple(opt_arg, ',', &s3_cred_string, &nelems, &s3_cred)) {
- error_msg("unable to parse malformed s3 credentials\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- if (nelems != 3) {
- error_msg("s3 credentials expects 3 elements\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- ccred[0] = (const char *)s3_cred[0];
- ccred[1] = (const char *)s3_cred[1];
- ccred[2] = (const char *)s3_cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- error_msg("Invalid S3 credentials\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- HDfree(s3_cred);
- HDfree(s3_cred_string);
- } /* s3 credential block */
+#endif
break;
-#endif /* H5_HAVE_ROS3_VFD */
case '#':
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- goto error;
-#else
- {
- /* read hdfs properties tuple and store values in `hdfs_fa` */
- unsigned nelems = 0;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
- if (FAIL == parse_tuple((const char *)opt_arg, ',', &props_src, &nelems, &props)) {
- error_msg("unable to parse hdfs properties tuple\n");
- goto error;
- }
- /* sanity-check tuple count
- */
- if (nelems != 5) {
+#ifdef H5_HAVE_LIBHDFS
+ if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa_g) < 0) {
+ error_msg("failed to parse HDFS VFD configuration info\n");
+ usage(h5tools_getprogname());
+ free_handler(hand, argc);
+ hand = NULL;
h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- /* Populate fapl configuration structure with given
- * properties.
- * WARNING: No error-checking is done on length of input
- * strings... Silent overflow is possible, albeit
- * unlikely.
- */
- if (strncmp(props[0], "", 1))
- HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0]));
-
- if (strncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (strncmp(props[2], "", 1))
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
-
- if (strncmp(props[3], "", 1))
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
-
- if (strncmp(props[4], "", 1)) {
- k = strtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
+ goto done;
}
- HDfree(props);
- HDfree(props_src);
- }
-#endif /* H5_HAVE_LIBHDFS */
+#else
+ error_msg("HDFS VFD not enabled.\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+#endif
break;
case '?':
@@ -1404,14 +1337,10 @@ main(int argc, const char *argv[])
hid_t fid = H5I_INVALID_HID;
hid_t gid = H5I_INVALID_HID;
hid_t fapl_id = H5P_DEFAULT;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
H5O_info_t oi;
struct handler_t *hand = NULL;
int i;
unsigned u;
- void * edata;
- void * tools_edata;
char * fname = NULL;
h5tools_setprogname(PROGRAMNAME);
@@ -1420,63 +1349,50 @@ main(int argc, const char *argv[])
dump_function_table = &ddl_function_table;
dump_indent = 0;
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
-
if ((hand = parse_command_line(argc, argv)) == NULL) {
goto done;
}
- if (bin_output && outfname == NULL) {
+ if (bin_output && outfname_g == NULL) {
error_msg("binary output requires a file name, use -o <filename>\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
- }
-
/* Check for conflicting options */
- if (doxml) {
- if (!display_all) {
+ if (doxml_g) {
+ if (!dump_opts.display_all) {
error_msg("option \"%s\" not available for XML\n", "to display selected objects");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_bb) {
+ else if (dump_opts.display_bb) {
error_msg("option \"%s\" not available for XML\n", "--boot-block");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_oid == 1) {
+ else if (dump_opts.display_oid == 1) {
error_msg("option \"%s\" not available for XML\n", "--object-ids");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_char == TRUE) {
+ else if (dump_opts.display_char == TRUE) {
error_msg("option \"%s\" not available for XML\n", "--string");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (usingdasho) {
+ else if (dump_opts.usingdasho) {
error_msg("option \"%s\" not available for XML\n", "--output");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
}
else {
- if (xml_dtd_uri) {
- warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri);
+ if (xml_dtd_uri_g) {
+ warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri_g);
}
}
@@ -1486,57 +1402,49 @@ main(int argc, const char *argv[])
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
- if (driver != NULL) {
- void *conf_fa = NULL;
+ if (driver_name_g != NULL) {
+ h5tools_vfd_info_t vfd_info;
+
+ vfd_info.info = NULL;
+ vfd_info.name = driver_name_g;
- if (!strcmp(driver, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
+ if (!HDstrcmp(driver_name_g, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ vfd_info.info = (void *)&ros3_fa_g;
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+#endif
}
- else if (!HDstrcmp(driver, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
+ else if (!HDstrcmp(driver_name_g, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ vfd_info.info = (void *)&hdfs_fa_g;
+#else
+ error_msg("The HDFS VFD is not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
+#endif
}
- if (conf_fa != NULL) {
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- error_msg("unable to create fapl entry\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- /* driver guaranteed "ros3" or "hdfs" */
- /* conf_fa appropriate to driver */
- if (0 == h5tools_set_configured_fapl(fapl_id, driver, conf_fa)) {
- error_msg("unable to set fapl\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &vfd_info)) < 0) {
+ error_msg("unable to create FAPL for file access\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
- } /* driver defined */
+ } /* driver name defined */
while (opt_ind < argc) {
fname = HDstrdup(argv[opt_ind++]);
- if (fapl_id != H5P_DEFAULT) {
- fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- }
- else {
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
- }
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0);
if (fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
@@ -1550,23 +1458,23 @@ main(int argc, const char *argv[])
/* Prepare to find objects that might be targets of a reference */
fill_ref_path_table(fid);
- if (doxml) {
+ if (doxml_g) {
/* initialize XML */
/* reset prefix! */
HDstrcpy(prefix, "");
/* make sure the URI is initialized to something */
- if (xml_dtd_uri == NULL) {
- if (useschema) {
- xml_dtd_uri = DEFAULT_XSD;
+ if (xml_dtd_uri_g == NULL) {
+ if (useschema_g) {
+ xml_dtd_uri_g = DEFAULT_XSD;
}
else {
- xml_dtd_uri = DEFAULT_DTD;
- xmlnsprefix = "";
+ xml_dtd_uri_g = DEFAULT_DTD;
+ xmlnsprefix = "";
}
}
else {
- if (useschema && HDstrcmp(xmlnsprefix, "")) {
+ if (useschema_g && HDstrcmp(xmlnsprefix, "")) {
error_msg(
"Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
h5tools_setstatus(EXIT_FAILURE);
@@ -1600,7 +1508,7 @@ main(int argc, const char *argv[])
} /* end if */
/* start to dump - display file header information */
- if (!doxml) {
+ if (!doxml_g) {
begin_obj(h5tools_dump_header_format->filebegin, fname,
h5tools_dump_header_format->fileblockbegin);
}
@@ -1608,12 +1516,12 @@ main(int argc, const char *argv[])
PRINTVALSTREAM(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
/* alternative first element, depending on schema or DTD. */
- if (useschema) {
+ if (useschema_g) {
if (HDstrcmp(xmlnsprefix, "") == 0) {
PRINTSTREAM(rawoutstream,
"<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
"xsi:noNamespaceSchemaLocation=\"%s\">\n",
- xml_dtd_uri);
+ xml_dtd_uri_g);
}
else {
/* TO DO: make -url option work in this case (may need new option) */
@@ -1636,13 +1544,13 @@ main(int argc, const char *argv[])
}
else {
PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n",
- xml_dtd_uri);
+ xml_dtd_uri_g);
PRINTVALSTREAM(rawoutstream, "<HDF5-File>\n");
}
}
- if (!doxml) {
- if (display_fi) {
+ if (!doxml_g) {
+ if (dump_opts.display_fi) {
PRINTVALSTREAM(rawoutstream, "\n");
dump_fcontents(fid);
end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
@@ -1650,20 +1558,20 @@ main(int argc, const char *argv[])
goto done;
}
- if (display_bb)
+ if (dump_opts.display_bb)
dump_fcpl(fid);
}
- if (display_all) {
+ if (dump_opts.display_all) {
if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
error_msg("unable to open root group\n");
h5tools_setstatus(EXIT_FAILURE);
}
else {
- if (!doxml)
+ if (!doxml_g)
dump_indent += COL;
dump_function_table->dump_group_function(gid, "/");
- if (!doxml)
+ if (!doxml_g)
dump_indent -= COL;
PRINTVALSTREAM(rawoutstream, "\n");
}
@@ -1675,7 +1583,7 @@ main(int argc, const char *argv[])
}
else {
/* Note: this option is not supported for XML */
- if (doxml) {
+ if (doxml_g) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -1689,7 +1597,7 @@ main(int argc, const char *argv[])
PRINTVALSTREAM(rawoutstream, "\n");
}
- if (!doxml) {
+ if (!doxml_g) {
end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
PRINTVALSTREAM(rawoutstream, "\n");
}
@@ -1718,8 +1626,6 @@ main(int argc, const char *argv[])
/* To Do: clean up XML table */
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
leave(h5tools_getstatus());
done:
@@ -1749,8 +1655,6 @@ done:
/* To Do: clean up XML table */
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
leave(h5tools_getstatus());
} /* main */
diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h
index 5cad93d..92fc7d5 100644
--- a/tools/h5dump/h5dump.h
+++ b/tools/h5dump/h5dump.h
@@ -43,6 +43,7 @@ typedef struct h5dump_table_items_t {
table_t * dset_table; /* Table of datasets */
table_t * type_table; /* Table of datatypes */
} h5dump_table_items_t;
+
typedef struct h5dump_table_list_t {
size_t nalloc;
size_t nused;
@@ -51,30 +52,34 @@ typedef struct h5dump_table_list_t {
h5dump_table_list_t table_list = {0, 0, NULL};
table_t * group_table = NULL, *dset_table = NULL, *type_table = NULL;
-unsigned dump_indent = 0; /*how far in to indent the line */
-int unamedtype = 0; /* shared datatype with no name */
-hbool_t hit_elink = FALSE; /* whether we have traversed an external link */
-size_t prefix_len = 1024;
-char * prefix = NULL;
-const char *fp_format = NULL;
+unsigned dump_indent = 0; /* how far in to indent the line */
+int unamedtype = 0; /* shared datatype with no name */
+hbool_t hit_elink = FALSE; /* whether we have traversed an external link */
+size_t prefix_len = 1024;
+char * prefix = NULL;
+const char *fp_format = NULL;
/* things to display or which are set via command line parameters */
-int display_all = TRUE;
-int display_oid = FALSE;
-int display_data = TRUE;
-int display_attr_data = TRUE;
-int display_char = FALSE; /*print 1-byte numbers as ASCII */
-int usingdasho = FALSE;
-int display_bb = FALSE; /*superblock */
-int display_dcpl = FALSE; /*dcpl */
-int display_fi = FALSE; /*file index */
-int display_ai = TRUE; /*array index */
-int display_escape = FALSE; /*escape non printable characters */
-int display_region = FALSE; /*print region reference data */
-int disable_compact_subset = FALSE; /* disable compact form of subset notation */
-int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/
-int include_attrs = TRUE; /* Display attributes */
+typedef struct {
+ int display_all;
+ int display_oid;
+ int display_data;
+ int display_attr_data;
+ int display_char; /* print 1-byte numbers as ASCII */
+ int usingdasho;
+ int display_bb; /* superblock */
+ int display_dcpl; /* dcpl */
+ int display_fi; /* file index */
+ int display_ai; /* array index */
+ int display_escape; /* escape non printable characters */
+ int display_region; /* print region reference data */
+ int disable_compact_subset; /* disable compact form of subset notation */
+ int display_packed_bits; /* print 1-8 byte numbers as packed bits */
+ int include_attrs; /* Display attributes */
+} dump_opt_t;
+dump_opt_t dump_opts = {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE,
+ FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE};
#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
#define PACKED_BITS_SIZE_MAX (8 * sizeof(long long)) /* Maximum bits size of integer types of packed-bits */
diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c
index c913a02..241f5f9 100644
--- a/tools/h5dump/h5dump_ddl.c
+++ b/tools/h5dump/h5dump_ddl.c
@@ -103,13 +103,13 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
- ctx.display_index = display_ai;
- ctx.display_char = display_char;
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
- oid_output = display_oid;
- data_output = display_data;
- attr_data_output = display_attr_data;
+ oid_output = dump_opts.display_oid;
+ data_output = dump_opts.display_data;
+ attr_data_output = dump_opts.display_attr_data;
string_dataformat = *outputformat;
@@ -125,7 +125,7 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
h5dump_type_table = type_table;
@@ -184,7 +184,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
/* Build the object's path name */
@@ -564,7 +564,7 @@ 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 (include_attrs) {
+ if (dump_opts.include_attrs) {
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");
@@ -641,7 +641,7 @@ dump_named_datatype(hid_t tid, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if ((tcpl_id = H5Tget_create_plist(tid)) < 0) {
@@ -797,7 +797,7 @@ dump_group(hid_t gid, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.need_prefix = TRUE;
@@ -827,7 +827,7 @@ dump_group(hid_t gid, const char *name)
}
} /* end if */
- if (display_oid)
+ if (dump_opts.display_oid)
h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid);
h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid);
@@ -924,7 +924,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if ((dcpl_id = H5Dget_create_plist(did)) < 0) {
@@ -965,11 +965,11 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space);
H5Sclose(space);
- if (display_oid) {
+ if (dump_opts.display_oid) {
h5tools_dump_oid(rawoutstream, outputformat, &ctx, did);
}
- if (display_dcpl) {
+ if (dump_opts.display_dcpl) {
h5dump_type_table = type_table;
h5tools_dump_dcpl(rawoutstream, outputformat, &ctx, dcpl_id, type, did);
h5dump_type_table = NULL;
@@ -977,16 +977,16 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
H5Pclose(dcpl_id);
ctx.sset = sset;
- ctx.display_index = display_ai;
- ctx.display_char = display_char;
- if (display_data) {
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
+ if (dump_opts.display_data) {
unsigned data_loop = 1;
unsigned u;
- if (display_packed_bits)
+ if (dump_opts.display_packed_bits)
data_loop = packed_bits_num;
for (u = 0; u < data_loop; u++) {
- if (display_packed_bits) {
+ if (dump_opts.display_packed_bits) {
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
@@ -1090,7 +1090,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
@@ -1098,7 +1098,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
ctx.cur_column = dump_indent;
ctx.sset = sset;
ctx.display_index = display_index;
- ctx.display_char = display_char;
+ ctx.display_char = dump_opts.display_char;
if (obj_data == DATASET_DATA)
print_dataset = TRUE;
@@ -1486,8 +1486,8 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
- ctx.display_index = display_ai;
- ctx.display_char = display_char;
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
string_dataformat = *outputformat;
@@ -1503,7 +1503,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/");
@@ -1543,9 +1543,9 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5
} /* end if */
attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
- oid_output = display_oid;
- data_output = display_data;
- attr_data_output = display_attr_data;
+ oid_output = dump_opts.display_oid;
+ data_output = dump_opts.display_data;
+ attr_data_output = dump_opts.display_attr_data;
h5dump_type_table = type_table;
h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id);
diff --git a/tools/h5dump/h5dump_extern.h b/tools/h5dump/h5dump_extern.h
index f6d5367..3ffac43 100644
--- a/tools/h5dump/h5dump_extern.h
+++ b/tools/h5dump/h5dump_extern.h
@@ -50,30 +50,33 @@ typedef struct h5dump_table_list_t {
extern h5dump_table_list_t table_list;
extern table_t * group_table, *dset_table, *type_table;
-extern unsigned dump_indent; /*how far in to indent the line */
-extern int unamedtype; /* shared datatype with no name */
-extern hbool_t hit_elink; /* whether we have traversed an external link */
+extern unsigned dump_indent; /* how far in to indent the line */
+extern int unamedtype; /* shared datatype with no name */
+extern hbool_t hit_elink; /* whether we have traversed an external link */
extern size_t prefix_len;
extern char * prefix;
extern const char *fp_format;
/* things to display or which are set via command line parameters */
-extern int display_all;
-extern int display_oid;
-extern int display_data;
-extern int display_attr_data;
-extern int display_char; /*print 1-byte numbers as ASCII */
-extern int usingdasho;
-extern int display_bb; /*superblock */
-extern int display_dcpl; /*dcpl */
-extern int display_fi; /*file index */
-extern int display_ai; /*array index */
-extern int display_escape; /*escape non printable characters */
-extern int display_region; /*print region reference data */
-extern int disable_compact_subset; /* disable compact form of subset notation */
-extern int display_packed_bits; /*print 1-8 byte numbers as packed bits*/
-extern int include_attrs; /* Display attributes */
+typedef struct {
+ int display_all;
+ int display_oid;
+ int display_data;
+ int display_attr_data;
+ int display_char; /* print 1-byte numbers as ASCII */
+ int usingdasho;
+ int display_bb; /* superblock */
+ int display_dcpl; /* dcpl */
+ int display_fi; /* file index */
+ int display_ai; /* array index */
+ int display_escape; /* escape non printable characters */
+ int display_region; /* print region reference data */
+ int disable_compact_subset; /* disable compact form of subset notation */
+ int display_packed_bits; /* print 1-8 byte numbers as packed bits */
+ int include_attrs; /* Display attributes */
+} dump_opt_t;
+extern dump_opt_t dump_opts;
#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
#define PACKED_BITS_SIZE_MAX 8 * sizeof(long long) /* Maximum bits size of integer types of packed-bits */
diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c
index ca3c501..dd27bb4 100644
--- a/tools/h5dump/h5dump_xml.c
+++ b/tools/h5dump/h5dump_xml.c
@@ -161,7 +161,7 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
/* Build the object's path name */
@@ -616,7 +616,7 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen)
HDsprintf(outstr, "xid_" H5_PRINTF_HADDR_FMT, objno);
- return (0);
+ return 0;
}
static const char *quote = "&quot;";
@@ -732,9 +732,9 @@ xml_escape_the_string(const char *str, int slen)
size_t extra;
size_t len;
size_t i;
- const char *cp;
- char * ncp;
- char * rcp;
+ const char *cp = NULL;
+ char * ncp = NULL;
+ char * rcp = NULL;
size_t ncp_len;
if (!str)
@@ -776,30 +776,32 @@ xml_escape_the_string(const char *str, int slen)
size_t esc_len;
if (*cp == '\\') {
- *ncp++ = '\\';
+ *ncp++ = '\\';
+ ncp_len--;
*ncp = *cp;
esc_len = 1;
}
else if (*cp == '\"') {
- *ncp++ = '\\';
+ *ncp++ = '\\';
+ ncp_len--;
*ncp = *cp;
esc_len = 1;
}
else if (*cp == '\'') {
+ HDstrncpy(ncp, apos, ncp_len);
esc_len = HDstrlen(apos);
- HDstrncpy(ncp, apos, esc_len);
}
else if (*cp == '<') {
+ HDstrncpy(ncp, lt, ncp_len);
esc_len = HDstrlen(lt);
- HDstrncpy(ncp, lt, esc_len);
}
else if (*cp == '>') {
+ HDstrncpy(ncp, gt, ncp_len);
esc_len = HDstrlen(gt);
- HDstrncpy(ncp, gt, esc_len);
}
else if (*cp == '&') {
+ HDstrncpy(ncp, amp, ncp_len);
esc_len = HDstrlen(amp);
- HDstrncpy(ncp, amp, esc_len);
}
else {
*ncp = *cp;
@@ -880,7 +882,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if (!in_group && H5Tcommitted(type) > 0) {
@@ -1578,7 +1580,7 @@ xml_dump_datatype(hid_t type)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.indent_level++;
@@ -1713,7 +1715,7 @@ xml_dump_dataspace(hid_t space)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.indent_level++;
@@ -2057,7 +2059,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.need_prefix = TRUE;
@@ -2080,7 +2082,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
ctx.indent_level++;
dump_indent += COL;
- if (display_attr_data && space_type != H5S_NULL) {
+ if (dump_opts.display_attr_data && space_type != H5S_NULL) {
switch (H5Tget_class(type)) {
case H5T_INTEGER:
case H5T_FLOAT:
@@ -2382,7 +2384,7 @@ xml_dump_named_datatype(hid_t type, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
dtxid = (char *)HDmalloc((size_t)100);
@@ -2602,7 +2604,7 @@ xml_dump_group(hid_t gid, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if (HDstrcmp(name, "/") == 0) {
@@ -2993,7 +2995,7 @@ xml_print_refs(hid_t did, int source)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
for (i = 0; i < (hsize_t)ssiz; i++) {
@@ -3145,7 +3147,7 @@ xml_print_strs(hid_t did, int source)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
for (i = 0; i < (hsize_t)ssiz; i++) {
@@ -3261,7 +3263,7 @@ check_filters(hid_t dcpl)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
nfilt = H5Pget_nfilters(dcpl);
@@ -3402,7 +3404,7 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.indent_level++;
@@ -3770,7 +3772,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
xml_name_to_XID(tmp, rstr, 100, 1);
@@ -4082,7 +4084,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss
dump_indent -= COL;
tempi = H5Dget_storage_size(did);
- if (display_data && (tempi > 0)) {
+ if (dump_opts.display_data && (tempi > 0)) {
switch (H5Tget_class(type)) {
case H5T_INTEGER:
case H5T_FLOAT:
@@ -4358,7 +4360,7 @@ xml_print_enum(hid_t type)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
nmembs = (unsigned)H5Tget_nmembers(type);
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 495570e..fb7a083 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -22,7 +22,7 @@
*/
#include "hdf5.h"
-#include "H5private.h"
+#include "h5test.h"
#include "h5tools.h"
#define FILE1 "tgroup.h5"
@@ -259,6 +259,7 @@ typedef struct s1_t {
#define F51_MAX_NAME_LEN ((64 * 1024) + 1024)
/* "File 64" macros */
+#define F64_FILE "tarray8.h5"
#define F64_DATASET "DS1"
#define F64_DIM0 1
#define F64_ARRAY_BUF_LEN (4 * 1024)
@@ -355,16 +356,13 @@ typedef struct s1_t {
/* "File 82" macros */
/* Name of dataset to create in datafile */
-#define F82_DATASETNAME "CompoundComplex1D"
-#define F82_DATASETNAME2 "CompoundComplex2D"
-#define F82_DATASETNAME3 "CompoundComplex3D"
-#define F82_DATASETNAME4 "CompoundComplex4D"
+#define F82_DATASETNAME "CompoundComplex1D"
/* Dataset dimensions */
#define F82_DIM32 32
#define F82_RANK 1
-#define F82_RANK2 2
-#define F82_RANK3 3
-#define F82_RANK4 4
+/* #define F82_RANK2 2 */
+/* #define F82_RANK3 3 */
+/* #define F82_RANK4 4 */
/* "File 83" macros */
/* Name of dataset to create in datafile */
@@ -424,11 +422,24 @@ gent_group(void)
static void
gent_dataset(void)
{
- hid_t fid, dataset, space;
- hsize_t dims[2];
- int dset1[10][20];
- double dset2[30][20];
- int i, j;
+ hid_t fid, dataset, space;
+ hsize_t dims[2];
+ int ** dset1 = NULL;
+ int * dset1_data = NULL;
+ double **dset2 = NULL;
+ double * dset2_data = NULL;
+ int i, j;
+
+ /* Set up data arrays */
+ dset1_data = (int *)HDcalloc(10 * 20, sizeof(int));
+ dset1 = (int **)HDcalloc(10, sizeof(dset1_data));
+ for (i = 0; i < 10; i++)
+ dset1[i] = dset1_data + (i * 20);
+
+ dset2_data = (double *)HDcalloc(30 * 20, sizeof(double));
+ dset2 = (double **)HDcalloc(30, sizeof(dset2_data));
+ for (i = 0; i < 30; i++)
+ dset2[i] = dset2_data + (i * 20);
fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -442,7 +453,7 @@ gent_dataset(void)
for (j = 0; j < 20; j++)
dset1[i][j] = j + i;
- H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1);
+ H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1_data);
H5Sclose(space);
H5Dclose(dataset);
@@ -456,11 +467,16 @@ gent_dataset(void)
for (j = 0; j < 20; j++)
dset2[i][j] = 0.0001F * (float)j + (float)i;
- H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2);
+ H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_data);
H5Sclose(space);
H5Dclose(dataset);
H5Fclose(fid);
+
+ HDfree(dset1);
+ HDfree(dset1_data);
+ HDfree(dset2);
+ HDfree(dset2_data);
}
static void
@@ -1747,8 +1763,16 @@ gent_str(void)
int a[8][10];
char s[12][33];
} compound_t;
- compound_t comp1[3][6];
- hsize_t mdims[2];
+
+ compound_t **comp1 = NULL;
+ compound_t * comp1_data = NULL;
+ hsize_t mdims[2];
+
+ /* Set up data array */
+ comp1_data = (compound_t *)HDcalloc(3 * 6, sizeof(compound_t));
+ comp1 = (compound_t **)HDcalloc(3, sizeof(comp1_data));
+ for (i = 0; i < 3; i++)
+ comp1[i] = comp1_data + (i * 6);
fid = H5Fcreate(FILE13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -1837,7 +1861,7 @@ gent_str(void)
}
dataset = H5Dcreate2(fid, "/comp1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1);
+ H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1_data);
H5Tclose(f_type);
H5Tclose(f_type2);
@@ -1845,6 +1869,9 @@ gent_str(void)
H5Dclose(dataset);
H5Fclose(fid);
+
+ HDfree(comp1);
+ HDfree(comp1_data);
}
/*