From 4a6f93f895a8e60dc4f78e321db98a2fa5f1bdaf Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 19 Jul 2012 14:53:17 -0500 Subject: [svn-r22588] HDFFV-721: h5dump supplies input for h5import Tested: local linux with cmake jam with configure --- MANIFEST | 8 + release_docs/CMake.txt | 106 +- tools/h5dump/CMakeLists.txt | 36 +- tools/h5dump/testh5dump.sh.in | 6 + tools/h5import/CMakeLists.txt | 102 +- tools/h5import/h5import.c | 2344 +++++++++++++++++++++++------ tools/h5import/h5import.h | 29 +- tools/h5import/h5importtestutil.sh | 70 +- tools/h5import/testfiles/dbinfp64.h5.txt | 2 + tools/h5import/testfiles/dbinin16.h5.txt | 2 + tools/h5import/testfiles/dbinin32.h5.txt | 2 + tools/h5import/testfiles/dbinin8.h5.txt | 2 + tools/h5import/testfiles/dbinin8w.h5.txt | 2 + tools/h5import/testfiles/dbinuin16.h5.txt | 2 + tools/h5import/testfiles/dbinuin32.h5.txt | 2 + tools/h5import/testfiles/dtxtstr.h5.txt | 2 + 16 files changed, 2229 insertions(+), 488 deletions(-) create mode 100644 tools/h5import/testfiles/dbinfp64.h5.txt create mode 100644 tools/h5import/testfiles/dbinin16.h5.txt create mode 100644 tools/h5import/testfiles/dbinin32.h5.txt create mode 100644 tools/h5import/testfiles/dbinin8.h5.txt create mode 100644 tools/h5import/testfiles/dbinin8w.h5.txt create mode 100644 tools/h5import/testfiles/dbinuin16.h5.txt create mode 100644 tools/h5import/testfiles/dbinuin32.h5.txt create mode 100644 tools/h5import/testfiles/dtxtstr.h5.txt diff --git a/MANIFEST b/MANIFEST index dece0ee..e106216 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1173,6 +1173,14 @@ ./tools/h5import/testfiles/txtstr.conf ./tools/h5import/testfiles/txtstr.h5 ./tools/h5import/testfiles/txtstr.txt +./tools/h5import/testfiles/dbinfp64.h5.txt +./tools/h5import/testfiles/dbinin8.h5.txt +./tools/h5import/testfiles/dbinin8w.h5.txt +./tools/h5import/testfiles/dbinin16.h5.txt +./tools/h5import/testfiles/dbinin32.h5.txt +./tools/h5import/testfiles/dbinuin16.h5.txt +./tools/h5import/testfiles/dbinuin32.h5.txt +./tools/h5import/testfiles/dtxtstr.h5.txt # h5diff sources ./tools/h5diff/Makefile.am diff --git a/release_docs/CMake.txt b/release_docs/CMake.txt index 2d15741..1d36e21 100644 --- a/release_docs/CMake.txt +++ b/release_docs/CMake.txt @@ -248,51 +248,69 @@ Notes: This short instruction is written for users who want to quickly build ======================================================================== All options for HDF5 C/C++ Libraries with CMake + Option Name --- Option Description --- Option Default ======================================================================== -OPTION (HDF5_Enable_Clear_File_Buffers "Securely clear file buffers before writing to file" ON) -OPTION (HDF5_Enable_Instrument "Instrument The library" HDF5_Enable_Instrument) -OPTION (HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF) -OPTION (HDF5_METADATA_TRACE_FILE "Enable metadata trace file collection" OFF) -OPTION (HDF5_WANT_DATA_ACCURACY "IF data accuracy is guaranteed during data conversions" ON) -OPTION (HDF5_WANT_DCONV_EXCEPTION "exception handling functions is checked during data conversions" ON) -OPTION (HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF) -OPTION (HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON) -OPTION (HDF5_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON) -OPTION (HDF5_ENABLE_GPFS "Enable GPFS hints for the MPI/POSIX file driver" OFF) -IF (APPLE) OPTION (HDF5_BUILD_WITH_INSTALL_NAME "Build with library install_name set to the installation path" OFF) -OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" OFF) -OPTION (BUILD_STATIC_EXECS "Build Static Executabless" OFF) -OPTION (BUILD_STATIC_PIC "Build Static PIC" OFF) -OPTION (HDF5_ENABLE_COVERAGE "Enable code coverage for Libraries and Programs" OFF) -OPTION (HDF5_ENABLE_USING_MEMCHECKER "Indicate that a memory checker is used" OFF) -OPTION (HDF5_ENABLE_DEPRECATED_SYMBOLS "Enable deprecated public API symbols" ON) -OPTION (HDF5_ENABLE_TRACE "Enable API tracing capability" ON) -OPTION (HDF5_ENABLE_TRACE "Enable API tracing capability" OFF) -OPTION (HDF5_ENABLE_EMBEDDED_LIBINFO "embed library info into executables" ON) -OPTION (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) -OPTION (HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF) -OPTION (HDF5_USE_16_API_DEFAULT "Use the HDF5 1.6.x API by default" OFF) -OPTION (HDF5_USE_18_API_DEFAULT "Use the HDF5 1.8.x API by default" OFF) -OPTION (HDF5_USE_FILTER_${FILTER} "Use the ${FILTER} Filter" ON) -OPTION (HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building" "NO") -OPTION (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 0) -OPTION (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 0) -OPTION (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF) -OPTION (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) -IF (HDF5_ENABLE_SZIP_SUPPORT) OPTION (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) -OPTION (HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" OFF) -IF (WIN32 AND NOT CYGWIN) OPTION (HDF5_ENABLE_THREADSAFE "Enable Threadsafety" OFF) -OPTION (BUILD_TESTING "Build HDF5 Unit Testing" OFF) -OPTION (HDF5_TEST_VFD "Execute tests with different VFDs" OFF) -IF (HDF5_TEST_VFD) OPTION (HDF5_TEST_FHEAP_VFD "Execute tests with different VFDs" ON) -OPTION (HDF5_BUILD_FORTRAN "Build FORTRAN support" OFF) -IF (HDF5_BUILD_FORTRAN) OPTION (HDF5_ENABLE_F2003 "Enable FORTRAN 2003 Standard" OFF) -OPTION (HDF5_BUILD_EXAMPLES "Build HDF5 Library Examples" OFF) -OPTION (HDF5_BUILD_CPP_LIB "Build HDF5 C++ Library" OFF) -OPTION (HDF5_BUILD_TOOLS "Build HDF5 Tools" OFF) -OPTION (HDF5_BUILD_HL_LIB "Build HIGH Level HDF5 Library" OFF) -OPTION (HDF5_NO_PACKAGES "Do not include CPack Packaging" OFF) -OPTION (HDF5_USE_FOLDERS "Do not include CPack Packaging" OFF) +---------------- General Build Options --------------------- +BUILD_SHARED_LIBS "Build Shared Libraries" OFF +BUILD_STATIC_EXECS "Build Static Executabless" OFF +BUILD_STATIC_PIC "Build Static PIC" OFF +BUILD_TESTING "Build HDF5 Unit Testing" OFF + +---------------- HDF5 Build Options --------------------- +HDF5_BUILD_CPP_LIB "Build HDF5 C++ Library" OFF +HDF5_BUILD_EXAMPLES "Build HDF5 Library Examples" OFF +HDF5_BUILD_FORTRAN "Build FORTRAN support" OFF +HDF5_BUILD_HL_LIB "Build HIGH Level HDF5 Library" OFF +HDF5_BUILD_TOOLS "Build HDF5 Tools" OFF +IF (HDF5_BUILD_FORTRAN) + HDF5_ENABLE_F2003 "Enable FORTRAN 2003 Standard" OFF + +---------------- HDF5 Advanced Options --------------------- +HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF +HDF5_Enable_Clear_File_Buffers "Securely clear file buffers before writing to file" ON +HDF5_Enable_Instrument "Instrument The library" HDF5_Enable_Instrument +HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF +HDF5_ENABLE_COVERAGE "Enable code coverage for Libraries and Programs" OFF +HDF5_ENABLE_DEPRECATED_SYMBOLS "Enable deprecated public API symbols" ON +HDF5_ENABLE_EMBEDDED_LIBINFO "embed library info into executables" ON +HDF5_ENABLE_GPFS "Enable GPFS hints for the MPI/POSIX file driver" OFF +HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON +HDF5_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON +HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF +HDF5_ENABLE_TRACE "Enable API tracing capability" OFF +HDF5_ENABLE_USING_MEMCHECKER "Indicate that a memory checker is used" OFF +HDF5_METADATA_TRACE_FILE "Enable metadata trace file collection" OFF +HDF5_NO_PACKAGES "Do not include CPack Packaging" OFF +HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" OFF +HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF +HDF5_TEST_VFD "Execute tests with different VFDs" OFF +HDF5_USE_16_API_DEFAULT "Use the HDF5 1.6.x API by default" OFF +HDF5_USE_18_API_DEFAULT "Use the HDF5 1.8.x API by default" OFF +HDF5_USE_FOLDERS "Do not include CPack Packaging" OFF +HDF5_WANT_DATA_ACCURACY "IF data accuracy is guaranteed during data conversions" ON +HDF5_WANT_DCONV_EXCEPTION "exception handling functions is checked during data conversions" ON +IF (APPLE) + HDF5_BUILD_WITH_INSTALL_NAME "Build with library install_name set to the installation path" OFF +IF (CMAKE_BUILD_TYPE MATCHES Debug) + HDF5_ENABLE_TRACE "Enable API tracing capability" ON +IF (HDF5_TEST_VFD) + HDF5_TEST_FHEAP_VFD "Execute tests with different VFDs" ON +IF (WIN32 AND NOT CYGWIN) + HDF_LEGACY_NAMING "Use Legacy Names for Libraries and Programs" OFF +HDF5_ENABLE_THREADSAFE "Enable Threadsafety" OFF + +---------------- External Library Options --------------------- +HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building" "NO" +HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF +HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF +ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 0 +SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 0 +HDF5_USE_FILTER_FLETCHER32 "Use the FLETCHER32 Filter" ON +HDF5_USE_FILTER_NBIT "Use the NBIT Filter" ON +HDF5_USE_FILTER_SCALEOFFSET "Use the SCALEOFFSET Filter" ON +HDF5_USE_FILTER_SHUFFLE "Use the SHUFFLE Filter" ON +IF (HDF5_ENABLE_SZIP_SUPPORT) + HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF ************************************************************************ diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 88d28c4..02327b4 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -1357,11 +1357,21 @@ IF (BUILD_TESTING) # NATIVE default. the NATIVE test can be validated with h5import/h5diff ADD_H5_TEST (tbin1 0 --enable-error-stack -d integer -o out1.bin -b tbinary.h5) + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5DUMP-tbin1 PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + SET (last_test "H5DUMP-tbin1") + IF (NOT HDF5_ENABLE_USING_MEMCHECKER) - IF (NOT "${last_test}" STREQUAL "") - SET_TESTS_PROPERTIES (H5DUMP-tbin1 PROPERTIES DEPENDS ${last_test}) - ENDIF (NOT "${last_test}" STREQUAL "") - SET (last_test "H5DUMP-tbin1") + ADD_TEST (NAME H5DUMP-clear-out1D COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/out1D.h5) + SET_TESTS_PROPERTIES (H5DUMP-clear-out1D PROPERTIES DEPENDS H5DUMP-tbin1) + ADD_TEST (NAME H5DUMP-h5import-out1D COMMAND h5import out1.bin -c tbin1.out -o out1D.h5) + SET_TESTS_PROPERTIES (H5DUMP-h5import-out1D PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + SET_TESTS_PROPERTIES (H5DUMP-h5import-out1D PROPERTIES DEPENDS H5DUMP-clear-out1D) + ADD_TEST (NAME H5DUMP-h5diff-out1D COMMAND h5diff tbinary.h5 out1D.h5 /integer /integer) + SET_TESTS_PROPERTIES (H5DUMP-h5diff-out1D PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + SET_TESTS_PROPERTIES (H5DUMP-h5diff-out1D PROPERTIES DEPENDS H5DUMP-h5import-out1D) + SET (last_test "H5DUMP-h5diff-out1D") ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) ADD_TEST (NAME H5DUMP-clear-out1 COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/out1.h5) @@ -1386,11 +1396,21 @@ IF (BUILD_TESTING) # the NATIVE test can be validated with h5import/h5diff ADD_H5_TEST (tbin3 0 --enable-error-stack -d integer -o out3.bin -b NATIVE tbinary.h5) + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5DUMP-tbin3 PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + SET (last_test "H5DUMP-tbin3") + IF (NOT HDF5_ENABLE_USING_MEMCHECKER) - IF (NOT "${last_test}" STREQUAL "") - SET_TESTS_PROPERTIES (H5DUMP-tbin3 PROPERTIES DEPENDS ${last_test}) - ENDIF (NOT "${last_test}" STREQUAL "") - SET (last_test "H5DUMP-tbin3") + ADD_TEST (NAME H5DUMP-clear-out3D COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/out3D.h5) + SET_TESTS_PROPERTIES (H5DUMP-clear-out3D PROPERTIES DEPENDS H5DUMP-tbin3) + ADD_TEST (NAME H5DUMP-h5import-out3D COMMAND h5import out3.bin -c tbin3.out -o out3D.h5) + SET_TESTS_PROPERTIES (H5DUMP-h5import-out3D PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + SET_TESTS_PROPERTIES (H5DUMP-h5import-out3D PROPERTIES DEPENDS H5DUMP-clear-out3D) + ADD_TEST (NAME H5DUMP-h5diff-out3D COMMAND h5diff tbinary.h5 out3D.h5 /integer /integer -q) + SET_TESTS_PROPERTIES (H5DUMP-h5diff-out3D PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + SET_TESTS_PROPERTIES (H5DUMP-h5diff-out3D PROPERTIES DEPENDS H5DUMP-h5import-out3D) + SET (last_test "H5DUMP-h5diff-out3D") ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) ADD_TEST (NAME H5DUMP-clear-out3 COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/out3.h5) diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 8d2fb20..fa71558 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -953,6 +953,9 @@ TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b LE tbinar TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b tbinary.h5 IMPORTTEST out1.bin -c out3.h5import -o out1.h5 DIFFTEST tbinary.h5 out1.h5 /integer /integer +# Same but use h5dump as input to h5import +IMPORTTEST out1.bin -c tbin1.ddl -o out1D.h5 +DIFFTEST tbinary.h5 out1D.h5 /integer /integer TOOLTEST tbin2.ddl --enable-error-stack -b BE -d float -o out2.bin tbinary.h5 @@ -960,6 +963,9 @@ TOOLTEST tbin2.ddl --enable-error-stack -b BE -d float -o out2.bin tbina TOOLTEST tbin3.ddl --enable-error-stack -d integer -o out3.bin -b NATIVE tbinary.h5 IMPORTTEST out3.bin -c out3.h5import -o out3.h5 DIFFTEST tbinary.h5 out3.h5 /integer /integer +# Same but use h5dump as input to h5import +IMPORTTEST out3.bin -c tbin3.ddl -o out3D.h5 +DIFFTEST tbinary.h5 out3D.h5 /integer /integer TOOLTEST tbin4.ddl --enable-error-stack -d double -b FILE -o out4.bin tbinary.h5 diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index bbe73a8..42c5c8e 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -12,6 +12,7 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) ADD_EXECUTABLE (h5import ${HDF5_TOOLS_H5IMPORT_SOURCE_DIR}/h5import.c) TARGET_NAMING (h5import ${LIB_TYPE}) TARGET_LINK_LIBRARIES (h5import ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) +#SET_TARGET_PROPERTIES (h5import PROPERTIES COMPILE_DEFINITIONS H5DEBUGIMPORT) SET_TARGET_PROPERTIES (h5import PROPERTIES FOLDER tools) SET (H5_DEP_EXECUTABLES h5import) @@ -59,6 +60,14 @@ IF (BUILD_TESTING) txtin32.txt textpfe64.txt txtstr.txt + dbinfp64.h5.txt + dbinin8.h5.txt + dbinin8w.h5.txt + dbinin16.h5.txt + dbinin32.h5.txt + dbinuin16.h5.txt + dbinuin32.h5.txt + dtxtstr.h5.txt ) SET (HDF5_REFERENCE_TEST_FILES binfp64.h5 @@ -170,7 +179,88 @@ IF (BUILD_TESTING) SET_TESTS_PROPERTIES (H5IMPORT-H5DMP_CMP-${testname} PROPERTIES DEPENDS H5IMPORT-H5DMP-${testname}) SET (last_test "H5IMPORT-H5DMP_CMP-${testname}") ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_TEST testname resultcode testfile vparam srcname dstname) + ENDMACRO (ADD_H5_TEST testname importfile conffile testfile) + + MACRO (ADD_H5_DUMPTEST testname datasetname testfile) + # If using memchecker add tests without using scripts + IF (NOT HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + d${testfile} + d${testfile}.bin + d${testfile}.imp + d${testfile}.imp.err + d${testfile}.dmp + d${testfile}.dmp.err + d${testfile}.dff + d${testfile}.dff.err + ) + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5IMPORT-DUMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + + IF ("${ARGN}" STREQUAL "BINARY") + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-H5DUMP + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-b;testfiles/${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=d${testfile}.dmp" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ELSE ("${ARGN}" STREQUAL "BINARY") + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-H5DUMP + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-y;--width=1;testfiles/${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=d${testfile}.dmp" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ENDIF ("${ARGN}" STREQUAL "BINARY") + SET_TESTS_PROPERTIES (H5IMPORT-DUMP-${testname}-H5DUMP PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-clear-objects") + + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=d${testfile}.bin;-c;d${testfile}.dmp;-o;d${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=d${testfile}.imp" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + SET_TESTS_PROPERTIES (H5IMPORT-DUMP-${testname} PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-H5DUMP") + + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-H5DIFF + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;d${testfile};testfiles/${testfile};${datasetname};${datasetname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=d${testfile}.dff" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=d${testfile}.txt" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + SET_TESTS_PROPERTIES (H5IMPORT-DUMP-${testname}-H5DIFF PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}") + SET (last_test "H5IMPORT-DUMP-${testname}-H5DIFF") + ELSE (NOT HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-SKIPPED + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname} ${datasetname} ${testfile}" + ) + ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) + ENDMACRO (ADD_H5_DUMPTEST testname datasetname testfile) ############################################################################## ############################################################################## @@ -223,27 +313,35 @@ IF (BUILD_TESTING) # ----- TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " ADD_H5_TEST (BINARY_F64 binfp64.bin testfiles/binfp64.conf binfp64.h5) + ADD_H5_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY) # ----- TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " ADD_H5_TEST (BINARY_I8 binin8.bin testfiles/binin8.conf binin8.h5) + ADD_H5_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY) # ----- TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended " ADD_H5_TEST (BINARY_I16 binin16.bin testfiles/binin16.conf binin16.h5) + ADD_H5_DUMPTEST (BINARY_I16 "/int/bin/16-bit" binin16.h5 BINARY) # ----- TESTING "BINARY I32 - rank 3 - Output BE + CHUNKED " ADD_H5_TEST (BINARY_I32 binin32.bin testfiles/binin32.conf binin32.h5) + ADD_H5_DUMPTEST (BINARY_I32 "/int/bin/32-bit" binin32.h5 BINARY) # ----- TESTING "BINARY UI16 - rank 3 - Output byte BE + CHUNKED " ADD_H5_TEST (BINARY_UI16 binuin16.bin testfiles/binuin16.conf binuin16.h5) + ADD_H5_DUMPTEST (BINARY_UI16 "/int/buin/16-bit" binuin16.h5 BINARY) - # ----- TESTING "BINARY UI32 - rank 3 - Output LE + CHUNKED " + # ----- TESTING "BINARY UI32 - rank 3 - Output LE " ADD_H5_TEST (BINARY_UI32 binuin32.bin testfiles/binuin32.conf binuin32.h5) + ADD_H5_DUMPTEST (BINARY_UI32 "/int/buin/32-bit" binuin32.h5 BINARY) # ----- TESTING "STR" ADD_H5_TEST (STR testfiles/txtstr.txt testfiles/txtstr.conf txtstr.h5) + ADD_H5_DUMPTEST (STR "/mytext/data" txtstr.h5) # ----- TESTING "BINARY I8 CR LF EOF" ADD_H5_TEST (BINARY_I8_EOF binin8w.bin testfiles/binin8w.conf binin8w.h5) + ADD_H5_DUMPTEST (BINARY_I8_EOF "/dataset0" binin8w.h5 BINARY) # ----- TESTING "ASCII F64 - rank 1 - INPUT-CLASS TEXTFPE " ADD_H5_TEST (ASCII_F64_R1 testfiles/textpfe64.txt testfiles/textpfe.conf textpfe.h5) diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index 56dc5ab..d6dcf1d 100644 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -371,11 +371,19 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) break; case 5: /* STR */ - - if (processStrData(strm, in, file_id) == -1) { - (void) HDfprintf(stderr, err11, infile); - HDfclose(strm); - return (-1); + if (in->h5dumpInput) { + if (processStrHDFData(strm, in, file_id) == -1) { + (void) HDfprintf(stderr, err11, infile); + HDfclose(strm); + return (-1); + } + } + else { + if (processStrData(strm, in, file_id) == -1) { + (void) HDfprintf(stderr, err11, infile); + HDfclose(strm); + return (-1); + } } break; @@ -944,6 +952,179 @@ out: return (-1); } +/*------------------------------------------------------------------------- + * Function: processStrData + * + * Purpose: read an ASCII file with string data and generate an HDF5 dataset + * with a variable length type + * + * Return: 0, ok, -1 no + * + *------------------------------------------------------------------------- + */ +static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) +{ + hid_t group_id; + hid_t dset_id; + hid_t space_id; + hid_t mspace_id; + hid_t type_id; + hid_t handle; + char *str1 = NULL; + char *str2 = NULL; + char *str3 = NULL; + char str[1024] = ""; + char c; + int results; + int j; + int nlines = 0; + int line; + + /*------------------------------------------------------------------------- + * read file and generate an HDF5 dataset + *------------------------------------------------------------------------- + */ +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING\n"); +#endif + + if ((type_id = H5Tcopy(H5T_C_S1)) < 0) + goto out; + + if (H5Tset_size(type_id, H5T_VARIABLE) < 0) + goto out; + + /* disable error reporting */ + H5E_BEGIN_TRY + { + /* create parent groups */ + if (in->path.count > 1) { + j = 0; + handle = file_id; + while (j < in->path.count - 1) { + if ((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) { + group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + for (; j < in->path.count - 1; j++) + group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + handle = group_id; + break; + } + handle = group_id; + j++; + } + } + else { + handle = file_id; + j = 0; + } + + /*enable error reporting */ + } + H5E_END_TRY; +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING groups created\n"); +#endif + + if ((space_id = H5Screate_simple(in->rank, in->sizeOfDimension, NULL)) < 0) + goto out; + + if ((mspace_id = H5Screate(H5S_SCALAR)) < 0) + goto out; + + if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING ready to process strings\n"); +#endif + line = 0; + j = 0; + + while (fgets(str,sizeof(str),strm)) { + str1 = str; + str2 = NULL; + str3 = NULL; +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING[%d]={%s}\n", line, str1); +#endif + /* process string to remove the first and last quote char */ + str2 = strchr(str1, '"'); + if (str2 != NULL) { +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str2), str2); +#endif + str2++; +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str2), str2); +#endif + str3 = strrchr(str2, '"'); + if (str3 != NULL) { +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str3), str3); +#endif + *str3 = '\0'; + +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str2), str2); +#endif + + if(strlen(str2) > 0) { + hid_t fspace_id; + hsize_t start[1]; + hsize_t count[1] = { 1 }; + +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING[%d] store %s\n", line, str2); +#endif + if ((fspace_id = H5Dget_space(dset_id)) < 0) + goto out; + + start[0] = line++; + + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + goto out; + + if (H5Dwrite(dset_id, type_id, mspace_id, fspace_id, H5P_DEFAULT, &str2) < 0) + goto out; + + if (H5Sclose(fspace_id) < 0) + goto out; + } + } + } + str[0] = '\0'; + j++; + } +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING eof reached\n"); +#endif + + /* close */ + H5Dclose(dset_id); + H5Sclose(space_id); + H5Sclose(mspace_id); + H5Tclose(type_id); + + return (0); + +out: +#ifdef H5DEBUGIMPORT + printf("processStrHDFData DATATYPE STRING error exit\n"); +#endif +/* disable error reporting */ +H5E_BEGIN_TRY +{ + /* close */ + H5Dclose(dset_id); + H5Sclose(space_id); + H5Sclose(mspace_id); + H5Tclose(type_id); +} +H5E_END_TRY; + + return (-1); +} + static int allocateIntegerStorage(struct Input *in) { hsize_t len = 1; @@ -1075,6 +1256,7 @@ static int processConfigurationFile(char *infile, struct Input *in) int kindex; char temp[255]; int ival; + int scanret; const char *err1 = "Unable to open the configuration file: %s for reading.\n"; const char *err2 = "Unknown keyword in configuration file: %s\n"; @@ -1124,502 +1306,1818 @@ static int processConfigurationFile(char *infile, struct Input *in) return (-1); } - while (fscanf(strm, "%s", key) == 1) { - if ((kindex = mapKeywordToIndex(key)) == -1) { - (void) HDfprintf(stderr, err2, infile); - HDfclose(strm); - return (-1); - } - switch (kindex) { - case 0: /* PATH */ - if (in->configOptionVector[PATH] == 1) { - (void) HDfprintf(stderr, err3a, infile); - HDfclose(strm); - return (-1); - } - if (fscanf(strm, "%s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); - HDfclose(strm); - return (-1); - } - if (parsePathInfo(&in->path, temp) == -1) { - (void) HDfprintf(stderr, err3b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[PATH] = 1; - break; - - case 1: /* INPUT-CLASS */ - if (in->configOptionVector[INPUT_CLASS] == 1) { - (void) HDfprintf(stderr, err4a, infile); - HDfclose(strm); - return (-1); - } - - if (fscanf(strm, "%s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); - HDfclose(strm); - return (-1); - } - if (getInputClass(in, temp) == -1) { - (void) HDfprintf(stderr, err4b, infile); - HDfclose(strm); - return (-1); - } - - in->configOptionVector[INPUT_CLASS] = 1; - - /*set default value for output-class */ - if (in->configOptionVector[OUTPUT_CLASS] == 0) { - if (in->inputClass == 0 || in->inputClass == 4) - in->outputClass = 0; - if (in->inputClass == 1 || in->inputClass == 2 - || in->inputClass == 3) - in->outputClass = 1; - if (in->inputClass == 6 || in->inputClass == 7) - in->outputClass = 2; - } - break; - - case 2: /* INPUT-SIZE */ - if (in->configOptionVector[INPUT_SIZE] == 1) { - (void) HDfprintf(stderr, err5a, infile); - HDfclose(strm); - return (-1); - } - if (fscanf(strm, "%d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err19); - HDfclose(strm); - return (-1); - } - if (getInputSize(in, ival) == -1) { - (void) HDfprintf(stderr, err5b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[INPUT_SIZE] = 1; - - /*set default value for output-size */ - if (in->configOptionVector[OUTPUT_SIZE] == 0) - in->outputSize = in->inputSize; - break; - - case 3: /* RANK */ - if (in->configOptionVector[RANK] == 1) { - (void) HDfprintf(stderr, err6a, infile); - HDfclose(strm); - return (-1); - } - - if (getRank(in, strm) == -1) { - (void) HDfprintf(stderr, err6b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[RANK] = 1; - break; - - case 4: /* DIMENSION-SIZES */ - if (in->configOptionVector[DIM] == 1) { - (void) HDfprintf(stderr, err7a, infile); - HDfclose(strm); - return (-1); - } + scanret = fscanf(strm, "%s", key); + if((scanret == 1) && !HDstrcmp("HDF5", key)) { +#ifdef H5DEBUGIMPORT + int pndx; + printf("\nh5dump file\n"); +#endif + in->h5dumpInput = 1; + scanret = fscanf(strm, "%s", temp); /* filename */ + scanret = fscanf(strm, "%s", temp); /* start bracket */ + scanret = fscanf(strm, "%s", key); /* DATASET */ + while (scanret == 1) { + if(!HDstrcmp("DATASET", key)) { /* PATH */ +#ifdef H5DEBUGIMPORT + printf("h5dump DATASET key\n"); +#endif + if (in->configOptionVector[PATH] == 1) { + (void) HDfprintf(stderr, err3a, infile); + HDfclose(strm); + return (-1); + } + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASET %s found\n", temp); +#endif + if (parsePathInfo(&in->path, temp) == -1) { + (void) HDfprintf(stderr, err3b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[PATH] = 1; + scanret = fscanf(strm, "%s", temp); /* start bracket */ +#ifdef H5DEBUGIMPORT + printf("h5dump DATASET %s found\n", temp); +#endif + } /* if(!HDstrcmp("DATASET", key)) PATH */ + else if(!HDstrcmp("DATATYPE", key)) { /* INPUT-CLASS */ +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE key\n"); +#endif + if (in->configOptionVector[INPUT_CLASS] == 1) { + (void) HDfprintf(stderr, err4a, infile); + HDfclose(strm); + return (-1); + } - if (in->configOptionVector[RANK] == 0) { - (void) HDfprintf(stderr, err7b, infile); - HDfclose(strm); - return (-1); - } - if (getDimensionSizes(in, strm) == -1) { - (void) HDfprintf(stderr, err7c, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[DIM] = 1; - break; + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE %s found\n", temp); +#endif + if ((kindex = getInputClassType(in, temp)) == -1) { + (void) HDfprintf(stderr, err4b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE type %d inputClass\n", in->inputClass); +#endif - case 5: /* OUTPUT-CLASS */ - if (in->configOptionVector[OUTPUT_CLASS] == 1) { - (void) HDfprintf(stderr, err8a, infile); - HDfclose(strm); - return (-1); - } + in->configOptionVector[INPUT_CLASS] = 1; + + /*set default value for output-class */ + if (in->configOptionVector[OUTPUT_CLASS] == 0) { + if (in->inputClass == 0 || in->inputClass == 4) + in->outputClass = 0; + if (in->inputClass == 1 || in->inputClass == 2 + || in->inputClass == 3) + in->outputClass = 1; + if (in->inputClass == 6 || in->inputClass == 7) + in->outputClass = 2; + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE type %d outputClass\n", in->outputClass); +#endif - if (getOutputClass(in, strm) == -1) { - (void) HDfprintf(stderr, err8b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[OUTPUT_CLASS] = 1; - break; + if(in->inputClass == 5) { /* STRING */ + int get_next_prop = 1; + in->outputClass = -1; +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING found\n"); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING %s found\n", temp); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* string properties */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } + while (get_next_prop) { + if(!HDstrcmp("STRSIZE", temp)) { /* STRSIZE */ + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err19); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING STRSIZE %s found\n", temp); +#endif + if (HDstrcmp("H5T_VARIABLE;", temp)) { + char *more = temp; + ival = strtoimax(more, &more, 10); + if (getInputSize(in, ival) == -1) { + (void) HDfprintf(stderr, err5b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING %d InputSize\n", in->inputSize); +#endif + } + } + else if(!HDstrcmp("STRPAD", temp)) { /* STRPAD */ + if (fscanf(strm, "%s", temp) != 1) { /* STRPAD type */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING STRPAD %s found\n", temp); +#endif + } + else if(!HDstrcmp("CSET", key)) { /* CSET */ + if (fscanf(strm, "%s", temp) != 1) { /* CSET type */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING CSET %s found\n", temp); +#endif - case 6: /* OUTPUT-SIZE */ - if (in->configOptionVector[OUTPUT_SIZE] == 1) { - (void) HDfprintf(stderr, err9a, infile); - HDfclose(strm); - return (-1); - } + } + else if(!HDstrcmp("CTYPE", temp)) { /* CTYPE */ + if (fscanf(strm, "%s", temp) != 1) { /* CTYPE type */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING CTYPE %s found\n", temp); +#endif + } /* if(!HDstrcmp("CSET", key)) */ + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING %s found\n", temp); +#endif + if(!HDstrcmp("}", temp)) { /* end bracket */ + get_next_prop = 0; + } + } /* while (get_next_prop) */ + } /* if(kindex == 5) STRING */ + } /* else if(!HDstrcmp("DATATYPE", key)) INPUT-CLASS */ + else if(!HDstrcmp("DATASPACE", key)) { /* RANK and DIMENSIONS */ + hsize_t temp_dims[MAX_NUM_DIMENSION]; + +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE key\n"); +#endif + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } + if(!HDstrcmp("SCALAR", temp)) { /* SCALAR */ + in->rank = 0; + } /* if(!HDstrcmp("SCALAR", key)) */ + else if(!HDstrcmp("NULL", temp)) { /* NULL */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } /* else if(!HDstrcmp("NULL", key)) */ + else if(!HDstrcmp("SIMPLE", temp)) { /* SIMPLE */ + int icount = 0; +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE found\n"); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + if(!HDstrcmp("(", temp)) { /* start paren */ + int get_next_dim = 1; + int i = 0; + + if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */ + (void) HDfprintf(stderr, err16c, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + while (get_next_dim) { + char *more = temp; + temp_dims[icount] = strtoull(more, &more, 10); + if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + if(!HDstrcmp(")", temp)) { /* end paren */ + in->rank = ++icount; + in->configOptionVector[RANK] = 1; + get_next_dim = 0; + } + else { /* Dimension */ + icount++; + if (icount > MAX_NUM_DIMENSION) { + (void) HDfprintf(stderr, "Invalid value for rank.\n"); + HDfclose(strm); + return (-1); + } + } + } /* while (get_next_dim) */ + + if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { + (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n"); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %d rank\n", in->rank); +#endif + for (i = 0; i < in->rank; i++) { + in->sizeOfDimension[i] = temp_dims[i]; + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE dims:", in->rank); + for (pndx = 0; pndx < in->rank; pndx++) { + printf(" %d", in->sizeOfDimension[pndx]); + } + printf("\n"); +#endif + in->configOptionVector[DIM] = 1; + } /* if(!HDstrcmp("(", key)) start paren */ + else { + (void) HDfprintf(stderr, err5b, infile); + HDfclose(strm); + return (-1); + } + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + if(!HDstrcmp("/", temp)) { /* / max dims */ + if ((in->maxsizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { + (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n"); + return (-1); + } + if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + if(!HDstrcmp("(", temp)) { /* start paren */ + int get_next_dim = 1; + int i = 0; - if (getOutputSize(in, strm) == -1) { - (void) HDfprintf(stderr, err9b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[OUTPUT_SIZE] = 1; - break; - - case 7: /* OUTPUT-ARCHITECTURE */ - if (in->configOptionVector[OUTPUT_ARCH] == 1) { - (void) HDfprintf(stderr, err10a, infile); - HDfclose(strm); - return (-1); +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE process max dim values\n"); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* max dim with optional comma */ + (void) HDfprintf(stderr, err16c, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + while (get_next_dim) { +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE get max dim value\n"); +#endif + if(!HDstrcmp("H5S_UNLIMITED", temp) || !HDstrcmp("H5S_UNLIMITED,", temp)) { /* unlimited */ + in->maxsizeOfDimension[i] = H5S_UNLIMITED; + in->configOptionVector[EXTEND] = 1; + } + else { + char *more = temp; + in->maxsizeOfDimension[i] = strtoull(more, &more, 10); + } + if (fscanf(strm, "%s", temp) != 1) { /* max dim or end paren */ + (void) HDfprintf(stderr, err16c, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + if(!HDstrcmp(")", temp)) { /* end paren */ + get_next_dim = 0; + } + else { /* comma */ + i++; + if (i > MAX_NUM_DIMENSION) { + (void) HDfprintf(stderr, "Invalid value for rank.\n"); + HDfclose(strm); + return (-1); + } + } + } /* while (get_next_dim) */ +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE maxdims:", in->rank); + for (pndx = 0; pndx < in->rank; pndx++) { + printf(" %d", in->maxsizeOfDimension[pndx]); + } + printf("\n"); + printf("h5dump DATASPACE SIMPLE get max dim finished\n"); +#endif + } /* if(!HDstrcmp("(", key)) start paren */ + else { + (void) HDfprintf(stderr, err16c, infile); + HDfclose(strm); + return (-1); + } + scanret = fscanf(strm, "%s", temp); /* end bracket */ +#ifdef H5DEBUGIMPORT + printf("h5dump DATASPACE SIMPLE %s found\n", temp); +#endif + } /* if(!HDstrcmp("/", key)) max dims separator */ + } /* else if(!HDstrcmp("SIMPLE", key)) */ + else { + (void) HDfprintf(stderr, err5b, infile); + HDfclose(strm); + return (-1); + } + } /* else if(!HDstrcmp("DATASPACE", key)) RANK and DIMENSIONS */ + else if(!HDstrcmp("STORAGE_LAYOUT", key)) { /* CHUNKED-DIMENSION-SIZES */ +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT key\n"); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT %s found\n", temp); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* CHUNKED */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT %s found\n", temp); +#endif + if(!HDstrcmp("CHUNKED", temp)) { /* CHUNKED */ + if ((in->sizeOfChunk = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { + (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n"); + return (-1); + } + if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); +#endif + if(!HDstrcmp("(", temp)) { /* start paren */ + int get_next_dim = 1; + int icount = 0; + + if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */ + (void) HDfprintf(stderr, err16c, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); +#endif + while (get_next_dim) { + char *more = temp; + in->sizeOfChunk[icount] = strtoull(more, &more, 10); + if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); +#endif + if(!HDstrcmp(")", temp)) { /* end paren */ + in->configOptionVector[RANK] = 1; + get_next_dim = 0; + } + else { /* Dimension */ + icount++; + if (icount > MAX_NUM_DIMENSION) { + (void) HDfprintf(stderr, "Invalid value for rank.\n"); + HDfclose(strm); + return (-1); + } + } + } /* while (get_next_dim) */ +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT CHUNKED dims:", in->rank); + for (pndx = 0; pndx < in->rank; pndx++) { + printf(" %d", in->sizeOfChunk[pndx]); + } + printf("\n"); +#endif + in->configOptionVector[DIM] = 1; + } /* if(!HDstrcmp("(", key)) start paren */ + else { + (void) HDfprintf(stderr, err5b, infile); + HDfclose(strm); + return (-1); + } + if (fscanf(strm, "%s", temp) != 1) { /* SIZE */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); +#endif + if(!HDstrcmp("SIZE", temp)) { /* SIZE */ + if (fscanf(strm, "%d", (&ival)) != 1) { + (void) HDfprintf(stderr, "%s", err19); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT CHUNKED SIZE %d found\n", ival); +#endif + } + while (HDstrcmp("}", temp)) { + if (fscanf(strm, "%s", temp) != 1) { /* end bracket */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); +#endif + } + in->configOptionVector[CHUNK] = 1; + } /* if(!HDstrcmp("CHUNKED", key)) CHUNKED */ + } /* else if(!HDstrcmp("STORAGE_LAYOUT", key)) CHUNKED-DIMENSION-SIZES */ + else if(!HDstrcmp("FILTERS", key)) { /* FILTERS */ +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS key\n"); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS %s found\n", temp); +#endif + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS %s found\n", temp); +#endif + if(!HDstrcmp("COMPRESSION", temp)) { /* COMPRESSION */ +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS COMPRESSION found\n"); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* DEFLATE */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS COMPRESSION %s found\n", temp); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* bgin bracket */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS COMPRESSION %s found\n", temp); +#endif + if (fscanf(strm, "%s", temp) != 1) { /* LEVEL */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS COMPRESSION %s found\n", temp); +#endif + if (fscanf(strm, "%d", (&ival)) != 1) { + (void) HDfprintf(stderr, "%s", err19); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS COMPRESSION LEVEL %d found\n", ival); +#endif + in->compressionParam = ival; + if (fscanf(strm, "%s", temp) != 1) { /* end bracket */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS COMPRESSION %s found\n", temp); +#endif + in->compressionType = 0; /* ONLY GZIP supported */ + in->configOptionVector[COMPRESS] = 1; + } + else if(!HDstrcmp("CONTIGUOUS", temp)) { /* CONTIGUOUS */ +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS CONTIGUOUS found\n"); +#endif + in->configOptionVector[COMPRESS] = 0; + } + else if(!HDstrcmp("NONE", temp)) { /* NONE */ +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS NONE found\n"); +#endif + in->configOptionVector[COMPRESS] = 0; + } + if (fscanf(strm, "%s", temp) != 1) { /* end bracket */ + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } +#ifdef H5DEBUGIMPORT + printf("h5dump FILTERS %s found\n", temp); +#endif } - - if (getOutputArchitecture(in, strm) == -1) { - (void) HDfprintf(stderr, err10b, infile); - HDfclose(strm); - return (-1); + else if(!HDstrcmp("DATA", key)) { /* FINSHED */ +#ifdef H5DEBUGIMPORT + printf("h5dump DATA key\n"); +#endif + scanret = 0; + break; } - in->configOptionVector[OUTPUT_ARCH] = 1; - break; - - case 8: /* OUTPUT-BYTE-ORDER */ - if (in->configOptionVector[OUTPUT_B_ORDER] == 1) { - (void) HDfprintf(stderr, err11a, infile); + scanret = fscanf(strm, "%s", key); + } +#ifdef H5DEBUGIMPORT + printf("h5dump path"); + for (pndx = 0; pndx < in->path.count; pndx++) { + printf(" : %s", in->path.group[pndx]); + } + printf("\n"); + printf("h5dump inputClass=%d\n", in->inputClass); + printf("h5dump inputSize=%d\n", in->inputSize); + printf("h5dump rank=%d\n", in->rank); + printf("h5dump outputClass=%d\n", in->outputClass); + printf("h5dump outputSize=%d\n", in->outputSize); + printf("h5dump outputArchitecture=%d\n", in->outputArchitecture); + printf("h5dump outputByteOrder=%d\n", in->outputByteOrder); + printf("h5dump compressionType=%d\n", in->compressionType); + printf("h5dump compressionParam=%d\n", in->compressionParam); + printf("h5dump externFilename=%s\n", in->externFilename); + printf("h5dump configOptionVector:\n"); + for (pndx = 0; pndx < NUM_KEYS; pndx++) { + printf(" %s=%d\n", keytable[pndx], in->configOptionVector[pndx]); + } +#endif + } + else { + while (scanret == 1) { + if ((kindex = mapKeywordToIndex(key)) == -1) { + (void) HDfprintf(stderr, err2, infile); HDfclose(strm); return (-1); } + switch (kindex) { + case 0: /* PATH */ + if (in->configOptionVector[PATH] == 1) { + (void) HDfprintf(stderr, err3a, infile); + HDfclose(strm); + return (-1); + } + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } + if (parsePathInfo(&in->path, temp) == -1) { + (void) HDfprintf(stderr, err3b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[PATH] = 1; + break; - if (getOutputByteOrder(in, strm) == -1) { - (void) HDfprintf(stderr, err11b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[OUTPUT_B_ORDER] = 1; - break; + case 1: /* INPUT-CLASS */ + if (in->configOptionVector[INPUT_CLASS] == 1) { + (void) HDfprintf(stderr, err4a, infile); + HDfclose(strm); + return (-1); + } - case 9: /* CHUNKED-DIMENSION-SIZES */ - if (in->configOptionVector[CHUNK] == 1) { - (void) HDfprintf(stderr, err12a, infile); - HDfclose(strm); - return (-1); - } - /* cant appear before dimension sizes have been provided */ - if (in->configOptionVector[DIM] == 0) { - (void) HDfprintf(stderr, err12b, infile); - HDfclose(strm); - return (-1); - } + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err18); + HDfclose(strm); + return (-1); + } + if (getInputClass(in, temp) == -1) { + (void) HDfprintf(stderr, err4b, infile); + HDfclose(strm); + return (-1); + } - if (getChunkedDimensionSizes(in, strm) == -1) { - (void) HDfprintf(stderr, err12c, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[CHUNK] = 1; - break; + in->configOptionVector[INPUT_CLASS] = 1; + + /*set default value for output-class */ + if (in->configOptionVector[OUTPUT_CLASS] == 0) { + if (in->inputClass == 0 || in->inputClass == 4) + in->outputClass = 0; + if (in->inputClass == 1 || in->inputClass == 2 + || in->inputClass == 3) + in->outputClass = 1; + if (in->inputClass == 6 || in->inputClass == 7) + in->outputClass = 2; + } + break; - case 10: /* COMPRESSION-TYPE */ - if (in->configOptionVector[COMPRESS] == 1) { - (void) HDfprintf(stderr, err13a, infile); - HDfclose(strm); - return (-1); - } + case 2: /* INPUT-SIZE */ + if (in->configOptionVector[INPUT_SIZE] == 1) { + (void) HDfprintf(stderr, err5a, infile); + HDfclose(strm); + return (-1); + } + if (fscanf(strm, "%d", (&ival)) != 1) { + (void) HDfprintf(stderr, "%s", err19); + HDfclose(strm); + return (-1); + } + if (getInputSize(in, ival) == -1) { + (void) HDfprintf(stderr, err5b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[INPUT_SIZE] = 1; - if (getCompressionType(in, strm) == -1) { - (void) HDfprintf(stderr, err13b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[COMPRESS] = 1; + /*set default value for output-size */ + if (in->configOptionVector[OUTPUT_SIZE] == 0) + in->outputSize = in->inputSize; + break; - if (in->configOptionVector[COMPRESS_PARAM] == 0) { - if (in->compressionType == 0) - in->compressionParam = 6; /* default value if compressionType is GZIP */ - } - break; + case 3: /* RANK */ + if (in->configOptionVector[RANK] == 1) { + (void) HDfprintf(stderr, err6a, infile); + HDfclose(strm); + return (-1); + } - case 11: /* COMPRESSION-PARAM */ - if (in->configOptionVector[COMPRESS_PARAM] == 1) { - (void) HDfprintf(stderr, err14a, infile); - HDfclose(strm); - return (-1); - } + if (getRank(in, strm) == -1) { + (void) HDfprintf(stderr, err6b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[RANK] = 1; + break; - if (getCompressionParameter(in, strm) == -1) { - (void) HDfprintf(stderr, err14b, infile); - HDfclose(strm); - return (-1); - } + case 4: /* DIMENSION-SIZES */ + if (in->configOptionVector[DIM] == 1) { + (void) HDfprintf(stderr, err7a, infile); + HDfclose(strm); + return (-1); + } - in->configOptionVector[COMPRESS_PARAM] = 1; + if (in->configOptionVector[RANK] == 0) { + (void) HDfprintf(stderr, err7b, infile); + HDfclose(strm); + return (-1); + } + if (getDimensionSizes(in, strm) == -1) { + (void) HDfprintf(stderr, err7c, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[DIM] = 1; + break; - if (in->configOptionVector[COMPRESS] == 0) - in->compressionType = 0; + case 5: /* OUTPUT-CLASS */ + if (in->configOptionVector[OUTPUT_CLASS] == 1) { + (void) HDfprintf(stderr, err8a, infile); + HDfclose(strm); + return (-1); + } - break; + if (getOutputClass(in, strm) == -1) { + (void) HDfprintf(stderr, err8b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[OUTPUT_CLASS] = 1; + break; - case 12: /* EXTERNAL-STORAGE */ - if (in->configOptionVector[EXTERNALSTORE] == 1) { - (void) HDfprintf(stderr, err15a, infile); - HDfclose(strm); - return (-1); - } + case 6: /* OUTPUT-SIZE */ + if (in->configOptionVector[OUTPUT_SIZE] == 1) { + (void) HDfprintf(stderr, err9a, infile); + HDfclose(strm); + return (-1); + } - if (getExternalFilename(in, strm) == -1) { - (void) HDfprintf(stderr, err15b, infile); - HDfclose(strm); - return (-1); - } - in->configOptionVector[EXTERNALSTORE] = 1; - break; + if (getOutputSize(in, strm) == -1) { + (void) HDfprintf(stderr, err9b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[OUTPUT_SIZE] = 1; + break; - case 13: /* MAXIMUM-DIMENSIONS */ - if (in->configOptionVector[EXTEND] == 1) { - (void) HDfprintf(stderr, err16a, infile); - HDfclose(strm); - return (-1); - } - /* cant appear before dimension sizes have been provided */ - if (in->configOptionVector[DIM] == 0) { - (void) HDfprintf(stderr, err16b, infile); - HDfclose(strm); - return (-1); - } - if (getMaximumDimensionSizes(in, strm) == -1) { - (void) HDfprintf(stderr, err16c, infile); - HDfclose(strm); - return (-1); + case 7: /* OUTPUT-ARCHITECTURE */ + if (in->configOptionVector[OUTPUT_ARCH] == 1) { + (void) HDfprintf(stderr, err10a, infile); + HDfclose(strm); + return (-1); + } + + if (getOutputArchitecture(in, strm) == -1) { + (void) HDfprintf(stderr, err10b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[OUTPUT_ARCH] = 1; + break; + + case 8: /* OUTPUT-BYTE-ORDER */ + if (in->configOptionVector[OUTPUT_B_ORDER] == 1) { + (void) HDfprintf(stderr, err11a, infile); + HDfclose(strm); + return (-1); + } + + if (getOutputByteOrder(in, strm) == -1) { + (void) HDfprintf(stderr, err11b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[OUTPUT_B_ORDER] = 1; + break; + + case 9: /* CHUNKED-DIMENSION-SIZES */ + if (in->configOptionVector[CHUNK] == 1) { + (void) HDfprintf(stderr, err12a, infile); + HDfclose(strm); + return (-1); + } + /* cant appear before dimension sizes have been provided */ + if (in->configOptionVector[DIM] == 0) { + (void) HDfprintf(stderr, err12b, infile); + HDfclose(strm); + return (-1); + } + + if (getChunkedDimensionSizes(in, strm) == -1) { + (void) HDfprintf(stderr, err12c, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[CHUNK] = 1; + break; + + case 10: /* COMPRESSION-TYPE */ + if (in->configOptionVector[COMPRESS] == 1) { + (void) HDfprintf(stderr, err13a, infile); + HDfclose(strm); + return (-1); + } + + if (getCompressionType(in, strm) == -1) { + (void) HDfprintf(stderr, err13b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[COMPRESS] = 1; + + if (in->configOptionVector[COMPRESS_PARAM] == 0) { + if (in->compressionType == 0) + in->compressionParam = 6; /* default value if compressionType is GZIP */ + } + break; + + case 11: /* COMPRESSION-PARAM */ + if (in->configOptionVector[COMPRESS_PARAM] == 1) { + (void) HDfprintf(stderr, err14a, infile); + HDfclose(strm); + return (-1); + } + + if (getCompressionParameter(in, strm) == -1) { + (void) HDfprintf(stderr, err14b, infile); + HDfclose(strm); + return (-1); + } + + in->configOptionVector[COMPRESS_PARAM] = 1; + + if (in->configOptionVector[COMPRESS] == 0) + in->compressionType = 0; + + break; + + case 12: /* EXTERNAL-STORAGE */ + if (in->configOptionVector[EXTERNALSTORE] == 1) { + (void) HDfprintf(stderr, err15a, infile); + HDfclose(strm); + return (-1); + } + + if (getExternalFilename(in, strm) == -1) { + (void) HDfprintf(stderr, err15b, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[EXTERNALSTORE] = 1; + break; + + case 13: /* MAXIMUM-DIMENSIONS */ + if (in->configOptionVector[EXTEND] == 1) { + (void) HDfprintf(stderr, err16a, infile); + HDfclose(strm); + return (-1); + } + /* cant appear before dimension sizes have been provided */ + if (in->configOptionVector[DIM] == 0) { + (void) HDfprintf(stderr, err16b, infile); + HDfclose(strm); + return (-1); + } + if (getMaximumDimensionSizes(in, strm) == -1) { + (void) HDfprintf(stderr, err16c, infile); + HDfclose(strm); + return (-1); + } + in->configOptionVector[EXTEND] = 1; + break; + + default: + break; } - in->configOptionVector[EXTEND] = 1; - break; + scanret = fscanf(strm, "%s", key); + } + } + + /* + check if keywords obtained are valid + if yes, return 0 else error + */ + + if (validateConfigurationParameters(in) == -1) { + (void) HDfprintf(stderr, err17, infile); + HDfclose(strm); + return (-1); + } + HDfclose(strm); + return (0); +} + +static int validateConfigurationParameters(struct Input *in) +{ + const char *err1 = "One or more of the required fields (RANK, DIMENSION-SIZES) missing.\n"; + const char *err2 = "Cannot specify chunking or compression or extendible data sets with the external file option.\n"; + const char *err3 = "Cannot specify the compression or the extendible data sets without the chunking option.\n"; + const char *err4a = "OUTPUT-ARCHITECTURE cannot be STD if OUTPUT-CLASS is floating point (FP).\n"; + const char *err4b = "OUTPUT-ARCHITECTURE cannot be IEEE if OUTPUT-CLASS is integer (IN).\n"; + const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n"; +#ifndef H5_SIZEOF_LONG_LONG + const char *err6 = "No support for reading 64-bit integer (INPUT-CLASS: IN, TEXTIN, UIN, TEXTUIN files\n"; +#endif + + /* for class STR other parameters are ignored */ + if (in->inputClass == 5) /* STR */ + return (0); + + if ((in->configOptionVector[DIM] != 1) || (in->configOptionVector[RANK] != 1)) { + (void) HDfprintf(stderr, "%s", err1); + return (-1); + } + + if (in->configOptionVector[EXTERNALSTORE] == 1) { + if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[CHUNK] == 1) || (in->configOptionVector[EXTEND] == 1)) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + } + + if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[EXTEND] == 1)) { + if (in->configOptionVector[CHUNK] != 1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + } + + /* Arch cant be STD if O/p class is FP */ + if (in->outputArchitecture == 1) + if (in->outputClass == 1) { + (void) HDfprintf(stderr, "%s", err4a); + return (-1); + } + + /* Arch cant be IEEE if O/p class is IN */ + if (in->outputArchitecture == 2) + if (in->outputClass == 0) { + (void) HDfprintf(stderr, "%s", err4b); + return (-1); + } + + if (in->outputClass == 1) + if (in->outputSize != 32 && in->outputSize != 64) { + (void) HDfprintf(stderr, "%s", err5); + return (-1); + } + +#ifndef H5_SIZEOF_LONG_LONG + if (in->inputSize == 64 && (in->inputClass == 0 || in->inputClass == 4 || in->inputClass == 6 || in->inputClass == 7) ) { + (void) HDfprintf(stderr, "%s", err6); + return -1; + } +#endif + return (0); +} + +static int mapKeywordToIndex(char *key) +{ + int i; + + for (i = 0; i < NUM_KEYS; i++) + if (!HDstrcmp(keytable[i], key)) + return i; + return -1; +} + +static int parsePathInfo(struct path_info *path, char *temp) +{ + const char delimiter[] = "/\""; + char *token; + int i = 0; + const char *err1 = "Path string larger than MAX_PATH_NAME_LENGTH.\n"; + + token = HDstrtok (temp, delimiter); + if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) { + (void) HDfprintf(stderr, err1); + return (-1); + } + HDstrcpy(path->group[i++],token); + + while (1) { + token = HDstrtok (NULL, delimiter); + if (token == NULL) + break; + if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) { + (void) HDfprintf(stderr, err1); + return (-1); + } + HDstrcpy(path->group[i++],token); + } + path->count = i; + return (0); +} + +static int parseDimensions(struct Input *in, char *strm) +{ + const char delimiter[] = ","; + char temp[255]; + char *token; + int i = 0; + const char *err1 = "Unable to allocate dynamic memory.\n"; + + HDstrncpy(temp, strm, sizeof(temp)); + temp[sizeof(temp) - 1] = '\0'; + HDstrtok (temp, delimiter); + + while (1) { + token = HDstrtok (NULL, delimiter); + if (token == NULL) + break; + i++; + } + in->rank = i + 1; + if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { + (void) HDfprintf(stderr, "%s", err1); + return (-1); + } + + i = 0; + HDstrncpy(temp, strm, sizeof(temp)); + temp[sizeof(temp) - 1] = '\0'; + in->sizeOfDimension[i++] + = HDstrtol(HDstrtok (temp, delimiter), NULL, BASE_10); + + while (1) { + token = HDstrtok (NULL, delimiter); + if (token == NULL) + break; + in->sizeOfDimension[i++] = HDstrtol(token, NULL, BASE_10); + } + return (0); +} + +static int getOutputClass(struct Input *in, FILE *strm) +{ + char temp[255]; + int kindex; + const char *err1 = "Unable to get 'string' value.\n"; + const char *err2 = "Invalid value for output class.\n"; + + if (fscanf(strm, "%s", temp) != 1) { + (void) HDfprintf(stderr, "%s", err1); + return (-1); + } + + if ((kindex = OutputClassStrToInt(temp)) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + + in->outputClass = kindex; + return (0); +} + +static int OutputClassStrToInt(char *temp) +{ + int i; + char classKeywordTable[3][15] = { "IN", "FP", "UIN" }; + for (i = 0; i < 3; i++) + if (!HDstrcmp(classKeywordTable[i], temp)) + return i; + + return -1; +} +/* same as getInputSize. But defined separately for extensibility */ +static int getOutputSize(struct Input *in, FILE *strm) +{ + int ival; + int i; + int outputSizeValidValues[4] = { 8, 16, 32, 64 }; + const char *err1 = "Unable to get integer value.\n"; + const char *err2 = "Invalid value for output size.\n"; + + if (fscanf(strm, "%d", (&ival)) != 1) { + (void) HDfprintf(stderr, "%s", err1); + return (-1); + } + + for (i = 0; i < 4; i++) + if (outputSizeValidValues[i] == ival) { + in->outputSize = ival; + return (0); + } + (void) HDfprintf(stderr, "%s", err2); + return (-1); +} + +static int getInputClass(struct Input *in, char * temp) +{ + int kindex; + const char *err1 = "Invalid value for input class.\n"; + + if ((kindex = InputClassStrToInt(temp)) == -1) { + (void) HDfprintf(stderr, "%s", err1); + return (-1); + } + + in->inputClass = kindex; + return (0); +} + +static int getInputClassType(struct Input *in, char * buffer) +{ + int kindex = -1; + const char *err1 = "Invalid value for input class.\n"; + const char *err2 = "Invalid value for output architecture.\n"; + const char *err3 = "Invalid value for output byte-order.\n"; + + if (!HDstrcmp(buffer, "H5T_STD_I8BE")) { + in->inputSize = 8; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_I8LE")) { + in->inputSize = 8; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_I16BE")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_I16LE")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_I32BE")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_I32LE")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_I64BE")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_I64LE")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_STD_U8BE")) { + in->inputSize = 8; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_STD_U8LE")) { + in->inputSize = 8; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_STD_U16BE")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_STD_U16LE")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_STD_U32BE")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_STD_U32LE")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_STD_U64BE")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_STD_U64LE")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_SCHAR")) { + in->inputSize = 8; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_UCHAR")) { + in->inputSize = 8; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_SHORT")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_USHORT")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_INT")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_UINT")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_LONG")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_ULONG")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_LLONG")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 4; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_ULLONG")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 7; + } + else if (!HDstrcmp(buffer, "H5T_IEEE_F32BE")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("IEEE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; - default: - break; + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); } - } - /* - check if keywords obtained are valid - if yes, return 0 else error - */ + in->outputByteOrder = kindex; - if (validateConfigurationParameters(in) == -1) { - (void) HDfprintf(stderr, err17, infile); - HDfclose(strm); - return (-1); + kindex = 3; } + else if (!HDstrcmp(buffer, "H5T_IEEE_F32LE")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; - HDfclose(strm); - return (0); -} - -static int validateConfigurationParameters(struct Input *in) -{ - const char *err1 = "One or more of the required fields (RANK, DIMENSION-SIZES) missing.\n"; - const char *err2 = "Cannot specify chunking or compression or extendible data sets with the external file option.\n"; - const char *err3 = "Cannot specify the compression or the extendible data sets without the chunking option.\n"; - const char *err4a = "OUTPUT-ARCHITECTURE cannot be STD if OUTPUT-CLASS is floating point (FP).\n"; - const char *err4b = "OUTPUT-ARCHITECTURE cannot be IEEE if OUTPUT-CLASS is integer (IN).\n"; - const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n"; -#ifndef H5_SIZEOF_LONG_LONG - const char *err6 = "No support for reading 64-bit integer (INPUT-CLASS: IN, TEXTIN, UIN, TEXTUIN files\n"; -#endif + if ((kindex = OutputArchStrToInt("IEEE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; - /* for class STR other parameters are ignored */ - if (in->inputClass == 5) /* STR */ - return (0); + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; - if ((in->configOptionVector[DIM] != 1) || (in->configOptionVector[RANK] != 1)) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); + kindex = 3; } + else if (!HDstrcmp(buffer, "H5T_IEEE_F64BE")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; - if (in->configOptionVector[EXTERNALSTORE] == 1) { - if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[CHUNK] == 1) || (in->configOptionVector[EXTEND] == 1)) { + if ((kindex = OutputArchStrToInt("IEEE")) == -1) { (void) HDfprintf(stderr, "%s", err2); return (-1); } - } + in->outputArchitecture = kindex; - if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[EXTEND] == 1)) { - if (in->configOptionVector[CHUNK] != 1) { + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { (void) HDfprintf(stderr, "%s", err3); return (-1); } + in->outputByteOrder = kindex; + + kindex = 3; } + else if (!HDstrcmp(buffer, "H5T_IEEE_F64LE")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; - /* Arch cant be STD if O/p class is FP */ - if (in->outputArchitecture == 1) - if (in->outputClass == 1) { - (void) HDfprintf(stderr, "%s", err4a); + if ((kindex = OutputArchStrToInt("IEEE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); return (-1); } + in->outputArchitecture = kindex; - /* Arch cant be IEEE if O/p class is IN */ - if (in->outputArchitecture == 2) - if (in->outputClass == 0) { - (void) HDfprintf(stderr, "%s", err4b); + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); return (-1); } + in->outputByteOrder = kindex; - if (in->outputClass == 1) - if (in->outputSize != 32 && in->outputSize != 64) { - (void) HDfprintf(stderr, "%s", err5); + kindex = 3; + } + else if (!HDstrcmp(buffer, "H5T_VAX_F32")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + kindex = 3; + } + else if (!HDstrcmp(buffer, "H5T_VAX_F64")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; + + kindex = 3; + } + else if (!HDstrcmp(buffer, "H5T_NATIVE_FLOAT")) { + in->inputSize = 32; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); return (-1); } + in->outputArchitecture = kindex; -#ifndef H5_SIZEOF_LONG_LONG - if (in->inputSize == 64 && (in->inputClass == 0 || in->inputClass == 4 || in->inputClass == 6 || in->inputClass == 7) ) { - (void) HDfprintf(stderr, "%s", err6); - return -1; + kindex = 3; } -#endif - return (0); -} + else if (!HDstrcmp(buffer, "H5T_NATIVE_DOUBLE")) { + in->inputSize = 64; + in->configOptionVector[INPUT_SIZE] = 1; -static int mapKeywordToIndex(char *key) -{ - int i; + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; - for (i = 0; i < NUM_KEYS; i++) - if (!HDstrcmp(keytable[i], key)) - return i; - return -1; -} + kindex = 3; + } +#if H5_SIZEOF_LONG_DOUBLE !=0 + else if (!HDstrcmp(buffer, "H5T_NATIVE_LDOUBLE")) { + in->inputSize = H5_SIZEOF_LONG_DOUBLE; + in->configOptionVector[INPUT_SIZE] = 1; -static int parsePathInfo(struct path_info *path, char *temp) -{ - const char delimiter[] = "/"; - char *token; - int i = 0; - const char *err1 = "Path string larger than MAX_PATH_NAME_LENGTH.\n"; + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; - token = HDstrtok (temp, delimiter); - if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) { - (void) HDfprintf(stderr, err1); - return (-1); + kindex = 3; } - HDstrcpy(path->group[i++],token); +#endif + else if(!HDstrcmp(buffer, "H5T_TIME: not yet implemented")) { + kindex = -1; + } + else if(!HDstrcmp(buffer, "H5T_STRING")) { + kindex = 5; + } + /* case H5T_BITFIELD: */ + else if (!HDstrcmp(buffer, "H5T_STD_B8BE")) { - while (1) { - token = HDstrtok (NULL, delimiter); - if (token == NULL) - break; - if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) { - (void) HDfprintf(stderr, err1); + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); return (-1); } - HDstrcpy(path->group[i++],token); + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = -1; } - path->count = i; - return (0); -} + else if (!HDstrcmp(buffer, "H5T_STD_B8LE")) { -static int parseDimensions(struct Input *in, char *strm) -{ - const char delimiter[] = ","; - char temp[255]; - char *token; - int i = 0; - const char *err1 = "Unable to allocate dynamic memory.\n"; + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; - HDstrncpy(temp, strm, sizeof(temp)); - temp[sizeof(temp) - 1] = '\0'; - HDstrtok (temp, delimiter); + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; - while (1) { - token = HDstrtok (NULL, delimiter); - if (token == NULL) - break; - i++; - } - in->rank = i + 1; - if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); + kindex = -1; } + else if (!HDstrcmp(buffer, "H5T_STD_B16BE")) { - i = 0; - HDstrncpy(temp, strm, sizeof(temp)); - temp[sizeof(temp) - 1] = '\0'; - in->sizeOfDimension[i++] - = HDstrtol(HDstrtok (temp, delimiter), NULL, BASE_10); + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; - while (1) { - token = HDstrtok (NULL, delimiter); - if (token == NULL) - break; - in->sizeOfDimension[i++] = HDstrtol(token, NULL, BASE_10); + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = -1; } - return (0); -} + else if (!HDstrcmp(buffer, "H5T_STD_B16LE")) { -static int getOutputClass(struct Input *in, FILE *strm) -{ - char temp[255]; - int kindex; - const char *err1 = "Unable to get 'string' value.\n"; - const char *err2 = "Invalid value for output class.\n"; + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; - if (fscanf(strm, "%s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = -1; } + else if (!HDstrcmp(buffer, "H5T_STD_B32BE")) { - if ((kindex = OutputClassStrToInt(temp)) == -1) { - (void) HDfprintf(stderr, "%s", err2); - return (-1); + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = -1; } + else if (!HDstrcmp(buffer, "H5T_STD_B32LE")) { - in->outputClass = kindex; - return (0); -} + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; -static int OutputClassStrToInt(char *temp) -{ - int i; - char classKeywordTable[3][15] = { "IN", "FP", "UIN" }; - for (i = 0; i < 3; i++) - if (!HDstrcmp(classKeywordTable[i], temp)) - return i; + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; - return -1; -} -/* same as getInputSize. But defined separately for extensibility */ -static int getOutputSize(struct Input *in, FILE *strm) -{ - int ival; - int i; - int outputSizeValidValues[4] = { 8, 16, 32, 64 }; - const char *err1 = "Unable to get integer value.\n"; - const char *err2 = "Invalid value for output size.\n"; + kindex = -1; + } + else if (!HDstrcmp(buffer, "H5T_STD_B64BE")) { - if (fscanf(strm, "%d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; + + kindex = -1; } + else if (!HDstrcmp(buffer, "H5T_STD_B64LE")) { - for (i = 0; i < 4; i++) - if (outputSizeValidValues[i] == ival) { - in->outputSize = ival; - return (0); + if ((kindex = OutputArchStrToInt("STD")) == -1) { + (void) HDfprintf(stderr, "%s", err2); + return (-1); } - (void) HDfprintf(stderr, "%s", err2); - return (-1); -} + in->outputArchitecture = kindex; -static int getInputClass(struct Input *in, char * temp) -{ - int kindex; - const char *err1 = "Invalid value for input class.\n"; + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void) HDfprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; - if ((kindex = InputClassStrToInt(temp)) == -1) { + kindex = -1; + } + /* case H5T_OPAQUE: */ + else if(!HDstrcmp(buffer, "H5T_OPAQUE")) { + kindex = -1; + } + /* case H5T_COMPOUND: */ + else if(!HDstrcmp(buffer, "H5T_COMPOUND")) { + kindex = -1; + } + /* case H5T_REFERENCE: */ + else if(!HDstrcmp(buffer, "H5T_REFERENCE")) { + kindex = -1; + } + /* case H5T_ENUM: */ + else if(!HDstrcmp(buffer, "H5T_ENUM")) { + kindex = -1; + } + /* case H5T_VLEN: */ + else if(!HDstrcmp(buffer, "H5T_VLEN")) { + kindex = -1; + } + /* case H5T_ARRAY: */ + else if(!HDstrcmp(buffer, "H5T_ARRAY")) { + kindex = -1; + } + + if (kindex == -1) { (void) HDfprintf(stderr, "%s", err1); return (-1); } + /*set default value for output-size */ + if (in->configOptionVector[OUTPUT_SIZE] == 0) + in->outputSize = in->inputSize; +#ifdef H5DEBUGIMPORT + printf("h5dump DATATYPE STRING %d inputSize\n", in->inputSize); + printf("h5dump DATATYPE STRING %d outputSize\n", in->outputSize); +#endif + in->inputClass = kindex; return (0); } @@ -1910,6 +3408,7 @@ void setDefaultValues(struct Input *in, int count) char temp[255]; char num[255]; + in->h5dumpInput = 0; in->inputClass = 3; /* FP */ in->inputSize = 32; in->outputClass = 1; /* FP */ @@ -2348,6 +3847,9 @@ static int process(struct Options *opt) /*create data type */ intype = createInputDataType(in); outtype = createOutputDataType(in); +#ifdef H5DEBUGIMPORT + printf("process intype %d outtype %d\n", intype, outtype); +#endif /* create property list */ proplist = H5Pcreate(H5P_DATASET_CREATE); @@ -2498,7 +4000,7 @@ void help(char *name) (void) HDfprintf(stdout, "\t The user can specify output type and storage properties in \n"); (void) HDfprintf(stdout, - "\t the configuration file. The user is requited to specify the \n"); + "\t the configuration file. The user is required to specify the \n"); (void) HDfprintf(stdout, "\t path of the dataset. If the groups in the path leading to \n"); (void) HDfprintf(stdout, @@ -2511,7 +4013,7 @@ void help(char *name) (void) HDfprintf(stdout, "\t provide the class and size of output data to be written to \n"); (void) HDfprintf(stdout, - "\t the dataset and may optionally specify the output-architecure,\n"); + "\t the dataset and may optionally specify the output-architecture,\n"); (void) HDfprintf(stdout, "\t and the output-byte-order. If output-architecture is not \n"); (void) HDfprintf(stdout, @@ -2596,7 +4098,11 @@ void help(char *name) (void) HDfprintf(stdout, "\t The configuration file is an ASCII text file and must be \n"); (void) HDfprintf(stdout, - "\t organized as \"CONFIG-KEYWORD VALUE\" pairs, one pair on each \n"); + "\t the ddl formatted file (without data values) produced by h5dump \n"); + (void) HDfprintf(stdout, + "\t when used with the options '-o outfilename -b' of a single dataset (-d) \n"); + (void) HDfprintf(stdout, + "\t OR organized as \"CONFIG-KEYWORD VALUE\" pairs, one pair on each \n"); (void) HDfprintf(stdout, "\t line.\n\n"); (void) HDfprintf(stdout, "\t The configuration file may have the following keywords each \n"); @@ -2612,7 +4118,7 @@ void help(char *name) (void) HDfprintf(stdout, "\t Optional KEYWORDS:\n"); (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE\n"); (void) HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER\n"); - (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES\n"); + (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES\n"); (void) HDfprintf(stdout, "\t COMPRESSION-TYPE\n"); (void) HDfprintf(stdout, "\t COMPRESSION-PARAM\n"); (void) HDfprintf(stdout, "\t EXTERNAL-STORAGE\n"); @@ -2622,7 +4128,7 @@ void help(char *name) (void) HDfprintf(stdout, "\t Strings separated by spaces to represent\n"); (void) HDfprintf(stdout, "\t the path of the data-set. If the groups in\n"); (void) HDfprintf(stdout, - "\t the path do no exist, they will be created. \n"); + "\t the path do not exist, they will be created. \n"); (void) HDfprintf(stdout, "\t For example,\n"); (void) HDfprintf(stdout, "\t PATH grp1/grp2/dataset1\n"); (void) HDfprintf(stdout, "\t PATH: keyword\n"); diff --git a/tools/h5import/h5import.h b/tools/h5import/h5import.h index dbc6844..c686624 100644 --- a/tools/h5import/h5import.h +++ b/tools/h5import/h5import.h @@ -44,20 +44,20 @@ #define MAX_NUM_DIMENSION 32 #define BASE_10 10 -#define CHUNK 0 -#define COMPRESS 1 -#define EXTEND 2 -#define EXTERNALSTORE 3 +#define PATH 0 +#define INPUT_CLASS 1 +#define INPUT_SIZE 2 +#define RANK 3 #define DIM 4 -#define RANK 5 -#define PATH 6 -#define INPUT_CLASS 7 -#define INPUT_SIZE 8 -#define OUTPUT_CLASS 9 -#define OUTPUT_SIZE 10 -#define OUTPUT_ARCH 11 -#define OUTPUT_B_ORDER 12 -#define COMPRESS_PARAM 13 +#define OUTPUT_CLASS 5 +#define OUTPUT_SIZE 6 +#define OUTPUT_ARCH 7 +#define OUTPUT_B_ORDER 8 +#define CHUNK 9 +#define COMPRESS 10 +#define COMPRESS_PARAM 11 +#define EXTERNALSTORE 12 +#define EXTEND 13 /* data types */ #define H5DT_INT8 signed char @@ -80,6 +80,7 @@ struct path_info struct Input { + int h5dumpInput; struct path_info path; int inputClass; int inputSize; @@ -198,6 +199,7 @@ static int parsePathInfo(struct path_info *path, char *strm); static int parseDimensions(struct Input *in, char *strm); static int getInputSize(struct Input *in, int ival); static int getInputClass(struct Input *in, char * strm); +static int getInputClassType(struct Input *in, char * strm); static int InputClassStrToInt(char *temp); static int getRank(struct Input *in, FILE *strm); static int getDimensionSizes(struct Input *in, FILE *strm); @@ -225,6 +227,7 @@ static int readUIntegerData(FILE *strm, struct Input *in); static int allocateUIntegerStorage(struct Input *in); static int validateConfigurationParameters(struct Input *in); static int processStrData(FILE *strm, struct Input *in, hid_t file_id); +static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id); #endif /* H5IMPORT_H__ */ diff --git a/tools/h5import/h5importtestutil.sh b/tools/h5import/h5importtestutil.sh index 7289b2a..86db229 100755 --- a/tools/h5import/h5importtestutil.sh +++ b/tools/h5import/h5importtestutil.sh @@ -101,6 +101,14 @@ $SRC_H5IMPORT_TESTFILES/txtin16.txt $SRC_H5IMPORT_TESTFILES/txtin32.txt $SRC_H5IMPORT_TESTFILES/textpfe64.txt $SRC_H5IMPORT_TESTFILES/txtstr.txt +$SRC_H5IMPORT_TESTFILES/dbinfp64.h5.txt +$SRC_H5IMPORT_TESTFILES/dbinin8.h5.txt +$SRC_H5IMPORT_TESTFILES/dbinin8w.h5.txt +$SRC_H5IMPORT_TESTFILES/dbinin16.h5.txt +$SRC_H5IMPORT_TESTFILES/dbinin32.h5.txt +$SRC_H5IMPORT_TESTFILES/dbinuin16.h5.txt +$SRC_H5IMPORT_TESTFILES/dbinuin32.h5.txt +$SRC_H5IMPORT_TESTFILES/dtxtstr.h5.txt " # @@ -153,6 +161,47 @@ else fi } +# Use h5dump output as input to h5import for binary numbers +# Use h5diff to verify results +TOOLTEST2() +{ +err=0 +$RUNSERIAL ../h5dump/h5dump -p -d $1 -o d$2.bin -b tmp_testfiles/$2 > d$2.dmp +$RUNSERIAL ./h5import d$2.bin -c d$2.dmp -o d$2 > d$2.imp +$RUNSERIAL ../h5diff/h5diff -v d$2 tmp_testfiles/$2 $1 $1 > log2 +$CP -f $SRC_H5IMPORT_TESTFILES/d$2.txt log1 + +cmp -s log1 log2 || err=1 +rm -f log1 log2 +if [ $err -eq 1 ]; then +nerrors="` expr $nerrors + 1 `"; + echo "*FAILED*" +else + echo " PASSED" +fi +} + +# Same as TOOLTEST2 except for strings +# Use h5dump output as input to h5import for strings +# Use h5diff to verify results +TOOLTEST3() +{ +err=0 +$RUNSERIAL ../h5dump/h5dump -p -d $1 -o d$2.bin -y --width=1 tmp_testfiles/$2 > d$2.dmp +$RUNSERIAL ./h5import d$2.bin -c d$2.dmp -o d$2 > d$2.imp +$RUNSERIAL ../h5diff/h5diff -v d$2 tmp_testfiles/$2 $1 $1 > log2 +$CP -f $SRC_H5IMPORT_TESTFILES/d$2.txt log1 + +cmp -s log1 log2 || err=1 +rm -f log1 log2 +if [ $err -eq 1 ]; then +nerrors="` expr $nerrors + 1 `"; + echo "*FAILED*" +else + echo " PASSED" +fi +} + echo "" echo "==============================" echo "H5IMPORT tests started" @@ -198,39 +247,56 @@ TOOLTEST $TESTDIR/txtfp32.txt -c $TESTDIR/txtfp32.conf -o txtfp32.h5 TESTING "ASCII F64 - rank 3 - Output BE + CHUNKED+Extended+Compressed " TOOLTEST $TESTDIR/txtfp64.txt -c $TESTDIR/txtfp64.conf -o txtfp64.h5 + TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " TOOLTEST binfp64.bin -c $TESTDIR/binfp64.conf -o binfp64.h5 +TESTING "H5DUMP-BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " +TOOLTEST2 "/fp/bin/64-bit" binfp64.h5 TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " -TOOLTEST binin8.bin -c $TESTDIR/binin8.conf -o binin8.h5 +TOOLTEST binin8.bin -c $TESTDIR/binin8.conf -o binin8.h5 +TESTING "H5DUMP-BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " +TOOLTEST2 "/int/bin/8-bit" binin8.h5 TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended " TOOLTEST binin16.bin -c $TESTDIR/binin16.conf -o binin16.h5 +TESTING "H5DUMP-BINARY I16 - rank 3 - Output order LE + CHUNKED + extended " +TOOLTEST2 "/int/bin/16-bit" binin16.h5 TESTING "BINARY I32 - rank 3 - Output BE + CHUNKED " TOOLTEST binin32.bin -c $TESTDIR/binin32.conf -o binin32.h5 +TESTING "H5DUMP-BINARY I32 - rank 3 - Output BE + CHUNKED " +TOOLTEST2 "/int/bin/32-bit" binin32.h5 TESTING "BINARY UI16 - rank 3 - Output byte BE + CHUNKED " TOOLTEST binuin16.bin -c $TESTDIR/binuin16.conf -o binuin16.h5 +TESTING "H5DUMP-BINARY UI16 - rank 3 - Output byte BE + CHUNKED " +TOOLTEST2 "/int/buin/16-bit" binuin16.h5 TESTING "BINARY UI32 - rank 3 - Output LE + CHUNKED " TOOLTEST binuin32.bin -c $TESTDIR/binuin32.conf -o binuin32.h5 +TESTING "H5DUMP-BINARY UI32 - rank 3 - Output LE + CHUNKED " +TOOLTEST2 "/int/buin/32-bit" binuin32.h5 TESTING "STR" TOOLTEST $TESTDIR/txtstr.txt -c $TESTDIR/txtstr.conf -o txtstr.h5 +TESTING "H5DUMP-STR" +TOOLTEST3 "/mytext/data" txtstr.h5 TESTING "BINARY I8 CR LF EOF" TOOLTEST binin8w.bin -c $TESTDIR/binin8w.conf -o binin8w.h5 +TESTING "H5DUMP-BINARY I8 CR LF EOF" +TOOLTEST2 "/dataset0" binin8w.h5 TESTING "ASCII F64 - rank 1 - INPUT-CLASS TEXTFPE " TOOLTEST $TESTDIR/textpfe64.txt -c $TESTDIR/textpfe.conf -o textpfe.h5 -rm -f txtin32.txt txtin16.txt txtin8.txt txtuin32.txt txtuin16.txt *.bin *.h5 +rm -f txtin32.txt txtin16.txt txtin8.txt txtuin32.txt txtuin16.txt *.bin *.dmp *.imp *.h5 rm -rf tmp_testfiles else echo "** h5import or h5importtest not available ***" diff --git a/tools/h5import/testfiles/dbinfp64.h5.txt b/tools/h5import/testfiles/dbinfp64.h5.txt new file mode 100644 index 0000000..fb88984 --- /dev/null +++ b/tools/h5import/testfiles/dbinfp64.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5import/testfiles/dbinin16.h5.txt b/tools/h5import/testfiles/dbinin16.h5.txt new file mode 100644 index 0000000..b94781e --- /dev/null +++ b/tools/h5import/testfiles/dbinin16.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5import/testfiles/dbinin32.h5.txt b/tools/h5import/testfiles/dbinin32.h5.txt new file mode 100644 index 0000000..a35cd79 --- /dev/null +++ b/tools/h5import/testfiles/dbinin32.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5import/testfiles/dbinin8.h5.txt b/tools/h5import/testfiles/dbinin8.h5.txt new file mode 100644 index 0000000..bbc6c67 --- /dev/null +++ b/tools/h5import/testfiles/dbinin8.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5import/testfiles/dbinin8w.h5.txt b/tools/h5import/testfiles/dbinin8w.h5.txt new file mode 100644 index 0000000..28d43d2 --- /dev/null +++ b/tools/h5import/testfiles/dbinin8w.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5import/testfiles/dbinuin16.h5.txt b/tools/h5import/testfiles/dbinuin16.h5.txt new file mode 100644 index 0000000..ecad7a0 --- /dev/null +++ b/tools/h5import/testfiles/dbinuin16.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5import/testfiles/dbinuin32.h5.txt b/tools/h5import/testfiles/dbinuin32.h5.txt new file mode 100644 index 0000000..cc1d9f3 --- /dev/null +++ b/tools/h5import/testfiles/dbinuin32.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found diff --git a/tools/h5import/testfiles/dtxtstr.h5.txt b/tools/h5import/testfiles/dtxtstr.h5.txt new file mode 100644 index 0000000..2170300 --- /dev/null +++ b/tools/h5import/testfiles/dtxtstr.h5.txt @@ -0,0 +1,2 @@ +dataset: and +0 differences found -- cgit v0.12 From 3a1c4de35969f10b9862111695e3148adc577445 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 20 Jul 2012 11:41:11 -0500 Subject: [svn-r22589] Change strto functions to the HD prefix versions. Tested: local --- tools/h5import/h5import.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index d6dcf1d..34870fb 100644 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -1040,7 +1040,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) line = 0; j = 0; - while (fgets(str,sizeof(str),strm)) { + while (HDfgets(str,sizeof(str),strm)) { str1 = str; str2 = NULL; str3 = NULL; @@ -1419,7 +1419,7 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif if (HDstrcmp("H5T_VARIABLE;", temp)) { char *more = temp; - ival = strtoimax(more, &more, 10); + ival = HDstrtol(more, &more, 10); if (getInputSize(in, ival) == -1) { (void) HDfprintf(stderr, err5b, infile); HDfclose(strm); @@ -1529,7 +1529,7 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif while (get_next_dim) { char *more = temp; - temp_dims[icount] = strtoull(more, &more, 10); + temp_dims[icount] = HDstrtoull(more, &more, 10); if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ (void) HDfprintf(stderr, err6b, infile); HDfclose(strm); @@ -1623,7 +1623,7 @@ static int processConfigurationFile(char *infile, struct Input *in) } else { char *more = temp; - in->maxsizeOfDimension[i] = strtoull(more, &more, 10); + in->maxsizeOfDimension[i] = HDstrtoull(more, &more, 10); } if (fscanf(strm, "%s", temp) != 1) { /* max dim or end paren */ (void) HDfprintf(stderr, err16c, infile); @@ -1718,7 +1718,7 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif while (get_next_dim) { char *more = temp; - in->sizeOfChunk[icount] = strtoull(more, &more, 10); + in->sizeOfChunk[icount] = HDstrtoull(more, &more, 10); if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ (void) HDfprintf(stderr, err6b, infile); HDfclose(strm); -- cgit v0.12 From 23d32fec2549762344d365c64fa520d9e6537212 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 20 Jul 2012 11:55:37 -0500 Subject: [svn-r22590] correct reference file location in runTest command --- tools/h5import/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index 42c5c8e..352ba14 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -249,7 +249,7 @@ IF (BUILD_TESTING) -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.dff" -D "TEST_EXPECT=0" - -D "TEST_REFERENCE=d${testfile}.txt" + -D "TEST_REFERENCE=testfiles/d${testfile}.txt" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) SET_TESTS_PROPERTIES (H5IMPORT-DUMP-${testname}-H5DIFF PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}") -- cgit v0.12 From 9e08a0d8c5fd8da07cf80cd979f0d0eb1469aa97 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Sun, 22 Jul 2012 01:42:30 -0500 Subject: [svn-r22594] Bug fix: HDFFV-8105 Description: The test command in COPY_TESTFILES_TO_TESTDIR used the wrong operator -a which means and. It is not sufficient to test mere existence as $tstfile could have been a directory or other non-file things. If the file is not readable, the $CP command would fail but its return code was not checked. Solution: Get rid of the test command and go ahead to $CP it and then check its returned code and report errors if detected. Tested; committested. (note that ostrick still failed on errors committed by other staff). --- release_docs/RELEASE.txt | 3 +++ tools/h5diff/testh5diff.sh | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index fe9e703..338cc61 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -702,6 +702,9 @@ Bug Fixes since HDF5-1.8.0 release Tools ----- + - h5diff: Fixed the Function COPY_TESTFILES_TO_TESTDIR() of + testh5diff.sh to better report when there is an error in the file + copying. HDFFV-8105 (AKC -2012/07/22) - h5diff: Fixed not to check and display dangling link status without --follow-symlinks option. This also improved performance when comparing lots of external links without the --follow-symlinks diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index cb91a19..a208acf 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -318,11 +318,9 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then echo "Error: FAILED to copy $tstfile ." - echo " $tstfile doesn't exist!" # Comment out this to CREATE expected file exit $EXIT_FAILURE -- cgit v0.12 From ab072288ad0876d21dec7fcae78869a1477ddb39 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 23 Jul 2012 10:58:30 -0500 Subject: [svn-r22598] BE machines have a different offset in STORAGE_LAYOUT then the LE machines. Use h5diff with -r to not report warnings. Tested: local with CMake and ostrich with shell script --- tools/h5import/CMakeLists.txt | 1 + tools/h5import/h5importtestutil.sh | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index 352ba14..5bbcf02 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -249,6 +249,7 @@ IF (BUILD_TESTING) -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.dff" -D "TEST_EXPECT=0" + -D "TEST_FILTER=(^(Warning)[^\n]*)" -D "TEST_REFERENCE=testfiles/d${testfile}.txt" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) diff --git a/tools/h5import/h5importtestutil.sh b/tools/h5import/h5importtestutil.sh index 86db229..5be3118 100755 --- a/tools/h5import/h5importtestutil.sh +++ b/tools/h5import/h5importtestutil.sh @@ -202,6 +202,28 @@ else fi } +# Same as TOOLTEST3 except for h5diff uses report mode without warnings +# Use h5dump output as input to h5import for strings +# Use h5diff to verify results +TOOLTEST4() +{ +err=0 +$RUNSERIAL ../h5dump/h5dump -p -d $1 -o d$2.bin -y --width=1 tmp_testfiles/$2 > d$2.dmp +$RUNSERIAL ./h5import d$2.bin -c d$2.dmp -o d$2 > d$2.imp +$RUNSERIAL ../h5diff/h5diff -r d$2 tmp_testfiles/$2 $1 $1 > log2 +$CP -f $SRC_H5IMPORT_TESTFILES/d$2.txt log1 + + +cmp -s log1 log2 || err=1 +rm -f log1 log2 +if [ $err -eq 1 ]; then +nerrors="` expr $nerrors + 1 `"; + echo "*FAILED*" +else + echo " PASSED" +fi +} + echo "" echo "==============================" echo "H5IMPORT tests started" @@ -284,7 +306,7 @@ TOOLTEST2 "/int/buin/32-bit" binuin32.h5 TESTING "STR" TOOLTEST $TESTDIR/txtstr.txt -c $TESTDIR/txtstr.conf -o txtstr.h5 TESTING "H5DUMP-STR" -TOOLTEST3 "/mytext/data" txtstr.h5 +TOOLTEST43 "/mytext/data" txtstr.h5 TESTING "BINARY I8 CR LF EOF" -- cgit v0.12 From b5ef63b550d4d1149aebb0c46aebc7df672427aa Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 24 Jul 2012 09:10:05 -0500 Subject: [svn-r22599] FinHDF5 should be generated during build. --- MANIFEST | 2 +- config/cmake/FindHDF5.cmake.in | 85 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 config/cmake/FindHDF5.cmake.in diff --git a/MANIFEST b/MANIFEST index e106216..2659d0e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2290,7 +2290,7 @@ ./config/cmake/CheckTypeSize.cmake ./config/cmake/H5cxx_config.h.in ./config/cmake/H5pubconf.h.in -./config/cmake/FindHDF5.cmake +./config/cmake/FindHDF5.cmake.in ./config/cmake/FindMPI.cmake ./config/cmake/hdf5-config.cmake.build.in ./config/cmake/hdf5-config.cmake.install.in diff --git a/config/cmake/FindHDF5.cmake.in b/config/cmake/FindHDF5.cmake.in new file mode 100644 index 0000000..a866859 --- /dev/null +++ b/config/cmake/FindHDF5.cmake.in @@ -0,0 +1,85 @@ +# +# 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_PACKAGE@ + /usr/share/@HDF5_PACKAGE@ + /usr/local/@HDF5_PACKAGE@ + /usr/local/@HDF5_PACKAGE@/share +) + +FIND_PATH (HDF5_ROOT_DIR "@HDF5_PACKAGE@@HDF5_PACKAGE_EXT@-config.cmake" + HINTS ${_HDF5_HINTS} + PATHS ${_HDF5_PATHS} + PATH_SUFFIXES + lib/cmake/@HDF5_PACKAGE@ + share/cmake/@HDF5_PACKAGE@ +) + +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_PACKAGE@@HDF5_PACKAGE_EXT@-config.cmake) +ENDIF (HDF5_INCLUDE_DIR) -- cgit v0.12 From c04144fb39b6d7a489c37e89ac8a0240991026a6 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Wed, 25 Jul 2012 16:50:22 -0500 Subject: [svn-r22601] Purpose: Fix HDFFV-5853 Description: When jumping out from between H5_BEGIN_TAG and H5_END_TAG macros using HGOTO_ERROR or HGOTO_DONE, the previous metadata tag is not reset on the dxpl. This could cause problems when, for example, calling H5Ocopy within an H5Literate callback. Added new HGOTO_ERROR_TAG and HGOTO_DONE_TAG macros which must be used in place of the above between H5_BEGIN_TAG and H5_END_TAG. Tested: jam, koala, ostrich (h5committest), durandal --- release_docs/RELEASE.txt | 3 ++ src/H5Aint.c | 2 +- src/H5Dchunk.c | 2 +- src/H5Eprivate.h | 21 ++++++++++ src/H5Gnode.c | 2 +- src/H5Gtest.c | 14 +++---- src/H5Gtraverse.c | 4 +- src/H5O.c | 2 +- src/H5Oainfo.c | 4 +- src/H5Ocopy.c | 2 +- src/H5Olinfo.c | 2 +- src/H5Oshared.c | 2 +- src/H5Ostab.c | 2 +- src/H5Otest.c | 22 +++++------ src/H5private.h | 3 +- test/objcopy.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ 16 files changed, 155 insertions(+), 31 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 338cc61..aafb18e 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -378,6 +378,9 @@ Bug Fixes since HDF5-1.8.0 release Library ------- + - Fixed an error that could occur when calling H5Ocopy within an + H5Literate callback (and possibly other situations). + (NAF - 2012/7/25 - HDFFV-5853) - Fixed an error that would occur when copying an object with attribute creation order tracked and indexed. (NAF - 2012/3/28 - HDFFV-7762) - Fixed a bug in H5Ocopy(): When copying an opened object, call the diff --git a/src/H5Aint.c b/src/H5Aint.c index 9503a1c..ab9bece 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1197,7 +1197,7 @@ H5A_dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) /* Insert attribute into dense storage */ if(H5A_dense_insert(udata->file, udata->dxpl_id, udata->ainfo, attr_dst) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") /* Reset metadata tag */ H5_END_TAG(H5_ITER_ERROR); diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index dfb4011..93e8869 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -4408,7 +4408,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Insert chunk into the destination index */ if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk into index") + HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk into index") /* Reset metadata tag in dxpl_id */ H5_END_TAG(H5_ITER_ERROR); diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 2ca48d2..b2ca5eb 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -69,6 +69,17 @@ typedef struct H5E_t H5E_t; } /* + * HGOTO_ERROR_TAG macro, used like HGOTO_ERROR between H5_BEGIN_TAG and + * H5_END_TAG statements. Resets the metadata tag before leaving the function. + */ +#define HGOTO_ERROR_TAG(maj, min, ret_val, ...) { \ + if(H5AC_tag(my_dxpl_id, prv_tag, NULL) < 0) \ + HERROR(H5E_CACHE, H5E_CANTTAG, "unable to apply metadata tag"); \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + HGOTO_DONE(ret_val) \ +} + +/* * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER() * and a FUNC_LEAVE() within a function body. The argument is the return * value which is assigned to the `ret_value' variable. Control branches to @@ -77,6 +88,16 @@ typedef struct H5E_t H5E_t; #define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} /* + * HGOTO_DONE_TAG macro, used like HGOTO_DONE between H5_BEGIN_TAG and + * H5_END_TAG statements. Resets the metadata tag before leaving the function. + */ +#define HGOTO_DONE_TAG(ret_val, err) { \ + if(H5AC_tag(my_dxpl_id, prv_tag, NULL) < 0) \ + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ + HGOTO_DONE(ret_val) \ +} + +/* * Macros handling system error messages as described in C standard. * These macros assume errnum is a valid system error code. */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 4d2e045..c0d2885 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1367,7 +1367,7 @@ H5G__node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr if(H5G__stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, obj_type, (obj_type == H5O_TYPE_GROUP ? &gcrt_info : NULL), dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") + HGOTO_ERROR_TAG(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") /* Reset metadata tag */ H5_END_TAG(H5_ITER_ERROR); diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 48aa10b..b39b4ff 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -399,31 +399,31 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) /* Get the link info */ if(H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") + HGOTO_ERROR_TAG(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ if(!H5F_addr_defined(linfo.fheap_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) if(!H5F_addr_defined(linfo.name_bt2_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ if(H5B2_get_nrec(bt2_name, name_count) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index aff87f8..1efc521 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -855,7 +855,7 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver if(H5P_get(lapl, H5L_ACS_NLINKS_NAME, &nlinks) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of links") } /* end else */ - + /* Set up invalid tag. This is a precautionary step only. Setting an invalid tag here will ensure that no metadata accessed while doing the traversal is given an improper tag, unless another one is specifically set up @@ -866,7 +866,7 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver /* Go perform "real" traversal */ if(H5G_traverse_real(loc, name, target, &nlinks, op, op_data, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed") + HGOTO_ERROR_TAG(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed") /* Reset tag after traversal */ H5_END_TAG(FAIL); diff --git a/src/H5O.c b/src/H5O.c index 104a9ae..5050941 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1258,7 +1258,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, /* Cache object header */ if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") oh = NULL; /* Reset metadata tag in dxpl_id */ diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index b207ea2..ad99be0 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -428,12 +428,12 @@ H5O_ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, if(H5F_addr_defined(ainfo_src->fheap_addr)) { /* copy dense attribute */ - + /* Set copied metadata tag */ H5_BEGIN_TAG(dxpl_id, H5AC__COPIED_TAG, NULL); if(H5A_dense_create(file_dst, dxpl_id, ainfo_dst) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") /* Reset metadata tag */ H5_END_TAG(NULL); diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 7b812ec..b22eeb0 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -862,7 +862,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Insert destination object header in cache */ if(H5AC_insert_entry(oloc_dst->file, dxpl_id, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") oh_dst = NULL; inserted = TRUE; diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index e96483a..5c0ed53 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -474,7 +474,7 @@ H5O_linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) /* Insert the new object in the destination file's group */ /* (Doesn't increment the link count - that's already been taken care of for hard links) */ if(H5G__dense_insert(udata->dst_oloc->file, udata->dxpl_id, udata->dst_linfo, &dst_lnk) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link") /* Reset metadata tag in dxpl_id */ H5_END_TAG(FAIL); diff --git a/src/H5Oshared.c b/src/H5Oshared.c index c29e2c7..e4a51ee 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -622,7 +622,7 @@ H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst, H5_BEGIN_TAG(dxpl_id, H5AC__COPIED_TAG, FAIL); if(H5SM_try_share(file_dst, dxpl_id, NULL, H5SM_DEFER, mesg_type->id, _native_dst, mesg_flags) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") /* Reset metadata tag */ H5_END_TAG(FAIL); diff --git a/src/H5Ostab.c b/src/H5Ostab.c index d5f5f86..47bd9fc 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -336,7 +336,7 @@ H5O_stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, /* Create components of symbol table message */ if(H5G__stab_create_components(file_dst, stab_dst, size_hint, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components") /* Reset metadata tag */ H5_END_TAG(NULL); diff --git a/src/H5Otest.c b/src/H5Otest.c index ca1b426..5802904 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -193,13 +193,13 @@ H5O_is_attr_empty_test(hid_t oid) if(H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ HDassert(nattrs == 0); - + /* Set metadata tag in dxpl_id */ H5_BEGIN_TAG(H5AC_ind_dxpl_id, loc->addr, FAIL); /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ H5_END_TAG(FAIL); @@ -292,7 +292,7 @@ H5O_num_attrs_test(hid_t oid, hsize_t *nattrs) /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ H5_END_TAG(FAIL); @@ -362,39 +362,39 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) /* Get the object header */ if(NULL == (oh = H5O_protect(loc, H5AC_ind_dxpl_id, H5AC_READ))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; if(oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ if(H5A_get_ainfo(loc->file, H5AC_ind_dxpl_id, oh, &ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") + HGOTO_ERROR_TAG(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for 'dense' attribute storage file addresses being defined */ if(!H5F_addr_defined(ainfo.fheap_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) if(!H5F_addr_defined(ainfo.name_bt2_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ if(H5B2_get_nrec(bt2_name, name_count) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ if(NULL == (bt2_corder = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; diff --git a/src/H5private.h b/src/H5private.h index 39ccb52..d30298f 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2291,7 +2291,8 @@ func_init_failed: \ /* Close Function */ \ } -/* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient) */ +/* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient). + * Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */ #define H5_BEGIN_TAG(dxpl, tag, err) { \ haddr_t prv_tag = HADDR_UNDEF; \ hid_t my_dxpl_id = dxpl; \ diff --git a/test/objcopy.c b/test/objcopy.c index ce0f3d3..6b56b66 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -11452,6 +11452,104 @@ error: /*------------------------------------------------------------------------- + * Function: test_copy_iterate + * + * Purpose: Tests iterating over objects in the root group, copying + * all of them. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Neil Fortner + * Thursday, July 12, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_copy_iterate_cb(hid_t loc_id, const char *name, + const H5L_info_t UNUSED *link_info, void *op_data) +{ + hid_t dst_loc_id = *((hid_t *)op_data); + + if(H5Ocopy(loc_id, name, dst_loc_id, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + + return(H5_ITER_CONT); + +error: + return(H5_ITER_ERROR); +} /* end test_copy_iterate_cb */ + +static int +test_copy_iterate(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) +{ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gid = -1; /* Group ID */ + int i; + char grp_name[8]; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + + TESTING("H5Ocopy(): inside H5Literate() callback"); + + /* Initialize the filenames */ + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], src_fapl, dst_filename, sizeof dst_filename); + + /* Reset file address checking info */ + addr_reset(); + + /* Create source file */ + if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR + + /* Create groups */ + for(i=0; i<9; i++) { + HDsnprintf(grp_name, sizeof(grp_name), "grp%d", i); + if((gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Gclose(gid) < 0) + TEST_ERROR + } /* end for */ + + /* Create destination file */ + if((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR + + /* Close files */ + if(H5Fclose(fid1) < 0) TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + + /* Reopen files */ + if((fid1 = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + + /* Iterate over links in the root group, copying each object */ + if((gid = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Literate(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_copy_iterate_cb, + &fid2) < 0) + TEST_ERROR + + /* Close */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(gid); + H5Fclose(fid1); + H5Fclose(fid2); + } H5E_END_TRY; + return 1; +} /* end test_copy_iterate */ + + +/*------------------------------------------------------------------------- * Function: test_copy_option * * Purpose: Create a group in SRC file and copy it to DST file @@ -12289,6 +12387,7 @@ main(void) nerrors += test_copy_same_file_named_datatype(fcpl_src, src_fapl); nerrors += test_copy_old_layout(fcpl_dst, dst_fapl); nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_iterate(fcpl_src, fcpl_dst, src_fapl, dst_fapl); } /* TODO: not implemented -- cgit v0.12 From dd27fe612cf9c80d223939a46a96202eaf81f60d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 25 Jul 2012 17:17:48 -0500 Subject: [svn-r22602] --- CMakeLists.txt | 56 +- config/cmake/FindHDF5.cmake | 85 --- config/cmake/FindHDF5.cmake.in | 4 +- config/cmake/H5pubconf.h.in | 18 - config/cmake/HDFLibMacros.cmake | 6 + config/cmake/cacheinit.cmake | 6 + config/cmake/hdf5-config.cmake.build.in | 12 +- config/cmake/hdf5-config.cmake.install.in | 10 +- config/cmake/libhdf5.settings.cmake.in | 2 +- tools/lib/h5tools.c | 355 ++++++------ tools/lib/h5tools.h | 3 +- tools/lib/h5tools_dump.c | 4 +- tools/lib/h5tools_str.c | 873 +++++++++++++++--------------- 13 files changed, 705 insertions(+), 729 deletions(-) delete mode 100644 config/cmake/FindHDF5.cmake 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")); } -- cgit v0.12 From 389e928176aae700eddefcb1983e9ff1a7665046 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 26 Jul 2012 08:32:12 -0500 Subject: [svn-r22604] cast void* to char* for calculation Issue on windows --- tools/lib/h5tools.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index c7ff2d3..495aca1 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1371,7 +1371,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t pad = H5Tget_strpad(tid); for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = _mem + block_index * size; + mem = ((unsigned char*)_mem) + block_index * size; if (H5Tis_variable_str(tid)) { s = *(char**) mem; @@ -1399,7 +1399,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nmembs = H5Tget_nmembers(tid); for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = _mem + block_index * size; + mem = ((unsigned char*)_mem) + block_index * size; for (j = 0; j < nmembs; j++) { offset = H5Tget_member_offset(tid, j); memb = H5Tget_member_type(tid, j); @@ -1432,7 +1432,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t } for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = _mem + block_index * size; + mem = ((unsigned char*)_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"); @@ -1450,7 +1450,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t memb = H5Tget_super(tid); for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = _mem + block_index * size; + mem = ((unsigned char*)_mem) + block_index * size; /* Get the number of sequence elements */ nelmts = ((hvl_t *) mem)->len; @@ -1470,7 +1470,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t H5S_sel_type region_type; for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = _mem + block_index * size; + mem = ((unsigned char*)_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); @@ -1494,7 +1494,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t break; default: for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = _mem + block_index * size; + mem = ((unsigned char*)_mem) + block_index * size; if (size != HDfwrite(mem, sizeof(char), size, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); } -- cgit v0.12 From aeaab5204b97a5912a26049fdfe95c7f6d962f93 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 26 Jul 2012 08:54:06 -0500 Subject: [svn-r22605] Skip test that require h5diff to compress when the DEFALTE filter is unavailable --- tools/h5import/CMakeLists.txt | 25 +++++++++++++++++++++++-- tools/h5import/h5importtestutil.sh | 21 +++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index 5bbcf02..0188852 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -263,6 +263,19 @@ IF (BUILD_TESTING) ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) ENDMACRO (ADD_H5_DUMPTEST testname datasetname testfile) + MACRO (ADD_H5_SKIP_DUMPTEST testname datasetname testfile) + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-SKIPPED + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname} ${datasetname} ${testfile} --- DEFLATE filter not available" + ) + ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) + ENDMACRO (ADD_H5_SKIP_DUMPTEST testname datasetname testfile) + + # -------------------------------------------------------------------- + # Determine if filter is available for h5diff + # -------------------------------------------------------------------- + SET (USE_FILTER_DEFLATE H5_HAVE_FILTER_DEFLATE) + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -314,11 +327,19 @@ IF (BUILD_TESTING) # ----- TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " ADD_H5_TEST (BINARY_F64 binfp64.bin testfiles/binfp64.conf binfp64.h5) - ADD_H5_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY) + IF (NOT USE_FILTER_DEFLATE) + ADD_H5_SKIP_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY) + ELSE (NOT USE_FILTER_DEFLATE) + ADD_H5_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY) + ENDIF (NOT USE_FILTER_DEFLATE) # ----- TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " ADD_H5_TEST (BINARY_I8 binin8.bin testfiles/binin8.conf binin8.h5) - ADD_H5_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY) + IF (NOT USE_FILTER_DEFLATE) + ADD_H5_SKIP_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY) + ELSE (NOT USE_FILTER_DEFLATE) + ADD_H5_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY) + ENDIF (NOT USE_FILTER_DEFLATE) # ----- TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended " ADD_H5_TEST (BINARY_I16 binin16.bin testfiles/binin16.conf binin16.h5) diff --git a/tools/h5import/h5importtestutil.sh b/tools/h5import/h5importtestutil.sh index 5be3118..45a360a 100755 --- a/tools/h5import/h5importtestutil.sh +++ b/tools/h5import/h5importtestutil.sh @@ -16,6 +16,9 @@ # HDF Utilities Test script # Usage: h5importtestutil.sh [machine-type] +# Determine which filters are available +USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" + TESTNAME=h5import EXIT_SUCCESS=0 EXIT_FAILURE=1 @@ -141,6 +144,12 @@ TESTING() { echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' } +# Print a "SKIP" message +SKIP() { + TESTING $TESTNAME $@ + echo " -SKIP-" +} + TOOLTEST() { err=0 @@ -273,13 +282,21 @@ TOOLTEST $TESTDIR/txtfp64.txt -c $TESTDIR/txtfp64.conf -o txtfp64.h5 TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " TOOLTEST binfp64.bin -c $TESTDIR/binfp64.conf -o binfp64.h5 TESTING "H5DUMP-BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " -TOOLTEST2 "/fp/bin/64-bit" binfp64.h5 +if test $USE_FILTER_DEFLATE != "yes"; then + SKIP "/fp/bin/64-bit" binfp64.h5 +else + TOOLTEST2 "/fp/bin/64-bit" binfp64.h5 +fi TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " TOOLTEST binin8.bin -c $TESTDIR/binin8.conf -o binin8.h5 TESTING "H5DUMP-BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " -TOOLTEST2 "/int/bin/8-bit" binin8.h5 +if test $USE_FILTER_DEFLATE != "yes"; then + SKIP "/int/bin/8-bit" binin8.h5 +else + TOOLTEST2 "/int/bin/8-bit" binin8.h5 +fi TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended " TOOLTEST binin16.bin -c $TESTDIR/binin16.conf -o binin16.h5 -- cgit v0.12 From 74e00605264ffb2b782b4f28be15accc7784217c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 26 Jul 2012 09:21:15 -0500 Subject: [svn-r22606] Correct typo from cut/paste --- tools/h5import/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index 0188852..a655bf2 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -264,11 +264,10 @@ IF (BUILD_TESTING) ENDMACRO (ADD_H5_DUMPTEST testname datasetname testfile) MACRO (ADD_H5_SKIP_DUMPTEST testname datasetname testfile) - ADD_TEST ( - NAME H5IMPORT-DUMP-${testname}-SKIPPED - COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname} ${datasetname} ${testfile} --- DEFLATE filter not available" - ) - ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-SKIPPED + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname} ${datasetname} ${testfile} --- DEFLATE filter not available" + ) ENDMACRO (ADD_H5_SKIP_DUMPTEST testname datasetname testfile) # -------------------------------------------------------------------- -- cgit v0.12 From 7143164de9d7de52516697bbb6bfc7cd2cf749d6 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 26 Jul 2012 14:33:59 -0500 Subject: [svn-r22608] Description: Switch propert list/class iteration from internal to external form of iteration, cleaning up and simplifying the code a bit. Bring other general improvements from plist_encode_decode branch back to trunk. Clean up many warnings. Tested on: Mac OSX/64 10.7.4 (amazon) w/gcc 4.7, debug and C++ & FORTRAN (too minor to require h5committest) --- src/H5B2int.c | 2 +- src/H5FD.c | 6 +- src/H5FDmpi.c | 4 +- src/H5FDpublic.h | 2 +- src/H5Fprivate.h | 44 +++---- src/H5Gcache.c | 2 +- src/H5HFdbg.c | 4 +- src/H5HFsection.c | 7 +- src/H5O.c | 20 +-- src/H5Oainfo.c | 6 +- src/H5Oalloc.c | 88 +++++++------ src/H5Oattr.c | 6 +- src/H5Ocache.c | 10 +- src/H5Ocont.c | 4 +- src/H5Ocopy.c | 12 +- src/H5Odbg.c | 4 +- src/H5Odtype.c | 28 ++-- src/H5Oefl.c | 10 +- src/H5Ofill.c | 9 +- src/H5Ofsinfo.c | 6 +- src/H5Oginfo.c | 10 +- src/H5Olinfo.c | 10 +- src/H5Olink.c | 18 ++- src/H5Omessage.c | 41 +++--- src/H5Opkg.h | 9 +- src/H5Opline.c | 4 +- src/H5Oshmesg.c | 8 +- src/H5Ostab.c | 2 +- src/H5Otest.c | 4 +- src/H5P.c | 56 +++++++- src/H5Pdapl.c | 34 ++--- src/H5Pdcpl.c | 142 ++++++++++---------- src/H5Pint.c | 384 +++++++++++++++++++++++++++++++++++------------------- src/H5Pocpl.c | 8 +- src/H5Ppkg.h | 6 +- src/H5Pstrcpl.c | 2 +- src/H5R.c | 10 +- src/H5SL.c | 8 +- src/H5Sall.c | 24 ++-- src/H5Shyper.c | 24 ++-- src/H5Snone.c | 6 +- src/H5Spoint.c | 6 +- src/H5T.c | 13 +- src/H5Tarray.c | 10 +- src/H5Tfields.c | 50 ++++--- src/H5Tprivate.h | 2 +- src/H5Ztrans.c | 12 +- 47 files changed, 689 insertions(+), 488 deletions(-) diff --git a/src/H5B2int.c b/src/H5B2int.c index 4355174..8ea8426 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -140,7 +140,7 @@ H5B2_locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, unsigned my_idx = 0; /* Final index value */ int cmp = -1; /* Key comparison value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR hi = nrec; while(lo < hi && cmp) { diff --git a/src/H5FD.c b/src/H5FD.c index 8ff9d9a..7db584e 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -1350,7 +1350,7 @@ H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); HDassert(flags); @@ -1361,7 +1361,6 @@ H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/) else *flags=0; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_query() */ @@ -1387,7 +1386,7 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(driver); HDassert(flags); @@ -1398,7 +1397,6 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) else *flags = 0; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_driver_query() */ diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index afc5536..01c28e6 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -479,11 +479,11 @@ H5FD_mpi_setup_collective(hid_t dxpl_id, MPI_Datatype *btype, MPI_Datatype *ftyp /* Set buffer MPI type */ if(H5P_set(plist, H5FD_MPI_XFER_MEM_MPI_TYPE_NAME, btype) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O property") /* Set File MPI type */ if(H5P_set(plist, H5FD_MPI_XFER_FILE_MPI_TYPE_NAME, ftype) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O property") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 5f70f71..ed50bc7 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -313,7 +313,7 @@ typedef enum { H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, H5FD_FILE_IMAGE_OP_FILE_OPEN, H5FD_FILE_IMAGE_OP_FILE_RESIZE, - H5FD_FILE_IMAGE_OP_FILE_CLOSE, + H5FD_FILE_IMAGE_OP_FILE_CLOSE } H5FD_file_image_op_t; /* Define structure to hold file image callbacks */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 40e075b..7c6fae8 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -70,10 +70,10 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; *(p) = (uint8_t)(((i) >> 24) & 0xff); (p)++; \ } -/* Encode a 32-bit unsigned integer into a variable-sized buffer */ +/* Encode an unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT32ENCODE_VAR(p, n, l) { \ - uint32_t _n = (n); \ +# define ENCODE_VAR(p, typ, n, l) { \ + typ _n = (n); \ size_t _i; \ uint8_t *_p = (uint8_t*)(p); \ \ @@ -82,6 +82,10 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; (p) = (uint8_t*)(p) + l; \ } +/* Encode a 32-bit unsigned integer into a variable-sized buffer */ +/* (Assumes that the high bits of the integer are zero) */ +# define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) + # define INT64ENCODE(p, n) { \ int64_t _n = (n); \ size_t _i; \ @@ -108,15 +112,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* Encode a 64-bit unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT64ENCODE_VAR(p, n, l) { \ - uint64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for(_i = 0; _i < l; _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t*)(p) + l; \ -} +# define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) /* DECODE converts little endian bytes pointed by p to integer values and store * it in i. For signed values, need to do sign-extension when converting @@ -152,12 +148,9 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; (i) |= ((uint32_t)(*(p) & 0xff) << 24); (p)++; \ } -/* Decode a variable-sized buffer into a 32-bit unsigned integer */ +/* Decode a variable-sized buffer */ /* (Assumes that the high bits of the integer will be zero) */ -/* (Note: this is exactly the same code as the 64-bit variable-length decoder - * and bugs/improvements should be make in both places - QAK) - */ -# define UINT32DECODE_VAR(p, n, l) { \ +# define DECODE_VAR(p, n, l) { \ size_t _i; \ \ n = 0; \ @@ -167,6 +160,10 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; (p) += l; \ } +/* Decode a variable-sized buffer into a 32-bit unsigned integer */ +/* (Assumes that the high bits of the integer will be zero) */ +# define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) + # define INT64DECODE(p, n) { \ /* WE DON'T CHECK FOR OVERFLOW! */ \ size_t _i; \ @@ -191,18 +188,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* Decode a variable-sized buffer into a 64-bit unsigned integer */ /* (Assumes that the high bits of the integer will be zero) */ -/* (Note: this is exactly the same code as the 32-bit variable-length decoder - * and bugs/improvements should be make in both places - QAK) - */ -# define UINT64DECODE_VAR(p, n, l) { \ - size_t _i; \ - \ - n = 0; \ - (p) += l; \ - for (_i = 0; _i < l; _i++) \ - n = (n << 8) | *(--p); \ - (p) += l; \ -} +# define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) /* Address-related macros */ #define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 1d2ad8b..15dbf65 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -302,7 +302,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5G_node_dest(H5F_t *f, H5G_node_t *sym) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index caaedc7..76c7b96 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -80,7 +80,7 @@ typedef struct { /* Local Prototypes */ /********************/ -static herr_t H5HF_dtable_debug(H5HF_dtable_t *dtable, FILE *stream, +static herr_t H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth); @@ -113,7 +113,7 @@ static herr_t H5HF_dtable_debug(H5HF_dtable_t *dtable, FILE *stream, *------------------------------------------------------------------------- */ static herr_t -H5HF_dtable_debug(H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth) +H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth) { FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5HFsection.c b/src/H5HFsection.c index 87fa069..e9ea7e0 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -651,9 +651,7 @@ herr_t H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect, haddr_t *dblock_addr, size_t *dblock_size) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* * Check arguments. @@ -678,8 +676,7 @@ H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, hid_t dxpl_id, *dblock_size = hdr->man_dtable.row_block_size[sect->u.single.par_entry / hdr->man_dtable.cparam.width]; } /* end else */ -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_sect_single_dblock_info() */ diff --git a/src/H5O.c b/src/H5O.c index 5050941..a896ee0 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1717,7 +1717,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, H5AC_protect_t prot) while(curr_msg < cont_msg_info.nmsgs) { H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ #ifndef NDEBUG - unsigned chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ + size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ #endif /* NDEBUG */ /* Bring the chunk into the cache */ @@ -2007,15 +2007,15 @@ H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force) /* Check version, to determine how to store time information */ if(oh->version == H5O_VERSION_1) { - int idx; /* Index of modification time message to update */ + size_t idx; /* Index of modification time message to update */ /* Look for existing message */ - for(idx = 0; idx < (int)oh->nmesgs; idx++) + for(idx = 0; idx < oh->nmesgs; idx++) if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) break; /* Create a new message, if necessary */ - if(idx == (int)oh->nmesgs) { + if(idx == oh->nmesgs) { unsigned mesg_flags = 0; /* Flags for message in object header */ /* If we would have to create a new message, but we aren't 'forcing' it, get out now */ @@ -2023,7 +2023,7 @@ H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force) HGOTO_DONE(SUCCEED); /*nothing to do*/ /* Allocate space for the modification time message */ - if((idx = H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now)) < 0) + if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message") /* Set the message's flags if appropriate */ @@ -2130,7 +2130,7 @@ done: herr_t H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) { - int idx; /* Local index variable */ + size_t idx; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2139,7 +2139,7 @@ H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) HDassert(oh); /* Look for existing message */ - for(idx = 0; idx < (int)oh->nmesgs; idx++) + for(idx = 0; idx < oh->nmesgs; idx++) if(H5O_MSG_BOGUS == oh->mesg[idx].type) break; @@ -2155,7 +2155,7 @@ H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) bogus->u = H5O_BOGUS_VALUE; /* Allocate space in the object header for bogus message */ - if((idx = H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_BOGUS, &mesg_flags, bogus)) < 0) + if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_BOGUS, &mesg_flags, bogus, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") /* Point to "bogus" information (take it over) */ @@ -2715,8 +2715,8 @@ H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) hdr->version = oh->version; /* Set the number of messages & chunks */ - hdr->nmesgs = oh->nmesgs; - hdr->nchunks = oh->nchunks; + H5_ASSIGN_OVERFLOW(hdr->nmesgs, oh->nmesgs, size_t, unsigned); + H5_ASSIGN_OVERFLOW(hdr->nchunks, oh->nchunks, size_t, unsigned); /* Set the status flags */ hdr->flags = oh->flags; diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index ad99be0..654163b 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -196,7 +196,7 @@ H5O_ainfo_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void /* The flags for the attribute indices */ flags = ainfo->track_corder ? H5O_AINFO_TRACK_CORDER : 0; - flags |= ainfo->index_corder ? H5O_AINFO_INDEX_CORDER : 0; + flags = (unsigned char)(flags | (ainfo->index_corder ? H5O_AINFO_INDEX_CORDER : 0)); *p++ = flags; /* Max. creation order value for the object */ @@ -284,12 +284,12 @@ H5O_ainfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = 1 /* Version */ + ret_value = (size_t)(1 /* Version */ + 1 /* Index flags */ + (ainfo->track_corder ? 2 : 0) /* Curr. max. creation order value */ + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" attributes */ + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of attributes */ - + (ainfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of attributes */ + + (ainfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0)); /* Address of v2 B-tree for indexing creation order values of attributes */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ainfo_size() */ diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 05322af..5c00fb2 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -59,14 +59,15 @@ /********************/ static herr_t H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, - hbool_t *chk_dirtied, unsigned idx, uint8_t *new_gap_loc, size_t new_gap_size); + hbool_t *chk_dirtied, size_t idx, uint8_t *new_gap_loc, size_t new_gap_size); static herr_t H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *new_gap_loc, size_t new_gap_size); -static herr_t H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, +static herr_t H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, void *new_native, size_t new_size); static htri_t H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - unsigned chunkno, size_t size, int *msg_idx); -static int H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size); + unsigned chunkno, size_t size, size_t *msg_idx); +static herr_t H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, + size_t *new_idx); static htri_t H5O_move_cont(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned cont_u); static htri_t H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh); static htri_t H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh); @@ -109,10 +110,10 @@ H5FL_EXTERN(H5O_cont_t); */ static herr_t H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, - unsigned idx, uint8_t *new_gap_loc, size_t new_gap_size) + size_t idx, uint8_t *new_gap_loc, size_t new_gap_size) { hbool_t merged_with_null; /* Whether the gap was merged with a null message */ - unsigned u; /* Local index variable */ + size_t u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -335,7 +336,7 @@ H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, *------------------------------------------------------------------------- */ static herr_t -H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, +H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, void *new_native, size_t new_size) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ @@ -505,7 +506,7 @@ done: */ static htri_t H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, - size_t size, int *msg_idx) + size_t size, size_t *msg_idx) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ @@ -514,11 +515,12 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, uint8_t *old_image; /* Old address of chunk's image in memory */ size_t old_size; /* Old size of chunk */ htri_t extended; /* If chunk can be extended */ - int extend_msg = -1;/* Index of null message to extend */ + size_t extend_msg; /* Index of null message to extend */ + hbool_t extended_msg = FALSE; /* Whether an existing message was extended */ uint8_t new_size_flags = 0; /* New chunk #0 size flags */ hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ size_t extra_prfx_size = 0; /* Extra bytes added to object header prefix */ - unsigned u; /* Local index variable */ + size_t u; /* Local index variable */ htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_NOAPI_NOINIT @@ -542,13 +544,14 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, == ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { - extend_msg = (int)u; + extend_msg = u; + extended_msg = TRUE; break; } /* end if */ } /* end for */ /* If we can extend an existing null message, adjust the delta appropriately */ - if(extend_msg >= 0) { + if(extended_msg) { HDassert(oh->chunk[chunkno].gap == 0); delta = aligned_size - oh->mesg[extend_msg].raw_size; } /* end if */ @@ -598,7 +601,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, /* Adjust object header prefix flags */ if(adjust_size_flags) { - oh->flags &= (uint8_t)~H5O_HDR_CHUNK0_SIZE; + oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Mark object header as dirty in cache */ @@ -607,7 +610,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, } /* end if */ /* If we can extend an existing null message, take care of that */ - if(extend_msg >= 0) { + if(extended_msg) { /* Adjust message size of existing null message */ oh->mesg[extend_msg].raw_size += delta; } /* end if */ @@ -619,7 +622,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Set extension message */ - extend_msg = (int)oh->nmesgs++; + extend_msg = oh->nmesgs++; /* Initialize new null message */ oh->mesg[extend_msg].type = H5O_MSG_NULL; @@ -690,7 +693,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, if(H5O_chunk_resize(oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize object header chunk") - /* Set return value */ + /* Set new message index */ *msg_idx = extend_msg; done: @@ -737,8 +740,8 @@ done: * *------------------------------------------------------------------------- */ -static int -H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) +static herr_t +H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, size_t *new_idx) { /* Struct for storing information about "best" messages to allocate from */ typedef struct { @@ -756,13 +759,13 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) int found_null = (-1); /* Best fit null message */ alloc_info found_attr = {-1, 0, 0, 0, 0}; /* Best fit attribute message */ alloc_info found_other = {-1, 0, 0, 0, 0}; /* Best fit other message */ - unsigned idx; /*message number */ + size_t idx; /* Message number */ uint8_t *p = NULL; /*ptr into new chunk */ H5O_cont_t *cont = NULL; /*native continuation message */ unsigned chunkno; /* Chunk allocated */ haddr_t new_chunk_addr; unsigned u; /* Local index variable */ - int ret_value; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1089,11 +1092,11 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) cont->chunkno = chunkno; /* Split the null message and point at continuation message */ - if(H5O_alloc_null(f, dxpl_id, oh, (unsigned)found_null, H5O_MSG_CONT, cont, cont_size) < 0) + if(H5O_alloc_null(f, dxpl_id, oh, (size_t)found_null, H5O_MSG_CONT, cont, cont_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") - /* Set return value */ - ret_value = (int)idx; + /* Set new message index value */ + *new_idx = idx; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1114,14 +1117,14 @@ done: * *------------------------------------------------------------------------- */ -int +herr_t H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, - const void *mesg) + const void *mesg, size_t *mesg_idx) { - size_t raw_size; /* Raw size of message */ - size_t aligned_size; /* Size of message including alignment */ - int idx; /* Index of message which fits allocation */ - int ret_value; /* Return value */ + size_t raw_size; /* Raw size of message */ + size_t aligned_size; /* Size of message including alignment */ + size_t idx; /* Index of message which fits allocation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1129,6 +1132,7 @@ H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, HDassert(oh); HDassert(type); HDassert(mesg); + HDassert(mesg_idx); /* Compute the size needed to store the message in the object header */ raw_size = (type->raw_size)(f, FALSE, mesg); @@ -1139,12 +1143,12 @@ H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, aligned_size = H5O_ALIGN_OH(oh, raw_size); /* look for a null message which is large enough */ - for(idx = 0; idx < (int)oh->nmesgs; idx++) + for(idx = 0; idx < oh->nmesgs; idx++) if(H5O_NULL_ID == oh->mesg[idx].type->id && oh->mesg[idx].raw_size >= aligned_size) break; /* if we didn't find one, then allocate more header space */ - if(idx >= (int)oh->nmesgs) { + if(idx >= oh->nmesgs) { unsigned chunkno; /* check to see if we can extend one of the chunks. If we can, @@ -1163,22 +1167,22 @@ H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, } /* end for */ /* If we were not able to extend a chunk, create a new one */ - if(idx >= (int)oh->nmesgs) - if((idx = H5O_alloc_new_chunk(f, dxpl_id, oh, raw_size)) < 0) + if(idx >= oh->nmesgs) + if(H5O_alloc_new_chunk(f, dxpl_id, oh, raw_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create a new object header data chunk") } /* end if */ - HDassert(idx >= 0 && idx < (int)oh->nmesgs); + HDassert(idx < oh->nmesgs); /* Split the null message and point at continuation message */ - if(H5O_alloc_null(f, dxpl_id, oh, (unsigned)idx, type, NULL, aligned_size) < 0) + if(H5O_alloc_null(f, dxpl_id, oh, idx, type, NULL, aligned_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") /* Mark object header as dirty in cache */ if(H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") - /* Set return value */ - ret_value = (int)idx; + /* Set message index value */ + *mesg_idx = idx; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1296,7 +1300,7 @@ H5O_move_cont(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned cont_u) size_t nonnull_size; /* Total size of nonnull messages in the chunk pointed to by cont message */ H5O_mesg_t *curr_msg; /* Pointer to the current message to operate on */ size_t gap_size; /* Size of gap produced */ - unsigned v; /* Local index variable */ + size_t v; /* Local index variable */ /* Spin through messages */ nonnull_size = 0; @@ -1533,7 +1537,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh) } /* end if */ else { H5O_mesg_t *null_msg; /* Pointer to current message to operate on */ - unsigned v; /* Local index variable */ + size_t v; /* Local index variable */ /* Check if messages in chunk pointed to can replace continuation message */ if(H5O_CONT_ID == curr_msg->type->id) { @@ -1607,7 +1611,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh) null_chk_dirtied = FALSE; } /* end if */ else { - unsigned new_null_msg; /* Message index for new null message */ + size_t new_null_msg; /* Message index for new null message */ /* Check if null message is large enough to still exist */ if((null_msg->raw_size - curr_msg->raw_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { @@ -2135,8 +2139,8 @@ H5O_alloc_shrink_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno) uint8_t new_size_flags = 0; /* New chunk #0 size flags */ hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ size_t less_prfx_size = 0; /* Bytes removed from object header prefix */ + size_t u; /* Index */ herr_t ret_value = SUCCEED; /* Return value */ - unsigned u; /* Index */ FUNC_ENTER_NOAPI_NOINIT @@ -2237,7 +2241,7 @@ H5O_alloc_shrink_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno) if(adjust_size_flags) { /* Adjust object header prefix flags */ - oh->flags &= (uint8_t)~H5O_HDR_CHUNK0_SIZE; + oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Slide chunk 0 data down */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 510d64f..b8e6b32 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -300,7 +300,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) if(attr->shared->version >= H5O_ATTR_VERSION_2) { flags = (is_type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0 ); flags |= (is_space_shared ? H5O_ATTR_FLAG_SPACE_SHARED : 0); - *p++ = flags; /* Set flags for attribute */ + *p++ = (uint8_t)flags; /* Set flags for attribute */ } /* end if */ else *p++ = 0; /* Reserved, for version <2 */ @@ -723,7 +723,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) { const H5A_t *attr = (const H5A_t *)_mesg; @@ -753,7 +753,7 @@ H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) { H5A_t *attr = (H5A_t *)_mesg; diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 2c33ebe..f09f693 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -658,7 +658,7 @@ H5O_size(const H5F_t UNUSED *f, const H5O_t *oh, size_t *size_ptr) /* Report the object header's prefix+first chunk length */ if(oh->chunk0_size) - *size_ptr = H5O_SIZEOF_HDR(oh) + oh->chunk0_size; + *size_ptr = (size_t)H5O_SIZEOF_HDR(oh) + oh->chunk0_size; else *size_ptr = oh->chunk[0].size; @@ -983,7 +983,7 @@ H5O_cache_chk_size(const H5F_t UNUSED *f, const H5O_chunk_proxy_t *chk_proxy, si static herr_t H5O_add_cont_msg(H5O_cont_msgs_t *cont_msg_info, const H5O_cont_t *cont) { - unsigned contno; /* Continuation message index */ + size_t contno; /* Continuation message index */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1034,7 +1034,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, { const uint8_t *p; /* Pointer into buffer to decode */ uint8_t *eom_ptr; /* Pointer to end of messages for a chunk */ - unsigned curmesg; /* Current message being decoded in object header */ + size_t curmesg; /* Current message being decoded in object header */ unsigned merged_null_msgs = 0; /* Number of null messages merged together */ unsigned chunkno; /* Current chunk's index */ #ifndef NDEBUG @@ -1104,7 +1104,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, nullcnt = 0; #endif /* NDEBUG */ while(p < eom_ptr) { - unsigned mesgno; /* Current message to operate on */ + size_t mesgno; /* Current message to operate on */ size_t mesg_size; /* Size of message read in */ unsigned id; /* ID (type) of current message */ uint8_t flags; /* Flags for current message */ @@ -1166,7 +1166,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, /* Combine adjacent null messages */ mesgno = oh->nmesgs - 1; - oh->mesg[mesgno].raw_size += H5O_SIZEOF_MSGHDR_OH(oh) + mesg_size; + oh->mesg[mesgno].raw_size += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + mesg_size; oh->mesg[mesgno].dirty = TRUE; merged_null_msgs++; udata->merged_null_msgs++; diff --git a/src/H5Ocont.c b/src/H5Ocont.c index b609bfd..647532b 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -179,8 +179,8 @@ H5O_cont_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED * FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = H5F_SIZEOF_ADDR(f) + /* Continuation header address */ - H5F_SIZEOF_SIZE(f); /* Continuation header length */ + ret_value = (size_t)(H5F_SIZEOF_ADDR(f) + /* Continuation header address */ + H5F_SIZEOF_SIZE(f)); /* Continuation header length */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_cont_size() */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index b22eeb0..1d1aa90 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -342,7 +342,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, void *cpy_udata = NULL; /* User data for passing to message callbacks */ uint64_t dst_oh_size; /* Total size of the destination OH */ size_t dst_oh_null; /* Size of the null message to add to destination OH */ - unsigned dst_oh_gap; /* Size of the gap in chunk #0 of destination OH */ + size_t dst_oh_gap; /* Size of the gap in chunk #0 of destination OH */ uint8_t *current_pos; /* Current position in destination image */ size_t msghdr_size; herr_t ret_value = SUCCEED; @@ -629,14 +629,14 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Compute space for messages. */ dst_oh_size = 0; for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { - dst_oh_size += H5O_SIZEOF_MSGHDR_OH(oh_dst); + dst_oh_size += (uint64_t)H5O_SIZEOF_MSGHDR_OH(oh_dst); dst_oh_size += oh_dst->mesg[mesgno].raw_size; } /* end for */ /* Check if we need to determine correct value for chunk #0 size bits */ if(oh_dst->version > H5O_VERSION_1) { /* Reset destination object header's "chunk 0 size" flags */ - oh_dst->flags &= ~H5O_HDR_CHUNK0_SIZE; + oh_dst->flags = (uint8_t)(oh_dst->flags & ~H5O_HDR_CHUNK0_SIZE); /* Determine correct value for chunk #0 size bits */ if(dst_oh_size > 4294967295) @@ -745,7 +745,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Check if we need to add a NULL message to this header */ if(dst_oh_null > 0) { - unsigned null_idx; /* Index of new NULL message */ + size_t null_idx; /* Index of new NULL message */ /* Make sure we have enough space for new NULL message */ if(oh_dst->nmesgs + 1 > oh_dst->alloc_nmesgs) @@ -1413,7 +1413,7 @@ H5O_copy_free_comm_dt_cb(void *item, void *_key, void UNUSED *op_data) haddr_t *addr = (haddr_t *)item; H5O_copy_search_comm_dt_key_t *key = (H5O_copy_search_comm_dt_key_t *)_key; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(addr); HDassert(key); @@ -1449,7 +1449,7 @@ H5O_copy_comm_dt_cmp(const void *_key1, const void *_key2) const H5O_copy_search_comm_dt_key_t *key2 = (const H5O_copy_search_comm_dt_key_t *)_key2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check fileno. It is unlikely to be different so check if they are equal * first so only one comparison needs to be made. */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 5c07b64..5901c61 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -398,7 +398,7 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i if(0 == i) { if(H5F_addr_ne(oh->chunk[i].addr, addr)) HDfprintf(stream, "*** WRONG ADDRESS FOR CHUNK #0!\n"); - chunk_size = oh->chunk[i].size - H5O_SIZEOF_HDR(oh); + chunk_size = oh->chunk[i].size - (size_t)H5O_SIZEOF_HDR(oh); } /* end if */ else chunk_size = oh->chunk[i].size; @@ -424,7 +424,7 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i unsigned chunkno; /* Chunk for message */ /* Accumulate message's size to total */ - mesg_total += H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[i].raw_size; + mesg_total += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[i].raw_size; /* For version 2 object header, add size of "OCHK" for continuation chunk */ if (oh->mesg[i].type->id == H5O_CONT_ID) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 6158fd9..b482115 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -626,6 +626,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") @@ -696,6 +697,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) HDassert(dt->shared->version >= H5O_DTYPE_VERSION_3); break; + case H5T_ORDER_MIXED: case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: @@ -764,7 +766,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet") } /* end switch */ - flags |= (dt->shared->u.atomic.u.f.sign << 8) & 0xff00; + flags = (unsigned)(flags | ((dt->shared->u.atomic.u.f.sign << 8) & 0xff00)); UINT16ENCODE(*pp, dt->shared->u.atomic.offset); UINT16ENCODE(*pp, dt->shared->u.atomic.prec); HDassert(dt->shared->u.atomic.u.f.epos <= 255); @@ -787,8 +789,9 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) flags |= 0x01; break; - case H5T_ORDER_ERROR: case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: + case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") @@ -806,8 +809,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) HDassert(dt->shared->u.atomic.lsb_pad == H5T_PAD_ZERO); HDassert(dt->shared->u.atomic.msb_pad == H5T_PAD_ZERO); - flags |= (dt->shared->u.atomic.u.s.pad & 0x0f); - flags |= (dt->shared->u.atomic.u.s.cset & 0x0f) << 4; + flags = (unsigned)(flags | (dt->shared->u.atomic.u.s.pad & 0x0f)); + flags = (unsigned)(flags | ((((unsigned)dt->shared->u.atomic.u.s.cset) & 0x0f) << 4)); break; case H5T_BITFIELD: @@ -822,8 +825,9 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) flags |= 0x01; break; - case H5T_ORDER_ERROR: case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: + case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") @@ -874,7 +878,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) z = HDstrlen(dt->shared->u.opaque.tag); aligned = (z + 7) & (H5T_OPAQUE_TAG_MAX - 8); - flags |= aligned; + flags = (unsigned)(flags | aligned); HDmemcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned)); for(n = MIN(z, aligned); n < aligned; n++) (*pp)[n] = 0; @@ -918,7 +922,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) /* Member offset */ /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ if(dt->shared->version >= H5O_DTYPE_VERSION_3) - UINT32ENCODE_VAR(*pp, dt->shared->u.compnd.memb[i].offset, offset_nbytes) + UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes) else UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset) @@ -1000,8 +1004,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) flags |= (dt->shared->u.vlen.type & 0x0f); if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { - flags |= (dt->shared->u.vlen.pad & 0x0f) << 4; - flags |= ((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8; + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4)); + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8)); } /* end if */ /* Encode base type of VL information */ @@ -1599,7 +1603,7 @@ H5O_dtype_shared_post_copy_upd(const H5O_loc_t UNUSED *src_oloc, { H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR if(dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { HDassert(H5T_committed(dt_dst)); @@ -1977,6 +1981,10 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "none"; break; + case H5T_ORDER_MIXED: + s = "mixed"; + break; + case H5T_ORDER_ERROR: default: sprintf(buf, "H5T_ORDER_%d", dt->shared->u.atomic.order); diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 3630cf4..db9066e 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -230,7 +230,7 @@ H5O_efl_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void * */ HDassert(mesg->slot[u].name_offset); H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH(f, p, mesg->slot[u].offset); + H5F_ENCODE_LENGTH(f, p, (hsize_t)mesg->slot[u].offset); H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size); } /* end for */ @@ -351,13 +351,13 @@ H5O_efl_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) HDassert(f); HDassert(mesg); - ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */ + ret_value = (size_t)H5F_SIZEOF_ADDR(f) + /*heap address */ 2 + /*slots allocated*/ 2 + /*num slots used*/ 4 + /*reserved */ - mesg->nused * (H5F_SIZEOF_SIZE(f) + /*name offset */ - H5F_SIZEOF_SIZE(f) + /*file offset */ - H5F_SIZEOF_SIZE(f)); /*file size */ + mesg->nused * ((size_t)H5F_SIZEOF_SIZE(f) + /*name offset */ + (size_t)H5F_SIZEOF_SIZE(f) + /*file offset */ + (size_t)H5F_SIZEOF_SIZE(f)); /*file size */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_efl_size() */ diff --git a/src/H5Ofill.c b/src/H5Ofill.c index f5569dc..1e8ccb1 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -397,11 +397,11 @@ H5O_fill_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_fill) /* Encode space allocation time */ HDassert(fill->alloc_time == (H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time)); - flags |= (H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME; + flags = (uint8_t)(flags | ((H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME)); /* Encode fill value writing time */ HDassert(fill->fill_time == (H5O_FILL_MASK_FILL_TIME & fill->fill_time)); - flags |= (H5O_FILL_MASK_FILL_TIME & fill->fill_time) << H5O_FILL_SHIFT_FILL_TIME; + flags = (uint8_t)(flags | ((H5O_FILL_MASK_FILL_TIME & fill->fill_time) << H5O_FILL_SHIFT_FILL_TIME)); /* Check if we need to encode a fill value size */ if(fill->size < 0) { @@ -833,10 +833,11 @@ H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_fill, FILE *s fprintf(stream,"Incremental\n"); break; + case H5D_ALLOC_TIME_DEFAULT: + case H5D_ALLOC_TIME_ERROR: default: fprintf(stream,"Unknown!\n"); break; - } /* end switch */ HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Time:"); switch(fill->fill_time) { @@ -852,6 +853,7 @@ H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_fill, FILE *s fprintf(stream,"If Set\n"); break; + case H5D_FILL_TIME_ERROR: default: fprintf(stream,"Unknown!\n"); break; @@ -872,6 +874,7 @@ H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_fill, FILE *s fprintf(stream,"User Defined\n"); break; + case H5D_FILL_VALUE_ERROR: default: fprintf(stream,"Unknown!\n"); break; diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index 3f0b15d..11bf43b 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -105,7 +105,7 @@ H5O_fsinfo_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, if(NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - fsinfo->strategy = *p++; /* file space strategy */ + fsinfo->strategy = (H5F_file_space_type_t)*p++; /* file space strategy */ H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* free space section size threshold */ /* Addresses of free space managers: only exist for H5F_FILE_SPACE_ALL_PERSIST */ @@ -231,10 +231,10 @@ H5O_fsinfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg /* Addresses of free-space managers exist only for H5F_FILE_SPACE_ALL_PERSIST type */ if(H5F_FILE_SPACE_ALL_PERSIST == fsinfo->strategy) - fs_addr_size = (H5FD_MEM_NTYPES - 1) * H5F_SIZEOF_ADDR(f); + fs_addr_size = (H5FD_MEM_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); ret_value = 2 /* Version & strategy */ - + H5F_SIZEOF_SIZE(f) /* Threshold */ + + (size_t)H5F_SIZEOF_SIZE(f) /* Threshold */ + fs_addr_size; /* Addresses of free-space managers */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index 418b053..d579984 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -184,7 +184,7 @@ H5O_ginfo_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, con /* The flags for the group info */ flags = ginfo->store_link_phase_change ? H5O_GINFO_STORE_PHASE_CHANGE : 0; - flags |= ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0; + flags = (unsigned char)(flags | (ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0)); *p++ = flags; /* Store the max. # of links to store compactly & the min. # of links to store densely */ @@ -273,12 +273,12 @@ H5O_ginfo_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared, const void ret_value = 1 + /* Version */ 1 + /* Flags */ (ginfo->store_link_phase_change ? ( - 2 + /* "Max compact" links */ - 2 /* "Min dense" links */ + (size_t)(2 + /* "Max compact" links */ + 2) /* "Min dense" links */ ) : 0) + /* "Min dense" links */ (ginfo->store_est_entry_info ? ( - 2 + /* Estimated # of entries in group */ - 2 /* Estimated length of name of entry in group */ + (size_t)(2 + /* Estimated # of entries in group */ + 2) /* Estimated length of name of entry in group */ ) : 0); FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index 5c0ed53..5d3d75c 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -206,7 +206,7 @@ H5O_linfo_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void /* The flags for the link indices */ index_flags = linfo->track_corder ? H5O_LINFO_TRACK_CORDER : 0; - index_flags |= linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0; + index_flags = (uint8_t)(index_flags | (linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0)); *p++ = index_flags; /* Max. link creation order value for the group, if tracked */ @@ -296,10 +296,10 @@ H5O_linfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) /* Set return value */ ret_value = 1 /* Version */ + 1 /* Index flags */ - + (linfo->track_corder ? 8 : 0) /* Curr. max. creation order value */ - + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ - + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ - + (linfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of links */ + + (linfo->track_corder ? (size_t)8 : 0) /* Curr. max. creation order value */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ + + (linfo->index_corder ? (size_t)H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of links */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_linfo_size() */ diff --git a/src/H5Olink.c b/src/H5Olink.c index 88c9e28..4dda5fe 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -226,6 +226,9 @@ H5O_link_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, break; /* User-defined links */ + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: default: if(lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown link type") @@ -306,9 +309,9 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void link_flags = H5O_LINK_NAME_2; else link_flags = H5O_LINK_NAME_1; - link_flags |= lnk->corder_valid ? H5O_LINK_STORE_CORDER : 0; - link_flags |= (lnk->type != H5L_TYPE_HARD) ? H5O_LINK_STORE_LINK_TYPE : 0; - link_flags |= (lnk->cset != H5T_CSET_ASCII) ? H5O_LINK_STORE_NAME_CSET : 0; + link_flags = (unsigned char)(link_flags | (lnk->corder_valid ? H5O_LINK_STORE_CORDER : 0)); + link_flags = (unsigned char)(link_flags | ((lnk->type != H5L_TYPE_HARD) ? H5O_LINK_STORE_LINK_TYPE : 0)); + link_flags = (unsigned char)(link_flags | ((lnk->cset != H5T_CSET_ASCII) ? H5O_LINK_STORE_NAME_CSET : 0)); *p++ = link_flags; /* Store the type of a non-default link */ @@ -366,6 +369,9 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void break; /* User-defined links */ + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: default: HDassert(lnk->type >= H5L_TYPE_UD_MIN && lnk->type <= H5L_TYPE_MAX); @@ -511,6 +517,9 @@ H5O_link_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) HDstrlen(lnk->u.soft.name); /* Link value */ break; + case H5L_TYPE_ERROR: + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_MAX: default: /* Default is user-defined link type */ HDassert(lnk->type >= H5L_TYPE_UD_MIN); ret_value += 2 + /* User-defined data size */ @@ -837,6 +846,9 @@ H5O_link_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * "Link Value:", lnk->u.soft.name); break; + case H5L_TYPE_ERROR: + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_MAX: default: if(lnk->type >= H5L_TYPE_UD_MIN) { if(lnk->type == H5L_TYPE_EXTERNAL) { diff --git a/src/H5Omessage.c b/src/H5Omessage.c index c9a0997..1369583 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -76,7 +76,7 @@ typedef struct { static herr_t H5O_msg_reset_real(const H5O_msg_class_t *type, void *native); static herr_t H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, unsigned *oh_modified, void *_udata/*in,out*/); -static herr_t H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, +static herr_t H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, unsigned mesg_flags, unsigned update_flags); @@ -207,7 +207,7 @@ herr_t H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags, void *mesg) { - int idx; /* Index of message to modify */ + size_t idx; /* Index of message to modify */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -220,11 +220,11 @@ H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *t HDassert(mesg); /* Allocate space for a new message */ - if((idx = H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, mesg)) < 0) + if(H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, mesg, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create new message") /* Copy the information for the message */ - if(H5O_copy_mesg(f, dxpl_id, oh, (unsigned)idx, type, mesg, mesg_flags, update_flags) < 0) + if(H5O_copy_mesg(f, dxpl_id, oh, idx, type, mesg, mesg_flags, update_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to write message") #ifdef H5O_DEBUG H5O_assert(oh); @@ -364,7 +364,7 @@ H5O_msg_write_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *ty unsigned mesg_flags, unsigned update_flags, void *mesg) { H5O_mesg_t *idx_msg; /* Pointer to message to modify */ - unsigned idx; /* Index of message to modify */ + size_t idx; /* Index of message to modify */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -788,6 +788,7 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header to operate on */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + unsigned msg_count; /* Message count */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -805,7 +806,8 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Count the messages of the correct type */ - ret_value = H5O_msg_count_real(oh, type); + msg_count = H5O_msg_count_real(oh, type); + H5_ASSIGN_OVERFLOW(ret_value, msg_count, unsigned, int); done: if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) @@ -1431,10 +1433,10 @@ H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, ret_value += extra_raw; /* Adjust size for alignment, if necessary */ - ret_value = H5O_ALIGN_F(f, ret_value); + ret_value = (size_t)H5O_ALIGN_F(f, ret_value); /* Add space for message header */ - ret_value += H5O_SIZEOF_MSGHDR_F(f, + ret_value += (size_t)H5O_SIZEOF_MSGHDR_F(f, (H5F_STORE_MSG_CRT_IDX(f) || oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)); done: @@ -1484,10 +1486,10 @@ H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, ret_value += extra_raw; /* Adjust size for alignment, if necessary */ - ret_value = H5O_ALIGN_OH(oh, ret_value); + ret_value = (size_t)H5O_ALIGN_OH(oh, ret_value); /* Add space for message header */ - ret_value += H5O_SIZEOF_MSGHDR_OH(oh); + ret_value += (size_t)H5O_SIZEOF_MSGHDR_OH(oh); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1894,12 +1896,13 @@ done: * *------------------------------------------------------------------------- */ -int +herr_t H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, - unsigned *mesg_flags, void *native) + unsigned *mesg_flags, void *native, size_t *mesg_idx) { + size_t new_idx; /* New index for message */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ - int ret_value = FAIL; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1910,6 +1913,7 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, HDassert(!(*mesg_flags & H5O_MSG_FLAG_SHARED)); HDassert(type); HDassert(native); + HDassert(mesg_idx); /* Check if message is already shared */ if((shared_mesg = H5O_msg_is_shared(type->id, native)) < 0) @@ -1927,16 +1931,19 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, } /* end else */ /* Allocate space in the object header for the message */ - if((ret_value = H5O_alloc(f, dxpl_id, oh, type, native)) < 0) + if(H5O_alloc(f, dxpl_id, oh, type, native, &new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for message") /* Get the message's "creation index", if it has one */ if(type->get_crt_index) { /* Retrieve the creation index from the native message */ - if((type->get_crt_index)(native, &oh->mesg[ret_value].crt_idx) < 0) + if((type->get_crt_index)(native, &oh->mesg[new_idx].crt_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve creation index") } /* end if */ + /* Set new message index */ + *mesg_idx = new_idx; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_alloc() */ @@ -1956,7 +1963,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, +H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, unsigned mesg_flags, unsigned update_flags) { @@ -2293,7 +2300,7 @@ H5O_msg_get_chunkno(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message type not found") /* Set return value */ - ret_value = idx_msg->chunkno; + H5_ASSIGN_OVERFLOW(ret_value, idx_msg->chunkno, unsigned, int); done: if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5Opkg.h b/src/H5Opkg.h index d4cc3fb..1f8a1cd 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -535,8 +535,9 @@ H5_DLL herr_t H5O_dec_rc(H5O_t *oh); H5_DLL herr_t H5O_free(H5O_t *oh); /* Object header message routines */ -H5_DLL int H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - const H5O_msg_class_t *type, unsigned *mesg_flags, void *mesg); +H5_DLL herr_t H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + const H5O_msg_class_t *type, unsigned *mesg_flags, void *mesg, + size_t *mesg_idx); H5_DLL herr_t H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags, void *mesg); @@ -570,8 +571,8 @@ H5_DLL herr_t H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, /* Object header allocation routines */ H5_DLL herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc); -H5_DLL int H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - const H5O_msg_class_t *type, const void *mesg); +H5_DLL herr_t H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + const H5O_msg_class_t *type, const void *mesg, size_t *mesg_idx); H5_DLL herr_t H5O_condense_header(H5F_t *f, H5O_t *oh, hid_t dxpl_id); H5_DLL herr_t H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link); diff --git a/src/H5Opline.c b/src/H5Opline.c index f626106..1a2baa0 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -250,7 +250,7 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) HDassert(mesg); /* Message header */ - *p++ = pline->version; + *p++ = (uint8_t)pline->version; *p++ = (uint8_t)(pline->nused); if(pline->version == H5O_PLINE_VERSION_1) { *p++ = 0; /*reserved 1*/ @@ -467,7 +467,7 @@ H5O_pline_size(const H5F_t UNUSED *f, const void *mesg) ((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ 2 + /*flags */ 2 + /*number of client data values */ - (pline->version == H5O_PLINE_VERSION_1 ? H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ + (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ ret_value += pline->filter[i].cd_nelmts * 4; if(pline->version == H5O_PLINE_VERSION_1) diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c index 69c7d49..2575856 100644 --- a/src/H5Oshmesg.c +++ b/src/H5Oshmesg.c @@ -129,9 +129,9 @@ H5O_shmesg_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi HDassert(mesg); /* Store version, table address, and number of indexes */ - *p++ = mesg->version; + *p++ = (uint8_t)mesg->version; H5F_addr_encode(f, &p, mesg->addr); - *p++ = mesg->nindexes; + *p++ = (uint8_t)mesg->nindexes; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_shmesg_encode() */ @@ -201,9 +201,9 @@ H5O_shmesg_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED /* Sanity check */ HDassert(f); - ret_value = 1 + /* Version number */ + ret_value = (size_t)(1 + /* Version number */ H5F_SIZEOF_ADDR(f) + /* Table address */ - 1; /* Number of indexes */ + 1); /* Number of indexes */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_shmesg_size() */ diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 47bd9fc..d05c7c2 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -227,7 +227,7 @@ H5O_stab_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED * FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value=2 * H5F_SIZEOF_ADDR(f); + ret_value = (size_t)(2 * H5F_SIZEOF_ADDR(f)); FUNC_LEAVE_NOAPI(ret_value) } diff --git a/src/H5Otest.c b/src/H5Otest.c index 5802904..705f716 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -504,8 +504,8 @@ H5O_expunge_chunks_test(const H5O_loc_t *loc, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header */ haddr_t chk_addr[16]; /* Array of chunk addresses */ - unsigned nchunks; /* Number of chunks in object header */ - unsigned u; /* Local index variable */ + size_t nchunks; /* Number of chunks in object header */ + size_t u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5P.c b/src/H5P.c index 92b3d18..abbfe4b 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -45,6 +45,13 @@ /* Local Typedefs */ /******************/ +/* Typedef for property iterator callback */ +typedef struct { + H5P_iterate_t iter_func; /* Iterator callback */ + hid_t id; /* Property list or class ID */ + void *iter_data; /* Iterator callback pointer */ +} H5P_iter_ud_t; + /********************/ /* Local Prototypes */ @@ -1045,6 +1052,45 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__iterate_cb + PURPOSE + Internal callback routine when iterating over properties in property list + or class + USAGE + int H5P__iterate_cb(prop, udata) + H5P_genprop_t *prop; IN: Pointer to the property + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine calls the actual callback routine for the property in the +property list or class. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_cb(H5P_genprop_t *prop, void *_udata) +{ + H5P_iter_ud_t *udata = (H5P_iter_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(prop); + HDassert(udata); + + /* Call the user's callback routine */ + ret_value = (*udata->iter_func)(udata->id, prop->name, udata->iter_data); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_cb() */ + + +/*-------------------------------------------------------------------------- + NAME H5Piterate PURPOSE Routine to iterate over the properties in a property list or class @@ -1099,6 +1145,7 @@ iteration, the function's behavior is undefined. int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) { + H5P_iter_ud_t udata; /* User data for internal iterator callback */ int fake_idx = 0; /* Index when user doesn't provide one */ int ret_value; /* return value */ @@ -1111,15 +1158,20 @@ H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) if(iter_func == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration callback"); + /* Set up user data */ + udata.iter_func = iter_func; + udata.id = id; + udata.iter_data = iter_data; + if(H5I_GENPROP_LST == H5I_get_type(id)) { /* Iterate over a property list */ - if((ret_value = H5P_iterate_plist(id, (idx ? idx : &fake_idx), iter_func, iter_data)) < 0) + if((ret_value = H5P_iterate_plist(id, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list"); } /* end if */ else if(H5I_GENPROP_CLS == H5I_get_type(id)) { /* Iterate over a property class */ - if((ret_value = H5P_iterate_pclass(id, (idx ? idx : &fake_idx), iter_func, iter_data)) < 0) + if((ret_value = H5P_iterate_pclass(id, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); } /* end if */ else diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 51e62fe..9e75eaa 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -33,12 +33,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ @@ -72,7 +72,7 @@ /********************/ /* Property class callbacks */ -static herr_t H5P_dacc_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass); /*********************/ @@ -85,7 +85,7 @@ const H5P_libclass_t H5P_CLS_DACC[1] = {{ &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class ID */ &H5P_LST_DATASET_ACCESS_g, /* Pointer to default property list ID */ - H5P_dacc_reg_prop, /* Default property registration routine */ + H5P__dacc_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -107,7 +107,7 @@ const H5P_libclass_t H5P_CLS_DACC[1] = {{ /*------------------------------------------------------------------------- - * Function: H5P_dacc_reg_prop + * Function: H5P__dacc_reg_prop * * Purpose: Register the dataset access property list class's * properties @@ -119,14 +119,14 @@ const H5P_libclass_t H5P_CLS_DACC[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5P_dacc_reg_prop(H5P_genclass_t *pclass) +H5P__dacc_reg_prop(H5P_genclass_t *pclass) { size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register the size of raw data chunk cache (elements) */ if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) @@ -142,7 +142,7 @@ H5P_dacc_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dacc_reg_prop() */ +} /* end H5P__dacc_reg_prop() */ /*------------------------------------------------------------------------- @@ -186,24 +186,24 @@ H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double /* Check arguments. Note that we allow negative values - they are * considered to "unset" the property. */ - if (rdcc_w0 > 1.0) + if(rdcc_w0 > 1.0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); /* Get the plist structure */ - if (NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS))) + if(NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ - if (H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + if(H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of chunks"); - if (H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) + if(H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); - if (H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) + if(H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks"); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_chunk_cache() */ /*------------------------------------------------------------------------- diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 54654c5..2235944 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -65,7 +65,7 @@ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the - * H5P_init_def_layout() routine. -QAK + * H5P__init_def_layout() routine. -QAK */ #define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} #define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} @@ -76,7 +76,7 @@ /* Definitions for storage layout property */ #define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) #define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG -#define H5D_CRT_LAYOUT_CMP H5P_dcrt_layout_cmp +#define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ #define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) @@ -88,7 +88,7 @@ /* Definitions for external file list */ #define H5D_CRT_EXT_FILE_LIST_SIZE sizeof(H5O_efl_t) #define H5D_CRT_EXT_FILE_LIST_DEF {HADDR_UNDEF, 0, 0, NULL} -#define H5D_CRT_EXT_FILE_LIST_CMP H5P_dcrt_ext_file_list_cmp +#define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp /******************/ @@ -106,19 +106,19 @@ /********************/ /* General routines */ -static herr_t H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); +static herr_t H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER -static herr_t H5P_init_def_layout(void); +static herr_t H5P__init_def_layout(void); #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Property class callbacks */ -static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P_dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); -static herr_t H5P_dcrt_close(hid_t dxpl_id, void *close_data); +static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P__dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); +static herr_t H5P__dcrt_close(hid_t dxpl_id, void *close_data); /* Property callbacks */ -static int H5P_dcrt_layout_cmp(const void *value1, const void *value2, size_t size); -static int H5P_dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); /*********************/ @@ -131,12 +131,12 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */ &H5P_CLS_DATASET_CREATE_g, /* Pointer to class ID */ &H5P_LST_DATASET_CREATE_g, /* Pointer to default property list ID */ - H5P_dcrt_reg_prop, /* Default property registration routine */ + H5P__dcrt_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ - H5P_dcrt_copy, /* Class copy callback */ + H5P__dcrt_copy, /* Class copy callback */ NULL, /* Class copy callback info */ - H5P_dcrt_close, /* Class close callback */ + H5P__dcrt_close, /* Class close callback */ NULL /* Class close callback info */ }}; @@ -163,7 +163,7 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; /*------------------------------------------------------------------------- - * Function: H5P_dcrt_reg_prop + * Function: H5P__dcrt_reg_prop * * Purpose: Register the dataset creation property list class's properties * @@ -174,7 +174,7 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; *------------------------------------------------------------------------- */ static herr_t -H5P_dcrt_reg_prop(H5P_genclass_t *pclass) +H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { H5O_layout_t layout = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ @@ -182,7 +182,7 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) H5O_efl_t efl = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register the storage layout property */ if(H5P_register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, H5D_CRT_LAYOUT_CMP, NULL) < 0) @@ -202,11 +202,11 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_reg_prop() */ +} /* end H5P__dcrt_reg_prop() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_copy + * Function: H5P__dcrt_copy * * Purpose: Callback routine which is called whenever any dataset * creation property list is copied. This routine copies @@ -222,7 +222,7 @@ done: */ /* ARGSUSED */ static herr_t -H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) +H5P__dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) { H5O_fill_t src_fill, dst_fill; /* Source & destination fill values */ H5O_efl_t src_efl, dst_efl; /* Source & destination external file lists */ @@ -231,7 +231,7 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) H5P_genplist_t *dst_plist; /* Pointer to destination property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Verify property list IDs */ if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_plist_id))) @@ -280,6 +280,8 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) dst_layout.storage.u.chunk.ops = NULL; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HDassert(0 && "Unknown layout type!"); } /* end switch */ @@ -314,11 +316,11 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_copy() */ +} /* end H5P__dcrt_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_close + * Function: H5P__dcrt_close * * Purpose: Callback routine which is called whenever any dataset create * property list is closed. This routine performs any generic @@ -334,14 +336,14 @@ done: */ /* ARGSUSED */ static herr_t -H5P_dcrt_close(hid_t dcpl_id, void UNUSED *close_data) +H5P__dcrt_close(hid_t dcpl_id, void UNUSED *close_data) { H5O_fill_t fill; /* Fill value */ H5O_efl_t efl; /* External file list */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) @@ -362,11 +364,11 @@ H5P_dcrt_close(hid_t dcpl_id, void UNUSED *close_data) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_close() */ +} /* end H5P__dcrt_close() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_layout_cmp + * Function: H5P__dcrt_layout_cmp * * Purpose: Callback routine which is called whenever the layout * property in the dataset creation property list is @@ -382,13 +384,13 @@ done: *------------------------------------------------------------------------- */ static int -H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED size) +H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED size) { const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ *layout2 = (const H5O_layout_t *)_layout2; herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(layout1); @@ -425,13 +427,15 @@ H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED si } /* end case */ break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HDassert(0 && "Unknown layout type!"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_layout_cmp() */ +} /* end H5P__dcrt_layout_cmp() */ /*------------------------------------------------------------------------- @@ -496,7 +500,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5P_dcrt_ext_file_list_cmp + * Function: H5P__dcrt_ext_file_list_cmp * * Purpose: Callback routine which is called whenever the external file * list property in the dataset creation property list is @@ -512,14 +516,14 @@ done: *------------------------------------------------------------------------- */ static int -H5P_dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED size) +H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED size) { const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ *efl2 = (const H5O_efl_t *)_efl2; int cmp_value; /* Value from comparison */ herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(efl1); @@ -573,11 +577,11 @@ H5P_dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED s done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_ext_file_list_cmp() */ +} /* end H5P__dcrt_ext_file_list_cmp() */ /*------------------------------------------------------------------------- - * Function: H5P_set_layout + * Function: H5P__set_layout * * Purpose: Sets the layout of raw data in the file. * @@ -589,12 +593,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) +H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) { unsigned alloc_time_state; /* State of allocation time property */ herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Get the allocation time state */ if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) @@ -622,6 +626,8 @@ H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) fill.alloc_time = H5D_ALLOC_TIME_INCR; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ @@ -637,12 +643,12 @@ H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_set_layout() */ +} /* end H5P__set_layout() */ #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /*------------------------------------------------------------------------- - * Function: H5P_init_def_layout + * Function: H5P__init_def_layout * * Purpose: Set the default layout information for the various types of * dataset layouts @@ -655,13 +661,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_init_def_layout(void) +H5P__init_def_layout(void) { const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; const H5O_storage_compact_t def_store_compact = H5D_DEF_STORAGE_COMPACT_INIT; const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Initialize the default layout info for non-contigous layouts */ H5D_def_layout_compact_g.storage.u.compact = def_store_compact; @@ -672,7 +678,7 @@ H5P_init_def_layout(void) H5P_dcrt_def_layout_init_g = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_init_def_layout() */ +} /* end H5P__init_def_layout() */ #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -718,7 +724,7 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) * the default layout structs have been initialized yet or not. *ick* -QAK */ if(!H5P_dcrt_def_layout_init_g) - if(H5P_init_def_layout() < 0) + if(H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -736,12 +742,14 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) layout = &H5D_def_layout_chunk_g; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ /* Set value */ - if(H5P_set_layout(plist, layout) < 0) + if(H5P__set_layout(plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: @@ -845,7 +853,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) * the default layout structs have been initialized yet or not. *ick* -QAK */ if(!H5P_dcrt_def_layout_init_g) - if(H5P_init_def_layout() < 0) + if(H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -870,7 +878,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) /* Set chunk information in property list */ chunk_layout.u.chunk.ndims = (unsigned)ndims; - if(H5P_set_layout(plist, &chunk_layout) < 0) + if(H5P__set_layout(plist, &chunk_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") done: @@ -959,18 +967,6 @@ done: * Programmer: Robb Matzke * Tuesday, March 3, 1998 * - * Modifications: - * - * Raymond Lu - * Tuesday, October 2, 2001 - * Changed the way to check parameter and set property for - * generic property list. - * - * Raymond Lu - * 7 April 2011 - * Starting from the 1.8.7 release, we allow dataspace to have - * zero dimension size. So the external storage size for - * dataset can be zero. *------------------------------------------------------------------------- */ herr_t @@ -979,16 +975,16 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) size_t idx; hsize_t total, tmp; H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*soh", plist_id, name, offset, size); /* Check arguments */ - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if (offset<0) + if(offset < 0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset") /* Get the plist structure */ @@ -997,14 +993,14 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") - if(efl.nused > 0 && H5O_EFL_UNLIMITED==efl.slot[efl.nused-1].size) + if(efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited") - if (H5O_EFL_UNLIMITED!=size) { - for (idx=0, total=size; idx0 && value!=NULL) || (size==0)); - HDassert(type!=H5P_PROP_WITHIN_UNKNOWN); + HDassert((size > 0 && value != NULL) || (size == 0)); + HDassert(type != H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ - if(NULL==(prop = H5FL_MALLOC (H5P_genprop_t))) + if(NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the property initial values */ @@ -994,37 +1012,37 @@ H5P_create_prop(const char *name, size_t size, H5P_prop_within_t type, prop->type = type; /* Duplicate value, if it exists */ - if(value!=NULL) { - if(NULL==(prop->value = H5MM_malloc (prop->size))) + if(value != NULL) { + if(NULL == (prop->value = H5MM_malloc (prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - HDmemcpy(prop->value,value,prop->size); + HDmemcpy(prop->value, value, prop->size); } /* end if */ else - prop->value=NULL; + prop->value = NULL; /* Set the function pointers */ - prop->create=prp_create; - prop->set=prp_set; - prop->get=prp_get; - prop->del=prp_delete; - prop->copy=prp_copy; + prop->create = prp_create; + prop->set = prp_set; + prop->get = prp_get; + prop->del = prp_delete; + prop->copy = prp_copy; /* Use custom comparison routine if available, otherwise default to memcmp() */ - if(prp_cmp!=NULL) - prop->cmp=prp_cmp; + if(prp_cmp != NULL) + prop->cmp = prp_cmp; else - prop->cmp=&memcmp; - prop->close=prp_close; + prop->cmp = &memcmp; + prop->close = prp_close; /* Set return value */ - ret_value=prop; + ret_value = prop; done: /* Free any resources allocated */ - if(ret_value==NULL) { - if(prop!=NULL) { - if(prop->name!=NULL) + if(ret_value == NULL) { + if(prop != NULL) { + if(prop->name != NULL) H5MM_xfree(prop->name); - if(prop->value!=NULL) + if(prop->value != NULL) H5MM_xfree(prop->value); prop = H5FL_FREE(H5P_genprop_t, prop); } /* end if */ @@ -2335,8 +2353,9 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, /* Check if the property has been deleted */ if(NULL != H5SL_search(plist->del, name)) { char *temp_name = NULL; + /* Remove the property name from the deleted property skip list */ - if(NULL == (temp_name = H5SL_remove(plist->del, name))) + if(NULL == (temp_name = (char *)H5SL_remove(plist->del, name))) HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from deleted skip list") /* free the name of the removed property */ @@ -3316,14 +3335,113 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__iterate_plist_cb + PURPOSE + Internal callback routine when iterating over properties in property list + USAGE + int H5P__iterate_plist_cb(item, key, udata) + void *item; IN: Pointer to the property + void *key; IN: Pointer to the property's name + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine calls the actual callback routine for the property in the +property list. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) +{ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(item); + HDassert(key); + + /* Check if we've found the correctly indexed property */ + if(*udata->curr_idx_ptr >= udata->prev_idx) { + /* Call the callback function */ + ret_value = (*udata->cb_func)(item, udata->udata); + if(ret_value != 0) + HGOTO_DONE(ret_value); + } /* end if */ + + /* Increment the current index */ + (*udata->curr_idx_ptr)++; + + /* Add property name to "seen" list */ + if(H5SL_insert(udata->seen, key, key) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into seen skip list") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_plist_cb() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P__iterate_plist_pclass_cb + PURPOSE + Internal callback routine when iterating over properties in property class + USAGE + int H5P__iterate_plist_pclass_cb(item, key, udata) + void *item; IN: Pointer to the property + void *key; IN: Pointer to the property's name + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine verifies that the property hasn't already been seen or was +deleted, and then chains to the property list callback. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_plist_pclass_cb(void *_item, void *_key, void *_udata) +{ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(item); + HDassert(key); + + /* Only call iterator callback for properties we haven't seen + * before and that haven't been deleted. + */ + if(NULL == H5SL_search(udata->seen, key) && + NULL == H5SL_search(udata->plist->del, key)) + ret_value = H5P__iterate_plist_cb(item, key, udata); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_plist_pclass_cb() */ + + +/*-------------------------------------------------------------------------- + NAME H5P_iterate_plist PURPOSE Internal routine to iterate over the properties in a property list USAGE - herr_t H5P_iterate_plist(plist_id, idx, iter_func, iter_data) + int H5P_iterate_plist(plist_id, idx, cb_func, iter_data) hid_t plist_id; IN: ID of property list to iterate over int *idx; IN/OUT: Index of the property to begin with - H5P_iterate_t iter_func; IN: Function pointer to function to be + H5P_iterate_t cb_func; IN: Function pointer to function to be called with each property iterated over. void *iter_data; IN/OUT: Pointer to iteration data from user RETURNS @@ -3366,106 +3484,60 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ int -H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_data) +H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_int_t cb_func, void *udata) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist; /* Property list pointer */ - H5P_genprop_t *tmp; /* Temporary pointer to properties */ + H5P_iter_plist_ud_t udata_int; /* User data for skip list iterator */ H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ - H5SL_node_t *curr_node; /* Current node in skip list */ int curr_idx = 0; /* Current iteration index */ - int ret_value = FAIL; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(idx); - HDassert(iter_func); + HDassert(cb_func); /* Get the property list object */ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Create the skip list to hold names of properties already seen */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties") - - /* Walk through the changed properties in the list */ - if(H5SL_count(plist->props) > 0) { - curr_node = H5SL_first(plist->props); - while(curr_node != NULL) { - /* Get pointer to property from node */ - tmp = (H5P_genprop_t *)H5SL_item(curr_node); - - /* Check if we've found the correctly indexed property */ - if(curr_idx>=*idx) { - /* Call the callback function */ - ret_value=(*iter_func)(plist_id,tmp->name,iter_data); - - if(ret_value!=0) - HGOTO_DONE(ret_value); - } /* end if */ - - /* Increment the current index */ - curr_idx++; - - /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") - - /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); - } /* end while */ - } /* end if */ + if(NULL == (seen = H5SL_create(H5SL_TYPE_STR, NULL))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't create skip list for seen properties") + + /* Set up iterator callback info */ + udata_int.plist = plist; + udata_int.cb_func = cb_func; + udata_int.udata = udata; + udata_int.seen = seen; + udata_int.curr_idx_ptr = &curr_idx; + udata_int.prev_idx = *idx; + + /* Iterate over properties in property list proper */ + /* (Will be only the non-default (i.e. changed) properties) */ + ret_value = H5SL_iterate(plist->props, H5P__iterate_plist_cb, &udata_int); + if(ret_value != 0) + HGOTO_DONE(ret_value); /* Walk up the class hiearchy */ - tclass=plist->pclass; - while(tclass!=NULL) { - if(tclass->nprops>0) { - /* Walk through the properties in the class */ - curr_node=H5SL_first(tclass->props); - while(curr_node!=NULL) { - /* Get pointer to property from node */ - tmp = (H5P_genprop_t *)H5SL_item(curr_node); - - /* Only call iterator callback for properties we haven't seen - * before and that haven't been deleted - */ - if(H5SL_search(seen,tmp->name) == NULL && - H5SL_search(plist->del,tmp->name) == NULL) { - - - /* Check if we've found the correctly indexed property */ - if(curr_idx>=*idx) { - /* Call the callback function */ - ret_value=(*iter_func)(plist_id,tmp->name,iter_data); - - if(ret_value!=0) - HGOTO_DONE(ret_value); - } /* end if */ - - /* Increment the current index */ - curr_idx++; - - /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") - } /* end if */ - - /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); - } /* end while */ - } /* end if */ + tclass = plist->pclass; + while(tclass != NULL) { + /* Iterate over properties in property list class */ + ret_value = H5SL_iterate(tclass->props, H5P__iterate_plist_pclass_cb, &udata_int); + if(ret_value != 0) + HGOTO_DONE(ret_value); /* Go up to parent class */ - tclass=tclass->parent; + tclass = tclass->parent; } /* end while */ done: /* Set the index we stopped at */ - *idx=curr_idx; + *idx = curr_idx; /* Release the skip list of 'seen' properties */ - if(seen!=NULL) + if(seen != NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value) @@ -3474,14 +3546,65 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__iterate_pclass_cb + PURPOSE + Internal callback routine when iterating over properties in property list + class + USAGE + int H5P__iterate_pclass_cb(item, key, udata) + void *item; IN: Pointer to the property + void *key; IN: Pointer to the property's name + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine calls the actual callback routine for the property in the +property list class. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_pclass_cb(void *_item, void *_key, void *_udata) +{ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_pclass_ud_t *udata = (H5P_iter_pclass_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(item); + HDassert(key); + + /* Check if we've found the correctly indexed property */ + if(*udata->curr_idx_ptr >= udata->prev_idx) { + /* Call the callback function */ + ret_value = (*udata->cb_func)(item, udata->udata); + if(ret_value != 0) + HGOTO_DONE(ret_value); + } /* end if */ + + /* Increment the current index */ + (*udata->curr_idx_ptr)++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_pclass_cb() */ + + +/*-------------------------------------------------------------------------- + NAME H5P_iterate_pclass PURPOSE Internal routine to iterate over the properties in a property class USAGE - herr_t H5P_iterate_pclass(pclass_id, idx, iter_func, iter_data) + herr_t H5P_iterate_pclass(pclass_id, idx, cb_func, iter_data) hid_t pclass_id; IN: ID of property class to iterate over int *idx; IN/OUT: Index of the property to begin with - H5P_iterate_t iter_func; IN: Function pointer to function to be + H5P_iterate_t cb_func; IN: Function pointer to function to be called with each property iterated over. void *iter_data; IN/OUT: Pointer to iteration data from user RETURNS @@ -3524,49 +3647,36 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ int -H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, void *iter_data) +H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_int_t cb_func, void *udata) { H5P_genclass_t *pclass; /* Property list pointer */ - H5SL_node_t *curr_node; /* Current node in skip list */ - H5P_genprop_t *prop; /* Temporary property pointer */ - int curr_idx=0; /* Current iteration index */ - int ret_value=FAIL; /* Return value */ + H5P_iter_pclass_ud_t udata_int; /* User data for skip list iterator */ + int curr_idx = 0; /* Current iteration index */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(idx); - HDassert(iter_func); + HDassert(cb_func); /* Get the property list object */ if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class") - /* Cycle through the properties and call the callback */ - curr_idx=0; - curr_node=H5SL_first(pclass->props); - while(curr_node!=NULL) { - if(curr_idx>=*idx) { - /* Get the property for the node */ - prop = (H5P_genprop_t *)H5SL_item(curr_node); - - /* Call the callback function */ - ret_value=(*iter_func)(pclass_id,prop->name,iter_data); + /* Set up iterator callback info */ + udata_int.cb_func = cb_func; + udata_int.udata = udata; + udata_int.curr_idx_ptr = &curr_idx; + udata_int.prev_idx = *idx; - /* Check if iteration function succeeded */ - if(ret_value!=0) - HGOTO_DONE(ret_value); - } /* end if */ - - /* Increment the iteration index */ - curr_idx++; - - /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); - } /* end while */ + /* Iterate over properties in property list class proper */ + ret_value = H5SL_iterate(pclass->props, H5P__iterate_pclass_cb, &udata_int); + if(ret_value != 0) + HGOTO_DONE(ret_value); done: /* Set the index we stopped at */ - *idx=curr_idx; + *idx = curr_idx; FUNC_LEAVE_NOAPI(ret_value) } /* H5P_iterate_pclass() */ @@ -4108,25 +4218,26 @@ H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) /* If not, get the information required to do an H5Pinsert2 with the property into the destination list */ else { /* Get the pointer to the source property */ - prop=H5P_find_prop_plist(src_plist,name); + prop = H5P_find_prop_plist(src_plist, name); /* Create property object from parameters */ - if((new_prop=H5P_create_prop(prop->name,prop->size,H5P_PROP_WITHIN_LIST,prop->value,prop->create,prop->set,prop->get,prop->del,prop->copy,prop->cmp,prop->close)) == NULL) + if(NULL == (new_prop = H5P_create_prop(prop->name, prop->size, H5P_PROP_WITHIN_LIST, prop->value, + prop->create, prop->set, prop->get, + prop->del, prop->copy, prop->cmp, prop->close))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property") /* Call property creation callback, if it exists */ if(new_prop->create) { - if((new_prop->create)(new_prop->name,new_prop->size,new_prop->value) < 0) + if((new_prop->create)(new_prop->name, new_prop->size, new_prop->value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property") } /* end if */ /* Insert property into property list class */ - if(H5P_add_prop(dst_plist->props,new_prop) < 0) + if(H5P_add_prop(dst_plist->props, new_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") /* Increment property count for class */ dst_plist->nprops++; - } /* end else */ done: @@ -4202,7 +4313,8 @@ H5P_copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name) /* Register the property into the destination */ orig_dst_pclass = dst_pclass; - if(H5P_register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, prop->del, prop->copy, prop->cmp, prop->close) < 0) + if(H5P_register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, + prop->del, prop->copy, prop->cmp, prop->close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") /* Check if the property class changed and needs to be substituted in the ID */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index 217d0ba..7a52f11 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -379,8 +379,8 @@ H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags) ohdr_flags &= (uint8_t)~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); /* Update with new attribute creation order flags */ - ohdr_flags |= (uint8_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0); - ohdr_flags |= (uint8_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0); + ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0)); + ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0)); /* Set object header flags */ if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) @@ -486,7 +486,7 @@ H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) ohdr_flags &= (uint8_t)~H5O_HDR_STORE_TIMES; /* Update with new time tracking flag */ - ohdr_flags |= (uint8_t)(track_times ? H5O_HDR_STORE_TIMES : 0); + ohdr_flags = (uint8_t)(ohdr_flags | (track_times ? H5O_HDR_STORE_TIMES : 0)); /* Set object header flags */ if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) @@ -1343,7 +1343,7 @@ H5P_get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, * *------------------------------------------------------------------------- */ -int +static int H5P_ocrt_pipeline_cmp(const void *_pline1, const void *_pline2, size_t UNUSED size) { const H5O_pline_t *pline1 = (const H5O_pline_t *)_pline1, /* Create local aliases for values */ diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index 1e71049..65d314e 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -138,6 +138,8 @@ typedef struct H5P_libclass_t { void *close_data; /* Pointer to user data to pass along to close callback */ } H5P_libclass_t; +/* Property list/class iterator callback function pointer */ +typedef int (*H5P_iterate_int_t)(H5P_genprop_t *prop, void *udata); /*****************************/ /* Package Private Variables */ @@ -176,9 +178,9 @@ H5_DLL H5P_genclass_t *H5P_get_class(const H5P_genplist_t *plist); H5_DLL herr_t H5P_get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops); H5_DLL int H5P_cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); H5_DLL int H5P_cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2); -H5_DLL int H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, +H5_DLL int H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_int_t iter_func, void *iter_data); -H5_DLL int H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, +H5_DLL int H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_int_t iter_func, void *iter_data); H5_DLL herr_t H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5P_copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name); diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index 91cf70b..188fdd2 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -108,7 +108,7 @@ const H5P_libclass_t H5P_CLS_STRCRT[1] = {{ * October 31, 2006 *------------------------------------------------------------------------- */ -herr_t +static herr_t H5P_strcrt_reg_prop(H5P_genclass_t *pclass) { H5T_cset_t char_encoding = H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ diff --git a/src/H5R.c b/src/H5R.c index 8fac4bf..d45947b 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -217,7 +217,7 @@ H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5 HDassert(_ref); HDassert(loc); HDassert(name); - HDassert(ref_type > H5R_BADTYPE || ref_type < H5R_MAXTYPE); + HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); /* Set up object location to fill in */ obj_loc.oloc = &oloc; @@ -272,7 +272,7 @@ H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5 HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection") /* Increase buffer size to allow for the dataset OID */ - buf_size += sizeof(haddr_t); + buf_size += (hssize_t)sizeof(haddr_t); /* Allocate the space to store the serialized information */ H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); @@ -418,7 +418,7 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, FUNC_ENTER_NOAPI_NOINIT HDassert(_ref); - HDassert(ref_type > H5R_BADTYPE || ref_type < H5R_MAXTYPE); + HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); HDassert(file); /* Initialize the object location */ @@ -525,6 +525,8 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, } /* end case */ break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: default: HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL, "can't identify type of object referenced") } /* end switch */ @@ -880,7 +882,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -ssize_t +static ssize_t H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { diff --git a/src/H5SL.c b/src/H5SL.c index b6c9f8e..7581858 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -745,7 +745,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ @@ -817,7 +817,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { herr_t ret_value = SUCCEED; @@ -873,7 +873,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) FUNC_ENTER_NOAPI(NULL) /* Check args */ - HDassert(type>=H5SL_TYPE_INT && type<=H5SL_TYPE_GENERIC); + HDassert(type >= H5SL_TYPE_INT && type <= H5SL_TYPE_GENERIC); /* Allocate skip list structure */ if(NULL == (new_slist = H5FL_MALLOC(H5SL_t))) @@ -889,7 +889,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) new_slist->nobjs = 0; /* Allocate the header node */ - if(NULL == (header = H5SL_new_node(NULL, NULL, ULONG_MAX))) + if(NULL == (header = H5SL_new_node(NULL, NULL, (uint32_t)ULONG_MAX))) HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") /* Initialize header node's forward pointer */ diff --git a/src/H5Sall.c b/src/H5Sall.c index c99d699..8d56c80 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -112,7 +112,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_all_iter_init (H5S_sel_iter_t *iter, const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -445,7 +445,7 @@ H5S_all_copy(H5S_t *dst, const H5S_t UNUSED *src, hbool_t UNUSED share_selection EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_valid (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -475,7 +475,7 @@ H5S_all_is_valid (const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -hssize_t +static hssize_t H5S_all_serial_size (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -509,7 +509,7 @@ H5S_all_serial_size (const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_serialize (const H5S_t *space, uint8_t *buf) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -545,7 +545,7 @@ H5S_all_serialize (const H5S_t *space, uint8_t *buf) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_deserialize(H5S_t *space, const uint8_t UNUSED *buf) { herr_t ret_value; /* return value */ @@ -588,7 +588,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { unsigned rank; /* Dataspace rank */ @@ -633,7 +633,7 @@ H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_offset(const H5S_t UNUSED *space, hsize_t *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -666,7 +666,7 @@ H5S_all_offset(const H5S_t UNUSED *space, hsize_t *offset) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_contiguous(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -695,7 +695,7 @@ H5S_all_is_contiguous(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_single(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -725,7 +725,7 @@ H5S_all_is_single(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_regular(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -755,7 +755,7 @@ H5S_all_is_regular(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_adjust_u(H5S_t UNUSED *space, const hsize_t UNUSED *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -945,7 +945,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_iter_t *iter, size_t UNUSED maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 1eeb098..d9b306d 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -234,7 +234,7 @@ H5S_hyper_print_diminfo(FILE *f, const H5S_t *space) * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ @@ -1614,7 +1614,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) { H5S_hyper_sel_t *dst_hslab; /* Pointer to destination hyperslab info */ @@ -1749,7 +1749,7 @@ H5S_hyper_is_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_t *o EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_valid (const H5S_t *space) { unsigned u; /* Counter */ @@ -2068,7 +2068,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) { const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ @@ -2229,7 +2229,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_deserialize (H5S_t *space, const uint8_t *buf) { uint32_t rank; /* rank of points */ @@ -2705,7 +2705,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { unsigned rank; /* Dataspace rank */ @@ -2772,7 +2772,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_offset(const H5S_t *space, hsize_t *offset) { const hssize_t *sel_offset; /* Pointer to the selection's offset */ @@ -2878,7 +2878,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_contiguous(const H5S_t *space) { unsigned small_contiguous, /* Flag for small contiguous block */ @@ -3063,7 +3063,7 @@ H5S_hyper_is_contiguous(const H5S_t *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_single(const H5S_t *space) { H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ @@ -3133,7 +3133,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_regular(const H5S_t *space) { htri_t ret_value; /* return value */ @@ -3175,7 +3175,7 @@ H5S_hyper_is_regular(const H5S_t *space) * changing the hyperslab selection of one data space causes a core dump * when closing some other data space. --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_release(H5S_t *space) { herr_t ret_value = SUCCEED; @@ -4008,7 +4008,7 @@ H5S_hyper_adjust_helper_u (H5S_hyper_span_info_t *spans, const hsize_t *offset) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_adjust_u(H5S_t *space, const hsize_t *offset) { unsigned u; /* Local index variable */ diff --git a/src/H5Snone.c b/src/H5Snone.c index e9a3bf9..021dd61 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -113,7 +113,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -589,7 +589,7 @@ H5S_none_bounds(const H5S_t UNUSED *space, hsize_t UNUSED *start, hsize_t UNUSED EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_none_offset(const H5S_t UNUSED *space, hsize_t UNUSED *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -708,7 +708,7 @@ H5S_none_is_regular(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_none_adjust_u(H5S_t UNUSED *space, const hsize_t UNUSED *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 7e82295..817b2f2 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -120,7 +120,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t); * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1136,7 +1136,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_point_offset(const H5S_t *space, hsize_t *offset) { const hsize_t *pnt; /* Pointer to a selected point's coordinates */ @@ -1316,7 +1316,7 @@ H5S_point_is_regular(const H5S_t *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_point_adjust_u(H5S_t *space, const hsize_t *offset) { H5S_pnt_node_t *node; /* Point node */ diff --git a/src/H5T.c b/src/H5T.c index b2d97bc..5a3c17b 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -734,7 +734,7 @@ DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -herr_t +static herr_t H5T_init_interface(void) { H5T_t *native_schar=NULL; /* Datatype structure for native signed char */ @@ -3155,7 +3155,7 @@ done: *------------------------------------------------------------------------- */ H5T_t * -H5T_copy(const H5T_t *old_dt, H5T_copy_t method) +H5T_copy(H5T_t *old_dt, H5T_copy_t method) { H5T_t *new_dt = NULL, *tmp = NULL; H5T_shared_t *reopened_fo = NULL; @@ -3840,8 +3840,10 @@ H5T_set_size(H5T_t *dt, size_t size) case H5T_ENUM: case H5T_VLEN: case H5T_ARRAY: - assert("can't happen" && 0); case H5T_REFERENCE: + assert("can't happen" && 0); + case H5T_NO_CLASS: + case H5T_NCLASSES: assert("invalid type" && 0); default: assert("not implemented yet" && 0); @@ -4296,6 +4298,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /*void */ break; + case H5R_BADTYPE: + case H5R_MAXTYPE: + assert("invalid type" && 0); default: assert("not implemented yet" && 0); } @@ -5147,7 +5152,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) } /* end for */ /* Apply the accumulated size change to the datatype */ - dt->shared->size += accum_change; + dt->shared->size = (size_t)(dt->shared->size + accum_change); break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL sequence */ diff --git a/src/H5Tarray.c b/src/H5Tarray.c index e9c8fe7..9986631 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -279,7 +279,7 @@ H5T__get_array_ndims(const H5T_t *dt) HDassert(dt->shared->type == H5T_ARRAY); /* Retrieve the number of dimensions */ - FUNC_LEAVE_NOAPI(dt->shared->u.array.ndims) + FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) } /* end H5T__get_array_ndims */ @@ -337,9 +337,8 @@ int H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) { unsigned u; /* Local index variable */ - int ret_value; /* return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR HDassert(dt); HDassert(dt->shared->type == H5T_ARRAY); @@ -350,10 +349,7 @@ H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) dims[u] = dt->shared->u.array.dim[u]; /* Pass along the array rank as the return value */ - ret_value = dt->shared->u.array.ndims; - -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) } /* end H5T__get_array_dims */ #ifndef H5_NO_DEPRECATED_SYMBOLS diff --git a/src/H5Tfields.c b/src/H5Tfields.c index aa1efe8..163bab3 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -83,7 +83,7 @@ H5Tget_nmembers(hid_t type_id) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if((ret_value = H5T_get_nmembers(dt)) < 0) @@ -165,7 +165,7 @@ H5Tget_member_name(hid_t type_id, unsigned membno) FUNC_ENTER_API(NULL) /* Check args */ - if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") if(NULL == (ret_value = H5T__get_member_name(dt, membno))) @@ -217,6 +217,17 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) ret_value = H5MM_xstrdup(dt->shared->u.enumer.name[membno]); break; + case H5T_NO_CLASS: + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_REFERENCE: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "operation not supported for type class") } /*lint !e788 All appropriate cases are covered */ @@ -255,31 +266,41 @@ H5Tget_member_index(hid_t type_id, const char *name) H5TRACE2("Is", "i*s", type_id, name); /* Check arguments */ - assert(name); - if(NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) + HDassert(name); + if(NULL == (dt = (H5T_t*)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Locate member by name */ - switch (dt->shared->type) { + switch(dt->shared->type) { case H5T_COMPOUND: - for(i=0; i< dt->shared->u.compnd.nmembs; i++) { + for(i = 0; i < dt->shared->u.compnd.nmembs; i++) if(!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) HGOTO_DONE((int)i) - } break; case H5T_ENUM: - for(i=0; i< dt->shared->u.enumer.nmembs; i++) { + for(i = 0; i < dt->shared->u.enumer.nmembs; i++) if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_DONE((int)i) - } break; + + case H5T_NO_CLASS: + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_REFERENCE: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for this type") } /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Tget_member_index() */ /*------------------------------------------------------------------------- @@ -308,7 +329,7 @@ H5T__sort_value(const H5T_t *dt, int *map) unsigned i, j; /* Local index variables */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(dt); @@ -381,7 +402,6 @@ H5T__sort_value(const H5T_t *dt, int *map) } /* end if */ } /* end else */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__sort_value() */ @@ -411,9 +431,8 @@ H5T__sort_name(const H5T_t *dt, int *map) size_t size; hbool_t swapped; uint8_t tbuf[32]; - herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Check args */ assert(dt); @@ -488,7 +507,6 @@ H5T__sort_name(const H5T_t *dt, int *map) } } -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 0c96896..345924c 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -106,7 +106,7 @@ H5_DLLVAR H5T_order_t H5T_native_order_g; /* Private functions */ H5_DLL herr_t H5TN_init_interface(void); H5_DLL herr_t H5T_init(void); -H5_DLL H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method); +H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); H5_DLL herr_t H5T_close(H5T_t *dt); H5_DLL H5T_t *H5T_get_super(const H5T_t *dt); diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 48948a7..9fa3863 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -537,7 +537,7 @@ done: * *------------------------------------------------------------------------- */ -void +static void H5Z_xform_destroy_parse_tree(H5Z_node *tree) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -567,7 +567,7 @@ H5Z_xform_destroy_parse_tree(H5Z_node *tree) * *------------------------------------------------------------------------- */ -void * +static void * H5Z_xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers) { H5Z_token tok; @@ -1251,7 +1251,7 @@ done: * *------------------------------------------------------------------------- */ -void * +static void * H5Z_xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datval_ptrs* new_dat_val_pointers) { H5Z_node* ret_value=NULL; @@ -1386,7 +1386,7 @@ H5Z_op_is_numbs2(H5Z_node* _tree) * *------------------------------------------------------------------------- */ -void +static void H5Z_xform_reduce_tree(H5Z_node* tree) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1516,7 +1516,7 @@ H5Z_xform_create(const char *expr) * we don't need to allocate any space since no array will have to be * stored */ if(count > 0) - if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val = (void *)H5MM_calloc(count * sizeof(void *)))) + if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array") /* Initialize the num_ptrs field, which will be used to keep track of the number of copies @@ -1651,7 +1651,7 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop) count++; if(count > 0) - if(NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void *)H5MM_calloc(count * sizeof(void *)))) + if(NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array") /* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right amount */ -- cgit v0.12 From f385b0d537b4fd5fec2e67b93e15c7c3a764c4a3 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Thu, 26 Jul 2012 21:51:04 -0500 Subject: [svn-r22610] HDFFV-8055 H5TBdelete_record destroys data after the deleted row Added fix and test case. Tested: gnu and intel (jam) --- hl/src/H5TB.c | 10 ++++- hl/test/test_table.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 2 deletions(-) diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 6edc244..8a77f13 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -1298,6 +1298,7 @@ herr_t H5TBdelete_record( hid_t loc_id, hid_t tid=-1; hid_t sid=-1; hid_t m_sid=-1; + hid_t mem_type_id=-1; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; @@ -1364,6 +1365,10 @@ herr_t H5TBdelete_record( hid_t loc_id, if ((sid = H5Dget_space( did )) < 0) goto out; + /* create the memory data type. */ + if ((mem_type_id=H5TB_create_type( loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0) + goto out; + /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = read_nrecords; @@ -1375,12 +1380,14 @@ herr_t H5TBdelete_record( hid_t loc_id, if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - if (H5Dwrite( did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) + if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) goto out; /* close */ if (H5Sclose( m_sid ) < 0) goto out; + if (H5Tclose( mem_type_id ) < 0) + goto out; if (H5Sclose( sid ) < 0) goto out; if (H5Tclose( tid ) < 0) @@ -1416,6 +1423,7 @@ out: free( tmp_buf ); H5E_BEGIN_TRY { + H5Tclose(mem_type_id); H5Dclose(did); H5Tclose(tid); H5Sclose(sid); diff --git a/hl/test/test_table.c b/hl/test/test_table.c index e3e040e..cdae768 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -114,6 +114,27 @@ typedef struct particle3_t int lati; } particle3_t; +/*------------------------------------------------------------------------- + * a particle, used in the delete field test differing memory layout + *------------------------------------------------------------------------- + */ + +/* Push current alignment rule forcing 4-byte alignment boundary + * to the internal stack ... + */ +#pragma pack(push,4) + typedef struct particle4_t { + uint32_t state; + double posx; + double posy; + float atx[3]; + float aty[3]; + float rro[2]; + } particle4_t; +/* + * ... and restore original alignment rules from stack + */ +#pragma pack(pop) /*------------------------------------------------------------------------- @@ -350,6 +371,34 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf3[0].temperature), sizeof( rbuf3[0].lati)}; + /*------------------------------------------------------------------------- + * initialize table parameters + * size and the offsets of struct members in memory + * these are used for the delete field test with differing memory layout + *------------------------------------------------------------------------- + */ + + /* Calculate the size and the offsets of our struct members in memory */ + size_t tbl_size = sizeof(particle4_t); + size_t tbl_offset[NFIELDS+1] = { HOFFSET(particle4_t, state), + HOFFSET(particle4_t, posx), + HOFFSET(particle4_t, posy), + HOFFSET(particle4_t, atx), + HOFFSET(particle4_t, aty), + HOFFSET(particle4_t, rro) + }; + + /* Define an array of Particles */ + particle4_t p_data[NRECORDS] = { + {12112, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12113, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12114, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12115, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12116, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12117, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12118, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12119, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}} + }; /*------------------------------------------------------------------------- * initialize table parameters @@ -376,10 +425,23 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf[0].temperature), sizeof( rbuf[0].lati) }; + + const char *field_names4[NFIELDS+1] = + { "F1", "F2", "F3", "F4", "F5", "F6"}; + hid_t field_type4[NFIELDS+1]; + particle4_t fill_data[1] = { {9999999, -9999999, 999999, {999,999,999},{999,999,999}, {999,999}} }; + + hsize_t nfields_out; + hsize_t nrecords_out; + hid_t arry3_32f; + hid_t arry2_32f; + hsize_t dims; + const char *field_names[NFIELDS] = - { "Name","Longitude","Pressure","Temperature","Latitude" }; + { "Name","Longitude","Pressure","Temperature","Latitude" }; hid_t field_type[NFIELDS]; hid_t string_type = H5Tcopy( H5T_C_S1 ); + H5Tset_size( string_type, 16 ); field_type[0] = string_type; field_type[1] = H5T_NATIVE_LONG; @@ -820,6 +882,59 @@ static int test_table(hid_t fid, int do_write) PASSED(); } + /*------------------------------------------------------------------------ + * Functions tested: + * + * H5TBdelete_record -- With differing memory layout from machine memory + * layout. HDFFV-8055 + * + *------------------------------------------------------------------------- + */ + if (do_write) + { + TESTING2("deleting records (differing memory layout)"); + + dims = 3; + arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + + dims = 2; + arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + + /* Initialize the field field_type */ + field_type4[0] = H5T_NATIVE_UINT32; + field_type4[1] = H5T_NATIVE_DOUBLE; + field_type4[2] = H5T_NATIVE_DOUBLE; + field_type4[3] = arry3_32f; + field_type4[4] = arry3_32f; + field_type4[5] = arry2_32f; + + /* Make the table */ + if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS, + tbl_size, field_names4, tbl_offset, field_type4, + chunk_size, fill_data, compress, p_data)<0) + goto out; + /* Delete records */ + start = 3; + nrecords = 3; + if (H5TBdelete_record(fid, "table", start, nrecords)<0) + goto out;; + /* Get table info */ + if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0) + goto out; + /* check */ + if( (int)nfields_out != (int)NFIELDS+1) + goto out; + + if( (int)nrecords_out != (int)NRECORDS-3) + goto out; + + /* close type */ + H5Tclose(arry3_32f); + H5Tclose(arry2_32f); + + PASSED(); + } + /*------------------------------------------------------------------------- * * Functions tested: -- cgit v0.12 From 65100aa371af1ae14fedd282c928615a307a8e57 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Thu, 26 Jul 2012 22:18:03 -0500 Subject: [svn-r22611] Fixed: HDFFV-8013 H5LTget_attribute_string appears to not close an object identifier Tested: gnu and intel (jam) --- hl/src/H5LT.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 678642f..eed2721 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -3024,8 +3024,11 @@ herr_t H5LTget_attribute_string( hid_t loc_id, return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) - return -1; + if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) + { + H5Oclose(obj_id); + return -1; + } /* Close the object */ if(H5Oclose(obj_id) < 0) @@ -3458,6 +3461,8 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, return 0; out: + if(obj_id > 0) + H5Oclose(obj_id); if(attr_id > 0) H5Aclose(attr_id); return -1; -- cgit v0.12 From d4d9cbd52d86800f5874fe8d6a2e939f090c5c2d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 30 Jul 2012 14:15:31 -0500 Subject: [svn-r22614] Revert heading of summary. --- config/cmake/libhdf5.settings.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index 22b223a..4027c55 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -1,4 +1,4 @@ - SUMMARY OF THE @HDF5_PACKAGE@ CONFIGURATION + SUMMARY OF THE HDF5 CONFIGURATION ================================= General Information: -- cgit v0.12