diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2012-07-25 22:17:48 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2012-07-25 22:17:48 (GMT) |
commit | dd27fe612cf9c80d223939a46a96202eaf81f60d (patch) | |
tree | 0deae7b9c4824be7e84aa7e232a529a9ae125c60 | |
parent | c04144fb39b6d7a489c37e89ac8a0240991026a6 (diff) | |
download | hdf5-dd27fe612cf9c80d223939a46a96202eaf81f60d.zip hdf5-dd27fe612cf9c80d223939a46a96202eaf81f60d.tar.gz hdf5-dd27fe612cf9c80d223939a46a96202eaf81f60d.tar.bz2 |
[svn-r22602]
-rw-r--r-- | CMakeLists.txt | 56 | ||||
-rw-r--r-- | config/cmake/FindHDF5.cmake | 85 | ||||
-rw-r--r-- | config/cmake/FindHDF5.cmake.in | 4 | ||||
-rw-r--r-- | config/cmake/H5pubconf.h.in | 18 | ||||
-rw-r--r-- | config/cmake/HDFLibMacros.cmake | 6 | ||||
-rwxr-xr-x | config/cmake/cacheinit.cmake | 6 | ||||
-rw-r--r-- | config/cmake/hdf5-config.cmake.build.in | 12 | ||||
-rw-r--r-- | config/cmake/hdf5-config.cmake.install.in | 10 | ||||
-rw-r--r-- | config/cmake/libhdf5.settings.cmake.in | 2 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 355 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 3 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 873 |
13 files changed, 705 insertions, 729 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0346ff3..4e688ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,7 +157,11 @@ IF (NOT HDF5_INSTALL_INCLUDE_DIR) SET (HDF5_INSTALL_INCLUDE_DIR include) ENDIF (NOT HDF5_INSTALL_INCLUDE_DIR) IF (NOT HDF5_INSTALL_DATA_DIR) - SET (HDF5_INSTALL_DATA_DIR share) + IF (NOT WIN32) + SET (HDF5_INSTALL_DATA_DIR share) + ELSE (NOT WIN32) + SET (HDF5_INSTALL_DATA_DIR ".") + ENDIF (NOT WIN32) ENDIF (NOT HDF5_INSTALL_DATA_DIR) #----------------------------------------------------------------------------- @@ -201,7 +205,7 @@ ELSE (NOT "${H5_VERS_SUBRELEASE}" STREQUAL "") ENDIF (NOT "${H5_VERS_SUBRELEASE}" STREQUAL "") SET (HDF5_PACKAGE_SOVERSION "${H5_SOVERS_MAJOR}.${H5_SOVERS_MINOR}.${H5_SOVERS_RELEASE}") SET (HDF5_PACKAGE_STRING "${HDF5_PACKAGE_NAME} ${HDF5_PACKAGE_VERSION_STRING}") -SET (HDF5_PACKAGE_TARNAME "hdf5") +SET (HDF5_PACKAGE_TARNAME "${HDF5_PACKAGE}${HDF_PACKAGE_EXT}") SET (HDF5_PACKAGE_URL "http://www.hdfgroup.org") SET (HDF5_PACKAGE_BUGREPORT "help@hdfgroup.org") @@ -268,10 +272,10 @@ SET (H5_ENABLE_SHARED_LIB NO) SET (H5_ENABLE_STATIC_LIB NO) IF (BUILD_SHARED_LIBS) SET (LIB_TYPE SHARED) - SET (H5_BUILT_AS_DYNAMIC_LIB 1) + ADD_DEFINITIONS (-DH5_BUILT_AS_DYNAMIC_LIB) SET (H5_ENABLE_SHARED_LIB YES) ELSE (BUILD_SHARED_LIBS) - SET (H5_BUILT_AS_STATIC_LIB 1) + ADD_DEFINITIONS (-DH5_BUILT_AS_STATIC_LIB) SET (H5_ENABLE_STATIC_LIB YES) IF (NOT WIN32) # should this be a user setting : Everyone uses it anyway ? @@ -556,7 +560,7 @@ OPTION (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF) IF (HDF5_ENABLE_Z_LIB_SUPPORT) IF (NOT H5_ZLIB_HEADER) IF (NOT ZLIB_USE_EXTERNAL) - FIND_PACKAGE (ZLIB) + FIND_PACKAGE (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT}) ENDIF (NOT ZLIB_USE_EXTERNAL) IF (ZLIB_FOUND) SET (H5_HAVE_FILTER_DEFLATE 1) @@ -596,7 +600,7 @@ OPTION (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) IF (HDF5_ENABLE_SZIP_SUPPORT) OPTION (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) IF (NOT SZIP_USE_EXTERNAL) - FIND_PACKAGE (SZIP) + FIND_PACKAGE (SZIP NAMES ${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT}) ENDIF (NOT SZIP_USE_EXTERNAL) IF (SZIP_FOUND) SET (H5_HAVE_FILTER_SZIP 1) @@ -615,7 +619,7 @@ IF (HDF5_ENABLE_SZIP_SUPPORT) ENDIF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") ENDIF (SZIP_FOUND) SET (LINK_LIBS ${LINK_LIBS} ${SZIP_LIBRARIES}) - INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIR}) MESSAGE (STATUS "Filter SZIP is ON") IF (H5_HAVE_FILTER_SZIP) SET (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DECODE") @@ -831,8 +835,8 @@ ENDIF (NOT HDF5_INSTALL_NO_DEVELOPMENT) IF (NOT HDF5_EXTERNALLY_CONFIGURED) INSTALL ( EXPORT ${HDF5_EXPORTED_TARGETS} - DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/hdf5 - FILE hdf5-targets.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} + FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake COMPONENT configinstall ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -843,7 +847,7 @@ ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) IF (NOT HDF5_EXTERNALLY_CONFIGURED) EXPORT ( TARGETS ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} - FILE hdf5-targets.cmake + FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -860,20 +864,35 @@ SET (HDF5_VERSION_MINOR @HDF5_PACKAGE_VERSION_MINOR@) CONFIGURE_FILE ( ${HDF5_RESOURCES_DIR}/hdf5-config.cmake.build.in - ${HDF5_BINARY_DIR}/hdf5-config.cmake @ONLY + ${HDF5_BINARY_DIR}/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake @ONLY ) #----------------------------------------------------------------------------- +# Configure the FindHDF5.cmake file for the install directory +#----------------------------------------------------------------------------- +IF (NOT HDF5_EXTERNALLY_CONFIGURED) + CONFIGURE_FILE ( + ${HDF5_RESOURCES_DIR}/FindHDF5.cmake.in + ${HDF5_BINARY_DIR}/CMakeFiles/FindHDF5${HDF_PACKAGE_EXT}.cmake @ONLY + ) + INSTALL ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/FindHDF5${HDF_PACKAGE_EXT}.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} + COMPONENT configinstall + ) +ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) + +#----------------------------------------------------------------------------- # Configure the hdf5-config.cmake file for the install directory #----------------------------------------------------------------------------- IF (NOT HDF5_EXTERNALLY_CONFIGURED) CONFIGURE_FILE ( ${HDF5_RESOURCES_DIR}/hdf5-config.cmake.install.in - ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake @ONLY + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake @ONLY ) INSTALL ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake - DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/hdf5 + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} COMPONENT configinstall ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -884,11 +903,11 @@ ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) IF (NOT HDF5_EXTERNALLY_CONFIGURED) CONFIGURE_FILE ( ${HDF5_RESOURCES_DIR}/hdf5-config-version.cmake.in - ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config-version.cmake @ONLY + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config-version.cmake @ONLY ) INSTALL ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config-version.cmake - DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/hdf5 + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF5_PACKAGE_EXT}-config-version.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} COMPONENT configinstall ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -907,7 +926,7 @@ CONFIGURE_FILE ( ) INSTALL ( FILES ${HDF5_BINARY_DIR}/libhdf5.settings - DESTINATION ${HDF5_INSTALL_LIB_DIR} + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} COMPONENT libraries ) @@ -984,7 +1003,6 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) SET (CPACK_NSIS_PACKAGE_NAME "HDF5 ${HDF5_PACKAGE_VERSION}") ELSE (WIN32) SET (CPACK_PACKAGING_INSTALL_PREFIX "/usr") - SET (CPACK_ARCHIVE_COMPONENT_INSTALL ON) SET (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) SET (CPACK_DEBIAN_PACKAGE_SECTION "Libraries") diff --git a/config/cmake/FindHDF5.cmake b/config/cmake/FindHDF5.cmake deleted file mode 100644 index 33532b0..0000000 --- a/config/cmake/FindHDF5.cmake +++ /dev/null @@ -1,85 +0,0 @@ -#
-# To be used by projects that make use of Cmakeified hdf5-1.8
-#
-
-#
-# Find the HDF5 includes and get all installed hdf5 library settings from
-# HDF5-config.cmake file : Requires a CMake compatible hdf5-1.8.5 or later
-# for this feature to work. The following vars are set if hdf5 is found.
-#
-# HDF5_FOUND - True if found, otherwise all other vars are undefined
-# HDF5_INCLUDE_DIR - The include dir for main *.h files
-# HDF5_FORTRAN_INCLUDE_DIR - The include dir for fortran modules and headers
-# HDF5_VERSION_STRING - full version (e.g. 1.8.5)
-# HDF5_VERSION_MAJOR - major part of version (e.g. 1.8)
-# HDF5_VERSION_MINOR - minor part (e.g. 5)
-#
-# The following boolean vars will be defined
-# HDF5_ENABLE_PARALLEL - 1 if HDF5 parallel supported
-# HDF5_BUILD_FORTRAN - 1 if HDF5 was compiled with fortran on
-# HDF5_BUILD_CPP_LIB - 1 if HDF5 was compiled with cpp on
-# HDF5_BUILD_TOOLS - 1 if HDF5 was compiled with tools on
-# HDF5_BUILD_HL_LIB - 1 if HDF5 was compiled with high level on
-# HDF5_BUILD_HL_CPP_LIB - 1 if HDF5 was compiled with high level and cpp on
-#
-# Target names that are valid (depending on enabled options)
-# will be the following
-#
-# hdf5 : HDF5 C library
-# hdf5_tools : the tools library
-# hdf5_f90cstub : used by Fortran to C interface
-# hdf5_fortran : Fortran HDF5 library
-# hdf5_cpp : HDF5 cpp interface library
-# hdf5_hl : High Level library
-# hdf5_hl_f90cstub : used by Fortran to C interface to High Level library
-# hdf5_hl_fortran : Fortran High Level library
-# hdf5_hl_cpp : High Level cpp interface library
-#
-# To aid in finding HDF5 as part of a subproject set
-# HDF5_ROOT_DIR_HINT to the location where hdf5-config.cmake lies
-
-INCLUDE (SelectLibraryConfigurations)
-INCLUDE (FindPackageHandleStandardArgs)
-
-# The HINTS option should only be used for values computed from the system.
-SET (_HDF5_HINTS
- $ENV{HOME}/.local
- $ENV{HDF5_ROOT}
- $ENV{HDF5_ROOT_DIR_HINT}
-)
-# Hard-coded guesses should still go in PATHS. This ensures that the user
-# environment can always override hard guesses.
-SET (_HDF5_PATHS
- $ENV{HOME}/.local
- $ENV{HDF5_ROOT}
- $ENV{HDF5_ROOT_DIR_HINT}
- /usr/lib/hdf5
- /usr/share/hdf5
- /usr/local/hdf5
- /usr/local/hdf5/share
-)
-
-FIND_PATH (HDF5_ROOT_DIR "hdf5-config.cmake"
- HINTS ${_HDF5_HINTS}
- PATHS ${_HDF5_PATHS}
- PATH_SUFFIXES
- lib/cmake/hdf5
- share/cmake/hdf5
-)
-
-FIND_PATH (HDF5_INCLUDE_DIRS "H5public.h"
- HINTS ${_HDF5_HINTS}
- PATHS ${_HDF5_PATHS}
- PATH_SUFFIXES
- include
- Include
-)
-
-# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of
-# HDF5_INCLUDE_DIRS
-SET ( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" )
-
-IF (HDF5_INCLUDE_DIR)
- SET (HDF5_FOUND "YES")
- INCLUDE (${HDF5_ROOT_DIR}/hdf5-config.cmake)
-ENDIF (HDF5_INCLUDE_DIR)
diff --git a/config/cmake/FindHDF5.cmake.in b/config/cmake/FindHDF5.cmake.in index a866859..7be4de3 100644 --- a/config/cmake/FindHDF5.cmake.in +++ b/config/cmake/FindHDF5.cmake.in @@ -59,7 +59,7 @@ SET (_HDF5_PATHS /usr/local/@HDF5_PACKAGE@/share
)
-FIND_PATH (HDF5_ROOT_DIR "@HDF5_PACKAGE@@HDF5_PACKAGE_EXT@-config.cmake"
+FIND_PATH (HDF5_ROOT_DIR "@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-config.cmake"
HINTS ${_HDF5_HINTS}
PATHS ${_HDF5_PATHS}
PATH_SUFFIXES
@@ -81,5 +81,5 @@ SET ( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) IF (HDF5_INCLUDE_DIR)
SET (HDF5_FOUND "YES")
- INCLUDE (${HDF5_ROOT_DIR}/@HDF5_PACKAGE@@HDF5_PACKAGE_EXT@-config.cmake)
+ INCLUDE (${HDF5_ROOT_DIR}/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-config.cmake)
ENDIF (HDF5_INCLUDE_DIR)
diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 6fca1ae..71e8c10 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -15,24 +15,6 @@ /* Define if using a Windows compiler (i.e. Visual Studio) */ #cmakedefine H5_HAVE_VISUAL_STUDIO @H5_HAVE_VISUAL_STUDIO@ -/* Defined if HDF5 was built with CMake AND build as a shared library */ -#cmakedefine H5_BUILT_AS_DYNAMIC_LIB @H5_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 was built with CMake AND build as a static library */ -#cmakedefine H5_BUILT_AS_STATIC_LIB @H5_BUILT_AS_STATIC_LIB@ - -/* Defined if HDF5 CPP was built with CMake AND build as a shared library */ -#cmakedefine H5_CPP_BUILT_AS_DYNAMIC_LIB @H5_CPP_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 CPP was built with CMake AND build as a static library */ -#cmakedefine H5_CPP_BUILT_AS_STATIC_LIB @H5_CPP_BUILT_AS_STATIC_LIB@ - -/* Defined if HDF5 HL was built with CMake AND build as a shared library */ -#cmakedefine H5_HL_BUILT_AS_DYNAMIC_LIB @H5_HL_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 HL was built with CMake AND build as a static library */ -#cmakedefine H5_HL_BUILT_AS_STATIC_LIB @H5_HL_BUILT_AS_STATIC_LIB@ - /* Define if building universal (internal helper macro) */ #cmakedefine H5_AC_APPLE_UNIVERSAL_BUILD @H5_AC_APPLE_UNIVERSAL_BUILD@ diff --git a/config/cmake/HDFLibMacros.cmake b/config/cmake/HDFLibMacros.cmake index 7b54c95..57e6be7 100644 --- a/config/cmake/HDFLibMacros.cmake +++ b/config/cmake/HDFLibMacros.cmake @@ -10,6 +10,7 @@ MACRO (EXTERNAL_JPEG_LIBRARY compress_type libtype jpeg_pic) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DJPEG_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -25,6 +26,7 @@ MACRO (EXTERNAL_JPEG_LIBRARY compress_type libtype jpeg_pic) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DJPEG_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -122,6 +124,7 @@ MACRO (EXTERNAL_SZIP_LIBRARY compress_type libtype encoding) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DSZIP_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -138,6 +141,7 @@ MACRO (EXTERNAL_SZIP_LIBRARY compress_type libtype encoding) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DSZIP_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -236,6 +240,7 @@ MACRO (EXTERNAL_ZLIB_LIBRARY compress_type libtype) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DZLIB_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -251,6 +256,7 @@ MACRO (EXTERNAL_ZLIB_LIBRARY compress_type libtype) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DZLIB_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index e7dd19f..d45ef9e 100755 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -8,6 +8,8 @@ SET (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries" FORCE) SET (BUILD_TESTING ON CACHE BOOL "Build HDF5 Unit Testing" FORCE)
+SET (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE)
+
SET (HDF5_BUILD_CPP_LIB ON CACHE BOOL "Build HDF5 C++ Library" FORCE)
SET (HDF5_BUILD_EXAMPLES ON CACHE BOOL "Build HDF5 Library Examples" FORCE)
@@ -69,3 +71,7 @@ SET (SZIP_SVN_URL "http://svn.hdfgroup.uiuc.edu/szip/trunk" CACHE STRING "Use SZ SET (ZLIB_TGZ_NAME "ZLib.tar.gz" CACHE STRING "Use ZLib from compressed file" FORCE)
SET (SZIP_TGZ_NAME "SZip.tar.gz" CACHE STRING "Use SZip from compressed file" FORCE)
+
+SET (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE)
+
+SET (SZIP_PACKAGE_NAME "szip" CACHE STRING "Name of SZIP package" FORCE)
diff --git a/config/cmake/hdf5-config.cmake.build.in b/config/cmake/hdf5-config.cmake.build.in index ccf5e67..881985e 100644 --- a/config/cmake/hdf5-config.cmake.build.in +++ b/config/cmake/hdf5-config.cmake.build.in @@ -42,6 +42,12 @@ IF (HDF5_BUILD_TOOLS) SET (HDF5_INCLUDE_DIR_TOOLS ${HDF5_INCLUDE_DIR} )
ENDIF (HDF5_BUILD_TOOLS)
+IF (HDF5_BUILD_SHARED_LIBS)
+ SET (H5_BUILT_AS_DYNAMIC_LIB 1 )
+ELSE (HDF5_BUILD_SHARED_LIBS)
+ SET (H5_BUILT_AS_STATIC_LIB 1 )
+ENDIF (HDF5_BUILD_SHARED_LIBS)
+
#-----------------------------------------------------------------------------
# Version Strings
#-----------------------------------------------------------------------------
@@ -53,7 +59,7 @@ SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) # Don't include targets if this file is being picked up by another
# project which has already build hdf5 as a subproject
#-----------------------------------------------------------------------------
-IF (NOT TARGET "hdf5")
- INCLUDE (${SELF_DIR}/hdf5-targets.cmake)
+IF (NOT TARGET "@HDF5_PACKAGE@")
+ INCLUDE (${SELF_DIR}/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake)
SET (HDF5_LIBRARIES "@HDF5_LIBRARIES_TO_EXPORT@")
-ENDIF (NOT TARGET "hdf5")
+ENDIF (NOT TARGET "@HDF5_PACKAGE@")
diff --git a/config/cmake/hdf5-config.cmake.install.in b/config/cmake/hdf5-config.cmake.install.in index a851915..bc253e2 100644 --- a/config/cmake/hdf5-config.cmake.install.in +++ b/config/cmake/hdf5-config.cmake.install.in @@ -58,16 +58,16 @@ SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) # Don't include targets if this file is being picked up by another
# project which has already built hdf5 as a subproject
#-----------------------------------------------------------------------------
-IF (NOT TARGET "hdf5")
+IF (NOT TARGET "@HDF5_PACKAGE@")
IF (HDF5_ENABLE_Z_LIB_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "zlib")
- INCLUDE (${SELF_DIR}/../ZLIB/ZLIB-targets.cmake)
+ INCLUDE (${SELF_DIR}/../ZLIB/ZLIB@HDF_PACKAGE_EXT@-targets.cmake)
ENDIF (HDF5_ENABLE_Z_LIB_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "zlib")
IF (HDF5_ENABLE_SZIP_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "szip")
- INCLUDE (${SELF_DIR}/../SZIP/SZIP-targets.cmake)
+ INCLUDE (${SELF_DIR}/../SZIP/SZIP@HDF_PACKAGE_EXT@-targets.cmake)
ENDIF (HDF5_ENABLE_SZIP_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "szip")
- INCLUDE (${SELF_DIR}/hdf5-targets.cmake)
+ INCLUDE (${SELF_DIR}/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake)
SET (HDF5_LIBRARIES "@HDF5_LIBRARIES_TO_EXPORT@")
-ENDIF (NOT TARGET "hdf5")
+ENDIF (NOT TARGET "@HDF5_PACKAGE@")
#-----------------------------------------------------------------------------
# Unfinished
diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index 4027c55..22b223a 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -1,4 +1,4 @@ - SUMMARY OF THE HDF5 CONFIGURATION + SUMMARY OF THE @HDF5_PACKAGE@ CONFIGURATION ================================= General Information: diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 24aa81a..c7ff2d3 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1064,37 +1064,6 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) } /*------------------------------------------------------------------------- - * Function: do_bin_output - * - * Purpose: Dump memory buffer to a binary file stream - * - * Return: Success: SUCCEED - * Failure: FAIL - *------------------------------------------------------------------------- - */ -int -do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem) -{ - HERR_INIT(int, SUCCEED) - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ - hsize_t i; /* element counter */ - - if((size = H5Tget_size(tid)) == 0) - H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - - for (i = 0; i < nelmts; i++) { - if (render_bin_output(stream, container, tid, mem + i * size) < 0) { - HDfprintf(err_stream,"\nError in writing binary stream\n"); - return FAIL; - } - } - -CATCH - return ret_value; -} - -/*------------------------------------------------------------------------- * Function: render_bin_output * * Purpose: Write one element of memory buffer to a binary file stream @@ -1103,6 +1072,8 @@ CATCH * Failure: FAIL *------------------------------------------------------------------------- */ + +#ifdef DEBUG_H5DUMP_BIN int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) { @@ -1124,44 +1095,27 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) #if H5_SIZEOF_LONG_DOUBLE !=0 long double templdouble; #endif -#ifdef DEBUG_H5DUMP_BIN static char fmt_llong[8], fmt_ullong[8]; if (!fmt_llong[0]) { HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); } -#endif if((size = H5Tget_size(tid)) == 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); if (H5Tequal(tid, H5T_NATIVE_FLOAT)) { HDmemcpy(&tempfloat, mem, sizeof(float)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%g ", tempfloat); -#else - if (1 != HDfwrite(&tempfloat, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) { HDmemcpy(&tempdouble, mem, sizeof(double)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%g ", tempdouble); -#else - if (1 != HDfwrite(&tempdouble, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } #if H5_SIZEOF_LONG_DOUBLE !=0 else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) { HDmemcpy(&templdouble, mem, sizeof(long double)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%Lf ", templdouble); -#else - if (1 != HDfwrite(&templdouble, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } #endif else if (H5T_STRING == H5Tget_class(tid)) { @@ -1183,160 +1137,75 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) } for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d", tempuchar); -#else - if (1 != HDfwrite(&tempuchar, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } /* i */ } else if (H5Tequal(tid, H5T_NATIVE_INT)) { HDmemcpy(&tempint, mem, sizeof(int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempint); -#else - if (1 != HDfwrite(&tempint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_UINT)) { HDmemcpy(&tempuint, mem, sizeof(unsigned int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempuint); -#else - if (1 != HDfwrite(&tempuint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_SCHAR)) { HDmemcpy(&tempschar, mem, sizeof(char)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempschar); -#else - if (1 != HDfwrite(&tempschar, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_UCHAR)) { HDmemcpy(&tempuchar, mem, sizeof(unsigned char)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempuchar); -#else - if (1 != HDfwrite(&tempuchar, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_SHORT)) { HDmemcpy(&tempshort, mem, sizeof(short)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempshort); -#else - if (1 != HDfwrite(&tempshort, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_USHORT)) { HDmemcpy(&tempushort, mem, sizeof(unsigned short)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempushort); -#else - if (1 != HDfwrite(&tempushort, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_LONG)) { HDmemcpy(&templong, mem, sizeof(long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%ld ", templong); -#else - if (1 != HDfwrite(&templong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_ULONG)) { HDmemcpy(&tempulong, mem, sizeof(unsigned long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%lu ", tempulong); -#else - if (1 != HDfwrite(&tempulong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_LLONG)) { HDmemcpy(&templlong, mem, sizeof(long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_llong, templlong); -#else - if (1 != HDfwrite(&templlong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_ULLONG)) { HDmemcpy(&tempullong, mem, sizeof(unsigned long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_ullong, tempullong); -#else - if (1 != HDfwrite(&tempullong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_HSSIZE)) { if (sizeof(hssize_t) == sizeof(int)) { HDmemcpy(&tempint, mem, sizeof(int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempint); -#else - if (1 != HDfwrite(&tempint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (sizeof(hssize_t) == sizeof(long)) { HDmemcpy(&templong, mem, sizeof(long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%ld ", templong); -#else - if (1 != HDfwrite(&templong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { HDmemcpy(&templlong, mem, sizeof(long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_llong, templlong); -#else - if (1 != HDfwrite(&templlong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } } else if (H5Tequal(tid, H5T_NATIVE_HSIZE)) { if (sizeof(hsize_t) == sizeof(int)) { HDmemcpy(&tempuint, mem, sizeof(unsigned int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempuint); -#else - if (1 != HDfwrite(&tempuint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (sizeof(hsize_t) == sizeof(long)) { HDmemcpy(&tempulong, mem, sizeof(unsigned long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%lu ", tempulong); -#else - if (1 != HDfwrite(&tempulong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { HDmemcpy(&tempullong, mem, sizeof(unsigned long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_ullong, tempullong); -#else - if (1 != HDfwrite(&tempullong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } } else if (H5Tget_class(tid) == H5T_COMPOUND) { @@ -1360,21 +1229,11 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) else if (H5Tget_class(tid) == H5T_ENUM) { unsigned int i; if (1 == size) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "0x%02x", mem[0]); -#else - if (1 != HDfwrite(&mem[0], size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { for (i = 0; i < size; i++) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%s%02x", i?":":"", mem[i]); -#else - if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } /*i*/ }/*else 1 */ } @@ -1450,21 +1309,11 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) else { size_t i; if (1 == size) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "0x%02x", mem[0]); -#else - if (1 != HDfwrite(&mem[0], size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { for (i = 0; i < size; i++) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%s%02x", i?":":"", mem[i]); -#else - if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } /*i*/ }/*else 1 */ } @@ -1472,6 +1321,190 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) CATCH return ret_value; } +#else +int +render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) +{ + HERR_INIT(int, SUCCEED) + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + hsize_t block_index; + H5T_class_t type_class; + + if((size = H5Tget_size(tid)) == 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + + if((type_class = H5Tget_class(tid)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed"); + + switch (type_class) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_ENUM: + block_index = block_nelmts * size; + while(block_index > 0) { + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ + size_t item_size = size; /* size of items in bytes */ + + if(block_index > sizeof(size_t)) + bytes_in = sizeof(size_t); + else + bytes_in = (size_t)block_index; + + bytes_wrote = HDfwrite(mem, 1, bytes_in, stream); + + if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream))) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + + block_index -= (hsize_t)bytes_wrote; + mem = mem + bytes_wrote; + } + break; + case H5T_STRING: + { + unsigned int i; + H5T_str_t pad; + char *s; + unsigned char tempuchar; + + pad = H5Tget_strpad(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = _mem + block_index * size; + + if (H5Tis_variable_str(tid)) { + s = *(char**) mem; + if (s != NULL) + size = HDstrlen(s); + } + else { + s = (char *) mem; + } + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); + if (1 != HDfwrite(&tempuchar, size, 1, stream)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + } /* i */ + } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ + } + break; + case H5T_COMPOUND: + { + unsigned j; + hid_t memb; + unsigned nmembs; + size_t offset; + + nmembs = H5Tget_nmembers(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = _mem + block_index * size; + for (j = 0; j < nmembs; j++) { + offset = H5Tget_member_offset(tid, j); + memb = H5Tget_member_type(tid, j); + + if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) + return FAIL; + + H5Tclose(memb); + } + } + } + break; + case H5T_ARRAY: + { + int k, ndims; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hid_t memb; + + /* get the array's base datatype for each element */ + memb = H5Tget_super(tid); + ndims = H5Tget_array_ndims(tid); + H5Tget_array_dims2(tid, dims); + HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t) temp_nelmts; + } + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = _mem + block_index * size; + /* dump the array element */ + if (render_bin_output(stream, container, memb, mem, nelmts) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + } + H5Tclose(memb); + } + break; + case H5T_VLEN: + { + unsigned int i; + hsize_t nelmts; + hid_t memb; + + /* get the VL sequences's base datatype for each element */ + memb = H5Tget_super(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = _mem + block_index * size; + /* Get the number of sequence elements */ + nelmts = ((hvl_t *) mem)->len; + + /* dump the array element */ + if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + } + H5Tclose(memb); + } + break; + case H5T_REFERENCE: + { + if (H5Tequal(tid, H5T_STD_REF_DSETREG)) { + if (region_output) { + /* region data */ + hid_t region_id, region_space; + H5S_sel_type region_type; + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = _mem + block_index * size; + region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem); + if (region_id >= 0) { + region_space = H5Rget_region(container, H5R_DATASET_REGION, mem); + if (region_space >= 0) { + region_type = H5Sget_select_type(region_space); + if(region_type == H5S_SEL_POINTS) + render_bin_output_region_points(region_space, region_id, stream, container); + else + render_bin_output_region_blocks(region_space, region_id, stream, container); + H5Sclose(region_space); + } /* end if (region_space >= 0) */ + H5Dclose(region_id); + } /* end if (region_id >= 0) */ + } + } /* end if (region_output... */ + } + else if (H5Tequal(tid, H5T_STD_REF_OBJ)) { + ; + } + } + break; + default: + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = _mem + block_index * size; + if (size != HDfwrite(mem, sizeof(char), size, stream)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + } + break; + } + +CATCH + return ret_value; +} +#endif /*------------------------------------------------------------------------- * Audience: Public @@ -1552,12 +1585,8 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - for (numindex = 0; numindex < numelem; numindex++) { - - render_bin_output(stream, container, type_id, - ((char*)region_buf + numindex * type_size)); - /* Render the region data element end */ - } /* end for (jndx = 0; jndx < numelem; jndx++) */ + render_bin_output(stream, container, type_id, (char*)region_buf, numelem); + /* Render the region data element end */ } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ done: @@ -1684,12 +1713,10 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id, if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); - for (jndx = 0; jndx < npoints; jndx++) { - if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - render_bin_output(stream, container, type_id, ((char*)region_buf + jndx * type_size)); - } /* end for (jndx = 0; jndx < npoints; jndx++) */ + render_bin_output(stream, container, type_id, (char*)region_buf, npoints); done: HDfree(region_buf); diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 0f4b271..3e3a4cf 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -560,8 +560,7 @@ H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *i H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum); -H5TOOLS_DLL int do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem); -H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem); +H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts); H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 0c0a49f..c2add9a 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -282,7 +282,9 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai /* binary dump */ if (bin_output) { - do_bin_output(rawdatastream, rawoutstream, container, nelmts, type, _mem); + if (render_bin_output(rawdatastream, container, type, _mem, nelmts) < 0) { + HDfprintf(rawoutstream,"\nError in writing binary stream\n"); + } } /* end if */ else { /* setup */ diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 0de126d..1646351 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -693,6 +693,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai unsigned nmembs; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; + H5T_class_t type_class; /* * some tempvars to store the value before we append it to the string to @@ -729,480 +730,494 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } } } - else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { - float tempfloat; + else { + if((type_class = H5Tget_class(type)) < 0) + return NULL; + switch (type_class) { + case H5T_FLOAT: + if (H5Tequal(type, H5T_NATIVE_FLOAT)) { + float tempfloat; - HDmemcpy(&tempfloat, vp, sizeof(float)); - h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat); - } - else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { - double tempdouble; + HDmemcpy(&tempfloat, vp, sizeof(float)); + h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat); + } + else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { + double tempdouble; - HDmemcpy(&tempdouble, vp, sizeof(double)); - h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); + HDmemcpy(&tempdouble, vp, sizeof(double)); + h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); #if H5_SIZEOF_LONG_DOUBLE !=0 - } - else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { - long double templdouble; + } + else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { + long double templdouble; - HDmemcpy(&templdouble, vp, sizeof(long double)); - h5tools_str_append(str, "%Lf", templdouble); + HDmemcpy(&templdouble, vp, sizeof(long double)); + h5tools_str_append(str, "%Lf", templdouble); #endif - } - else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || - H5Tequal(type, H5T_NATIVE_UCHAR))) { - h5tools_print_char(str, info, (char) (*ucp_vp)); - } - else if (H5T_STRING == H5Tget_class(type)) { - unsigned int i; - char quote = '\0'; - char *s; - - quote = '\0'; - if (H5Tis_variable_str(type)) { - /* cp_vp is the pointer into the struct where a `char*' is stored. So we have - * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ - s = *(char**) cp_vp; - if (s != NULL) - size = HDstrlen(s); - } - else { - s = cp_vp; - size = H5Tget_size(type); - } - pad = H5Tget_strpad(type); - - /* Check for NULL pointer for string */ - if (s == NULL) { - h5tools_str_append(str, "NULL"); - } - else { - for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { - int j = 1; - - /* - * Count how many times the next character repeats. If the - * threshold is zero then that means it can repeat any number - * of times. - */ - if (info->str_repeat > 0) - while (i + j < size && s[i] == s[i + j]) - j++; - - /* - * Print the opening quote. If the repeat count is high enough to - * warrant printing the number of repeats instead of enumerating - * the characters, then make sure the character to be repeated is - * in it's own quote. - */ - if (info->str_repeat > 0 && j > info->str_repeat) { - if (quote) - h5tools_str_append(str, "%c", quote); - - quote = '\''; - h5tools_str_append(str, "%s%c", i ? " " : "", quote); } - else if (!quote) { - quote = '"'; - h5tools_str_append(str, "%s%c", i ? " " : "", quote); - } - - /* Print the character */ - h5tools_print_char(str, info, s[i]); + break; + case H5T_STRING: + { + unsigned int i; + char quote = '\0'; + char *s; - /* Print the repeat count */ - if (info->str_repeat && j > info->str_repeat) { + quote = '\0'; + if (H5Tis_variable_str(type)) { + /* cp_vp is the pointer into the struct where a `char*' is stored. So we have + * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ + s = *(char**) cp_vp; + if (s != NULL) size = HDstrlen(s); + } + else { + s = cp_vp; + size = H5Tget_size(type); + } + pad = H5Tget_strpad(type); + + /* Check for NULL pointer for string */ + if (s == NULL) { + h5tools_str_append(str, "NULL"); + } + else { + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + int j = 1; + + /* + * Count how many times the next character repeats. If the + * threshold is zero then that means it can repeat any number + * of times. + */ + if (info->str_repeat > 0) while (i + j < size && s[i] == s[i + j]) + j++; + + /* + * Print the opening quote. If the repeat count is high enough to + * warrant printing the number of repeats instead of enumerating + * the characters, then make sure the character to be repeated is + * in it's own quote. + */ + if (info->str_repeat > 0 && j > info->str_repeat) { + if (quote) h5tools_str_append(str, "%c", quote); + + quote = '\''; + h5tools_str_append(str, "%s%c", i ? " " : "", quote); + } + else if (!quote) { + quote = '"'; + h5tools_str_append(str, "%s%c", i ? " " : "", quote); + } + + /* Print the character */ + h5tools_print_char(str, info, s[i]); + + /* Print the repeat count */ + if (info->str_repeat && j > info->str_repeat) { #ifdef REPEAT_VERBOSE - h5tools_str_append(str, "%c repeats %d times", quote, j - 1); + h5tools_str_append(str, "%c repeats %d times", quote, j - 1); #else - h5tools_str_append(str, "%c*%d", quote, j - 1); + h5tools_str_append(str, "%c*%d", quote, j - 1); #endif /* REPEAT_VERBOSE */ - quote = '\0'; - i += j - 1; - } + quote = '\0'; + i += j - 1; + } - } + } - if (quote) - h5tools_str_append(str, "%c", quote); + if (quote) h5tools_str_append(str, "%c", quote); - if (i == 0) - /*empty string*/ - h5tools_str_append(str, "\"\""); - } /* end else */ - } - else if (H5Tequal(type, H5T_NATIVE_INT)) { - HDmemcpy(&tempint, vp, sizeof(int)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(int)) - tempint = 0; - else - tempint = (tempint >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); - } - else if (H5Tequal(type, H5T_NATIVE_UINT)) { - HDmemcpy(&tempuint, vp, sizeof(unsigned int)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned int)) - tempuint = 0; - else - tempuint = (tempuint >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); - } - else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { - signed char tempchar; - HDmemcpy(&tempchar, cp_vp, sizeof(char)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(char)) - tempchar = 0; - else - tempchar = (tempchar >> packed_data_offset) & packed_data_mask; - } + if (i == 0) + /*empty string*/ + h5tools_str_append(str, "\"\""); + } /* end else */ + } + break; + case H5T_INTEGER: + if (H5Tequal(type, H5T_NATIVE_INT)) { + HDmemcpy(&tempint, vp, sizeof(int)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(int)) + tempint = 0; + else + tempint = (tempint >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); + } + else if (H5Tequal(type, H5T_NATIVE_UINT)) { + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned int)) + tempuint = 0; + else + tempuint = (tempuint >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); + } + else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { + h5tools_print_char(str, info, (char) (*ucp_vp)); + } + else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { + signed char tempchar; + HDmemcpy(&tempchar, cp_vp, sizeof(char)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(char)) + tempchar = 0; + else + tempchar = (tempchar >> packed_data_offset) & packed_data_mask; + } #ifdef H5_VMS - h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar); + h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar); #else - h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar); + h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar); #endif - } - else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { - unsigned char tempuchar; - HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned char)) - tempuchar = 0; - else - tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar); - } - else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - short tempshort; - - HDmemcpy(&tempshort, vp, sizeof(short)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(short)) - tempshort = 0; - else - tempshort = (tempshort >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); - } - else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - unsigned short tempushort; - - HDmemcpy(&tempushort, vp, sizeof(unsigned short)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned short)) - tempushort = 0; - else - tempushort = (tempushort >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); - } - else if (H5Tequal(type, H5T_NATIVE_LONG)) { - HDmemcpy(&templong, vp, sizeof(long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(long)) - templong = 0; - else - templong = (templong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); - } - else if (H5Tequal(type, H5T_NATIVE_ULONG)) { - HDmemcpy(&tempulong, vp, sizeof(unsigned long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned long)) - tempulong = 0; - else - tempulong = (tempulong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); - } - else if (H5Tequal(type, H5T_NATIVE_LLONG)) { - HDmemcpy(&templlong, vp, sizeof(long long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(long long)) - templlong = 0; - else - templlong = (templlong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); - } - else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { - HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned long long)) - tempullong = 0; - else - tempullong = (tempullong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); - } - else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { - if (sizeof(hssize_t) == sizeof(int)) { - HDmemcpy(&tempint, vp, sizeof(int)); - h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); - } - else if (sizeof(hssize_t) == sizeof(long)) { - HDmemcpy(&templong, vp, sizeof(long)); - h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); - } - else { - HDmemcpy(&templlong, vp, sizeof(long long)); - h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); - } - } - else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { - if (sizeof(hsize_t) == sizeof(int)) { - HDmemcpy(&tempuint, vp, sizeof(unsigned int)); - h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); - } - else if (sizeof(hsize_t) == sizeof(long)) { - HDmemcpy(&tempulong, vp, sizeof(long)); - h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); - } - else { - HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); - h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); - } - } - else if (H5Tget_class(type) == H5T_COMPOUND) { - unsigned j; - - nmembs = H5Tget_nmembers(type); - h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + } + else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { + unsigned char tempuchar; + HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned char)) + tempuchar = 0; + else + tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar); + } + else if (H5Tequal(type, H5T_NATIVE_SHORT)) { + short tempshort; + + HDmemcpy(&tempshort, vp, sizeof(short)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(short)) + tempshort = 0; + else + tempshort = (tempshort >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); + } + else if (H5Tequal(type, H5T_NATIVE_USHORT)) { + unsigned short tempushort; + + HDmemcpy(&tempushort, vp, sizeof(unsigned short)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned short)) + tempushort = 0; + else + tempushort = (tempushort >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); + } + else if (H5Tequal(type, H5T_NATIVE_LONG)) { + HDmemcpy(&templong, vp, sizeof(long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(long)) + templong = 0; + else + templong = (templong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); + } + else if (H5Tequal(type, H5T_NATIVE_ULONG)) { + HDmemcpy(&tempulong, vp, sizeof(unsigned long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned long)) + tempulong = 0; + else + tempulong = (tempulong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); + } + else if (H5Tequal(type, H5T_NATIVE_LLONG)) { + HDmemcpy(&templlong, vp, sizeof(long long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(long long)) + templlong = 0; + else + templlong = (templlong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); + } + else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { + HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned long long)) + tempullong = 0; + else + tempullong = (tempullong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); + } + else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { + if (sizeof(hssize_t) == sizeof(int)) { + HDmemcpy(&tempint, vp, sizeof(int)); + h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); + } + else if (sizeof(hssize_t) == sizeof(long)) { + HDmemcpy(&templong, vp, sizeof(long)); + h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); + } + else { + HDmemcpy(&templlong, vp, sizeof(long long)); + h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); + } + } + else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { + if (sizeof(hsize_t) == sizeof(int)) { + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); + h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); + } + else if (sizeof(hsize_t) == sizeof(long)) { + HDmemcpy(&tempulong, vp, sizeof(long)); + h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); + } + else { + HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); + h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); + } + } + break; + case H5T_COMPOUND: + { + unsigned j; - ctx->indent_level++; + nmembs = H5Tget_nmembers(type); + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); - for (j = 0; j < nmembs; j++) { - if (j) - h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); - else - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + ctx->indent_level++; - if(info->arr_linebreak) - h5tools_str_indent(str, info, ctx); - - /* The name */ - name = H5Tget_member_name(type, j); - h5tools_str_append(str, OPT(info->cmpd_name, ""), name); - HDfree(name); + for (j = 0; j < nmembs; j++) { + if (j) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); + else + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - /* The value */ - offset = H5Tget_member_offset(type, j); - memb = H5Tget_member_type(type, j); + if (info->arr_linebreak) h5tools_str_indent(str, info, ctx); - h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); + /* The name */ + name = H5Tget_member_name(type, j); + h5tools_str_append(str, OPT(info->cmpd_name, ""), name); + HDfree(name); - H5Tclose(memb); - } - ctx->indent_level--; + /* The value */ + offset = H5Tget_member_offset(type, j); + memb = H5Tget_member_type(type, j); + h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); - if(info->arr_linebreak) { - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - h5tools_str_indent(str, info, ctx); - } - h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + H5Tclose(memb); + } + ctx->indent_level--; - } - else if (H5Tget_class(type) == H5T_ENUM) { - char enum_name[1024]; + if (info->arr_linebreak) { + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + h5tools_str_indent(str, info, ctx); + } + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); - if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) { - h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); - } - else { - size_t i; - n = H5Tget_size(type); - if (1 == n) { - h5tools_str_append(str, "0x%02x", ucp_vp[0]); - } - else { - for (i = 0; i < n; i++) - h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); - } - } - } - else if (H5Tequal(type, H5T_STD_REF_DSETREG)) { - if (h5tools_str_is_zero(vp, H5Tget_size(type))) { - h5tools_str_append(str, "NULL"); - } - else { - h5tools_str_sprint_region(str, info, container, vp); - } - } - else if (H5Tequal(type, H5T_STD_REF_OBJ)) { - /* - * Object references -- show the type and OID of the referenced - * object. - */ - if (h5tools_str_is_zero(vp, H5Tget_size(type))) { - h5tools_str_append(str, "NULL"); - } - else { - H5O_info_t oi; - const char *path; - - obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); - H5Oget_info(obj, &oi); - - /* Print object type and close object */ - switch (oi.type) { - case H5O_TYPE_GROUP: - h5tools_str_append(str, H5_TOOLS_GROUP); - break; - - case H5O_TYPE_DATASET: - h5tools_str_append(str, H5_TOOLS_DATASET); + } break; - - case H5O_TYPE_NAMED_DATATYPE: - h5tools_str_append(str, H5_TOOLS_DATATYPE); + case H5T_ENUM: + { + char enum_name[1024]; + + if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) { + h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); + } + else { + size_t i; + n = H5Tget_size(type); + if (1 == n) { + h5tools_str_append(str, "0x%02x", ucp_vp[0]); + } + else { + for (i = 0; i < n; i++) + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); + } + } + } break; - - default: - h5tools_str_append(str, "%u-", (unsigned) oi.type); + case H5T_REFERENCE: + if (H5Tequal(type, H5T_STD_REF_DSETREG)) { + if (h5tools_str_is_zero(vp, H5Tget_size(type))) { + h5tools_str_append(str, "NULL"); + } + else { + h5tools_str_sprint_region(str, info, container, vp); + } + } + else if (H5Tequal(type, H5T_STD_REF_OBJ)) { + /* + * Object references -- show the type and OID of the referenced + * object. + */ + if (h5tools_str_is_zero(vp, H5Tget_size(type))) { + h5tools_str_append(str, "NULL"); + } + else { + H5O_info_t oi; + const char *path; + + obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); + H5Oget_info(obj, &oi); + + /* Print object type and close object */ + switch (oi.type) { + case H5O_TYPE_GROUP: + h5tools_str_append(str, H5_TOOLS_GROUP); + break; + + case H5O_TYPE_DATASET: + h5tools_str_append(str, H5_TOOLS_DATASET); + break; + + case H5O_TYPE_NAMED_DATATYPE: + h5tools_str_append(str, H5_TOOLS_DATATYPE); + break; + + default: + h5tools_str_append(str, "%u-", (unsigned) oi.type); + break; + } /* end switch */ + H5Oclose(obj); + + /* Print OID */ + if (info->obj_hidefileno) + h5tools_str_append(str, info->obj_format, oi.addr); + else + h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); + + /* Print name */ + path = lookup_ref_path(*(haddr_t *) vp); + if (path) { + h5tools_str_append(str, " "); + h5tools_str_append(str, path); + h5tools_str_append(str, " "); + } /* end if */ + } /* end else */ + } break; - } /* end switch */ - H5Oclose(obj); - - /* Print OID */ - if (info->obj_hidefileno) - h5tools_str_append(str, info->obj_format, oi.addr); - else - h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); - - /* Print name */ - path = lookup_ref_path(*(haddr_t *) vp); - if (path) { - h5tools_str_append(str, " "); - h5tools_str_append(str, path); - h5tools_str_append(str, " "); - } /* end if */ - } /* end else */ - } - else if (H5Tget_class(type) == H5T_ARRAY) { - int k, ndims; - hsize_t i, dims[H5S_MAX_RANK], temp_nelmts; - static int is_next_arry_elmt = 0; - - /* Get the array's base datatype for each element */ - memb = H5Tget_super(type); - size = H5Tget_size(memb); - ndims = H5Tget_array_ndims(type); - H5Tget_array_dims2(type, dims); - HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); - - /* Calculate the number of array elements */ - for (k = 0, nelmts = 1; k < ndims; k++) { - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts)); - nelmts = (size_t) temp_nelmts; - } - /* Print the opening bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); - - ctx->indent_level++; - - for (i = 0; i < nelmts; i++) { - if (i) - h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); - - if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { - h5tools_str_append(str, "%s", "\n"); - h5tools_str_indent(str, info, ctx); - - } /* end if */ - else if (i && info->arr_sep) { - /* if next element begin, add next line with indent */ - if (is_next_arry_elmt) { - is_next_arry_elmt = 0; - - h5tools_str_append(str, "%s", "\n "); - h5tools_str_indent(str, info, ctx); - + case H5T_ARRAY: + { + int k, ndims; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts; + static int is_next_arry_elmt = 0; + + /* Get the array's base datatype for each element */ + memb = H5Tget_super(type); + size = H5Tget_size(memb); + ndims = H5Tget_array_ndims(type); + H5Tget_array_dims2(type, dims); + HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* Calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts)); + nelmts = (size_t) temp_nelmts; + } + /* Print the opening bracket */ + h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); + + ctx->indent_level++; + + for (i = 0; i < nelmts; i++) { + if (i) h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); + + if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); + + } /* end if */ + else if (i && info->arr_sep) { + /* if next element begin, add next line with indent */ + if (is_next_arry_elmt) { + is_next_arry_elmt = 0; + + h5tools_str_append(str, "%s", "\n "); + h5tools_str_indent(str, info, ctx); + + } + /* otherwise just add space */ + else + h5tools_str_append(str, " "); + + } /* end else if */ + + /* Dump values in an array element */ + is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */ + h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx); + } /* end for */ + + ctx->indent_level--; + + /* Print the closing bracket */ + h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); + is_next_arry_elmt = 1; /* set for begining of next array element */ + H5Tclose(memb); } - /* otherwise just add space */ - else - h5tools_str_append(str, " "); - - } /* end else if */ - - /* Dump values in an array element */ - is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */ - h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx); - } /* end for */ - - ctx->indent_level--; - - /* Print the closing bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); - is_next_arry_elmt = 1; /* set for begining of next array element */ - H5Tclose(memb); - } - else if (H5Tget_class(type) == H5T_VLEN) { - unsigned int i; + break; + case H5T_VLEN: + { + unsigned int i; - /* Get the VL sequences's base datatype for each element */ - memb = H5Tget_super(type); - size = H5Tget_size(memb); + /* Get the VL sequences's base datatype for each element */ + memb = H5Tget_super(type); + size = H5Tget_size(memb); - /* Print the opening bracket */ - h5tools_str_append(str, "%s", OPT(info->vlen_pre, "(")); + /* Print the opening bracket */ + h5tools_str_append(str, "%s", OPT(info->vlen_pre, "(")); - /* Get the number of sequence elements */ - nelmts = ((hvl_t *) cp_vp)->len; + /* Get the number of sequence elements */ + nelmts = ((hvl_t *) cp_vp)->len; - for (i = 0; i < nelmts; i++) { - if (i) - h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); + for (i = 0; i < nelmts; i++) { + if (i) h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); #ifdef LATER - /* Need to fix so VL data breaks at correct location on end of line -QAK */ - if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) { - int x; + /* Need to fix so VL data breaks at correct location on end of line -QAK */ + if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) { + int x; - h5tools_str_append(str, "%s", "\n"); + h5tools_str_append(str, "%s", "\n"); - /* need to indent some more here */ - if (ctx->indent_level >= 0) - h5tools_str_append(str, "%s", OPT(info->line_pre, "")); + /* need to indent some more here */ + if (ctx->indent_level >= 0) + h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - for (x = 0; x < ctx->indent_level + 1; x++) - h5tools_str_append(str,"%s",OPT(info->line_indent,"")); - } /* end if */ + for (x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str,"%s",OPT(info->line_indent,"")); + } /* end if */ #endif /* LATER */ - ctx->indent_level++; + ctx->indent_level++; - /* Dump the array element */ - h5tools_str_sprint(str, info, container, memb, - ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx); + /* Dump the array element */ + h5tools_str_sprint(str, info, container, memb, ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx); - ctx->indent_level--; - } /* end for */ + ctx->indent_level--; + } /* end for */ - h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")")); - H5Tclose(memb); - } - else { - /* All other types get printed as hexadecimal */ - size_t i; - n = H5Tget_size(type); - if (1 == n) { - h5tools_str_append(str, "0x%02x", ucp_vp[0]); - } - else { - for (i = 0; i < n; i++) - h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); - } - } + h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")")); + H5Tclose(memb); + } + break; + default: + { + /* All other types get printed as hexadecimal */ + size_t i; + n = H5Tget_size(type); + if (1 == n) { + h5tools_str_append(str, "0x%02x", ucp_vp[0]); + } + else { + for (i = 0; i < n; i++) + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); + } + } + break; + } /* end switch */ + } return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s")); } |