summaryrefslogtreecommitdiffstats
path: root/tools/src/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/misc')
-rw-r--r--tools/src/misc/CMakeLists.txt10
-rw-r--r--tools/src/misc/Makefile.in62
-rw-r--r--tools/src/misc/h5clear.c24
-rw-r--r--tools/src/misc/h5debug.c406
-rw-r--r--tools/src/misc/h5mkgrp.c194
-rw-r--r--tools/src/misc/h5repart.c2
6 files changed, 381 insertions, 317 deletions
diff --git a/tools/src/misc/CMakeLists.txt b/tools/src/misc/CMakeLists.txt
index 6b41d7f..1e9cacc 100644
--- a/tools/src/misc/CMakeLists.txt
+++ b/tools/src/misc/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_MISC C)
# --------------------------------------------------------------------
@@ -8,6 +8,7 @@ project (HDF5_TOOLS_SRC_MISC C)
if (NOT ONLY_SHARED_LIBS)
add_executable (h5debug ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5debug.c)
target_include_directories (h5debug PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5debug PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5debug STATIC)
target_link_libraries (h5debug PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5debug PROPERTIES FOLDER tools)
@@ -15,6 +16,7 @@ if (NOT ONLY_SHARED_LIBS)
add_executable (h5repart ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5repart.c)
target_include_directories (h5repart PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repart PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repart STATIC)
target_link_libraries (h5repart PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5repart PROPERTIES FOLDER tools)
@@ -22,6 +24,7 @@ if (NOT ONLY_SHARED_LIBS)
add_executable (h5mkgrp ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5mkgrp.c)
target_include_directories (h5mkgrp PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5mkgrp PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5mkgrp STATIC)
target_link_libraries (h5mkgrp PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5mkgrp PROPERTIES FOLDER tools)
@@ -29,6 +32,7 @@ if (NOT ONLY_SHARED_LIBS)
add_executable (h5clear ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5clear.c)
target_include_directories (h5clear PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5clear PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5clear STATIC)
target_link_libraries (h5clear PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5clear PROPERTIES FOLDER tools)
@@ -45,12 +49,14 @@ if (BUILD_SHARED_LIBS)
add_executable (h5debug-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5debug.c)
target_include_directories (h5debug-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5debug-shared SHARED)
+ target_compile_options(h5debug-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
target_link_libraries (h5debug-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5debug-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5debug-shared")
add_executable (h5repart-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5repart.c)
target_include_directories (h5repart-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repart-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repart-shared SHARED)
target_link_libraries (h5repart-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5repart-shared PROPERTIES FOLDER tools)
@@ -58,6 +64,7 @@ if (BUILD_SHARED_LIBS)
add_executable (h5mkgrp-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5mkgrp.c)
target_include_directories (h5mkgrp-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5mkgrp-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5mkgrp-shared SHARED)
target_link_libraries (h5mkgrp-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5mkgrp-shared PROPERTIES FOLDER tools)
@@ -65,6 +72,7 @@ if (BUILD_SHARED_LIBS)
add_executable (h5clear-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5clear.c)
target_include_directories (h5clear-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5clear-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5clear-shared SHARED)
target_link_libraries (h5clear-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5clear-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/misc/Makefile.in b/tools/src/misc/Makefile.in
index e240c12..d04e1fe 100644
--- a/tools/src/misc/Makefile.in
+++ b/tools/src/misc/Makefile.in
@@ -438,15 +438,15 @@ 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@
+AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@
# Include src directory
AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \
-I$(top_srcdir)/tools/lib
-AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
+AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
AM_JAVACFLAGS = @AM_JAVACFLAGS@
@@ -466,6 +466,7 @@ CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_VERSION = @CC_VERSION@
CFLAGS = @CFLAGS@
+CLANG_SANITIZE_CHECKS = @CLANG_SANITIZE_CHECKS@
CODESTACK = @CODESTACK@
CONFIG_DATE = @CONFIG_DATE@
CONFIG_MODE = @CONFIG_MODE@
@@ -482,6 +483,7 @@ DEFAULT_API_VERSION = @DEFAULT_API_VERSION@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
+DESIRED_FILE_LOCKING = @DESIRED_FILE_LOCKING@
DEV_WARNINGS = @DEV_WARNINGS@
DIRECT_VFD = @DIRECT_VFD@
DLLTOOL = @DLLTOOL@
@@ -518,8 +520,11 @@ H5_CFLAGS = @H5_CFLAGS@
H5_CLASSPATH = @H5_CLASSPATH@
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_IS_DARWIN = @H5_IS_DARWIN@
H5_JAVACFLAGS = @H5_JAVACFLAGS@
H5_JAVAFLAGS = @H5_JAVAFLAGS@
H5_JNIFLAGS = @H5_JNIFLAGS@
@@ -542,6 +547,7 @@ HL = @HL@
HL_FOR = @HL_FOR@
HSIZE_T = @HSIZE_T@
HSSIZE_T = @HSSIZE_T@
+IGNORE_DISABLED_FILE_LOCKS = @IGNORE_DISABLED_FILE_LOCKS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -578,6 +584,7 @@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMORYALLOCSANITYCHECK = @MEMORYALLOCSANITYCHECK@
+MIRROR_VFD = @MIRROR_VFD@
MKDIR_P = @MKDIR_P@
MPE = @MPE@
NM = @NM@
@@ -637,6 +644,7 @@ TIME = @TIME@
TR = @TR@
TRACE_API = @TRACE_API@
UNAME_INFO = @UNAME_INFO@
+USE_FILE_LOCKING = @USE_FILE_LOCKING@
USE_FILTER_DEFLATE = @USE_FILTER_DEFLATE@
USE_FILTER_SZIP = @USE_FILTER_SZIP@
USINGMEMCHECKER = @USINGMEMCHECKER@
@@ -672,6 +680,7 @@ docdir = $(exec_prefix)/doc
dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
+examplesdir = @examplesdir@
exec_prefix = @exec_prefix@
fortran_linux_linker_option = @fortran_linux_linker_option@
host = @host@
@@ -728,15 +737,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
@@ -777,7 +786,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 =
@@ -1389,28 +1398,37 @@ $(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_:
echo "============================" > $${log}; \
fi; \
if test "X$(FORTRAN_API)" = "Xyes"; then \
- echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
+ echo "Fortran API: Testing $${tname} $(TEST_FLAGS)"; \
if test -n "$(REALTIMEOUTPUT)"; then \
- echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \
+ echo "Fortran API: Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log}; \
else \
- echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
+ echo "Fortran API: Test log for $${tname} $(TEST_FLAGS)" >> $${log}; \
fi; \
elif test "X$(CXX_API)" = "Xyes"; then \
- echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
+ echo "C++ API: Testing $${tname} $(TEST_FLAGS)"; \
if test -n "$(REALTIMEOUTPUT)"; then \
- echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log};\
+ echo "C++ API: Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log};\
else \
- echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\
+ echo "C++ API: Test log for $${tname} $(TEST_FLAGS)" >> $${log};\
fi; \
else \
- echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
+ echo "Testing: $${tname} $(TEST_FLAGS)"; \
if test -n "$(REALTIMEOUTPUT)"; then \
- echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \
+ echo "Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log}; \
else \
- echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
+ echo "Test log for $${tname} $(TEST_FLAGS)" >> $${log}; \
fi; \
fi; \
if test -n "$(REALTIMEOUTPUT)"; then \
+ if test -n "$(HDF5_DRIVER)"; then \
+ echo "Virtual file driver (VFD): $(HDF5_DRIVER)" | tee -a $${log}; \
+ fi; \
+ else \
+ if test -n "$(HDF5_DRIVER)"; then \
+ echo "Virtual file driver (VFD): $(HDF5_DRIVER)" >> $${log}; \
+ fi; \
+ fi; \
+ if test -n "$(REALTIMEOUTPUT)"; then \
echo "============================" | tee -a $${log}; \
else \
echo "============================" >> $${log}; \
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index ae57031..96cbf9c 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -101,8 +101,13 @@ static void usage(const char *prog)
HDfprintf(stdout, " -s, --status Clear the status_flags field in the file's superblock\n");
HDfprintf(stdout, " -m, --image Remove the metadata cache image from the file\n");
HDfprintf(stdout, " --filesize Print the file's EOA and EOF\n");
- HDfprintf(stdout, " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>\n");
- HDfprintf(stdout, " C is >= 0; C is optional and will default to 1M when not set");
+ HDfprintf(stdout, " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for\n");
+ HDfprintf(stdout, " the file <file_name>.\n");
+ HDfprintf(stdout, " C is >= 0; C is optional and will default to 1M when not set.\n");
+ HDfprintf(stdout, " This option helps to repair a crashed file where the stored EOA\n");
+ HDfprintf(stdout, " in the superblock is different from the actual EOF.\n");
+ HDfprintf(stdout, " The file’s EOA and EOF will be the same after applying\n");
+ HDfprintf(stdout, " this option to the file.\n");
HDfprintf(stdout, "\n");
HDfprintf(stdout, "Examples of use:\n");
HDfprintf(stdout, "\n");
@@ -175,7 +180,7 @@ parse_command_line(int argc, const char **argv)
usage(h5tools_getprogname());
goto done;
}
- increment = HDatoi(opt_arg);
+ increment = (hsize_t)HDatoi(opt_arg);
}
break;
@@ -252,8 +257,8 @@ int
main (int argc, const char *argv[])
{
char *fname = NULL; /* File name */
- hid_t fapl = -1; /* File access property list */
- hid_t fid = -1; /* File ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
haddr_t image_addr;
hsize_t image_len;
unsigned flags = H5F_ACC_RDWR; /* file access flags */
@@ -261,9 +266,6 @@ main (int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable the HDF5 library's error reporting */
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* initialize h5tools lib */
h5tools_init();
@@ -274,6 +276,9 @@ main (int argc, const char *argv[])
if(fname_g == NULL)
goto done;
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Print usage/exit if not using at least one of the options */
if(!clear_status_flags && !remove_cache_image &&
!increment_eoa_eof && !print_filesize) {
@@ -339,7 +344,7 @@ main (int argc, const char *argv[])
}
/* Open the file */
- if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) {
+ if((fid = h5tools_fopen(fname, flags, fapl, FALSE, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -380,7 +385,6 @@ main (int argc, const char *argv[])
warn_msg("No cache image in the file\n");
}
-
h5tools_setstatus(EXIT_SUCCESS);
done:
diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c
index b28457e..bc7e9a3 100644
--- a/tools/src/misc/h5debug.c
+++ b/tools/src/misc/h5debug.c
@@ -15,7 +15,7 @@
*
* Created: debug.c
* Jul 18 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Robb Matzke
*
* Purpose: Debugs an existing HDF5 file at a low level.
*
@@ -68,7 +68,6 @@
* Return: Non-NULL on success/NULL on failure
*
* Programmer: Quincey Koziol
- * koziol@hdfgroup.org
* Sep 11 2008
*
*-------------------------------------------------------------------------
@@ -77,65 +76,64 @@ static const H5B2_class_t *
get_H5B2_class(const uint8_t *sig)
{
H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5B2_class_t *cls;
+ const H5B2_class_t *cls = NULL;
switch(subtype) {
- case H5B2_TEST_ID:
- cls = H5B2_TEST;
- break;
-
- case H5B2_FHEAP_HUGE_INDIR_ID:
- cls = H5HF_HUGE_BT2_INDIR;
- break;
-
- case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
- cls = H5HF_HUGE_BT2_FILT_INDIR;
- break;
-
- case H5B2_FHEAP_HUGE_DIR_ID:
- cls = H5HF_HUGE_BT2_DIR;
- break;
-
- case H5B2_FHEAP_HUGE_FILT_DIR_ID:
- cls = H5HF_HUGE_BT2_FILT_DIR;
- break;
-
- case H5B2_GRP_DENSE_NAME_ID:
- cls = H5G_BT2_NAME;
- break;
-
- case H5B2_GRP_DENSE_CORDER_ID:
- cls = H5G_BT2_CORDER;
- break;
-
- case H5B2_SOHM_INDEX_ID:
- cls = H5SM_INDEX;
- break;
-
- case H5B2_ATTR_DENSE_NAME_ID:
- cls = H5A_BT2_NAME;
- break;
-
- case H5B2_ATTR_DENSE_CORDER_ID:
- cls = H5A_BT2_CORDER;
- break;
-
- case H5B2_CDSET_ID:
- cls = H5D_BT2;
- break;
-
- case H5B2_CDSET_FILT_ID:
- cls = H5D_BT2_FILT;
- break;
-
- case H5B2_TEST2_ID:
- cls = H5B2_TEST2;
- break;
-
- case H5B2_NUM_BTREE_ID:
- default:
- HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
+ case H5B2_TEST_ID:
+ cls = H5B2_TEST;
+ break;
+
+ case H5B2_FHEAP_HUGE_INDIR_ID:
+ cls = H5HF_HUGE_BT2_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_DIR_ID:
+ cls = H5HF_HUGE_BT2_DIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_DIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_DIR;
+ break;
+
+ case H5B2_GRP_DENSE_NAME_ID:
+ cls = H5G_BT2_NAME;
+ break;
+
+ case H5B2_GRP_DENSE_CORDER_ID:
+ cls = H5G_BT2_CORDER;
+ break;
+
+ case H5B2_SOHM_INDEX_ID:
+ cls = H5SM_INDEX;
+ break;
+
+ case H5B2_ATTR_DENSE_NAME_ID:
+ cls = H5A_BT2_NAME;
+ break;
+
+ case H5B2_ATTR_DENSE_CORDER_ID:
+ cls = H5A_BT2_CORDER;
+ break;
+
+ case H5B2_CDSET_ID:
+ cls = H5D_BT2;
+ break;
+
+ case H5B2_CDSET_FILT_ID:
+ cls = H5D_BT2_FILT;
+ break;
+
+ case H5B2_TEST2_ID:
+ cls = H5B2_TEST2;
+ break;
+
+ case H5B2_NUM_BTREE_ID:
+ default:
+ HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype));
} /* end switch */
return(cls);
@@ -152,7 +150,6 @@ get_H5B2_class(const uint8_t *sig)
* Return: Non-NULL on success/NULL on failure
*
* Programmer: Quincey Koziol
- * koziol@hdfgroup.org
* Sep 11 2008
*
*-------------------------------------------------------------------------
@@ -161,25 +158,24 @@ static const H5EA_class_t *
get_H5EA_class(const uint8_t *sig)
{
H5EA_cls_id_t clsid = (H5EA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5EA_class_t *cls;
+ const H5EA_class_t *cls = NULL;
switch(clsid) {
- case H5EA_CLS_TEST_ID:
- cls = H5EA_CLS_TEST;
- break;
-
- case H5EA_CLS_CHUNK_ID:
- cls = H5EA_CLS_CHUNK;
- break;
-
- case H5EA_CLS_FILT_CHUNK_ID:
- cls = H5EA_CLS_FILT_CHUNK;
- break;
-
- case H5EA_NUM_CLS_ID:
- default:
- HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid));
- HDexit(4);
+ case H5EA_CLS_TEST_ID:
+ cls = H5EA_CLS_TEST;
+ break;
+
+ case H5EA_CLS_CHUNK_ID:
+ cls = H5EA_CLS_CHUNK;
+ break;
+
+ case H5EA_CLS_FILT_CHUNK_ID:
+ cls = H5EA_CLS_FILT_CHUNK;
+ break;
+
+ case H5EA_NUM_CLS_ID:
+ default:
+ HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid));
} /* end switch */
return(cls);
@@ -196,7 +192,6 @@ get_H5EA_class(const uint8_t *sig)
* Return: Non-NULL on success/NULL on failure
*
* Programmer: Quincey Koziol
- * koziol@hdfgroup.org
* Sep 11 2008
*
*-------------------------------------------------------------------------
@@ -205,25 +200,24 @@ static const H5FA_class_t *
get_H5FA_class(const uint8_t *sig)
{
H5FA_cls_id_t clsid = (H5FA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5FA_class_t *cls;
+ const H5FA_class_t *cls = NULL;
switch(clsid) {
- case H5FA_CLS_TEST_ID:
- cls = H5FA_CLS_TEST;
- break;
-
- case H5FA_CLS_CHUNK_ID:
- cls = H5FA_CLS_CHUNK;
- break;
-
- case H5FA_CLS_FILT_CHUNK_ID:
- cls = H5FA_CLS_FILT_CHUNK;
- break;
-
- case H5FA_NUM_CLS_ID:
- default:
- HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid));
- HDexit(4);
+ case H5FA_CLS_TEST_ID:
+ cls = H5FA_CLS_TEST;
+ break;
+
+ case H5FA_CLS_CHUNK_ID:
+ cls = H5FA_CLS_CHUNK;
+ break;
+
+ case H5FA_CLS_FILT_CHUNK_ID:
+ cls = H5FA_CLS_FILT_CHUNK;
+ break;
+
+ case H5FA_NUM_CLS_ID:
+ default:
+ HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid));
} /* end switch */
return(cls);
@@ -240,7 +234,6 @@ get_H5FA_class(const uint8_t *sig)
* Failure: exit (non-zero)
*
* Programmer: Robb Matzke
- * matzke@llnl.gov
* Jul 18 1997
*
*-------------------------------------------------------------------------
@@ -248,25 +241,31 @@ get_H5FA_class(const uint8_t *sig)
int
main(int argc, char *argv[])
{
- hid_t fid, fapl;
+ hid_t fid = H5I_INVALID_HID;
+ hid_t fapl = H5I_INVALID_HID;
H5F_t *f;
- haddr_t addr = 0, extra = 0, extra2 = 0, extra3 = 0, extra4 = 0;
+ haddr_t addr = 0;
+ int extra_count = 0; /* Number of extra arguments */
+ haddr_t extra[10];
uint8_t sig[H5F_SIGNATURE_LEN];
size_t u;
H5E_auto2_t func;
void *edata;
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t status = SUCCEED;
+ int exit_value = 0;
if(argc == 1) {
- HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]]\n", argv[0]);
- HDexit(1);
+ HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]*]\n", argv[0]);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Initialize the library */
if(H5open() < 0) {
HDfprintf(stderr, "cannot initialize the library\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Disable error reporting */
@@ -278,49 +277,65 @@ main(int argc, char *argv[])
*/
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
HDfprintf(stderr, "cannot create file access property list\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
if(HDstrchr(argv[1], '%'))
if(H5Pset_fapl_family (fapl, (hsize_t)0, H5P_DEFAULT) < 0) {
HDfprintf(stderr, "cannot set file access property list\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
if((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) {
HDfprintf(stderr, "cannot open file\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Push API context */
if(H5CX_push() < 0) {
HDfprintf(stderr, "cannot set API context\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(fid))) {
HDfprintf(stderr, "cannot obtain H5F_t pointer\n");
- HDexit(2);
+ exit_value = 2;
+ goto done;
} /* end if */
/* Ignore metadata tags while using h5debug */
if(H5AC_ignore_tags(f) < 0) {
HDfprintf(stderr, "cannot ignore metadata tags\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
/*
* Parse command arguments.
*/
+
+ /* Primary data structure to dump */
if(argc > 2)
addr = (haddr_t)HDstrtoll(argv[2], NULL, 0);
- if(argc > 3)
- extra = (haddr_t)HDstrtoll(argv[3], NULL, 0);
- if(argc > 4)
- extra2 = (haddr_t)HDstrtoll(argv[4], NULL, 0);
- if(argc > 5)
- extra3 = (haddr_t)HDstrtoll(argv[5], NULL, 0);
- if(argc > 6)
- extra4 = (haddr_t)HDstrtoll(argv[6], NULL, 0);
+
+ /* Extra arguments for primary data structure */
+ HDmemset(extra, 0, sizeof(extra));
+ if(argc > 3) {
+ /* Number of extra arguments */
+ extra_count = argc - 3;
+
+ /* Range check against 'extra' array size */
+ if(extra_count > (int)(sizeof(extra) / sizeof(haddr_t))) {
+ HDfprintf(stderr, "\nWARNING: Only using first %d extra parameters\n\n", (int)(sizeof(extra) / sizeof(haddr_t)));
+ extra_count = (int)(sizeof(extra) / sizeof(haddr_t));
+ } /* end if */
+
+ for(u = 0; u < (size_t)extra_count; u++)
+ extra[u] = (haddr_t)HDstrtoll(argv[u + 3], NULL, 0);
+ } /* end if */
/*
* Read the signature at the specified file position.
@@ -328,7 +343,8 @@ main(int argc, char *argv[])
HDfprintf(stdout, "Reading signature at address %a (rel)\n", addr);
if(H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), sig) < 0) {
HDfprintf(stderr, "cannot read signature\n");
- HDexit(3);
+ exit_value = 3;
+ goto done;
}
if(!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) {
/*
@@ -356,13 +372,13 @@ main(int argc, char *argv[])
*/
/* Check for extra parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
HDfprintf(stderr, "Symbol table node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Symbol table node address> <address of local heap>\n\n");
} /* end if */
- status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra);
+ status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]);
}
else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -378,46 +394,51 @@ main(int argc, char *argv[])
switch(subtype) {
case H5B_SNODE_ID:
/* Check for extra parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
HDfprintf(stderr, "B-tree symbol table node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <address of local heap>\n\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra);
+ status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]);
break;
case H5B_CHUNK_ID:
/* Check for extra parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n");
HDfprintf(stderr, "B-tree chunked storage node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- /* Build array of chunk dimensions */
- ndims = (unsigned)extra;
- dim[0] = (uint32_t)extra2;
- if(ndims > 1)
- dim[1] = (uint32_t)extra3;
- if(ndims > 2)
- dim[2] = (uint32_t)extra4;
+ /* Set # of dimensions */
+ ndims = (unsigned)extra[0];
/* Check for dimension error */
- if(ndims > 3) {
- HDfprintf(stderr, "ERROR: Only 3 dimensions support currently (fix h5debug)\n");
+ if(ndims > 9) {
+ HDfprintf(stderr, "ERROR: Only 9 dimensions support currently (fix h5debug)\n");
HDfprintf(stderr, "B-tree chunked storage node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end for */
+
+ /* Build array of chunk dimensions */
+ for(u = 0; u < ndims; u++)
+ dim[u] = (uint32_t)extra[u + 1];
+
+ /* Check for dimension error */
for(u = 0; u < ndims; u++)
if(0 == dim[u]) {
HDfprintf(stderr, "ERROR: Chunk dimensions should be >0\n");
HDfprintf(stderr, "B-tree chunked storage node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
/* Set the last dimension (the element size) to zero */
@@ -429,7 +450,8 @@ main(int argc, char *argv[])
case H5B_NUM_BTREE_ID:
default:
HDfprintf(stderr, "Unknown v1 B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
+ exit_value = 4;
+ goto done;
}
}
@@ -440,14 +462,15 @@ main(int argc, char *argv[])
const H5B2_class_t *cls = get_H5B2_class(sig);
HDassert(cls);
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && extra == 0) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0)) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "v2 B-tree hdr usage:\n");
HDfprintf(stderr, "\th5debug <filename> <v2 B-tree header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra);
+ status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra[0]);
}
else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -458,23 +481,25 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 || extra4 == 0)) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 || extra[3] == 0)) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object header address containing the layout message in order to dump internal node\n");
HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
}
- else if(extra == 0 || extra2 == 0 || extra3 == 0) {
+ else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and depth in order to dump internal node\n");
HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (unsigned)extra3, (haddr_t)extra4);
+ status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (unsigned)extra[2], (haddr_t)extra[3]);
}
else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -485,22 +510,24 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 )) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 )) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header address containing the layout message in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
}
- else if(extra == 0 || extra2 == 0) {
+ else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (haddr_t)extra3);
+ status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (haddr_t)extra[2]);
}
else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -516,14 +543,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to dump direct block\n");
HDfprintf(stderr, "Fractal heap direct block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <direct block address> <heap header address> <size of direct block>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra, (size_t)extra2);
+ status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra[0], (size_t)extra[1]);
}
else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -532,14 +560,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump indirect block\n");
HDfprintf(stderr, "Fractal heap indirect block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <indirect block address> <heap header address> <number of rows>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra, (unsigned)extra2);
+ status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra[0], (unsigned)extra[1]);
}
else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -556,14 +585,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump serialized sections\n");
HDfprintf(stderr, "Free space serialized sections usage:\n");
HDfprintf(stderr, "\th5debug <filename> <serialized sections address> <free space header address> <client address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra, extra2);
+ status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra[0], extra[1]);
}
else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -580,14 +610,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need shared message header address in order to shared message list\n");
HDfprintf(stderr, "Shared message list usage:\n");
HDfprintf(stderr, "\th5debug <filename> <shared message list address> <shared message header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra);
+ status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra[0]);
}
else if(!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -598,14 +629,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "Extensible array header block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Extensible Array header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra);
+ status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]);
}
else if(!HDmemcmp(sig, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -616,14 +648,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need extensible array header address and object header address containing the layout message in order to dump index block\n");
HDfprintf(stderr, "Extensible array index block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <index block address> <array header address> <object header address\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__iblock_debug(f, addr, stdout, 0, VCOL, cls, extra, extra2);
+ status = H5EA__iblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]);
}
else if(!HDmemcmp(sig, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -634,14 +667,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
HDfprintf(stderr, "ERROR: Need extensible array header address, super block index and object header address containing the layout message in order to dump super block\n");
HDfprintf(stderr, "Extensible array super block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <super block address> <array header address> <super block index> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, extra3);
+ status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], extra[2]);
}
else if(!HDmemcmp(sig, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -652,14 +686,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
HDfprintf(stderr, "ERROR: Need extensible array header address, # of elements in data block and object header address containing the layout message in order to dump data block\n");
HDfprintf(stderr, "Extensible array data block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <data block address> <array header address> <# of elements in data block> <object header address\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra, (size_t)extra2, extra3);
+ status = H5EA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (size_t)extra[1], extra[2]);
}
else if(!HDmemcmp(sig, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -670,14 +705,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "Fixed array header block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Fixed Array header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra);
+ status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]);
}
else if(!HDmemcmp(sig, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -688,14 +724,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need fixed array header address and object header address containing the layout message in order to dump data block\n");
HDfprintf(stderr, "fixed array data block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <data block address> <array header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra, extra2);
+ status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]);
}
else if(!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -732,24 +769,27 @@ main(int argc, char *argv[])
HDputchar('\n');
HDfprintf(stderr, "unknown signature\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end else */
/* Check for an error when dumping information */
if(status < 0) {
HDfprintf(stderr, "An error occurred!\n");
H5Eprint2(H5E_DEFAULT, stderr);
- HDexit(5);
+ exit_value = 5;
+ goto done;
} /* end if */
- H5Pclose(fapl);
- H5Fclose(fid);
+done:
+ if(fapl > 0) H5Pclose(fapl);
+ if(fid > 0) H5Fclose(fid);
/* Pop API context */
if(api_ctx_pushed) H5CX_pop();
H5Eset_auto2(H5E_DEFAULT, func, edata);
- return 0;
+ return exit_value;
} /* main() */
diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c
index feb60d4..2046373 100644
--- a/tools/src/misc/h5mkgrp.c
+++ b/tools/src/misc/h5mkgrp.c
@@ -25,24 +25,26 @@ int d_status = EXIT_SUCCESS;
/* command-line options: short and long-named parameters */
static const char *s_opts = "hlpvV";
static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "latest", no_arg, 'l' },
- { "parents", no_arg, 'p' },
- { "verbose", no_arg, 'v' },
- { "version", no_arg, 'V' },
+ { "help", no_arg, 'h' },
+ { "latest", no_arg, 'l' },
+ { "parents", no_arg, 'p' },
+ { "verbose", no_arg, 'v' },
+ { "version", no_arg, 'V' },
{ NULL, 0, '\0' }
};
/* Command line parameter settings */
-typedef struct {
+typedef struct mkgrp_opt_t {
char *fname; /* File name to operate on */
hbool_t latest; /* Whether file should use latest format versions */
hbool_t verbose; /* Whether output should be verbose */
hbool_t parents; /* Whether to create intermediate groups */
size_t ngroups; /* Number of groups to create */
char **groups; /* Pointer to array of group names */
-} param_t;
-param_t params; /* Command line parameter settings */
+ hid_t fapl_id; /* fapl to use when opening the file */
+} mkgrp_opt_t;
+
+mkgrp_opt_t params_g; /* Command line parameter settings */
/*-------------------------------------------------------------------------
@@ -61,13 +63,17 @@ leave(int ret)
{
size_t curr_group;
- if (params.fname)
- HDfree (params.fname);
- if (params.ngroups) {
- for(curr_group = 0; curr_group < params.ngroups; curr_group++)
- HDfree (params.groups[curr_group]);
- HDfree (params.groups);
+ if (params_g.fname)
+ HDfree(params_g.fname);
+ if (params_g.ngroups) {
+ for (curr_group = 0; curr_group < params_g.ngroups; curr_group++)
+ HDfree(params_g.groups[curr_group]);
+ HDfree(params_g.groups);
}
+ if (H5I_INVALID_HID != params_g.fapl_id && H5P_DEFAULT != params_g.fapl_id)
+ if (H5Pclose(params_g.fapl_id) < 0)
+ error_msg("Could not close file access property list\n");
+
h5tools_close();
HDexit(ret);
} /* end leave() */
@@ -85,65 +91,67 @@ leave(int ret)
*-------------------------------------------------------------------------
*/
static void
-usage(void)
+usage(const char *prog)
{
- HDfprintf(stdout, "\
-usage: h5mkgrp [OPTIONS] FILE GROUP...\n\
- OPTIONS\n\
- -h, --help Print a usage message and exit\n\
- -l, --latest Use latest version of file format to create groups\n\
- -p, --parents No error if existing, make parent groups as needed\n\
- -v, --verbose Print information about OBJECTS and OPTIONS\n\
- -V, --version Print version number and exit\n");
+ FLUSHSTREAM(rawoutstream);
+ PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] FILE GROUP...\n", prog);
+ PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
+ PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n");
+ PRINTVALSTREAM(rawoutstream, " -l, --latest Use latest version of file format to create groups\n");
+ PRINTVALSTREAM(rawoutstream, " -p, --parents No error if existing, make parent groups as needed\n");
+ PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n");
+ PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
} /* end usage() */
/*-------------------------------------------------------------------------
- * Function: parse_command_line
+ * Function: parse_command_line
*
- * Purpose: Parses command line and sets up global variable to control output
+ * Purpose: Parses command line and sets up global variable to control
+ * output
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
* Programmer: Quincey Koziol, 2/13/2007
*
*-------------------------------------------------------------------------
*/
static int
-parse_command_line(int argc, const char *argv[], param_t *parms)
+parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options)
{
int opt; /* Option from command line */
size_t curr_group; /* Current group name to copy */
/* Check for empty command line */
if(argc == 1) {
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
- } /* end if */
+ }
/* Parse command line options */
while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch((char)opt) {
/* Display 'help' */
case 'h':
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
/* Create objects with the latest version of the format */
case 'l':
- parms->latest = TRUE;
+ options->latest = TRUE;
break;
/* Create parent groups */
case 'p':
- parms->parents = TRUE;
+ options->parents = TRUE;
break;
/* Verbose output */
case 'v':
- parms->verbose = TRUE;
+ options->verbose = TRUE;
break;
/* Display version */
@@ -154,7 +162,7 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
/* Bad command line argument */
default:
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end switch */
} /* end while */
@@ -162,43 +170,34 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
/* Check for file name to be processed */
if(argc <= opt_ind) {
error_msg("missing file name\n");
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Retrieve file name */
- parms->fname = HDstrdup(argv[opt_ind]);
+ options->fname = HDstrdup(argv[opt_ind]);
opt_ind++;
/* Check for group(s) to be created */
if(argc <= opt_ind) {
error_msg("missing group name(s)\n");
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Allocate space for the group name pointers */
- parms->ngroups = (size_t)(argc - opt_ind);
- parms->groups = (char **)HDmalloc(parms->ngroups * sizeof(char *));
+ options->ngroups = (size_t)(argc - opt_ind);
+ options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *));
/* Retrieve the group names */
curr_group = 0;
while(opt_ind < argc) {
- parms->groups[curr_group] = HDstrdup(argv[opt_ind]);
+ options->groups[curr_group] = HDstrdup(argv[opt_ind]);
curr_group++;
opt_ind++;
- } /* end while */
-
-#ifdef QAK
-HDfprintf(stderr, "parms->parents = %t\n", parms->parents);
-HDfprintf(stderr, "parms->verbose = %t\n", parms->verbose);
-HDfprintf(stderr, "parms->fname = '%s'\n", parms->fname);
-HDfprintf(stderr, "parms->ngroups = %Zu\n", parms->ngroups);
-for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
- HDfprintf(stderr, "parms->group[%Zu] = '%s'\n", curr_group, parms->groups[curr_group]);
-#endif /* QAK */
+ }
- return(0);
+ return 0;
} /* parse_command_line() */
@@ -214,117 +213,112 @@ for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
int
main(int argc, const char *argv[])
{
- hid_t fid; /* HDF5 file ID */
- hid_t fapl_id; /* File access property list ID */
- hid_t lcpl_id; /* Link creation property list ID */
- size_t curr_group; /* Current group to create */
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t lcpl_id = H5I_INVALID_HID; /* Link creation property list ID */
+ size_t curr_group; /* Current group to create */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable the HDF5 library's error reporting */
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Parse command line */
- HDmemset(&params, 0, sizeof(params));
- if(parse_command_line(argc, argv, &params) < 0) {
- error_msg("unable to parse command line arguments\n");
- leave(EXIT_FAILURE);
- } /* end if */
+ /* Initialize the parameters */
+ HDmemset(&params_g, 0, sizeof(params_g));
/* Create file access property list */
- if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if((params_g.fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("Could not create file access property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
+
+ /* Parse command line */
+ if(parse_command_line(argc, argv, &params_g) < 0) {
+ error_msg("unable to parse command line arguments\n");
+ leave(EXIT_FAILURE);
+ }
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/* Check for creating groups with new format version */
- if(params.latest) {
+ if(params_g.latest) {
/* Set the "use the latest version of the format" bounds */
- if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ if(H5Pset_libver_bounds(params_g.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
error_msg("Could not set property for using latest version of the format\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
+ if(params_g.verbose)
HDprintf("%s: Creating groups with latest version of the format\n", h5tools_getprogname());
- } /* end if */
+ }
/* Attempt to open an existing HDF5 file first */
- fid = h5tools_fopen(params.fname, H5F_ACC_RDWR, fapl_id, NULL, NULL, 0);
+ fid = h5tools_fopen(params_g.fname, H5F_ACC_RDWR, params_g.fapl_id, FALSE, NULL, 0);
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
if(fid < 0)
- fid = H5Fcreate(params.fname, H5F_ACC_EXCL, H5P_DEFAULT, fapl_id);
+ fid = H5Fcreate(params_g.fname, H5F_ACC_EXCL, H5P_DEFAULT, params_g.fapl_id);
/* Test for error in opening file */
if(fid < 0) {
- error_msg("Could not open output file '%s'\n", params.fname);
+ error_msg("Could not open output file '%s'\n", params_g.fname);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Create link creation property list */
if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
error_msg("Could not create link creation property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Check for creating intermediate groups */
- if(params.parents) {
+ if(params_g.parents) {
/* Set the intermediate group creation property */
if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
error_msg("Could not set property for creating parent groups\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
+ if(params_g.verbose)
HDprintf("%s: Creating parent groups\n", h5tools_getprogname());
- } /* end if */
+ }
/* Loop over creating requested groups */
- for(curr_group = 0; curr_group < params.ngroups; curr_group++) {
+ for(curr_group = 0; curr_group < params_g.ngroups; curr_group++) {
hid_t gid; /* Group ID */
/* Attempt to create a group */
- if((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- error_msg("Could not create group '%s'\n", params.groups[curr_group]);
+ if((gid = H5Gcreate2(fid, params_g.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ error_msg("Could not create group '%s'\n", params_g.groups[curr_group]);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Close the group */
if(H5Gclose(gid) < 0) {
- error_msg("Could not close group '%s'??\n", params.groups[curr_group]);
+ error_msg("Could not close group '%s'??\n", params_g.groups[curr_group]);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
- HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params.groups[curr_group]);
+ if(params_g.verbose)
+ HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params_g.groups[curr_group]);
} /* end for */
/* Close link creation property list */
if(H5Pclose(lcpl_id) < 0) {
error_msg("Could not close link creation property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Close file */
if(H5Fclose(fid) < 0) {
- error_msg("Could not close output file '%s'??\n", params.fname);
+ error_msg("Could not close output file '%s'??\n", params_g.fname);
leave(EXIT_FAILURE);
- } /* end if */
-
- /* Close file access property list */
- if(H5Pclose(fapl_id) < 0) {
- error_msg("Could not close file access property list\n");
- leave(EXIT_FAILURE);
- } /* end if */
+ }
leave(EXIT_SUCCESS);
} /* end main() */
diff --git a/tools/src/misc/h5repart.c b/tools/src/misc/h5repart.c
index d516fa0..371cf2c 100644
--- a/tools/src/misc/h5repart.c
+++ b/tools/src/misc/h5repart.c
@@ -12,7 +12,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Programmer: Robb Matzke
* Wednesday, May 13, 1998
*
* Purpose: Repartitions a file family. This program can be used to