diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2011-05-03 17:56:23 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2011-05-03 17:56:23 (GMT) |
commit | 907a5a1df061e3343d6783c354574fcbb409f73b (patch) | |
tree | 7314cd2cc9d7b64aa7c32ae00f6319fc7a4366c3 /tools/h5dump | |
parent | 344352d88e5e0359b4b727fcbe88917822dd06a3 (diff) | |
download | hdf5-907a5a1df061e3343d6783c354574fcbb409f73b.zip hdf5-907a5a1df061e3343d6783c354574fcbb409f73b.tar.gz hdf5-907a5a1df061e3343d6783c354574fcbb409f73b.tar.bz2 |
[svn-r20713] Packed Bits Merge:
removed option defines and #ifdef/#endif
refactored all printf to HDfprintf in h5dump.c
formatted and indention improvements
synched with 1.8 branch
Tested: local linux
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/CMakeLists.txt | 541 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 3790 | ||||
-rw-r--r-- | tools/h5dump/h5dump.h | 2 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 151 |
4 files changed, 2265 insertions, 2219 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index a02388a..2032057 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -399,78 +399,75 @@ IF (BUILD_TESTING) ENDIF (WIN32 AND NOT CYGWIN) # -------------------------------------------------------------------- - # Special option for Packed Bits + # Packed Bits # -------------------------------------------------------------------- - IF (HDF5_USE_H5DUMP_PACKED_BITS) - #-- Copy all the HDF5 files from the test directory into the source directory - SET (HDF5_REFERENCE_PBITS - tnofilename-with-packed-bits.ddl - tpbitsArray.ddl - tpbitsCompound.ddl - tpbitsIncomplete.ddl - tpbitsLengthExceeded.ddl - tpbitsCharLengthExceeded.ddl - tpbitsIntLengthExceeded.ddl - tpbitsLongLengthExceeded.ddl - tpbitsLengthPositive.ddl - tpbitsMax.ddl - tpbitsMaxExceeded.ddl - tpbitsOffsetExceeded.ddl - tpbitsCharOffsetExceeded.ddl - tpbitsIntOffsetExceeded.ddl - tpbitsLongOffsetExceeded.ddl - tpbitsOffsetNegative.ddl - tpbitsOverlapped.ddl - tpbitsSigned.ddl - tpbitsUnsigned.ddl - tpbitsSignedInt.ddl - tpbitsUnsignedInt.ddl - tpbitsSignedLong.ddl - tpbitsUnsignedLong.ddl - tpbitsSignedLongLong.ddl - tpbitsUnsignedLongLong.ddl - tpbitsSignedWhole.ddl - tpbitsUnsignedWhole.ddl - tpbitsSignedIntWhole.ddl - tpbitsUnsignedIntWhole.ddl - tpbitsSignedLongWhole.ddl - tpbitsUnsignedLongWhole.ddl - tpbitsSignedLongLongWhole.ddl - tpbitsUnsignedLongLongWhole.ddl - tpbitsSignedLongLongWhole1.ddl - tpbitsUnsignedLongLongWhole1.ddl - tpbitsSignedLongLongWhole63.ddl - tpbitsUnsignedLongLongWhole63.ddl - tpbitsSigned4.ddl - tpbitsUnsigned4.ddl - tpbitsSignedInt8.ddl - tpbitsUnsignedInt8.ddl - tpbitsSignedLong16.ddl - tpbitsUnsignedLong16.ddl - tpbitsSignedLongLong32.ddl - tpbitsUnsignedLongLong32.ddl - tpbitsSigned2.ddl - tpbitsUnsigned2.ddl - tpbitsSignedInt4.ddl - tpbitsUnsignedInt4.ddl - tpbitsSignedLong8.ddl - tpbitsUnsignedLong8.ddl - tpbitsSignedLongLong16.ddl - tpbitsUnsignedLongLong16.ddl - ) - - FOREACH (ddl_pbits ${HDF5_REFERENCE_PBITS}) - SET (ddldest "${PROJECT_BINARY_DIR}/${ddl_pbits}") - #MESSAGE (STATUS " Translating ${ddl_pbits}") - ADD_CUSTOM_COMMAND ( - TARGET h5dump - POST_BUILD - COMMAND ${XLATE_UTILITY} - ARGS ${HDF5_TOOLS_SRC_DIR}/testfiles/${ddl_pbits} ${ddldest} -l3 - ) - ENDFOREACH (ddl_pbits ${HDF5_REFERENCE_PBITS}) + #-- Copy all the HDF5 files from the test directory into the source directory + SET (HDF5_REFERENCE_PBITS + tnofilename-with-packed-bits.ddl + tpbitsArray.ddl + tpbitsCompound.ddl + tpbitsIncomplete.ddl + tpbitsLengthExceeded.ddl + tpbitsCharLengthExceeded.ddl + tpbitsIntLengthExceeded.ddl + tpbitsLongLengthExceeded.ddl + tpbitsLengthPositive.ddl + tpbitsMax.ddl + tpbitsMaxExceeded.ddl + tpbitsOffsetExceeded.ddl + tpbitsCharOffsetExceeded.ddl + tpbitsIntOffsetExceeded.ddl + tpbitsLongOffsetExceeded.ddl + tpbitsOffsetNegative.ddl + tpbitsOverlapped.ddl + tpbitsSigned.ddl + tpbitsUnsigned.ddl + tpbitsSignedInt.ddl + tpbitsUnsignedInt.ddl + tpbitsSignedLong.ddl + tpbitsUnsignedLong.ddl + tpbitsSignedLongLong.ddl + tpbitsUnsignedLongLong.ddl + tpbitsSignedWhole.ddl + tpbitsUnsignedWhole.ddl + tpbitsSignedIntWhole.ddl + tpbitsUnsignedIntWhole.ddl + tpbitsSignedLongWhole.ddl + tpbitsUnsignedLongWhole.ddl + tpbitsSignedLongLongWhole.ddl + tpbitsUnsignedLongLongWhole.ddl + tpbitsSignedLongLongWhole1.ddl + tpbitsUnsignedLongLongWhole1.ddl + tpbitsSignedLongLongWhole63.ddl + tpbitsUnsignedLongLongWhole63.ddl + tpbitsSigned4.ddl + tpbitsUnsigned4.ddl + tpbitsSignedInt8.ddl + tpbitsUnsignedInt8.ddl + tpbitsSignedLong16.ddl + tpbitsUnsignedLong16.ddl + tpbitsSignedLongLong32.ddl + tpbitsUnsignedLongLong32.ddl + tpbitsSigned2.ddl + tpbitsUnsigned2.ddl + tpbitsSignedInt4.ddl + tpbitsUnsignedInt4.ddl + tpbitsSignedLong8.ddl + tpbitsUnsignedLong8.ddl + tpbitsSignedLongLong16.ddl + tpbitsUnsignedLongLong16.ddl + ) - ENDIF (HDF5_USE_H5DUMP_PACKED_BITS) + FOREACH (ddl_pbits ${HDF5_REFERENCE_PBITS}) + SET (ddldest "${PROJECT_BINARY_DIR}/${ddl_pbits}") + #MESSAGE (STATUS " Translating ${ddl_pbits}") + ADD_CUSTOM_COMMAND ( + TARGET h5dump + POST_BUILD + COMMAND ${XLATE_UTILITY} + ARGS ${HDF5_TOOLS_SRC_DIR}/testfiles/${ddl_pbits} ${ddldest} -l3 + ) + ENDFOREACH (ddl_pbits ${HDF5_REFERENCE_PBITS}) ############################################################################## ############################################################################## @@ -608,11 +605,6 @@ IF (BUILD_TESTING) SET (USE_FILTER_NBIT H5_HAVE_FILTER_NBIT) SET (USE_FILTER_SCALEOFFSET H5_HAVE_FILTER_SCALEOFFSET) - # -------------------------------------------------------------------- - # Determine if H5dump packed bits feature is included - # -------------------------------------------------------------------- - SET (USE_PACKED_BITS HDF5_USE_H5DUMP_PACKED_BITS) - ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -974,14 +966,7 @@ IF (BUILD_TESTING) # test printing characters in ASCII instead of decimal ADD_H5_TEST (tchar1 0 -r tchar.h5) - # test failure handling - IF (NOT HDF5_USE_H5DUMP_PACKED_BITS) - # Missing file name - ADD_H5_TEST (tnofilename 1) - ENDIF (NOT HDF5_USE_H5DUMP_PACKED_BITS) - # rev. 2004 - # tests for super block ADD_H5_TEST (tboot1 0 -H -B -d dset tfcontents1.h5) ADD_H5_TEST (tboot2 0 -B tfcontents2.h5) @@ -1200,203 +1185,201 @@ IF (BUILD_TESTING) ADD_H5_TEST (tall-6 0 -y -o data -d /g1/g1.1/dset1.1.1 tall.h5) ####### test for dataset packed bits ###### - IF (HDF5_USE_H5DUMP_PACKED_BITS) - # Remove any output file left over from previous test run - ADD_TEST ( - NAME H5DUMP_PACKED_BITS-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tnofilename-with-packed-bits.out - tnofilename-with-packed-bits.out.err - tpbitsArray.out - tpbitsArray.out.err - tpbitsCompound.out - tpbitsCompound.out.err - tpbitsIncomplete.out - tpbitsIncomplete.out.err - tpbitsLengthExceeded.out - tpbitsLengthExceeded.out.err - tpbitsCharLengthExceeded.out - tpbitsCharLengthExceeded.out.err - tpbitsIntLengthExceeded.out - tpbitsIntLengthExceeded.out.err - tpbitsLongLengthExceeded.out - tpbitsLongLengthExceeded.out.err - tpbitsLengthPositive.out - tpbitsLengthPositive.out.err - tpbitsMax.out - tpbitsMax.out.err - tpbitsMaxExceeded.out - tpbitsMaxExceeded.out.err - tpbitsOffsetExceeded.out - tpbitsOffsetExceeded.out.err - tpbitsCharOffsetExceeded.out - tpbitsCharOffsetExceeded.out.err - tpbitsIntOffsetExceeded.out - tpbitsIntOffsetExceeded.out.err - tpbitsLongOffsetExceeded.out - tpbitsLongOffsetExceeded.out.err - tpbitsOffsetNegative.out - tpbitsOffsetNegative.out.err - tpbitsOverlapped.out - tpbitsOverlapped.out.err - tpbitsSigned.out - tpbitsSigned.out.err - tpbitsUnsigned.out - tpbitsUnsigned.out.err - tpbitsSignedInt.out - tpbitsSignedInt.out.err - tpbitsUnsignedInt.out - tpbitsUnsignedInt.out.err - tpbitsSignedLong.out - tpbitsSignedLong.out.err - tpbitsUnsignedLong.out - tpbitsUnsignedLong.out.err - tpbitsSignedLongLong.out - tpbitsSignedLongLong.out.err - tpbitsUnsignedLongLong.out - tpbitsUnsignedLongLong.out.err - tpbitsSignedWhole.out - tpbitsSignedWhole.out.err - tpbitsUnsignedWhole.out - tpbitsUnsignedWhole.out.err - tpbitsSignedIntWhole.out - tpbitsSignedIntWhole.out.err - tpbitsUnsignedIntWhole.out - tpbitsUnsignedIntWhole.out.err - tpbitsSignedLongWhole.out - tpbitsSignedLongWhole.out.err - tpbitsUnsignedLongWhole.out - tpbitsUnsignedLongWhole.out.err - tpbitsSignedLongLongWhole.out - tpbitsSignedLongLongWhole.out.err - tpbitsUnsignedLongLongWhole.out - tpbitsUnsignedLongLongWhole.out.err - tpbitsSignedLongLongWhole1.out - tpbitsSignedLongLongWhole1.out.err - tpbitsUnsignedLongLongWhole1.out - tpbitsUnsignedLongLongWhole1.out.err - tpbitsSignedLongLongWhole63.out - tpbitsSignedLongLongWhole63.out.err - tpbitsUnsignedLongLongWhole63.out - tpbitsUnsignedLongLongWhole63.out.err - tpbitsSigned4.out - tpbitsSigned4.out.err - tpbitsUnsigned4.out - tpbitsUnsigned4.out.err - tpbitsSignedInt8.out - tpbitsSignedInt8.out.err - tpbitsUnsignedInt8.out - tpbitsUnsignedInt8.out.err - tpbitsSignedLong16.out - tpbitsSignedLong16.out.err - tpbitsUnsignedLong16.out - tpbitsUnsignedLong16.out.err - tpbitsSignedLongLong32.out - tpbitsSignedLongLong32.out.err - tpbitsUnsignedLongLong32.out - tpbitsUnsignedLongLong32.out.err - tpbitsSigned2.out - tpbitsSigned2.out.err - tpbitsUnsigned2.out - tpbitsUnsigned2.out.err - tpbitsSignedInt4.out - tpbitsSignedInt4.out.err - tpbitsUnsignedInt4.out - tpbitsUnsignedInt4.out.err - tpbitsSignedLong8.out - tpbitsSignedLong8.out.err - tpbitsUnsignedLong8.out - tpbitsUnsignedLong8.out.err - tpbitsSignedLongLong16.out - tpbitsSignedLongLong16.out.err - tpbitsUnsignedLongLong16.out - tpbitsUnsignedLongLong16.out.err - ) - IF (NOT "${last_test}" STREQUAL "") - SET_TESTS_PROPERTIES (H5DUMP_PACKED_BITS-clearall-objects PROPERTIES DEPENDS ${last_test}) - ENDIF (NOT "${last_test}" STREQUAL "") - SET (last_test "H5DUMP_PACKED_BITS-clearall-objects") - - # test failure handling - # Missing file name - ADD_H5_TEST (tnofilename-with-packed-bits 1) - # Limits: - # Maximum number of packed bits is 8 (for now). - # Maximum integer size is 8*sizeof(long long). - # Maximun Offset is Maximum size - 1. - # Maximum Offset+Length is Maximum size. - # Tests: - # Normal operation on both signed and unsigned int datasets. - # Sanity check - # Their rawdata output should be the same. - ADD_H5_TEST (tpbitsSignedWhole 0 -d /DS08BITS -M 0,8 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedWhole 0 -d /DU08BITS -M 0,8 packedbits.h5) - ADD_H5_TEST (tpbitsSignedIntWhole 0 -d /DS16BITS -M 0,16 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedIntWhole 0 -d /DU16BITS -M 0,16 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLongWhole 0 -d /DS32BITS -M 0,32 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLongWhole 0 -d /DU32BITS -M 0,32 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLongLongWhole 0 -d /DS64BITS -M 0,64 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLongLongWhole 0 -d /DU64BITS -M 0,64 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLongLongWhole63 0 -d /DS64BITS -M 0,63 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLongLongWhole63 0 -d /DU64BITS -M 0,63 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLongLongWhole1 0 -d /DS64BITS -M 1,63 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLongLongWhole1 0 -d /DU64BITS -M 1,63 packedbits.h5) - # Half sections - ADD_H5_TEST (tpbitsSigned4 0 -d /DS08BITS -M 0,4,4,4 packedbits.h5) - ADD_H5_TEST (tpbitsUnsigned4 0 -d /DU08BITS -M 0,4,4,4 packedbits.h5) - ADD_H5_TEST (tpbitsSignedInt8 0 -d /DS16BITS -M 0,8,8,8 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedInt8 0 -d /DU16BITS -M 0,8,8,8 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLong16 0 -d /DS32BITS -M 0,16,16,16 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLong16 0 -d /DU32BITS -M 0,16,16,16 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLongLong32 0 -d /DS64BITS -M 0,32,32,32 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLongLong32 0 -d /DU64BITS -M 0,32,32,32 packedbits.h5) - # Quarter sections - ADD_H5_TEST (tpbitsSigned2 0 -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5) - ADD_H5_TEST (tpbitsUnsigned2 0 -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5) - ADD_H5_TEST (tpbitsSignedInt4 0 -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedInt4 0 -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLong8 0 -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLong8 0 -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLongLong16 0 -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLongLong16 0 -d /DU64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5) - # Begin and End - ADD_H5_TEST (tpbitsSigned 0 -d /DS08BITS -M 0,2,2,6 packedbits.h5) - ADD_H5_TEST (tpbitsUnsigned 0 -d /DU08BITS -M 0,2,2,6 packedbits.h5) - ADD_H5_TEST (tpbitsSignedInt 0 -d /DS16BITS -M 0,2,10,6 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedInt 0 -d /DU16BITS -M 0,2,10,6 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLong 0 -d /DS32BITS -M 0,2,26,6 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLong 0 -d /DU32BITS -M 0,2,26,6 packedbits.h5) - ADD_H5_TEST (tpbitsSignedLongLong 0 -d /DS64BITS -M 0,2,58,6 packedbits.h5) - ADD_H5_TEST (tpbitsUnsignedLongLong 0 -d /DU64BITS -M 0,2,58,6 packedbits.h5) - # Overlapped packed bits. - ADD_H5_TEST (tpbitsOverlapped 0 -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5) - # Maximum number of packed bits. - ADD_H5_TEST (tpbitsMax 0 -d /DS08BITS -M 0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5) - # Compound type. - ADD_H5_TEST (tpbitsCompound 0 -d /dset1 -M 0,1,1,1 tcompound.h5) - # Array type. - ADD_H5_TEST (tpbitsArray 0 -d /Dataset1 -M 0,1,1,1 tarray1.h5) - # Test Error handling. - # Too many packed bits requested. Max is 8 for now. - ADD_H5_TEST (tpbitsMaxExceeded 1 -d /DS08BITS -M 0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5) - # Offset too large. Max is 8*sizeof(long long. - ADD_H5_TEST (tpbitsOffsetExceeded 1 -d /DS08BITS -M 64,1 packedbits.h5) - ADD_H5_TEST (tpbitsCharOffsetExceeded 0 -d /DS08BITS -M 8,1 packedbits.h5) - ADD_H5_TEST (tpbitsIntOffsetExceeded 0 -d /DS16BITS -M 16,1 packedbits.h5) - ADD_H5_TEST (tpbitsLongOffsetExceeded 0 -d /DS32BITS -M 32,1 packedbits.h5) - # Bad offset, must not be negative. - ADD_H5_TEST (tpbitsOffsetNegative 1 -d /DS08BITS -M -1,1 packedbits.h5) - # Bad length, must not be positive. - ADD_H5_TEST (tpbitsLengthPositive 1 -d /DS08BITS -M 4,0 packedbits.h5) - # Offset+Length is too large. Max is 8*sizeof(long long). - ADD_H5_TEST (tpbitsLengthExceeded 1 -d /DS08BITS -M 37,28 packedbits.h5) - ADD_H5_TEST (tpbitsCharLengthExceeded 0 -d /DS08BITS -M 2,7 packedbits.h5) - ADD_H5_TEST (tpbitsIntLengthExceeded 0 -d /DS16BITS -M 10,7 packedbits.h5) - ADD_H5_TEST (tpbitsLongLengthExceeded 0 -d /DS32BITS -M 26,7 packedbits.h5) - # Incomplete pair of packed bits request. - ADD_H5_TEST (tpbitsIncomplete 1 -d /DS08BITS -M 0,2,2,1,0,2,2, packedbits.h5) - ENDIF (HDF5_USE_H5DUMP_PACKED_BITS) + # Remove any output file left over from previous test run + ADD_TEST ( + NAME H5DUMP_PACKED_BITS-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + tnofilename-with-packed-bits.out + tnofilename-with-packed-bits.out.err + tpbitsArray.out + tpbitsArray.out.err + tpbitsCompound.out + tpbitsCompound.out.err + tpbitsIncomplete.out + tpbitsIncomplete.out.err + tpbitsLengthExceeded.out + tpbitsLengthExceeded.out.err + tpbitsCharLengthExceeded.out + tpbitsCharLengthExceeded.out.err + tpbitsIntLengthExceeded.out + tpbitsIntLengthExceeded.out.err + tpbitsLongLengthExceeded.out + tpbitsLongLengthExceeded.out.err + tpbitsLengthPositive.out + tpbitsLengthPositive.out.err + tpbitsMax.out + tpbitsMax.out.err + tpbitsMaxExceeded.out + tpbitsMaxExceeded.out.err + tpbitsOffsetExceeded.out + tpbitsOffsetExceeded.out.err + tpbitsCharOffsetExceeded.out + tpbitsCharOffsetExceeded.out.err + tpbitsIntOffsetExceeded.out + tpbitsIntOffsetExceeded.out.err + tpbitsLongOffsetExceeded.out + tpbitsLongOffsetExceeded.out.err + tpbitsOffsetNegative.out + tpbitsOffsetNegative.out.err + tpbitsOverlapped.out + tpbitsOverlapped.out.err + tpbitsSigned.out + tpbitsSigned.out.err + tpbitsUnsigned.out + tpbitsUnsigned.out.err + tpbitsSignedInt.out + tpbitsSignedInt.out.err + tpbitsUnsignedInt.out + tpbitsUnsignedInt.out.err + tpbitsSignedLong.out + tpbitsSignedLong.out.err + tpbitsUnsignedLong.out + tpbitsUnsignedLong.out.err + tpbitsSignedLongLong.out + tpbitsSignedLongLong.out.err + tpbitsUnsignedLongLong.out + tpbitsUnsignedLongLong.out.err + tpbitsSignedWhole.out + tpbitsSignedWhole.out.err + tpbitsUnsignedWhole.out + tpbitsUnsignedWhole.out.err + tpbitsSignedIntWhole.out + tpbitsSignedIntWhole.out.err + tpbitsUnsignedIntWhole.out + tpbitsUnsignedIntWhole.out.err + tpbitsSignedLongWhole.out + tpbitsSignedLongWhole.out.err + tpbitsUnsignedLongWhole.out + tpbitsUnsignedLongWhole.out.err + tpbitsSignedLongLongWhole.out + tpbitsSignedLongLongWhole.out.err + tpbitsUnsignedLongLongWhole.out + tpbitsUnsignedLongLongWhole.out.err + tpbitsSignedLongLongWhole1.out + tpbitsSignedLongLongWhole1.out.err + tpbitsUnsignedLongLongWhole1.out + tpbitsUnsignedLongLongWhole1.out.err + tpbitsSignedLongLongWhole63.out + tpbitsSignedLongLongWhole63.out.err + tpbitsUnsignedLongLongWhole63.out + tpbitsUnsignedLongLongWhole63.out.err + tpbitsSigned4.out + tpbitsSigned4.out.err + tpbitsUnsigned4.out + tpbitsUnsigned4.out.err + tpbitsSignedInt8.out + tpbitsSignedInt8.out.err + tpbitsUnsignedInt8.out + tpbitsUnsignedInt8.out.err + tpbitsSignedLong16.out + tpbitsSignedLong16.out.err + tpbitsUnsignedLong16.out + tpbitsUnsignedLong16.out.err + tpbitsSignedLongLong32.out + tpbitsSignedLongLong32.out.err + tpbitsUnsignedLongLong32.out + tpbitsUnsignedLongLong32.out.err + tpbitsSigned2.out + tpbitsSigned2.out.err + tpbitsUnsigned2.out + tpbitsUnsigned2.out.err + tpbitsSignedInt4.out + tpbitsSignedInt4.out.err + tpbitsUnsignedInt4.out + tpbitsUnsignedInt4.out.err + tpbitsSignedLong8.out + tpbitsSignedLong8.out.err + tpbitsUnsignedLong8.out + tpbitsUnsignedLong8.out.err + tpbitsSignedLongLong16.out + tpbitsSignedLongLong16.out.err + tpbitsUnsignedLongLong16.out + tpbitsUnsignedLongLong16.out.err + ) + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5DUMP_PACKED_BITS-clearall-objects PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + SET (last_test "H5DUMP_PACKED_BITS-clearall-objects") + + # test failure handling + # Missing file name + ADD_H5_TEST (tnofilename-with-packed-bits 1) + # Limits: + # Maximum number of packed bits is 8 (for now). + # Maximum integer size is 8*sizeof(long long). + # Maximun Offset is Maximum size - 1. + # Maximum Offset+Length is Maximum size. + # Tests: + # Normal operation on both signed and unsigned int datasets. + # Sanity check + # Their rawdata output should be the same. + ADD_H5_TEST (tpbitsSignedWhole 0 -d /DS08BITS -M 0,8 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedWhole 0 -d /DU08BITS -M 0,8 packedbits.h5) + ADD_H5_TEST (tpbitsSignedIntWhole 0 -d /DS16BITS -M 0,16 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedIntWhole 0 -d /DU16BITS -M 0,16 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLongWhole 0 -d /DS32BITS -M 0,32 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLongWhole 0 -d /DU32BITS -M 0,32 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLongLongWhole 0 -d /DS64BITS -M 0,64 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLongLongWhole 0 -d /DU64BITS -M 0,64 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLongLongWhole63 0 -d /DS64BITS -M 0,63 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLongLongWhole63 0 -d /DU64BITS -M 0,63 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLongLongWhole1 0 -d /DS64BITS -M 1,63 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLongLongWhole1 0 -d /DU64BITS -M 1,63 packedbits.h5) + # Half sections + ADD_H5_TEST (tpbitsSigned4 0 -d /DS08BITS -M 0,4,4,4 packedbits.h5) + ADD_H5_TEST (tpbitsUnsigned4 0 -d /DU08BITS -M 0,4,4,4 packedbits.h5) + ADD_H5_TEST (tpbitsSignedInt8 0 -d /DS16BITS -M 0,8,8,8 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedInt8 0 -d /DU16BITS -M 0,8,8,8 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLong16 0 -d /DS32BITS -M 0,16,16,16 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLong16 0 -d /DU32BITS -M 0,16,16,16 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLongLong32 0 -d /DS64BITS -M 0,32,32,32 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLongLong32 0 -d /DU64BITS -M 0,32,32,32 packedbits.h5) + # Quarter sections + ADD_H5_TEST (tpbitsSigned2 0 -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5) + ADD_H5_TEST (tpbitsUnsigned2 0 -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5) + ADD_H5_TEST (tpbitsSignedInt4 0 -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedInt4 0 -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLong8 0 -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLong8 0 -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLongLong16 0 -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLongLong16 0 -d /DU64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5) + # Begin and End + ADD_H5_TEST (tpbitsSigned 0 -d /DS08BITS -M 0,2,2,6 packedbits.h5) + ADD_H5_TEST (tpbitsUnsigned 0 -d /DU08BITS -M 0,2,2,6 packedbits.h5) + ADD_H5_TEST (tpbitsSignedInt 0 -d /DS16BITS -M 0,2,10,6 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedInt 0 -d /DU16BITS -M 0,2,10,6 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLong 0 -d /DS32BITS -M 0,2,26,6 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLong 0 -d /DU32BITS -M 0,2,26,6 packedbits.h5) + ADD_H5_TEST (tpbitsSignedLongLong 0 -d /DS64BITS -M 0,2,58,6 packedbits.h5) + ADD_H5_TEST (tpbitsUnsignedLongLong 0 -d /DU64BITS -M 0,2,58,6 packedbits.h5) + # Overlapped packed bits. + ADD_H5_TEST (tpbitsOverlapped 0 -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5) + # Maximum number of packed bits. + ADD_H5_TEST (tpbitsMax 0 -d /DS08BITS -M 0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5) + # Compound type. + ADD_H5_TEST (tpbitsCompound 0 -d /dset1 -M 0,1,1,1 tcompound.h5) + # Array type. + ADD_H5_TEST (tpbitsArray 0 -d /Dataset1 -M 0,1,1,1 tarray1.h5) + # Test Error handling. + # Too many packed bits requested. Max is 8 for now. + ADD_H5_TEST (tpbitsMaxExceeded 1 -d /DS08BITS -M 0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5) + # Offset too large. Max is 8*sizeof(long long. + ADD_H5_TEST (tpbitsOffsetExceeded 1 -d /DS08BITS -M 64,1 packedbits.h5) + ADD_H5_TEST (tpbitsCharOffsetExceeded 0 -d /DS08BITS -M 8,1 packedbits.h5) + ADD_H5_TEST (tpbitsIntOffsetExceeded 0 -d /DS16BITS -M 16,1 packedbits.h5) + ADD_H5_TEST (tpbitsLongOffsetExceeded 0 -d /DS32BITS -M 32,1 packedbits.h5) + # Bad offset, must not be negative. + ADD_H5_TEST (tpbitsOffsetNegative 1 -d /DS08BITS -M -1,1 packedbits.h5) + # Bad length, must not be positive. + ADD_H5_TEST (tpbitsLengthPositive 1 -d /DS08BITS -M 4,0 packedbits.h5) + # Offset+Length is too large. Max is 8*sizeof(long long). + ADD_H5_TEST (tpbitsLengthExceeded 1 -d /DS08BITS -M 37,28 packedbits.h5) + ADD_H5_TEST (tpbitsCharLengthExceeded 0 -d /DS08BITS -M 2,7 packedbits.h5) + ADD_H5_TEST (tpbitsIntLengthExceeded 0 -d /DS16BITS -M 10,7 packedbits.h5) + ADD_H5_TEST (tpbitsLongLengthExceeded 0 -d /DS32BITS -M 26,7 packedbits.h5) + # Incomplete pair of packed bits request. + ADD_H5_TEST (tpbitsIncomplete 1 -d /DS08BITS -M 0,2,2,1,0,2,2, packedbits.h5) # Remove any output file left over from previous test run ADD_TEST ( diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index da6e806..05ec369 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -27,23 +27,23 @@ /* Macros for displaying objects */ #define begin_obj(obj,name,begin) \ - do { \ + do { \ if (name) \ - printf("%s \"%s\" %s\n", (obj), (name), (begin)); \ + HDfprintf(stdout, "%s \"%s\" %s\n", (obj), (name), (begin)); \ else \ - printf("%s %s\n", (obj), (begin)); \ + HDfprintf(stdout, "%s %s\n", (obj), (begin)); \ } while(0); #define end_obj(obj,end) \ - do { \ + do { \ if(HDstrlen(end)) { \ - printf("%s", end); \ + HDfprintf(stdout, "%s", end); \ if(HDstrlen(obj)) \ - printf(" "); \ + HDfprintf(stdout, " "); \ } \ if(HDstrlen(obj)) \ - printf("%s", obj); \ - printf("\n"); \ + HDfprintf(stdout, "%s", obj); \ + HDfprintf(stdout, "\n"); \ } while(0); /* 3 private values: can't be set, but can be read. @@ -72,7 +72,7 @@ static h5dump_table_list_t table_list = {0, 0, NULL}; static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; static hbool_t hit_elink = FALSE; /* whether we have traversed an external link */ static size_t prefix_len = 1024; -static char *prefix; +static char *prefix = NULL; static const char *driver = NULL; /* The driver to open the file with. */ static const h5dump_header_t *dump_header_format; static const char *fp_format = NULL; @@ -93,24 +93,20 @@ static int display_ai = TRUE; /*array index */ static int display_escape = FALSE; /*escape non printable characters */ static int display_region = FALSE; /*print region reference data */ static int enable_error_stack= FALSE; /* re-enable error stack */ -#ifdef H5_HAVE_H5DUMP_PACKED_BITS static int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/ -#endif /* sort parameters */ static H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */ static H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */ -#ifdef H5_HAVE_H5DUMP_PACKED_BITS -#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ -#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */ +#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ +#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */ /* mask list for packed bits */ static unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ /* packed bits display parameters */ static int packed_offset[PACKED_BITS_MAX]; static int packed_length[PACKED_BITS_MAX]; -#endif /** ** Added for XML ** @@ -131,9 +127,7 @@ static int indent; /*how far in to indent the line /* internal functions */ static hid_t h5_fileaccess(void); static void dump_oid(hid_t oid); -#ifdef H5_HAVE_H5DUMP_PACKED_BITS static void dump_packed_bits(unsigned int packed_index, hid_t type); -#endif static void print_enum(hid_t type); static int xml_name_to_XID(const char *, char *, int , int ); static void init_prefix(char **prfx, size_t prfx_len); @@ -406,12 +400,7 @@ struct handler_t { */ /* The following initialization makes use of C language cancatenating */ /* "xxx" "yyy" into "xxxyyy". */ -static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:RE" -#ifdef H5_HAVE_H5DUMP_PACKED_BITS -"M:" -#endif -; /* end of *s_opt initialization */ - +static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:REM:"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "hel", no_arg, 'h' }, @@ -525,9 +514,7 @@ static struct long_options l_opts[] = { { "format", require_arg, 'm' }, { "region", no_arg, 'R' }, { "enable-error-stack", no_arg, 'E' }, -#ifdef H5_HAVE_H5DUMP_PACKED_BITS { "packed-bits", require_arg, 'M' }, -#endif { NULL, 0, '\0' } }; @@ -683,16 +670,14 @@ usage(const char *prog) fprintf(stdout, " -m T, --format=T Set the floating point output format\n"); fprintf(stdout, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n"); fprintf(stdout, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n"); -#ifdef H5_HAVE_H5DUMP_PACKED_BITS fprintf(stdout, - " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n" - " format L for an integer dataset specified with\n" - " option -d. L is a list of offset,length values,\n" - " separated by commas. Offset is the beginning bit in\n" - " the data value and length is the number of bits of\n" - " the mask.\n" - ); -#endif + " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n" + " format L for an integer dataset specified with\n" + " option -d. L is a list of offset,length values,\n" + " separated by commas. Offset is the beginning bit in\n" + " the data value and length is the number of bits of\n" + " the mask.\n" + ); fprintf(stdout, " -R, --region Print dataset pointed by region references\n"); fprintf(stdout, " -x, --xml Output in XML using Schema\n"); fprintf(stdout, " -u, --use-dtd Output in XML using DTD\n"); @@ -739,7 +724,7 @@ usage(const char *prog) fprintf(stdout, "\n"); fprintf(stdout, " 1) Attribute foo of the group /bar_none in file quux.h5\n"); fprintf(stdout, "\n"); - fprintf(stdout, " h5dump -a /bar_none/foo quux.h5\n"); + fprintf(stdout, " h5dump -a /bar_none/foo quux.h5\n"); fprintf(stdout, "\n"); fprintf(stdout, " 2) Selecting a subset from dataset /foo in file quux.h5\n"); fprintf(stdout, "\n"); @@ -749,12 +734,10 @@ usage(const char *prog) fprintf(stdout, " using a little-endian type\n"); fprintf(stdout, "\n"); fprintf(stdout, " h5dump -d /dset -b LE -o out.bin quux.h5\n"); -#ifdef H5_HAVE_H5DUMP_PACKED_BITS fprintf(stdout, "\n"); fprintf(stdout, " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n"); fprintf(stdout, "\n"); fprintf(stdout, " h5dump -d /dset -M 0,1,4,3 quux.h5\n"); -#endif fprintf(stdout, "\n"); } @@ -798,7 +781,7 @@ table_list_add(hid_t oid, unsigned long file_no) return -1; } if(init_objs(oid, &info, &table_list.tables[idx].group_table, - &table_list.tables[idx].dset_table, &table_list.tables[idx].type_table) < 0) { + &table_list.tables[idx].dset_table, &table_list.tables[idx].type_table) < 0) { H5Idec_ref(oid); table_list.nused--; return -1; @@ -918,7 +901,7 @@ print_datatype(hid_t type,unsigned in_group) if (!in_group && H5Tcommitted(type) > 0) { H5O_info_t oinfo; - obj_t *obj; /* Found object */ + obj_t *obj; /* Found object */ H5Oget_info(type, &oinfo); obj = search_obj(type_table, oinfo.addr); @@ -927,152 +910,195 @@ print_datatype(hid_t type,unsigned in_group) if(!obj->recorded) HDfprintf(stdout,"\"/#%a\"", obj->objno); else - printf("\"%s\"", obj->objname); - } else { + HDfprintf(stdout, "\"%s\"", obj->objname); + } + else { error_msg("unknown committed type.\n"); h5tools_setstatus(EXIT_FAILURE); } - } else { + } + else { switch(H5Tget_class(type)) { case H5T_INTEGER: if(H5Tequal(type, H5T_STD_I8BE) == TRUE) { - printf("H5T_STD_I8BE"); - } else if(H5Tequal(type, H5T_STD_I8LE) == TRUE) { - printf("H5T_STD_I8LE"); - } else if(H5Tequal(type, H5T_STD_I16BE) == TRUE) { - printf("H5T_STD_I16BE"); - } else if(H5Tequal(type, H5T_STD_I16LE) == TRUE) { - printf("H5T_STD_I16LE"); - } else if(H5Tequal(type, H5T_STD_I32BE) == TRUE) { - printf("H5T_STD_I32BE"); - } else if(H5Tequal(type, H5T_STD_I32LE) == TRUE) { - printf("H5T_STD_I32LE"); - } else if(H5Tequal(type, H5T_STD_I64BE) == TRUE) { - printf("H5T_STD_I64BE"); - } else if(H5Tequal(type, H5T_STD_I64LE) == TRUE) { - printf("H5T_STD_I64LE"); - } else if(H5Tequal(type, H5T_STD_U8BE) == TRUE) { - printf("H5T_STD_U8BE"); - } else if(H5Tequal(type, H5T_STD_U8LE) == TRUE) { - printf("H5T_STD_U8LE"); - } else if(H5Tequal(type, H5T_STD_U16BE) == TRUE) { - printf("H5T_STD_U16BE"); - } else if(H5Tequal(type, H5T_STD_U16LE) == TRUE) { - printf("H5T_STD_U16LE"); - } else if(H5Tequal(type, H5T_STD_U32BE) == TRUE) { - printf("H5T_STD_U32BE"); - } else if(H5Tequal(type, H5T_STD_U32LE) == TRUE) { - printf("H5T_STD_U32LE"); - } else if(H5Tequal(type, H5T_STD_U64BE) == TRUE) { - printf("H5T_STD_U64BE"); - } else if(H5Tequal(type, H5T_STD_U64LE) == TRUE) { - printf("H5T_STD_U64LE"); - } else if(H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) { - printf("H5T_NATIVE_SCHAR"); - } else if(H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) { - printf("H5T_NATIVE_UCHAR"); - } else if(H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) { - printf("H5T_NATIVE_SHORT"); - } else if(H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) { - printf("H5T_NATIVE_USHORT"); - } else if(H5Tequal(type, H5T_NATIVE_INT) == TRUE) { - printf("H5T_NATIVE_INT"); - } else if(H5Tequal(type, H5T_NATIVE_UINT) == TRUE) { - printf("H5T_NATIVE_UINT"); - } else if(H5Tequal(type, H5T_NATIVE_LONG) == TRUE) { - printf("H5T_NATIVE_LONG"); - } else if(H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) { - printf("H5T_NATIVE_ULONG"); - } else if(H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) { - printf("H5T_NATIVE_LLONG"); - } else if(H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) { - printf("H5T_NATIVE_ULLONG"); - } else { - - /* byte order */ - if(H5Tget_size(type)>1) { - order = H5Tget_order(type); - if (H5T_ORDER_LE == order) { - order_s = " little-endian"; - } else if (H5T_ORDER_BE == order) { - order_s = " big-endian"; - } else if (H5T_ORDER_VAX == order) { - order_s = " mixed-endian"; - } else { - order_s = " unknown-byte-order"; - } - } else { - order_s = ""; - } - - /* sign */ - if ((sign=H5Tget_sign(type))>=0) - { - if (H5T_SGN_NONE == sign) { - sign_s = " unsigned"; - } else if (H5T_SGN_2 == sign) { - sign_s = ""; - } else { - sign_s = " unknown-sign"; - } - } else { - sign_s = " unknown-sign"; - } - - /* print size, order, and sign */ - printf("%lu-bit%s%s integer", - (unsigned long)(8*H5Tget_size(type)), order_s, sign_s); - } + HDfprintf(stdout, "H5T_STD_I8BE"); + } + else if(H5Tequal(type, H5T_STD_I8LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_I8LE"); + } + else if(H5Tequal(type, H5T_STD_I16BE) == TRUE) { + HDfprintf(stdout, "H5T_STD_I16BE"); + } + else if(H5Tequal(type, H5T_STD_I16LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_I16LE"); + } + else if(H5Tequal(type, H5T_STD_I32BE) == TRUE) { + HDfprintf(stdout, "H5T_STD_I32BE"); + } + else if(H5Tequal(type, H5T_STD_I32LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_I32LE"); + } + else if(H5Tequal(type, H5T_STD_I64BE) == TRUE) { + HDfprintf(stdout, "H5T_STD_I64BE"); + } + else if(H5Tequal(type, H5T_STD_I64LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_I64LE"); + } + else if(H5Tequal(type, H5T_STD_U8BE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U8BE"); + } + else if(H5Tequal(type, H5T_STD_U8LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U8LE"); + } + else if(H5Tequal(type, H5T_STD_U16BE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U16BE"); + } + else if(H5Tequal(type, H5T_STD_U16LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U16LE"); + } + else if(H5Tequal(type, H5T_STD_U32BE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U32BE"); + } + else if(H5Tequal(type, H5T_STD_U32LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U32LE"); + } + else if(H5Tequal(type, H5T_STD_U64BE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U64BE"); + } + else if(H5Tequal(type, H5T_STD_U64LE) == TRUE) { + HDfprintf(stdout, "H5T_STD_U64LE"); + } + else if(H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_SCHAR"); + } + else if(H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_UCHAR"); + } + else if(H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_SHORT"); + } + else if(H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_USHORT"); + } + else if(H5Tequal(type, H5T_NATIVE_INT) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_INT"); + } + else if(H5Tequal(type, H5T_NATIVE_UINT) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_UINT"); + } + else if(H5Tequal(type, H5T_NATIVE_LONG) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_LONG"); + } + else if(H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_ULONG"); + } + else if(H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_LLONG"); + } + else if(H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_ULLONG"); + } + else { + + /* byte order */ + if(H5Tget_size(type) > 1) { + order = H5Tget_order(type); + if (H5T_ORDER_LE == order) { + order_s = " little-endian"; + } + else if (H5T_ORDER_BE == order) { + order_s = " big-endian"; + } + else if (H5T_ORDER_VAX == order) { + order_s = " mixed-endian"; + } + else { + order_s = " unknown-byte-order"; + } + } + else { + order_s = ""; + } /* end of if(H5Tget_size(type) > 1) */ + + /* sign */ + if ((sign = H5Tget_sign(type)) >= 0) { + if (H5T_SGN_NONE == sign) { + sign_s = " unsigned"; + } + else if (H5T_SGN_2 == sign) { + sign_s = ""; + } + else { + sign_s = " unknown-sign"; + } + } + else { + sign_s = " unknown-sign"; + } /* end of if ((sign = H5Tget_sign(type)) >= 0) */ + + /* print size, order, and sign */ + HDfprintf(stdout, "%lu-bit%s%s integer", (unsigned long)(8*H5Tget_size(type)), order_s, sign_s); + } /* end of if(H5Tequal(...) */ break; case H5T_FLOAT: if(H5Tequal(type, H5T_IEEE_F32BE) == TRUE) { - printf("H5T_IEEE_F32BE"); - } else if(H5Tequal(type, H5T_IEEE_F32LE) == TRUE) { - printf("H5T_IEEE_F32LE"); - } else if(H5Tequal(type, H5T_IEEE_F64BE) == TRUE) { - printf("H5T_IEEE_F64BE"); - } else if(H5Tequal(type, H5T_IEEE_F64LE) == TRUE) { - printf("H5T_IEEE_F64LE"); - } else if(H5Tequal(type, H5T_VAX_F32) == TRUE) { - printf("H5T_VAX_F32"); - } else if(H5Tequal(type, H5T_VAX_F64) == TRUE) { - printf("H5T_VAX_F64"); - } else if(H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) { - printf("H5T_NATIVE_FLOAT"); - } else if(H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) { - printf("H5T_NATIVE_DOUBLE"); + HDfprintf(stdout, "H5T_IEEE_F32BE"); + } + else if(H5Tequal(type, H5T_IEEE_F32LE) == TRUE) { + HDfprintf(stdout, "H5T_IEEE_F32LE"); + } + else if(H5Tequal(type, H5T_IEEE_F64BE) == TRUE) { + HDfprintf(stdout, "H5T_IEEE_F64BE"); + } + else if(H5Tequal(type, H5T_IEEE_F64LE) == TRUE) { + HDfprintf(stdout, "H5T_IEEE_F64LE"); + } + else if(H5Tequal(type, H5T_VAX_F32) == TRUE) { + HDfprintf(stdout, "H5T_VAX_F32"); + } + else if(H5Tequal(type, H5T_VAX_F64) == TRUE) { + HDfprintf(stdout, "H5T_VAX_F64"); + } + else if(H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_FLOAT"); + } + else if(H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_DOUBLE"); #if H5_SIZEOF_LONG_DOUBLE !=0 - } else if(H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) { - printf("H5T_NATIVE_LDOUBLE"); + } + else if(H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) { + HDfprintf(stdout, "H5T_NATIVE_LDOUBLE"); #endif - } else { - - /* byte order */ - if(H5Tget_size(type)>1) { - order = H5Tget_order(type); - if (H5T_ORDER_LE == order) { - order_s = " little-endian"; - } else if (H5T_ORDER_BE == order) { - order_s = " big-endian"; - } else if (H5T_ORDER_VAX == order) { - order_s = " mixed-endian"; - } else { - order_s = " unknown-byte-order"; - } - } else { - order_s = ""; - } - - /* print size and byte order */ - printf("%lu-bit%s floating-point", - (unsigned long)(8*H5Tget_size(type)), order_s); + } + else { + /* byte order */ + if(H5Tget_size(type) > 1) { + order = H5Tget_order(type); + if (H5T_ORDER_LE == order) { + order_s = " little-endian"; + } + else if (H5T_ORDER_BE == order) { + order_s = " big-endian"; + } + else if (H5T_ORDER_VAX == order) { + order_s = " mixed-endian"; + } + else { + order_s = " unknown-byte-order"; + } + } + else { + order_s = ""; + } /* end of if(H5Tget_size(type) > 1) */ - } + /* print size and byte order */ + HDfprintf(stdout, "%lu-bit%s floating-point", (unsigned long)(8*H5Tget_size(type)), order_s); + } /* end of if(H5Tequal(...) */ break; case H5T_TIME: - printf("H5T_TIME: not yet implemented"); + HDfprintf(stdout, "H5T_TIME: not yet implemented"); break; case H5T_STRING: @@ -1085,33 +1111,33 @@ print_datatype(hid_t type,unsigned in_group) cset = H5Tget_cset(tmp_type); is_vlstr = H5Tis_variable_str(tmp_type); - printf("H5T_STRING %s\n", dump_header_format->strblockbegin); + HDfprintf(stdout, "H5T_STRING %s\n", dump_header_format->strblockbegin); indent += COL; indentation(indent + COL); if(is_vlstr) - printf("%s H5T_VARIABLE;\n", STRSIZE); + HDfprintf(stdout, "%s H5T_VARIABLE;\n", STRSIZE); else - printf("%s %d;\n", STRSIZE, (int) size); + HDfprintf(stdout, "%s %d;\n", STRSIZE, (int) size); indentation(indent + COL); - printf("%s ", STRPAD); + HDfprintf(stdout, "%s ", STRPAD); if (str_pad == H5T_STR_NULLTERM) - printf("H5T_STR_NULLTERM;\n"); + HDfprintf(stdout, "H5T_STR_NULLTERM;\n"); else if (str_pad == H5T_STR_NULLPAD) - printf("H5T_STR_NULLPAD;\n"); + HDfprintf(stdout, "H5T_STR_NULLPAD;\n"); else if (str_pad == H5T_STR_SPACEPAD) - printf("H5T_STR_SPACEPAD;\n"); + HDfprintf(stdout, "H5T_STR_SPACEPAD;\n"); else - printf("H5T_STR_ERROR;\n"); + HDfprintf(stdout, "H5T_STR_ERROR;\n"); indentation(indent + COL); - printf("%s ", CSET); + HDfprintf(stdout, "%s ", CSET); if (cset == H5T_CSET_ASCII) - printf("H5T_CSET_ASCII;\n"); + HDfprintf(stdout, "H5T_CSET_ASCII;\n"); else - printf("unknown_cset;\n"); + HDfprintf(stdout, "unknown_cset;\n"); str_type = H5Tcopy(H5T_C_S1); if(is_vlstr) @@ -1122,23 +1148,23 @@ print_datatype(hid_t type,unsigned in_group) H5Tset_strpad(str_type, str_pad); indentation(indent + COL); - printf("%s ", CTYPE); + HDfprintf(stdout, "%s ", CTYPE); /* Check C variable-length string first. Are the two types equal? */ if (H5Tequal(tmp_type, str_type)) { - printf("H5T_C_S1;\n"); + HDfprintf(stdout, "H5T_C_S1;\n"); goto done; } /* Change the endianness and see if they're equal. */ order = H5Tget_order(tmp_type); - if(order==H5T_ORDER_LE) + if(order == H5T_ORDER_LE) H5Tset_order(str_type, H5T_ORDER_LE); - else if(order==H5T_ORDER_BE) + else if(order == H5T_ORDER_BE) H5Tset_order(str_type, H5T_ORDER_BE); if (H5Tequal(tmp_type, str_type)) { - printf("H5T_C_S1;\n"); + HDfprintf(stdout, "H5T_C_S1;\n"); goto done; } @@ -1151,24 +1177,24 @@ print_datatype(hid_t type,unsigned in_group) /* Are the two types equal? */ if (H5Tequal(tmp_type, str_type)) { - printf("H5T_FORTRAN_S1;\n"); + HDfprintf(stdout, "H5T_FORTRAN_S1;\n"); goto done; } /* Change the endianness and see if they're equal. */ order = H5Tget_order(tmp_type); - if(order==H5T_ORDER_LE) + if(order == H5T_ORDER_LE) H5Tset_order(str_type, H5T_ORDER_LE); - else if(order==H5T_ORDER_BE) + else if(order == H5T_ORDER_BE) H5Tset_order(str_type, H5T_ORDER_BE); if (H5Tequal(tmp_type, str_type)) { - printf("H5T_FORTRAN_S1;\n"); + HDfprintf(stdout, "H5T_FORTRAN_S1;\n"); goto done; } /* Type doesn't match any of above. */ - printf("unknown_one_character_type;\n "); + HDfprintf(stdout, "unknown_one_character_type;\n "); h5tools_setstatus(EXIT_FAILURE); done: @@ -1177,46 +1203,54 @@ print_datatype(hid_t type,unsigned in_group) indent -= COL; indentation(indent + COL); - printf("%s", dump_header_format->strblockend); + HDfprintf(stdout, "%s", dump_header_format->strblockend); break; case H5T_BITFIELD: if (H5Tequal(type, H5T_STD_B8BE)==TRUE) { - printf("H5T_STD_B8BE"); - } else if (H5Tequal(type, H5T_STD_B8LE)==TRUE) { - printf("H5T_STD_B8LE"); - } else if (H5Tequal(type, H5T_STD_B16BE)==TRUE) { - printf("H5T_STD_B16BE"); - } else if (H5Tequal(type, H5T_STD_B16LE)==TRUE) { - printf("H5T_STD_B16LE"); - } else if (H5Tequal(type, H5T_STD_B32BE)==TRUE) { - printf("H5T_STD_B32BE"); - } else if (H5Tequal(type, H5T_STD_B32LE)==TRUE) { - printf("H5T_STD_B32LE"); - } else if (H5Tequal(type, H5T_STD_B64BE)==TRUE) { - printf("H5T_STD_B64BE"); - } else if (H5Tequal(type, H5T_STD_B64LE)==TRUE) { - printf("H5T_STD_B64LE"); - } else { - printf("undefined bitfield"); + HDfprintf(stdout, "H5T_STD_B8BE"); + } + else if (H5Tequal(type, H5T_STD_B8LE)==TRUE) { + HDfprintf(stdout, "H5T_STD_B8LE"); + } + else if (H5Tequal(type, H5T_STD_B16BE)==TRUE) { + HDfprintf(stdout, "H5T_STD_B16BE"); + } + else if (H5Tequal(type, H5T_STD_B16LE)==TRUE) { + HDfprintf(stdout, "H5T_STD_B16LE"); + } + else if (H5Tequal(type, H5T_STD_B32BE)==TRUE) { + HDfprintf(stdout, "H5T_STD_B32BE"); + } + else if (H5Tequal(type, H5T_STD_B32LE)==TRUE) { + HDfprintf(stdout, "H5T_STD_B32LE"); + } + else if (H5Tequal(type, H5T_STD_B64BE)==TRUE) { + HDfprintf(stdout, "H5T_STD_B64BE"); + } + else if (H5Tequal(type, H5T_STD_B64LE)==TRUE) { + HDfprintf(stdout, "H5T_STD_B64LE"); + } + else { + HDfprintf(stdout, "undefined bitfield"); h5tools_setstatus(EXIT_FAILURE); - } + } /* end of if(H5Tequal(...) */ break; case H5T_OPAQUE: - printf("\n"); + HDfprintf(stdout, "\n"); indentation(indent + COL); - printf("H5T_OPAQUE;\n"); + HDfprintf(stdout, "H5T_OPAQUE;\n"); indentation(indent + COL); mname = H5Tget_tag(type); - printf("OPAQUE_TAG \"%s\";\n", mname); + HDfprintf(stdout, "OPAQUE_TAG \"%s\";\n", mname); free(mname); indentation(indent); break; case H5T_COMPOUND: nmembers = H5Tget_nmembers(type); - printf("H5T_COMPOUND %s\n", dump_header_format->structblockbegin); + HDfprintf(stdout, "H5T_COMPOUND %s\n", dump_header_format->structblockbegin); for (i = 0; i < nmembers; i++) { mname = H5Tget_member_name(type, i); @@ -1231,47 +1265,47 @@ print_datatype(hid_t type,unsigned in_group) if (H5Tget_class(mtype) == H5T_COMPOUND) indent -= COL; - printf(" \"%s\";\n", mname); + HDfprintf(stdout, " \"%s\";\n", mname); free(mname); - } + } /* end of for (i = 0; i < nmembers; i++) */ indentation(indent); - printf("%s", dump_header_format->structblockend); + HDfprintf(stdout, "%s", dump_header_format->structblockend); break; case H5T_REFERENCE: - printf("H5T_REFERENCE"); + HDfprintf(stdout, "H5T_REFERENCE"); /* The BNF document states that the type of reference should be * displayed after "H5T_REFERENCE". */ if (H5Tequal(type, H5T_STD_REF_DSETREG)==TRUE) { - printf(" { H5T_STD_REF_DSETREG }"); + HDfprintf(stdout, " { H5T_STD_REF_DSETREG }"); } else { - printf(" { H5T_STD_REF_OBJECT }"); + HDfprintf(stdout, " { H5T_STD_REF_OBJECT }"); } break; case H5T_ENUM: - printf("H5T_ENUM %s\n", dump_header_format->enumblockbegin); + HDfprintf(stdout, "H5T_ENUM %s\n", dump_header_format->enumblockbegin); indent += COL; indentation(indent + COL); super = H5Tget_super(type); print_datatype(super,0); - printf(";\n"); + HDfprintf(stdout, ";\n"); print_enum(type); indent -= COL; indentation(indent + COL); - printf("%s", dump_header_format->enumblockend); + HDfprintf(stdout, "%s", dump_header_format->enumblockend); break; case H5T_VLEN: - printf("H5T_VLEN %s ", dump_header_format->vlenblockbegin); + HDfprintf(stdout, "H5T_VLEN %s ", dump_header_format->vlenblockbegin); super = H5Tget_super(type); print_datatype(super,0); H5Tclose(super); /* Print closing */ - printf("%s", dump_header_format->vlenblockend); + HDfprintf(stdout, "%s", dump_header_format->vlenblockend); break; case H5T_ARRAY: @@ -1279,7 +1313,7 @@ print_datatype(hid_t type,unsigned in_group) super = H5Tget_super(type); /* Print lead-in */ - printf("H5T_ARRAY { "); + HDfprintf(stdout, "H5T_ARRAY { "); /* Get array information */ ndims = H5Tget_array_ndims(type); @@ -1287,9 +1321,9 @@ print_datatype(hid_t type,unsigned in_group) /* Print array dimensions */ for (i = 0; i < ndims; i++) - printf("[%d]", (int) dims[i]); + HDfprintf(stdout, "[%d]", (int) dims[i]); - printf(" "); + HDfprintf(stdout, " "); /* Print base type */ print_datatype(super,0); @@ -1298,12 +1332,12 @@ print_datatype(hid_t type,unsigned in_group) H5Tclose(super); /* Print closing */ - printf(" }"); + HDfprintf(stdout, " }"); break; default: - printf("unknown datatype"); + HDfprintf(stdout, "unknown datatype"); h5tools_setstatus(EXIT_FAILURE); break; } @@ -1331,13 +1365,11 @@ dump_datatype(hid_t type) indent += COL; indentation(indent); - printf("%s %s ", dump_header_format->datatypebegin, - dump_header_format->datatypeblockbegin); + HDfprintf(stdout, "%s %s ", dump_header_format->datatypebegin, dump_header_format->datatypeblockbegin); print_datatype(type,0); - end_obj(dump_header_format->datatypeend, - dump_header_format->datatypeblockend); + end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend); indent -= COL; } @@ -1358,40 +1390,37 @@ dump_datatype(hid_t type) static void dump_dataspace(hid_t space) { - hsize_t size[H5DUMP_MAX_RANK]; - hsize_t maxsize[H5DUMP_MAX_RANK]; - int ndims = H5Sget_simple_extent_dims(space, size, maxsize); + hsize_t size[H5DUMP_MAX_RANK]; + hsize_t maxsize[H5DUMP_MAX_RANK]; + int i; + + int ndims = H5Sget_simple_extent_dims(space, size, maxsize); H5S_class_t space_type = H5Sget_simple_extent_type(space); - int i; indentation(indent + COL); - printf("%s ", dump_header_format->dataspacebegin); + HDfprintf(stdout, "%s ", dump_header_format->dataspacebegin); switch(space_type) { case H5S_SCALAR: /* scalar dataspace */ - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedescriptionbegin, S_SCALAR); + HDfprintf(stdout, "%s %s", dump_header_format->dataspacedescriptionbegin, S_SCALAR); break; case H5S_SIMPLE: /* simple dataspace */ - HDfprintf(stdout, "%s %s { %s %Hu", - dump_header_format->dataspacedescriptionbegin, S_SIMPLE, - dump_header_format->dataspacedimbegin, size[0]); + HDfprintf(stdout, "%s %s { %s %Hu", + dump_header_format->dataspacedescriptionbegin, S_SIMPLE, + dump_header_format->dataspacedimbegin, size[0]); for(i = 1; i < ndims; i++) HDfprintf(stdout, ", %Hu", size[i]); - printf(" %s / ", dump_header_format->dataspacedimend); + HDfprintf(stdout, " %s / ", dump_header_format->dataspacedimend); if(maxsize[0] == H5S_UNLIMITED) - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedimbegin, - "H5S_UNLIMITED"); + HDfprintf(stdout, "%s %s", dump_header_format->dataspacedimbegin, "H5S_UNLIMITED"); else - HDfprintf(stdout, "%s %Hu", - dump_header_format->dataspacedimbegin, maxsize[0]); + HDfprintf(stdout, "%s %Hu", dump_header_format->dataspacedimbegin, maxsize[0]); for(i = 1; i < ndims; i++) if(maxsize[i] == H5S_UNLIMITED) @@ -1399,23 +1428,21 @@ dump_dataspace(hid_t space) else HDfprintf(stdout, ", %Hu", maxsize[i]); - printf(" %s }", dump_header_format->dataspacedimend); + HDfprintf(stdout, " %s }", dump_header_format->dataspacedimend); break; case H5S_NULL: /* null dataspace */ - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedescriptionbegin, S_NULL); + HDfprintf(stdout, "%s %s", dump_header_format->dataspacedescriptionbegin, S_NULL); break; case H5S_NO_CLASS: default: - printf("%s unknown dataspace %s\n", BEGIN, END); + HDfprintf(stdout, "%s unknown dataspace %s\n", BEGIN, END); break; } /* end switch */ - end_obj(dump_header_format->dataspaceend, - dump_header_format->dataspaceblockend); + end_obj(dump_header_format->dataspaceend, dump_header_format->dataspaceblockend); } @@ -1442,18 +1469,17 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, vo herr_t ret = SUCCEED; indentation(indent); - begin_obj(dump_header_format->attributebegin, attr_name, - dump_header_format->attributeblockbegin); + begin_obj(dump_header_format->attributebegin, attr_name, dump_header_format->attributeblockbegin); if((attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT)) < 0) { indentation(indent + COL); error_msg("unable to open attribute \"%s\"\n", attr_name); indentation(indent); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); + end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } else { + } + else { hid_t type, space; type = H5Aget_type(attr_id); @@ -1553,7 +1579,8 @@ dump_selected_attr(hid_t loc_id, const char *name) H5Aclose(attr_id); end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - } else { + } + else { indentation(COL); error_msg("unable to open attribute \"%s\"\n", obj_name); end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); @@ -1605,8 +1632,8 @@ static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED *op_data) { hid_t obj; - char *obj_path = NULL; /* Full path of object */ herr_t ret = SUCCEED; + char *obj_path = NULL; /* Full path of object */ /* Build the object's path name */ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); @@ -1648,7 +1675,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED add_prefix(&prefix, &prefix_len, name); /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); + dump_function_table->dump_group_function(obj, name); /* Restore old prefix name */ HDstrcpy(prefix, old_prefix); @@ -1668,14 +1695,11 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED if(found_obj == NULL) { indentation(indent); - begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); + begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin); indentation(indent + COL); - error_msg("internal error (file %s:line %d)\n", - __FILE__, __LINE__); + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); + end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; H5Dclose(obj); @@ -1685,13 +1709,11 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED indentation(indent); if(!doxml) { - begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); + begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin); indentation(indent + COL); - printf("%s \"%s\"\n", HARDLINK, found_obj->objname); + HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname); indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); + end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); } else { /* the XML version */ @@ -1699,15 +1721,15 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); char *t_name = xml_escape_the_name(name); char *t_objname = xml_escape_the_name(found_obj->objname); - char dsetxid[100]; - char parentxid[100]; - char pointerxid[100]; + char dsetxid[100]; + char parentxid[100]; + char pointerxid[100]; /* Create OBJ-XIDs for the parent and object */ xml_name_to_XID(obj_path, dsetxid, sizeof(dsetxid), 1); xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1); - printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " + HDfprintf(stdout, "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " "H5Path=\"%s\" Parents=\"%s\" " "H5ParentPaths=\"%s\">\n", xmlnsprefix, @@ -1719,11 +1741,11 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED indentation(indent + COL); xml_name_to_XID(found_obj->objname, pointerxid, sizeof(pointerxid), 1); - printf("<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", + HDfprintf(stdout, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", xmlnsprefix, pointerxid,t_objname); indentation(indent); - printf("</%sDataset>\n", xmlnsprefix); + HDfprintf(stdout, "</%sDataset>\n", xmlnsprefix); HDfree(t_name); HDfree(t_obj_path); @@ -1777,8 +1799,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED HDassert(targbuf); if(!doxml) { - begin_obj(dump_header_format->softlinkbegin, name, - dump_header_format->softlinkblockbegin); + begin_obj(dump_header_format->softlinkbegin, name, dump_header_format->softlinkblockbegin); indentation(indent + COL); } @@ -1791,7 +1812,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED /* print the value of a soft link */ if (!doxml) { /* Standard DDL: no modification */ - printf("LINKTARGET \"%s\"\n", targbuf); + HDfprintf(stdout, "LINKTARGET \"%s\"\n", targbuf); } else { /* XML */ @@ -1803,7 +1824,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED char *t_targbuf = xml_escape_the_name(targbuf); char *t_obj_path = xml_escape_the_name(obj_path); char *t_link_path; - int res; + int res; t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1); if(targbuf[0] == '/') @@ -1821,7 +1842,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED res = xml_name_to_XID(t_link_path, targetxid, sizeof(targetxid), 0); if (res == 0) { /* target obj found */ - printf("<%sSoftLink LinkName=\"%s\" " + HDfprintf(stdout, "<%sSoftLink LinkName=\"%s\" " "OBJ-XID=\"%s\" " "H5SourcePath=\"%s\" " "TargetPath=\"%s\" TargetObj=\"%s\" " @@ -1837,7 +1858,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED } else { /* dangling link -- omit from xml attributes */ - printf("<%sSoftLink LinkName=\"%s\" " + HDfprintf(stdout, "<%sSoftLink LinkName=\"%s\" " "OBJ-XID=\"%s\" " "H5SourcePath=\"%s\" " "TargetPath=\"%s\" " @@ -1861,8 +1882,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED if (!doxml) { indentation(indent); - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); + end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend); } HDfree(targbuf); @@ -1893,14 +1913,12 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED else { if(!doxml) { indentation(indent + COL); - printf("TARGETFILE \"%s\"\n", filename); + HDfprintf(stdout, "TARGETFILE \"%s\"\n", filename); indentation(indent + COL); - printf("TARGETPATH \"%s\"\n", targname); + HDfprintf(stdout, "TARGETPATH \"%s\"\n", targname); /* dump the external link */ dump_extlink(group, name, targname); - - } /* end if */ /* XML */ else { @@ -1916,20 +1934,20 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1); xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1); - printf("<%sExternalLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetFilename=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - filename, /* TargetFilename */ - targname, /* TargetPath*/ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ + HDfprintf(stdout, "<%sExternalLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetFilename=\"%s\" " + "TargetPath=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + filename, /* TargetFilename */ + targname, /* TargetPath*/ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ HDfree(t_prefix); HDfree(t_name); HDfree(t_filename); @@ -1950,7 +1968,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED if(!doxml) { begin_obj(dump_header_format->udlinkbegin, name, dump_header_format->udlinkblockbegin); indentation(indent + COL); - printf("LINKCLASS %d\n", linfo->type); + HDfprintf(stdout, "LINKCLASS %d\n", linfo->type); indentation(indent); end_obj(dump_header_format->udlinkend, dump_header_format->udlinkblockend); } /* end if */ @@ -1966,18 +1984,18 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1); xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1); - printf("<%sUserDefined LinkName=\"%s\" " + HDfprintf(stdout, "<%sUserDefined LinkName=\"%s\" " "OBJ-XID=\"%s\" " "H5SourcePath=\"%s\" " "LinkClass=\"%d\" " "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - linfo->type, /* LinkClass */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + linfo->type, /* LinkClass */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ HDfree(t_prefix); HDfree(t_name); HDfree(t_obj_path); @@ -2013,19 +2031,17 @@ static void dump_named_datatype(hid_t tid, const char *name) { H5O_info_t oinfo; - unsigned attr_crt_order_flags; - hid_t tcpl_id; /* datatype creation property list ID */ + unsigned attr_crt_order_flags; + hid_t tcpl_id; /* datatype creation property list ID */ - if ((tcpl_id = H5Tget_create_plist(tid)) < 0) - { + if ((tcpl_id = H5Tget_create_plist(tid)) < 0) { error_msg("error in getting creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } /* query the creation properties for attributes */ - if (H5Pget_attr_creation_order(tcpl_id, &attr_crt_order_flags) < 0) - { + if (H5Pget_attr_creation_order(tcpl_id, &attr_crt_order_flags) < 0) { error_msg("error in getting creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -2037,7 +2053,7 @@ dump_named_datatype(hid_t tid, const char *name) indentation(indent); - printf("%s \"%s\" %s", dump_header_format->datatypebegin, name, + HDfprintf(stdout, "%s \"%s\" %s", dump_header_format->datatypebegin, name, dump_header_format->datatypeblockbegin); H5Oget_info(tid, &oinfo); @@ -2051,13 +2067,12 @@ dump_named_datatype(hid_t tid, const char *name) found_obj = search_obj(type_table, oinfo.addr); if (found_obj == NULL) { - error_msg("internal error (file %s:line %d)\n", - __FILE__, __LINE__); + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; } else if (found_obj->displayed) { - printf("%s \"%s\"\n", HARDLINK, found_obj->objname); + HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname); goto done; } else @@ -2066,7 +2081,7 @@ dump_named_datatype(hid_t tid, const char *name) print_datatype(tid, 1); if(H5Tget_class(tid) != H5T_COMPOUND) - printf(";\n"); + HDfprintf(stdout, ";\n"); /* print attributes */ indent += COL; @@ -2074,7 +2089,7 @@ dump_named_datatype(hid_t tid, const char *name) /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the datatype's create property list for attributes, then, sort by creation order, otherwise by name */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { if(H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); @@ -2090,8 +2105,7 @@ dump_named_datatype(hid_t tid, const char *name) indent -= COL; done: - end_obj(dump_header_format->datatypeend, - dump_header_format->datatypeblockend); + end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend); } /*------------------------------------------------------------------------- @@ -2116,29 +2130,27 @@ static void dump_group(hid_t gid, const char *name) { H5O_info_t oinfo; - hid_t dset, type; - char type_name[1024], *tmp; + hid_t dset; + hid_t type; + hid_t gcpl_id; unsigned crt_order_flags; unsigned attr_crt_order_flags; - hid_t gcpl_id; - + char type_name[1024]; + char *tmp = NULL; - if ((gcpl_id = H5Gget_create_plist(gid)) < 0) - { + if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { error_msg("error in getting group creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } /* query the group creation properties for attributes */ - if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0) - { + if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0) { error_msg("error in getting group creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) - { + if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { error_msg("error in getting group creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -2148,7 +2160,6 @@ dump_group(hid_t gid, const char *name) h5tools_setstatus(EXIT_FAILURE); } - tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); indentation(indent); @@ -2161,7 +2172,7 @@ dump_group(hid_t gid, const char *name) dump_comment(gid); if(!HDstrcmp(name, "/") && unamedtype) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* dump unamed type in root group */ for(u = 0; u < type_table->nobjs; u++) @@ -2192,7 +2203,7 @@ dump_group(hid_t gid, const char *name) } else if (found_obj->displayed) { indentation(indent); - printf("%s \"%s\"\n", HARDLINK, found_obj->objname); + HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname); } else { found_obj->displayed = TRUE; @@ -2219,14 +2230,10 @@ dump_group(hid_t gid, const char *name) H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL); else H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL); - } } - - else - { - + else { /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group for attributes, then, sort by creation order, otherwise by name */ @@ -2250,8 +2257,6 @@ dump_group(hid_t gid, const char *name) H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL); else H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL); - - } indent -= COL; @@ -2283,22 +2288,19 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) unsigned attr_crt_order_flags; hid_t dcpl_id; /* dataset creation property list ID */ - if ((dcpl_id = H5Dget_create_plist(did)) < 0) - { + if ((dcpl_id = H5Dget_create_plist(did)) < 0) { error_msg("error in getting creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } /* query the creation properties for attributes */ - if (H5Pget_attr_creation_order(dcpl_id, &attr_crt_order_flags) < 0) - { + if (H5Pget_attr_creation_order(dcpl_id, &attr_crt_order_flags) < 0) { error_msg("error in getting creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } indentation(indent); - begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); + begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin); type = H5Dget_type(did); space = H5Dget_space(did); @@ -2314,22 +2316,20 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) dump_dcpl(dcpl_id, type, did); if(display_data) { -#ifdef H5_HAVE_H5DUMP_PACKED_BITS - int data_loop = 1; - int i; + int data_loop = 1; + int i; if(display_packed_bits) data_loop = packed_bits_num; - for(i=0;i<data_loop;i++) { + for(i=0; i<data_loop; i++) { if(display_packed_bits) { dump_packed_bits(i, type); packed_data_mask = packed_mask[i]; packed_data_offset = packed_offset[i]; } -#endif - switch(H5Tget_class(type)) { + switch(H5Tget_class(type)) { case H5T_TIME: indentation(indent + COL); - printf("DATA{ not yet implemented.}\n"); + HDfprintf(stdout, "DATA{ not yet implemented.}\n"); break; case H5T_INTEGER: @@ -2347,21 +2347,17 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) default: break; - } /* end switch */ -#ifdef H5_HAVE_H5DUMP_PACKED_BITS + } /* end switch */ } /* for(i=0;i<data_loop;i++) */ -#endif } indent += COL; - if ( !bin_output ) - { - + if (!bin_output) { /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group for attributes, then, sort by creation order, otherwise by name */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); @@ -2382,7 +2378,6 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) H5Sclose(space); H5Pclose(dcpl_id); - indentation(indent); end_obj(dump_header_format->datasetend,dump_header_format->datasetblockend); } @@ -2409,8 +2404,7 @@ dump_dims(hsize_t *s, int dims) for (i = 0; i < dims; i++) { printf(HSIZE_T_FORMAT, s[i]); - if (i + 1 != dims) - printf(", "); + if (i + 1 != dims) HDfprintf(stdout, ", "); } } @@ -2432,47 +2426,38 @@ static void dump_subsetting_header(struct subset_t *sset, int dims) { indentation(indent); - printf("%s %s\n", dump_header_format->subsettingbegin, - dump_header_format->subsettingblockbegin); + HDfprintf(stdout, "%s %s\n", dump_header_format->subsettingbegin, dump_header_format->subsettingblockbegin); indent += COL; indentation(indent); - printf("%s %s ", dump_header_format->startbegin, - dump_header_format->startblockbegin); + HDfprintf(stdout, "%s %s ", dump_header_format->startbegin, dump_header_format->startblockbegin); dump_dims(sset->start.data, dims); - printf("%s %s\n", dump_header_format->startend, - dump_header_format->startblockend); + HDfprintf(stdout, "%s %s\n", dump_header_format->startend, dump_header_format->startblockend); indentation(indent); - printf("%s %s ", dump_header_format->stridebegin, - dump_header_format->strideblockbegin); + HDfprintf(stdout, "%s %s ", dump_header_format->stridebegin, dump_header_format->strideblockbegin); dump_dims(sset->stride.data, dims); - printf("%s %s\n", dump_header_format->strideend, - dump_header_format->strideblockend); + HDfprintf(stdout, "%s %s\n", dump_header_format->strideend, dump_header_format->strideblockend); indentation(indent); - printf("%s %s ", dump_header_format->countbegin, - dump_header_format->countblockbegin); + HDfprintf(stdout, "%s %s ", dump_header_format->countbegin, dump_header_format->countblockbegin); if(sset->count.data) dump_dims(sset->count.data, dims); else - printf("DEFAULT"); + HDfprintf(stdout, "DEFAULT"); - printf("%s %s\n", dump_header_format->countend, - dump_header_format->countblockend); + HDfprintf(stdout, "%s %s\n", dump_header_format->countend, dump_header_format->countblockend); indentation(indent); - printf("%s %s ", dump_header_format->blockbegin, - dump_header_format->blockblockbegin); + HDfprintf(stdout, "%s %s ", dump_header_format->blockbegin, dump_header_format->blockblockbegin); if(sset->block.data) dump_dims(sset->block.data, dims); else - printf("DEFAULT"); + HDfprintf(stdout, "DEFAULT"); - printf("%s %s\n", dump_header_format->blockend, - dump_header_format->blockblockend); + HDfprintf(stdout, "%s %s\n", dump_header_format->blockend, dump_header_format->blockblockend); } /*------------------------------------------------------------------------- @@ -2493,18 +2478,22 @@ dump_subsetting_header(struct subset_t *sset, int dims) static void dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) { - h5tool_format_t *outputformat = &dataformat; - int status = -1; - void *buf = NULL; - hid_t space, type, p_type; H5S_class_t space_type; - int ndims, i; - hsize_t size[64], nelmts = 1, alloc_size; + int ndims; + int i; + hid_t space; + hid_t type; + hid_t p_type; + hsize_t size[64]; + hsize_t alloc_size; + hsize_t nelmts = 1; int depth; int stdindent = COL; /* should be 3 */ + int status = -1; + void *buf = NULL; + h5tool_format_t *outputformat = &dataformat; - if (fp_format) - { + if (fp_format) { outputformat->fmt_double = fp_format; outputformat->fmt_float = fp_format; } @@ -2575,16 +2564,15 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) } indentation(indent); - begin_obj(dump_header_format->databegin, (const char *)NULL, - dump_header_format->datablockbegin); + begin_obj(dump_header_format->databegin, (const char *)NULL, dump_header_format->datablockbegin); /* Print all the values. */ if(obj_data == DATASET_DATA) { - hid_t f_type = H5Dget_type(obj_id); - char string_prefix[64]; - h5tool_format_t string_dataformat; + h5tool_format_t string_dataformat; + char string_prefix[64]; + hid_t f_type = H5Dget_type(obj_id); - if(display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) { + if((display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) { /* * Print 1-byte integer data as an ASCII character string * instead of integers if the `-r' or `--string' command-line @@ -2611,7 +2599,6 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) outputformat = &string_dataformat; } - status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth); H5Tclose(f_type); @@ -2624,9 +2611,8 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) status = SUCCEED; } else { - char string_prefix[64]; - h5tool_format_t string_dataformat; - + char string_prefix[64]; + h5tool_format_t string_dataformat; /* VL data special information */ unsigned int vl_data = 0; /* contains VL datatypes */ @@ -2636,7 +2622,9 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) ndims = H5Sget_simple_extent_dims(space, size, NULL); /* Check if we have VL data in the dataset's datatype */ - if (h5tools_detect_vlen(p_type) == TRUE) + if (h5tools_detect_vlen_str(p_type) == TRUE) + vl_data = TRUE; + if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE) vl_data = TRUE; for (i = 0; i < ndims; i++) @@ -2677,15 +2665,15 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) outputformat = &string_dataformat; } - status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, - space, buf, depth); + status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, space, buf, depth); /* Reclaim any VL memory, if necessary */ if (vl_data) H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); free(buf); - } else + } + else status = SUCCEED; H5Tclose(p_type); @@ -2706,8 +2694,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) if (sset && obj_data == DATASET_DATA) { indentation(indent); - end_obj(dump_header_format->subsettingend, - dump_header_format->subsettingblockend); + end_obj(dump_header_format->subsettingend, dump_header_format->subsettingblockend); indent -= COL; } } @@ -2729,9 +2716,9 @@ static void dump_oid(hid_t oid) { indentation(indent + COL); - printf("%s %s %d %s\n", OBJID, BEGIN, oid, END); + HDfprintf(stdout, "%s %s %d %s\n", OBJID, BEGIN, oid, END); } -#ifdef H5_HAVE_H5DUMP_PACKED_BITS + /*------------------------------------------------------------------------- * Function: dump_packed_bits * @@ -2744,7 +2731,8 @@ dump_oid(hid_t oid) static void dump_packed_bits(unsigned int packed_index, hid_t type) { - int packed_bits_size = 0; + int packed_bits_size = 0; + hid_t n_type = h5tools_get_native_type(type); if(H5Tget_class(n_type)==H5T_INTEGER) { if(H5Tequal(n_type, H5T_NATIVE_SCHAR) == TRUE) { @@ -2783,12 +2771,11 @@ dump_packed_bits(unsigned int packed_index, hid_t type) indentation(indent + COL); if ((packed_bits_size>0) && (packed_offset[packed_index] + packed_length[packed_index]) > packed_bits_size) { error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n", - packed_offset[packed_index]+packed_length[packed_index], packed_bits_size); + packed_offset[packed_index]+packed_length[packed_index], packed_bits_size); packed_mask[packed_index] = 0; }; - printf("%s %s=%d %s=%d\n", PACKED_BITS, PACKED_OFFSET, packed_offset[packed_index], PACKED_LENGTH, packed_length[packed_index]); + HDfprintf(stdout, "%s %s=%d %s=%d\n", PACKED_BITS, PACKED_OFFSET, packed_offset[packed_index], PACKED_LENGTH, packed_length[packed_index]); } -#endif /*------------------------------------------------------------------------- * Function: dump_comment @@ -2806,9 +2793,9 @@ dump_packed_bits(unsigned int packed_index, hid_t type) static void dump_comment(hid_t obj_id) { - size_t buf_size = 0; - char* comment = NULL; + size_t buf_size = 0; ssize_t cmt_bufsize = -1; + char *comment = NULL; cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size); @@ -2821,7 +2808,7 @@ dump_comment(hid_t obj_id) if(cmt_bufsize > 0) { comment[cmt_bufsize] = '\0'; /* necessary because null char is not returned */ indentation(indent); - printf("COMMENT \"%s\"\n", comment); + HDfprintf(stdout, "COMMENT \"%s\"\n", comment); } /* end if */ HDfree(comment); } @@ -2843,15 +2830,14 @@ dump_comment(hid_t obj_id) * *------------------------------------------------------------------------- */ - static void dump_fill_value(hid_t dcpl,hid_t type_id, hid_t obj_id) { - h5tools_context_t ctx; /*print context */ + h5tools_context_t ctx; /* print context */ size_t size; - void *buf=NULL; - hsize_t nelmts=1; - h5tool_format_t *outputformat = &dataformat; hid_t n_type; + hsize_t nelmts = 1; + void *buf = NULL; + h5tool_format_t *outputformat = &dataformat; memset(&ctx, 0, sizeof(ctx)); ctx.indent_level=2; @@ -2899,7 +2885,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) unsigned szip_pixels_per_block; hsize_t chsize[64]; /* chunk size in elements */ int rank; /* rank */ - char name[256]; /* external file name */ + char name[256]; /* external file name */ off_t offset; /* offset of external file */ hsize_t size; /* size of external file */ H5D_fill_value_t fvstatus; @@ -2920,44 +2906,40 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) *------------------------------------------------------------------------- */ indentation(indent + COL); - printf("%s %s\n", STORAGE_LAYOUT, BEGIN); + HDfprintf(stdout, "%s %s\n", STORAGE_LAYOUT, BEGIN); if (H5D_CHUNKED == H5Pget_layout(dcpl_id)) { /*start indent */ indent += COL; indentation(indent + COL); - printf("%s ", CHUNKED); + HDfprintf(stdout, "%s ", CHUNKED); rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize); HDfprintf(stdout,"%s %Hu", dump_header_format->dataspacedimbegin, chsize[0]); - for ( i=1; i<rank; i++) + for (i=1; i<rank; i++) HDfprintf(stdout, ", %Hu", chsize[i]); - printf(" %s\n", dump_header_format->dataspacedimend); + HDfprintf(stdout, " %s\n", dump_header_format->dataspacedimend); indentation(indent + COL); - /* if there are filters, print a compression ratio */ - if ( nfilters ) - { - - hid_t sid = H5Dget_space( obj_id ); - hid_t tid = H5Dget_type( obj_id ); - size_t datum_size = H5Tget_size( tid ); - hsize_t dims[H5S_MAX_RANK]; - int ndims = H5Sget_simple_extent_dims( sid, dims, NULL); - hsize_t nelmts = 1; - double ratio = 0; - int ok = 0; + if (nfilters) { + hsize_t dims[H5S_MAX_RANK]; + hsize_t nelmts = 1; + double ratio = 0; + int ok = 0; + + hid_t tid = H5Dget_type(obj_id); + hid_t sid = H5Dget_space(obj_id); + size_t datum_size = H5Tget_size(tid); + int ndims = H5Sget_simple_extent_dims(sid, dims, NULL); /* only print the compression ratio for these filters */ - for ( i = 0; i < nfilters; i++) - { + for (i = 0; i < nfilters; i++) { cd_nelmts = NELMTS(cd_values); filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, - cd_values, sizeof(f_name), f_name, NULL); + cd_values, sizeof(f_name), f_name, NULL); - switch (filtn) - { + switch (filtn) { case H5Z_FILTER_DEFLATE: case H5Z_FILTER_SZIP: case H5Z_FILTER_NBIT: @@ -2967,12 +2949,10 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) } } - if (ndims && ok ) - { + if (ndims && ok) { hsize_t uncomp_size; - for (i = 0; i < ndims; i++) - { + for (i = 0; i < ndims; i++) { nelmts *= dims[i]; } uncomp_size = nelmts * datum_size; @@ -2988,26 +2968,24 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) else HDfprintf(stdout, "SIZE %Hu\n ", storage_size); - H5Sclose(sid); H5Tclose(tid); } - else - { + else { HDfprintf(stdout, "SIZE %Hu\n ", storage_size); } /*end indent */ indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); } else if (H5D_COMPACT == H5Pget_layout(dcpl_id)) { /*start indent */ indent += COL; indentation(indent + COL); - printf("%s\n", COMPACT); + HDfprintf(stdout, "%s\n", COMPACT); indentation(indent + COL); HDfprintf(stdout, "SIZE %Hu\n", storage_size); @@ -3015,7 +2993,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) /*end indent */ indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); } else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl_id)) { int next; @@ -3030,10 +3008,10 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) /*start indent */ indent += COL; indentation(indent + COL); - printf("%s\n", CONTIGUOUS); + HDfprintf(stdout, "%s\n", CONTIGUOUS); indentation(indent + COL); - printf("%s %s\n", EXTERNAL, BEGIN); + HDfprintf(stdout, "%s %s\n", EXTERNAL, BEGIN); /*start indent */ indent += COL; @@ -3045,18 +3023,18 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) /*end indent */ indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); /*end indent */ indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); } else { /*start indent */ indent += COL; indentation(indent + COL); - printf("%s\n", CONTIGUOUS); + HDfprintf(stdout, "%s\n", CONTIGUOUS); indentation(indent + COL); HDfprintf(stdout,"SIZE %Hu\n", storage_size); @@ -3066,17 +3044,15 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) /*end indent */ indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); } } /*------------------------------------------------------------------------- * FILTERS *------------------------------------------------------------------------- */ - - indentation(indent + COL); - printf("%s %s\n", FILTERS, BEGIN); + HDfprintf(stdout, "%s %s\n", FILTERS, BEGIN); indent += COL; if (nfilters) { @@ -3088,15 +3064,15 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) switch (filtn) { case H5Z_FILTER_DEFLATE: indentation(indent + COL); - printf("%s %s %s %d %s\n", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END); + HDfprintf(stdout, "%s %s %s %d %s\n", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END); break; case H5Z_FILTER_SHUFFLE: indentation(indent + COL); - printf("%s\n", SHUFFLE); + HDfprintf(stdout, "%s\n", SHUFFLE); break; case H5Z_FILTER_FLETCHER32: indentation(indent + COL); - printf("%s\n", FLETCHER32); + HDfprintf(stdout, "%s\n", FLETCHER32); break; case H5Z_FILTER_SZIP: { @@ -3104,69 +3080,69 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) szip_pixels_per_block=cd_values[1]; indentation(indent + COL); - printf("%s %s\n",SZIP, BEGIN); + HDfprintf(stdout, "%s %s\n",SZIP, BEGIN); /*start indent */ indent += COL; indentation(indent + COL); - printf("PIXELS_PER_BLOCK %d\n", szip_pixels_per_block); + HDfprintf(stdout, "PIXELS_PER_BLOCK %d\n", szip_pixels_per_block); indentation(indent + COL); if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK) - printf("MODE %s\n", "HARDWARE"); + HDfprintf(stdout, "MODE %s\n", "HARDWARE"); else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK) - printf("MODE %s\n", "K13"); + HDfprintf(stdout, "MODE %s\n", "K13"); indentation(indent + COL); if (szip_options_mask & H5_SZIP_EC_OPTION_MASK) - printf("CODING %s\n", "ENTROPY"); + HDfprintf(stdout, "CODING %s\n", "ENTROPY"); else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK) - printf("CODING %s\n", "NEAREST NEIGHBOUR"); + HDfprintf(stdout, "CODING %s\n", "NEAREST NEIGHBOUR"); indentation(indent + COL); if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK) - printf("BYTE_ORDER %s\n", "LSB"); + HDfprintf(stdout, "BYTE_ORDER %s\n", "LSB"); else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK) - printf("BYTE_ORDER %s\n", "MSB"); + HDfprintf(stdout, "BYTE_ORDER %s\n", "MSB"); indentation(indent + COL); if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK) - printf("HEADER %s\n", "RAW"); + HDfprintf(stdout, "HEADER %s\n", "RAW"); /*end indent */ indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); } break; case H5Z_FILTER_NBIT: indentation(indent + COL); - printf("%s\n", NBIT); + HDfprintf(stdout, "%s\n", NBIT); break; case H5Z_FILTER_SCALEOFFSET: indentation(indent + COL); - printf("%s %s %s %d %s\n", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT, cd_values[0], END); + HDfprintf(stdout, "%s %s %s %d %s\n", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT, cd_values[0], END); break; default: indentation(indent + COL); if (H5Zfilter_avail(filtn)) - printf("%s %s\n", "USER_REGISTERED_FILTER", BEGIN); + HDfprintf(stdout, "%s %s\n", "USER_REGISTERED_FILTER", BEGIN); else - printf("%s %s\n", "UNKNOWN_FILTER", BEGIN); + HDfprintf(stdout, "%s %s\n", "UNKNOWN_FILTER", BEGIN); /*start indent */ indent += COL; indentation(indent + COL); - printf("FILTER_ID %d\n", filtn); + HDfprintf(stdout, "FILTER_ID %d\n", filtn); if (f_name[0]!='\0') { indentation(indent + COL); - printf("COMMENT %s\n", f_name); + HDfprintf(stdout, "COMMENT %s\n", f_name); } if (cd_nelmts) { indentation(indent + COL); - printf("%s %s ","PARAMS", BEGIN); + HDfprintf(stdout, "%s %s ","PARAMS", BEGIN); for (j=0; j<cd_nelmts; j++) - printf("%d ", cd_values[j]); - printf("%s\n", END); + HDfprintf(stdout, "%d ", cd_values[j]); + HDfprintf(stdout, "%s\n", END); } break; }/*switch*/ @@ -3174,70 +3150,70 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) }/*nfilters*/ else { indentation(indent + COL); - printf("NONE\n"); + HDfprintf(stdout, "NONE\n"); } indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); /*------------------------------------------------------------------------- * FILLVALUE *------------------------------------------------------------------------- */ indentation(indent + COL); - printf("%s %s\n", FILLVALUE, BEGIN); + HDfprintf(stdout, "%s %s\n", FILLVALUE, BEGIN); /*start indent */ indent += COL; indentation(indent + COL); - printf("FILL_TIME "); + HDfprintf(stdout, "FILL_TIME "); H5Pget_fill_time(dcpl_id, &ft); switch ( ft ) { case H5D_FILL_TIME_ALLOC: - printf("%s", "H5D_FILL_TIME_ALLOC\n"); + HDfprintf(stdout, "%s", "H5D_FILL_TIME_ALLOC\n"); break; case H5D_FILL_TIME_NEVER: - printf("%s", "H5D_FILL_TIME_NEVER\n"); + HDfprintf(stdout, "%s", "H5D_FILL_TIME_NEVER\n"); break; case H5D_FILL_TIME_IFSET: - printf("%s", "H5D_FILL_TIME_IFSET\n"); + HDfprintf(stdout, "%s", "H5D_FILL_TIME_IFSET\n"); break; default: assert(0); break; } indentation(indent + COL); - printf("%s ", "VALUE "); + HDfprintf(stdout, "%s ", "VALUE "); H5Pfill_value_defined(dcpl_id, &fvstatus); if (fvstatus == H5D_FILL_VALUE_UNDEFINED) - printf("%s\n", "H5D_FILL_VALUE_UNDEFINED"); + HDfprintf(stdout, "%s\n", "H5D_FILL_VALUE_UNDEFINED"); else dump_fill_value(dcpl_id,type_id,obj_id); /* end indent */ indent -= COL; indentation(indent + COL); - printf("\n"); + HDfprintf(stdout, "\n"); indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); /*------------------------------------------------------------------------- * ALLOCATION_TIME *------------------------------------------------------------------------- */ indentation(indent + COL); - printf("ALLOCATION_TIME %s\n",BEGIN); + HDfprintf(stdout, "ALLOCATION_TIME %s\n",BEGIN); /*start indent */ indent += COL; indentation(indent + COL); H5Pget_alloc_time(dcpl_id, &at); switch (at) { case H5D_ALLOC_TIME_EARLY: - printf("%s", "H5D_ALLOC_TIME_EARLY\n"); + HDfprintf(stdout, "%s", "H5D_ALLOC_TIME_EARLY\n"); break; case H5D_ALLOC_TIME_INCR: - printf("%s", "H5D_ALLOC_TIME_INCR\n"); + HDfprintf(stdout, "%s", "H5D_ALLOC_TIME_INCR\n"); break; case H5D_ALLOC_TIME_LATE: - printf("%s", "H5D_ALLOC_TIME_LATE\n"); + HDfprintf(stdout, "%s", "H5D_ALLOC_TIME_LATE\n"); break; default: assert(0); @@ -3246,7 +3222,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) /* end indent */ indent -= COL; indentation(indent + COL); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); } /*------------------------------------------------------------------------- @@ -3275,9 +3251,9 @@ dump_fcpl(hid_t fid) unsigned sym_lk; /* symbol table B-tree leaf 'K' value */ unsigned sym_ik; /* symbol table B-tree internal 'K' value */ unsigned istore_ik; /* indexed storage B-tree internal 'K' value */ - H5F_file_space_type_t fs_strategy; /* file space strategy */ - hsize_t fs_threshold; /* free-space section threshold */ - H5F_info2_t finfo; /* file information */ + H5F_file_space_type_t fs_strategy; /* file space strategy */ + hsize_t fs_threshold; /* free-space section threshold */ + H5F_info2_t finfo; /* file information */ fcpl=H5Fget_create_plist(fid); H5Fget_info2(fid, &finfo); @@ -3295,23 +3271,23 @@ dump_fcpl(hid_t fid) * SUPER_BLOCK *------------------------------------------------------------------------- */ - printf("%s %s\n",SUPER_BLOCK, BEGIN); + HDfprintf(stdout, "%s %s\n",SUPER_BLOCK, BEGIN); indentation(indent + COL); - printf("%s %u\n","SUPERBLOCK_VERSION", finfo.super.version); + HDfprintf(stdout, "%s %u\n","SUPERBLOCK_VERSION", finfo.super.version); indentation(indent + COL); - printf("%s %u\n","FREELIST_VERSION", finfo.free.version); + HDfprintf(stdout, "%s %u\n","FREELIST_VERSION", finfo.free.version); indentation(indent + COL); - printf("%s %u\n","SYMBOLTABLE_VERSION", 0); /* Retain this for backward compatibility, for now (QAK) */ + HDfprintf(stdout, "%s %u\n","SYMBOLTABLE_VERSION", 0); /* Retain this for backward compatibility, for now (QAK) */ indentation(indent + COL); - printf("%s %u\n","OBJECTHEADER_VERSION", finfo.sohm.version); + HDfprintf(stdout, "%s %u\n","OBJECTHEADER_VERSION", finfo.sohm.version); indentation(indent + COL); HDfprintf(stdout,"%s %Hd\n","OFFSET_SIZE", (long long)off_size); indentation(indent + COL); HDfprintf(stdout,"%s %Hd\n","LENGTH_SIZE", (long long)len_size); indentation(indent + COL); - printf("%s %u\n","BTREE_RANK", sym_ik); + HDfprintf(stdout, "%s %u\n","BTREE_RANK", sym_ik); indentation(indent + COL); - printf("%s %d\n","BTREE_LEAF", sym_lk); + HDfprintf(stdout, "%s %d\n","BTREE_LEAF", sym_lk); if (H5FD_CORE==fdriver) HDstrcpy(dname,"H5FD_CORE"); @@ -3341,34 +3317,34 @@ dump_fcpl(hid_t fid) /* Take out this because the driver used can be different from the * standard output. */ /*indentation(indent + COL); - printf("%s %s\n","FILE_DRIVER", dname);*/ + HDfprintf(stdout, "%s %s\n","FILE_DRIVER", dname);*/ indentation(indent + COL); - printf("%s %u\n","ISTORE_K", istore_ik); + HDfprintf(stdout, "%s %u\n","ISTORE_K", istore_ik); indentation(indent + COL); if(fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) - printf("%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL_PERSIST"); + HDfprintf(stdout, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL_PERSIST"); else if(fs_strategy == H5F_FILE_SPACE_ALL) - printf("%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL"); + HDfprintf(stdout, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL"); else if(fs_strategy == H5F_FILE_SPACE_AGGR_VFD) - printf("%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_AGGR_VFD"); + HDfprintf(stdout, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_AGGR_VFD"); else if(fs_strategy == H5F_FILE_SPACE_VFD) - printf("%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_VFD"); + HDfprintf(stdout, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_VFD"); else - printf("%s %s\n", "FILE_SPACE_STRATEGY", "Unknown strategy"); + HDfprintf(stdout, "%s %s\n", "FILE_SPACE_STRATEGY", "Unknown strategy"); indentation(indent + COL); HDfprintf(stdout, "%s %Hu\n","FREE_SPACE_THRESHOLD", fs_threshold); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); /*------------------------------------------------------------------------- * USER_BLOCK *------------------------------------------------------------------------- */ - printf("USER_BLOCK %s\n",BEGIN); + HDfprintf(stdout, "USER_BLOCK %s\n",BEGIN); indentation(indent + COL); HDfprintf(stdout,"%s %Hu\n","USERBLOCK_SIZE", userblock); - printf("%s\n",END); + HDfprintf(stdout, "%s\n",END); } /*------------------------------------------------------------------------- @@ -3387,8 +3363,7 @@ dump_fcpl(hid_t fid) static void dump_fcontents(hid_t fid) { - - printf("%s %s\n",FILE_CONTENTS, BEGIN); + HDfprintf(stdout, "%s %s\n",FILE_CONTENTS, BEGIN); /* special case of unamed types in root group */ if (unamedtype) { @@ -3396,17 +3371,16 @@ static void dump_fcontents(hid_t fid) for (u = 0; u < type_table->nobjs; u++) { if (!type_table->objs[u].recorded) - printf(" %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno); + HDfprintf(stdout, " %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno); } } /* print objects in the files */ h5trav_print(fid); - printf(" %s\n",END); + HDfprintf(stdout, " %s\n",END); } - /*------------------------------------------------------------------------- * Function: set_output_file * @@ -3426,36 +3400,32 @@ static void dump_fcontents(hid_t fid) static int set_output_file(const char *fname, int is_bin) { - FILE *f; /* temporary holding place for the stream pointer -* so that rawdatastream is changed only when succeeded */ - - if (rawdatastream && rawdatastream != stdout) { - if (fclose(rawdatastream)) - perror("closing rawdatastream"); - else - rawdatastream = NULL; - } - - /* binary output */ - if (is_bin) - { - if ((f = fopen(fname, "wb")) != NULL) { - rawdatastream = f; - return 0; - } - } - else - { - if ((f = fopen(fname, "w")) != NULL) { - rawdatastream = f; - return 0; - } - } - - return -1; -} + FILE *f; /* temporary holding place for the stream pointer + * so that rawdatastream is changed only when succeeded */ + if (rawdatastream && rawdatastream != stdout) { + if (fclose(rawdatastream)) + perror("closing rawdatastream"); + else + rawdatastream = NULL; + } + + /* binary output */ + if (is_bin) { + if ((f = fopen(fname, "wb")) != NULL) { + rawdatastream = f; + return 0; + } + } + else { + if ((f = fopen(fname, "w")) != NULL) { + rawdatastream = f; + return 0; + } + } + return -1; +} /*------------------------------------------------------------------------- * Function: set_binary_form @@ -3475,21 +3445,20 @@ set_output_file(const char *fname, int is_bin) static int set_binary_form(const char *form) { - int bform=-1; - - if (strcmp(form,"NATIVE")==0 || - strcmp(form,"MEMORY")==0) - {/* native form */ - bform = 0; - } - else if (strcmp(form,"FILE")==0) /* file type form */ - bform = 1; - else if (strcmp(form,"LE")==0) /* convert to little endian */ - bform = 2; - else if (strcmp(form,"BE")==0) /* convert to big endian */ - bform = 3; - - return bform; + int bform = -1; + + if (strcmp(form,"NATIVE") == 0 || strcmp(form,"MEMORY") == 0) { + /* native form */ + bform = 0; + } + else if (strcmp(form,"FILE") == 0) /* file type form */ + bform = 1; + else if (strcmp(form,"LE") == 0) /* convert to little endian */ + bform = 2; + else if (strcmp(form,"BE") == 0) /* convert to big endian */ + bform = 3; + + return bform; } /*------------------------------------------------------------------------- @@ -3511,18 +3480,16 @@ set_binary_form(const char *form) static H5_index_t set_sort_by(const char *form) { - H5_index_t idx_type = H5_INDEX_UNKNOWN; + H5_index_t idx_type = H5_INDEX_UNKNOWN; - if (strcmp(form,"name")==0) /* H5_INDEX_NAME */ - idx_type = H5_INDEX_NAME; - else if (strcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ - idx_type = H5_INDEX_CRT_ORDER; + if (strcmp(form,"name")==0) /* H5_INDEX_NAME */ + idx_type = H5_INDEX_NAME; + else if (strcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ + idx_type = H5_INDEX_CRT_ORDER; - return idx_type; + return idx_type; } - - /*------------------------------------------------------------------------- * Function: set_sort_order * @@ -3542,17 +3509,16 @@ set_sort_by(const char *form) static H5_iter_order_t set_sort_order(const char *form) { - H5_iter_order_t iter_order = H5_ITER_UNKNOWN; + H5_iter_order_t iter_order = H5_ITER_UNKNOWN; - if (strcmp(form,"ascending")==0) /* H5_ITER_INC */ - iter_order = H5_ITER_INC; - else if (strcmp(form,"descending")==0) /* H5_ITER_DEC */ - iter_order = H5_ITER_DEC; + if (strcmp(form,"ascending")==0) /* H5_ITER_INC */ + iter_order = H5_ITER_INC; + else if (strcmp(form,"descending")==0) /* H5_ITER_DEC */ + iter_order = H5_ITER_DEC; - return iter_order; + return iter_order; } - /*------------------------------------------------------------------------- * Function: handle_attributes * @@ -3600,7 +3566,9 @@ parse_hsize_list(const char *h_list, subset_d *d) { hsize_t *p_list; const char *ptr; - unsigned int size_count = 0, i = 0, last_digit = 0; + unsigned int size_count = 0; + unsigned int i = 0; + unsigned int last_digit = 0; if (!h_list || !*h_list || *h_list == ';') return; @@ -3613,7 +3581,8 @@ parse_hsize_list(const char *h_list, subset_d *d) size_count++; last_digit = 1; - } else { + } + else { last_digit = 0; } @@ -3674,24 +3643,21 @@ parse_subset_params(char *dset) while (*brace && *brace != ';') brace++; - if (*brace) - brace++; + if (*brace) brace++; parse_hsize_list(brace, &s->stride); while (*brace && *brace != ';') brace++; - if (*brace) - brace++; + if (*brace) brace++; parse_hsize_list(brace, &s->count); while (*brace && *brace != ';') brace++; - if (*brace) - brace++; + if (*brace) brace++; parse_hsize_list(brace, &s->block); } @@ -3700,7 +3666,6 @@ parse_subset_params(char *dset) return s; } -#ifdef H5_HAVE_H5DUMP_PACKED_BITS /*------------------------------------------------------------------------- * Function: parse_mask_list * @@ -3718,102 +3683,99 @@ parse_subset_params(char *dset) static int parse_mask_list(const char *h_list) { - const char *ptr; - int offset_value, length_value; + int offset_value; + int length_value; unsigned long long temp_mask; + const char *ptr = NULL; /* sanity check */ HDassert(h_list); HDmemset(packed_mask,0,sizeof(packed_mask)); - + packed_bits_num = 0; /* scan in pair of offset,length separated by commas. */ ptr = h_list; while (*ptr) { - /* scan for an offset which is an unsigned int */ - if (!HDisdigit(*ptr)){ - error_msg("Bad mask list(%s)\n", h_list); - return FAIL; - } - offset_value = HDatoi(ptr); - if (offset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX){ - error_msg("Packed Bit offset value(%d) must be between 0 and %d\n", - offset_value, PACKED_BITS_SIZE_MAX - 1); - return FAIL; - } - - /* skip to end of integer */ - while (HDisdigit(*++ptr)) - ; - /* Look for the common separator */ - if (*ptr++ != ',') { - error_msg("Bad mask list(%s), missing expected comma separator.\n", h_list); - return FAIL; - } - - /* scan for a length which is a positive int */ - if (!HDisdigit(*ptr)){ - error_msg("Bad mask list(%s)\n", h_list); - return FAIL; - } - length_value = HDatoi(ptr); - if (length_value <= 0){ - error_msg("Packed Bit length value(%d) must be positive.\n", - length_value); - return FAIL; - }; - if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX){ - error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n", - offset_value+length_value, PACKED_BITS_SIZE_MAX); - return FAIL; - }; - - /* skip to end of int */ - while (HDisdigit(*++ptr)) - ; - - /* store the offset,length pair */ - if (packed_bits_num >= PACKED_BITS_MAX){ - /* too many requests */ - error_msg("Too many masks requested (max. %d). Mask list(%s)\n", - PACKED_BITS_MAX, h_list); - return FAIL; - } - packed_offset[packed_bits_num] = offset_value; - packed_length[packed_bits_num] = length_value; - /* create the bit mask by left shift 1's by length, then negate it. */ - /* After packed_mask is calculated, packed_length is not needed but */ - /* keep it for debug purpose. */ - temp_mask = ~0L; - if(length_value<8*sizeof(unsigned long long)) { - temp_mask = temp_mask << length_value; - packed_mask[packed_bits_num] = ~temp_mask; - } - else - packed_mask[packed_bits_num] = temp_mask; - packed_bits_num++; - - /* skip a possible comma separator */ - if (*ptr == ','){ - if (!(*++ptr)){ - /* unexpected end of string */ - error_msg("Bad mask list(%s), unexpected end of string.\n", h_list); - return FAIL; - } - } + /* scan for an offset which is an unsigned int */ + if (!HDisdigit(*ptr)) { + error_msg("Bad mask list(%s)\n", h_list); + return FAIL; + } + offset_value = HDatoi(ptr); + if (offset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) { + error_msg("Packed Bit offset value(%d) must be between 0 and %d\n", + offset_value, PACKED_BITS_SIZE_MAX - 1); + return FAIL; + } + + /* skip to end of integer */ + while (HDisdigit(*++ptr)) + ; + /* Look for the common separator */ + if (*ptr++ != ',') { + error_msg("Bad mask list(%s), missing expected comma separator.\n", h_list); + return FAIL; + } + + /* scan for a length which is a positive int */ + if (!HDisdigit(*ptr)) { + error_msg("Bad mask list(%s)\n", h_list); + return FAIL; + } + length_value = HDatoi(ptr); + if (length_value <= 0) { + error_msg("Packed Bit length value(%d) must be positive.\n", length_value); + return FAIL; + } + if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX){ + error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n", + offset_value+length_value, PACKED_BITS_SIZE_MAX); + return FAIL; + } + + /* skip to end of int */ + while (HDisdigit(*++ptr)) + ; + + /* store the offset,length pair */ + if (packed_bits_num >= PACKED_BITS_MAX) { + /* too many requests */ + error_msg("Too many masks requested (max. %d). Mask list(%s)\n", PACKED_BITS_MAX, h_list); + return FAIL; + } + packed_offset[packed_bits_num] = offset_value; + packed_length[packed_bits_num] = length_value; + /* create the bit mask by left shift 1's by length, then negate it. */ + /* After packed_mask is calculated, packed_length is not needed but */ + /* keep it for debug purpose. */ + temp_mask = ~0L; + if(length_value<8*sizeof(unsigned long long)) { + temp_mask = temp_mask << length_value; + packed_mask[packed_bits_num] = ~temp_mask; + } + else + packed_mask[packed_bits_num] = temp_mask; + packed_bits_num++; + + /* skip a possible comma separator */ + if (*ptr == ',') { + if (!(*++ptr)) { + /* unexpected end of string */ + error_msg("Bad mask list(%s), unexpected end of string.\n", h_list); + return FAIL; + } + } } HDassert(packed_bits_num <= PACKED_BITS_MAX); - if (packed_bits_num == 0){ - /* got no masks! */ + if (packed_bits_num == 0) { + /* got no masks! */ error_msg("Bad mask list(%s)\n", h_list); return FAIL; } return SUCCEED; } -#endif - /*------------------------------------------------------------------------- * Function: handle_datasets * @@ -3843,16 +3805,12 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis struct subset_t *sset = (struct subset_t *)data; const char *real_name = display_name ? display_name : dset; - if((dsetid = H5Dopen2(fid, dset, H5P_DEFAULT)) < 0) - { - if (pe) - { - begin_obj(dump_header_format->datasetbegin, real_name, - dump_header_format->datasetblockbegin); + if((dsetid = H5Dopen2(fid, dset, H5P_DEFAULT)) < 0) { + if (pe) { + begin_obj(dump_header_format->datasetbegin, real_name, dump_header_format->datasetblockbegin); indentation(COL); error_msg("unable to open dataset \"%s\"\n", real_name); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); + end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); h5tools_setstatus(EXIT_FAILURE); } return; @@ -3951,14 +3909,13 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis if(found_obj) { if (found_obj->displayed) { indentation(indent); - begin_obj(dump_header_format->datasetbegin, real_name, - dump_header_format->datasetblockbegin); + begin_obj(dump_header_format->datasetbegin, real_name, dump_header_format->datasetblockbegin); indentation(indent + COL); - printf("%s \"%s\"\n", HARDLINK, found_obj->objname); + HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname); indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); - } else { + end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); + } + else { found_obj->displayed = TRUE; dump_dataset(dsetid, real_name, sset); } @@ -3994,16 +3951,13 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis *------------------------------------------------------------------------- */ static void -handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const char * display_name) +handle_groups(hid_t fid, const char *group, void UNUSED *data, int pe, const char *display_name) { hid_t gid; const char *real_name = display_name ? display_name : group; - - if((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) - { - if ( pe ) - { + if((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) { + if (pe) { begin_obj(dump_header_format->groupbegin, real_name, dump_header_format->groupblockbegin); indentation(COL); error_msg("unable to open group \"%s\"\n", real_name); @@ -4011,12 +3965,10 @@ handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const ch h5tools_setstatus(EXIT_FAILURE); } } - else - { + else { size_t new_len = HDstrlen(group) + 1; - if(prefix_len <= new_len) - { + if(prefix_len <= new_len) { prefix_len = new_len; prefix = (char *)HDrealloc(prefix, prefix_len); } /* end if */ @@ -4052,68 +4004,63 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) { error_msg("unable to get link info from \"%s\"\n", links); h5tools_setstatus(EXIT_FAILURE); - } else if(linfo.type == H5L_TYPE_HARD) { + } + else if(linfo.type == H5L_TYPE_HARD) { error_msg("\"%s\" is a hard link\n", links); h5tools_setstatus(EXIT_FAILURE); - } else { + } + else { char *buf = (char *)HDmalloc(linfo.u.val_size); switch(linfo.type) { - case H5L_TYPE_SOFT: /* Soft link */ - begin_obj(dump_header_format->softlinkbegin, links, - dump_header_format->softlinkblockbegin); - indentation(COL); - if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) - printf("LINKTARGET \"%s\"\n", buf); - else { - error_msg("h5dump error: unable to get link value for \"%s\"\n", - links); - h5tools_setstatus(EXIT_FAILURE); - } - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); - break; + case H5L_TYPE_SOFT: /* Soft link */ + begin_obj(dump_header_format->softlinkbegin, links, dump_header_format->softlinkblockbegin); + indentation(COL); + if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) + HDfprintf(stdout, "LINKTARGET \"%s\"\n", buf); + else { + error_msg("h5dump error: unable to get link value for \"%s\"\n", links); + h5tools_setstatus(EXIT_FAILURE); + } + end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend); + break; - case H5L_TYPE_EXTERNAL: - begin_obj(dump_header_format->udlinkbegin, links, - dump_header_format->udlinkblockbegin); - indentation(COL); - begin_obj(dump_header_format->extlinkbegin, links, - dump_header_format->extlinkblockbegin); - if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { - const char *elink_file; - const char *elink_path; - - if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path)>=0) { - indentation(COL); - printf("LINKCLASS %d\n", linfo.type); - indentation(COL); - printf("TARGETFILE \"%s\"\n", elink_file); - indentation(COL); - printf("TARGETPATH \"%s\"\n", elink_path); - } else { - error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - } else { - error_msg("h5dump error: unable to get external link value for \"%s\"\n", links); + case H5L_TYPE_EXTERNAL: + begin_obj(dump_header_format->udlinkbegin, links, dump_header_format->udlinkblockbegin); + indentation(COL); + begin_obj(dump_header_format->extlinkbegin, links, dump_header_format->extlinkblockbegin); + if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { + const char *elink_file; + const char *elink_path; + + if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path)>=0) { + indentation(COL); + HDfprintf(stdout, "LINKCLASS %d\n", linfo.type); + indentation(COL); + HDfprintf(stdout, "TARGETFILE \"%s\"\n", elink_file); + indentation(COL); + HDfprintf(stdout, "TARGETPATH \"%s\"\n", elink_path); + } + else { + error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links); h5tools_setstatus(EXIT_FAILURE); } - end_obj(dump_header_format->extlinkend, - dump_header_format->extlinkblockend); - break; + } + else { + error_msg("h5dump error: unable to get external link value for \"%s\"\n", links); + h5tools_setstatus(EXIT_FAILURE); + } + end_obj(dump_header_format->extlinkend, dump_header_format->extlinkblockend); + break; - default: - begin_obj(dump_header_format->udlinkbegin, links, - dump_header_format->udlinkblockbegin); - indentation(COL); - begin_obj(dump_header_format->udlinkbegin, links, - dump_header_format->udlinkblockbegin); - indentation(COL); - printf("LINKCLASS %d\n", linfo.type); - end_obj(dump_header_format->udlinkend, - dump_header_format->udlinkblockend); - break; + default: + begin_obj(dump_header_format->udlinkbegin, links, dump_header_format->udlinkblockbegin); + indentation(COL); + begin_obj(dump_header_format->udlinkbegin, links, dump_header_format->udlinkblockbegin); + indentation(COL); + HDfprintf(stdout, "LINKCLASS %d\n", linfo.type); + end_obj(dump_header_format->udlinkend, dump_header_format->udlinkblockend); + break; } /* end switch */ HDfree(buf); } /* end else */ @@ -4144,17 +4091,14 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const hid_t type_id; const char *real_name = display_name ? display_name : type; - if((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) - { + if((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) { /* check if type is unamed datatype */ unsigned idx = 0; - while(idx < type_table->nobjs ) - { + while(idx < type_table->nobjs ) { char name[128]; - if(!type_table->objs[idx].recorded) - { + if(!type_table->objs[idx].recorded) { /* unamed datatype */ sprintf(name, "/#"H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno); @@ -4165,22 +4109,17 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const idx++; } /* end while */ - if(idx == type_table->nobjs) - { - if ( pe ) - { + if(idx == type_table->nobjs) { + if (pe) { /* unknown type */ - begin_obj(dump_header_format->datatypebegin, real_name, - dump_header_format->datatypeblockbegin); + begin_obj(dump_header_format->datatypebegin, real_name, dump_header_format->datatypeblockbegin); indentation(COL); error_msg("unable to open datatype \"%s\"\n", real_name); - end_obj(dump_header_format->datatypeend, - dump_header_format->datatypeblockend); + end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend); h5tools_setstatus(EXIT_FAILURE); } } - else - { + else { hid_t dsetid = H5Dopen2(fid, type_table->objs[idx].objname, H5P_DEFAULT); type_id = H5Dget_type(dsetid); dump_named_datatype(type_id, real_name); @@ -4188,8 +4127,7 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const H5Dclose(dsetid); } } - else - { + else { dump_named_datatype(type_id, real_name); if(H5Tclose(type_id) < 0) @@ -4199,6 +4137,54 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const /*------------------------------------------------------------------------- + * Function: free_handler + * + * Purpose: Convenience function to free the handler_t structures. Needs a + * length variable (LEN) to know how many in the array it needs + * to free + * + * Return: Nothing + * + * Programmer: Bill Wendling + * Tuesday, 20. February 2001 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +free_handler(struct handler_t *hand, int len) +{ + register int i; + + if(hand) { + for (i = 0; i < len; i++) { + if(hand[i].obj) { + free(hand[i].obj); + hand[i].obj=NULL; + } + + if (hand[i].subset_info) { + if(hand[i].subset_info->start.data) + free(hand[i].subset_info->start.data); + if(hand[i].subset_info->stride.data) + free(hand[i].subset_info->stride.data); + if(hand[i].subset_info->count.data) + free(hand[i].subset_info->count.data); + if(hand[i].subset_info->block.data) + free(hand[i].subset_info->block.data); + + free(hand[i].subset_info); + hand[i].subset_info=NULL; + } + } + + free(hand); + } +} + + +/*------------------------------------------------------------------------- * Function: parse_command_line * * Purpose: Parse the command line for the h5dumper. @@ -4220,17 +4206,22 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const static struct handler_t * parse_command_line(int argc, const char *argv[]) { - struct handler_t *hand, *last_dset = NULL; - int i, opt, last_was_dset = FALSE; + struct handler_t *hand = NULL; + struct handler_t *last_dset = NULL; + int i; + int opt; + int last_was_dset = FALSE; /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } /* this will be plenty big enough to hold the info */ - hand = (struct handler_t *)calloc((size_t)argc, sizeof(struct handler_t)); + if((hand = (struct handler_t *)calloc((size_t)argc, sizeof(struct handler_t)))==NULL) { + goto error; + } /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { @@ -4276,7 +4267,10 @@ parse_start: break; case 'V': print_version(h5tools_getprogname()); - leave(EXIT_SUCCESS); + free_handler(hand, argc); + hand = NULL; + h5tools_setstatus(EXIT_SUCCESS); + goto done; break; case 'w': nCols = HDatoi(opt_arg); @@ -4352,13 +4346,13 @@ parse_start: if ( bin_output ) { if (set_output_file(opt_arg, 1) < 0) { usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } } else { if (set_output_file(opt_arg, 0) < 0) { usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } } @@ -4372,7 +4366,7 @@ parse_start: if ( ( bin_form = set_binary_form(opt_arg)) < 0) { /* failed to set binary form */ usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } } bin_output = TRUE; @@ -4380,7 +4374,7 @@ parse_start: if (set_output_file(outfname, 1) < 0) { /* failed to set output file */ usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } last_was_dset = FALSE; @@ -4391,7 +4385,7 @@ parse_start: if ( ( sort_by = set_sort_by(opt_arg)) < 0) { /* failed to set "sort by" form */ usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } break; @@ -4399,24 +4393,21 @@ parse_start: if ( ( sort_order = set_sort_order(opt_arg)) < 0) { /* failed to set "sort order" form */ usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } break; -#ifdef H5_HAVE_H5DUMP_PACKED_BITS case 'M': if (!last_was_dset) { - error_msg("option `-%c' can only be used after --dataset option\n", - opt); - leave(EXIT_FAILURE); + error_msg("option `-%c' can only be used after --dataset option\n", opt); + goto error; } if (parse_mask_list(opt_arg) != SUCCEED){ - usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + usage(h5tools_getprogname()); + goto error; } display_packed_bits = TRUE; break; -#endif /** begin XML parameters **/ case 'x': @@ -4444,21 +4435,19 @@ parse_start: fp_format = opt_arg; break; - - - case 'X': /* specify XML namespace (default="hdf5:"), or none */ /* To Do: check format of this value? */ - if (!useschema) { + if (!useschema) { usage(h5tools_getprogname()); - leave(EXIT_FAILURE); - } - if (strcmp(opt_arg,":") == 0) { + goto error; + } + if (strcmp(opt_arg,":") == 0) { xmlnsprefix = ""; - } else { + } + else { xmlnsprefix = opt_arg; - } + } break; /** end XML parameters **/ @@ -4470,9 +4459,8 @@ parse_start: struct subset_t *s; if (!last_was_dset) { - error_msg("option `-%c' can only be used after --dataset option\n", - opt); - leave(EXIT_FAILURE); + error_msg("option `-%c' can only be used after --dataset option\n", opt); + goto error; } if (last_dset->subset_info) { @@ -4481,7 +4469,8 @@ parse_start: * the two. */ s = last_dset->subset_info; - } else { + } + else { last_dset->subset_info = s = (struct subset_t *)calloc(1, sizeof(struct subset_t)); } @@ -4498,11 +4487,36 @@ parse_start: */ do { switch ((char)opt) { - case 's': if(s->start.data) free(s->start.data); parse_hsize_list(opt_arg, &s->start); break; - case 'S': if(s->stride.data) free(s->stride.data); parse_hsize_list(opt_arg, &s->stride); break; - case 'c': if(s->count.data) free(s->count.data); parse_hsize_list(opt_arg, &s->count); break; - case 'k': if(s->block.data) free(s->block.data); parse_hsize_list(opt_arg, &s->block); break; - default: goto end_collect; + case 's': + if (s->start.data) { + free(s->start.data); + s->start.data = NULL; + } + parse_hsize_list(opt_arg, &s->start); + break; + case 'S': + if (s->stride.data) { + free(s->stride.data); + s->stride.data = NULL; + } + parse_hsize_list(opt_arg, &s->stride); + break; + case 'c': + if (s->count.data) { + free(s->count.data); + s->count.data = NULL; + } + parse_hsize_list(opt_arg, &s->count); + break; + case 'k': + if (s->block.data) { + free(s->block.data); + s->block.data = NULL; + } + parse_hsize_list(opt_arg, &s->block); + break; + default: + goto end_collect; } } while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF); @@ -4521,11 +4535,14 @@ end_collect: break; case 'h': usage(h5tools_getprogname()); - leave(EXIT_SUCCESS); + free_handler(hand, argc); + hand = NULL; + h5tools_setstatus(EXIT_SUCCESS); + goto done; case '?': default: usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } } @@ -4534,48 +4551,21 @@ parse_end: if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + goto error; } +done: return hand; -} - - -/*------------------------------------------------------------------------- - * Function: free_handler - * - * Purpose: Convenience function to free the handler_t structures. Needs a - * length variable (LEN) to know how many in the array it needs - * to free - * - * Return: Nothing - * - * Programmer: Bill Wendling - * Tuesday, 20. February 2001 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -free_handler(struct handler_t *hand, int len) -{ - register int i; - for (i = 0; i < len; i++) { - free(hand[i].obj); - - if (hand[i].subset_info) { - free(hand[i].subset_info->start.data); - free(hand[i].subset_info->stride.data); - free(hand[i].subset_info->count.data); - free(hand[i].subset_info->block.data); - free(hand[i].subset_info); - } - } - - free(hand); +error: + if (hand) { + free_handler(hand, argc); + hand = NULL; } + h5tools_setstatus(EXIT_FAILURE); + return hand; +} + /*------------------------------------------------------------------------- * Function: main * @@ -4618,14 +4608,15 @@ free_handler(struct handler_t *hand, int len) int main(int argc, const char *argv[]) { - hid_t fid, gid; - char *fname = NULL; - void *edata; + hid_t fid = -1; + hid_t gid = -1; H5E_auto2_t func; H5O_info_t oi; struct handler_t *hand; int i; unsigned u; + void *edata; + char *fname = NULL; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -4638,11 +4629,15 @@ main(int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - hand = parse_command_line(argc, argv); + if((hand = parse_command_line(argc, argv))==NULL) { + h5tools_setstatus(EXIT_FAILURE); + goto done; + } if (bin_output && outfname == NULL) { error_msg("binary output requires a file name, use -o <filename>\n"); - leave(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } if (enable_error_stack) @@ -4653,35 +4648,41 @@ main(int argc, const char *argv[]) if (!display_all) { error_msg("option \"%s\" not available for XML\n", "to display selected objects"); - leave(EXIT_FAILURE); - } else if (display_bb) { - error_msg("option \"%s\" not available for XML\n", - "--boot-block"); - leave(EXIT_FAILURE); - } else if (display_oid == 1) { - error_msg("option \"%s\" not available for XML\n", - "--object-ids"); - leave(EXIT_FAILURE); - } else if (display_char == TRUE) { - error_msg("option \"%s\" not available for XML\n", - "--string"); - leave(EXIT_FAILURE); - } else if (usingdasho) { - error_msg("option \"%s\" not available for XML\n", - "--output"); - leave(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + else if (display_bb) { + error_msg("option \"%s\" not available for XML\n", "--boot-block"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + else if (display_oid == 1) { + error_msg("option \"%s\" not available for XML\n", "--object-ids"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + else if (display_char == TRUE) { + error_msg("option \"%s\" not available for XML\n", "--string"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + else if (usingdasho) { + error_msg("option \"%s\" not available for XML\n", "--output"); + h5tools_setstatus(EXIT_FAILURE); + goto done; } - } else { + } + else { if (xml_dtd_uri) { - warn_msg("option \"%s\" only applies with XML: %s\n", - "--xml-dtd", xml_dtd_uri); + warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri); } } if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } fname = HDstrdup(argv[opt_ind]); @@ -4689,7 +4690,8 @@ main(int argc, const char *argv[]) if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); - leave(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } /* allocate and initialize internal data structure */ @@ -4700,7 +4702,6 @@ main(int argc, const char *argv[]) if(doxml) { /* initialize XML */ - /* reset prefix! */ HDstrcpy(prefix, ""); @@ -4708,19 +4709,21 @@ main(int argc, const char *argv[]) if (xml_dtd_uri == NULL) { if (useschema) { xml_dtd_uri = DEFAULT_XSD; - } else { + } + else { xml_dtd_uri = DEFAULT_DTD; xmlnsprefix = ""; } - } else { + } + else { if (useschema && strcmp(xmlnsprefix,"")) { error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); - leave(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } } } - /* Get object info for root group */ if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) { error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); @@ -4747,35 +4750,36 @@ main(int argc, const char *argv[]) /* start to dump - display file header information */ if (!doxml) { - begin_obj(dump_header_format->filebegin, fname, - dump_header_format->fileblockbegin); - } else { - printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + begin_obj(dump_header_format->filebegin, fname, dump_header_format->fileblockbegin); + } + else { + HDfprintf(stdout, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); /* alternative first element, depending on schema or DTD. */ if (useschema) { if (strcmp(xmlnsprefix,"") == 0) { - printf("<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", - xml_dtd_uri); - } else { + HDfprintf(stdout, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", + xml_dtd_uri); + } + else { /* TO DO: make -url option work in this case (may need new option) */ - char * ns; + char *ns; char *indx; ns = HDstrdup(xmlnsprefix); indx = strrchr(ns,(int)':'); if (indx) *indx = '\0'; - printf("<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/DTDs/HDF5-File\" " - "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " - "xsi:schemaLocation=\"http://hdfgroup.org/DTDs/HDF5-File " - "http://www.hdfgroup.org/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns); + HDfprintf(stdout, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/DTDs/HDF5-File\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xsi:schemaLocation=\"http://hdfgroup.org/DTDs/HDF5-File " + "http://www.hdfgroup.org/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns); HDfree(ns); } - } else { - printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", - xml_dtd_uri); - printf("<HDF5-File>\n"); + } + else { + HDfprintf(stdout, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri); + HDfprintf(stdout, "<HDF5-File>\n"); } } @@ -4790,30 +4794,23 @@ main(int argc, const char *argv[]) dump_fcpl(fid); } - if(display_all) - { + if(display_all) { if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { error_msg("unable to open root group\n"); h5tools_setstatus(EXIT_FAILURE); } - else - { - + else { dump_function_table->dump_group_function(gid, "/" ); - } - if(H5Gclose(gid) < 0) - { + if(H5Gclose(gid) < 0) { error_msg("unable to close root group\n"); h5tools_setstatus(EXIT_FAILURE); } - } - else - { + else { /* Note: this option is not supported for XML */ if(doxml) { error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); @@ -4828,8 +4825,9 @@ main(int argc, const char *argv[]) if (!doxml) { end_obj(dump_header_format->fileend, dump_header_format->fileblockend); - } else { - printf("</%sHDF5-File>\n", xmlnsprefix); + } + else { + HDfprintf(stdout, "</%sHDF5-File>\n", xmlnsprefix); } done: @@ -4839,6 +4837,7 @@ done: if (H5Fclose(fid) < 0) h5tools_setstatus(EXIT_FAILURE); + if(hand) free_handler(hand, argc); HDfree(prefix); @@ -4868,30 +4867,30 @@ done: static void print_enum(hid_t type) { - char **name = NULL; /*member names */ - unsigned char *value = NULL; /*value array */ - unsigned char *copy = NULL; /*a pointer to value array */ - unsigned nmembs; /*number of members */ - int nchars; /*number of output characters */ - hid_t super; /*enum base integer type */ - hid_t native = -1; /*native integer datatype */ - size_t dst_size; /*destination value type size */ - unsigned i; - - nmembs = (unsigned)H5Tget_nmembers(type); + char **name = NULL; /*member names */ + unsigned char *value = NULL; /*value array */ + unsigned char *copy = NULL; /*a pointer to value array */ + unsigned nmembs; /*number of members */ + int nchars; /*number of output characters */ + hid_t super; /*enum base integer type */ + hid_t native = -1; /*native integer datatype */ + size_t dst_size; /*destination value type size */ + unsigned i; + + nmembs = (unsigned) H5Tget_nmembers(type); super = H5Tget_super(type); /* * Determine what datatype to use for the native values. To simplify * things we entertain three possibilities: * 1. long long -- the largest native signed integer - * 2. unsigned long long -- the largest native unsigned integer - * 3. raw format + * 2. unsigned long long -- the largest native unsigned integer + * 3. raw format */ - if(H5Tget_size(type) <= sizeof(long long)) { + if (H5Tget_size(type) <= sizeof(long long)) { dst_size = sizeof(long long); - if(H5T_SGN_NONE == H5Tget_sign(type)) + if (H5T_SGN_NONE == H5Tget_sign(type)) native = H5T_NATIVE_ULLONG; else native = H5T_NATIVE_LLONG; @@ -4900,12 +4899,12 @@ print_enum(hid_t type) dst_size = H5Tget_size(type); /* Get the names and raw values of all members */ - name = (char **)calloc(nmembs, sizeof(char *)); - value = (unsigned char *)calloc(nmembs, MAX(H5Tget_size(type), dst_size)); + name = (char **) calloc(nmembs, sizeof(char *)); + value = (unsigned char *) calloc(nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { - name[i] = H5Tget_member_name(type, i); - H5Tget_member_value(type, i, value + i * H5Tget_size(type)); + name[i] = H5Tget_member_name(type, i); + H5Tget_member_value(type, i, value + i * H5Tget_size(type)); } /* Convert values to native datatype */ @@ -4919,44 +4918,44 @@ print_enum(hid_t type) /* Print members */ for (i = 0; i < nmembs; i++) { - indentation(indent + COL); - nchars = printf("\"%s\"", name[i]); - printf("%*s ", MAX(0, 16 - nchars), ""); + indentation(indent + COL); + nchars = HDfprintf(stdout, "\"%s\"", name[i]); + HDfprintf(stdout, "%*s ", MAX(0, 16 - nchars), ""); - if (native < 0) { + if (native < 0) { size_t j; - printf("0x"); - - for (j = 0; j < dst_size; j++) - printf("%02x", value[i * dst_size + j]); - } else if (H5T_SGN_NONE == H5Tget_sign(native)) { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *) - ((void *)copy))); - } else { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", - *((long long *) ((void *)copy))); - } + HDfprintf(stdout, "0x"); + + for (j = 0; j < dst_size; j++) + HDfprintf(stdout, "%02x", value[i * dst_size + j]); + } + else if (H5T_SGN_NONE == H5Tget_sign(native)) { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value + i * dst_size; + HDfprintf(stdout, "%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *) ((void *) copy))); + } + else { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value + i * dst_size; + HDfprintf(stdout, "%" H5_PRINTF_LL_WIDTH "d", *((long long *) ((void *) copy))); + } - printf(";\n"); + HDfprintf(stdout, ";\n"); } /* Release resources */ for (i = 0; i < nmembs; i++) - free(name[i]); + free(name[i]); free(name); free(value); H5Tclose(super); if (0 == nmembs) - printf("\n%*s <empty>", indent + 4, ""); + HDfprintf(stdout, "\n%*s <empty>", indent + 4, ""); } @@ -4967,7 +4966,6 @@ print_enum(hid_t type) * 'gen'; 0 - return null if not found * 1 - generate a fake entry and return fake id. */ - int xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) { @@ -4984,16 +4982,19 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) objno = ref_path_table_gen_fake(str); sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno); return 0; - } else { + } + else { return 1; } } - } else { + } + else { if (gen) { objno = ref_path_table_gen_fake(str); sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno); return 0; - } else { + } + else { return 1; } } @@ -5027,38 +5028,42 @@ static const char *apos = "'"; static char * xml_escape_the_name(const char *str) { - size_t extra; - size_t len; - size_t i; - const char *cp; - char *ncp; - char *rcp; + size_t extra; + size_t len; + size_t i; + const char *cp; + char *ncp; + char *rcp; if (!str) - return NULL; + return NULL; cp = str; len = strlen(str); extra = 0; for (i = 0; i < len; i++) { - if (*cp == '\"') { - extra += (strlen(quote) - 1); - } else if (*cp == '\'') { - extra += (strlen(apos) - 1); - } else if (*cp == '<') { - extra += (strlen(lt) - 1); - } else if (*cp == '>') { - extra += (strlen(gt) - 1); - } else if (*cp == '&') { - extra += (strlen(amp) - 1); - } + if (*cp == '\"') { + extra += (strlen(quote) - 1); + } + else if (*cp == '\'') { + extra += (strlen(apos) - 1); + } + else if (*cp == '<') { + extra += (strlen(lt) - 1); + } + else if (*cp == '>') { + extra += (strlen(gt) - 1); + } + else if (*cp == '&') { + extra += (strlen(amp) - 1); + } - cp++; + cp++; } if (extra == 0) - return HDstrdup(str); + return HDstrdup(str); cp = str; rcp = ncp = (char *)HDmalloc(len + extra + 1); @@ -5071,23 +5076,28 @@ xml_escape_the_name(const char *str) strncpy(ncp, apos, strlen(apos)); ncp += strlen(apos); cp++; - } else if (*cp == '<') { + } + else if (*cp == '<') { strncpy(ncp, lt, strlen(lt)); ncp += strlen(lt); cp++; - } else if (*cp == '>') { + } + else if (*cp == '>') { strncpy(ncp, gt, strlen(gt)); ncp += strlen(gt); cp++; - } else if (*cp == '\"') { + } + else if (*cp == '\"') { strncpy(ncp, quote, strlen(quote)); ncp += strlen(quote); cp++; - } else if (*cp == '&') { + } + else if (*cp == '&') { strncpy(ncp, amp, strlen(amp)); ncp += strlen(amp); cp++; - } else { + } + else { *ncp++ = *cp++; } } @@ -5113,74 +5123,85 @@ xml_escape_the_name(const char *str) static char * xml_escape_the_string(const char *str, int slen) { - size_t extra; - size_t len; - size_t i; - const char *cp; - char *ncp; - char *rcp; + size_t extra; + size_t len; + size_t i; + const char *cp; + char *ncp; + char *rcp; if (!str) - return NULL; + return NULL; cp = str; if (slen < 0) - len = strlen(str); + len = strlen(str); else - len = slen; + len = slen; extra = 0; for (i = 0; i < len; i++) { - if (*cp == '\\') { - extra++; - } else if (*cp == '\"') { - extra++; - } else if (*cp == '\'') { - extra += (strlen(apos) - 1); - } else if (*cp == '<') { - extra += (strlen(lt) - 1); - } else if (*cp == '>') { - extra += (strlen(gt) - 1); - } else if (*cp == '&') { - extra += (strlen(amp) - 1); - } - cp++; + if (*cp == '\\') { + extra++; + } + else if (*cp == '\"') { + extra++; + } + else if (*cp == '\'') { + extra += (strlen(apos) - 1); + } + else if (*cp == '<') { + extra += (strlen(lt) - 1); + } + else if (*cp == '>') { + extra += (strlen(gt) - 1); + } + else if (*cp == '&') { + extra += (strlen(amp) - 1); + } + cp++; } cp = str; - rcp = ncp = (char *)calloc((len + extra + 1), sizeof(char)); + rcp = ncp = (char *) calloc((len + extra + 1), sizeof(char)); if (ncp == NULL) - return NULL; /* ?? */ + return NULL; /* ?? */ for (i = 0; i < len; i++) { - if (*cp == '\\') { - *ncp++ = '\\'; - *ncp++ = *cp++; - } else if (*cp == '\"') { - *ncp++ = '\\'; - *ncp++ = *cp++; - } else if (*cp == '\'') { - strncpy(ncp, apos, strlen(apos)); - ncp += strlen(apos); - cp++; - } else if (*cp == '<') { - strncpy(ncp, lt, strlen(lt)); - ncp += strlen(lt); - cp++; - } else if (*cp == '>') { - strncpy(ncp, gt, strlen(gt)); - ncp += strlen(gt); - cp++; - } else if (*cp == '&') { - strncpy(ncp, amp, strlen(amp)); - ncp += strlen(amp); - cp++; - } else { - *ncp++ = *cp++; - } + if (*cp == '\\') { + *ncp++ = '\\'; + *ncp++ = *cp++; + } + else if (*cp == '\"') { + *ncp++ = '\\'; + *ncp++ = *cp++; + } + else if (*cp == '\'') { + strncpy(ncp, apos, strlen(apos)); + ncp += strlen(apos); + cp++; + } + else if (*cp == '<') { + strncpy(ncp, lt, strlen(lt)); + ncp += strlen(lt); + cp++; + } + else if (*cp == '>') { + strncpy(ncp, gt, strlen(gt)); + ncp += strlen(gt); + cp++; + } + else if (*cp == '&') { + strncpy(ncp, amp, strlen(amp)); + ncp += strlen(amp); + cp++; + } + else { + *ncp++ = *cp++; + } } *ncp = '\0'; @@ -5248,327 +5269,336 @@ xml_print_datatype(hid_t type, unsigned in_group) if (!found_obj->recorded) { /* 'anonymous' NDT. Use it's object num. as it's name. */ - printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n", + HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n", xmlnsprefix, dtxid); - } else { + } + else { /* point to the NDT by name */ char *t_objname = xml_escape_the_name(found_obj->objname); - printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", + HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", xmlnsprefix, dtxid, t_objname); free(t_objname); } free(dtxid); - } else { - printf("<!-- h5dump error: unknown committed type. -->\n"); + } + else { + HDfprintf(stdout, "<!-- h5dump error: unknown committed type. -->\n"); h5tools_setstatus(EXIT_FAILURE); } - } else { + } + else { switch (H5Tget_class(type)) { - case H5T_INTEGER: - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */ - ord = H5Tget_order(type); - sgn = H5Tget_sign(type); - indentation(indent); - printf("<%sIntegerType ByteOrder=\"",xmlnsprefix); - switch (ord) { - case H5T_ORDER_LE: - printf("LE"); - break; - case H5T_ORDER_BE: - printf("BE"); - break; - case H5T_ORDER_VAX: - default: - printf("ERROR_UNKNOWN"); - } - printf("\" Sign=\""); - switch (sgn) { - case H5T_SGN_NONE: - printf("false"); - break; - case H5T_SGN_2: - printf("true"); - break; - default: - printf("ERROR_UNKNOWN"); - } - printf("\" Size=\""); - sz = H5Tget_size(type); - printf("%lu", (unsigned long)sz); - printf("\" />\n"); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); + case H5T_INTEGER: + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */ + ord = H5Tget_order(type); + sgn = H5Tget_sign(type); + indentation(indent); + HDfprintf(stdout, "<%sIntegerType ByteOrder=\"",xmlnsprefix); + switch (ord) { + case H5T_ORDER_LE: + HDfprintf(stdout, "LE"); break; - - case H5T_FLOAT: - /* <hdf5:FloatType ByteOrder="bo" Size="bytes" - SignBitLocation="bytes" - ExponentBits="eb" ExponentLocation="el" - MantissaBits="mb" MantissaLocation="ml" /> */ - ord = H5Tget_order(type); - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sFloatType ByteOrder=\"",xmlnsprefix); - switch (ord) { - case H5T_ORDER_LE: - printf("LE"); - break; - case H5T_ORDER_BE: - printf("BE"); - break; - case H5T_ORDER_VAX: - printf("VAX"); - break; - default: - printf("ERROR_UNKNOWN"); - } - printf("\" Size=\""); - sz = H5Tget_size(type); - printf("%lu", (unsigned long)sz); - H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize); - printf("\" SignBitLocation=\"%lu\" ", (unsigned long)spos); - printf("ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos); - printf("MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />\n", - (unsigned long)msize, (unsigned long)mpos); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); + case H5T_ORDER_BE: + HDfprintf(stdout, "BE"); break; - - case H5T_TIME: - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sTimeType />\n",xmlnsprefix); - printf("<!-- H5T_TIME: not yet implemented -->"); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); + case H5T_ORDER_VAX: + default: + HDfprintf(stdout, "ERROR_UNKNOWN"); + } + + HDfprintf(stdout, "\" Sign=\""); + + switch (sgn) { + case H5T_SGN_NONE: + HDfprintf(stdout, "false"); break; - - case H5T_STRING: - /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */ - size = H5Tget_size(type); - str_pad = H5Tget_strpad(type); - cset = H5Tget_cset(type); - is_vlstr = H5Tis_variable_str(type); - - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sStringType Cset=\"",xmlnsprefix); - if (cset == H5T_CSET_ASCII) { - printf("H5T_CSET_ASCII\" "); - } else { - printf("unknown_cset\" "); - } - if(is_vlstr) - printf("StrSize=\"H5T_VARIABLE\" StrPad=\""); - else - printf("StrSize=\"%d\" StrPad=\"", (int) size); - if (str_pad == H5T_STR_NULLTERM) { - printf("H5T_STR_NULLTERM\"/>\n"); - } else if (str_pad == H5T_STR_NULLPAD) { - printf("H5T_STR_NULLPAD\"/>\n"); - } else if (str_pad == H5T_STR_SPACEPAD) { - printf("H5T_STR_SPACEPAD\"/>\n"); - } else { - printf("H5T_STR_ERROR\"/>\n"); - } - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); + case H5T_SGN_2: + HDfprintf(stdout, "true"); break; + default: + HDfprintf(stdout, "ERROR_UNKNOWN"); + } + + HDfprintf(stdout, "\" Size=\""); + sz = H5Tget_size(type); + HDfprintf(stdout, "%lu", (unsigned long)sz); + HDfprintf(stdout, "\" />\n"); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - case H5T_BITFIELD: - /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */ - ord = H5Tget_order(type); - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sBitfieldType ByteOrder=\"",xmlnsprefix); - switch (ord) { - case H5T_ORDER_LE: - printf("LE"); - break; - case H5T_ORDER_BE: - printf("BE"); - break; - case H5T_ORDER_VAX: - default: - printf("ERROR_UNKNOWN"); - } - size = H5Tget_size(type); - printf("\" Size=\"%lu\"/>\n", (unsigned long)size); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); + case H5T_FLOAT: + /* <hdf5:FloatType ByteOrder="bo" Size="bytes" + SignBitLocation="bytes" + ExponentBits="eb" ExponentLocation="el" + MantissaBits="mb" MantissaLocation="ml" /> */ + ord = H5Tget_order(type); + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sFloatType ByteOrder=\"",xmlnsprefix); + + switch (ord) { + case H5T_ORDER_LE: + HDfprintf(stdout, "LE"); break; - - case H5T_OPAQUE: - /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */ - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - mname = H5Tget_tag(type); - printf("<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname); - free(mname); - size = H5Tget_size(type); - printf("Size=\"%lu\"/>\n", (unsigned long)size); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); + case H5T_ORDER_BE: + HDfprintf(stdout, "BE"); break; + case H5T_ORDER_VAX: + HDfprintf(stdout, "VAX"); + break; + default: + HDfprintf(stdout, "ERROR_UNKNOWN"); + } + + HDfprintf(stdout, "\" Size=\""); + sz = H5Tget_size(type); + HDfprintf(stdout, "%lu", (unsigned long)sz); + H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize); + HDfprintf(stdout, "\" SignBitLocation=\"%lu\" ", (unsigned long)spos); + HDfprintf(stdout, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos); + HDfprintf(stdout, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />\n", (unsigned long)msize, (unsigned long)mpos); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - case H5T_COMPOUND: - /* recursively describe the components of a compound datatype */ + case H5T_TIME: + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sTimeType />\n",xmlnsprefix); + HDfprintf(stdout, "<!-- H5T_TIME: not yet implemented -->"); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - /* type of a dataset */ - nmembers = H5Tget_nmembers(type); + case H5T_STRING: + /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */ + size = H5Tget_size(type); + str_pad = H5Tget_strpad(type); + cset = H5Tget_cset(type); + is_vlstr = H5Tis_variable_str(type); - indentation(indent); - printf("<%sCompoundType>\n",xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sStringType Cset=\"",xmlnsprefix); + if (cset == H5T_CSET_ASCII) { + HDfprintf(stdout, "H5T_CSET_ASCII\" "); + } + else { + HDfprintf(stdout, "unknown_cset\" "); + } + if(is_vlstr) + HDfprintf(stdout, "StrSize=\"H5T_VARIABLE\" StrPad=\""); + else + HDfprintf(stdout, "StrSize=\"%d\" StrPad=\"", (int) size); + if (str_pad == H5T_STR_NULLTERM) { + HDfprintf(stdout, "H5T_STR_NULLTERM\"/>\n"); + } + else if (str_pad == H5T_STR_NULLPAD) { + HDfprintf(stdout, "H5T_STR_NULLPAD\"/>\n"); + } + else if (str_pad == H5T_STR_SPACEPAD) { + HDfprintf(stdout, "H5T_STR_SPACEPAD\"/>\n"); + } + else { + HDfprintf(stdout, "H5T_STR_ERROR\"/>\n"); + } + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - /* List each member Field of the type */ - /* <hdf5:Field FieldName="name" > */ - /* <hdf5:DataType > */ - indent += COL; - for (i = 0; i < nmembers; i++) { - char *t_fname; + case H5T_BITFIELD: + /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */ + ord = H5Tget_order(type); + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sBitfieldType ByteOrder=\"",xmlnsprefix); + + switch (ord) { + case H5T_ORDER_LE: + HDfprintf(stdout, "LE"); + break; + case H5T_ORDER_BE: + HDfprintf(stdout, "BE"); + break; + case H5T_ORDER_VAX: + default: + HDfprintf(stdout, "ERROR_UNKNOWN"); + } + + size = H5Tget_size(type); + HDfprintf(stdout, "\" Size=\"%lu\"/>\n", (unsigned long)size); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - mname = H5Tget_member_name(type, i); - mtype = H5Tget_member_type(type, i); - indentation(indent); - t_fname = xml_escape_the_name(mname); - printf("<%sField FieldName=\"%s\">\n",xmlnsprefix, t_fname); + case H5T_OPAQUE: + /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */ + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + mname = H5Tget_tag(type); + HDfprintf(stdout, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname); + free(mname); + size = H5Tget_size(type); + HDfprintf(stdout, "Size=\"%lu\"/>\n", (unsigned long)size); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - free(mname); - free(t_fname); - indent += COL; - indentation(indent); - printf("<%sDataType>\n",xmlnsprefix); - indent += COL; - xml_print_datatype(mtype,0); - indent -= COL; - indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); - indent -= COL; + case H5T_COMPOUND: + /* recursively describe the components of a compound datatype */ - indentation(indent); - printf("</%sField>\n",xmlnsprefix); - } - indent -= COL; - indentation(indent); - printf("</%sCompoundType>\n",xmlnsprefix); - break; + /* type of a dataset */ + nmembers = H5Tget_nmembers(type); - case H5T_REFERENCE: - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - /* Only Object references supported at this time */ - printf("<%sReferenceType>\n",xmlnsprefix); - indentation(indent + COL); - printf("<%sObjectReferenceType />\n",xmlnsprefix); - indentation(indent); - printf("</%sReferenceType>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; + indentation(indent); + HDfprintf(stdout, "<%sCompoundType>\n",xmlnsprefix); - case H5T_ENUM: - /* <hdf5:EnumType Nelems="ne" > - list Name, values of enum - */ - nmembs = H5Tget_nmembers(type); - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sEnumType Nelems=\"%d\">\n",xmlnsprefix, nmembs); - xml_print_enum(type); - indentation(indent); - printf("</%sEnumType>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; + /* List each member Field of the type */ + /* <hdf5:Field FieldName="name" > */ + /* <hdf5:DataType > */ + indent += COL; + for (i = 0; i < nmembers; i++) { + char *t_fname; - case H5T_VLEN: + mname = H5Tget_member_name(type, i); + mtype = H5Tget_member_type(type, i); indentation(indent); - printf("<%sVLType>\n",xmlnsprefix); - super = H5Tget_super(type); + t_fname = xml_escape_the_name(mname); + HDfprintf(stdout, "<%sField FieldName=\"%s\">\n",xmlnsprefix, t_fname); + + free(mname); + free(t_fname); indent += COL; indentation(indent); - printf("<%sDataType>\n",xmlnsprefix); + HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix); indent += COL; - xml_print_datatype(super,0); + xml_print_datatype(mtype,0); indent -= COL; indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); + HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix); indent -= COL; + indentation(indent); - printf("</%sVLType>\n",xmlnsprefix); - H5Tclose(super); + HDfprintf(stdout, "</%sField>\n",xmlnsprefix); + } + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sCompoundType>\n",xmlnsprefix); + break; - break; + case H5T_REFERENCE: + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + /* Only Object references supported at this time */ + HDfprintf(stdout, "<%sReferenceType>\n",xmlnsprefix); + indentation(indent + COL); + HDfprintf(stdout, "<%sObjectReferenceType />\n",xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "</%sReferenceType>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - case H5T_ARRAY: - /* Get array base type */ - super = H5Tget_super(type); + case H5T_ENUM: + /* <hdf5:EnumType Nelems="ne" > list Name, values of enum */ + nmembs = H5Tget_nmembers(type); + indentation(indent); + HDfprintf(stdout, "<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sEnumType Nelems=\"%d\">\n",xmlnsprefix, nmembs); + xml_print_enum(type); + indentation(indent); + HDfprintf(stdout, "</%sEnumType>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sAtomicType>\n",xmlnsprefix); + break; - /* Print lead-in */ - indentation(indent); - printf("<%sArrayType Ndims=\"",xmlnsprefix); - ndims = H5Tget_array_ndims(type); - printf("%u\">\n", ndims); + case H5T_VLEN: + indentation(indent); + HDfprintf(stdout, "<%sVLType>\n",xmlnsprefix); + super = H5Tget_super(type); + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix); + indent += COL; + xml_print_datatype(super,0); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sVLType>\n",xmlnsprefix); + H5Tclose(super); - /* Get array information */ - H5Tget_array_dims2(type, dims); + break; - /* list of dimensions */ - indent += COL; - for (i = 0; i < ndims; i++) { - indentation(indent); - printf("<%sArrayDimension DimSize=\"%u\"/>\n", - xmlnsprefix, - (int) dims[i]); - } - indent -= COL; + case H5T_ARRAY: + /* Get array base type */ + super = H5Tget_super(type); - indent += COL; - indentation(indent); - printf("<%sDataType>\n",xmlnsprefix); - indent += COL; - xml_print_datatype(super,0); - indent -= COL; - indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); - indent -= COL; + /* Print lead-in */ + indentation(indent); + HDfprintf(stdout, "<%sArrayType Ndims=\"",xmlnsprefix); + ndims = H5Tget_array_ndims(type); + HDfprintf(stdout, "%u\">\n", ndims); + + /* Get array information */ + H5Tget_array_dims2(type, dims); + + /* list of dimensions */ + indent += COL; + for (i = 0; i < ndims; i++) { indentation(indent); - printf("</%sArrayType>\n",xmlnsprefix); - /* Close array base type */ - H5Tclose(super); - break; + HDfprintf(stdout, "<%sArrayDimension DimSize=\"%u\"/>\n", xmlnsprefix, (int) dims[i]); + } + indent -= COL; - default: - printf("<!-- unknown datatype -->"); - h5tools_setstatus(EXIT_FAILURE); - break; + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix); + indent += COL; + xml_print_datatype(super,0); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + HDfprintf(stdout, "</%sArrayType>\n",xmlnsprefix); + /* Close array base type */ + H5Tclose(super); + break; + + default: + HDfprintf(stdout, "<!-- unknown datatype -->"); + h5tools_setstatus(EXIT_FAILURE); + break; } } /* end else */ } @@ -5589,7 +5619,6 @@ xml_print_datatype(hid_t type, unsigned in_group) static void xml_dump_datatype(hid_t type) { - indent += COL; indentation(indent); @@ -5604,7 +5633,7 @@ xml_dump_datatype(hid_t type) if(found_obj) { /* Shared datatype, must be entered as an object */ /* These 2 cases are the same now, but may change */ - char * dtxid = (char *)malloc(100); + char *dtxid = (char *)malloc(100); xml_name_to_XID(found_obj->objname, dtxid, 100, 1); if (!found_obj->recorded) { @@ -5613,29 +5642,31 @@ xml_dump_datatype(hid_t type) practice: use it's object ref as its name */ - printf("<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n", + HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n", xmlnsprefix, dtxid); - } else { + } + else { /* pointer to a named datatype already in XML */ char *t_objname = xml_escape_the_name(found_obj->objname); - printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n", + HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n", xmlnsprefix, dtxid, t_objname); free(t_objname); } free(dtxid); - } else { - printf("<!-- h5dump error: unknown committed type. -->\n"); + } + else { + HDfprintf(stdout, "<!-- h5dump error: unknown committed type. -->\n"); } indent -= COL; } else { - printf("<%sDataType>\n", xmlnsprefix); + HDfprintf(stdout, "<%sDataType>\n", xmlnsprefix); indent += COL; xml_print_datatype(type, 0); indent -= COL; indentation(indent); - printf("</%sDataType>\n", xmlnsprefix); + HDfprintf(stdout, "</%sDataType>\n", xmlnsprefix); indent -= COL; } } @@ -5656,64 +5687,63 @@ xml_dump_datatype(hid_t type) static void xml_dump_dataspace(hid_t space) { - hsize_t size[H5DUMP_MAX_RANK]; - hsize_t maxsize[H5DUMP_MAX_RANK]; - int ndims = - H5Sget_simple_extent_dims(space, size, maxsize); - H5S_class_t space_type = H5Sget_simple_extent_type(space); - int i; + hsize_t size[H5DUMP_MAX_RANK]; + hsize_t maxsize[H5DUMP_MAX_RANK]; + int i; + + int ndims = H5Sget_simple_extent_dims(space, size, maxsize); + H5S_class_t space_type = H5Sget_simple_extent_type(space); indentation(indent + COL); - printf("<%sDataspace>\n", xmlnsprefix); + HDfprintf(stdout, "<%sDataspace>\n", xmlnsprefix); indentation(indent + COL + COL); switch (space_type) { - case H5S_SCALAR: - /* scalar dataspace (just a tag, no XML attrs. defined */ - printf("<%sScalarDataspace />\n",xmlnsprefix); - break; + case H5S_SCALAR: + /* scalar dataspace (just a tag, no XML attrs. defined */ + HDfprintf(stdout, "<%sScalarDataspace />\n",xmlnsprefix); + break; - case H5S_SIMPLE: - /* simple dataspace */ - /* <hdf5:SimpleDataspace Ndims="nd"> */ - printf("<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); + case H5S_SIMPLE: + /* simple dataspace */ + /* <hdf5:SimpleDataspace Ndims="nd"> */ + HDfprintf(stdout, "<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); - /* print the <hdf5:Dimension> elements */ - for (i = 0; i < ndims; i++) { - indentation(indent + COL + COL + COL); - if (maxsize[i] == H5S_UNLIMITED) { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"UNLIMITED\"/>\n", - xmlnsprefix,size[i]); - } else if (maxsize[i] == (hsize_t) 0) { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", - xmlnsprefix,size[i], size[i]); - } else { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", - xmlnsprefix, size[i], maxsize[i]); - } + /* print the <hdf5:Dimension> elements */ + for (i = 0; i < ndims; i++) { + indentation(indent + COL + COL + COL); + if (maxsize[i] == H5S_UNLIMITED) { + HDfprintf(stdout, "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"UNLIMITED\"/>\n", + xmlnsprefix,size[i]); + } + else if (maxsize[i] == (hsize_t) 0) { + HDfprintf(stdout, "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", + xmlnsprefix,size[i], size[i]); + } + else { + HDfprintf(stdout, "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", + xmlnsprefix, size[i], maxsize[i]); } - indentation(indent + COL + COL); - printf("</%sSimpleDataspace>\n", xmlnsprefix ); - break; + } + indentation(indent + COL + COL); + HDfprintf(stdout, "</%sSimpleDataspace>\n", xmlnsprefix ); + break; #ifdef TMP /* Commented out: wait until the schema is updated first */ - case H5S_NULL: - /* null dataspace (just a tag, no XML attrs. defined */ - printf("<%sNullDataspace />\n",xmlnsprefix); - break; + case H5S_NULL: + /* null dataspace (just a tag, no XML attrs. defined */ + HDfprintf(stdout, "<%sNullDataspace />\n",xmlnsprefix); + break; #endif /* TMP */ - case H5S_NO_CLASS: - default: - printf("<!-- unknown dataspace -->\n"); + case H5S_NO_CLASS: + default: + HDfprintf(stdout, "<!-- unknown dataspace -->\n"); } indentation(indent + COL); - printf("</%sDataspace>\n", xmlnsprefix); + HDfprintf(stdout, "</%sDataspace>\n", xmlnsprefix); } /*------------------------------------------------------------------------- @@ -5734,17 +5764,20 @@ xml_dump_dataspace(hid_t space) static void xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNUSED pindex) { - h5tool_format_t *outputformat = &xml_dataformat; - int status = -1; - void *buf; - hid_t space, type, p_type; - int ndims, i; - hsize_t size[64], nelmts = 1; - int depth; - int stdindent = COL; /* should be 3 */ - - if (fp_format) - { + hid_t space; + hid_t type; + hid_t p_type; + hsize_t size[64]; + hsize_t nelmts = 1; + int ndims; + int i; + int depth; + int status = -1; + int stdindent = COL; /* should be 3 */ + h5tool_format_t *outputformat = &xml_dataformat; + void *buf = NULL; + + if (fp_format) { outputformat->fmt_double = fp_format; outputformat->fmt_float = fp_format; } @@ -5767,19 +5800,22 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU /* Print all the values. */ indentation(indent); - printf("<%sData>\n", xmlnsprefix); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); indentation(indent + COL); - printf("<%sDataFromFile>\n",xmlnsprefix); + HDfprintf(stdout, "<%sDataFromFile>\n",xmlnsprefix); if (obj_data == DATASET_DATA) { type = H5Dget_type(obj_id); if (H5Tget_class(type) == H5T_REFERENCE) { status = xml_print_refs(obj_id, DATASET_DATA); - } else if (H5Tget_class(type) == H5T_STRING) { + } + else if (H5Tget_class(type) == H5T_STRING) { status = xml_print_strs(obj_id, DATASET_DATA); - } else { + } + else { status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, NULL, depth); } - } else { + } + else { /* Attribute data */ type = H5Aget_type(obj_id); @@ -5791,16 +5827,20 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU */ status = xml_print_refs(obj_id, ATTRIBUTE_DATA); H5Tclose(type); - } else if (H5Tget_class(type) == H5T_STRING) { + } + else if (H5Tget_class(type) == H5T_STRING) { status = xml_print_strs(obj_id, ATTRIBUTE_DATA); - } else { /* all other data */ + } + else { /* all other data */ /* VL data special information */ unsigned int vl_data = 0; /* contains VL datatypes */ p_type = h5tools_get_native_type(type); /* Check if we have VL data in the dataset's datatype */ - if (h5tools_detect_vlen(p_type) == TRUE) + if (h5tools_detect_vlen_str(p_type) == TRUE) + vl_data = TRUE; + if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE) vl_data = TRUE; H5Tclose(type); @@ -5816,8 +5856,7 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU assert(buf); if (H5Aread(obj_id, p_type, buf) >= 0) - status = h5tools_dump_mem(stdout, outputformat, obj_id, - p_type, space, buf, depth); + status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, space, buf, depth); /* Reclaim any VL memory, if necessary */ if (vl_data) @@ -5832,14 +5871,14 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU if (status == FAIL) { indentation(indent + COL); - printf("Unable to print data.\n"); + HDfprintf(stdout, "Unable to print data.\n"); status = 1; } indentation(indent + COL); - printf("</%sDataFromFile>\n",xmlnsprefix); + HDfprintf(stdout, "</%sDataFromFile>\n",xmlnsprefix); indentation(indent); - printf("</%sData>\n", xmlnsprefix); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); indent -= COL; } @@ -5860,12 +5899,15 @@ static herr_t xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t UNUSED *info, void UNUSED * op_data) { - hid_t attr_id, type, space; + hid_t attr_id; + hid_t type; + hid_t space; H5S_class_t space_type; - char *t_aname = xml_escape_the_name(attr_name); + + char *t_aname = xml_escape_the_name(attr_name); indentation(indent); - printf("<%sAttribute Name=\"%s\">\n",xmlnsprefix, t_aname); + HDfprintf(stdout, "<%sAttribute Name=\"%s\">\n", xmlnsprefix, t_aname); free(t_aname); if ((attr_id = H5Aopen(attr, attr_name, H5P_DEFAULT)) >= 0) { @@ -5876,95 +5918,98 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t UNUSED *info, dump_function_table->dump_dataspace_function(space); dump_function_table->dump_datatype_function(type); - if (display_attr_data && space_type!=H5S_NULL) { + if (display_attr_data && space_type != H5S_NULL) { switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; - case H5T_TIME: - indent += COL; - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Time data not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("<hdf5:Data>\n"); - printf("</%sData>\n",xmlnsprefix); - indent -= COL; - break; + case H5T_TIME: + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "<!-- Time data not yet implemented. -->\n"); + indentation(indent); + HDfprintf(stdout, "<%sNoData/>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "<hdf5:Data>\n"); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); + indent -= COL; + break; - case H5T_COMPOUND: - indentation(indent); - printf("<!-- Note: format of compound data not specified -->\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; + case H5T_COMPOUND: + indentation(indent); + HDfprintf(stdout, "<!-- Note: format of compound data not specified -->\n"); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; - case H5T_REFERENCE: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); + case H5T_REFERENCE: + indentation(indent); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); + indentation(indent); + if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + HDfprintf(stdout, "<!-- Note: Region references not supported -->\n"); indentation(indent); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - printf("<!-- Note: Region references not supported -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(attr_id, ATTRIBUTE_DATA); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - } + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + } + else { + HDfprintf(stdout, "<%sDataFromFile>\n", xmlnsprefix); + xml_print_refs(attr_id, ATTRIBUTE_DATA); indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; + HDfprintf(stdout, "</%sDataFromFile>\n", xmlnsprefix); + } + indentation(indent); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); + break; - case H5T_VLEN: - printf("<!-- Note: format of VL data not specified -->\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - default: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; + case H5T_VLEN: + HDfprintf(stdout, "<!-- Note: format of VL data not specified -->\n"); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + default: + indentation(indent); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + HDfprintf(stdout, "<%sNoData/>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); + break; } - } else { + } + else { /* The case of an attribute never yet written ?? - * Or dataspace is H5S_NULL. */ + * Or dataspace is H5S_NULL. */ indentation(indent + COL); - printf("<%sData>\n",xmlnsprefix); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); indentation(indent + COL + COL); - printf("<%sNoData/>\n",xmlnsprefix); + HDfprintf(stdout, "<%sNoData/>\n", xmlnsprefix); indentation(indent + COL); - printf("</%sData>\n",xmlnsprefix); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); } H5Tclose(type); H5Sclose(space); H5Aclose(attr_id); indentation(indent); - printf("</%sAttribute>\n", xmlnsprefix ); + HDfprintf(stdout, "</%sAttribute>\n", xmlnsprefix); return SUCCEED; - } else { + } + else { /* ?? failed */ indentation(indent + COL); - printf("<!-- h5dump error: unable to open attribute. -->\n"); + HDfprintf(stdout, "<!-- h5dump error: unable to open attribute. -->\n"); indentation(indent); - printf("</%sAttribute>\n", xmlnsprefix ); + HDfprintf(stdout, "</%sAttribute>\n", xmlnsprefix); h5tools_setstatus(EXIT_FAILURE); return FAIL; } @@ -5986,12 +6031,12 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t UNUSED *info, static void xml_dump_named_datatype(hid_t type, const char *name) { - char *tmp; - char * dtxid; - char * parentxid; - char *t_tmp; - char *t_prefix; - char *t_name; + char *tmp; + char *dtxid; + char *parentxid; + char *t_tmp; + char *t_prefix; + char *t_name; tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); @@ -6016,15 +6061,16 @@ xml_dump_named_datatype(hid_t type, const char *name) in the event we want to do something else in the future. */ - printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + HDfprintf(stdout, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix, name, dtxid, parentxid, HDstrcmp(prefix,"") ? t_prefix : "/"); - } else { + } + else { H5O_info_t oinfo; /* Object info */ - printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + HDfprintf(stdout, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix, t_name, dtxid, @@ -6040,11 +6086,11 @@ xml_dump_named_datatype(hid_t type, const char *name) if (found_obj == NULL) { indentation(indent); - error_msg("internal error (file %s:line %d)\n", - __FILE__, __LINE__); + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; - } else if(found_obj->displayed) { + } + else if(found_obj->displayed) { /* We have already printed this named datatype, print it as a * NamedDatatypePtr */ @@ -6053,31 +6099,31 @@ xml_dump_named_datatype(hid_t type, const char *name) indentation(indent + COL); xml_name_to_XID(found_obj->objname, pointerxid, sizeof(pointerxid), 1); - printf("<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", - xmlnsprefix, pointerxid, t_objname); + HDfprintf(stdout, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", xmlnsprefix, pointerxid, t_objname); indentation(indent); - printf("</%sNamedDataType>\n", xmlnsprefix); + HDfprintf(stdout, "</%sNamedDataType>\n", xmlnsprefix); HDfree(t_objname); goto done; - } else + } + else found_obj->displayed = TRUE; } } indent += COL; indentation(indent); - printf("<%sDataType>\n",xmlnsprefix); + HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix); indent += COL; xml_print_datatype(type,1); indent -= COL; indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); + HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix); indent -= COL; indentation(indent); - printf("</%sNamedDataType>\n",xmlnsprefix); + HDfprintf(stdout, "</%sNamedDataType>\n",xmlnsprefix); done: HDfree(dtxid); @@ -6107,34 +6153,32 @@ static void xml_dump_group(hid_t gid, const char *name) { H5O_info_t oinfo; - char *cp; + hid_t gcpl_id; hid_t dset, type; - char type_name[1024], *tmp = NULL; - char *par = NULL; - int isRoot = 0; - char *t_objname; - char *par_name; unsigned crt_order_flags; unsigned attr_crt_order_flags; - hid_t gcpl_id; + int isRoot = 0; + char type_name[1024]; + char *t_objname = NULL; + char *par_name = NULL; + char *cp = NULL; + char *tmp = NULL; + char *par = NULL; - if ((gcpl_id = H5Gget_create_plist(gid)) < 0) - { + if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { error_msg("error in getting group creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } /* query the group creation properties for attributes */ - if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0) - { + if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0) { error_msg("error in getting group creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) - { + if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { error_msg("error in getting group creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -6147,7 +6191,8 @@ xml_dump_group(hid_t gid, const char *name) if(HDstrcmp(name, "/") == 0) { isRoot = 1; tmp = HDstrdup("/"); - } else { + } + else { tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); par = HDstrdup(tmp); @@ -6173,10 +6218,10 @@ xml_dump_group(hid_t gid, const char *name) if (found_obj == NULL) { indentation(indent); - error_msg("internal error (file %s:line %d)\n", - __FILE__, __LINE__); + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); - } else { + } + else { char *t_name = xml_escape_the_name(name); char *grpxid = (char *)malloc(100); char *parentxid = (char *)malloc(100); @@ -6188,14 +6233,15 @@ xml_dump_group(hid_t gid, const char *name) if(isRoot) { /* probably can't happen! */ xml_name_to_XID("/", grpxid, 100, 1); - printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", + HDfprintf(stdout, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", xmlnsprefix, grpxid, "/"); - } else { + } + else { t_objname = xml_escape_the_name(found_obj->objname); par_name = xml_escape_the_name(par); xml_name_to_XID(tmp, grpxid, 100, 1); xml_name_to_XID(par, parentxid, 100, 1); - printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" " + HDfprintf(stdout, "<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix,t_name, grpxid, get_next_xid(), t_objname, parentxid, par_name); @@ -6207,7 +6253,7 @@ xml_dump_group(hid_t gid, const char *name) par_name = xml_escape_the_name(par); xml_name_to_XID(found_obj->objname, ptrstr, 100, 1); xml_name_to_XID(par, parentxid, 100, 1); - printf("<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" " + HDfprintf(stdout, "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", xmlnsprefix, ptrstr, t_objname, parentxid, par_name); @@ -6215,20 +6261,22 @@ xml_dump_group(hid_t gid, const char *name) free(par_name); } free(ptrstr); - } else { + } + else { /* first time this group has been seen -- describe it */ if(isRoot) { xml_name_to_XID("/", grpxid, 100, 1); - printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", + HDfprintf(stdout, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", xmlnsprefix, grpxid, "/"); - } else { + } + else { char *t_tmp = xml_escape_the_name(tmp); par_name = xml_escape_the_name(par); xml_name_to_XID(tmp, grpxid, 100, 1); xml_name_to_XID(par, parentxid, 100, 1); - printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " + HDfprintf(stdout, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\" >\n", xmlnsprefix,t_name, grpxid, t_tmp, parentxid, par_name); free(t_tmp); @@ -6280,7 +6328,8 @@ xml_dump_group(hid_t gid, const char *name) free(grpxid); free(parentxid); } - } else { + } + else { /* only link -- must be first time! */ char *t_name = xml_escape_the_name(name); @@ -6289,18 +6338,17 @@ xml_dump_group(hid_t gid, const char *name) if(isRoot) { xml_name_to_XID("/", grpxid, 100, 1); - printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", - xmlnsprefix, grpxid, "/"); - } else { + HDfprintf(stdout, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", xmlnsprefix, grpxid, "/"); + } + else { char *t_tmp = xml_escape_the_name(tmp); par_name = xml_escape_the_name(par); xml_name_to_XID(tmp, grpxid, 100, 1); xml_name_to_XID(par, parentxid, 100, 1); - printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " + HDfprintf(stdout, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\" >\n", - xmlnsprefix, t_name, grpxid, t_tmp, - parentxid, par_name); + xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name); free(t_tmp); free(par_name); } @@ -6342,7 +6390,7 @@ xml_dump_group(hid_t gid, const char *name) /* iterate through all the links */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) + if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL); else H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL); @@ -6351,9 +6399,12 @@ xml_dump_group(hid_t gid, const char *name) indent -= COL; indentation(indent); if(isRoot) - printf("</%sRootGroup>\n", xmlnsprefix); + HDfprintf(stdout, "</%sRootGroup>\n", xmlnsprefix); else - printf("</%sGroup>\n" , xmlnsprefix); + HDfprintf(stdout, "</%sGroup>\n" , xmlnsprefix); + if(par) + free(par); + if(tmp) free(tmp); } @@ -6373,13 +6424,14 @@ xml_dump_group(hid_t gid, const char *name) static int xml_print_refs(hid_t did, int source) { - herr_t e; - hid_t type, space; - char *buf = NULL; + herr_t e; + hid_t type; + hid_t space; + hssize_t ssiz; + hsize_t i; + size_t tsiz; hobj_ref_t *refbuf = NULL; - hssize_t ssiz; - hsize_t i; - size_t tsiz; + char *buf = NULL; if (source == DATASET_DATA) { type = H5Dget_type(did); @@ -6437,18 +6489,16 @@ xml_print_refs(hid_t did, int source) refbuf = (hobj_ref_t *) buf; for (i = 0; i < ssiz; i++) { - const char *path; - - path = lookup_ref_path(*refbuf); + const char *path = lookup_ref_path(*refbuf); indentation(indent + COL); if (!path) { - printf("\"%s\"\n", "NULL"); + HDfprintf(stdout, "\"%s\"\n", "NULL"); } else { char *t_path = xml_escape_the_string(path, -1); - printf("\"%s\"\n", t_path); + HDfprintf(stdout, "\"%s\"\n", t_path); free(t_path); } @@ -6487,16 +6537,17 @@ error: static int xml_print_strs(hid_t did, int source) { - herr_t e; - hid_t type, space; - void *buf = NULL; - char *bp; - char *onestring = NULL; - hssize_t ssiz; - size_t tsiz; - size_t str_size = 0; - size_t i; - htri_t is_vlstr; + herr_t e; + hid_t type; + hid_t space; + hssize_t ssiz; + htri_t is_vlstr = FALSE; + size_t tsiz; + size_t i; + size_t str_size = 0; + char *bp = NULL; + char *onestring = NULL; + void *buf = NULL; if (source == DATASET_DATA) { type = H5Dget_type(did); @@ -6513,7 +6564,7 @@ xml_print_strs(hid_t did, int source) goto error; } /* Check if we have VL data in the dataset's datatype */ - is_vlstr = (TRUE == H5Tis_variable_str(type)); + is_vlstr = H5Tis_variable_str(type); if (source == DATASET_DATA) { space = H5Dget_space(did); @@ -6565,12 +6616,12 @@ xml_print_strs(hid_t did, int source) indentation(indent + COL); if (!onestring) { - printf("NULL\n"); + HDfprintf(stdout, "NULL\n"); } else { char *t_onestring = xml_escape_the_string(onestring, (int) str_size); if (t_onestring) { - printf("\"%s\"\n", t_onestring); + HDfprintf(stdout, "\"%s\"\n", t_onestring); free(t_onestring); } } @@ -6619,74 +6670,81 @@ error: static void check_filters(hid_t dcpl) { - int nfilt; - int i; - H5Z_filter_t filter; - char namebuf[120]; - size_t cd_nelmts = 20; - unsigned int cd_values[20]; - unsigned int flags; + int nfilt; + int i; + H5Z_filter_t filter; + char namebuf[120]; + size_t cd_nelmts = 20; + unsigned int cd_values[20]; + unsigned int flags; nfilt = H5Pget_nfilters(dcpl); if (nfilt <= 0) return; for (i = 0; i < nfilt; i++) { - filter = H5Pget_filter2(dcpl, (unsigned)i, &flags, - (size_t *) &cd_nelmts, - cd_values, 120, namebuf, NULL); + filter = H5Pget_filter2(dcpl, (unsigned) i, &flags, (size_t *) &cd_nelmts, cd_values, 120, namebuf, NULL); if (filter == H5Z_FILTER_DEFLATE) { indentation(indent + COL); - printf("<%sDeflate Level=\"",xmlnsprefix); + HDfprintf(stdout, "<%sDeflate Level=\"", xmlnsprefix); if (cd_nelmts < 1) { /* not sure what this means? */ - printf("6"); - } else { - printf("%d",cd_values[0]); + HDfprintf(stdout, "6"); + } + else { + HDfprintf(stdout, "%d", cd_values[0]); } - printf("\"/>\n"); - } else if (filter == H5Z_FILTER_FLETCHER32) { + HDfprintf(stdout, "\"/>\n"); + } + else if (filter == H5Z_FILTER_FLETCHER32) { indentation(indent + COL); - printf("<%sFletcher32 />",xmlnsprefix); - } else if (filter == H5Z_FILTER_SHUFFLE) { + HDfprintf(stdout, "<%sFletcher32 />", xmlnsprefix); + } + else if (filter == H5Z_FILTER_SHUFFLE) { indentation(indent + COL); - printf("<%sShuffle />",xmlnsprefix); - } else if (filter == H5Z_FILTER_SZIP) { + HDfprintf(stdout, "<%sShuffle />", xmlnsprefix); + } + else if (filter == H5Z_FILTER_SZIP) { indentation(indent + COL); - printf("<%sSZIP ",xmlnsprefix); + HDfprintf(stdout, "<%sSZIP ", xmlnsprefix); if (cd_nelmts < 2) { /* no pixels ? */ - printf("Pixels_per_block=\"-1\" "); - } else { - printf("Pixels_per_block=\"%d\" ",cd_values[1]); + HDfprintf(stdout, "Pixels_per_block=\"-1\" "); + } + else { + HDfprintf(stdout, "Pixels_per_block=\"%d\" ", cd_values[1]); } /* analyse the options mask */ if (cd_values[0] & H5_SZIP_CHIP_OPTION_MASK) { - printf("Mode =\"Hardware\" "); - } else if (cd_values[0] & H5_SZIP_ALLOW_K13_OPTION_MASK) { - printf("Mode =\"K13\" "); + HDfprintf(stdout, "Mode =\"Hardware\" "); } - printf("Coding=\""); + else if (cd_values[0] & H5_SZIP_ALLOW_K13_OPTION_MASK) { + HDfprintf(stdout, "Mode =\"K13\" "); + } + HDfprintf(stdout, "Coding=\""); if (cd_values[0] & H5_SZIP_EC_OPTION_MASK) { - printf("Entropy"); - } else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) { - printf("NN"); + HDfprintf(stdout, "Entropy"); + } + else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) { + HDfprintf(stdout, "NN"); } - printf("\" "); + HDfprintf(stdout, "\" "); - printf("ByteOrder=\""); + HDfprintf(stdout, "ByteOrder=\""); if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) { - printf("LSB"); - } else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) { - printf("MSB"); + HDfprintf(stdout, "LSB"); } - printf("\" "); + else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) { + HDfprintf(stdout, "MSB"); + } + HDfprintf(stdout, "\" "); if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) { - printf("Header=\"Raw\""); + HDfprintf(stdout, "Header=\"Raw\""); } - printf("/>\n"); - } else { + HDfprintf(stdout, "/>\n"); + } + else { /* unknown option */ } } @@ -6695,124 +6753,125 @@ check_filters(hid_t dcpl) static void xml_dump_fill_value(hid_t dcpl, hid_t type) { - size_t sz; - size_t i; - hsize_t space; - void * buf; - char * name; + size_t sz; + size_t i; + hsize_t space; + void *buf; + char *name; indent += COL; indentation(indent); - printf("<%sData>\n",xmlnsprefix); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); indent += COL; space = H5Tget_size(type); - buf = malloc((size_t)space); + buf = malloc((size_t) space); H5Pget_fill_value(dcpl, type, buf); if (H5Tget_class(type) == H5T_REFERENCE) { - const char * path; - - path = lookup_ref_path(*(hobj_ref_t *)buf); + const char * path = lookup_ref_path(*(hobj_ref_t *) buf); indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); + HDfprintf(stdout, "<%sDataFromFile>\n", xmlnsprefix); if (!path) { - printf("\"%s\"\n", "NULL"); - } else { + HDfprintf(stdout, "\"%s\"\n", "NULL"); + } + else { char *t_path = xml_escape_the_string(path, -1); - printf("\"%s\"\n", t_path); + HDfprintf(stdout, "\"%s\"\n", t_path); free(t_path); } indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - } else if (H5Tget_class(type) == H5T_STRING) { - /* ????? */ - indentation(indent); - printf("<!-- String fill values not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - } else { + HDfprintf(stdout, "</%sDataFromFile>\n", xmlnsprefix); + } + else if (H5Tget_class(type) == H5T_STRING) { + /* ????? */ + indentation(indent); + HDfprintf(stdout, "<!-- String fill values not yet implemented. -->\n"); + indentation(indent); + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + } + else { /* all other data */ switch (H5Tget_class(type)) { - case H5T_INTEGER: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - indentation(indent); - printf("\"%d\"\n",*(int *)buf); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; - case H5T_FLOAT: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - indentation(indent); - printf("\"%f\"\n",*(float *)buf); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; - case H5T_BITFIELD: - case H5T_OPAQUE: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - sz = H5Tget_size(type); - indentation(indent); - printf("\""); - for (i = 0; i < sz; i++) { - printf("%x ",*(unsigned int *)buf); - buf = (char *)buf + sizeof(unsigned int); - } - printf("\"\n"); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; - case H5T_ENUM: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - name = H5Tget_member_name(type, *(unsigned *)buf); - indentation(indent); - printf("\"%s\"\n",name); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; - case H5T_ARRAY: - indentation(indent); - printf("<!-- Array fill values not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - break; - case H5T_TIME: - indentation(indent); - printf("<!-- Time fill not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - break; - case H5T_COMPOUND: - indentation(indent); - printf("<!-- Compound fill not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - break; - case H5T_VLEN: - indentation(indent); - printf("<!-- VL fill not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - break; - default: - indentation(indent); - printf("<!-- Unknown fill datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - break; + case H5T_INTEGER: + indentation(indent); + HDfprintf(stdout, "<%sDataFromFile>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "\"%d\"\n", *(int *) buf); + indentation(indent); + HDfprintf(stdout, "</%sDataFromFile>\n", xmlnsprefix); + break; + case H5T_FLOAT: + indentation(indent); + HDfprintf(stdout, "<%sDataFromFile>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "\"%f\"\n", *(float *) buf); + indentation(indent); + HDfprintf(stdout, "</%sDataFromFile>\n", xmlnsprefix); + break; + case H5T_BITFIELD: + case H5T_OPAQUE: + indentation(indent); + HDfprintf(stdout, "<%sDataFromFile>\n", xmlnsprefix); + sz = H5Tget_size(type); + indentation(indent); + HDfprintf(stdout, "\""); + for (i = 0; i < sz; i++) { + HDfprintf(stdout, "%x ", *(unsigned int *) buf); + buf = (char *) buf + sizeof(unsigned int); + } + HDfprintf(stdout, "\"\n"); + indentation(indent); + HDfprintf(stdout, "</%sDataFromFile>\n", xmlnsprefix); + break; + case H5T_ENUM: + indentation(indent); + HDfprintf(stdout, "<%sDataFromFile>\n", xmlnsprefix); + name = H5Tget_member_name(type, *(unsigned *) buf); + indentation(indent); + HDfprintf(stdout, "\"%s\"\n", name); + indentation(indent); + HDfprintf(stdout, "</%sDataFromFile>\n", xmlnsprefix); + break; + case H5T_ARRAY: + indentation(indent); + HDfprintf(stdout, "<!-- Array fill values not yet implemented. -->\n"); + indentation(indent); + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + break; + case H5T_TIME: + indentation(indent); + HDfprintf(stdout, "<!-- Time fill not yet implemented. -->\n"); + indentation(indent); + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + break; + case H5T_COMPOUND: + indentation(indent); + HDfprintf(stdout, "<!-- Compound fill not yet implemented. -->\n"); + indentation(indent); + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + break; + case H5T_VLEN: + indentation(indent); + HDfprintf(stdout, "<!-- VL fill not yet implemented. -->\n"); + indentation(indent); + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + break; + default: + indentation(indent); + HDfprintf(stdout, "<!-- Unknown fill datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + HDfprintf(stdout, "<%sNoData/>\n", xmlnsprefix); + break; } } free(buf); indent -= COL; indentation(indent); - printf("</%sData>\n",xmlnsprefix); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); indent -= COL; } @@ -6834,23 +6893,27 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) static void xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) { - hid_t type, space; - hid_t dcpl; - H5D_fill_value_t fvstatus; - int maxdims; - hsize_t *chsize; - int ndims; - int i; - H5D_alloc_time_t at; - H5D_fill_time_t ft; - hsize_t tempi; - char *tmp; - char *t_name, *t_tmp, *t_prefix; - unsigned attr_crt_order_flags; - char *rstr = (char *)HDmalloc(100); - char *pstr = (char *)HDmalloc(100); + hid_t type; + hid_t space; + hid_t dcpl; + H5D_fill_value_t fvstatus; + int maxdims; + hsize_t *chsize; + int ndims; + int i; + H5D_alloc_time_t at; + H5D_fill_time_t ft; + hsize_t tempi; + char *tmp; + char *t_name; + char *t_tmp; + char *t_prefix; + unsigned attr_crt_order_flags; + + char *rstr = (char*) HDmalloc(100); + char *pstr = (char*) HDmalloc(100); - tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + tmp = (char*) HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); HDstrcat(tmp, "/"); HDstrcat(tmp, name); @@ -6862,8 +6925,9 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) xml_name_to_XID(tmp, rstr, 100, 1); xml_name_to_XID(prefix, pstr, 100, 1); - printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n",xmlnsprefix, - t_name, rstr, t_tmp, pstr, strcmp(prefix, "") ? t_prefix : "/"); + HDfprintf(stdout, "<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n", + xmlnsprefix, t_name, rstr, t_tmp, pstr, + strcmp(prefix, "") ? t_prefix : "/"); HDfree(t_name); HDfree(t_tmp); @@ -6876,69 +6940,70 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) type = H5Dget_type(did); space = H5Dget_space(did); - /* query the creation properties for attributes */ + /* query the creation properties for attributes */ H5Pget_attr_creation_order(dcpl, &attr_crt_order_flags); /* Print information about storage layout */ - if(H5D_CHUNKED == H5Pget_layout(dcpl)) { + if (H5D_CHUNKED == H5Pget_layout(dcpl)) { maxdims = H5Sget_simple_extent_ndims(space); - chsize = (hsize_t *)malloc(maxdims * sizeof(hsize_t)); + chsize = (hsize_t *) malloc(maxdims * sizeof(hsize_t)); indent += COL; indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); + HDfprintf(stdout, "<%sStorageLayout>\n", xmlnsprefix); indent += COL; indentation(indent); - printf("<%sChunkedLayout ",xmlnsprefix); + HDfprintf(stdout, "<%sChunkedLayout ", xmlnsprefix); ndims = H5Pget_chunk(dcpl, maxdims, chsize); - printf("Ndims=\"%d\">\n", ndims); + HDfprintf(stdout, "Ndims=\"%d\">\n", ndims); indent += COL; for (i = 0; i < ndims; i++) { indentation(indent); - HDfprintf(stdout, "<%sChunkDimension DimSize=\"%Hu\" />\n", - xmlnsprefix, chsize[i]); + HDfprintf(stdout, "<%sChunkDimension DimSize=\"%Hu\" />\n", xmlnsprefix, chsize[i]); } indentation(indent); - printf("<%sRequiredFilter>\n",xmlnsprefix); + HDfprintf(stdout, "<%sRequiredFilter>\n", xmlnsprefix); indent += COL; check_filters(dcpl); indent -= COL; indentation(indent); - printf("</%sRequiredFilter>\n",xmlnsprefix); + HDfprintf(stdout, "</%sRequiredFilter>\n", xmlnsprefix); indent -= COL; indentation(indent); - printf("</%sChunkedLayout>\n",xmlnsprefix); + HDfprintf(stdout, "</%sChunkedLayout>\n", xmlnsprefix); indent -= COL; indentation(indent); - printf("</%sStorageLayout>\n",xmlnsprefix); + HDfprintf(stdout, "</%sStorageLayout>\n", xmlnsprefix); indent -= COL; free(chsize); - } else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) { + } + else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) { indent += COL; indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); + HDfprintf(stdout, "<%sStorageLayout>\n", xmlnsprefix); indent += COL; indentation(indent); - printf("<%sContiguousLayout/>\n",xmlnsprefix); + HDfprintf(stdout, "<%sContiguousLayout/>\n", xmlnsprefix); indent -= COL; indentation(indent); - printf("</%sStorageLayout>\n",xmlnsprefix); + HDfprintf(stdout, "</%sStorageLayout>\n", xmlnsprefix); indent -= COL; indentation(indent); - } else if (H5D_COMPACT == H5Pget_layout(dcpl)) { + } + else if (H5D_COMPACT == H5Pget_layout(dcpl)) { indent += COL; indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); + HDfprintf(stdout, "<%sStorageLayout>\n", xmlnsprefix); indent += COL; indentation(indent); - printf("<%sCompactLayout/>\n",xmlnsprefix); + HDfprintf(stdout, "<%sCompactLayout/>\n", xmlnsprefix); indent -= COL; indentation(indent); - printf("</%sStorageLayout>\n",xmlnsprefix); + HDfprintf(stdout, "</%sStorageLayout>\n", xmlnsprefix); indent -= COL; indentation(indent); } @@ -6948,64 +7013,65 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) indent += COL; indentation(indent); - printf("<%sFillValueInfo ",xmlnsprefix); + HDfprintf(stdout, "<%sFillValueInfo ", xmlnsprefix); H5Pget_fill_time(dcpl, &ft); - printf("FillTime=\""); - switch ( ft ) { - case H5D_FILL_TIME_ALLOC: - printf("FillOnAlloc"); - break; - case H5D_FILL_TIME_NEVER: - printf("FillNever"); - break; - case H5D_FILL_TIME_IFSET: - printf("FillIfSet"); - break; - default: - printf("?"); - break; + HDfprintf(stdout, "FillTime=\""); + switch (ft) { + case H5D_FILL_TIME_ALLOC: + HDfprintf(stdout, "FillOnAlloc"); + break; + case H5D_FILL_TIME_NEVER: + HDfprintf(stdout, "FillNever"); + break; + case H5D_FILL_TIME_IFSET: + HDfprintf(stdout, "FillIfSet"); + break; + default: + HDfprintf(stdout, "?"); + break; } - printf("\" "); + HDfprintf(stdout, "\" "); H5Pget_alloc_time(dcpl, &at); - printf("AllocationTime=\""); - switch ( at ) { - case H5D_ALLOC_TIME_EARLY: - printf("Early"); - break; - case H5D_ALLOC_TIME_INCR: - printf("Incremental"); - break; - case H5D_ALLOC_TIME_LATE: - printf("Late"); - break; - case H5D_ALLOC_TIME_DEFAULT: - default: - printf("?"); - break; + HDfprintf(stdout, "AllocationTime=\""); + switch (at) { + case H5D_ALLOC_TIME_EARLY: + HDfprintf(stdout, "Early"); + break; + case H5D_ALLOC_TIME_INCR: + HDfprintf(stdout, "Incremental"); + break; + case H5D_ALLOC_TIME_LATE: + HDfprintf(stdout, "Late"); + break; + case H5D_ALLOC_TIME_DEFAULT: + default: + HDfprintf(stdout, "?"); + break; } - printf("\""); - printf(">\n"); + HDfprintf(stdout, "\""); + HDfprintf(stdout, ">\n"); indent += COL; indentation(indent); - printf("<%sFillValue>\n",xmlnsprefix); + HDfprintf(stdout, "<%sFillValue>\n", xmlnsprefix); indent += COL; H5Pfill_value_defined(dcpl, &fvstatus); - if (fvstatus == H5D_FILL_VALUE_UNDEFINED || - (fvstatus==H5D_FILL_VALUE_DEFAULT && ft==H5D_FILL_TIME_IFSET)) { + if (fvstatus == H5D_FILL_VALUE_UNDEFINED || + (fvstatus == H5D_FILL_VALUE_DEFAULT && ft == H5D_FILL_TIME_IFSET)) { indentation(indent + COL); - printf("<%sNoFill/>\n",xmlnsprefix); - } else { - xml_dump_fill_value(dcpl,type); + HDfprintf(stdout, "<%sNoFill/>\n", xmlnsprefix); + } + else { + xml_dump_fill_value(dcpl, type); } indent -= COL; indentation(indent); - printf("</%sFillValue>\n",xmlnsprefix); + HDfprintf(stdout, "</%sFillValue>\n", xmlnsprefix); indent -= COL; indentation(indent); - printf("</%sFillValueInfo>\n",xmlnsprefix); + HDfprintf(stdout, "</%sFillValueInfo>\n", xmlnsprefix); indent -= COL; dump_function_table->dump_dataspace_function(space); @@ -7013,14 +7079,14 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) indent += COL; - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { + if (H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end if */ else { - if(H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if (H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ @@ -7031,83 +7097,85 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) if (display_data && (tempi > 0)) { switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; - case H5T_TIME: - indent += COL; - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Time data not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indent -= COL; - break; + case H5T_TIME: + indent += COL; + indentation(indent); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "<!-- Time data not yet implemented. -->\n"); + indentation(indent); + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); + indent -= COL; + break; - case H5T_COMPOUND: - indentation(indent); - printf("<!-- Note: format of compound data not specified -->\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; + case H5T_COMPOUND: + indentation(indent); + HDfprintf(stdout, "<!-- Note: format of compound data not specified -->\n"); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; - case H5T_REFERENCE: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); + case H5T_REFERENCE: + indentation(indent); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); + indentation(indent); + if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + HDfprintf(stdout, "<!-- Note: Region references not supported -->\n"); indentation(indent); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - printf("<!-- Note: Region references not supported -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(did, DATASET_DATA); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - } + HDfprintf(stdout, "<%sNoData />\n", xmlnsprefix); + } + else { + HDfprintf(stdout, "<%sDataFromFile>\n", xmlnsprefix); + xml_print_refs(did, DATASET_DATA); indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; + HDfprintf(stdout, "</%sDataFromFile>\n", xmlnsprefix); + } + indentation(indent); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); + break; - case H5T_VLEN: - printf("<!-- Note: format of VL data not specified -->\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; - default: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; + case H5T_VLEN: + HDfprintf(stdout, "<!-- Note: format of VL data not specified -->\n"); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; + default: + indentation(indent); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + HDfprintf(stdout, "<%sNoData/>\n", xmlnsprefix); + indentation(indent); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); + break; } - } else { + } + else { /* no data written */ indentation(indent + COL); - printf("<%sData>\n",xmlnsprefix); + HDfprintf(stdout, "<%sData>\n", xmlnsprefix); indentation(indent + COL + COL); - printf("<%sNoData/>\n",xmlnsprefix); + HDfprintf(stdout, "<%sNoData/>\n", xmlnsprefix); indentation(indent + COL); - printf("</%sData>\n",xmlnsprefix); + HDfprintf(stdout, "</%sData>\n", xmlnsprefix); } H5Tclose(type); H5Sclose(space); H5Pclose(dcpl); indentation(indent); - printf("</%sDataset>\n", xmlnsprefix); + HDfprintf(stdout, "</%sDataset>\n", xmlnsprefix); } /*------------------------------------------------------------------------- @@ -7127,23 +7195,23 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) static void xml_print_enum(hid_t type) { - char **name = NULL; /*member names */ - unsigned char *value = NULL; /*value array */ - unsigned nmembs; /*number of members */ - hid_t super; /*enum base integer type */ - hid_t native = -1; /*native integer datatype */ - size_t dst_size; /*destination value type size */ - unsigned i; /*miscellaneous counters */ - size_t j; + char **name = NULL; /*member names */ + unsigned char *value = NULL; /*value array */ + unsigned nmembs; /*number of members */ + hid_t super; /*enum base integer type */ + hid_t native = -1; /*native integer datatype */ + size_t dst_size; /*destination value type size */ + unsigned i; /*miscellaneous counters */ + size_t j; nmembs = (unsigned)H5Tget_nmembers(type); super = H5Tget_super(type); indentation(indent); - printf("<%sDataType>\n",xmlnsprefix); + HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix); xml_print_datatype(super,0); indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); + HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix); /* * Determine what datatype to use for the native values. To simplify @@ -7157,10 +7225,12 @@ xml_print_enum(hid_t type) if (H5T_SGN_NONE == H5Tget_sign(type)) { native = H5T_NATIVE_ULLONG; - } else { + } + else { native = H5T_NATIVE_LLONG; } - } else { + } + else { dst_size = H5Tget_size(type); } @@ -7186,30 +7256,32 @@ xml_print_enum(hid_t type) char *t_name = xml_escape_the_name(name[i]); indentation(indent); - printf("<%sEnumElement>\n",xmlnsprefix); + HDfprintf(stdout, "<%sEnumElement>\n",xmlnsprefix); indentation(indent + COL); - printf("%s\n", t_name); + HDfprintf(stdout, "%s\n", t_name); free(t_name); indentation(indent); - printf("</%sEnumElement>\n",xmlnsprefix); + HDfprintf(stdout, "</%sEnumElement>\n",xmlnsprefix); indentation(indent); - printf("<%sEnumValue>\n",xmlnsprefix); + HDfprintf(stdout, "<%sEnumValue>\n",xmlnsprefix); indentation(indent + COL); if (native < 0) { - printf("0x"); + HDfprintf(stdout, "0x"); for (j = 0; j < dst_size; j++) - printf("%02x", value[i * dst_size + j]); - } else if (H5T_SGN_NONE == H5Tget_sign(native)) { + HDfprintf(stdout, "%02x", value[i * dst_size + j]); + } + else if (H5T_SGN_NONE == H5Tget_sign(native)) { HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *) - ((void *) (value + i * dst_size)))); - } else { + ((void *) (value + i * dst_size)))); + } + else { HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", - *((long long *) ((void *) (value + i * dst_size)))); + *((long long *) ((void *) (value + i * dst_size)))); } - printf("\n"); + HDfprintf(stdout, "\n"); indentation(indent); - printf("</%sEnumValue>\n",xmlnsprefix); + HDfprintf(stdout, "</%sEnumValue>\n",xmlnsprefix); } indent -= COL; @@ -7248,8 +7320,8 @@ h5_fileaccess(void) static const char *multi_letters = "msbrglo"; const char *val = NULL; const char *name; - char s[1024]; - hid_t fapl = -1; + char s[1024]; + hid_t fapl = -1; /* First use the environment variable, then the constant */ val = HDgetenv("HDF5_DRIVER"); @@ -7267,26 +7339,28 @@ h5_fileaccess(void) if (!HDstrcmp(name, "sec2")) { /* Unix read() and write() system calls */ if (H5Pset_fapl_sec2(fapl)<0) return -1; - } else if (!HDstrcmp(name, "stdio")) { + } + else if (!HDstrcmp(name, "stdio")) { /* Standard C fread() and fwrite() system calls */ if (H5Pset_fapl_stdio(fapl)<0) return -1; - } else if (!HDstrcmp(name, "core")) { + } + else if (!HDstrcmp(name, "core")) { /* In-core temporary file with 1MB increment */ if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; - } else if (!HDstrcmp(name, "split")) { + } + else if (!HDstrcmp(name, "split")) { /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT)<0) - return -1; - } else if (!HDstrcmp(name, "multi")) { + if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) + return -1; + } + else if (!HDstrcmp(name, "multi")) { /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][1024]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); @@ -7296,24 +7370,25 @@ h5_fileaccess(void) assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { memb_fapl[mt] = H5P_DEFAULT; - memb_map[mt] = mt; + memb_map[mt] = mt; sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10); } - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE) < 0) + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) return -1; - } else if (!HDstrcmp(name, "family")) { + } + else if (!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ /* Family of files, each 1MB and using the default driver */ if ((val=HDstrtok(NULL, " \t\n\r"))) fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) - return -1; - } else if (!HDstrcmp(name, "log")) { + return -1; + } + else if (!HDstrcmp(name, "log")) { long log_flags = H5FD_LOG_LOC_IO; /* Log file access */ @@ -7322,11 +7397,13 @@ h5_fileaccess(void) if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0) return -1; - } else if (!HDstrcmp(name, "direct")) { + } + else if (!HDstrcmp(name, "direct")) { /* Substitute Direct I/O driver with sec2 driver temporarily because * some output has sec2 driver as the standard. */ if (H5Pset_fapl_sec2(fapl)<0) return -1; - } else { + } + else { /* Unknown driver */ return -1; } @@ -7378,7 +7455,7 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name) HDstrcat(HDstrcat(*prfx, "/"), name); } /* end add_prefix */ - + /*------------------------------------------------------------------------- * Function: dump_extlink * @@ -7399,6 +7476,7 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name) *------------------------------------------------------------------------- */ + static int dump_extlink(hid_t group, const char *linkname, const char *objname) { hid_t oid; @@ -7409,7 +7487,6 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname) hbool_t old_hit_elink; ssize_t idx; - /* Open target object */ if ((oid = H5Oopen(group, linkname, H5P_DEFAULT)) < 0) goto fail; @@ -7472,12 +7549,9 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname) if (H5Idec_ref(oid) < 0) h5tools_setstatus(EXIT_FAILURE); - return SUCCEED; fail: - return FAIL; - } diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h index 3e34538..be77002 100644 --- a/tools/h5dump/h5dump.h +++ b/tools/h5dump/h5dump.h @@ -69,11 +69,9 @@ #define EXTERNAL_FILE "EXTERNAL_FILE" #define FILLVALUE "FILLVALUE" #define FILE_CONTENTS "FILE_CONTENTS" -#ifdef H5_HAVE_H5DUMP_PACKED_BITS #define PACKED_BITS "PACKED_BITS" #define PACKED_OFFSET "OFFSET" #define PACKED_LENGTH "LENGTH" -#endif #define BEGIN "{" #define END "}" diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index f8da64b..9406df7 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -23,9 +23,6 @@ USE_FILTER_FLETCHER32="@USE_FILTER_FLETCHER32@" USE_FILTER_NBIT="@USE_FILTER_NBIT@" USE_FILTER_SCALEOFFSET="@USE_FILTER_SCALEOFFSET@" -# Determine if H5dump packed bits feature is included -Have_Packed_Bits="@PACKED_BITS@" - TESTNAME=h5dump EXIT_SUCCESS=0 EXIT_FAILURE=1 @@ -82,12 +79,12 @@ TOOLTEST() { echo "#############################" echo "Expected output for '$DUMPER $@'" echo "#############################" - cd $srcdir/../testfiles - $RUNSERIAL $DUMPER_BIN $@ + cd $srcdir/../testfiles + $RUNSERIAL $DUMPER_BIN $@ ) >$actual 2>$actual_err cat $actual_err >> $actual - if [ ! -f $expect ]; then + if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. echo " CREATED" cp $actual $expect @@ -96,13 +93,13 @@ TOOLTEST() { else echo "*FAILED*" echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err + rm -f $actual $actual_err fi } @@ -121,12 +118,12 @@ TOOLTEST1() { TESTING $DUMPER $@ ( - cd $srcdir/../testfiles - $RUNSERIAL $DUMPER_BIN $@ + cd $srcdir/../testfiles + $RUNSERIAL $DUMPER_BIN $@ ) >$actual 2>$actual_err cat $actual_err >> $actual - if [ ! -f $expect ]; then + if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. echo " CREATED" cp $actual $expect @@ -135,13 +132,13 @@ TOOLTEST1() { else echo "*FAILED*" echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err + rm -f $actual $actual_err fi } @@ -250,8 +247,8 @@ TOOLTEST3() { # Print a "SKIP" message SKIP() { - TESTING $DUMPER $@ - echo " -SKIP-" + TESTING $DUMPER $@ + echo " -SKIP-" } # Print a line-line message left justified in a field of 70 characters @@ -268,8 +265,8 @@ DIFFTEST() { PRINT_H5DIFF $@ ( - cd $srcdir/../testfiles - $RUNSERIAL $H5DIFF_BIN "$@" -q + cd $srcdir/../testfiles + $RUNSERIAL $H5DIFF_BIN "$@" -q ) RET=$? if [ $RET != 0 ] ; then @@ -301,8 +298,8 @@ IMPORTTEST() PRINT_H5IMPORT $@ ( - cd $srcdir/../testfiles - $RUNSERIAL $H5IMPORT_BIN "$@" + cd $srcdir/../testfiles + $RUNSERIAL $H5IMPORT_BIN "$@" ) RET=$? if [ $RET != 0 ] ; then @@ -317,7 +314,7 @@ IMPORTTEST() ############################################################################## ############################################################################## -### T H E T E S T S ### +### T H E T E S T S ### ############################################################################## ############################################################################## @@ -646,12 +643,6 @@ TOOLTEST3 filter_fail.ddl --enable-error-stack filter_fail.h5 TOOLTEST1 tall-6.ddl -y -o $TESTDIR/data -d /g1/g1.1/dset1.1.1 tall.h5 # test for dataset packed bits -# Set up xCMD to test or skip. -if test "$Have_Packed_Bits" = "yes"; then - xCMD=TOOLTEST -else - xCMD=SKIP -fi # Limits: # Maximum number of packed bits is 8 (for now). # Maximum integer size is 64 (for now). @@ -661,72 +652,72 @@ fi # Normal operation on both signed and unsigned int datasets. # Sanity check # Their rawdata output should be the same. -$xCMD tpbitsSignedWhole.ddl -d /DS08BITS -M 0,8 packedbits.h5 -$xCMD tpbitsUnsignedWhole.ddl -d /DU08BITS -M 0,8 packedbits.h5 -$xCMD tpbitsSignedIntWhole.ddl -d /DS16BITS -M 0,16 packedbits.h5 -$xCMD tpbitsUnsignedIntWhole.ddl -d /DU16BITS -M 0,16 packedbits.h5 -$xCMD tpbitsSignedLongWhole.ddl -d /DS32BITS -M 0,32 packedbits.h5 -$xCMD tpbitsUnsignedLongWhole.ddl -d /DU32BITS -M 0,32 packedbits.h5 -$xCMD tpbitsSignedLongLongWhole.ddl -d /DS64BITS -M 0,64 packedbits.h5 -$xCMD tpbitsUnsignedLongLongWhole.ddl -d /DU64BITS -M 0,64 packedbits.h5 -$xCMD tpbitsSignedLongLongWhole63.ddl -d /DS64BITS -M 0,63 packedbits.h5 -$xCMD tpbitsUnsignedLongLongWhole63.ddl -d /DU64BITS -M 0,63 packedbits.h5 -$xCMD tpbitsSignedLongLongWhole1.ddl -d /DS64BITS -M 1,63 packedbits.h5 -$xCMD tpbitsUnsignedLongLongWhole1.ddl -d /DU64BITS -M 1,63 packedbits.h5 +TOOLTEST tpbitsSignedWhole.ddl -d /DS08BITS -M 0,8 packedbits.h5 +TOOLTEST tpbitsUnsignedWhole.ddl -d /DU08BITS -M 0,8 packedbits.h5 +TOOLTEST tpbitsSignedIntWhole.ddl -d /DS16BITS -M 0,16 packedbits.h5 +TOOLTEST tpbitsUnsignedIntWhole.ddl -d /DU16BITS -M 0,16 packedbits.h5 +TOOLTEST tpbitsSignedLongWhole.ddl -d /DS32BITS -M 0,32 packedbits.h5 +TOOLTEST tpbitsUnsignedLongWhole.ddl -d /DU32BITS -M 0,32 packedbits.h5 +TOOLTEST tpbitsSignedLongLongWhole.ddl -d /DS64BITS -M 0,64 packedbits.h5 +TOOLTEST tpbitsUnsignedLongLongWhole.ddl -d /DU64BITS -M 0,64 packedbits.h5 +TOOLTEST tpbitsSignedLongLongWhole63.ddl -d /DS64BITS -M 0,63 packedbits.h5 +TOOLTEST tpbitsUnsignedLongLongWhole63.ddl -d /DU64BITS -M 0,63 packedbits.h5 +TOOLTEST tpbitsSignedLongLongWhole1.ddl -d /DS64BITS -M 1,63 packedbits.h5 +TOOLTEST tpbitsUnsignedLongLongWhole1.ddl -d /DU64BITS -M 1,63 packedbits.h5 # Half sections -$xCMD tpbitsSigned4.ddl -d /DS08BITS -M 0,4,4,4 packedbits.h5 -$xCMD tpbitsUnsigned4.ddl -d /DU08BITS -M 0,4,4,4 packedbits.h5 -$xCMD tpbitsSignedInt8.ddl -d /DS16BITS -M 0,8,8,8 packedbits.h5 -$xCMD tpbitsUnsignedInt8.ddl -d /DU16BITS -M 0,8,8,8 packedbits.h5 -$xCMD tpbitsSignedLong16.ddl -d /DS32BITS -M 0,16,16,16 packedbits.h5 -$xCMD tpbitsUnsignedLong16.ddl -d /DU32BITS -M 0,16,16,16 packedbits.h5 -$xCMD tpbitsSignedLongLong32.ddl -d /DS64BITS -M 0,32,32,32 packedbits.h5 -$xCMD tpbitsUnsignedLongLong32.ddl -d /DU64BITS -M 0,32,32,32 packedbits.h5 +TOOLTEST tpbitsSigned4.ddl -d /DS08BITS -M 0,4,4,4 packedbits.h5 +TOOLTEST tpbitsUnsigned4.ddl -d /DU08BITS -M 0,4,4,4 packedbits.h5 +TOOLTEST tpbitsSignedInt8.ddl -d /DS16BITS -M 0,8,8,8 packedbits.h5 +TOOLTEST tpbitsUnsignedInt8.ddl -d /DU16BITS -M 0,8,8,8 packedbits.h5 +TOOLTEST tpbitsSignedLong16.ddl -d /DS32BITS -M 0,16,16,16 packedbits.h5 +TOOLTEST tpbitsUnsignedLong16.ddl -d /DU32BITS -M 0,16,16,16 packedbits.h5 +TOOLTEST tpbitsSignedLongLong32.ddl -d /DS64BITS -M 0,32,32,32 packedbits.h5 +TOOLTEST tpbitsUnsignedLongLong32.ddl -d /DU64BITS -M 0,32,32,32 packedbits.h5 # Quarter sections -$xCMD tpbitsSigned2.ddl -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5 -$xCMD tpbitsUnsigned2.ddl -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5 -$xCMD tpbitsSignedInt4.ddl -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5 -$xCMD tpbitsUnsignedInt4.ddl -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5 -$xCMD tpbitsSignedLong8.ddl -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5 -$xCMD tpbitsUnsignedLong8.ddl -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5 -$xCMD tpbitsSignedLongLong16.ddl -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5 -$xCMD tpbitsUnsignedLongLong16.ddl -d /DU64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5 +TOOLTEST tpbitsSigned2.ddl -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5 +TOOLTEST tpbitsUnsigned2.ddl -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5 +TOOLTEST tpbitsSignedInt4.ddl -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5 +TOOLTEST tpbitsUnsignedInt4.ddl -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5 +TOOLTEST tpbitsSignedLong8.ddl -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5 +TOOLTEST tpbitsUnsignedLong8.ddl -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5 +TOOLTEST tpbitsSignedLongLong16.ddl -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5 +TOOLTEST tpbitsUnsignedLongLong16.ddl -d /DU64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5 # Begin and End -$xCMD tpbitsSigned.ddl -d /DS08BITS -M 0,2,2,6 packedbits.h5 -$xCMD tpbitsUnsigned.ddl -d /DU08BITS -M 0,2,2,6 packedbits.h5 -$xCMD tpbitsSignedInt.ddl -d /DS16BITS -M 0,2,10,6 packedbits.h5 -$xCMD tpbitsUnsignedInt.ddl -d /DU16BITS -M 0,2,10,6 packedbits.h5 -$xCMD tpbitsSignedLong.ddl -d /DS32BITS -M 0,2,26,6 packedbits.h5 -$xCMD tpbitsUnsignedLong.ddl -d /DU32BITS -M 0,2,26,6 packedbits.h5 -$xCMD tpbitsSignedLongLong.ddl -d /DS64BITS -M 0,2,58,6 packedbits.h5 -$xCMD tpbitsUnsignedLongLong.ddl -d /DU64BITS -M 0,2,58,6 packedbits.h5 +TOOLTEST tpbitsSigned.ddl -d /DS08BITS -M 0,2,2,6 packedbits.h5 +TOOLTEST tpbitsUnsigned.ddl -d /DU08BITS -M 0,2,2,6 packedbits.h5 +TOOLTEST tpbitsSignedInt.ddl -d /DS16BITS -M 0,2,10,6 packedbits.h5 +TOOLTEST tpbitsUnsignedInt.ddl -d /DU16BITS -M 0,2,10,6 packedbits.h5 +TOOLTEST tpbitsSignedLong.ddl -d /DS32BITS -M 0,2,26,6 packedbits.h5 +TOOLTEST tpbitsUnsignedLong.ddl -d /DU32BITS -M 0,2,26,6 packedbits.h5 +TOOLTEST tpbitsSignedLongLong.ddl -d /DS64BITS -M 0,2,58,6 packedbits.h5 +TOOLTEST tpbitsUnsignedLongLong.ddl -d /DU64BITS -M 0,2,58,6 packedbits.h5 # Overlapped packed bits. -$xCMD tpbitsOverlapped.ddl -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5 +TOOLTEST tpbitsOverlapped.ddl -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5 # Maximum number of packed bits. -$xCMD tpbitsMax.ddl -d /DS08BITS -M 0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5 +TOOLTEST tpbitsMax.ddl -d /DS08BITS -M 0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5 # Compound type. -$xCMD tpbitsCompound.ddl -d /dset1 -M 0,1,1,1 tcompound.h5 +TOOLTEST tpbitsCompound.ddl -d /dset1 -M 0,1,1,1 tcompound.h5 # Array type. -$xCMD tpbitsArray.ddl -d /Dataset1 -M 0,1,1,1 tarray1.h5 +TOOLTEST tpbitsArray.ddl -d /Dataset1 -M 0,1,1,1 tarray1.h5 # Test Error handling. # Too many packed bits requested. Max is 8 for now. -$xCMD tpbitsMaxExceeded.ddl -d /DS08BITS -M 0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5 +TOOLTEST tpbitsMaxExceeded.ddl -d /DS08BITS -M 0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5 # Offset too large. Max is 7 (8-1) for now. -$xCMD tpbitsOffsetExceeded.ddl -d /DS08BITS -M 64,1 packedbits.h5 -$xCMD tpbitsCharOffsetExceeded.ddl -d /DS08BITS -M 8,1 packedbits.h5 -$xCMD tpbitsIntOffsetExceeded.ddl -d /DS16BITS -M 16,1 packedbits.h5 -$xCMD tpbitsLongOffsetExceeded.ddl -d /DS32BITS -M 32,1 packedbits.h5 +TOOLTEST tpbitsOffsetExceeded.ddl -d /DS08BITS -M 64,1 packedbits.h5 +TOOLTEST tpbitsCharOffsetExceeded.ddl -d /DS08BITS -M 8,1 packedbits.h5 +TOOLTEST tpbitsIntOffsetExceeded.ddl -d /DS16BITS -M 16,1 packedbits.h5 +TOOLTEST tpbitsLongOffsetExceeded.ddl -d /DS32BITS -M 32,1 packedbits.h5 # Bad offset, must not be negative. -$xCMD tpbitsOffsetNegative.ddl -d /DS08BITS -M -1,1 packedbits.h5 +TOOLTEST tpbitsOffsetNegative.ddl -d /DS08BITS -M -1,1 packedbits.h5 # Bad length, must not be positive. -$xCMD tpbitsLengthPositive.ddl -d /DS08BITS -M 4,0 packedbits.h5 +TOOLTEST tpbitsLengthPositive.ddl -d /DS08BITS -M 4,0 packedbits.h5 # Offset+Length is too large. Max is 8 for now. -$xCMD tpbitsLengthExceeded.ddl -d /DS08BITS -M 37,28 packedbits.h5 -$xCMD tpbitsCharLengthExceeded.ddl -d /DS08BITS -M 2,7 packedbits.h5 -$xCMD tpbitsIntLengthExceeded.ddl -d /DS16BITS -M 10,7 packedbits.h5 -$xCMD tpbitsLongLengthExceeded.ddl -d /DS32BITS -M 26,7 packedbits.h5 +TOOLTEST tpbitsLengthExceeded.ddl -d /DS08BITS -M 37,28 packedbits.h5 +TOOLTEST tpbitsCharLengthExceeded.ddl -d /DS08BITS -M 2,7 packedbits.h5 +TOOLTEST tpbitsIntLengthExceeded.ddl -d /DS16BITS -M 10,7 packedbits.h5 +TOOLTEST tpbitsLongLengthExceeded.ddl -d /DS32BITS -M 26,7 packedbits.h5 # Incomplete pair of packed bits request. -$xCMD tpbitsIncomplete.ddl -d /DS08BITS -M 0,2,2,1,0,2,2, packedbits.h5 +TOOLTEST tpbitsIncomplete.ddl -d /DS08BITS -M 0,2,2,1,0,2,2, packedbits.h5 # Report test results and exit |