summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-03-02 14:21:13 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-03-02 14:21:13 (GMT)
commit68d93b7f4e458ace2ac255c1c7d9dd8873132b51 (patch)
tree5e8429affabf4e90eee15cc85119820b3afc36a8 /tools/h5dump
parentc714d9ef43e8b442bd271867c7afab0487fc0c0a (diff)
downloadhdf5-68d93b7f4e458ace2ac255c1c7d9dd8873132b51.zip
hdf5-68d93b7f4e458ace2ac255c1c7d9dd8873132b51.tar.gz
hdf5-68d93b7f4e458ace2ac255c1c7d9dd8873132b51.tar.bz2
[svn-r22013] HDFFV-7560:
Merge 1.8 and h5dump/tools and tests based on tools library from trunk. Reduced warnings. HDFFV-7949: Remove duplicated functions in h5ls Tested: local linux,h5committest
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/CMakeLists.txt313
-rw-r--r--tools/h5dump/Makefile.am3
-rw-r--r--tools/h5dump/Makefile.in14
-rw-r--r--tools/h5dump/h5dump.c6661
-rw-r--r--tools/h5dump/h5dump.h217
-rw-r--r--tools/h5dump/h5dump_ddl.c1917
-rw-r--r--tools/h5dump/h5dump_ddl.h50
-rw-r--r--tools/h5dump/h5dump_defines.h54
-rw-r--r--tools/h5dump/h5dump_extern.h112
-rw-r--r--tools/h5dump/h5dump_xml.c4456
-rw-r--r--tools/h5dump/h5dump_xml.h128
-rw-r--r--tools/h5dump/h5dumpgentest.c789
-rw-r--r--tools/h5dump/testh5dump.sh.in316
13 files changed, 7973 insertions, 7057 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index 676bace..a4ac75f 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -10,7 +10,11 @@ INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test)
# --------------------------------------------------------------------
# Add the h5dump executables
# --------------------------------------------------------------------
-ADD_EXECUTABLE (h5dump ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump.c)
+ADD_EXECUTABLE (h5dump
+ ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump.c
+ ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump_ddl.c
+ ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump_xml.c
+)
TARGET_NAMING (h5dump ${LIB_TYPE})
TARGET_LINK_LIBRARIES (h5dump ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
SET_TARGET_PROPERTIES (h5dump PROPERTIES FOLDER tools)
@@ -126,7 +130,7 @@ IF (BUILD_TESTING)
tnamed_dtype_attr.ddl
tnestcomp-1.ddl
tnbit.ddl
- tnofilename.ddl
+ tno-subset.ddl
tnullspace.ddl
zerodim.ddl
tordergr1.ddl
@@ -293,6 +297,7 @@ IF (BUILD_TESTING)
tmulti-s.h5
tnamed_dtype_attr.h5
tnestedcomp.h5
+ tno-subset.h5
tnullspace.h5
zerodim.h5
torderattr.h5
@@ -408,6 +413,7 @@ IF (BUILD_TESTING)
# --------------------------------------------------------------------
#-- 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
@@ -827,8 +833,8 @@ IF (BUILD_TESTING)
tnestcomp-1.out.err
tnbit.out
tnbit.out.err
- tnofilename.out
- tnofilename.out.err
+ tno-subset.out
+ tno-subset.out.err
tnullspace.out
tnullspace.out.err
zerodim.out
@@ -909,168 +915,174 @@ IF (BUILD_TESTING)
ADD_HELP_TEST(help 0 -h)
# test for signed/unsigned datasets
- ADD_H5_TEST (packedbits 0 packedbits.h5)
+ ADD_H5_TEST (packedbits 0 --enable-error-stack packedbits.h5)
# test for displaying groups
- ADD_H5_TEST (tgroup-1 0 tgroup.h5)
+ ADD_H5_TEST (tgroup-1 0 --enable-error-stack tgroup.h5)
# test for displaying the selected groups
ADD_H5_TEST (tgroup-2 1 --group=/g2 --group / -g /y tgroup.h5)
# test for displaying simple space datasets
- ADD_H5_TEST (tdset-1 0 tdset.h5)
+ ADD_H5_TEST (tdset-1 0 --enable-error-stack tdset.h5)
# test for displaying selected datasets
ADD_H5_TEST (tdset-2 1 -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5)
# test for displaying attributes
- ADD_H5_TEST (tattr-1 0 tattr.h5)
+ ADD_H5_TEST (tattr-1 0 --enable-error-stack tattr.h5)
# test for displaying the selected attributes of string type and scalar space
- ADD_H5_TEST (tattr-2 0 -a /attr1 --attribute /attr4 --attribute=/attr5 tattr.h5)
+ ADD_H5_TEST (tattr-2 0 --enable-error-stack -a /attr1 --attribute /attr4 --attribute=/attr5 tattr.h5)
# test for header and error messages
ADD_H5_TEST (tattr-3 1 --header -a /attr2 --attribute=/attr tattr.h5)
# test for displaying attributes in shared datatype (also in group and dataset)
- ADD_H5_TEST (tnamed_dtype_attr 0 tnamed_dtype_attr.h5)
+ ADD_H5_TEST (tnamed_dtype_attr 0 --enable-error-stack tnamed_dtype_attr.h5)
# test for displaying at least 9 attributes on root from a be machine
- ADD_H5_TEST (tattr-4_be 0 tattr4_be.h5)
+ ADD_H5_TEST (tattr-4_be 0 --enable-error-stack tattr4_be.h5)
# test for displaying soft links and user-defined links
- ADD_H5_TEST (tslink-1 0 tslink.h5)
- ADD_H5_TEST (tudlink-1 0 tudlink.h5)
+ ADD_H5_TEST (tslink-1 0 --enable-error-stack tslink.h5)
+ ADD_H5_TEST (tudlink-1 0 --enable-error-stack tudlink.h5)
# test for displaying the selected link
- ADD_H5_TEST (tslink-2 0 -l slink2 tslink.h5)
- ADD_H5_TEST (tudlink-2 0 -l udlink2 tudlink.h5)
+ ADD_H5_TEST (tslink-2 0 --enable-error-stack -l slink2 tslink.h5)
+ ADD_H5_TEST (tudlink-2 0 --enable-error-stack -l udlink2 tudlink.h5)
# tests for hard links
- ADD_H5_TEST (thlink-1 0 thlink.h5)
- ADD_H5_TEST (thlink-2 0 -d /g1/dset2 --dataset /dset1 --dataset=/g1/g1.1/dset3 thlink.h5)
- ADD_H5_TEST (thlink-3 0 -d /g1/g1.1/dset3 --dataset /g1/dset2 --dataset=/dset1 thlink.h5)
- ADD_H5_TEST (thlink-4 0 -g /g1 thlink.h5)
- ADD_H5_TEST (thlink-5 0 -d /dset1 -g /g2 -d /g1/dset2 thlink.h5)
+ ADD_H5_TEST (thlink-1 0 --enable-error-stack thlink.h5)
+ ADD_H5_TEST (thlink-2 0 --enable-error-stack -d /g1/dset2 --dataset /dset1 --dataset=/g1/g1.1/dset3 thlink.h5)
+ ADD_H5_TEST (thlink-3 0 --enable-error-stack -d /g1/g1.1/dset3 --dataset /g1/dset2 --dataset=/dset1 thlink.h5)
+ ADD_H5_TEST (thlink-4 0 --enable-error-stack -g /g1 thlink.h5)
+ ADD_H5_TEST (thlink-5 0 --enable-error-stack -d /dset1 -g /g2 -d /g1/dset2 thlink.h5)
# tests for compound data types
- ADD_H5_TEST (tcomp-1 0 tcompound.h5)
+ ADD_H5_TEST (tcomp-1 0 --enable-error-stack tcompound.h5)
# test for named data types
- ADD_H5_TEST (tcomp-2 0 -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5)
+ ADD_H5_TEST (tcomp-2 0 --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5)
# test for unamed type
- #ADD_H5_TEST (tcomp-3 0 -t /#6632 -g /group2 tcompound.h5)
+ # JIRA HDFFV-7936 ADD_H5_TEST (tcomp-3 0 "--enable-error-stack;-t;/#6632;-g;/group2;tcompound.h5")
+ ADD_H5_TEST (tcomp-3 0 "-t;/#6632;-g;/group2;tcompound.h5")
# test complicated compound datatype
- ADD_H5_TEST (tcomp-4 0 tcompound_complex.h5)
+ ADD_H5_TEST (tcomp-4 0 --enable-error-stack tcompound_complex.h5)
#test for the nested compound type
- ADD_H5_TEST (tnestcomp-1 0 tnestedcomp.h5)
+ ADD_H5_TEST (tnestcomp-1 0 --enable-error-stack tnestedcomp.h5)
# test for options
+ # JIRA HDFFV-7936 ADD_H5_TEST (tall-1 0 --enable-error-stack tall.h5)
ADD_H5_TEST (tall-1 0 tall.h5)
- ADD_H5_TEST (tall-2 0 --header -g /g1/g1.1 -a attr2 tall.h5)
- ADD_H5_TEST (tall-3 0 -d /g2/dset2.1 -l /g1/g1.2/g1.2.1/slink tall.h5)
+ ADD_H5_TEST (tall-2 0 --enable-error-stack --header -g /g1/g1.1 -a attr2 tall.h5)
+ ADD_H5_TEST (tall-3 0 --enable-error-stack -d /g2/dset2.1 -l /g1/g1.2/g1.2.1/slink tall.h5)
# test for loop detection
- ADD_H5_TEST (tloop-1 0 tloop.h5)
+ ADD_H5_TEST (tloop-1 0 --enable-error-stack tloop.h5)
# test for string
- ADD_H5_TEST (tstr-1 0 tstr.h5)
- ADD_H5_TEST (tstr-2 0 tstr2.h5)
+ ADD_H5_TEST (tstr-1 0 --enable-error-stack tstr.h5)
+ ADD_H5_TEST (tstr-2 0 --enable-error-stack tstr2.h5)
# test for file created by Lib SAF team
- ADD_H5_TEST (tsaf 0 tsaf.h5)
+ ADD_H5_TEST (tsaf 0 --enable-error-stack tsaf.h5)
# test for file with variable length data
- ADD_H5_TEST (tvldtypes1 0 tvldtypes1.h5)
- ADD_H5_TEST (tvldtypes2 0 tvldtypes2.h5)
- ADD_H5_TEST (tvldtypes3 0 tvldtypes3.h5)
- ADD_H5_TEST (tvldtypes4 0 tvldtypes4.h5)
- ADD_H5_TEST (tvldtypes5 0 tvldtypes5.h5)
+ ADD_H5_TEST (tvldtypes1 0 --enable-error-stack tvldtypes1.h5)
+ ADD_H5_TEST (tvldtypes2 0 --enable-error-stack tvldtypes2.h5)
+ ADD_H5_TEST (tvldtypes3 0 --enable-error-stack tvldtypes3.h5)
+ ADD_H5_TEST (tvldtypes4 0 --enable-error-stack tvldtypes4.h5)
+ ADD_H5_TEST (tvldtypes5 0 --enable-error-stack tvldtypes5.h5)
#test for file with variable length string data
- ADD_H5_TEST (tvlstr 0 tvlstr.h5)
+ ADD_H5_TEST (tvlstr 0 --enable-error-stack tvlstr.h5)
# test for files with array data
- ADD_H5_TEST (tarray1 0 tarray1.h5)
+ ADD_H5_TEST (tarray1 0 --enable-error-stack tarray1.h5)
# # added for bug# 2092 - tarray1_big.h5
+ # JIRA HDFFV-7936 ADD_H5_TEST (tarray1_big 0 --enable-error-stack -R tarray1_big.h5)
ADD_H5_TEST (tarray1_big 0 -R tarray1_big.h5)
- ADD_H5_TEST (tarray2 0 tarray2.h5)
- ADD_H5_TEST (tarray3 0 tarray3.h5)
- ADD_H5_TEST (tarray4 0 tarray4.h5)
- ADD_H5_TEST (tarray5 0 tarray5.h5)
- ADD_H5_TEST (tarray6 0 tarray6.h5)
- ADD_H5_TEST (tarray7 0 tarray7.h5)
- ADD_H5_TEST (tarray8 0 tarray8.h5)
+ ADD_H5_TEST (tarray2 0 --enable-error-stack tarray2.h5)
+ ADD_H5_TEST (tarray3 0 --enable-error-stack tarray3.h5)
+ ADD_H5_TEST (tarray4 0 --enable-error-stack tarray4.h5)
+ ADD_H5_TEST (tarray5 0 --enable-error-stack tarray5.h5)
+ ADD_H5_TEST (tarray6 0 --enable-error-stack tarray6.h5)
+ ADD_H5_TEST (tarray7 0 --enable-error-stack tarray7.h5)
+ ADD_H5_TEST (tarray8 0 --enable-error-stack tarray8.h5)
# test for files with empty data
- ADD_H5_TEST (tempty 0 tempty.h5)
+ ADD_H5_TEST (tempty 0 --enable-error-stack tempty.h5)
# test for files with groups that have comments
- ADD_H5_TEST (tgrp_comments 0 tgrp_comments.h5)
+ ADD_H5_TEST (tgrp_comments 0 --enable-error-stack tgrp_comments.h5)
# test the --filedriver flag
- ADD_H5_TEST (tsplit_file 0 --filedriver=split tsplit_file)
- ADD_H5_TEST (tfamily 0 --filedriver=family tfamily%05d.h5)
- ADD_H5_TEST (tmulti 0 --filedriver=multi tmulti)
+ ADD_H5_TEST (tsplit_file 0 --enable-error-stack --filedriver=split tsplit_file)
+ ADD_H5_TEST (tfamily 0 --enable-error-stack --filedriver=family tfamily%05d.h5)
+ ADD_H5_TEST (tmulti 0 --enable-error-stack --filedriver=multi tmulti)
# test for files with group names which reach > 1024 bytes in size
- ADD_H5_TEST (tlarge_objname 0 -w157 tlarge_objname.h5)
+ ADD_H5_TEST (tlarge_objname 0 --enable-error-stack -w157 tlarge_objname.h5)
# test '-A' to suppress data but print attr's
+ # JIRA HDFFV-7936 ADD_H5_TEST (tall-2A 0 --enable-error-stack -A tall.h5)
ADD_H5_TEST (tall-2A 0 -A tall.h5)
# test '-r' to print attributes in ASCII instead of decimal
+ # JIRA HDFFV-7936 ADD_H5_TEST (tall-2B 0 --enable-error-stack -A -r tall.h5)
ADD_H5_TEST (tall-2B 0 -A -r tall.h5)
# test Subsetting
- ADD_H5_TEST (tall-4s 0 --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5)
- ADD_H5_TEST (tall-5s 0 -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5)
- ADD_H5_TEST (tdset-3s 0 -d "/dset1[1,1;;;]" tdset.h5)
+ ADD_H5_TEST (tall-4s 0 --enable-error-stack --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5)
+ ADD_H5_TEST (tall-5s 0 --enable-error-stack -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5)
+ ADD_H5_TEST (tdset-3s 0 --enable-error-stack -d "/dset1[1,1;;;]" tdset.h5)
+ ADD_H5_TEST (tno-subset 0 --enable-error-stack --no-compact-subset -d "AHFINDERDIRECT::ah_centroid_t[0] it=0 tl=0" tno-subset.h5)
# test printing characters in ASCII instead of decimal
- ADD_H5_TEST (tchar1 0 -r tchar.h5)
+ ADD_H5_TEST (tchar1 0 --enable-error-stack -r tchar.h5)
# 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)
+ ADD_H5_TEST (tboot1 0 --enable-error-stack -H -B -d dset tfcontents1.h5)
+ ADD_H5_TEST (tboot2 0 --enable-error-stack -B tfcontents2.h5)
# test -p with a non existing dataset
ADD_H5_TEST (tperror 1 -p -d bogus tfcontents1.h5)
# test for file contents
- ADD_H5_TEST (tcontents 0 -n tfcontents1.h5)
+ ADD_H5_TEST (tcontents 0 --enable-error-stack -n tfcontents1.h5)
# tests for storage layout
# compact
- ADD_H5_TEST (tcompact 0 -H -p -d compact tfilters.h5)
+ ADD_H5_TEST (tcompact 0 --enable-error-stack -H -p -d compact tfilters.h5)
# contiguous
- ADD_H5_TEST (tcontiguos 0 -H -p -d contiguous tfilters.h5)
+ ADD_H5_TEST (tcontiguos 0 --enable-error-stack -H -p -d contiguous tfilters.h5)
# chunked
- ADD_H5_TEST (tchunked 0 -H -p -d chunked tfilters.h5)
+ ADD_H5_TEST (tchunked 0 --enable-error-stack -H -p -d chunked tfilters.h5)
# external
- ADD_H5_TEST (texternal 0 -H -p -d external tfilters.h5)
+ ADD_H5_TEST (texternal 0 --enable-error-stack -H -p -d external tfilters.h5)
# fill values
- ADD_H5_TEST (tfill 0 -p tfvalues.h5)
+ ADD_H5_TEST (tfill 0 --enable-error-stack -p tfvalues.h5)
# several datatype, with references , print path
- ADD_H5_TEST (treference 0 tattr2.h5)
+ ADD_H5_TEST (treference 0 --enable-error-stack tattr2.h5)
# escape/not escape non printable characters
- ADD_H5_TEST (tstringe 0 -e tstr3.h5)
- ADD_H5_TEST (tstring 0 tstr3.h5)
+ ADD_H5_TEST (tstringe 0 --enable-error-stack -e tstr3.h5)
+ ADD_H5_TEST (tstring 0 --enable-error-stack tstr3.h5)
# char data as ASCII with non escape
- ADD_H5_TEST (tstring2 0 -r -d str4 tstr3.h5)
+ ADD_H5_TEST (tstring2 0 --enable-error-stack -r -d str4 tstr3.h5)
# array indices print/not print
- ADD_H5_TEST (tindicesyes 0 taindices.h5)
- ADD_H5_TEST (tindicesno 0 -y taindices.h5)
+ ADD_H5_TEST (tindicesyes 0 --enable-error-stack taindices.h5)
+ ADD_H5_TEST (tindicesno 0 --enable-error-stack -y taindices.h5)
########## array indices with subsetting
# 1D case
- ADD_H5_TEST (tindicessub1 0 -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5)
+ ADD_H5_TEST (tindicessub1 0 --enable-error-stack -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5)
# 2D case
- ADD_H5_TEST (tindicessub2 0 -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5)
+ ADD_H5_TEST (tindicessub2 0 --enable-error-stack -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5)
# 3D case
- ADD_H5_TEST (tindicessub3 0 -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5)
+ ADD_H5_TEST (tindicessub3 0 --enable-error-stack -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5)
# 4D case
- ADD_H5_TEST (tindicessub4 0 -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5)
+ ADD_H5_TEST (tindicessub4 0 --enable-error-stack -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5)
# Exceed the dimensions for subsetting
ADD_H5_TEST (texceedsubstart 1 -d 1d -s 1,3 taindices.h5)
@@ -1129,34 +1141,34 @@ IF (BUILD_TESTING)
ADD_SKIP_H5_TEST (tallfilters 0 ${TESTTYPE} -H -p -d all tfilters.h5)
# user defined
- ADD_H5_TEST (tuserfilter 0 -H -p -d myfilter tfilters.h5)
+ ADD_H5_TEST (tuserfilter 0 --enable-error-stack -H -p -d myfilter tfilters.h5)
# test for displaying objects with very long names
- ADD_H5_TEST (tlonglinks 0 tlonglinks.h5)
+ ADD_H5_TEST (tlonglinks 0 --enable-error-stack tlonglinks.h5)
# dimensions over 4GB, print boundary
- ADD_H5_TEST (tbigdims 0 -d dset4gb -s 4294967284 -c 22 tbigdims.h5)
+ ADD_H5_TEST (tbigdims 0 --enable-error-stack -d dset4gb -s 4294967284 -c 22 tbigdims.h5)
# hyperslab read
- ADD_H5_TEST (thyperslab 0 thyperslab.h5)
+ ADD_H5_TEST (thyperslab 0 --enable-error-stack thyperslab.h5)
# test for displaying dataset and attribute of null space
- ADD_H5_TEST (tnullspace 0 tnullspace.h5)
+ ADD_H5_TEST (tnullspace 0 --enable-error-stack tnullspace.h5)
# test for displaying dataset and attribute of space with 0 dimension size
- ADD_H5_TEST (zerodim 0 zerodim.h5)
+ ADD_H5_TEST (zerodim 0 --enable-error-stack zerodim.h5)
# test for long double (some systems do not have long double)
- #ADD_H5_TEST (tldouble 0 tldouble.h5)
+ #ADD_H5_TEST (tldouble 0 --enable-error-stack tldouble.h5)
# test for vms
- ADD_H5_TEST (tvms 0 tvms.h5)
+ ADD_H5_TEST (tvms 0 --enable-error-stack tvms.h5)
# test for binary output
- ADD_H5_TEST (tbin1LE 0 -d integer -o out1LE.bin -b LE tbinary.h5)
+ ADD_H5_TEST (tbin1LE 0 --enable-error-stack -d integer -o out1LE.bin -b LE tbinary.h5)
# NATIVE default. the NATIVE test can be validated with h5import/h5diff
- ADD_H5_TEST (tbin1 0 -d integer -o out1.bin -b tbinary.h5)
+ ADD_H5_TEST (tbin1 0 --enable-error-stack -d integer -o out1.bin -b tbinary.h5)
IF (NOT HDF5_ENABLE_USING_MEMCHECKER)
IF (NOT "${last_test}" STREQUAL "")
SET_TESTS_PROPERTIES (H5DUMP-tbin1 PROPERTIES DEPENDS ${last_test})
@@ -1174,7 +1186,7 @@ IF (BUILD_TESTING)
SET_TESTS_PROPERTIES (H5DUMP-h5diff-out1 PROPERTIES DEPENDS H5DUMP-h5import-out1)
SET (last_test "H5DUMP-h5diff-out1")
- ADD_H5_TEST (tbin2 0 -b BE -d float -o out2.bin tbinary.h5)
+ ADD_H5_TEST (tbin2 0 --enable-error-stack -b BE -d float -o out2.bin tbinary.h5)
IF (NOT HDF5_ENABLE_USING_MEMCHECKER)
IF (NOT "${last_test}" STREQUAL "")
SET_TESTS_PROPERTIES (H5DUMP-tbin2 PROPERTIES DEPENDS ${last_test})
@@ -1183,7 +1195,7 @@ IF (BUILD_TESTING)
ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER)
# the NATIVE test can be validated with h5import/h5diff
- ADD_H5_TEST (tbin3 0 -d integer -o out3.bin -b NATIVE tbinary.h5)
+ ADD_H5_TEST (tbin3 0 --enable-error-stack -d integer -o out3.bin -b NATIVE tbinary.h5)
IF (NOT HDF5_ENABLE_USING_MEMCHECKER)
IF (NOT "${last_test}" STREQUAL "")
SET_TESTS_PROPERTIES (H5DUMP-tbin3 PROPERTIES DEPENDS ${last_test})
@@ -1201,7 +1213,7 @@ IF (BUILD_TESTING)
SET_TESTS_PROPERTIES (H5DUMP-h5diff-out3 PROPERTIES DEPENDS H5DUMP-h5import-out3)
SET (last_test "H5DUMP-h5diff-out3")
- ADD_H5_TEST (tbin4 0 -d double -b FILE -o out4.bin tbinary.h5)
+ ADD_H5_TEST (tbin4 0 --enable-error-stack -d double -b FILE -o out4.bin tbinary.h5)
IF (NOT HDF5_ENABLE_USING_MEMCHECKER)
IF (NOT "${last_test}" STREQUAL "")
SET_TESTS_PROPERTIES (H5DUMP-tbin4 PROPERTIES DEPENDS ${last_test})
@@ -1230,41 +1242,46 @@ IF (BUILD_TESTING)
SET (last_test "H5DUMP-clear-objects")
# test for dataset region references
- ADD_H5_TEST (tdatareg 0 tdatareg.h5)
+ ADD_H5_TEST (tdatareg 0 --enable-error-stack tdatareg.h5)
+ # JIRA HDFFV-7936 ADD_H5_TEST (tdataregR 0 --enable-error-stack -R tdatareg.h5)
ADD_H5_TEST (tdataregR 0 -R tdatareg.h5)
- ADD_H5_TEST (tattrreg 0 tattrreg.h5)
+ ADD_H5_TEST (tattrreg 0 --enable-error-stack tattrreg.h5)
+ # JIRA HDFFV-7936 ADD_H5_TEST (tattrregR 0 --enable-error-stack -R tattrreg.h5)
ADD_H5_TEST (tattrregR 0 -R tattrreg.h5)
- ADD_H5_EXPORT_TEST (tbinregR tdatareg.h5 0 -d /Dataset1 -s 0 -R -y -o)
+ ADD_H5_EXPORT_TEST (tbinregR tdatareg.h5 0 --enable-error-stack -d /Dataset1 -s 0 -R -y -o)
# tests for group creation order
# "1" tracked, "2" name, root tracked
- ADD_H5_TEST (tordergr1 0 --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5)
- ADD_H5_TEST (tordergr2 0 --group=1 --sort_by=creation_order --sort_order=descending tordergr.h5)
- ADD_H5_TEST (tordergr3 0 -g 2 -q name -z ascending tordergr.h5)
- ADD_H5_TEST (tordergr4 0 -g 2 -q name -z descending tordergr.h5)
- ADD_H5_TEST (tordergr5 0 -q creation_order tordergr.h5)
+ ADD_H5_TEST (tordergr1 0 --enable-error-stack --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5)
+ ADD_H5_TEST (tordergr2 0 --enable-error-stack --group=1 --sort_by=creation_order --sort_order=descending tordergr.h5)
+ ADD_H5_TEST (tordergr3 0 --enable-error-stack -g 2 -q name -z ascending tordergr.h5)
+ ADD_H5_TEST (tordergr4 0 --enable-error-stack -g 2 -q name -z descending tordergr.h5)
+ ADD_H5_TEST (tordergr5 0 --enable-error-stack -q creation_order tordergr.h5)
# tests for attribute order
- ADD_H5_TEST (torderattr1 0 -H --sort_by=name --sort_order=ascending torderattr.h5)
- ADD_H5_TEST (torderattr2 0 -H --sort_by=name --sort_order=descending torderattr.h5)
- ADD_H5_TEST (torderattr3 0 -H --sort_by=creation_order --sort_order=ascending torderattr.h5)
- ADD_H5_TEST (torderattr4 0 -H --sort_by=creation_order --sort_order=descending torderattr.h5)
+ ADD_H5_TEST (torderattr1 0 --enable-error-stack -H --sort_by=name --sort_order=ascending torderattr.h5)
+ ADD_H5_TEST (torderattr2 0 --enable-error-stack -H --sort_by=name --sort_order=descending torderattr.h5)
+ ADD_H5_TEST (torderattr3 0 --enable-error-stack -H --sort_by=creation_order --sort_order=ascending torderattr.h5)
+ ADD_H5_TEST (torderattr4 0 --enable-error-stack -H --sort_by=creation_order --sort_order=descending torderattr.h5)
# tests for floating point user defined printf format
- ADD_H5_TEST (tfpformat 0 -m %.7f tfpformat.h5)
+ ADD_H5_TEST (tfpformat 0 --enable-error-stack -m %.7f tfpformat.h5)
# tests for traversal of external links
+ # JIRA HDFFV-7936 ADD_H5_TEST (textlinksrc 0 --enable-error-stack textlinksrc.h5)
ADD_H5_TEST (textlinksrc 0 textlinksrc.h5)
+ # JIRA HDFFV-7936 ADD_H5_TEST (textlinkfar 0 --enable-error-stack textlinkfar.h5)
ADD_H5_TEST (textlinkfar 0 textlinkfar.h5)
# test for dangling external links
+ # JIRA HDFFV-7936 ADD_H5_TEST (textlink 0 --enable-error-stack textlink.h5)
ADD_H5_TEST (textlink 0 textlink.h5)
# test for error stack display (BZ2048)
ADD_H5_MASK_TEST (filter_fail 1 --enable-error-stack filter_fail.h5)
# test for -o -y for dataset with attributes
- ADD_H5_TEST (tall-6 0 -y -o data -d /g1/g1.1/dset1.1.1 tall.h5)
+ ADD_H5_TEST (tall-6 0 --enable-error-stack -y -o data -d /g1/g1.1/dset1.1.1 tall.h5)
####### test for dataset packed bits ######
IF (HDF5_ENABLE_USING_MEMCHECKER)
@@ -1273,6 +1290,8 @@ IF (BUILD_TESTING)
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
@@ -1386,7 +1405,7 @@ IF (BUILD_TESTING)
# test failure handling
# Missing file name
- ADD_H5_TEST (tnofilename 1)
+ 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).
@@ -1396,70 +1415,70 @@ IF (BUILD_TESTING)
# 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)
+ ADD_H5_TEST (tpbitsSignedWhole 0 --enable-error-stack -d /DS08BITS -M 0,8 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedWhole 0 --enable-error-stack -d /DU08BITS -M 0,8 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedIntWhole 0 --enable-error-stack -d /DS16BITS -M 0,16 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedIntWhole 0 --enable-error-stack -d /DU16BITS -M 0,16 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLongWhole 0 --enable-error-stack -d /DS32BITS -M 0,32 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLongWhole 0 --enable-error-stack -d /DU32BITS -M 0,32 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLongLongWhole 0 --enable-error-stack -d /DS64BITS -M 0,64 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLongLongWhole 0 --enable-error-stack -d /DU64BITS -M 0,64 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLongLongWhole63 0 --enable-error-stack -d /DS64BITS -M 0,63 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLongLongWhole63 0 --enable-error-stack -d /DU64BITS -M 0,63 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLongLongWhole1 0 --enable-error-stack -d /DS64BITS -M 1,63 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLongLongWhole1 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsSigned4 0 --enable-error-stack -d /DS08BITS -M 0,4,4,4 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsigned4 0 --enable-error-stack -d /DU08BITS -M 0,4,4,4 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedInt8 0 --enable-error-stack -d /DS16BITS -M 0,8,8,8 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedInt8 0 --enable-error-stack -d /DU16BITS -M 0,8,8,8 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLong16 0 --enable-error-stack -d /DS32BITS -M 0,16,16,16 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLong16 0 --enable-error-stack -d /DU32BITS -M 0,16,16,16 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLongLong32 0 --enable-error-stack -d /DS64BITS -M 0,32,32,32 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLongLong32 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsSigned2 0 --enable-error-stack -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsigned2 0 --enable-error-stack -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedInt4 0 --enable-error-stack -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedInt4 0 --enable-error-stack -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLong8 0 --enable-error-stack -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLong8 0 --enable-error-stack -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLongLong16 0 --enable-error-stack -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLongLong16 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsSigned 0 --enable-error-stack -d /DS08BITS -M 0,2,2,6 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsigned 0 --enable-error-stack -d /DU08BITS -M 0,2,2,6 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedInt 0 --enable-error-stack -d /DS16BITS -M 0,2,10,6 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedInt 0 --enable-error-stack -d /DU16BITS -M 0,2,10,6 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLong 0 --enable-error-stack -d /DS32BITS -M 0,2,26,6 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLong 0 --enable-error-stack -d /DU32BITS -M 0,2,26,6 packedbits.h5)
+ ADD_H5_TEST (tpbitsSignedLongLong 0 --enable-error-stack -d /DS64BITS -M 0,2,58,6 packedbits.h5)
+ ADD_H5_TEST (tpbitsUnsignedLongLong 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsOverlapped 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsMax 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsCompound 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsArray 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsCharOffsetExceeded 0 --enable-error-stack -d /DS08BITS -M 8,1 packedbits.h5)
+ ADD_H5_TEST (tpbitsIntOffsetExceeded 0 --enable-error-stack -d /DS16BITS -M 16,1 packedbits.h5)
+ ADD_H5_TEST (tpbitsLongOffsetExceeded 0 --enable-error-stack -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)
+ ADD_H5_TEST (tpbitsCharLengthExceeded 0 --enable-error-stack -d /DS08BITS -M 2,7 packedbits.h5)
+ ADD_H5_TEST (tpbitsIntLengthExceeded 0 --enable-error-stack -d /DS16BITS -M 10,7 packedbits.h5)
+ ADD_H5_TEST (tpbitsLongLengthExceeded 0 --enable-error-stack -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)
diff --git a/tools/h5dump/Makefile.am b/tools/h5dump/Makefile.am
index 81e38d1..97d81c2 100644
--- a/tools/h5dump/Makefile.am
+++ b/tools/h5dump/Makefile.am
@@ -40,6 +40,9 @@ h5dump_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
# All the programs depend on the hdf5 and h5tools libraries
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+# Source files for the program
+h5dump_SOURCES=h5dump.c h5dump_ddl.c h5dump_xml.c
+
# Temporary files. *.h5 are generated by h5dumpgentest. They should
# copied to the testfiles/ directory if update is required.
CHECK_CLEANFILES+=*.h5 *.bin
diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in
index 7d462bf..9d46557 100644
--- a/tools/h5dump/Makefile.in
+++ b/tools/h5dump/Makefile.in
@@ -77,8 +77,9 @@ binread_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
-h5dump_SOURCES = h5dump.c
-h5dump_OBJECTS = h5dump.$(OBJEXT)
+am_h5dump_OBJECTS = h5dump.$(OBJEXT) h5dump_ddl.$(OBJEXT) \
+ h5dump_xml.$(OBJEXT)
+h5dump_OBJECTS = $(am_h5dump_OBJECTS)
h5dump_LDADD = $(LDADD)
h5dump_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5)
h5dump_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -114,8 +115,8 @@ am__v_CCLD_0 = @echo " CCLD " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = binread.c h5dump.c h5dumpgentest.c
-DIST_SOURCES = binread.c h5dump.c h5dumpgentest.c
+SOURCES = binread.c $(h5dump_SOURCES) h5dumpgentest.c
+DIST_SOURCES = binread.c $(h5dump_SOURCES) h5dumpgentest.c
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@@ -420,6 +421,9 @@ h5dump_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
# All the programs depend on the hdf5 and h5tools libraries
LDADD = $(LIBH5TOOLS) $(LIBHDF5)
+
+# Source files for the program
+h5dump_SOURCES = h5dump.c h5dump_ddl.c h5dump_xml.c
DISTCLEANFILES = testh5dump.sh
# Automake needs to be taught how to build lib, progs, and tests targets.
@@ -545,6 +549,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binread.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5dump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5dump_ddl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5dump_xml.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5dumpgentest.Po@am__quote@
.c.o:
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 147f6ab..73bfd13 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -16,383 +16,46 @@
#include <stdlib.h>
#include "h5dump.h"
-#include "H5private.h"
-#include "h5tools.h"
-#include "h5tools_utils.h"
-#include "h5tools_ref.h"
-#include "h5trav.h"
+#include "h5dump_ddl.h"
+#include "h5dump_xml.h"
/* Name of tool */
#define PROGRAMNAME "h5dump"
-/* Macros for displaying objects */
-#define begin_obj(obj,name,begin) \
- do { \
- if (name) \
- HDfprintf(stdout, "%s \"%s\" %s\n", (obj), (name), (begin)); \
- else \
- HDfprintf(stdout, "%s %s\n", (obj), (begin)); \
- } while(0);
-
-#define end_obj(obj,end) \
- do { \
- if(HDstrlen(end)) { \
- HDfprintf(stdout, "%s", end); \
- if(HDstrlen(obj)) \
- HDfprintf(stdout, " "); \
- } \
- if(HDstrlen(obj)) \
- HDfprintf(stdout, "%s", obj); \
- HDfprintf(stdout, "\n"); \
- } while(0);
-
-/* 3 private values: can't be set, but can be read.
- Note: these are defined in H5Zprivate, they are
- duplicated here.
- */
-#define H5_SZIP_LSB_OPTION_MASK 8
-#define H5_SZIP_MSB_OPTION_MASK 16
-#define H5_SZIP_RAW_OPTION_MASK 128
-
-/* List of table structures. There is one table structure for each file */
-typedef struct h5dump_table_list_t {
- size_t nalloc;
- size_t nused;
- struct {
- unsigned long fileno; /* File number that these tables refer to */
- hid_t oid; /* ID of an object in this file, held open so fileno is consistent */
- table_t *group_table; /* Table of groups */
- table_t *dset_table; /* Table of datasets */
- table_t *type_table; /* Table of datatypes */
- } *tables;
-} h5dump_table_list_t;
-
-static int unamedtype = 0; /* shared datatype with no name */
-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 = 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;
const char *outfname=NULL;
-
-
-/* things to display or which are set via command line parameters */
-static int display_all = TRUE;
-static int display_oid = FALSE;
-static int display_data = TRUE;
-static int display_attr_data = TRUE;
-static int display_char = FALSE; /*print 1-byte numbers as ASCII */
-static int usingdasho = FALSE;
-static int display_bb = FALSE; /*superblock */
-static int display_dcpl = FALSE; /*dcpl */
-static int display_fi = FALSE; /*file index */
-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 */
-static int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/
-
-/* 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] */
-
-#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];
-
-/**
-** Added for XML **
-**/
+static int doxml = 0;
+static int useschema = 1;
+static const char *xml_dtd_uri = NULL;
/* module-scoped variables for XML option */
#define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd"
#define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.dtd"
-static int doxml = 0;
-static int useschema = 1;
-static const char *xml_dtd_uri = NULL;
-static const char *xmlnsprefix="hdf5:";
-static int indent; /*how far in to indent the line */
-
-/** end XML **/
-
-/* internal functions */
-static hid_t h5_fileaccess(void);
-static void dump_oid(hid_t oid);
-static void dump_packed_bits(unsigned int packed_index, hid_t type);
-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);
-static void add_prefix(char **prfx, size_t *prfx_len, const char *name);
-/* callback function used by H5Literate() */
-static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void *op_data);
-static int dump_extlink(hid_t group, const char *linkname, const char *objname);
-
-
-
-static h5tool_format_t dataformat = {
- 0, /*raw */
-
- "", /*fmt_raw */
- "%d", /*fmt_int */
- "%u", /*fmt_uint */
-#ifdef H5_VMS
- "%hd", /*fmt_schar */
-#else
- "%hhd", /*fmt_schar */
-#endif
- "%u", /*fmt_uchar */
- "%d", /*fmt_short */
- "%u", /*fmt_ushort */
- "%ld", /*fmt_long */
- "%lu", /*fmt_ulong */
- NULL, /*fmt_llong */
- NULL, /*fmt_ullong */
- "%g", /*fmt_double */
- "%g", /*fmt_float */
-
- 0, /*ascii */
- 0, /*str_locale */
- 0, /*str_repeat */
-
- "[ ", /*arr_pre */
- ",", /*arr_sep */
- " ]", /*arr_suf */
- 1, /*arr_linebreak */
-
- "", /*cmpd_name */
- ",\n", /*cmpd_sep */
- "{\n", /*cmpd_pre */
- "}", /*cmpd_suf */
- "\n", /*cmpd_end */
-
- ", ", /*vlen_sep */
- "(", /*vlen_pre */
- ")", /*vlen_suf */
- "", /*vlen_end */
-
- "%s", /*elmt_fmt */
- ",", /*elmt_suf1 */
- " ", /*elmt_suf2 */
-
- "", /*idx_n_fmt */
- "", /*idx_sep */
- "", /*idx_fmt */
-
- 80, /*line_ncols *//*standard default columns */
- 0, /*line_per_line */
- "", /*line_pre */
- "%s", /*line_1st */
- "%s", /*line_cont */
- "", /*line_suf */
- "", /*line_sep */
- 1, /*line_multi_new */
- " ", /*line_indent */
-
- 1, /*skip_first */
-
- 1, /*obj_hidefileno */
- " "H5_PRINTF_HADDR_FMT, /*obj_format */
-
- 1, /*dset_hidefileno */
- "DATASET %s ", /*dset_format */
- "%s", /*dset_blockformat_pre */
- "%s", /*dset_ptformat_pre */
- "%s", /*dset_ptformat */
- 1, /*array indices */
- 1 /*escape non printable characters */
-};
-
-/**
-** Added for XML **
-**/
-/*
- * Alternative formating for data dumped to XML
- * In general, the numbers are the same, but separators
- * except spaces are not used.
- *
- * Some of these are not used, as some kinds of data are
- * dumped in completely new subroutines.
- *
- * Some of this formatting may yet need to change.
- *
- * This table only affects XML output.
- */
-static h5tool_format_t xml_dataformat = {
- 0, /*raw */
-
- "", /*fmt_raw */
- "%d", /*fmt_int */
- "%u", /*fmt_uint */
-#ifdef H5_VMS
- "%hd", /*fmt_schar */
-#else
- "%hhd", /*fmt_schar */
-#endif
- "%u", /*fmt_uchar */
- "%d", /*fmt_short */
- "%u", /*fmt_ushort */
- "%ld", /*fmt_long */
- "%lu", /*fmt_ulong */
- NULL, /*fmt_llong */
- NULL, /*fmt_ullong */
- "%g", /*fmt_double */
- "%g", /*fmt_float */
-
- 0, /*ascii */
- 0, /*str_locale */
- 0, /*str_repeat */
-
- " ", /*arr_pre */
- "", /*arr_sep */
- "", /*arr_suf */
- 1, /*arr_linebreak */
-
- "", /*cmpd_name */
- " ", /*cmpd_sep */
- "", /*cmpd_pre */
- "", /*cmpd_suf */
- "", /*cmpd_end */
-
- " ", /*vlen_sep */
- " ", /*vlen_pre */
- "", /*vlen_suf */
- "", /*vlen_end */
-
- "%s", /*elmt_fmt */
- "", /*elmt_suf1 */
- " ", /*elmt_suf2 */
-
- "", /*idx_n_fmt */
- "", /*idx_sep */
- "", /*idx_fmt */
-
- 80, /*line_ncols *//*standard default columns */
- 0, /*line_per_line */
- "", /*line_pre */
- "%s", /*line_1st */
- "%s", /*line_cont */
- "", /*line_suf */
- "", /*line_sep */
- 1, /*line_multi_new */
- " ", /*line_indent */
-
- 1, /*skip_first */
-
- 1, /*obj_hidefileno */
- " "H5_PRINTF_HADDR_FMT, /*obj_format */
-
- 1, /*dset_hidefileno */
- "DATASET %s ", /*dset_format */
- "%s", /*dset_blockformat_pre */
- "%s", /*dset_ptformat_pre */
- "%s", /*dset_ptformat */
- 0, /*array indices */
- 0 /*escape non printable characters */
+/* Standard DDL output */
+static const dump_functions ddl_function_table = {
+ dump_group,
+ dump_named_datatype,
+ dump_dataset,
+ dump_dataspace,
+ dump_datatype,
+ dump_attr_cb,
+ dump_data
};
-/** XML **/
-
-static const h5dump_header_t standardformat = {
- "standardformat", /*name */
- "HDF5", /*fileebgin */
- "", /*fileend */
- SUPER_BLOCK, /*bootblockbegin */
- "", /*bootblockend */
- H5_TOOLS_GROUP, /*groupbegin */
- "", /*groupend */
- H5_TOOLS_DATASET, /*datasetbegin */
- "", /*datasetend */
- ATTRIBUTE, /*attributebegin */
- "", /*attributeend */
- H5_TOOLS_DATATYPE, /*datatypebegin */
- "", /*datatypeend */
- DATASPACE, /*dataspacebegin */
- "", /*dataspaceend */
- DATA, /*databegin */
- "", /*dataend */
- SOFTLINK, /*softlinkbegin */
- "", /*softlinkend */
- EXTLINK, /*extlinkbegin */
- "", /*extlinkend */
- UDLINK, /*udlinkbegin */
- "", /*udlinkend */
- SUBSET, /*subsettingbegin */
- "", /*subsettingend */
- START, /*startbegin */
- "", /*startend */
- STRIDE, /*stridebegin */
- "", /*strideend */
- COUNT, /*countbegin */
- "", /*countend */
- BLOCK, /*blockbegin */
- "", /*blockend */
-
- "{", /*fileblockbegin */
- "}", /*fileblockend */
- "{", /*bootblockblockbegin */
- "}", /*bootblockblockend */
- "{", /*groupblockbegin */
- "}", /*groupblockend */
- "{", /*datasetblockbegin */
- "}", /*datasetblockend */
- "{", /*attributeblockbegin */
- "}", /*attributeblockend */
- "", /*datatypeblockbegin */
- "", /*datatypeblockend */
- "", /*dataspaceblockbegin */
- "", /*dataspaceblockend */
- "{", /*datablockbegin */
- "}", /*datablockend */
- "{", /*softlinkblockbegin */
- "}", /*softlinkblockend */
- "{", /*extlinkblockbegin */
- "}", /*extlinkblockend */
- "{", /*udlinkblockbegin */
- "}", /*udlinkblockend */
- "{", /*strblockbegin */
- "}", /*strblockend */
- "{", /*enumblockbegin */
- "}", /*enumblockend */
- "{", /*structblockbegin */
- "}", /*structblockend */
- "{", /*vlenblockbegin */
- "}", /*vlenblockend */
- "{", /*subsettingblockbegin */
- "}", /*subsettingblockend */
- "(", /*startblockbegin */
- ");", /*startblockend */
- "(", /*strideblockbegin */
- ");", /*strideblockend */
- "(", /*countblockbegin */
- ");", /*countblockend */
- "(", /*blockblockbegin */
- ");", /*blockblockend */
-
- "", /*dataspacedescriptionbegin */
- "", /*dataspacedescriptionend */
- "(", /*dataspacedimbegin */
- ")", /*dataspacedimend */
+/* XML output */
+static const dump_functions xml_function_table = {
+ xml_dump_group,
+ xml_dump_named_datatype,
+ xml_dump_dataset,
+ xml_dump_dataspace,
+ xml_dump_datatype,
+ xml_dump_attr,
+ xml_dump_data
};
-/**
-** Added for XML **
-**/
-/* internal functions used by XML option */
-static void xml_print_datatype(hid_t, unsigned);
-static void xml_print_enum(hid_t);
-static int xml_print_refs(hid_t, int);
-static int xml_print_strs(hid_t, int);
-static char *xml_escape_the_string(const char *, int);
-static char *xml_escape_the_name(const char *);
+/* internal functions */
+static void init_prefix(char **prfx, size_t prfx_len);
/* a structure for handling the order command-line parameters come in */
struct handler_t {
@@ -408,209 +71,126 @@ 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:REM:";
+static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:RECM:";
static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "hel", no_arg, 'h' },
- { "contents", no_arg, 'n' },
- { "properties", no_arg, 'p' },
- { "boot-block", no_arg, 'B' },
- { "boot-bloc", no_arg, 'B' },
- { "boot-blo", no_arg, 'B' },
- { "boot-bl", no_arg, 'B' },
- { "boot-b", no_arg, 'B' },
- { "boot", no_arg, 'B' },
- { "boo", no_arg, 'B' },
- { "bo", no_arg, 'B' },
- { "header", no_arg, 'H' },
- { "heade", no_arg, 'H' },
- { "head", no_arg, 'H' },
- { "hea", no_arg, 'H' },
- { "object-ids", no_arg, 'i' },
- { "object-id", no_arg, 'i' },
- { "object-i", no_arg, 'i' },
- { "object", no_arg, 'i' },
- { "objec", no_arg, 'i' },
- { "obje", no_arg, 'i' },
- { "obj", no_arg, 'i' },
- { "ob", no_arg, 'i' },
- { "version", no_arg, 'V' },
- { "versio", no_arg, 'V' },
- { "versi", no_arg, 'V' },
- { "vers", no_arg, 'V' },
- { "ver", no_arg, 'V' },
- { "ve", no_arg, 'V' },
- { "attribute", require_arg, 'a' },
- { "attribut", require_arg, 'a' },
- { "attribu", require_arg, 'a' },
- { "attrib", require_arg, 'a' },
- { "attri", require_arg, 'a' },
- { "attr", require_arg, 'a' },
- { "att", require_arg, 'a' },
- { "at", require_arg, 'a' },
- { "block", require_arg, 'k' },
- { "bloc", require_arg, 'k' },
- { "blo", require_arg, 'k' },
- { "bl", require_arg, 'k' },
- { "count", require_arg, 'c' },
- { "coun", require_arg, 'c' },
- { "cou", require_arg, 'c' },
- { "co", require_arg, 'c' },
- { "dataset", require_arg, 'd' },
- { "datase", require_arg, 'd' },
- { "datas", require_arg, 'd' },
- { "datatype", require_arg, 't' },
- { "datatyp", require_arg, 't' },
- { "dataty", require_arg, 't' },
- { "datat", require_arg, 't' },
- { "filedriver", require_arg, 'f' },
- { "filedrive", require_arg, 'f' },
- { "filedriv", require_arg, 'f' },
- { "filedri", require_arg, 'f' },
- { "filedr", require_arg, 'f' },
- { "filed", require_arg, 'f' },
- { "file", require_arg, 'f' },
- { "fil", require_arg, 'f' },
- { "fi", require_arg, 'f' },
- { "group", require_arg, 'g' },
- { "grou", require_arg, 'g' },
- { "gro", require_arg, 'g' },
- { "gr", require_arg, 'g' },
- { "output", require_arg, 'o' },
- { "outpu", require_arg, 'o' },
- { "outp", require_arg, 'o' },
- { "out", require_arg, 'o' },
- { "ou", require_arg, 'o' },
- { "soft-link", require_arg, 'l' },
- { "soft-lin", require_arg, 'l' },
- { "soft-li", require_arg, 'l' },
- { "soft-l", require_arg, 'l' },
- { "soft", require_arg, 'l' },
- { "sof", require_arg, 'l' },
- { "start", require_arg, 's' },
- { "star", require_arg, 's' },
- { "sta", require_arg, 's' },
- { "stride", require_arg, 'S' },
- { "strid", require_arg, 'S' },
- { "string", no_arg, 'r' },
- { "strin", no_arg, 'r' },
- { "use-dtd", no_arg, 'u' },
- { "use-dt", no_arg, 'u' },
- { "use-d", no_arg, 'u' },
- { "use-", no_arg, 'u' },
- { "use", no_arg, 'u' },
- { "us", no_arg, 'u' },
- { "u", no_arg, 'u' },
- { "width", require_arg, 'w' },
- { "widt", require_arg, 'w' },
- { "wid", require_arg, 'w' },
- { "wi", require_arg, 'w' },
- { "xml-dtd", require_arg, 'D' },
- { "xml-dt", require_arg, 'D' },
- { "xml-d", require_arg, 'D' },
- { "xml-ns", require_arg, 'X' },
- { "xml-n", require_arg, 'X' },
- { "xml", no_arg, 'x' },
- { "xm", no_arg, 'x' },
- { "onlyattr", no_arg, 'A' },
- { "escape", no_arg, 'e' },
- { "noindex", no_arg, 'y' },
- { "binary", optional_arg, 'b' },
- { "form", require_arg, 'F' },
- { "sort_by", require_arg, 'q' },
- { "sort_order", require_arg, 'z' },
- { "format", require_arg, 'm' },
- { "region", no_arg, 'R' },
- { "enable-error-stack", no_arg, 'E' },
- { "packed-bits", require_arg, 'M' },
- { NULL, 0, '\0' }
-};
-
-
-/**
-** Change for XML **
-**
-** The 'dump_xxx' functions have two versions, standard and XML.
-**
-** They are called indirectly through the 'dump_function_table'.
-** e.g., dump_group(...) becomes dump_functions->dump_group(...);
-**
-** The standard functions are unchanged except for the way
-** they are called
-**/
-
-/* The dump functions of the dump_function_table */
-
-/* standard format: no change */
-static void dump_group(hid_t, const char *);
-static void dump_named_datatype(hid_t, const char *);
-static void dump_dataset(hid_t, const char *, struct subset_t *);
-static void dump_dataspace(hid_t space);
-static void dump_datatype(hid_t type);
-static void dump_data(hid_t, int, struct subset_t *, int);
-static void dump_dcpl(hid_t dcpl, hid_t type_id, hid_t obj_id);
-static void dump_comment(hid_t obj_id);
-static void dump_fcpl(hid_t fid);
-static void dump_fcontents(hid_t fid);
-/* callback function used by H5Aiterate2() */
-static herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data);
-
-
-/* XML format: same interface, alternative output */
-
-static void xml_dump_group(hid_t, const char *);
-static void xml_dump_named_datatype(hid_t, const char *);
-static void xml_dump_dataset(hid_t, const char *, struct subset_t *);
-static void xml_dump_dataspace(hid_t space);
-static void xml_dump_datatype(hid_t type);
-static herr_t xml_dump_attr(hid_t, const char *, const H5A_info_t *, void *);
-static void xml_dump_data(hid_t, int, struct subset_t *, int);
-
-/**
-** Added for XML **
-**
-** This is the global dispatch table for the dump functions.
-**/
-/* the table of dump functions */
-typedef struct dump_functions_t {
- void (*dump_group_function) (hid_t, const char *);
- void (*dump_named_datatype_function) (hid_t, const char *);
- void (*dump_dataset_function) (hid_t, const char *, struct subset_t *);
- void (*dump_dataspace_function) (hid_t);
- void (*dump_datatype_function) (hid_t);
- herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *);
- void (*dump_data_function) (hid_t, int, struct subset_t *, int);
-} dump_functions;
-
-/* Standard DDL output */
-static const dump_functions ddl_function_table = {
- dump_group,
- dump_named_datatype,
- dump_dataset,
- dump_dataspace,
- dump_datatype,
- dump_attr_cb,
- dump_data
-};
-
-/* XML output */
-static const dump_functions xml_function_table = {
- xml_dump_group,
- xml_dump_named_datatype,
- xml_dump_dataset,
- xml_dump_dataspace,
- xml_dump_datatype,
- xml_dump_attr,
- xml_dump_data
+ { "help", no_arg, 'h' },
+ { "hel", no_arg, 'h' },
+ { "contents", no_arg, 'n' },
+ { "properties", no_arg, 'p' },
+ { "boot-block", no_arg, 'B' },
+ { "boot-bloc", no_arg, 'B' },
+ { "boot-blo", no_arg, 'B' },
+ { "boot-bl", no_arg, 'B' },
+ { "boot-b", no_arg, 'B' },
+ { "boot", no_arg, 'B' },
+ { "boo", no_arg, 'B' },
+ { "bo", no_arg, 'B' },
+ { "header", no_arg, 'H' },
+ { "heade", no_arg, 'H' },
+ { "head", no_arg, 'H' },
+ { "hea", no_arg, 'H' },
+ { "object-ids", no_arg, 'i' },
+ { "object-id", no_arg, 'i' },
+ { "object-i", no_arg, 'i' },
+ { "object", no_arg, 'i' },
+ { "objec", no_arg, 'i' },
+ { "obje", no_arg, 'i' },
+ { "obj", no_arg, 'i' },
+ { "ob", no_arg, 'i' },
+ { "version", no_arg, 'V' },
+ { "versio", no_arg, 'V' },
+ { "versi", no_arg, 'V' },
+ { "vers", no_arg, 'V' },
+ { "ver", no_arg, 'V' },
+ { "ve", no_arg, 'V' },
+ { "attribute", require_arg, 'a' },
+ { "attribut", require_arg, 'a' },
+ { "attribu", require_arg, 'a' },
+ { "attrib", require_arg, 'a' },
+ { "attri", require_arg, 'a' },
+ { "attr", require_arg, 'a' },
+ { "att", require_arg, 'a' },
+ { "at", require_arg, 'a' },
+ { "block", require_arg, 'k' },
+ { "bloc", require_arg, 'k' },
+ { "blo", require_arg, 'k' },
+ { "bl", require_arg, 'k' },
+ { "count", require_arg, 'c' },
+ { "coun", require_arg, 'c' },
+ { "cou", require_arg, 'c' },
+ { "co", require_arg, 'c' },
+ { "dataset", require_arg, 'd' },
+ { "datase", require_arg, 'd' },
+ { "datas", require_arg, 'd' },
+ { "datatype", require_arg, 't' },
+ { "datatyp", require_arg, 't' },
+ { "dataty", require_arg, 't' },
+ { "datat", require_arg, 't' },
+ { "filedriver", require_arg, 'f' },
+ { "filedrive", require_arg, 'f' },
+ { "filedriv", require_arg, 'f' },
+ { "filedri", require_arg, 'f' },
+ { "filedr", require_arg, 'f' },
+ { "filed", require_arg, 'f' },
+ { "file", require_arg, 'f' },
+ { "fil", require_arg, 'f' },
+ { "fi", require_arg, 'f' },
+ { "group", require_arg, 'g' },
+ { "grou", require_arg, 'g' },
+ { "gro", require_arg, 'g' },
+ { "gr", require_arg, 'g' },
+ { "output", require_arg, 'o' },
+ { "outpu", require_arg, 'o' },
+ { "outp", require_arg, 'o' },
+ { "out", require_arg, 'o' },
+ { "ou", require_arg, 'o' },
+ { "soft-link", require_arg, 'l' },
+ { "soft-lin", require_arg, 'l' },
+ { "soft-li", require_arg, 'l' },
+ { "soft-l", require_arg, 'l' },
+ { "soft", require_arg, 'l' },
+ { "sof", require_arg, 'l' },
+ { "start", require_arg, 's' },
+ { "star", require_arg, 's' },
+ { "sta", require_arg, 's' },
+ { "stride", require_arg, 'S' },
+ { "strid", require_arg, 'S' },
+ { "string", no_arg, 'r' },
+ { "strin", no_arg, 'r' },
+ { "use-dtd", no_arg, 'u' },
+ { "use-dt", no_arg, 'u' },
+ { "use-d", no_arg, 'u' },
+ { "use-", no_arg, 'u' },
+ { "use", no_arg, 'u' },
+ { "us", no_arg, 'u' },
+ { "u", no_arg, 'u' },
+ { "width", require_arg, 'w' },
+ { "widt", require_arg, 'w' },
+ { "wid", require_arg, 'w' },
+ { "wi", require_arg, 'w' },
+ { "xml-dtd", require_arg, 'D' },
+ { "xml-dt", require_arg, 'D' },
+ { "xml-d", require_arg, 'D' },
+ { "xml-ns", require_arg, 'X' },
+ { "xml-n", require_arg, 'X' },
+ { "xml", no_arg, 'x' },
+ { "xm", no_arg, 'x' },
+ { "onlyattr", no_arg, 'A' },
+ { "escape", no_arg, 'e' },
+ { "noindex", no_arg, 'y' },
+ { "binary", optional_arg, 'b' },
+ { "form", require_arg, 'F' },
+ { "sort_by", require_arg, 'q' },
+ { "sort_order", require_arg, 'z' },
+ { "format", require_arg, 'm' },
+ { "region", no_arg, 'R' },
+ { "enable-error-stack", no_arg, 'E' },
+ { "packed-bits", require_arg, 'M' },
+ { "no-compact-subset", no_arg, 'C' },
+ { NULL, 0, '\0' }
};
-/*
- * The global table is set to either ddl_function_table or
- * xml_function_table in the initialization.
- */
-static const dump_functions *dump_function_table;
-
-
+
/*-------------------------------------------------------------------------
* Function: leave
*
@@ -630,10 +210,10 @@ leave(int ret)
{
h5tools_close();
- exit(ret);
+ HDexit(ret);
}
-
+
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -650,106 +230,108 @@ leave(int ret)
static void
usage(const char *prog)
{
- fflush(stdout);
- fprintf(stdout, "usage: %s [OPTIONS] file\n", prog);
- fprintf(stdout, " OPTIONS\n");
- fprintf(stdout, " -h, --help Print a usage message and exit\n");
- fprintf(stdout, " -n, --contents Print a list of the file contents and exit\n");
- fprintf(stdout, " -B, --superblock Print the content of the super block\n");
- fprintf(stdout, " -H, --header Print the header only; no data is displayed\n");
- fprintf(stdout, " -A, --onlyattr Print the header and value of attributes\n");
- fprintf(stdout, " -i, --object-ids Print the object ids\n");
- fprintf(stdout, " -r, --string Print 1-byte integer datasets as ASCII\n");
- fprintf(stdout, " -e, --escape Escape non printing characters\n");
- fprintf(stdout, " -V, --version Print version number and exit\n");
- fprintf(stdout, " -a P, --attribute=P Print the specified attribute\n");
- fprintf(stdout, " -d P, --dataset=P Print the specified dataset\n");
- fprintf(stdout, " -y, --noindex Do not print array indices with the data\n");
- fprintf(stdout, " -p, --properties Print dataset filters, storage layout and fill value\n");
- fprintf(stdout, " -f D, --filedriver=D Specify which driver to open the file with\n");
- fprintf(stdout, " -g P, --group=P Print the specified group and all members\n");
- fprintf(stdout, " -l P, --soft-link=P Print the value(s) of the specified soft link\n");
- fprintf(stdout, " -o F, --output=F Output raw data into file F\n");
- fprintf(stdout, " -b B, --binary=B Binary file output, of form B\n");
- fprintf(stdout, " -t P, --datatype=P Print the specified named datatype\n");
- fprintf(stdout, " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n");
- fprintf(stdout, " sets the number of columns to the maximum (65535).\n");
- fprintf(stdout, " Default width is 80 columns.\n");
- 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");
- 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"
- );
- 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");
- fprintf(stdout, " -D U, --xml-dtd=U Use the DTD or schema at U\n");
- fprintf(stdout, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n");
- fprintf(stdout, " \":\": no namespace, default: \"hdf5:\"\n");
- fprintf(stdout, " E.g., to dump a file called `-f', use h5dump -- -f\n");
- fprintf(stdout, " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
- fprintf(stdout, " occur.\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " Subsetting is available by using the following options with a dataset\n");
- fprintf(stdout, " attribute. Subsetting is done by selecting a hyperslab from the data.\n");
- fprintf(stdout, " Thus, the options mirror those for performing a hyperslab selection.\n");
- fprintf(stdout, " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n");
- fprintf(stdout, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n");
- fprintf(stdout, " each dimension. START is optional and will default to 0 in each dimension.\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " -s START, --start=START Offset of start of subsetting selection\n");
- fprintf(stdout, " -S STRIDE, --stride=STRIDE Hyperslab stride\n");
- fprintf(stdout, " -c COUNT, --count=COUNT Number of blocks to include in selection\n");
- fprintf(stdout, " -k BLOCK, --block=BLOCK Size of block in hyperslab\n");
- fprintf(stdout, " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n");
- fprintf(stdout, " number of dimensions in the dataspace being queried\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " D - is the file driver to use in opening the file. Acceptable values\n");
- fprintf(stdout, " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n");
- fprintf(stdout, " the file driver flag, the file will be opened with each driver in\n");
- fprintf(stdout, " turn and in the order specified above until one driver succeeds\n");
- fprintf(stdout, " in opening the file.\n");
- fprintf(stdout, " F - is a filename.\n");
- fprintf(stdout, " P - is the full path from the root group to the object.\n");
- fprintf(stdout, " N - is an integer greater than 1.\n");
- fprintf(stdout, " T - is a string containing the floating point format, e.g '%%.3f'\n");
- fprintf(stdout, " U - is a URI reference (as defined in [IETF RFC 2396],\n");
- fprintf(stdout, " updated by [IETF RFC 2732])\n");
- fprintf(stdout, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n");
- fprintf(stdout, " file type, LE or BE for pre-existing little or big endian types.\n");
- fprintf(stdout, " Must be used with -o (output file) and it is recommended that\n");
- fprintf(stdout, " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n");
- fprintf(stdout, " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n");
- fprintf(stdout, " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " Examples:\n");
- 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, "\n");
- fprintf(stdout, " 2) Selecting a subset from dataset /foo in file quux.h5\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin'\n");
- fprintf(stdout, " using a little-endian type\n");
- fprintf(stdout, "\n");
- fprintf(stdout, " h5dump -d /dset -b LE -o out.bin quux.h5\n");
- 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");
- fprintf(stdout, "\n");
+ HDfflush(rawoutstream);
+ HDfprintf(rawoutstream, "usage: %s [OPTIONS] file\n", prog);
+ HDfprintf(rawoutstream, " OPTIONS\n");
+ HDfprintf(rawoutstream, " -h, --help Print a usage message and exit\n");
+ HDfprintf(rawoutstream, " -n, --contents Print a list of the file contents and exit\n");
+ HDfprintf(rawoutstream, " -B, --superblock Print the content of the super block\n");
+ HDfprintf(rawoutstream, " -H, --header Print the header only; no data is displayed\n");
+ HDfprintf(rawoutstream, " -A, --onlyattr Print the header and value of attributes\n");
+ HDfprintf(rawoutstream, " -i, --object-ids Print the object ids\n");
+ HDfprintf(rawoutstream, " -r, --string Print 1-byte integer datasets as ASCII\n");
+ HDfprintf(rawoutstream, " -e, --escape Escape non printing characters\n");
+ HDfprintf(rawoutstream, " -V, --version Print version number and exit\n");
+ HDfprintf(rawoutstream, " -a P, --attribute=P Print the specified attribute\n");
+ HDfprintf(rawoutstream, " -d P, --dataset=P Print the specified dataset\n");
+ HDfprintf(rawoutstream, " -y, --noindex Do not print array indices with the data\n");
+ HDfprintf(rawoutstream, " -p, --properties Print dataset filters, storage layout and fill value\n");
+ HDfprintf(rawoutstream, " -f D, --filedriver=D Specify which driver to open the file with\n");
+ HDfprintf(rawoutstream, " -g P, --group=P Print the specified group and all members\n");
+ HDfprintf(rawoutstream, " -l P, --soft-link=P Print the value(s) of the specified soft link\n");
+ HDfprintf(rawoutstream, " -o F, --output=F Output raw data into file F\n");
+ HDfprintf(rawoutstream, " -b B, --binary=B Binary file output, of form B\n");
+ HDfprintf(rawoutstream, " -t P, --datatype=P Print the specified named datatype\n");
+ HDfprintf(rawoutstream, " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n");
+ HDfprintf(rawoutstream, " sets the number of columns to the maximum (65535).\n");
+ HDfprintf(rawoutstream, " Default width is 80 columns.\n");
+ HDfprintf(rawoutstream, " -m T, --format=T Set the floating point output format\n");
+ HDfprintf(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n");
+ HDfprintf(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n");
+ HDfprintf(rawoutstream,
+ " -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"
+ );
+ HDfprintf(rawoutstream, " -R, --region Print dataset pointed by region references\n");
+ HDfprintf(rawoutstream, " -x, --xml Output in XML using Schema\n");
+ HDfprintf(rawoutstream, " -u, --use-dtd Output in XML using DTD\n");
+ HDfprintf(rawoutstream, " -D U, --xml-dtd=U Use the DTD or schema at U\n");
+ HDfprintf(rawoutstream, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n");
+ HDfprintf(rawoutstream, " \":\": no namespace, default: \"hdf5:\"\n");
+ HDfprintf(rawoutstream, " E.g., to dump a file called `-f', use h5dump -- -f\n");
+ HDfprintf(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
+ HDfprintf(rawoutstream, " occur.\n");
+ HDfprintf(rawoutstream, " --no-compact-subset Disable compact form of subsetting and allow the use\n");
+ HDfprintf(rawoutstream, " of \"[\" in datset names.\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " Subsetting is available by using the following options with a dataset\n");
+ HDfprintf(rawoutstream, " attribute. Subsetting is done by selecting a hyperslab from the data.\n");
+ HDfprintf(rawoutstream, " Thus, the options mirror those for performing a hyperslab selection.\n");
+ HDfprintf(rawoutstream, " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n");
+ HDfprintf(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n");
+ HDfprintf(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " -s START, --start=START Offset of start of subsetting selection\n");
+ HDfprintf(rawoutstream, " -S STRIDE, --stride=STRIDE Hyperslab stride\n");
+ HDfprintf(rawoutstream, " -c COUNT, --count=COUNT Number of blocks to include in selection\n");
+ HDfprintf(rawoutstream, " -k BLOCK, --block=BLOCK Size of block in hyperslab\n");
+ HDfprintf(rawoutstream, " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n");
+ HDfprintf(rawoutstream, " number of dimensions in the dataspace being queried\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " D - is the file driver to use in opening the file. Acceptable values\n");
+ HDfprintf(rawoutstream, " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n");
+ HDfprintf(rawoutstream, " the file driver flag, the file will be opened with each driver in\n");
+ HDfprintf(rawoutstream, " turn and in the order specified above until one driver succeeds\n");
+ HDfprintf(rawoutstream, " in opening the file.\n");
+ HDfprintf(rawoutstream, " F - is a filename.\n");
+ HDfprintf(rawoutstream, " P - is the full path from the root group to the object.\n");
+ HDfprintf(rawoutstream, " N - is an integer greater than 1.\n");
+ HDfprintf(rawoutstream, " T - is a string containing the floating point format, e.g '%%.3f'\n");
+ HDfprintf(rawoutstream, " U - is a URI reference (as defined in [IETF RFC 2396],\n");
+ HDfprintf(rawoutstream, " updated by [IETF RFC 2732])\n");
+ HDfprintf(rawoutstream, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n");
+ HDfprintf(rawoutstream, " file type, LE or BE for pre-existing little or big endian types.\n");
+ HDfprintf(rawoutstream, " Must be used with -o (output file) and it is recommended that\n");
+ HDfprintf(rawoutstream, " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n");
+ HDfprintf(rawoutstream, " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n");
+ HDfprintf(rawoutstream, " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " Examples:\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " 1) Attribute foo of the group /bar_none in file quux.h5\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " h5dump -a /bar_none/foo quux.h5\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " 2) Selecting a subset from dataset /foo in file quux.h5\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin'\n");
+ HDfprintf(rawoutstream, " using a little-endian type\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " h5dump -d /dset -b LE -o out.bin quux.h5\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " h5dump -d /dset -M 0,1,4,3 quux.h5\n");
+ HDfprintf(rawoutstream, "\n");
}
-
+
/*-------------------------------------------------------------------------
* Function: table_list_add
*
@@ -764,7 +346,7 @@ usage(const char *prog)
*
*-------------------------------------------------------------------------
*/
-static ssize_t
+ssize_t
table_list_add(hid_t oid, unsigned long file_no)
{
size_t idx; /* Index of table to use */
@@ -789,7 +371,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;
@@ -802,7 +384,7 @@ table_list_add(hid_t oid, unsigned long file_no)
return((ssize_t) idx);
} /* end table_list_add() */
-
+
/*-------------------------------------------------------------------------
* Function: table_list_visited
*
@@ -817,7 +399,7 @@ table_list_add(hid_t oid, unsigned long file_no)
*
*-------------------------------------------------------------------------
*/
-static ssize_t
+ssize_t
table_list_visited(unsigned long file_no)
{
size_t u; /* Local index variable */
@@ -832,7 +414,7 @@ table_list_visited(unsigned long file_no)
return(-1);
} /* end table_list_visited() */
-
+
/*-------------------------------------------------------------------------
* Function: table_list_free
*
@@ -872,2571 +454,116 @@ table_list_free(void)
table_list.nalloc = table_list.nused = 0;
} /* end table_list_free() */
-
-/*-------------------------------------------------------------------------
- * Function: print_datatype
- *
- * Purpose: print the datatype.
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications: pvn, March 28, 2006
- * print information about type when a native match is not possible
- *
- *-------------------------------------------------------------------------
- */
-static void
-print_datatype(hid_t type,unsigned in_group)
-{
- char *mname;
- hid_t mtype, str_type;
- unsigned nmembers;
- unsigned ndims;
- unsigned i;
- size_t size=0;
- hsize_t dims[H5DUMP_MAX_RANK];
- H5T_str_t str_pad;
- H5T_cset_t cset;
- H5T_order_t order;
- hid_t super;
- hid_t tmp_type;
- htri_t is_vlstr=FALSE;
- const char *order_s=NULL; /* byte order string */
- H5T_sign_t sign; /* sign scheme value */
- const char *sign_s=NULL; /* sign scheme string */
-
- if (!in_group && H5Tcommitted(type) > 0) {
- H5O_info_t oinfo;
- obj_t *obj; /* Found object */
-
- H5Oget_info(type, &oinfo);
- obj = search_obj(type_table, oinfo.addr);
-
- if(obj) {
- if(!obj->recorded)
- HDfprintf(stdout,"\"/#%a\"", obj->objno);
- else
- HDfprintf(stdout, "\"%s\"", obj->objname);
- }
- else {
- error_msg("unknown committed type.\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
- }
- else {
- switch(H5Tget_class(type)) {
- case H5T_INTEGER:
- if(H5Tequal(type, H5T_STD_I8BE) == TRUE) {
- 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) {
- 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) {
- 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 = "";
- } /* 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:
- HDfprintf(stdout, "H5T_TIME: not yet implemented");
- break;
-
- case H5T_STRING:
- /* Make a copy of type in memory in case when TYPE is on disk, the size
- * will be bigger than in memory. This makes it easier to compare
- * types in memory. */
- tmp_type = H5Tcopy(type);
- size = H5Tget_size(tmp_type);
- str_pad = H5Tget_strpad(tmp_type);
- cset = H5Tget_cset(tmp_type);
- is_vlstr = H5Tis_variable_str(tmp_type);
-
- HDfprintf(stdout, "H5T_STRING %s\n", dump_header_format->strblockbegin);
- indent += COL;
-
- indentation(indent + COL);
- if(is_vlstr)
- HDfprintf(stdout, "%s H5T_VARIABLE;\n", STRSIZE);
- else
- HDfprintf(stdout, "%s %d;\n", STRSIZE, (int) size);
-
- indentation(indent + COL);
- HDfprintf(stdout, "%s ", STRPAD);
- 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");
-
- indentation(indent + COL);
- HDfprintf(stdout, "%s ", CSET);
-
- if (cset == H5T_CSET_ASCII)
- HDfprintf(stdout, "H5T_CSET_ASCII;\n");
- else
- HDfprintf(stdout, "unknown_cset;\n");
-
- str_type = H5Tcopy(H5T_C_S1);
- if(is_vlstr)
- H5Tset_size(str_type, H5T_VARIABLE);
- else
- H5Tset_size(str_type, size);
- H5Tset_cset(str_type, cset);
- H5Tset_strpad(str_type, str_pad);
-
- indentation(indent + COL);
- HDfprintf(stdout, "%s ", CTYPE);
-
- /* Check C variable-length string first. Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- 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)
- H5Tset_order(str_type, H5T_ORDER_LE);
- else if(order==H5T_ORDER_BE)
- H5Tset_order(str_type, H5T_ORDER_BE);
-
- if (H5Tequal(tmp_type, str_type)) {
- HDfprintf(stdout, "H5T_C_S1;\n");
- goto done;
- }
-
- /* If not equal to C variable-length string, check Fortran type. */
- H5Tclose(str_type);
- str_type = H5Tcopy(H5T_FORTRAN_S1);
- H5Tset_cset(str_type, cset);
- H5Tset_size(str_type, size);
- H5Tset_strpad(str_type, str_pad);
-
- /* Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- 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)
- H5Tset_order(str_type, H5T_ORDER_LE);
- else if(order==H5T_ORDER_BE)
- H5Tset_order(str_type, H5T_ORDER_BE);
-
- if (H5Tequal(tmp_type, str_type)) {
- HDfprintf(stdout, "H5T_FORTRAN_S1;\n");
- goto done;
- }
-
- /* Type doesn't match any of above. */
- HDfprintf(stdout, "unknown_one_character_type;\n ");
- h5tools_setstatus(EXIT_FAILURE);
-
- done:
- H5Tclose(str_type);
- H5Tclose(tmp_type);
-
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s", dump_header_format->strblockend);
- break;
-
- case H5T_BITFIELD:
- if (H5Tequal(type, H5T_STD_B8BE)==TRUE) {
- 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:
- HDfprintf(stdout, "\n");
- indentation(indent + COL);
- HDfprintf(stdout, "H5T_OPAQUE;\n");
- indentation(indent + COL);
- mname = H5Tget_tag(type);
- HDfprintf(stdout, "OPAQUE_TAG \"%s\";\n", mname);
- free(mname);
- indentation(indent);
- break;
-
- case H5T_COMPOUND:
- nmembers = H5Tget_nmembers(type);
- HDfprintf(stdout, "H5T_COMPOUND %s\n", dump_header_format->structblockbegin);
-
- for (i = 0; i < nmembers; i++) {
- mname = H5Tget_member_name(type, i);
- mtype = H5Tget_member_type(type, i);
- indentation(indent + COL);
-
- if (H5Tget_class(mtype) == H5T_COMPOUND)
- indent += COL;
-
- print_datatype(mtype,0);
-
- if (H5Tget_class(mtype) == H5T_COMPOUND)
- indent -= COL;
-
- HDfprintf(stdout, " \"%s\";\n", mname);
- free(mname);
- } /* end of for (i = 0; i < nmembers; i++) */
-
- indentation(indent);
- HDfprintf(stdout, "%s", dump_header_format->structblockend);
- break;
-
- case 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) {
- HDfprintf(stdout, " { H5T_STD_REF_DSETREG }");
- }
- else {
- HDfprintf(stdout, " { H5T_STD_REF_OBJECT }");
- }
- break;
-
- case H5T_ENUM:
- HDfprintf(stdout, "H5T_ENUM %s\n", dump_header_format->enumblockbegin);
- indent += COL;
- indentation(indent + COL);
- super = H5Tget_super(type);
- print_datatype(super,0);
- HDfprintf(stdout, ";\n");
- print_enum(type);
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s", dump_header_format->enumblockend);
- break;
-
- case H5T_VLEN:
- HDfprintf(stdout, "H5T_VLEN %s ", dump_header_format->vlenblockbegin);
- super = H5Tget_super(type);
- print_datatype(super,0);
- H5Tclose(super);
-
- /* Print closing */
- HDfprintf(stdout, "%s", dump_header_format->vlenblockend);
- break;
-
- case H5T_ARRAY:
- /* Get array base type */
- super = H5Tget_super(type);
-
- /* Print lead-in */
- HDfprintf(stdout, "H5T_ARRAY { ");
-
- /* Get array information */
- ndims = H5Tget_array_ndims(type);
- H5Tget_array_dims2(type, dims);
-
- /* Print array dimensions */
- for (i = 0; i < ndims; i++)
- HDfprintf(stdout, "[%d]", (int) dims[i]);
-
- HDfprintf(stdout, " ");
-
- /* Print base type */
- print_datatype(super,0);
-
- /* Close array base type */
- H5Tclose(super);
-
- /* Print closing */
- HDfprintf(stdout, " }");
-
- break;
-
- default:
- HDfprintf(stdout, "unknown datatype");
- h5tools_setstatus(EXIT_FAILURE);
- break;
- }
- } /* end else */
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: dump_datatype
- *
- * Purpose: Dump the datatype. Datatype can be HDF5 predefined
- * atomic datatype or committed/transient datatype.
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_datatype(hid_t type)
-{
- indent += COL;
-
- indentation(indent);
- 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);
- indent -= COL;
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_dataspace
- *
- * Purpose: Dump the dataspace. Dataspace can be named dataspace,
- * array, or others.
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_dataspace(hid_t space)
-{
- 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);
- 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);
- break;
-
- case H5S_SIMPLE:
- /* simple dataspace */
- 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]);
-
- HDfprintf(stdout, " %s / ", dump_header_format->dataspacedimend);
-
- if(maxsize[0] == H5S_UNLIMITED)
- HDfprintf(stdout, "%s %s", dump_header_format->dataspacedimbegin, "H5S_UNLIMITED");
- else
- HDfprintf(stdout, "%s %Hu", dump_header_format->dataspacedimbegin, maxsize[0]);
-
- for(i = 1; i < ndims; i++)
- if(maxsize[i] == H5S_UNLIMITED)
- HDfprintf(stdout, ", %s", "H5S_UNLIMITED");
- else
- HDfprintf(stdout, ", %Hu", maxsize[i]);
-
- HDfprintf(stdout, " %s }", dump_header_format->dataspacedimend);
- break;
-
- case H5S_NULL:
- /* null dataspace */
- HDfprintf(stdout, "%s %s", dump_header_format->dataspacedescriptionbegin, S_NULL);
- break;
-
- case H5S_NO_CLASS:
- default:
- HDfprintf(stdout, "%s unknown dataspace %s\n", BEGIN, END);
- break;
- } /* end switch */
-
- end_obj(dump_header_format->dataspaceend, dump_header_format->dataspaceblockend);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: dump_attr_cb
- *
- * Purpose: attribute function callback called by H5Aiterate2, displays the attribute
- *
- * Return: Success: SUCCEED
- *
- * Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications: Pedro Vicente, October 4, 2007
- * Added H5A_info_t parameter to conform with H5Aiterate2
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, void UNUSED *_op_data)
-{
- hid_t attr_id;
- herr_t ret = SUCCEED;
-
- indentation(indent);
- 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);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- hid_t type, space;
-
- type = H5Aget_type(attr_id);
- space = H5Aget_space(attr_id);
- dump_datatype(type);
- dump_dataspace(space);
-
- if(display_oid)
- dump_oid(attr_id);
-
- if(display_data || display_attr_data)
- dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai);
-
- H5Tclose(type);
- H5Sclose(space);
- H5Aclose(attr_id);
-
- indentation(indent);
- end_obj(dump_header_format->attributeend,dump_header_format->attributeblockend);
- }
-
- return ret;
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_selected_attr
- *
- * Purpose: dump the selected attribute
- *
- * Return: Success: SUCCEED
- *
- * Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-dump_selected_attr(hid_t loc_id, const char *name)
-{
- hid_t oid = -1;
- hid_t attr_id = -1;
- char *obj_name;
- const char *attr_name;
- int j;
-
- j = (int)HDstrlen(name) - 1;
- obj_name = (char *)HDmalloc((size_t)j + 2);
- if(obj_name == NULL)
- goto error;
-
- /* find the last / */
- while(j >= 0) {
- if (name[j] == '/')
- break;
- j--;
- }
-
- /* object name */
- if(j == -1)
- HDstrcpy(obj_name, "/");
- else {
- HDstrncpy(obj_name, name, (size_t)j + 1);
- obj_name[j + 1] = '\0';
- } /* end else */
-
- attr_name = name + j + 1;
- begin_obj(dump_header_format->attributebegin, name,
- dump_header_format->attributeblockbegin);
-
- /* Open the object with the attribute */
- if((oid = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) {
- indentation(COL);
- error_msg("unable to open object \"%s\"\n", obj_name);
- end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
- goto error;
- } /* end if */
-
- if((attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT)) >= 0) {
- hid_t type, space;
-
- type = H5Aget_type(attr_id);
- space = H5Aget_space(attr_id);
- dump_datatype(type);
- dump_dataspace(space);
-
- if(display_oid)
- dump_oid(attr_id);
-
- if(display_data || display_attr_data)
- dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai);
-
- H5Tclose(type);
- H5Sclose(space);
- H5Aclose(attr_id);
- end_obj(dump_header_format->attributeend,
- dump_header_format->attributeblockend);
- }
- else {
- indentation(COL);
- error_msg("unable to open attribute \"%s\"\n", obj_name);
- end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
- goto error;
- }
-
- /* Close object */
- if(H5Oclose(oid) < 0) {
- goto error;
- } /* end if */
-
- HDfree(obj_name);
- return SUCCEED;
-
- error:
- h5tools_setstatus(EXIT_FAILURE);
- if(obj_name)
- HDfree(obj_name);
-
- H5E_BEGIN_TRY {
- H5Oclose(oid);
- H5Aclose(attr_id);
- } H5E_END_TRY;
- return FAIL;
-}
-
/*-------------------------------------------------------------------------
- * Function: dump_all_cb
- *
- * Purpose: function callback called by H5Literate,
- * displays everything in the specified object
- *
- * Return: Success: SUCCEED
- *
- * Failure: FAIL
+ * Function: set_data_output_file
*
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- * RMcG, November 2000
- * Added XML support. Also, optionally checks the op_data argument
- *
- * PVN, May 2008
- * Dump external links
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED *op_data)
-{
- hid_t obj;
- 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);
- if(!obj_path) {
- ret = FAIL;
- goto done;
- }
-
- HDstrcpy(obj_path, prefix);
- HDstrcat(obj_path, "/");
- HDstrcat(obj_path, name);
-
- if(linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oinfo;
-
- /* Stat the object */
- if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) {
- error_msg("unable to get object information for \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- goto done;
- } /* end if */
-
- switch(oinfo.type) {
- case H5O_TYPE_GROUP:
- if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg("unable to dump group \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- char *old_prefix; /* Pointer to previous prefix */
-
- /* Keep copy of prefix before iterating into group */
- old_prefix = HDstrdup(prefix);
- HDassert(old_prefix);
-
- /* Append group name to prefix */
- add_prefix(&prefix, &prefix_len, name);
-
- /* Iterate into group */
- dump_function_table->dump_group_function(obj, name);
-
- /* Restore old prefix name */
- HDstrcpy(prefix, old_prefix);
- HDfree(old_prefix);
-
- /* Close group */
- H5Gclose(obj);
- }
- break;
-
- case H5O_TYPE_DATASET:
- if((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) {
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
-
- found_obj = search_obj(dset_table, oinfo.addr);
-
- if(found_obj == NULL) {
- indentation(indent);
- 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__);
- indentation(indent);
- end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- H5Dclose(obj);
- goto done;
- }
- else if(found_obj->displayed) {
- indentation(indent);
-
- if(!doxml) {
- begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin);
- indentation(indent + COL);
- HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname);
- indentation(indent);
- end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
- }
- else {
- /* the XML version */
- char *t_obj_path = xml_escape_the_name(obj_path);
- 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];
-
- /* 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);
-
- HDfprintf(stdout, "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" "
- "H5Path=\"%s\" Parents=\"%s\" "
- "H5ParentPaths=\"%s\">\n",
- xmlnsprefix,
- t_name, /* Dataset Name */
- dsetxid, get_next_xid(), /* OBJ-XID */
- t_obj_path, /* H5Path */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
-
- indentation(indent + COL);
- xml_name_to_XID(found_obj->objname, pointerxid, sizeof(pointerxid), 1);
- HDfprintf(stdout, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n",
- xmlnsprefix,
- pointerxid,t_objname);
- indentation(indent);
- HDfprintf(stdout, "</%sDataset>\n", xmlnsprefix);
-
- HDfree(t_name);
- HDfree(t_obj_path);
- HDfree(t_prefix);
- HDfree(t_objname);
- }
-
- H5Dclose(obj);
- goto done;
- }
- else {
- found_obj->displayed = TRUE;
- }
- } /* end if */
-
- dump_function_table->dump_dataset_function(obj, name, NULL);
- H5Dclose(obj);
- }
- else {
- error_msg("unable to dump dataset \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg("unable to dump datatype \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- dump_function_table->dump_named_datatype_function(obj, name);
- H5Tclose(obj);
- }
- break;
-
- default:
- error_msg("unknown object \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- } /* end if */
- else {
- char *targbuf;
-
- switch(linfo->type) {
- case H5L_TYPE_SOFT:
- indentation(indent);
- targbuf = (char *)HDmalloc(linfo->u.val_size);
- HDassert(targbuf);
-
- if(!doxml) {
- begin_obj(dump_header_format->softlinkbegin, name, dump_header_format->softlinkblockbegin);
- indentation(indent + COL);
- }
-
- if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg("unable to get link value\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- /* print the value of a soft link */
- if (!doxml) {
- /* Standard DDL: no modification */
- HDfprintf(stdout, "LINKTARGET \"%s\"\n", targbuf);
- }
- else {
- /* XML */
- char linkxid[100];
- char parentxid[100];
- char targetxid[100];
- char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
- char *t_name = xml_escape_the_name(name);
- char *t_targbuf = xml_escape_the_name(targbuf);
- char *t_obj_path = xml_escape_the_name(obj_path);
- char *t_link_path;
- int res;
-
- t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
- if(targbuf[0] == '/')
- HDstrcpy(t_link_path, targbuf);
- else {
- HDstrcpy(t_link_path, prefix);
- HDstrcat(HDstrcat(t_link_path, "/"), targbuf);
- } /* end else */
-
- /* Create OBJ-XIDs for the parent and object */
- xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
- xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
-
- /* Try to create an OBJ-XID for the object pointed to */
- res = xml_name_to_XID(t_link_path, targetxid, sizeof(targetxid), 0);
- if (res == 0) {
- /* target obj found */
- HDfprintf(stdout, "<%sSoftLink LinkName=\"%s\" "
- "OBJ-XID=\"%s\" "
- "H5SourcePath=\"%s\" "
- "TargetPath=\"%s\" TargetObj=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />\n",
- xmlnsprefix,
- t_name, /* LinkName */
- linkxid, /* OBJ-XID */
- t_obj_path, /* H5SourcePath */
- t_targbuf, /* TargetPath */
- targetxid, /* TargetObj */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- }
- else {
- /* dangling link -- omit from xml attributes */
- HDfprintf(stdout, "<%sSoftLink LinkName=\"%s\" "
- "OBJ-XID=\"%s\" "
- "H5SourcePath=\"%s\" "
- "TargetPath=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />\n",
- xmlnsprefix,
- t_name, /* LinkName */
- linkxid, /* OBJ-XID */
- t_obj_path, /* H5SourcePath */
- t_targbuf, /* TargetPath */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- }
-
- HDfree(t_prefix);
- HDfree(t_name);
- HDfree(t_targbuf);
- HDfree(t_obj_path);
- HDfree(t_link_path);
- }
- }
-
- if (!doxml) {
- indentation(indent);
- end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend);
- }
-
- HDfree(targbuf);
- break;
-
- case H5L_TYPE_EXTERNAL:
- targbuf = (char *)HDmalloc(linfo->u.val_size);
- HDassert(targbuf);
-
- indentation(indent);
- if(!doxml)
- begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin);
-
- if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg("unable to get external link value\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- } /* end if */
- else {
- const char *filename;
- const char *targname;
-
- if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
- error_msg("unable to unpack external link value\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- } /* end if */
- else {
- if(!doxml) {
- indentation(indent + COL);
- HDfprintf(stdout, "TARGETFILE \"%s\"\n", filename);
- indentation(indent + COL);
- HDfprintf(stdout, "TARGETPATH \"%s\"\n", targname);
-
- /* dump the external link */
- dump_extlink(group, name, targname);
-
-
- } /* end if */
- /* XML */
- else {
- char linkxid[100];
- char parentxid[100];
- char *t_name = xml_escape_the_name(name);
- char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
- char *t_obj_path = xml_escape_the_name(obj_path);
- char *t_filename = xml_escape_the_name(filename);
- char *t_targname = xml_escape_the_name(targname);
-
- /* Create OBJ-XIDs for the parent and object */
- xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
- xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
-
- 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);
- HDfree(t_targname);
- HDfree(t_obj_path);
- } /* end else */
- } /* end else */
- } /* end else */
- if(!doxml) {
- indentation(indent);
- end_obj(dump_header_format->extlinkend, dump_header_format->extlinkblockend);
- } /* end if */
- HDfree(targbuf);
- break;
-
- default:
- indentation(indent);
- if(!doxml) {
- begin_obj(dump_header_format->udlinkbegin, name, dump_header_format->udlinkblockbegin);
- indentation(indent + COL);
- HDfprintf(stdout, "LINKCLASS %d\n", linfo->type);
- indentation(indent);
- end_obj(dump_header_format->udlinkend, dump_header_format->udlinkblockend);
- } /* end if */
- /* XML */
- else {
- char linkxid[100];
- char parentxid[100];
- char *t_name = xml_escape_the_name(name);
- char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
- char *t_obj_path = xml_escape_the_name(obj_path);
-
- /* Create OBJ-XIDs for the parent and object */
- xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
- xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
-
- 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 */
- HDfree(t_prefix);
- HDfree(t_name);
- HDfree(t_obj_path);
- } /* end else */
- break;
- } /* end switch */
- } /* end else */
-
- done:
- if(obj_path)
- HDfree(obj_path);
- return ret;
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_named_datatype
- *
- * Purpose: Dump named datatype
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- * Pedro Vicente, March 27, 2006
- * added display of attributes
- * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for
- * other iteration orders
- *
- *-------------------------------------------------------------------------
- */
-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 */
-
-
- 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) {
- error_msg("error in getting creation properties\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
-
- if(H5Pclose(tcpl_id) < 0) {
- error_msg("error in closing creation property list ID\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
-
-
- indentation(indent);
- HDfprintf(stdout, "%s \"%s\" %s", dump_header_format->datatypebegin, name,
- dump_header_format->datatypeblockbegin);
-
- H5Oget_info(tid, &oinfo);
-
- /* Must check for uniqueness of all objects if we've traversed an elink,
- * otherwise only check if the reference count > 1.
- */
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
-
- found_obj = search_obj(type_table, oinfo.addr);
-
- if (found_obj == NULL) {
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- else if (found_obj->displayed) {
- HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname);
- goto done;
- }
- else
- found_obj->displayed = TRUE;
- } /* end if */
-
- print_datatype(tid, 1);
- if(H5Tget_class(tid) != H5T_COMPOUND)
- HDfprintf(stdout, ";\n");
-
- /* print attributes */
- indent += COL;
-
- /* 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(H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end if */
- else {
- if(H5Aiterate2(tid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
-
- indent -= COL;
-
- done:
- end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend);
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_group
- *
- * Purpose: Dump everything within the specified group
+ * Purpose: Open fname as the output file for dataset raw data.
+ * Set rawdatastream as its file stream.
*
- * Return: void
+ * Return: 0 -- succeeded
+ * negative -- failed
*
- * Programmer: Ruey-Hsia Li
+ * Programmer: Albert Cheng, 2000/09/30
*
* Modifications:
- *
- * Call to dump_all_cb -- add parameter to select everything.
- *
- * Pedro Vicente, October 1, 2007
- * handle several iteration orders for attributes and groups
+ * pvn June, 1, 2006. Add a switch for binary output
*
*-------------------------------------------------------------------------
*/
-static void
-dump_group(hid_t gid, const char *name)
+static int
+set_data_output_file(const char *fname, int is_bin)
{
- H5O_info_t oinfo;
- hid_t dset;
- hid_t type;
- hid_t gcpl_id;
- unsigned crt_order_flags;
- unsigned attr_crt_order_flags;
- char type_name[1024];
- char *tmp = NULL;
-
- 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) {
- 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) {
- error_msg("error in getting group creation properties\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
-
- if(H5Pclose(gcpl_id) < 0) {
- error_msg("error in closing group creation property list ID\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
-
-
- tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
- HDstrcpy(tmp, prefix);
- indentation(indent);
- begin_obj(dump_header_format->groupbegin, name, dump_header_format->groupblockbegin);
- indent += COL;
-
- if(display_oid)
- dump_oid(gid);
-
- dump_comment(gid);
-
- if(!HDstrcmp(name, "/") && unamedtype) {
- unsigned u; /* Local index variable */
-
- /* dump unamed type in root group */
- for(u = 0; u < type_table->nobjs; u++)
- if(!type_table->objs[u].recorded) {
- dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
- type = H5Dget_type(dset);
- sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
- dump_function_table->dump_named_datatype_function(type, type_name);
- H5Tclose(type);
- H5Dclose(dset);
- }
- } /* end if */
-
- H5Oget_info(gid, &oinfo);
-
- /* Must check for uniqueness of all objects if we've traversed an elink,
- * otherwise only check if the reference count > 1.
- */
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
-
- found_obj = search_obj(group_table, oinfo.addr);
-
- if (found_obj == NULL) {
- indentation(indent);
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- }
- else if (found_obj->displayed) {
- indentation(indent);
- HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname);
- }
- else {
- found_obj->displayed = TRUE;
- /* 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(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end if */
- else {
- if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
-
- /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the group, then, sort by creation order, otherwise by name */
-
- 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);
-
- }
- }
-
- 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 */
-
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end if */
- else {
- if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
-
- /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
- in the group, then, sort by creation order, otherwise by name */
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawdatastream is changed only when succeeded */
- 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);
+ if (rawdatastream && rawdatastream != stdout) {
+ if (fclose(rawdatastream))
+ perror("closing rawdatastream");
else
- H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL);
-
-
- }
-
- indent -= COL;
- indentation(indent);
- end_obj(dump_header_format->groupend, dump_header_format->groupblockend);
- free(tmp);
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_dataset
- *
- * Purpose: Dump the specified data set
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- * Pedro Vicente, 2004, added dataset creation property list display
- * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for
- * other iteration orders
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_dataset(hid_t did, const char *name, struct subset_t *sset)
-{
- hid_t type, space;
- unsigned attr_crt_order_flags;
- hid_t dcpl_id; /* dataset creation property list ID */
-
- 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) {
- 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);
-
- type = H5Dget_type(did);
- space = H5Dget_space(did);
-
- dump_comment(did);
- dump_datatype(type);
- dump_dataspace(space);
-
- if(display_oid)
- dump_oid(did);
-
- if(display_dcpl)
- dump_dcpl(dcpl_id, type, did);
-
- if(display_data) {
- int data_loop = 1;
- int i;
- if(display_packed_bits)
- data_loop = packed_bits_num;
- 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];
- }
- switch(H5Tget_class(type)) {
- case H5T_TIME:
- indentation(indent + COL);
- HDfprintf(stdout, "DATA{ not yet implemented.}\n");
- break;
-
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_COMPOUND:
- case H5T_REFERENCE:
- case H5T_ENUM:
- case H5T_VLEN:
- case H5T_ARRAY:
- dump_data(did, DATASET_DATA, sset, display_ai);
- break;
-
- default:
- break;
- } /* end switch */
- } /* for(i=0;i<data_loop;i++) */
- }
-
- indent += COL;
-
- 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(H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, 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_attr_cb, NULL) < 0) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
-
- }
-
- indent -= COL;
-
- H5Tclose(type);
- H5Sclose(space);
- H5Pclose(dcpl_id);
-
-
- indentation(indent);
- end_obj(dump_header_format->datasetend,dump_header_format->datasetblockend);
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_dims
- *
- * Purpose: Dump the dimensions handed to it in a comma separated list
- *
- * Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 27. February 2001
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_dims(hsize_t *s, int dims)
-{
- int i;
-
- for (i = 0; i < dims; i++) {
- printf(HSIZE_T_FORMAT, s[i]);
-
- if (i + 1 != dims) HDfprintf(stdout, ", ");
- }
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_subsetting_header
- *
- * Purpose: Dump the subsetting header like specified in the DDL.
- *
- * Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 27. February 2001
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_subsetting_header(struct subset_t *sset, int dims)
-{
- indentation(indent);
- HDfprintf(stdout, "%s %s\n", dump_header_format->subsettingbegin, dump_header_format->subsettingblockbegin);
-
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "%s %s ", dump_header_format->startbegin, dump_header_format->startblockbegin);
- dump_dims(sset->start.data, dims);
- HDfprintf(stdout, "%s %s\n", dump_header_format->startend, dump_header_format->startblockend);
-
- indentation(indent);
- HDfprintf(stdout, "%s %s ", dump_header_format->stridebegin, dump_header_format->strideblockbegin);
- dump_dims(sset->stride.data, dims);
- HDfprintf(stdout, "%s %s\n", dump_header_format->strideend, dump_header_format->strideblockend);
-
- indentation(indent);
- HDfprintf(stdout, "%s %s ", dump_header_format->countbegin, dump_header_format->countblockbegin);
-
- if(sset->count.data)
- dump_dims(sset->count.data, dims);
- else
- HDfprintf(stdout, "DEFAULT");
-
- HDfprintf(stdout, "%s %s\n", dump_header_format->countend, dump_header_format->countblockend);
-
- indentation(indent);
- HDfprintf(stdout, "%s %s ", dump_header_format->blockbegin, dump_header_format->blockblockbegin);
-
- if(sset->block.data)
- dump_dims(sset->block.data, dims);
- else
- HDfprintf(stdout, "DEFAULT");
-
- HDfprintf(stdout, "%s %s\n", dump_header_format->blockend, dump_header_format->blockblockend);
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_data
- *
- * Purpose: Dump attribute or dataset data
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications: pvn, print the matrix indices
- * Albert Cheng, 2004/11/18
- * Add --string printing for attributes too.
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
-{
- H5S_class_t space_type;
- 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) {
- outputformat->fmt_double = fp_format;
- outputformat->fmt_float = fp_format;
- }
-
- if (nCols==0) {
- outputformat->line_ncols = 65535;
- outputformat->line_per_line = 1;
- }
- else
- outputformat->line_ncols = nCols;
- outputformat->do_escape=display_escape;
- /* print the matrix indices */
- outputformat->pindex=display_index;
-
- /* do not print indices for regions */
- if(obj_data == DATASET_DATA) {
- hid_t f_type = H5Dget_type(obj_id);
-
- if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) {
- /* For the region option, correct the display of indices */
- if (display_region) {
- if (display_index) {
- outputformat->pindex = 1;
- outputformat->idx_fmt = "(%s): ";
- outputformat->idx_n_fmt = HSIZE_T_FORMAT;
- outputformat->idx_sep = ",";
- outputformat->line_pre = "%s";
- }
- else {
- outputformat->pindex = 0;
- outputformat->idx_fmt = "";
- outputformat->idx_n_fmt = "";
- outputformat->idx_sep = "";
- outputformat->line_pre = "";
- }
- }
- else
- outputformat->pindex = 0;
- }
- H5Tclose(f_type);
- }
-
- if (outputformat->pindex) {
- outputformat->idx_fmt = "(%s): ";
- outputformat->idx_n_fmt = HSIZE_T_FORMAT;
- outputformat->idx_sep = ",";
- outputformat->line_pre = "%s";
- }
-
- indent += COL;
-
- /*
- * the depth will tell us how far we need to indent extra. we use to just
- * use indent but with the merging of the tools lib we have to do
- * something different for the lib funtions... the normal indentation is 6
- * so when we don't need any extra indentation, depth will be 0.
- */
- depth = indent / stdindent + 1;
-
- if (sset && obj_data == DATASET_DATA) {
- hid_t f_space = H5Dget_space(obj_id);
-
- dump_subsetting_header(sset, H5Sget_simple_extent_ndims(f_space));
- H5Sclose(f_space);
-
- /* recalculate the depth of the data */
- depth = indent / stdindent + 1;
+ rawdatastream = NULL;
}
- indentation(indent);
- begin_obj(dump_header_format->databegin, (const char *)NULL, dump_header_format->datablockbegin);
-
- /* Print all the values. */
- if(obj_data == DATASET_DATA) {
- 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)) {
- /*
- * Print 1-byte integer data as an ASCII character string
- * instead of integers if the `-r' or `--string' command-line
- * option was given.
- *
- * We don't want to modify the global dataformat, so make a
- * copy of it instead.
- */
- string_dataformat = *outputformat;
- string_dataformat.idx_fmt = " ";
- string_dataformat.line_multi_new = 1;
- string_dataformat.line_1st = " %s\"";
- string_dataformat.line_pre = " %s";
- string_dataformat.line_cont = " %s";
- string_dataformat.str_repeat = 8;
- string_dataformat.ascii = TRUE;
- string_dataformat.elmt_suf1 = "";
- string_dataformat.elmt_suf2 = "";
- string_dataformat.line_indent = "";
- strcpy(string_prefix, string_dataformat.line_pre);
- strcat(string_prefix, "\"");
- string_dataformat.line_pre = string_prefix;
- string_dataformat.line_suf = "\"";
- outputformat = &string_dataformat;
+ /* binary output */
+ if (is_bin) {
+ if ((f = fopen(fname, "wb")) != NULL) {
+ rawdatastream = f;
+ return 0;
}
-
-
- status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth);
-
- H5Tclose(f_type);
}
else {
- /* need to call h5tools_dump_mem for the attribute data */
- space = H5Aget_space(obj_id);
- space_type = H5Sget_simple_extent_type(space);
- if(space_type == H5S_NULL || space_type == H5S_NO_CLASS) {
- status = SUCCEED;
- }
- else {
- char string_prefix[64];
- h5tool_format_t string_dataformat;
-
- /* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
-
- type = H5Aget_type(obj_id);
- p_type = h5tools_get_native_type(type);
-
- ndims = H5Sget_simple_extent_dims(space, size, NULL);
-
- /* Check if we have VL data in the dataset's datatype */
- 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++)
- nelmts *= size[i];
-
- alloc_size = nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
- assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
-
- if(alloc_size) {
- buf = malloc((size_t)alloc_size);
- assert(buf);
-
- if (H5Aread(obj_id, p_type, buf) >= 0)
- if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) {
- /*
- * Print 1-byte integer data as an ASCII character string
- * instead of integers if the `-r' or `--string' command-line
- * option was given.
- *
- * We don't want to modify the global dataformat, so make a
- * copy of it instead.
- */
- string_dataformat = *outputformat;
- string_dataformat.idx_fmt = " ";
- string_dataformat.line_multi_new = 1;
- string_dataformat.line_1st = " %s\"";
- string_dataformat.line_pre = " %s";
- string_dataformat.line_cont = " %s";
- string_dataformat.str_repeat = 8;
- string_dataformat.ascii = TRUE;
- string_dataformat.elmt_suf1 = "";
- string_dataformat.elmt_suf2 = "";
- string_dataformat.line_indent = "";
- strcpy(string_prefix, string_dataformat.line_pre);
- strcat(string_prefix, "\"");
- string_dataformat.line_pre = string_prefix;
- string_dataformat.line_suf = "\"";
- outputformat = &string_dataformat;
- }
-
- 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
- status = SUCCEED;
-
- H5Tclose(p_type);
- H5Tclose(type);
+ if ((f = fopen(fname, "w")) != NULL) {
+ rawdatastream = f;
+ return 0;
}
- H5Sclose(space);
}
- if (status == FAIL) {
- indentation(indent + COL);
- error_msg("unable to print data\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
-
- indentation(indent);
- end_obj(dump_header_format->dataend, dump_header_format->datablockend);
- indent -= COL;
-
- if (sset && obj_data == DATASET_DATA) {
- indentation(indent);
- end_obj(dump_header_format->subsettingend, dump_header_format->subsettingblockend);
- indent -= COL;
- }
+ return -1;
}
/*-------------------------------------------------------------------------
- * Function: dump_oid
- *
- * Purpose: Prints the object ids
- *
- * Return: void
+ * Function: set_output_file
*
- * Programmer: Patrick Lu
+ * Purpose: Open fname as the output file for raw output.
+ * Set rawoutstream as its file stream.
*
- * Modifications:
+ * Return: 0 -- succeeded
+ * negative -- failed
*
*-------------------------------------------------------------------------
*/
-static void
-dump_oid(hid_t oid)
+static int
+set_output_file(const char *fname)
{
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s %d %s\n", OBJID, BEGIN, oid, END);
-}
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawoutstream is changed only when succeeded */
-/*-------------------------------------------------------------------------
- * Function: dump_packed_bits
- *
- * Purpose: Prints the packed bits offset and length
- *
- * Return: void
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_packed_bits(unsigned int packed_index, hid_t type)
-{
- 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) {
- packed_bits_size = 8 * sizeof(char);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_UCHAR) == TRUE) {
- packed_bits_size = 8 * sizeof(unsigned char);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_SHORT) == TRUE) {
- packed_bits_size = 8 * sizeof(short);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_USHORT) == TRUE) {
- packed_bits_size = 8 * sizeof(unsigned short);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_INT) == TRUE) {
- packed_bits_size = 8 * sizeof(int);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_UINT) == TRUE) {
- packed_bits_size = 8 * sizeof(unsigned int);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_LONG) == TRUE) {
- packed_bits_size = 8 * sizeof(long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_ULONG) == TRUE) {
- packed_bits_size = 8 * sizeof(unsigned long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_LLONG) == TRUE) {
- packed_bits_size = 8 * sizeof(long long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_ULLONG) == TRUE) {
- packed_bits_size = 8 * sizeof(unsigned long long);
- }
+ if (rawoutstream && rawoutstream != stdout) {
+ if (fclose(rawoutstream))
+ perror("closing rawoutstream");
else
- error_msg("Packed Bit not valid for this datatype");
- }
- 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_mask[packed_index] = 0;
- };
- HDfprintf(stdout, "%s %s=%d %s=%d\n", PACKED_BITS, PACKED_OFFSET, packed_offset[packed_index], PACKED_LENGTH, packed_length[packed_index]);
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_comment
- *
- * Purpose: prints the comment for the the object name
- *
- * Return: void
- *
- * Programmer: pvn
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_comment(hid_t obj_id)
-{
- size_t buf_size = 0;
- ssize_t cmt_bufsize = -1;
- char* comment = NULL;
-
- cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
-
- /* call H5Oget_comment again with the correct value.
- * If the call to H5Oget_comment returned an error, skip this block */
- if (cmt_bufsize > 0) {
- comment = (char *)HDmalloc((size_t)(cmt_bufsize+1)); /* new_size including null terminator */
- if(comment) {
- cmt_bufsize = H5Oget_comment(obj_id, comment, cmt_bufsize);
- if(cmt_bufsize > 0) {
- comment[cmt_bufsize] = '\0'; /* necessary because null char is not returned */
- indentation(indent);
- HDfprintf(stdout, "COMMENT \"%s\"\n", comment);
- } /* end if */
- HDfree(comment);
- }
- }
-
-} /* end dump_comment() */
-
-
-/*-------------------------------------------------------------------------
- * Function: dump_fill_value
- *
- * Purpose: prints the fill value
- *
- * Return: void
- *
- * Programmer: pvn
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-static void dump_fill_value(hid_t dcpl,hid_t type_id, hid_t obj_id)
-{
- h5tools_context_t ctx; /*print context */
- size_t size;
- 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;
-
- n_type = h5tools_get_native_type(type_id);
-
- size = H5Tget_size(n_type);
- buf = malloc(size);
-
- H5Pget_fill_value(dcpl, n_type, buf);
-
- h5tools_dump_simple_data(stdout, outputformat, obj_id, &ctx, START_OF_DATA | END_OF_DATA, nelmts, n_type, buf);
-
- H5Tclose(n_type);
-
- if (buf)
- free (buf);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: dump_dcpl
- *
- * Purpose: prints several dataset create property list properties
- *
- * Return: void
- *
- * Programmer: pvn
- *
- * Modifications: pvn, March 28, 2008
- * Add a COMPRESSION ratio information for cases when filters are present
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
-{
- int nfilters; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- char f_name[256]; /* filter name */
- unsigned szip_options_mask;
- unsigned szip_pixels_per_block;
- hsize_t chsize[64]; /* chunk size in elements */
- int rank; /* rank */
- 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;
- H5D_alloc_time_t at;
- H5D_fill_time_t ft;
- hsize_t storage_size;
- haddr_t ioffset;
- int i;
- unsigned j;
-
- storage_size = H5Dget_storage_size(obj_id);
- nfilters = H5Pget_nfilters(dcpl_id);
- ioffset = H5Dget_offset(obj_id);
- HDstrcpy(f_name,"\0");
-
- /*-------------------------------------------------------------------------
- * STORAGE_LAYOUT
- *-------------------------------------------------------------------------
- */
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s\n", STORAGE_LAYOUT, BEGIN);
-
- if (H5D_CHUNKED == H5Pget_layout(dcpl_id)) {
- /*start indent */
- indent += COL;
- indentation(indent + COL);
- 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++)
- HDfprintf(stdout, ", %Hu", chsize[i]);
- HDfprintf(stdout, " %s\n", dump_header_format->dataspacedimend);
- indentation(indent + COL);
-
-
- /* if there are filters, print a compression ratio */
- 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++) {
- cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_name), f_name, NULL);
-
- switch (filtn) {
- case H5Z_FILTER_DEFLATE:
- case H5Z_FILTER_SZIP:
- case H5Z_FILTER_NBIT:
- case H5Z_FILTER_SCALEOFFSET:
- ok = 1;
- break;
- }
- }
-
- if (ndims && ok) {
- hsize_t uncomp_size;
-
- for (i = 0; i < ndims; i++) {
- nelmts *= dims[i];
- }
- uncomp_size = nelmts * datum_size;
-
- /* compression ratio = uncompressed size / compressed size */
-
- if (storage_size != 0)
- ratio = (double) uncomp_size / (double) storage_size;
-
- HDfprintf(stdout, "SIZE %Hu (%.3f:1 COMPRESSION)\n ", storage_size, ratio);
-
- }
- else
- HDfprintf(stdout, "SIZE %Hu\n ", storage_size);
-
-
- H5Sclose(sid);
- H5Tclose(tid);
-
- }
- else {
- HDfprintf(stdout, "SIZE %Hu\n ", storage_size);
- }
-
- /*end indent */
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
- }
- else if (H5D_COMPACT == H5Pget_layout(dcpl_id)) {
- /*start indent */
- indent += COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n", COMPACT);
-
- indentation(indent + COL);
- HDfprintf(stdout, "SIZE %Hu\n", storage_size);
-
- /*end indent */
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
- }
- else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl_id)) {
- int next;
-
- next = H5Pget_external_count(dcpl_id);
-
- /*-------------------------------------------------------------------------
- * EXTERNAL_FILE
- *-------------------------------------------------------------------------
- */
- if (next) {
- /*start indent */
- indent += COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n", CONTIGUOUS);
-
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s\n", EXTERNAL, BEGIN);
-
- /*start indent */
- indent += COL;
- for ( j=0; j<(unsigned)next; j++) {
- H5Pget_external(dcpl_id,j,sizeof(name),name,&offset,&size);
- indentation(indent + COL);
- HDfprintf(stdout,"FILENAME %s SIZE %Hu OFFSET %ld\n",name,size,offset);
- }
- /*end indent */
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
-
- /*end indent */
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
- }
- else {
- /*start indent */
- indent += COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n", CONTIGUOUS);
-
- indentation(indent + COL);
- HDfprintf(stdout,"SIZE %Hu\n", storage_size);
- indentation(indent + COL);
- HDfprintf(stdout,"OFFSET %Hu\n", ioffset);
-
- /*end indent */
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
- }
- }
- /*-------------------------------------------------------------------------
- * FILTERS
- *-------------------------------------------------------------------------
- */
-
-
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s\n", FILTERS, BEGIN);
- indent += COL;
-
- if (nfilters) {
- 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);
-
- switch (filtn) {
- case H5Z_FILTER_DEFLATE:
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s %s %d %s\n", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END);
- break;
- case H5Z_FILTER_SHUFFLE:
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n", SHUFFLE);
- break;
- case H5Z_FILTER_FLETCHER32:
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n", FLETCHER32);
- break;
- case H5Z_FILTER_SZIP:
- {
- szip_options_mask=cd_values[0];;
- szip_pixels_per_block=cd_values[1];
-
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s\n",SZIP, BEGIN);
-
- /*start indent */
- indent += COL;
- indentation(indent + COL);
- HDfprintf(stdout, "PIXELS_PER_BLOCK %d\n", szip_pixels_per_block);
-
- indentation(indent + COL);
- if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK)
- HDfprintf(stdout, "MODE %s\n", "HARDWARE");
- else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK)
- HDfprintf(stdout, "MODE %s\n", "K13");
-
- indentation(indent + COL);
- if (szip_options_mask & H5_SZIP_EC_OPTION_MASK)
- HDfprintf(stdout, "CODING %s\n", "ENTROPY");
- else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK)
- HDfprintf(stdout, "CODING %s\n", "NEAREST NEIGHBOUR");
-
- indentation(indent + COL);
- if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK)
- HDfprintf(stdout, "BYTE_ORDER %s\n", "LSB");
- else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK)
- HDfprintf(stdout, "BYTE_ORDER %s\n", "MSB");
-
- indentation(indent + COL);
- if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK)
- HDfprintf(stdout, "HEADER %s\n", "RAW");
-
- /*end indent */
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
- }
- break;
- case H5Z_FILTER_NBIT:
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n", NBIT);
- break;
- case H5Z_FILTER_SCALEOFFSET:
- indentation(indent + COL);
- 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))
- HDfprintf(stdout, "%s %s\n", "USER_REGISTERED_FILTER", BEGIN);
- else
- HDfprintf(stdout, "%s %s\n", "UNKNOWN_FILTER", BEGIN);
- /*start indent */
- indent += COL;
- indentation(indent + COL);
- HDfprintf(stdout, "FILTER_ID %d\n", filtn);
- if (f_name[0]!='\0') {
- indentation(indent + COL);
- HDfprintf(stdout, "COMMENT %s\n", f_name);
- }
- if (cd_nelmts) {
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s ","PARAMS", BEGIN);
- for (j=0; j<cd_nelmts; j++)
- HDfprintf(stdout, "%d ", cd_values[j]);
- HDfprintf(stdout, "%s\n", END);
- }
- break;
- }/*switch*/
- } /*i*/
- }/*nfilters*/
- else {
- indentation(indent + COL);
- HDfprintf(stdout, "NONE\n");
+ rawoutstream = NULL;
}
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
-
- /*-------------------------------------------------------------------------
- * FILLVALUE
- *-------------------------------------------------------------------------
- */
- indentation(indent + COL);
- HDfprintf(stdout, "%s %s\n", FILLVALUE, BEGIN);
- /*start indent */
- indent += COL;
- indentation(indent + COL);
- HDfprintf(stdout, "FILL_TIME ");
- H5Pget_fill_time(dcpl_id, &ft);
- switch ( ft ) {
- case H5D_FILL_TIME_ALLOC:
- HDfprintf(stdout, "%s", "H5D_FILL_TIME_ALLOC\n");
- break;
- case H5D_FILL_TIME_NEVER:
- HDfprintf(stdout, "%s", "H5D_FILL_TIME_NEVER\n");
- break;
- case H5D_FILL_TIME_IFSET:
- HDfprintf(stdout, "%s", "H5D_FILL_TIME_IFSET\n");
- break;
- default:
- assert(0);
- break;
- }
- indentation(indent + COL);
- HDfprintf(stdout, "%s ", "VALUE ");
- H5Pfill_value_defined(dcpl_id, &fvstatus);
- if (fvstatus == 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);
- HDfprintf(stdout, "\n");
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
-
- /*-------------------------------------------------------------------------
- * ALLOCATION_TIME
- *-------------------------------------------------------------------------
- */
- indentation(indent + COL);
- 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:
- HDfprintf(stdout, "%s", "H5D_ALLOC_TIME_EARLY\n");
- break;
- case H5D_ALLOC_TIME_INCR:
- HDfprintf(stdout, "%s", "H5D_ALLOC_TIME_INCR\n");
- break;
- case H5D_ALLOC_TIME_LATE:
- HDfprintf(stdout, "%s", "H5D_ALLOC_TIME_LATE\n");
- break;
- default:
- assert(0);
- break;
- }
- /* end indent */
- indent -= COL;
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n",END);
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_fcpl
- *
- * Purpose: prints file creation property list information
- *
- * Return: void
- *
- * Programmer: pvn
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-dump_fcpl(hid_t fid)
-{
- hid_t fcpl; /* file creation property list ID */
- hid_t fapl; /* file access property list ID */
- hsize_t userblock; /* userblock size retrieved from FCPL */
- size_t off_size; /* size of offsets in the file */
- size_t len_size; /* size of lengths in the file */
- unsigned super; /* superblock version # */
- unsigned freelist; /* free list version # */
- unsigned stab; /* symbol table entry version # */
- unsigned shhdr; /* shared object header version # */
- hid_t fdriver; /* file driver */
- char dname[32]; /* buffer to store driver name */
- 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 */
-
- fcpl=H5Fget_create_plist(fid);
- H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
- H5Pget_userblock(fcpl,&userblock);
- H5Pget_sizes(fcpl,&off_size,&len_size);
- H5Pget_sym_k(fcpl,&sym_ik,&sym_lk);
- H5Pget_istore_k(fcpl,&istore_ik);
- H5Pclose(fcpl);
- fapl=h5_fileaccess();
- fdriver=H5Pget_driver(fapl);
- H5Pclose(fapl);
-
- /*-------------------------------------------------------------------------
- * SUPER_BLOCK
- *-------------------------------------------------------------------------
- */
- HDfprintf(stdout, "%s %s\n",SUPER_BLOCK, BEGIN);
- indentation(indent + COL);
- HDfprintf(stdout, "%s %u\n","SUPERBLOCK_VERSION", super);
- indentation(indent + COL);
- HDfprintf(stdout, "%s %u\n","FREELIST_VERSION", freelist);
- indentation(indent + COL);
- HDfprintf(stdout, "%s %u\n","SYMBOLTABLE_VERSION", stab);
- indentation(indent + COL);
- HDfprintf(stdout, "%s %u\n","OBJECTHEADER_VERSION", shhdr);
- 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);
- HDfprintf(stdout, "%s %u\n","BTREE_RANK", sym_ik);
- indentation(indent + COL);
- HDfprintf(stdout, "%s %d\n","BTREE_LEAF", sym_lk);
-
- if (H5FD_CORE==fdriver)
- HDstrcpy(dname,"H5FD_CORE");
-#ifdef H5_HAVE_DIRECT
- else if (H5FD_DIRECT==fdriver)
- HDstrcpy(dname,"H5FD_DIRECT");
-#endif
- else if (H5FD_FAMILY==fdriver)
- HDstrcpy(dname,"H5FD_FAMILY");
- else if (H5FD_LOG==fdriver)
- HDstrcpy(dname,"H5FD_LOG");
- else if (H5FD_MPIO==fdriver)
- HDstrcpy(dname,"H5FD_MPIO");
- else if (H5FD_MULTI==fdriver)
- HDstrcpy(dname,"H5FD_MULTI");
- else if (H5FD_SEC2==fdriver)
- HDstrcpy(dname,"H5FD_SEC2");
- else if (H5FD_STDIO==fdriver)
- HDstrcpy(dname,"H5FD_STDIO");
-#ifdef H5_HAVE_STREAM
- else if (H5FD_STREAM==fdriver)
- HDstrcpy(dname,"H5FD_STREAM");
-#endif
- else
- HDstrcpy(dname,"Unknown driver");
-
- /* Take out this because the driver used can be different from the
- * standard output. */
- /*indentation(indent + COL);
- HDfprintf(stdout, "%s %s\n","FILE_DRIVER", dname);*/
- indentation(indent + COL);
- HDfprintf(stdout, "%s %u\n","ISTORE_K", istore_ik);
- HDfprintf(stdout, "%s\n",END);
-
- /*-------------------------------------------------------------------------
- * USER_BLOCK
- *-------------------------------------------------------------------------
- */
- HDfprintf(stdout, "USER_BLOCK %s\n",BEGIN);
- indentation(indent + COL);
- HDfprintf(stdout,"%s %Hu\n","USERBLOCK_SIZE", userblock);
- HDfprintf(stdout, "%s\n",END);
-}
-
-/*-------------------------------------------------------------------------
- * Function: dump_fcontents
- *
- * Purpose: prints all objects
- *
- * Return: void
- *
- * Programmer: pvn
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-static void dump_fcontents(hid_t fid)
-{
-
- HDfprintf(stdout, "%s %s\n",FILE_CONTENTS, BEGIN);
-
- /* special case of unamed types in root group */
- if (unamedtype) {
- unsigned u;
- for (u = 0; u < type_table->nobjs; u++) {
- if (!type_table->objs[u].recorded)
- HDfprintf(stdout, " %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno);
- }
+ if ((f = fopen(fname, "w")) != NULL) {
+ rawoutstream = f;
+ return 0;
}
- /* print objects in the files */
- h5trav_print(fid);
-
- HDfprintf(stdout, " %s\n",END);
+ return -1;
}
-
/*-------------------------------------------------------------------------
- * Function: set_output_file
+ * Function: set_error_file
*
- * Purpose: Open fname as the output file for dataset raw data.
- * Set rawdatastream as its file stream.
+ * Purpose: Open fname as the error output file for dataset raw error.
+ * Set rawerrorstream as its file stream.
*
* Return: 0 -- succeeded
* negative -- failed
*
- * Programmer: Albert Cheng, 2000/09/30
- *
- * Modifications:
- * pvn June, 1, 2006. Add a switch for binary output
- *
*-------------------------------------------------------------------------
*/
static int
-set_output_file(const char *fname, int is_bin)
+set_error_file(const char *fname)
{
FILE *f; /* temporary holding place for the stream pointer
- * so that rawdatastream is changed only when succeeded */
+ * so that rawerrorstream is changed only when succeeded */
- if (rawdatastream && rawdatastream != stdout) {
- if (fclose(rawdatastream))
- perror("closing rawdatastream");
+ if (rawerrorstream && rawerrorstream != stderr) {
+ if (fclose(rawerrorstream))
+ perror("closing rawerrorstream");
else
- rawdatastream = NULL;
+ rawerrorstream = 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;
- }
+ if ((f = fopen(fname, "w")) != NULL) {
+ rawerrorstream = f;
+ return 0;
}
return -1;
}
-
-
/*-------------------------------------------------------------------------
* Function: set_binary_form
*
@@ -3455,17 +582,17 @@ set_output_file(const char *fname, int is_bin)
static int
set_binary_form(const char *form)
{
- int bform=-1;
+ 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 */
+ else if (strcmp(form,"FILE") == 0) /* file type form */
bform = 1;
- else if (strcmp(form,"LE")==0) /* convert to little endian */
+ else if (strcmp(form,"LE") == 0) /* convert to little endian */
bform = 2;
- else if (strcmp(form,"BE")==0) /* convert to big endian */
+ else if (strcmp(form,"BE") == 0) /* convert to big endian */
bform = 3;
return bform;
@@ -3500,8 +627,6 @@ set_sort_by(const char *form)
return idx_type;
}
-
-
/*-------------------------------------------------------------------------
* Function: set_sort_order
*
@@ -3531,30 +656,6 @@ set_sort_order(const char *form)
return iter_order;
}
-
-/*-------------------------------------------------------------------------
- * Function: handle_attributes
- *
- * Purpose: Handle the attributes from the command.
- *
- * Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- *
- * PVN, May 2008
- * add an extra parameter PE, to allow printing/not printing of error messages
- *
- *-------------------------------------------------------------------------
- */
-static void
-handle_attributes(hid_t fid, const char *attr, void UNUSED * data, int UNUSED pe, const char UNUSED *display_name)
-{
- dump_selected_attr(fid, attr);
-}
-
/*-------------------------------------------------------------------------
* Function: parse_hsize_list
*
@@ -3604,7 +705,7 @@ parse_hsize_list(const char *h_list, subset_d *d)
return;
/* allocate an array for the integers in the list */
- p_list = (hsize_t *)calloc(size_count, sizeof(hsize_t));
+ p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t));
for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
if(isdigit(*ptr)) {
@@ -3617,7 +718,7 @@ parse_hsize_list(const char *h_list, subset_d *d)
}
d->data = p_list;
d->len = size_count;
-
+
return;
}
@@ -3643,37 +744,32 @@ parse_subset_params(char *dset)
struct subset_t *s = NULL;
register char *brace;
- if ((brace = strrchr(dset, '[')) != NULL) {
- char *slash = strrchr(dset, '/');
+ if (!disable_compact_subset && ((brace = strrchr(dset, '[')) != NULL)) {
+ *brace++ = '\0';
- /* sanity check to make sure the [ isn't part of the dataset name */
- if (brace > slash) {
- *brace++ = '\0';
+ s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
+ parse_hsize_list(brace, &s->start);
- s = (struct subset_t *)calloc(1, sizeof(struct subset_t));
- parse_hsize_list(brace, &s->start);
+ while (*brace && *brace != ';')
+ brace++;
- while (*brace && *brace != ';')
- brace++;
+ if (*brace) brace++;
- if (*brace) brace++;
+ parse_hsize_list(brace, &s->stride);
- parse_hsize_list(brace, &s->stride);
+ while (*brace && *brace != ';')
+ brace++;
- while (*brace && *brace != ';')
- brace++;
+ if (*brace) brace++;
- if (*brace) brace++;
+ parse_hsize_list(brace, &s->count);
- parse_hsize_list(brace, &s->count);
+ while (*brace && *brace != ';')
+ brace++;
- while (*brace && *brace != ';')
- brace++;
+ if (*brace) brace++;
- if (*brace) brace++;
-
- parse_hsize_list(brace, &s->block);
- }
+ parse_hsize_list(brace, &s->block);
}
return s;
@@ -3711,12 +807,12 @@ parse_mask_list(const char *h_list)
ptr = h_list;
while (*ptr) {
/* scan for an offset which is an unsigned int */
- if (!HDisdigit(*ptr)){
+ 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){
+ 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;
@@ -3732,18 +828,18 @@ parse_mask_list(const char *h_list)
}
/* scan for a length which is a positive int */
- if (!HDisdigit(*ptr)){
+ if (!HDisdigit(*ptr)) {
error_msg("Bad mask list(%s)\n", h_list);
return FAIL;
}
length_value = HDatoi(ptr);
- if (length_value <= 0){
+ 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);
+ offset_value+length_value, PACKED_BITS_SIZE_MAX);
return FAIL;
}
@@ -3752,7 +848,7 @@ parse_mask_list(const char *h_list)
;
/* store the offset,length pair */
- if (packed_bits_num >= PACKED_BITS_MAX){
+ 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;
@@ -3772,8 +868,8 @@ parse_mask_list(const char *h_list)
packed_bits_num++;
/* skip a possible comma separator */
- if (*ptr == ','){
- if (!(*++ptr)){
+ if (*ptr == ',') {
+ if (!(*++ptr)) {
/* unexpected end of string */
error_msg("Bad mask list(%s), unexpected end of string.\n", h_list);
return FAIL;
@@ -3781,7 +877,7 @@ parse_mask_list(const char *h_list)
}
}
HDassert(packed_bits_num <= PACKED_BITS_MAX);
- if (packed_bits_num == 0){
+ if (packed_bits_num == 0) {
/* got no masks! */
error_msg("Bad mask list(%s)\n", h_list);
return FAIL;
@@ -3789,366 +885,7 @@ parse_mask_list(const char *h_list)
return SUCCEED;
}
-/*-------------------------------------------------------------------------
- * Function: handle_datasets
- *
- * Purpose: Handle the datasets from the command.
- *
- * Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- * Pedro Vicente, Tuesday, January 15, 2008
- * check for block overlap\
- *
- * Pedro Vicente, May 8, 2008
- * added a flag PE that prints/not prints error messages
- * added for cases of external links not found, to avoid printing of
- * objects not found, since external links are dumped on a trial error basis
- *
- *-------------------------------------------------------------------------
- */
-static void
-handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name)
-{
- H5O_info_t oinfo;
- hid_t dsetid;
- 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);
- indentation(COL);
- error_msg("unable to open dataset \"%s\"\n", real_name);
- end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
- h5tools_setstatus(EXIT_FAILURE);
- }
- return;
- } /* end if */
-
- if(sset) {
- unsigned int i;
- hid_t sid = H5Dget_space(dsetid);
- int ndims = H5Sget_simple_extent_ndims(sid);
-
- H5Sclose(sid);
- if(ndims < 0) {
- error_msg("H5Sget_simple_extent_ndims failed\n");
- h5tools_setstatus(EXIT_FAILURE);
- return;
- }
-
- if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) {
- /* they didn't specify a ``stride'' or ``block''. default to 1 in all
- * dimensions */
- if(!sset->start.data) {
- /* default to (0, 0, ...) for the start coord */
- sset->start.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t));
- sset->start.len = ndims;
- }
-
- if(!sset->stride.data) {
- sset->stride.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t));
- sset->stride.len = ndims;
- for (i = 0; i < ndims; i++)
- sset->stride.data[i] = 1;
- }
-
- if(!sset->count.data) {
- sset->count.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t));
- sset->count.len = ndims;
- for (i = 0; i < ndims; i++)
- sset->count.data[i] = 1;
- }
-
- if(!sset->block.data) {
- sset->block.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t));
- sset->block.len = ndims;
- for (i = 0; i < ndims; i++)
- sset->block.data[i] = 1;
- }
- }
-
- /*-------------------------------------------------------------------------
- * check for dimension overflow
- *-------------------------------------------------------------------------
- */
- if(sset->start.len > ndims) {
- error_msg("number of start dims (%u) exceed dataset dims (%u)\n", sset->start.len, ndims);
- h5tools_setstatus(EXIT_FAILURE);
- return;
- }
- if(sset->stride.len > ndims) {
- error_msg("number of stride dims (%u) exceed dataset dims (%u)\n", sset->stride.len, ndims);
- h5tools_setstatus(EXIT_FAILURE);
- return;
- }
- if(sset->count.len > ndims) {
- error_msg("number of count dims (%u) exceed dataset dims (%u)\n", sset->count.len, ndims);
- h5tools_setstatus(EXIT_FAILURE);
- return;
- }
- if(sset->block.len > ndims) {
- error_msg("number of block dims (%u) exceed dataset dims (%u)\n", sset->block.len, ndims);
- h5tools_setstatus(EXIT_FAILURE);
- return;
- }
-
- /*-------------------------------------------------------------------------
- * check for block overlap
- *-------------------------------------------------------------------------
- */
- for(i = 0; i < ndims; i++) {
- if(sset->count.data[i] > 1) {
- if(sset->stride.data[i] < sset->block.data[i]) {
- error_msg("wrong subset selection; blocks overlap\n");
- h5tools_setstatus(EXIT_FAILURE);
- return;
- } /* end if */
- } /* end if */
- } /* end for */
- } /* end if */
-
-
- H5Oget_info(dsetid, &oinfo);
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
-
- found_obj = search_obj(dset_table, oinfo.addr);
-
- if(found_obj) {
- if (found_obj->displayed) {
- indentation(indent);
- begin_obj(dump_header_format->datasetbegin, real_name, dump_header_format->datasetblockbegin);
- indentation(indent + COL);
- HDfprintf(stdout, "%s \"%s\"\n", HARDLINK, found_obj->objname);
- indentation(indent);
- end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
- }
- else {
- found_obj->displayed = TRUE;
- dump_dataset(dsetid, real_name, sset);
- }
- }
- else
- h5tools_setstatus(EXIT_FAILURE);
- }
- else
- dump_dataset(dsetid, real_name, sset);
-
- if(H5Dclose(dsetid) < 0)
- h5tools_setstatus(EXIT_FAILURE);
-}
-
-/*-------------------------------------------------------------------------
- * Function: handle_groups
- *
- * Purpose: Handle the groups from the command.
- *
- * Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications: Pedro Vicente, September 26, 2007
- * handle creation order
- *
- * Pedro Vicente, May 8, 2008
- * added a flag PE that prints/not prints error messages
- * added for cases of external links not found, to avoid printing of
- * objects not found, since external links are dumped on a trial error basis
- *
- *-------------------------------------------------------------------------
- */
-static void
-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) {
- begin_obj(dump_header_format->groupbegin, real_name, dump_header_format->groupblockbegin);
- indentation(COL);
- error_msg("unable to open group \"%s\"\n", real_name);
- end_obj(dump_header_format->groupend, dump_header_format->groupblockend);
- h5tools_setstatus(EXIT_FAILURE);
- }
- }
- else {
- size_t new_len = HDstrlen(group) + 1;
-
- if(prefix_len <= new_len) {
- prefix_len = new_len;
- prefix = (char *)HDrealloc(prefix, prefix_len);
- } /* end if */
-
- HDstrcpy(prefix, group);
-
- dump_group(gid, real_name);
-
- if(H5Gclose(gid) < 0)
- h5tools_setstatus(EXIT_FAILURE);
- } /* end else */
-} /* end handle_groups() */
-
-/*-------------------------------------------------------------------------
- * Function: handle_links
- *
- * Purpose: Handle soft or UD links from the command.
- *
- * Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, const char UNUSED *display_name)
-{
- H5L_info_t linfo;
-
- 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) {
- error_msg("\"%s\" is a hard link\n", links);
- h5tools_setstatus(EXIT_FAILURE);
- }
- 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)
- 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);
- 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);
- }
- }
- 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);
- HDfprintf(stdout, "LINKCLASS %d\n", linfo.type);
- end_obj(dump_header_format->udlinkend, dump_header_format->udlinkblockend);
- break;
- } /* end switch */
- HDfree(buf);
- } /* end else */
-}
-
-/*-------------------------------------------------------------------------
- * Function: handle_datatypes
- *
- * Purpose: Handle the datatypes from the command.
- *
- * Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- *
- * Pedro Vicente, May 8, 2008
- * added a flag PE that prints/not prints error messages
- * added for cases of external links not found, to avoid printing of
- * objects not found, since external links are dumped on a trial error basis
- *
- *-------------------------------------------------------------------------
- */
-static void
-handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const char *display_name)
-{
- hid_t type_id;
- const char *real_name = display_name ? display_name : type;
-
- if((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) {
- /* check if type is unamed datatype */
- unsigned idx = 0;
-
- while(idx < type_table->nobjs ) {
- char name[128];
-
- if(!type_table->objs[idx].recorded) {
- /* unamed datatype */
- sprintf(name, "/#"H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno);
-
- if(!HDstrcmp(name, real_name))
- break;
- } /* end if */
-
- idx++;
- } /* end while */
-
- if(idx == type_table->nobjs) {
- if (pe) {
- /* unknown type */
- 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);
- h5tools_setstatus(EXIT_FAILURE);
- }
- }
- 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);
- H5Tclose(type_id);
- H5Dclose(dsetid);
- }
- }
- else {
- dump_named_datatype(type_id, real_name);
-
- if(H5Tclose(type_id) < 0)
- h5tools_setstatus(EXIT_FAILURE);
- }
-}
-
-
+
/*-------------------------------------------------------------------------
* Function: free_handler
*
@@ -4169,34 +906,34 @@ 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);
+ HDfree(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);
+ HDfree(hand[i].subset_info->start.data);
if(hand[i].subset_info->stride.data)
- free(hand[i].subset_info->stride.data);
+ HDfree(hand[i].subset_info->stride.data);
if(hand[i].subset_info->count.data)
- free(hand[i].subset_info->count.data);
+ HDfree(hand[i].subset_info->count.data);
if(hand[i].subset_info->block.data)
- free(hand[i].subset_info->block.data);
+ HDfree(hand[i].subset_info->block.data);
- free(hand[i].subset_info);
+ HDfree(hand[i].subset_info);
hand[i].subset_info=NULL;
}
}
- free(hand);
+ HDfree(hand);
}
}
-
+
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
@@ -4219,26 +956,26 @@ free_handler(struct handler_t *hand, int len)
static struct handler_t *
parse_command_line(int argc, const char *argv[])
{
- struct handler_t *hand = NULL;
- struct handler_t *last_dset = NULL;
+ struct handler_t *hand = NULL;
+ struct handler_t *last_dset = NULL;
int i;
int opt;
int last_was_dset = FALSE;
- /* no arguments */
+ /* no arguments */
if (argc == 1) {
usage(h5tools_getprogname());
goto error;
}
/* this will be plenty big enough to hold the info */
- if((hand = (struct handler_t *)calloc((size_t)argc, sizeof(struct handler_t)))==NULL) {
- goto error;
+ if((hand = (struct handler_t *)HDcalloc((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) {
- parse_start:
+parse_start:
switch ((char)opt) {
case 'R':
display_region = TRUE;
@@ -4286,7 +1023,7 @@ parse_command_line(int argc, const char *argv[])
goto done;
break;
case 'w':
- nCols = HDatoi(opt_arg);
+ h5tools_nCols = HDatoi(opt_arg);
last_was_dset = FALSE;
break;
case 'a':
@@ -4357,13 +1094,13 @@ parse_command_line(int argc, const char *argv[])
case 'o':
if ( bin_output ) {
- if (set_output_file(opt_arg, 1) < 0) {
+ if (set_data_output_file(opt_arg, 1) < 0) {
usage(h5tools_getprogname());
goto error;
}
}
else {
- if (set_output_file(opt_arg, 0) < 0) {
+ if (set_data_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
}
@@ -4384,7 +1121,7 @@ parse_command_line(int argc, const char *argv[])
}
bin_output = TRUE;
if (outfname!=NULL) {
- if (set_output_file(outfname, 1) < 0) {
+ if (set_data_output_file(outfname, 1) < 0) {
/* failed to set output file */
usage(h5tools_getprogname());
goto error;
@@ -4422,30 +1159,34 @@ parse_command_line(int argc, const char *argv[])
display_packed_bits = TRUE;
break;
- /** begin XML parameters **/
+ /** begin XML parameters **/
case 'x':
/* select XML output */
doxml = TRUE;
useschema = TRUE;
- dump_header_format = NULL;
+ h5tools_dump_header_format = NULL;
dump_function_table = &xml_function_table;
+ h5tools_nCols = 0;
break;
case 'u':
doxml = TRUE;
useschema = FALSE;
xmlnsprefix = "";
- dump_header_format = NULL;
+ h5tools_dump_header_format = NULL;
dump_function_table = &xml_function_table;
+ h5tools_nCols = 0;
break;
case 'D':
/* specify alternative XML DTD or schema */
/* To Do: check format of this value? */
xml_dtd_uri = opt_arg;
+ h5tools_nCols = 0;
break;
case 'm':
/* specify alternative floating point printing format */
fp_format = opt_arg;
+ h5tools_nCols = 0;
break;
case 'X':
@@ -4461,10 +1202,11 @@ parse_command_line(int argc, const char *argv[])
else {
xmlnsprefix = opt_arg;
}
+ h5tools_nCols = 0;
break;
- /** end XML parameters **/
+ /** end XML parameters **/
- /** begin subsetting parameters **/
+ /** begin subsetting parameters **/
case 's':
case 'S':
case 'c':
@@ -4484,7 +1226,7 @@ parse_command_line(int argc, const char *argv[])
s = last_dset->subset_info;
}
else {
- last_dset->subset_info = s = (struct subset_t *)calloc(1, sizeof(struct subset_t));
+ last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
}
/*
@@ -4502,28 +1244,28 @@ parse_command_line(int argc, const char *argv[])
switch ((char)opt) {
case 's':
if (s->start.data) {
- free(s->start.data);
+ HDfree(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);
+ HDfree(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);
+ HDfree(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);
+ HDfree(s->block.data);
s->block.data = NULL;
}
parse_hsize_list(opt_arg, &s->block);
@@ -4533,7 +1275,7 @@ parse_command_line(int argc, const char *argv[])
}
} while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF);
- end_collect:
+end_collect:
last_was_dset = FALSE;
if (opt != EOF)
@@ -4546,6 +1288,9 @@ parse_command_line(int argc, const char *argv[])
case 'E':
enable_error_stack = TRUE;
break;
+ case 'C':
+ disable_compact_subset = TRUE;
+ break;
case 'h':
usage(h5tools_getprogname());
free_handler(hand, argc);
@@ -4559,17 +1304,17 @@ parse_command_line(int argc, const char *argv[])
}
}
- parse_end:
+parse_end:
/* check for file name to be processed */
if (argc <= opt_ind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
goto error;
}
- done:
+done:
return hand;
- error:
+error:
if (hand) {
free_handler(hand, argc);
hand = NULL;
@@ -4578,7 +1323,7 @@ parse_command_line(int argc, const char *argv[])
return hand;
}
-
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -4633,8 +1378,9 @@ main(int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- dump_header_format = &standardformat;
+ h5tools_dump_header_format = &h5tools_standardformat;
dump_function_table = &ddl_function_table;
+ dump_indent = 0;
/* Disable error reporting */
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
@@ -4662,28 +1408,28 @@ main(int argc, const char *argv[])
"to display selected objects");
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 {
if (xml_dtd_uri) {
warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri);
@@ -4714,7 +1460,6 @@ main(int argc, const char *argv[])
if(doxml) {
/* initialize XML */
-
/* reset prefix! */
HDstrcpy(prefix, "");
@@ -4737,7 +1482,6 @@ main(int argc, const char *argv[])
}
}
-
/* 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__);
@@ -4764,43 +1508,45 @@ 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);
+ begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin);
}
else {
- HDfprintf(stdout, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ HDfprintf(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
/* alternative first element, depending on schema or DTD. */
if (useschema) {
if (strcmp(xmlnsprefix,"") == 0) {
- HDfprintf(stdout, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n",
- xml_dtd_uri);
+ HDfprintf(rawoutstream, "<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;
+/* TO DO: make -url option work in this case (may need new option) */
+ char *ns;
char *indx;
ns = HDstrdup(xmlnsprefix);
indx = strrchr(ns,(int)':');
if (indx) *indx = '\0';
- HDfprintf(stdout, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File\" "
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
- "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File "
- "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns);
+ HDfprintf(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File "
+ "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns);
HDfree(ns);
}
}
else {
- HDfprintf(stdout, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri);
- HDfprintf(stdout, "<HDF5-File>\n");
+ HDfprintf(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri);
+ HDfprintf(rawoutstream, "<HDF5-File>\n");
}
}
if (!doxml) {
if (display_fi) {
+ HDfprintf(rawoutstream, "\n");
dump_fcontents(fid);
- end_obj(dump_header_format->fileend,dump_header_format->fileblockend);
+ end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend);
+ HDfprintf(rawoutstream, "\n");
goto done;
}
@@ -4808,24 +1554,25 @@ main(int argc, const char *argv[])
dump_fcpl(fid);
}
- if (display_all) {
- if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
- {
+ if(display_all) {
+ if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
error_msg("unable to open root group\n");
h5tools_setstatus(EXIT_FAILURE);
}
else {
-
+ if (!doxml)
+ dump_indent += COL;
dump_function_table->dump_group_function(gid, "/" );
-
+ if (!doxml)
+ dump_indent -= COL;
+ HDfprintf(rawoutstream, "\n");
}
- if (H5Gclose(gid) < 0) {
+ if(H5Gclose(gid) < 0) {
error_msg("unable to close root group\n");
h5tools_setstatus(EXIT_FAILURE);
}
-
}
else {
/* Note: this option is not supported for XML */
@@ -4835,19 +1582,23 @@ main(int argc, const char *argv[])
goto done;
} /* end if */
- for(i = 0; i < argc; i++)
- if(hand[i].func)
+ for(i = 0; i < argc; i++) {
+ if(hand[i].func) {
hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL);
+ }
+ }
+ HDfprintf(rawoutstream, "\n");
}
if (!doxml) {
- end_obj(dump_header_format->fileend, dump_header_format->fileblockend);
+ end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
+ HDfprintf(rawoutstream, "\n");
}
else {
- HDfprintf(stdout, "</%sHDF5-File>\n", xmlnsprefix);
+ HDfprintf(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix);
}
- done:
+done:
/* Free tables for objects */
table_list_free();
@@ -4855,13 +1606,13 @@ main(int argc, const char *argv[])
free_handler(hand, argc);
if(fid >=0)
- if (H5Fclose(fid) < 0)
- h5tools_setstatus(EXIT_FAILURE);
-
+ if (H5Fclose(fid) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
+
if(prefix)
- HDfree(prefix);
+ HDfree(prefix);
if(fname)
- HDfree(fname);
+ HDfree(fname);
/* To Do: clean up XML table */
@@ -4871,2445 +1622,6 @@ main(int argc, const char *argv[])
}
/*-------------------------------------------------------------------------
- * Function: print_enum
- *
- * Purpose: prints the enum data
- *
- * Return: void
- *
- * Programmer: Patrick Lu
- *
- * Modifications:
- *
- * NOTE: this function was taken from h5ls. should be moved into the toolslib
- *
- *-----------------------------------------------------------------------*/
-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);
- 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
- */
- if(H5Tget_size(type) <= sizeof(long long)) {
- dst_size = sizeof(long long);
-
- if(H5T_SGN_NONE == H5Tget_sign(type))
- native = H5T_NATIVE_ULLONG;
- else
- native = H5T_NATIVE_LLONG;
- } /* end if */
- else
- 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));
-
- for (i = 0; i < nmembs; i++) {
- name[i] = H5Tget_member_name(type, i);
- H5Tget_member_value(type, i, value + i * H5Tget_size(type));
- }
-
- /* Convert values to native datatype */
- if (native > 0)
- H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT);
-
- /*
- * Sort members by increasing value
- * ***not implemented yet***
- */
-
- /* Print members */
- for (i = 0; i < nmembs; i++) {
- indentation(indent + COL);
- nchars = HDfprintf(stdout, "\"%s\"", name[i]);
- HDfprintf(stdout, "%*s ", MAX(0, 16 - nchars), "");
-
- if (native < 0) {
- size_t j;
-
- 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)));
- }
-
- HDfprintf(stdout, ";\n");
- }
-
- /* Release resources */
- for (i = 0; i < nmembs; i++)
- free(name[i]);
-
- free(name);
- free(value);
- H5Tclose(super);
-
- if (0 == nmembs)
- HDfprintf(stdout, "\n%*s <empty>", indent + 4, "");
-}
-
-
-/*
- * create a string suitable for and XML NCNAME. Uses the
- * object reference to create the string.
- *
- * '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)
-{
- haddr_t objno; /* Object ID for object at path */
-
- if (outlen < 22) return 1;
-
- objno = ref_path_table_lookup(str);
- if (objno == HADDR_UNDEF) {
- if (HDstrlen(str) == 0) {
- objno = ref_path_table_lookup("/");
- if (objno == HADDR_UNDEF) {
- if (gen) {
- objno = ref_path_table_gen_fake(str);
- sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
- return 0;
- }
- else {
- return 1;
- }
- }
- }
- else {
- if (gen) {
- objno = ref_path_table_gen_fake(str);
- sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
- return 0;
- }
- else {
- return 1;
- }
- }
- }
-
- sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
-
- return(0);
-}
-
-static const char *quote = "&quot;";
-static const char *amp = "&amp;";
-static const char *lt = "&lt;";
-static const char *gt = "&gt;";
-static const char *apos = "&apos;";
-
-/*-------------------------------------------------------------------------
- * Function: xml_escape_the_name
- *
- * Purpose: Escape XML reserved chars in a name, so HDF5 strings
- * and paths can be correctly read back in XML element.
- *
- * Return: The revised string.
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-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;
-
- if (!str)
- 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);
- }
-
- cp++;
- }
-
- if (extra == 0)
- return HDstrdup(str);
-
- cp = str;
- rcp = ncp = (char *)HDmalloc(len + extra + 1);
-
- if (!ncp)
- return NULL; /* ?? */
-
- for (i = 0; i < len; i++) {
- 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, quote, strlen(quote));
- ncp += strlen(quote);
- cp++;
- }
- else if (*cp == '&') {
- strncpy(ncp, amp, strlen(amp));
- ncp += strlen(amp);
- cp++;
- }
- else {
- *ncp++ = *cp++;
- }
- }
-
- *ncp = '\0';
- return rcp;
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_escape_the_string
- *
- * Purpose: Escape XML reserved chars in a string, so HDF5 strings
- * and paths can be correctly read back in XML CDATA.
- *
- * Return: The revised string.
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-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;
-
- if (!str)
- return NULL;
-
- cp = str;
-
- if (slen < 0)
- len = strlen(str);
- else
- 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++;
- }
-
- cp = str;
- rcp = ncp = (char *)calloc((len + extra + 1), sizeof(char));
-
- if (ncp == 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++;
- }
- }
-
- *ncp = '\0';
- return rcp;
-}
-
-/**
-** XML print functions--these replace some functions in the
-** h5tools.c suite.
-**/
-
-/*-------------------------------------------------------------------------
- * Function: xml_print_datatype
- *
- * Purpose: Print description of a datatype in XML.
- * Note: this is called inside a <DataType> element.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-xml_print_datatype(hid_t type, unsigned in_group)
-{
- char *mname;
- hid_t mtype;
- unsigned nmembers;
- unsigned ndims;
- unsigned i;
- size_t size;
- hsize_t dims[H5DUMP_MAX_RANK];
- H5T_str_t str_pad;
- H5T_cset_t cset;
- hid_t super;
- H5T_order_t ord;
- H5T_sign_t sgn;
- size_t sz;
- size_t spos;
- size_t epos;
- size_t esize;
- size_t mpos;
- size_t msize;
- int nmembs;
- htri_t is_vlstr=FALSE;
-
- if(!in_group && H5Tcommitted(type) > 0) {
- H5O_info_t oinfo;
- obj_t *found_obj; /* Found object */
-
- /* detect a shared datatype, output only once */
- H5Oget_info(type, &oinfo);
- found_obj = search_obj(type_table, oinfo.addr);
-
- if(found_obj) {
- /* This should be defined somewhere else */
- /* These 2 cases are handled the same right now, but
- probably will have something different eventually */
- char * dtxid = (char *)malloc(100);
-
- xml_name_to_XID(found_obj->objname, dtxid, 100, 1);
- if (!found_obj->recorded) {
- /* 'anonymous' NDT. Use it's object num.
- as it's name. */
- HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n",
- xmlnsprefix, dtxid);
- }
- else {
- /* point to the NDT by name */
- char *t_objname = xml_escape_the_name(found_obj->objname);
-
- HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n",
- xmlnsprefix, dtxid, t_objname);
- free(t_objname);
- }
- free(dtxid);
- }
- else {
- HDfprintf(stdout, "<!-- h5dump error: unknown committed type. -->\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
- }
- else {
-
- switch (H5Tget_class(type)) {
- 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_ORDER_BE:
- HDfprintf(stdout, "BE");
- break;
- case H5T_ORDER_VAX:
- default:
- HDfprintf(stdout, "ERROR_UNKNOWN");
- }
- HDfprintf(stdout, "\" Sign=\"");
- switch (sgn) {
- case H5T_SGN_NONE:
- HDfprintf(stdout, "false");
- break;
- 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_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_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_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;
-
- 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);
- 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;
-
- 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;
-
- 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;
-
- case H5T_COMPOUND:
- /* recursively describe the components of a compound datatype */
-
- /* type of a dataset */
- nmembers = H5Tget_nmembers(type);
-
- indentation(indent);
- HDfprintf(stdout, "<%sCompoundType>\n",xmlnsprefix);
-
- /* List each member Field of the type */
- /* <hdf5:Field FieldName="name" > */
- /* <hdf5:DataType > */
- indent += COL;
- for (i = 0; i < nmembers; i++) {
- char *t_fname;
-
- mname = H5Tget_member_name(type, i);
- mtype = H5Tget_member_type(type, i);
- indentation(indent);
- 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);
- HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix);
- indent += COL;
- xml_print_datatype(mtype,0);
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix);
- indent -= COL;
-
- indentation(indent);
- HDfprintf(stdout, "</%sField>\n",xmlnsprefix);
- }
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sCompoundType>\n",xmlnsprefix);
- 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_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;
-
- 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);
-
- break;
-
- case H5T_ARRAY:
- /* Get array base type */
- super = H5Tget_super(type);
-
- /* 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);
- HDfprintf(stdout, "<%sArrayDimension DimSize=\"%u\"/>\n", xmlnsprefix, (int) dims[i]);
- }
- indent -= COL;
-
- 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 */
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_dump_datatype
- *
- * Purpose: Dump description of a datatype in XML.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-xml_dump_datatype(hid_t type)
-{
-
- indent += COL;
- indentation(indent);
-
- if(H5Tcommitted(type) > 0) {
- H5O_info_t oinfo;
- obj_t *found_obj; /* Found object */
-
- /* Datatype is a shared or named datatype */
- H5Oget_info(type, &oinfo);
- found_obj = search_obj(type_table, oinfo.addr);
-
- 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);
-
- xml_name_to_XID(found_obj->objname, dtxid, 100, 1);
- if (!found_obj->recorded) {
- /* anonymous stored datatype:
- following the dumper's current
- practice:
- use it's object ref as its name
- */
- HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n",
- xmlnsprefix, dtxid);
- }
- else {
- /* pointer to a named datatype already in XML */
- char *t_objname = xml_escape_the_name(found_obj->objname);
-
- HDfprintf(stdout, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n",
- xmlnsprefix, dtxid, t_objname);
- free(t_objname);
- }
- free(dtxid);
- }
- else {
- HDfprintf(stdout, "<!-- h5dump error: unknown committed type. -->\n");
- }
- indent -= COL;
- }
- else {
- HDfprintf(stdout, "<%sDataType>\n", xmlnsprefix);
- indent += COL;
- xml_print_datatype(type, 0);
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sDataType>\n", xmlnsprefix);
- indent -= COL;
- }
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_dump_dataspace
- *
- * Purpose: Dump description of a dataspace in XML.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-xml_dump_dataspace(hid_t space)
-{
- 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);
- HDfprintf(stdout, "<%sDataspace>\n", xmlnsprefix);
- indentation(indent + COL + COL);
-
- switch (space_type) {
- 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"> */
- 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]);
- }
- }
- 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 */
- HDfprintf(stdout, "<%sNullDataspace />\n",xmlnsprefix);
- break;
-#endif /* TMP */
-
- case H5S_NO_CLASS:
- default:
- HDfprintf(stdout, "<!-- unknown dataspace -->\n");
- }
-
- indentation(indent + COL);
- HDfprintf(stdout, "</%sDataspace>\n", xmlnsprefix);
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_dump_data
- *
- * Purpose: Dump description of data in XML.
- * Note that this calls the h5dump_xxx calls in
- * the h5tools library.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNUSED pindex)
-{
- 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;
- }
-
- if (nCols==0) {
- outputformat->line_ncols = 65535;
- outputformat->line_per_line = 1;
- }
- else
- outputformat->line_ncols = nCols;
- indent += COL;
-
- /*
- * the depth will tell us how far we need to indent extra. we use to just
- * use indent but with the merging of the tools lib we have to do
- * something different for the lib funtions... the normal indentation is 6
- * so when we don't need any extra indentation, depth will be 0.
- */
- depth = indent / stdindent + 1;
-
- /* Print all the values. */
- indentation(indent);
- HDfprintf(stdout, "<%sData>\n", xmlnsprefix);
- indentation(indent + COL);
- 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) {
- status = xml_print_strs(obj_id, DATASET_DATA);
- }
- else {
- status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, NULL, depth);
- }
- }
- else {
- /* Attribute data */
- type = H5Aget_type(obj_id);
-
- if (H5Tget_class(type) == H5T_REFERENCE) {
- /* references are done differently than
- the standard output:
- XML dumps a path to the object
- referenced.
- */
- status = xml_print_refs(obj_id, ATTRIBUTE_DATA);
- H5Tclose(type);
- }
- else if (H5Tget_class(type) == H5T_STRING) {
- status = xml_print_strs(obj_id, ATTRIBUTE_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_str(p_type) == TRUE)
- vl_data = TRUE;
- if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
- vl_data = TRUE;
-
- H5Tclose(type);
-
- space = H5Aget_space(obj_id);
-
- ndims = H5Sget_simple_extent_dims(space, size, NULL);
-
- for (i = 0; i < ndims; i++)
- nelmts *= size[i];
-
- buf = malloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type))));
- assert(buf);
-
- if (H5Aread(obj_id, p_type, buf) >= 0)
- 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);
- H5Tclose(p_type);
- H5Sclose(space);
- H5Tclose(type);
- }
- }
-
- if (status == FAIL) {
- indentation(indent + COL);
- HDfprintf(stdout, "Unable to print data.\n");
- status = 1;
- }
-
- indentation(indent + COL);
- HDfprintf(stdout, "</%sDataFromFile>\n",xmlnsprefix);
- indentation(indent);
- HDfprintf(stdout, "</%sData>\n", xmlnsprefix);
- indent -= COL;
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_dump_attr
- *
- * Purpose: Dump a description of an HDF5 attribute in XML.
- *
- * Return: herr_t
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-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;
- hid_t type;
- hid_t space;
- H5S_class_t space_type;
- char *t_aname = xml_escape_the_name(attr_name);
-
- indentation(indent);
- HDfprintf(stdout, "<%sAttribute Name=\"%s\">\n",xmlnsprefix, t_aname);
- free(t_aname);
-
- if ((attr_id = H5Aopen(attr, attr_name, H5P_DEFAULT)) >= 0) {
- type = H5Aget_type(attr_id);
- space = H5Aget_space(attr_id);
- space_type = H5Sget_simple_extent_type(space);
-
- dump_function_table->dump_dataspace_function(space);
- dump_function_table->dump_datatype_function(type);
-
- 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_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);
- 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);
- HDfprintf(stdout, "<%sData>\n",xmlnsprefix);
- indentation(indent);
- if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
- HDfprintf(stdout, "<!-- Note: Region references not supported -->\n");
- indentation(indent);
- HDfprintf(stdout, "<%sNoData />\n",xmlnsprefix);
- }
- else {
- HDfprintf(stdout, "<%sDataFromFile>\n",xmlnsprefix);
- xml_print_refs(attr_id, ATTRIBUTE_DATA);
- indentation(indent);
- HDfprintf(stdout, "</%sDataFromFile>\n",xmlnsprefix);
- }
- indentation(indent);
- HDfprintf(stdout, "</%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 {
- /* The case of an attribute never yet written ??
- * Or dataspace is H5S_NULL. */
- indentation(indent + COL);
- HDfprintf(stdout, "<%sData>\n",xmlnsprefix);
- indentation(indent + COL + COL);
- HDfprintf(stdout, "<%sNoData/>\n",xmlnsprefix);
- indentation(indent + COL);
- HDfprintf(stdout, "</%sData>\n",xmlnsprefix);
- }
-
- H5Tclose(type);
- H5Sclose(space);
- H5Aclose(attr_id);
- indentation(indent);
- HDfprintf(stdout, "</%sAttribute>\n", xmlnsprefix );
- return SUCCEED;
-
- }
- else {
- /* ?? failed */
- indentation(indent + COL);
- HDfprintf(stdout, "<!-- h5dump error: unable to open attribute. -->\n");
- indentation(indent);
- HDfprintf(stdout, "</%sAttribute>\n", xmlnsprefix );
- h5tools_setstatus(EXIT_FAILURE);
- return FAIL;
- }
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_dump_named_datatype
- *
- * Purpose: Dump a description of an HDF5 NDT in XML.
- *
- * Return: herr_t
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-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;
-
- tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
- HDstrcpy(tmp, prefix);
- HDstrcat(tmp, "/");
- HDstrcat(tmp, name);
-
- indentation(indent);
- dtxid = (char *)HDmalloc(100);
- parentxid = (char *)HDmalloc(100);
- t_tmp = xml_escape_the_name(tmp);
- t_prefix = xml_escape_the_name(prefix);
- t_name = xml_escape_the_name(name);
-
- xml_name_to_XID(tmp, dtxid, 100, 1);
- xml_name_to_XID(prefix, parentxid, 100, 1);
- if(HDstrncmp(name, "#", 1) == 0) {
- /* Special: this is an 'anonymous' NDT, deleted but
- still in use.
- We follow the dumper's undocumented practice, and
- use its object id as its name.
- Exactly the same as normal, but a separate case
- in the event we want to do something else in
- the future.
- */
- HDfprintf(stdout, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\">\n",
- xmlnsprefix,
- name, dtxid,
- parentxid, HDstrcmp(prefix,"") ? t_prefix : "/");
- }
- else {
- H5O_info_t oinfo; /* Object info */
-
- HDfprintf(stdout, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
- "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n",
- xmlnsprefix,
- t_name, dtxid,
- t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/"));
-
- /* Check uniqueness of named datatype */
- H5Oget_info(type, &oinfo);
- if(oinfo.rc > 1) {
- obj_t *found_obj; /* Found object */
-
- /* Group with more than one link to it... */
- found_obj = search_obj(type_table, oinfo.addr);
-
- if (found_obj == NULL) {
- indentation(indent);
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- else if(found_obj->displayed) {
- /* We have already printed this named datatype, print it as a
- * NamedDatatypePtr
- */
- char pointerxid[100];
- char *t_objname = xml_escape_the_name(found_obj->objname);
-
- indentation(indent + COL);
- xml_name_to_XID(found_obj->objname, pointerxid, sizeof(pointerxid), 1);
- HDfprintf(stdout, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", xmlnsprefix, pointerxid, t_objname);
- indentation(indent);
- HDfprintf(stdout, "</%sNamedDataType>\n", xmlnsprefix);
- HDfree(t_objname);
- goto done;
- }
- else
- found_obj->displayed = TRUE;
- }
- }
-
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix);
-
- indent += COL;
- xml_print_datatype(type,1);
-
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix);
-
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sNamedDataType>\n",xmlnsprefix);
-
- done:
- HDfree(dtxid);
- HDfree(parentxid);
- HDfree(t_tmp);
- HDfree(t_prefix);
- HDfree(t_name);
- HDfree(tmp);
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_dump_group
- *
- * Purpose: Dump a description of an HDF5 Group (and its members) in XML.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- * Pedro Vicente, October 9, 2007
- * added parameters to H5A(L)iterate to allow for other iteration orders
- *
- *-------------------------------------------------------------------------
- */
-static void
-xml_dump_group(hid_t gid, const char *name)
-{
- H5O_info_t oinfo;
- hid_t gcpl_id;
- hid_t dset, type;
- unsigned crt_order_flags;
- unsigned attr_crt_order_flags;
- 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) {
- 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) {
- 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) {
- error_msg("error in getting group creation properties\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
-
- if(H5Pclose(gcpl_id) < 0) {
- error_msg("error in closing group creation property list ID\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
-
- if(HDstrcmp(name, "/") == 0) {
- isRoot = 1;
- tmp = HDstrdup("/");
- }
- else {
- tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
- HDstrcpy(tmp, prefix);
- par = HDstrdup(tmp);
- cp = HDstrrchr(par, '/');
- if(cp) {
- if((cp == par) && HDstrlen(par) > 1)
- *(cp + 1) = '\0';
- else
- *cp = '\0';
- }
- }
-
- indentation(indent);
- indent += COL;
-
- H5Oget_info(gid, &oinfo);
-
- if(oinfo.rc > 1) {
- obj_t *found_obj; /* Found object */
-
- /* Group with more than one link to it... */
- found_obj = search_obj(group_table, oinfo.addr);
-
- if (found_obj == NULL) {
- indentation(indent);
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- }
- else {
- char *t_name = xml_escape_the_name(name);
- char *grpxid = (char *)malloc(100);
- char *parentxid = (char *)malloc(100);
-
- if(found_obj->displayed) {
- char *ptrstr = (char *)malloc(100);
-
- /* already seen: enter a groupptr */
- if(isRoot) {
- /* probably can't happen! */
- xml_name_to_XID("/", grpxid, 100, 1);
- HDfprintf(stdout, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n",
- xmlnsprefix, grpxid, "/");
- }
- 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);
- 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);
- free(t_objname);
- free(par_name);
-
- indentation(indent + COL);
- t_objname = xml_escape_the_name(found_obj->objname);/* point to the NDT by 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);
- HDfprintf(stdout, "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />\n",
- xmlnsprefix,
- ptrstr, t_objname, parentxid, par_name);
- free(t_objname);
- free(par_name);
- }
- free(ptrstr);
- }
- else {
-
- /* first time this group has been seen -- describe it */
- if(isRoot) {
- xml_name_to_XID("/", grpxid, 100, 1);
- 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);
- 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);
- free(par_name);
- }
- found_obj->displayed = TRUE;
-
- /* 1. do all the attributes of the group */
-
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, 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(gid, 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 */
- } /* end else */
-
- if(isRoot && unamedtype) {
- unsigned u;
-
- /* Very special case: dump unamed type in root group */
- for(u = 0; u < type_table->nobjs; u++) {
- if(!type_table->objs[u].recorded) {
- dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
- type = H5Dget_type(dset);
- sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
- dump_function_table->dump_named_datatype_function(type, type_name);
- H5Tclose(type);
- H5Dclose(dset);
- }
- }
- }
-
- /* iterate through all the links */
-
- 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);
-
-
- }
- free(t_name);
- free(grpxid);
- free(parentxid);
- }
- }
- else {
-
- /* only link -- must be first time! */
- char *t_name = xml_escape_the_name(name);
- char *grpxid = (char *)malloc(100);
- char *parentxid = (char *)malloc(100);
-
- if(isRoot) {
- xml_name_to_XID("/", grpxid, 100, 1);
- 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);
- 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);
- free(par_name);
- }
- free(t_name);
- free(grpxid);
- free(parentxid);
-
- /* 1. do all the attributes of the group */
-
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, 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(gid, 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 */
- } /* end else */
-
-
- if(isRoot && unamedtype) {
- unsigned u;
-
- /* Very special case: dump unamed type in root group */
- for(u = 0; u < type_table->nobjs; u++) {
- if(!type_table->objs[u].recorded) {
- dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
- type = H5Dget_type(dset);
- sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
- dump_function_table->dump_named_datatype_function(type, type_name);
- H5Tclose(type);
- H5Dclose(dset);
- }
- }
- }
-
- /* iterate through all the links */
-
- 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);
- }
-
- indent -= COL;
- indentation(indent);
- if(isRoot)
- HDfprintf(stdout, "</%sRootGroup>\n", xmlnsprefix);
- else
- HDfprintf(stdout, "</%sGroup>\n", xmlnsprefix);
- if(par)
- free(par);
- if(tmp)
- free(tmp);
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_print_refs
- *
- * Purpose: Print a path to the objects referenced by HDF5 Referneces.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-xml_print_refs(hid_t did, int source)
-{
- herr_t e;
- hid_t type;
- hid_t space;
- hssize_t ssiz;
- hsize_t i;
- size_t tsiz;
- hobj_ref_t *refbuf = NULL;
- char *buf = NULL;
-
- if (source == DATASET_DATA) {
- type = H5Dget_type(did);
- }
- else if (source == ATTRIBUTE_DATA) {
- type = H5Aget_type(did);
- }
- else {
- /* return an error */
- return FAIL;
- }
- if (H5Tget_class(type) != H5T_REFERENCE) {
- /* return an error */
- goto error;
- }
- if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
- /* region ref not supported yet... */
- /* return an error */
- goto error;
- }
- if (source == DATASET_DATA) {
- space = H5Dget_space(did);
- if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
- goto error;
- if ((tsiz = H5Tget_size(type)) == 0)
- goto error;
-
- buf = (char *) calloc((size_t)(ssiz * tsiz), sizeof(char));
- if (buf == NULL)
- goto error;
- e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- /* need to check result here */
- if (e < 0) {
- goto error;
- }
- }
- else if (source == ATTRIBUTE_DATA) {
- space = H5Aget_space(did);
- if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
- goto error;
- if ((tsiz = H5Tget_size(type)) == 0)
- goto error;
-
- buf = (char *) calloc((size_t)(ssiz * tsiz), sizeof(char));
- if (buf == NULL) {
- goto error;
- }
- e = H5Aread(did, H5T_STD_REF_OBJ, buf);
- /* need to check the result here */
- if (e < 0) {
- goto error;
- }
- }
-
- refbuf = (hobj_ref_t *) buf;
-
- for (i = 0; i < ssiz; i++) {
- const char *path = lookup_ref_path(*refbuf);
- indentation(indent + COL);
-
- if (!path) {
- HDfprintf(stdout, "\"%s\"\n", "NULL");
- }
- else {
- char *t_path = xml_escape_the_string(path, -1);
-
- HDfprintf(stdout, "\"%s\"\n", t_path);
- free(t_path);
- }
-
- refbuf++;
- }
-
- free(buf);
- H5Tclose(type);
- H5Sclose(space);
- return SUCCEED;
-
- error:
- if(buf)
- free(buf);
-
- H5E_BEGIN_TRY {
- H5Tclose(type);
- H5Sclose(space);
- } H5E_END_TRY;
- return FAIL;
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_print_strs
- *
- * Purpose: Print strings.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-xml_print_strs(hid_t did, int source)
-{
- 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);
- }
- else if (source == ATTRIBUTE_DATA) {
- type = H5Aget_type(did);
- }
- else {
- /* return an error */
- return FAIL;
- }
- if (H5Tget_class(type) != H5T_STRING) {
- /* return an error */
- goto error;
- }
- /* Check if we have VL data in the dataset's datatype */
- is_vlstr = H5Tis_variable_str(type);
-
- if (source == DATASET_DATA) {
- space = H5Dget_space(did);
- if((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
- goto error;
- if((tsiz = H5Tget_size(type)) == 0)
- goto error;
-
- buf = malloc((size_t)(ssiz * tsiz));
- if (buf == NULL)
- goto error;
-
- e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- if (e < 0) {
- goto error;
- }
- }
- else if (source == ATTRIBUTE_DATA) {
- space = H5Aget_space(did);
- if((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
- goto error;
- if((tsiz = H5Tget_size(type)) == 0)
- goto error;
-
- buf = malloc((size_t)(ssiz * tsiz));
- if (buf == NULL)
- goto error;
-
- e = H5Aread(did, type, buf);
- if (e < 0) {
- goto error;
- }
- }
-
- bp = (char*) buf;
- if (!is_vlstr)
- onestring = (char *) calloc(tsiz, sizeof(char));
-
- for (i = 0; i < ssiz; i++) {
- if (is_vlstr) {
- onestring = *(char **) bp;
- if (onestring)
- str_size = (size_t) HDstrlen(onestring);
- }
- else {
- HDstrncpy(onestring, bp, tsiz);
- str_size = tsiz;
- }
- indentation(indent + COL);
-
- if (!onestring) {
- HDfprintf(stdout, "NULL\n");
- }
- else {
- char *t_onestring = xml_escape_the_string(onestring, (int) str_size);
- if (t_onestring) {
- HDfprintf(stdout, "\"%s\"\n", t_onestring);
- free(t_onestring);
- }
- }
-
- bp += tsiz;
- }
-
- /* Reclaim any VL memory, if necessary */
- if (!is_vlstr)
- if (onestring)
- free(onestring);
- if (buf) {
- if (is_vlstr)
- H5Dvlen_reclaim(type, space, H5P_DEFAULT, buf);
- free(buf);
- }
- H5Tclose(type);
- H5Sclose(space);
- return SUCCEED;
-
- error:
- if(buf)
- free(buf);
-
- H5E_BEGIN_TRY {
- H5Tclose(type);
- H5Sclose(space);
- } H5E_END_TRY;
- return FAIL;
-}
-
-/*-------------------------------------------------------------------------
- * Function: check_filters
- *
- * Purpose: private function to check for the filters and
- * put tags in the XML.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-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;
-
- 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);
- if (filter == H5Z_FILTER_DEFLATE) {
- indentation(indent + COL);
- HDfprintf(stdout, "<%sDeflate Level=\"",xmlnsprefix);
- if (cd_nelmts < 1) {
- /* not sure what this means? */
- HDfprintf(stdout, "6");
- }
- else {
- HDfprintf(stdout, "%d",cd_values[0]);
- }
- HDfprintf(stdout, "\"/>\n");
- }
- else if (filter == H5Z_FILTER_FLETCHER32) {
- indentation(indent + COL);
- HDfprintf(stdout, "<%sFletcher32 />",xmlnsprefix);
- }
- else if (filter == H5Z_FILTER_SHUFFLE) {
- indentation(indent + COL);
- HDfprintf(stdout, "<%sShuffle />",xmlnsprefix);
- }
- else if (filter == H5Z_FILTER_SZIP) {
-
- indentation(indent + COL);
- HDfprintf(stdout, "<%sSZIP ",xmlnsprefix);
- if (cd_nelmts < 2) {
- /* no pixels ? */
- 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) {
- HDfprintf(stdout, "Mode =\"Hardware\" ");
- }
- 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) {
- HDfprintf(stdout, "Entropy");
- }
- else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) {
- HDfprintf(stdout, "NN");
- }
- HDfprintf(stdout, "\" ");
-
- HDfprintf(stdout, "ByteOrder=\"");
- if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) {
- HDfprintf(stdout, "LSB");
- }
- else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) {
- HDfprintf(stdout, "MSB");
- }
- HDfprintf(stdout, "\" ");
-
- if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) {
- HDfprintf(stdout, "Header=\"Raw\"");
- }
- HDfprintf(stdout, "/>\n");
- }
- else {
- /* unknown option */
- }
- }
-}
-
-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;
-
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sData>\n",xmlnsprefix);
- indent += COL;
-
- space = H5Tget_size(type);
- buf = malloc((size_t)space);
-
- H5Pget_fill_value(dcpl, type, buf);
-
- if (H5Tget_class(type) == H5T_REFERENCE) {
- const char * path = lookup_ref_path(*(hobj_ref_t *) buf);
-
- indentation(indent);
- HDfprintf(stdout, "<%sDataFromFile>\n",xmlnsprefix);
- if (!path) {
- HDfprintf(stdout, "\"%s\"\n", "NULL");
- }
- else {
- char *t_path = xml_escape_the_string(path, -1);
-
- HDfprintf(stdout, "\"%s\"\n", t_path);
- free(t_path);
- }
- indentation(indent);
- 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);
- 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);
- HDfprintf(stdout, "</%sData>\n",xmlnsprefix);
- indent -= COL;
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_dump_dataset
- *
- * Purpose: Dump a description of an HDF5 dataset in XML.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- * Pedro Vicente, October 9, 2007
- * added parameters to H5Aiterate2 to allow for other iteration orders
- *
- *-------------------------------------------------------------------------
- */
-static void
-xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
-{
- 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);
- HDstrcpy(tmp, prefix);
- HDstrcat(tmp, "/");
- HDstrcat(tmp, name);
- indentation(indent);
-
- t_name = xml_escape_the_name(name);
- t_tmp = xml_escape_the_name(tmp);
- t_prefix = xml_escape_the_name(prefix);
-
- xml_name_to_XID(tmp, rstr, 100, 1);
- xml_name_to_XID(prefix, pstr, 100, 1);
- 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);
- HDfree(t_prefix);
- HDfree(rstr);
- HDfree(pstr);
- HDfree(tmp);
-
- dcpl = H5Dget_create_plist(did);
- type = H5Dget_type(did);
- space = H5Dget_space(did);
-
- /* 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)) {
- maxdims = H5Sget_simple_extent_ndims(space);
- chsize = (hsize_t *)malloc(maxdims * sizeof(hsize_t));
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sStorageLayout>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sChunkedLayout ",xmlnsprefix);
- ndims = H5Pget_chunk(dcpl, maxdims, chsize);
- 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]);
- }
-
- indentation(indent);
- HDfprintf(stdout, "<%sRequiredFilter>\n",xmlnsprefix);
- indent += COL;
- check_filters(dcpl);
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sRequiredFilter>\n",xmlnsprefix);
-
- indent -= COL;
-
- indentation(indent);
- HDfprintf(stdout, "</%sChunkedLayout>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sStorageLayout>\n",xmlnsprefix);
- indent -= COL;
- free(chsize);
- }
- else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) {
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sStorageLayout>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sContiguousLayout/>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sStorageLayout>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- }
- else if (H5D_COMPACT == H5Pget_layout(dcpl)) {
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sStorageLayout>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sCompactLayout/>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sStorageLayout>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- }
- /* and check for external.... ?? */
-
- /* fill value */
-
- indent += COL;
- indentation(indent);
- HDfprintf(stdout, "<%sFillValueInfo ",xmlnsprefix);
- H5Pget_fill_time(dcpl, &ft);
- 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;
- }
- HDfprintf(stdout, "\" ");
- H5Pget_alloc_time(dcpl, &at);
- 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;
- }
- HDfprintf(stdout, "\"");
- HDfprintf(stdout, ">\n");
-
- indent += COL;
- indentation(indent);
- 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)) {
- indentation(indent + COL);
- HDfprintf(stdout, "<%sNoFill/>\n",xmlnsprefix);
- }
- else {
- xml_dump_fill_value(dcpl,type);
- }
-
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sFillValue>\n",xmlnsprefix);
-
- indent -= COL;
- indentation(indent);
- HDfprintf(stdout, "</%sFillValueInfo>\n",xmlnsprefix);
- indent -= COL;
-
- dump_function_table->dump_dataspace_function(space);
- dump_function_table->dump_datatype_function(type);
-
- 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) {
- 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) {
- error_msg("error getting attribute information\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
- } /* end else */
-
- indent -= COL;
- tempi = H5Dget_storage_size(did);
-
- 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_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);
- 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);
- HDfprintf(stdout, "<%sData>\n",xmlnsprefix);
- indentation(indent);
- if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
- HDfprintf(stdout, "<!-- Note: Region references not supported -->\n");
- indentation(indent);
- HDfprintf(stdout, "<%sNoData />\n",xmlnsprefix);
- }
- else {
- HDfprintf(stdout, "<%sDataFromFile>\n",xmlnsprefix);
- xml_print_refs(did, DATASET_DATA);
- indentation(indent);
- HDfprintf(stdout, "</%sDataFromFile>\n",xmlnsprefix);
- }
- indentation(indent);
- HDfprintf(stdout, "</%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 {
- /* no data written */
- indentation(indent + COL);
- HDfprintf(stdout, "<%sData>\n",xmlnsprefix);
- indentation(indent + COL + COL);
- HDfprintf(stdout, "<%sNoData/>\n",xmlnsprefix);
- indentation(indent + COL);
- HDfprintf(stdout, "</%sData>\n",xmlnsprefix);
- }
-
- H5Tclose(type);
- H5Sclose(space);
- H5Pclose(dcpl);
- indentation(indent);
- HDfprintf(stdout, "</%sDataset>\n", xmlnsprefix);
-}
-
-/*-------------------------------------------------------------------------
- * Function: xml_print_enum
- *
- * Purpose: Print the values of an HDF5 ENUM in XML.
- * Very similar to regular DDL output.
- *
- * Return: void
- *
- * Programmer: REMcG
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-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;
-
- nmembs = (unsigned)H5Tget_nmembers(type);
- super = H5Tget_super(type);
-
- indentation(indent);
- HDfprintf(stdout, "<%sDataType>\n",xmlnsprefix);
- xml_print_datatype(super,0);
- indentation(indent);
- HDfprintf(stdout, "</%sDataType>\n",xmlnsprefix);
-
- /*
- * 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
- */
- if (H5Tget_size(type) <= sizeof(long long)) {
- dst_size = sizeof(long long);
-
- if (H5T_SGN_NONE == H5Tget_sign(type)) {
- native = H5T_NATIVE_ULLONG;
- }
- else {
- native = H5T_NATIVE_LLONG;
- }
- }
- else {
- 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));
-
- for (i = 0; i < nmembs; i++) {
- name[i] = H5Tget_member_name(type, i);
- H5Tget_member_value(type, i, value + i * H5Tget_size(type));
- }
-
- /* Convert values to native datatype */
- if (native > 0)
- H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT);
-
- /* Sort members by increasing value */
- /*not implemented yet */
-
- /* Print members */
- indent += COL;
- for (i = 0; i < nmembs; i++) {
- char *t_name = xml_escape_the_name(name[i]);
-
- indentation(indent);
- HDfprintf(stdout, "<%sEnumElement>\n",xmlnsprefix);
- indentation(indent + COL);
- HDfprintf(stdout, "%s\n", t_name);
- free(t_name);
- indentation(indent);
- HDfprintf(stdout, "</%sEnumElement>\n",xmlnsprefix);
- indentation(indent);
- HDfprintf(stdout, "<%sEnumValue>\n",xmlnsprefix);
- indentation(indent + COL);
- if (native < 0) {
- 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)) {
- HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *)
- ((void *) (value + i * dst_size))));
- }
- else {
- HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d",
- *((long long *) ((void *) (value + i * dst_size))));
- }
- HDfprintf(stdout, "\n");
- indentation(indent);
- HDfprintf(stdout, "</%sEnumValue>\n",xmlnsprefix);
-
- }
- indent -= COL;
-
- /* Release resources */
- for (i = 0; i < nmembs; i++)
- free(name[i]);
-
- free(name);
- free(value);
- H5Tclose(super);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: h5_fileaccess
*
* Purpose: Returns a file access template which is the default template
@@ -7327,14 +1639,14 @@ xml_print_enum(hid_t type)
*
*-------------------------------------------------------------------------
*/
-static hid_t
+hid_t
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");
@@ -7363,24 +1675,24 @@ h5_fileaccess(void)
}
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)
+ 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);
HDmemset(memb_name, 0, sizeof memb_name);
HDmemset(memb_addr, 0, sizeof memb_addr);
- assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+ HDassert(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;
@@ -7424,7 +1736,7 @@ h5_fileaccess(void)
return fapl;
}
-
+
/*-------------------------------------------------------------------------
* Function: init_prefix
*
@@ -7443,7 +1755,7 @@ init_prefix(char **prfx, size_t prfx_len)
*prfx = (char *)HDcalloc(prfx_len, 1);
}
-
+
/*-------------------------------------------------------------------------
* Function: add_prefix
*
@@ -7453,7 +1765,7 @@ init_prefix(char **prfx, size_t prfx_len)
*
*-------------------------------------------------------------------------
*/
-static void
+void
add_prefix(char **prfx, size_t *prfx_len, const char *name)
{
size_t new_len = HDstrlen(*prfx) + HDstrlen(name) + 2;
@@ -7468,106 +1780,3 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name)
HDstrcat(HDstrcat(*prfx, "/"), name);
} /* end add_prefix */
-
-/*-------------------------------------------------------------------------
- * Function: dump_extlink
- *
- * made by: PVN
- *
- * Purpose: Dump an external link
- * Since external links are soft links, they are dumped on a trial error
- * basis, attempting to dump as a dataset, as a group and as a named datatype
- * Error messages are supressed
- *
- * Modifications:
- * Neil Fortner
- * 13 October 2008
- * Function basically rewritten. No longer directly opens the target file,
- * now initializes a new set of tables for the external file. No longer
- * dumps on a trial and error basis, but errors are still suppressed.
- *
- *-------------------------------------------------------------------------
- */
-
-static int dump_extlink(hid_t group, const char *linkname, const char *objname)
-{
- hid_t oid;
- H5O_info_t oi;
- table_t *old_group_table = group_table;
- table_t *old_dset_table = dset_table;
- table_t *old_type_table = type_table;
- hbool_t old_hit_elink;
- ssize_t idx;
-
-
- /* Open target object */
- if ((oid = H5Oopen(group, linkname, H5P_DEFAULT)) < 0)
- goto fail;
-
- /* Get object info */
- if (H5Oget_info(oid, &oi) < 0) {
- H5Oclose(oid);
- goto fail;
- }
-
- /* Check if we have visited this file already */
- if ((idx = table_list_visited(oi.fileno)) < 0) {
- /* We have not visited this file, build object tables */
- if ((idx = table_list_add(oid, oi.fileno)) < 0) {
- H5Oclose(oid);
- goto fail;
- }
- }
-
- /* Do not recurse through an external link into the original file (idx=0) */
- if (idx) {
- /* Update table pointers */
- group_table = table_list.tables[idx].group_table;
- dset_table = table_list.tables[idx].dset_table;
- type_table = table_list.tables[idx].type_table;
-
- /* We will now traverse the external link, set this global to indicate this */
- old_hit_elink = hit_elink;
- hit_elink = TRUE;
-
- /* add some indentation to distinguish that these objects are external */
- indent += 2*COL;
-
- /* Recurse into the external file */
- switch (oi.type) {
- case H5O_TYPE_GROUP:
- handle_groups(group, linkname, NULL, 0, objname);
- break;
- case H5O_TYPE_DATASET:
- handle_datasets(group, linkname, NULL, 0, objname);
- break;
- case H5O_TYPE_NAMED_DATATYPE:
- handle_datatypes(group, linkname, NULL, 0, objname);
- break;
- default:
- h5tools_setstatus(EXIT_FAILURE);
- }
-
- indent -= 2*COL;
-
- /* Reset table pointers */
- group_table = old_group_table;
- dset_table = old_dset_table;
- type_table = old_type_table;
-
- /* Reset hit_elink */
- hit_elink = old_hit_elink;
- } /* end if */
-
- 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 be77002..7d4f460 100644
--- a/tools/h5dump/h5dump.h
+++ b/tools/h5dump/h5dump.h
@@ -16,148 +16,97 @@
#define H5DUMP_H__
#include "hdf5.h"
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_utils.h"
+#include "h5tools_ref.h"
+#include "h5trav.h"
+#include "h5dump_defines.h"
-#define H5DUMP_MAX_RANK H5S_MAX_RANK
+/**
+ ** This is the global dispatch table for the dump functions.
+ **/
+/* the table of dump functions */
+typedef struct dump_functions_t {
+ void (*dump_group_function) (hid_t, const char *);
+ void (*dump_named_datatype_function) (hid_t, const char *);
+ void (*dump_dataset_function) (hid_t, const char *, struct subset_t *);
+ void (*dump_dataspace_function) (hid_t);
+ void (*dump_datatype_function) (hid_t);
+ herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *);
+ void (*dump_data_function) (hid_t, int, struct subset_t *, int);
+} dump_functions;
-#define ATTRIBUTE_DATA 0
-#define DATASET_DATA 1
-#define ENUM_DATA 2
-#define COL 3
+/* List of table structures. There is one table structure for each file */
+typedef struct h5dump_table_list_t {
+ size_t nalloc;
+ size_t nused;
+ struct {
+ unsigned long fileno; /* File number that these tables refer to */
+ hid_t oid; /* ID of an object in this file, held open so fileno is consistent */
+ table_t *group_table; /* Table of groups */
+ table_t *dset_table; /* Table of datasets */
+ table_t *type_table; /* Table of datatypes */
+ } *tables;
+} h5dump_table_list_t;
-/* Strings for output */
-#define ATTRIBUTE "ATTRIBUTE"
-#define BLOCK "BLOCK"
-#define SUPER_BLOCK "SUPER_BLOCK"
-#define COMPRESSION "COMPRESSION"
-#define CONCATENATOR "//"
-#define COMPLEX "COMPLEX"
-#define COUNT "COUNT"
-#define CSET "CSET"
-#define CTYPE "CTYPE"
-#define DATA "DATA"
-#define DATASPACE "DATASPACE"
-#define EXTERNAL "EXTERNAL"
-#define FILENO "FILENO"
-#define HARDLINK "HARDLINK"
-#define NLINK "NLINK"
-#define OBJID "OBJECTID"
-#define OBJNO "OBJNO"
-#define S_SCALAR "SCALAR"
-#define S_SIMPLE "SIMPLE"
-#define S_NULL "NULL"
-#define SOFTLINK "SOFTLINK"
-#define EXTLINK "EXTERNAL_LINK"
-#define UDLINK "USERDEFINED_LINK"
-#define START "START"
-#define STRIDE "STRIDE"
-#define STRSIZE "STRSIZE"
-#define STRPAD "STRPAD"
-#define SUBSET "SUBSET"
-#define FILTERS "FILTERS"
-#define DEFLATE "COMPRESSION DEFLATE"
-#define DEFLATE_LEVEL "LEVEL"
-#define SHUFFLE "PREPROCESSING SHUFFLE"
-#define FLETCHER32 "CHECKSUM FLETCHER32"
-#define SZIP "COMPRESSION SZIP"
-#define NBIT "COMPRESSION NBIT"
-#define SCALEOFFSET "COMPRESSION SCALEOFFSET"
-#define SCALEOFFSET_MINBIT "MIN BITS"
-#define STORAGE_LAYOUT "STORAGE_LAYOUT"
-#define CONTIGUOUS "CONTIGUOUS"
-#define COMPACT "COMPACT"
-#define CHUNKED "CHUNKED"
-#define EXTERNAL_FILE "EXTERNAL_FILE"
-#define FILLVALUE "FILLVALUE"
-#define FILE_CONTENTS "FILE_CONTENTS"
-#define PACKED_BITS "PACKED_BITS"
-#define PACKED_OFFSET "OFFSET"
-#define PACKED_LENGTH "LENGTH"
+h5dump_table_list_t table_list = {0, 0, NULL};
+table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
+int dump_indent = 0; /*how far in to indent the line */
-#define BEGIN "{"
-#define END "}"
+int unamedtype = 0; /* shared datatype with no name */
+hbool_t hit_elink = FALSE; /* whether we have traversed an external link */
+size_t prefix_len = 1024;
+char *prefix = NULL;
+const char *fp_format = NULL;
-typedef struct h5dump_header_t {
- const char *name;
- const char *filebegin;
- const char *fileend;
- const char *bootblockbegin;
- const char *bootblockend;
- const char *groupbegin;
- const char *groupend;
- const char *datasetbegin;
- const char *datasetend;
- const char *attributebegin;
- const char *attributeend;
- const char *datatypebegin;
- const char *datatypeend;
- const char *dataspacebegin;
- const char *dataspaceend;
- const char *databegin;
- const char *dataend;
- const char *softlinkbegin;
- const char *softlinkend;
- const char *extlinkbegin;
- const char *extlinkend;
- const char *udlinkbegin;
- const char *udlinkend;
- const char *subsettingbegin;
- const char *subsettingend;
- const char *startbegin;
- const char *startend;
- const char *stridebegin;
- const char *strideend;
- const char *countbegin;
- const char *countend;
- const char *blockbegin;
- const char *blockend;
+/* things to display or which are set via command line parameters */
+int display_all = TRUE;
+int display_oid = FALSE;
+int display_data = TRUE;
+int display_attr_data = TRUE;
+int display_char = FALSE; /*print 1-byte numbers as ASCII */
+int usingdasho = FALSE;
+int display_bb = FALSE; /*superblock */
+int display_dcpl = FALSE; /*dcpl */
+int display_fi = FALSE; /*file index */
+int display_ai = TRUE; /*array index */
+int display_escape = FALSE; /*escape non printable characters */
+int display_region = FALSE; /*print region reference data */
+int enable_error_stack= FALSE; /* re-enable error stack */
+int disable_compact_subset= FALSE; /* disable compact form of subset notation */
+int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/
- const char *fileblockbegin;
- const char *fileblockend;
- const char *bootblockblockbegin;
- const char *bootblockblockend;
- const char *groupblockbegin;
- const char *groupblockend;
- const char *datasetblockbegin;
- const char *datasetblockend;
- const char *attributeblockbegin;
- const char *attributeblockend;
- const char *datatypeblockbegin;
- const char *datatypeblockend;
- const char *dataspaceblockbegin;
- const char *dataspaceblockend;
- const char *datablockbegin;
- const char *datablockend;
- const char *softlinkblockbegin;
- const char *softlinkblockend;
- const char *extlinkblockbegin;
- const char *extlinkblockend;
- const char *udlinkblockbegin;
- const char *udlinkblockend;
- const char *strblockbegin;
- const char *strblockend;
- const char *enumblockbegin;
- const char *enumblockend;
- const char *structblockbegin;
- const char *structblockend;
- const char *vlenblockbegin;
- const char *vlenblockend;
- const char *subsettingblockbegin;
- const char *subsettingblockend;
- const char *startblockbegin;
- const char *startblockend;
- const char *strideblockbegin;
- const char *strideblockend;
- const char *countblockbegin;
- const char *countblockend;
- const char *blockblockbegin;
- const char *blockblockend;
+/* sort parameters */
+H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */
+H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */
- const char *dataspacedescriptionbegin;
- const char *dataspacedescriptionend;
- const char *dataspacedimbegin;
- const char *dataspacedimend;
+#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 */
+unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
-} h5dump_header_t;
+/* packed bits display parameters */
+int packed_offset[PACKED_BITS_MAX];
+int packed_length[PACKED_BITS_MAX];
+/*
+ * The global table is set to either ddl_function_table or
+ * xml_function_table in the initialization.
+ */
+const dump_functions *dump_function_table;
+
+#ifdef __cplusplus
+"C" {
+#endif
+
+void add_prefix(char **prfx, size_t *prfx_len, const char *name);
+hid_t h5_fileaccess(void);
+ssize_t table_list_add(hid_t oid, unsigned long file_no);
+ssize_t table_list_visited(unsigned long file_no);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* !H5DUMP_H__ */
diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c
new file mode 100644
index 0000000..89000c1
--- /dev/null
+++ b/tools/h5dump/h5dump_ddl.c
@@ -0,0 +1,1917 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_dump.h"
+#include "h5tools_utils.h"
+#include "h5tools_ref.h"
+#include "h5trav.h"
+#include "h5dump_extern.h"
+#include "h5dump_ddl.h"
+
+/*-------------------------------------------------------------------------
+ * Function: dump_datatype
+ *
+ * Purpose: Dump the datatype. Datatype can be HDF5 predefined
+ * atomic datatype or committed/transient datatype.
+ *
+ * Return: void
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_datatype(hid_t type)
+{
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ h5dump_type_table = type_table;
+ h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type);
+ h5dump_type_table = NULL;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_dataspace
+ *
+ * Purpose: Dump the dataspace. Dataspace can be named dataspace,
+ * array, or others.
+ *
+ * Return: void
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_dataspace(hid_t space)
+{
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: dump_attr_cb
+ *
+ * Purpose: attribute function callback called by H5Aiterate2, displays the attribute
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications: Pedro Vicente, October 4, 2007
+ * Added H5A_info_t parameter to conform with H5Aiterate2
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, void UNUSED *_op_data)
+{
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tool_format_t string_dataformat;
+
+ hid_t attr_id;
+ herr_t ret = SUCCEED;
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
+ oid_output = display_oid;
+ data_output = display_data;
+ attr_data_output = display_attr_data;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ h5dump_type_table = type_table;
+ h5tools_dump_attribute(rawoutstream, outputformat, &ctx, oid, attr_name, attr_id, display_ai, display_char);
+ h5dump_type_table = NULL;
+
+ if(attr_id < 0) {
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+
+ return ret;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_all_cb
+ *
+ * Purpose: function callback called by H5Literate,
+ * displays everything in the specified object
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications:
+ * RMcG, November 2000
+ * Added XML support. Also, optionally checks the op_data argument
+ *
+ * PVN, May 2008
+ * Dump external links
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED *op_data)
+{
+ hid_t obj;
+ herr_t ret = SUCCEED;
+ char *obj_path = NULL; /* Full path of object */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ /* Build the object's path name */
+ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ if(!obj_path) {
+ ret = FAIL;
+ goto done;
+ }
+
+ HDstrcpy(obj_path, prefix);
+ HDstrcat(obj_path, "/");
+ HDstrcat(obj_path, name);
+
+ if(linfo->type == H5L_TYPE_HARD) {
+ H5O_info_t oinfo;
+
+ /* Stat the object */
+ if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) {
+ error_msg("unable to get object information for \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ goto done;
+ } /* end if */
+
+ switch(oinfo.type) {
+ case H5O_TYPE_GROUP:
+ if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump group \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ char *old_prefix; /* Pointer to previous prefix */
+
+ /* Keep copy of prefix before iterating into group */
+ old_prefix = HDstrdup(prefix);
+ HDassert(old_prefix);
+
+ /* Append group name to prefix */
+ add_prefix(&prefix, &prefix_len, name);
+
+ /* Iterate into group */
+ dump_function_table->dump_group_function(obj, name);
+
+ /* Restore old prefix name */
+ HDstrcpy(prefix, old_prefix);
+ HDfree(old_prefix);
+
+ /* Close group */
+ H5Gclose(obj);
+ }
+ break;
+
+ case H5O_TYPE_DATASET:
+ if((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) {
+ if(oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
+
+ found_obj = search_obj(dset_table, oinfo.addr);
+
+ if(found_obj == NULL) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ H5Dclose(obj);
+ goto done;
+ }
+ else if(found_obj->displayed) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ H5Dclose(obj);
+ goto done;
+ }
+ else {
+ found_obj->displayed = TRUE;
+ }
+ } /* end if */
+
+ dump_function_table->dump_dataset_function(obj, name, NULL);
+ H5Dclose(obj);
+ }
+ else {
+ error_msg("unable to dump dataset \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump datatype \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ dump_function_table->dump_named_datatype_function(obj, name);
+ H5Tclose(obj);
+ }
+ break;
+
+ default:
+ error_msg("unknown object \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ } /* end if */
+ else {
+ char *targbuf;
+
+ switch(linfo->type) {
+ case H5L_TYPE_SOFT:
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
+ HDassert(targbuf);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->softlinkbegin, name,
+ h5tools_dump_header_format->softlinkblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+
+ if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ error_msg("unable to get link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ /* print the value of a soft link */
+ /* Standard DDL: no modification */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->softlinkblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend);
+ if(HDstrlen(h5tools_dump_header_format->softlinkend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->softlinkend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(targbuf);
+ break;
+
+ case H5L_TYPE_EXTERNAL:
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
+ HDassert(targbuf);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->extlinkbegin, name,
+ h5tools_dump_header_format->extlinkblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ indentation(dump_indent);
+ error_msg("unable to get external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ } /* end if */
+ else {
+ const char *filename;
+ const char *targname;
+
+ if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
+ indentation(dump_indent);
+ error_msg("unable to unpack external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ } /* end if */
+ else {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ /* dump the external link */
+ dump_extlink(group, name, targname);
+ ctx.indent_level--;
+ } /* end else */
+ } /* end else */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->extlinkblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend);
+ if(HDstrlen(h5tools_dump_header_format->extlinkend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->extlinkend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(targbuf);
+ break;
+
+ default:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->udlinkbegin, name,
+ h5tools_dump_header_format->udlinkblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "LINKCLASS %d", linfo->type);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->udlinkblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkblockend);
+ if(HDstrlen(h5tools_dump_header_format->udlinkend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->udlinkend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ break;
+ } /* end switch */
+ } /* end else */
+
+done:
+
+ h5tools_str_close(&buffer);
+
+ if(obj_path)
+ HDfree(obj_path);
+ return ret;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_named_datatype
+ *
+ * Purpose: Dump named datatype
+ *
+ * Return: void
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications:
+ * Pedro Vicente, March 27, 2006
+ * added display of attributes
+ * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for
+ * other iteration orders
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_named_datatype(hid_t tid, const char *name)
+{
+ H5O_info_t oinfo;
+ unsigned attr_crt_order_flags;
+ hid_t tcpl_id = -1; /* datatype creation property list ID */
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tool_format_t string_dataformat;
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ 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) {
+ error_msg("error in getting creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ if(H5Pclose(tcpl_id) < 0) {
+ error_msg("error in closing creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datatypebegin, name,
+ h5tools_dump_header_format->datatypeblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ H5Oget_info(tid, &oinfo);
+
+ /* Must check for uniqueness of all objects if we've traversed an elink,
+ * otherwise only check if the reference count > 1.
+ */
+ if(oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
+
+ found_obj = search_obj(type_table, oinfo.addr);
+
+ if (found_obj == NULL) {
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ else if (found_obj->displayed) {
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ goto done;
+ }
+ else
+ found_obj->displayed = TRUE;
+ } /* end if */
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_print_datatype(rawoutstream, &buffer, outputformat, &ctx, tid, FALSE);
+
+ if(H5Tget_class(tid) != H5T_COMPOUND) {
+ h5tools_str_append(&buffer, ";");
+ }
+
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ /* print attributes */
+ dump_indent += COL;
+
+ /* 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(H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end if */
+ else {
+ if(H5Aiterate2(tid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end else */
+
+ dump_indent -= COL;
+
+done:
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend);
+ if(HDstrlen(h5tools_dump_header_format->datatypeend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->datatypeend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_group
+ *
+ * Purpose: Dump everything within the specified group
+ *
+ * Return: void
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications:
+ *
+ * Call to dump_all_cb -- add parameter to select everything.
+ *
+ * Pedro Vicente, October 1, 2007
+ * handle several iteration orders for attributes and groups
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_group(hid_t gid, const char *name)
+{
+ H5O_info_t oinfo;
+ hid_t dset;
+ hid_t type;
+ hid_t gcpl_id;
+ unsigned crt_order_flags;
+ unsigned attr_crt_order_flags;
+ char type_name[1024];
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ 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) {
+ 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) {
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ if(H5Pclose(gcpl_id) < 0) {
+ error_msg("error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->groupbegin, name,
+ h5tools_dump_header_format->groupblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ if(!HDstrcmp(name, "/") && unamedtype) {
+ unsigned u; /* Local index variable */
+
+ /* dump unamed type in root group */
+ for(u = 0; u < type_table->nobjs; u++)
+ if(!type_table->objs[u].recorded) {
+ dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
+ type = H5Dget_type(dset);
+ sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+ dump_function_table->dump_named_datatype_function(type, type_name);
+ H5Tclose(type);
+ H5Dclose(dset);
+ }
+ } /* end if */
+
+ if(display_oid) {
+ h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid);
+ }
+
+ h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid);
+
+ H5Oget_info(gid, &oinfo);
+
+ /* Must check for uniqueness of all objects if we've traversed an elink,
+ * otherwise only check if the reference count > 1.
+ */
+ if(oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
+
+ found_obj = search_obj(group_table, oinfo.addr);
+
+ if (found_obj == NULL) {
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ else if (found_obj->displayed) {
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ found_obj->displayed = TRUE;
+ /* 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(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end if */
+ else {
+ if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end else */
+
+ /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
+ in the group, then, sort by creation order, otherwise by name */
+ 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);
+ }
+ }
+ 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 */
+
+ if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
+ if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end if */
+ else {
+ if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end else */
+
+ /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
+ in the group, then, sort by creation order, otherwise by name */
+ 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);
+ }
+
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->groupblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupblockend);
+ if(HDstrlen(h5tools_dump_header_format->groupend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->groupend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_dataset
+ *
+ * Purpose: Dump the specified data set
+ *
+ * Return: void
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications:
+ * Pedro Vicente, 2004, added dataset creation property list display
+ * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for
+ * other iteration orders
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_dataset(hid_t did, const char *name, struct subset_t *sset)
+{
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tool_format_t string_dataformat;
+ hid_t type, space;
+ unsigned attr_crt_order_flags;
+ hid_t dcpl_id; /* dataset creation property list ID */
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ 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) {
+ error_msg("error in getting creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_dump_comment(rawoutstream, outputformat, &ctx, did);
+
+ dump_indent += COL;
+ ctx.indent_level++;
+
+ type = H5Dget_type(did);
+ h5dump_type_table = type_table;
+ h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type);
+ h5dump_type_table = NULL;
+
+ space = H5Dget_space(did);
+ h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space);
+ H5Sclose(space);
+
+ if(display_oid) {
+ h5tools_dump_oid(rawoutstream, outputformat, &ctx, did);
+ }
+
+ if(display_dcpl) {
+ h5dump_type_table = type_table;
+ h5tools_dump_dcpl(rawoutstream, outputformat, &ctx, dcpl_id, type, did);
+ h5dump_type_table = NULL;
+ }
+ H5Pclose(dcpl_id);
+
+ if(display_data) {
+ int data_loop = 1;
+ int i;
+ if(display_packed_bits)
+ data_loop = packed_bits_num;
+ for(i=0; i<data_loop; i++) {
+ if(display_packed_bits) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ packed_data_mask = packed_mask[i];
+ packed_data_offset = packed_offset[i];
+ packed_data_length = packed_length[i];
+ h5tools_print_packed_bits(&buffer, type);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ switch(H5Tget_class(type)) {
+ case H5T_TIME:
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "DATA{ not yet implemented.}");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+ break;
+
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_COMPOUND:
+ case H5T_REFERENCE:
+ case H5T_ENUM:
+ case H5T_VLEN:
+ case H5T_ARRAY:
+ {
+ h5tools_dump_data(rawoutstream, outputformat, &ctx, did, TRUE, sset, display_ai, display_char);
+ }
+ break;
+
+ default:
+ break;
+ } /* end switch */
+ } /* for(i=0;i<data_loop;i++) */
+ }
+ H5Tclose(type);
+
+ 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(H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, 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_attr_cb, NULL) < 0) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end else */
+ }
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_data
+ *
+ * Purpose: Dump attribute or dataset data
+ *
+ * Return: void
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications: pvn, print the matrix indices
+ * Albert Cheng, 2004/11/18
+ * Add --string printing for attributes too.
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
+{
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tool_format_t string_dataformat;
+ int print_dataset = FALSE;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ if(obj_data == DATASET_DATA)
+ print_dataset = TRUE;
+ h5tools_dump_data(rawoutstream, outputformat, &ctx, obj_id, print_dataset, sset, display_index, display_char);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: dump_fcpl
+ *
+ * Purpose: prints file creation property list information
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_fcpl(hid_t fid)
+{
+ hid_t fcpl; /* file creation property list ID */
+ hsize_t userblock; /* userblock size retrieved from FCPL */
+ size_t off_size; /* size of offsets in the file */
+ size_t len_size; /* size of lengths in the file */
+ unsigned super; /* superblock version # */
+ unsigned freelist; /* free list version # */
+ unsigned stab; /* symbol table entry version # */
+ unsigned shhdr; /* shared object header version # */
+#ifdef SHOW_FILE_DRIVER
+ hid_t fapl; /* file access property list ID */
+ hid_t fdriver; /* file driver */
+ char dname[32]; /* buffer to store driver name */
+#endif
+ 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 */
+
+ fcpl=H5Fget_create_plist(fid);
+ H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr);
+ H5Pget_userblock(fcpl,&userblock);
+ H5Pget_sizes(fcpl,&off_size,&len_size);
+ H5Pget_sym_k(fcpl,&sym_ik,&sym_lk);
+ H5Pget_istore_k(fcpl,&istore_ik);
+ H5Pclose(fcpl);
+#ifdef SHOW_FILE_DRIVER
+ fapl=h5_fileaccess();
+ fdriver=H5Pget_driver(fapl);
+ H5Pclose(fapl);
+#endif
+
+ /*-------------------------------------------------------------------------
+ * SUPER_BLOCK
+ *-------------------------------------------------------------------------
+ */
+ HDfprintf(rawoutstream, "\n%s %s\n",SUPER_BLOCK, BEGIN);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %u\n","SUPERBLOCK_VERSION", super);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %u\n","FREELIST_VERSION", freelist);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %u\n","SYMBOLTABLE_VERSION", stab);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %u\n","OBJECTHEADER_VERSION", shhdr);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream,"%s %Hd\n","OFFSET_SIZE", (long long)off_size);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream,"%s %Hd\n","LENGTH_SIZE", (long long)len_size);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %u\n","BTREE_RANK", sym_ik);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %d\n","BTREE_LEAF", sym_lk);
+
+#ifdef SHOW_FILE_DRIVER
+ if (H5FD_CORE==fdriver)
+ HDstrcpy(dname,"H5FD_CORE");
+#ifdef H5_HAVE_DIRECT
+ else if (H5FD_DIRECT==fdriver)
+ HDstrcpy(dname,"H5FD_DIRECT");
+#endif
+ else if (H5FD_FAMILY==fdriver)
+ HDstrcpy(dname,"H5FD_FAMILY");
+ else if (H5FD_LOG==fdriver)
+ HDstrcpy(dname,"H5FD_LOG");
+ else if (H5FD_MPIO==fdriver)
+ HDstrcpy(dname,"H5FD_MPIO");
+ else if (H5FD_MULTI==fdriver)
+ HDstrcpy(dname,"H5FD_MULTI");
+ else if (H5FD_SEC2==fdriver)
+ HDstrcpy(dname,"H5FD_SEC2");
+ else if (H5FD_STDIO==fdriver)
+ HDstrcpy(dname,"H5FD_STDIO");
+#ifdef H5_HAVE_STREAM
+ else if (H5FD_STREAM==fdriver)
+ HDstrcpy(dname,"H5FD_STREAM");
+#endif
+ else
+ HDstrcpy(dname,"Unknown driver");
+
+ /* Take out this because the driver used can be different from the
+ * standard output. */
+ /*indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %s\n","FILE_DRIVER", dname);*/
+#endif
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s %u\n","ISTORE_K", istore_ik);
+
+ /*-------------------------------------------------------------------------
+ * USER_BLOCK
+ *-------------------------------------------------------------------------
+ */
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "USER_BLOCK %s\n",BEGIN);
+ indentation(dump_indent + COL + COL);
+ HDfprintf(rawoutstream,"%s %Hu\n","USERBLOCK_SIZE", userblock);
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s\n",END);
+
+ HDfprintf(rawoutstream, "%s",END);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_fcontents
+ *
+ * Purpose: prints all objects
+ *
+ * Return: void
+ *
+ * Programmer: pvn
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+dump_fcontents(hid_t fid)
+{
+ HDfprintf(rawoutstream, "%s %s\n",FILE_CONTENTS, BEGIN);
+
+ /* special case of unamed types in root group */
+ if (unamedtype) {
+ unsigned u;
+
+ for (u = 0; u < type_table->nobjs; u++) {
+ if (!type_table->objs[u].recorded)
+ HDfprintf(rawoutstream, " %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno);
+ }
+ }
+
+ /* print objects in the files */
+ h5trav_print(fid);
+
+ HDfprintf(rawoutstream, " %s\n",END);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: handle_attributes
+ *
+ * Purpose: Handle the attributes from the command.
+ *
+ * Return: void
+ *
+ * Programmer: Bill Wendling
+ * Tuesday, 9. January 2001
+ *
+ * Modifications:
+ *
+ * PVN, May 2008
+ * add an extra parameter PE, to allow printing/not printing of error messages
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+handle_attributes(hid_t fid, const char *attr, void UNUSED * data, int UNUSED pe, const char UNUSED *display_name)
+{
+ hid_t oid = -1;
+ hid_t attr_id = -1;
+ char *obj_name;
+ const char *attr_name;
+ int j;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ j = (int)HDstrlen(attr) - 1;
+ obj_name = (char *)HDmalloc((size_t)j + 2);
+ if(obj_name == NULL)
+ goto error;
+
+ /* find the last / */
+ while(j >= 0) {
+ if (attr[j] == '/')
+ break;
+ j--;
+ }
+
+ /* object name */
+ if(j == -1)
+ HDstrcpy(obj_name, "/");
+ else {
+ HDstrncpy(obj_name, attr, (size_t)j + 1);
+ obj_name[j + 1] = '\0';
+ } /* end else */
+
+ dump_indent += COL;
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ attr_name = attr + j + 1;
+
+ /* Open the object with the attribute */
+ if((oid = H5Oopen(fid, obj_name, H5P_DEFAULT)) < 0) {
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->attributebegin, attr,
+ h5tools_dump_header_format->attributeblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ error_msg("unable to open object \"%s\"\n", obj_name);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->attributeblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeblockend);
+ if(HDstrlen(h5tools_dump_header_format->attributeend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->attributeend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+
+ goto error;
+ } /* end if */
+
+ attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
+ oid_output = display_oid;
+ data_output = display_data;
+ attr_data_output = display_attr_data;
+
+ h5dump_type_table = type_table;
+ h5tools_dump_attribute(rawoutstream, outputformat, &ctx, oid, attr, attr_id, display_ai, display_char);
+ h5dump_type_table = NULL;
+
+ if(attr_id < 0) {
+ goto error;
+ }
+
+ /* Close object */
+ if(H5Oclose(oid) < 0) {
+ goto error;
+ } /* end if */
+
+ HDfree(obj_name);
+ dump_indent -= COL;
+ return;
+
+error:
+ h5tools_setstatus(EXIT_FAILURE);
+ if(obj_name)
+ HDfree(obj_name);
+
+ H5E_BEGIN_TRY {
+ H5Oclose(oid);
+ H5Aclose(attr_id);
+ } H5E_END_TRY;
+ dump_indent -= COL;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: handle_datasets
+ *
+ * Purpose: Handle the datasets from the command.
+ *
+ * Return: void
+ *
+ * Programmer: Bill Wendling
+ * Tuesday, 9. January 2001
+ *
+ * Modifications:
+ * Pedro Vicente, Tuesday, January 15, 2008
+ * check for block overlap\
+ *
+ * Pedro Vicente, May 8, 2008
+ * added a flag PE that prints/not prints error messages
+ * added for cases of external links not found, to avoid printing of
+ * objects not found, since external links are dumped on a trial error basis
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name)
+{
+ H5O_info_t oinfo;
+ hid_t dsetid;
+ 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) {
+ HDfprintf(rawoutstream, "\n");
+ begin_obj(h5tools_dump_header_format->datasetbegin, real_name, h5tools_dump_header_format->datasetblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(COL);
+ error_msg("unable to open dataset \"%s\"\n", real_name);
+ end_obj(h5tools_dump_header_format->datasetend, h5tools_dump_header_format->datasetblockend);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ return;
+ } /* end if */
+
+ if(sset) {
+ unsigned int i;
+ hid_t sid = H5Dget_space(dsetid);
+ int ndims = H5Sget_simple_extent_ndims(sid);
+
+ H5Sclose(sid);
+ if(ndims < 0) {
+ error_msg("H5Sget_simple_extent_ndims failed\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ return;
+ }
+
+ if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) {
+ /* they didn't specify a ``stride'' or ``block''. default to 1 in all
+ * dimensions */
+ if(!sset->start.data) {
+ /* default to (0, 0, ...) for the start coord */
+ sset->start.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
+ sset->start.len = ndims;
+ }
+
+ if(!sset->stride.data) {
+ sset->stride.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
+ sset->stride.len = ndims;
+ for (i = 0; i < ndims; i++)
+ sset->stride.data[i] = 1;
+ }
+
+ if(!sset->count.data) {
+ sset->count.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
+ sset->count.len = ndims;
+ for (i = 0; i < ndims; i++)
+ sset->count.data[i] = 1;
+ }
+
+ if(!sset->block.data) {
+ sset->block.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
+ sset->block.len = ndims;
+ for (i = 0; i < ndims; i++)
+ sset->block.data[i] = 1;
+ }
+ }
+
+ /*-------------------------------------------------------------------------
+ * check for dimension overflow
+ *-------------------------------------------------------------------------
+ */
+ if(sset->start.len > ndims) {
+ error_msg("number of start dims (%u) exceed dataset dims (%u)\n", sset->start.len, ndims);
+ h5tools_setstatus(EXIT_FAILURE);
+ return;
+ }
+ if(sset->stride.len > ndims) {
+ error_msg("number of stride dims (%u) exceed dataset dims (%u)\n", sset->stride.len, ndims);
+ h5tools_setstatus(EXIT_FAILURE);
+ return;
+ }
+ if(sset->count.len > ndims) {
+ error_msg("number of count dims (%u) exceed dataset dims (%u)\n", sset->count.len, ndims);
+ h5tools_setstatus(EXIT_FAILURE);
+ return;
+ }
+ if(sset->block.len > ndims) {
+ error_msg("number of block dims (%u) exceed dataset dims (%u)\n", sset->block.len, ndims);
+ h5tools_setstatus(EXIT_FAILURE);
+ return;
+ }
+
+ /*-------------------------------------------------------------------------
+ * check for block overlap
+ *-------------------------------------------------------------------------
+ */
+ for(i = 0; i < ndims; i++) {
+ if(sset->count.data[i] > 1) {
+ if(sset->stride.data[i] < sset->block.data[i]) {
+ error_msg("wrong subset selection; blocks overlap\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ return;
+ } /* end if */
+ } /* end if */
+ } /* end for */
+ } /* end if */
+
+
+ H5Oget_info(dsetid, &oinfo);
+ if(oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
+
+ found_obj = search_obj(dset_table, oinfo.addr);
+
+ if(found_obj) {
+ if (found_obj->displayed) {
+ HDfprintf(rawoutstream, "\n");
+ indentation(dump_indent);
+ begin_obj(h5tools_dump_header_format->datasetbegin, real_name, h5tools_dump_header_format->datasetblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(dump_indent + COL);
+ HDfprintf(rawoutstream, "%s \"%s\"\n", HARDLINK, found_obj->objname);
+ indentation(dump_indent);
+ end_obj(h5tools_dump_header_format->datasetend, h5tools_dump_header_format->datasetblockend);
+ }
+ else {
+ found_obj->displayed = TRUE;
+ dump_indent += COL;
+ dump_dataset(dsetid, real_name, sset);
+ dump_indent -= COL;
+ }
+ }
+ else
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ else {
+ dump_indent += COL;
+ dump_dataset(dsetid, real_name, sset);
+ dump_indent -= COL;
+ }
+
+ if(H5Dclose(dsetid) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: handle_groups
+ *
+ * Purpose: Handle the groups from the command.
+ *
+ * Return: void
+ *
+ * Programmer: Bill Wendling
+ * Tuesday, 9. January 2001
+ *
+ * Modifications: Pedro Vicente, September 26, 2007
+ * handle creation order
+ *
+ * Pedro Vicente, May 8, 2008
+ * added a flag PE that prints/not prints error messages
+ * added for cases of external links not found, to avoid printing of
+ * objects not found, since external links are dumped on a trial error basis
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+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) {
+ HDfprintf(rawoutstream, "\n");
+ begin_obj(h5tools_dump_header_format->groupbegin, real_name, h5tools_dump_header_format->groupblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(COL);
+ error_msg("unable to open group \"%s\"\n", real_name);
+ end_obj(h5tools_dump_header_format->groupend, h5tools_dump_header_format->groupblockend);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ }
+ else {
+ size_t new_len = HDstrlen(group) + 1;
+
+ if(prefix_len <= new_len) {
+ prefix_len = new_len;
+ prefix = (char *)HDrealloc(prefix, prefix_len);
+ } /* end if */
+
+ HDstrcpy(prefix, group);
+
+ dump_indent += COL;
+ dump_group(gid, real_name);
+ dump_indent -= COL;
+
+ if(H5Gclose(gid) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end else */
+} /* end handle_groups() */
+
+/*-------------------------------------------------------------------------
+ * Function: handle_links
+ *
+ * Purpose: Handle soft or UD links from the command.
+ *
+ * Return: void
+ *
+ * Programmer: Bill Wendling
+ * Tuesday, 9. January 2001
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, const char UNUSED *display_name)
+{
+ H5L_info_t linfo;
+
+ 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) {
+ error_msg("\"%s\" is a hard link\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ else {
+ char *buf = (char *)HDmalloc(linfo.u.val_size);
+ HDfprintf(rawoutstream, "\n");
+
+ switch(linfo.type) {
+ case H5L_TYPE_SOFT: /* Soft link */
+ begin_obj(h5tools_dump_header_format->softlinkbegin, links, h5tools_dump_header_format->softlinkblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(COL);
+ if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0)
+ HDfprintf(rawoutstream, "LINKTARGET \"%s\"\n", buf);
+ else {
+ error_msg("h5dump error: unable to get link value for \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ end_obj(h5tools_dump_header_format->softlinkend, h5tools_dump_header_format->softlinkblockend);
+ break;
+
+ case H5L_TYPE_EXTERNAL:
+ begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(COL);
+ begin_obj(h5tools_dump_header_format->extlinkbegin, links, h5tools_dump_header_format->extlinkblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ 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(rawoutstream, "LINKCLASS %d\n", linfo.type);
+ indentation(COL);
+ HDfprintf(rawoutstream, "TARGETFILE \"%s\"\n", elink_file);
+ indentation(COL);
+ HDfprintf(rawoutstream, "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);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ end_obj(h5tools_dump_header_format->extlinkend, h5tools_dump_header_format->extlinkblockend);
+ break;
+
+ default:
+ begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(COL);
+ begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(COL);
+ HDfprintf(rawoutstream, "LINKCLASS %d\n", linfo.type);
+ end_obj(h5tools_dump_header_format->udlinkend, h5tools_dump_header_format->udlinkblockend);
+ break;
+ } /* end switch */
+ HDfree(buf);
+ } /* end else */
+}
+
+/*-------------------------------------------------------------------------
+ * Function: handle_datatypes
+ *
+ * Purpose: Handle the datatypes from the command.
+ *
+ * Return: void
+ *
+ * Programmer: Bill Wendling
+ * Tuesday, 9. January 2001
+ *
+ * Modifications:
+ *
+ * Pedro Vicente, May 8, 2008
+ * added a flag PE that prints/not prints error messages
+ * added for cases of external links not found, to avoid printing of
+ * objects not found, since external links are dumped on a trial error basis
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const char *display_name)
+{
+ hid_t type_id;
+ const char *real_name = display_name ? display_name : type;
+
+ if((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) {
+ /* check if type is unamed datatype */
+ unsigned idx = 0;
+
+ while(idx < type_table->nobjs ) {
+ char name[128];
+
+ if(!type_table->objs[idx].recorded) {
+ /* unamed datatype */
+ sprintf(name, "/#"H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno);
+
+ if(!HDstrcmp(name, real_name))
+ break;
+ } /* end if */
+
+ idx++;
+ } /* end while */
+
+ if(idx == type_table->nobjs) {
+ if (pe) {
+ /* unknown type */
+ HDfprintf(rawoutstream, "\n");
+ begin_obj(h5tools_dump_header_format->datatypebegin, real_name, h5tools_dump_header_format->datatypeblockbegin);
+ HDfprintf(rawoutstream, "\n");
+ indentation(COL);
+ error_msg("unable to open datatype \"%s\"\n", real_name);
+ end_obj(h5tools_dump_header_format->datatypeend, h5tools_dump_header_format->datatypeblockend);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ }
+ else {
+ hid_t dsetid = H5Dopen2(fid, type_table->objs[idx].objname, H5P_DEFAULT);
+ type_id = H5Dget_type(dsetid);
+
+ dump_indent += COL;
+ dump_named_datatype(type_id, real_name);
+ dump_indent -= COL;
+
+ H5Tclose(type_id);
+ H5Dclose(dsetid);
+ }
+ }
+ else {
+ dump_indent += COL;
+ dump_named_datatype(type_id, real_name);
+ dump_indent -= COL;
+
+ if(H5Tclose(type_id) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: dump_extlink
+ *
+ * made by: PVN
+ *
+ * Purpose: Dump an external link
+ * Since external links are soft links, they are dumped on a trial error
+ * basis, attempting to dump as a dataset, as a group and as a named datatype
+ * Error messages are supressed
+ *
+ * Modifications:
+ * Neil Fortner
+ * 13 October 2008
+ * Function basically rewritten. No longer directly opens the target file,
+ * now initializes a new set of tables for the external file. No longer
+ * dumps on a trial and error basis, but errors are still suppressed.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+
+static int dump_extlink(hid_t group, const char *linkname, const char *objname)
+{
+ hid_t oid;
+ H5O_info_t oi;
+ table_t *old_group_table = group_table;
+ table_t *old_dset_table = dset_table;
+ table_t *old_type_table = type_table;
+ hbool_t old_hit_elink;
+ ssize_t idx;
+
+ /* Open target object */
+ if ((oid = H5Oopen(group, linkname, H5P_DEFAULT)) < 0)
+ goto fail;
+
+ /* Get object info */
+ if (H5Oget_info(oid, &oi) < 0) {
+ H5Oclose(oid);
+ goto fail;
+ }
+
+ /* Check if we have visited this file already */
+ if ((idx = table_list_visited(oi.fileno)) < 0) {
+ /* We have not visited this file, build object tables */
+ if ((idx = table_list_add(oid, oi.fileno)) < 0) {
+ H5Oclose(oid);
+ goto fail;
+ }
+ }
+
+ /* Do not recurse through an external link into the original file (idx=0) */
+ if (idx) {
+ /* Update table pointers */
+ group_table = table_list.tables[idx].group_table;
+ dset_table = table_list.tables[idx].dset_table;
+ type_table = table_list.tables[idx].type_table;
+
+ /* We will now traverse the external link, set this global to indicate this */
+ old_hit_elink = hit_elink;
+ hit_elink = TRUE;
+
+ /* add some indentation to distinguish that these objects are external */
+ dump_indent += COL;
+
+ /* Recurse into the external file */
+ switch (oi.type) {
+ case H5O_TYPE_GROUP:
+ handle_groups(group, linkname, NULL, 0, objname);
+ break;
+ case H5O_TYPE_DATASET:
+ handle_datasets(group, linkname, NULL, 0, objname);
+ break;
+ case H5O_TYPE_NAMED_DATATYPE:
+ handle_datatypes(group, linkname, NULL, 0, objname);
+ break;
+ default:
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ dump_indent -= COL;
+
+ /* Reset table pointers */
+ group_table = old_group_table;
+ dset_table = old_dset_table;
+ type_table = old_type_table;
+
+ /* Reset hit_elink */
+ hit_elink = old_hit_elink;
+ } /* end if */
+
+ if (H5Idec_ref(oid) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
+
+ return SUCCEED;
+
+fail:
+ return FAIL;
+}
+
diff --git a/tools/h5dump/h5dump_ddl.h b/tools/h5dump/h5dump_ddl.h
new file mode 100644
index 0000000..c769194
--- /dev/null
+++ b/tools/h5dump/h5dump_ddl.h
@@ -0,0 +1,50 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#ifndef H5DUMP_DDL_H__
+#define H5DUMP_DDL_H__
+
+/* callback function used by H5Literate() */
+static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void *op_data);
+static int dump_extlink(hid_t group, const char *linkname, const char *objname);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The dump functions of the dump_function_table */
+/* standard format: no change */
+void dump_group(hid_t, const char *);
+void dump_named_datatype(hid_t, const char *);
+void dump_dataset(hid_t, const char *, struct subset_t *);
+void dump_dataspace(hid_t space);
+void dump_datatype(hid_t type);
+void dump_data(hid_t, int, struct subset_t *, int);
+void dump_fcpl(hid_t fid);
+void dump_fcontents(hid_t fid);
+
+/* callback function used by H5Aiterate2() */
+herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data);
+
+void handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name);
+void handle_attributes(hid_t fid, const char *attr, void UNUSED * data, int UNUSED pe, const char UNUSED *display_name);
+void handle_groups(hid_t fid, const char *group, void UNUSED *data, int pe, const char *display_name);
+void handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, const char UNUSED *display_name);
+void handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const char *display_name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !H5DUMP_DDL_H__ */
diff --git a/tools/h5dump/h5dump_defines.h b/tools/h5dump/h5dump_defines.h
new file mode 100644
index 0000000..4af5360
--- /dev/null
+++ b/tools/h5dump/h5dump_defines.h
@@ -0,0 +1,54 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#ifndef H5DUMP_DEFINES_H__
+#define H5DUMP_DEFINES_H__
+
+#define H5DUMP_MAX_RANK H5S_MAX_RANK
+
+#define ATTRIBUTE_DATA 0
+#define DATASET_DATA 1
+#define ENUM_DATA 2
+#define COL 3
+
+/* Macros for displaying objects */
+#define begin_obj(obj,name,begin) \
+ do { \
+ if (name) \
+ HDfprintf(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \
+ else \
+ HDfprintf(rawoutstream, "%s %s", (obj), (begin)); \
+ } while(0);
+
+#define end_obj(obj,end) \
+ do { \
+ if(HDstrlen(end)) { \
+ HDfprintf(rawoutstream, "%s", end); \
+ if(HDstrlen(obj)) \
+ HDfprintf(rawoutstream, " "); \
+ } \
+ if(HDstrlen(obj)) \
+ HDfprintf(rawoutstream, "%s", obj); \
+ } while(0);
+
+
+/* 3 private values: can't be set, but can be read.
+ Note: these are defined in H5Zprivate, they are
+ duplicated here.
+ */
+#define H5_SZIP_LSB_OPTION_MASK 8
+#define H5_SZIP_MSB_OPTION_MASK 16
+#define H5_SZIP_RAW_OPTION_MASK 128
+
+#endif /* !H5DUMP_DEFINES_H__ */
diff --git a/tools/h5dump/h5dump_extern.h b/tools/h5dump/h5dump_extern.h
new file mode 100644
index 0000000..5a0f2bd
--- /dev/null
+++ b/tools/h5dump/h5dump_extern.h
@@ -0,0 +1,112 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#ifndef H5DUMP_EXTERN_H__
+#define H5DUMP_EXTERN_H__
+
+#include "hdf5.h"
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_utils.h"
+#include "h5tools_ref.h"
+#include "h5trav.h"
+#include "h5dump_defines.h"
+
+/**
+ ** This is the global dispatch table for the dump functions.
+ **/
+/* the table of dump functions */
+typedef struct dump_functions_t {
+ void (*dump_group_function) (hid_t, const char *);
+ void (*dump_named_datatype_function) (hid_t, const char *);
+ void (*dump_dataset_function) (hid_t, const char *, struct subset_t *);
+ void (*dump_dataspace_function) (hid_t);
+ void (*dump_datatype_function) (hid_t);
+ herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *);
+ void (*dump_data_function) (hid_t, int, struct subset_t *, int);
+} dump_functions;
+
+/* List of table structures. There is one table structure for each file */
+typedef struct h5dump_table_list_t {
+ size_t nalloc;
+ size_t nused;
+ struct {
+ unsigned long fileno; /* File number that these tables refer to */
+ hid_t oid; /* ID of an object in this file, held open so fileno is consistent */
+ table_t *group_table; /* Table of groups */
+ table_t *dset_table; /* Table of datasets */
+ table_t *type_table; /* Table of datatypes */
+ } *tables;
+} h5dump_table_list_t;
+
+extern h5dump_table_list_t table_list;
+extern table_t *group_table, *dset_table, *type_table;
+extern int dump_indent; /*how far in to indent the line */
+
+extern int unamedtype; /* shared datatype with no name */
+extern hbool_t hit_elink; /* whether we have traversed an external link */
+extern size_t prefix_len;
+extern char *prefix;
+extern const char *fp_format;
+
+/* things to display or which are set via command line parameters */
+extern int display_all;
+extern int display_oid;
+extern int display_data;
+extern int display_attr_data;
+extern int display_char; /*print 1-byte numbers as ASCII */
+extern int usingdasho;
+extern int display_bb; /*superblock */
+extern int display_dcpl; /*dcpl */
+extern int display_fi; /*file index */
+extern int display_ai; /*array index */
+extern int display_escape; /*escape non printable characters */
+extern int display_region; /*print region reference data */
+extern int enable_error_stack; /* re-enable error stack */
+extern int disable_compact_subset; /* disable compact form of subset notation */
+extern int display_packed_bits; /*print 1-8 byte numbers as packed bits*/
+
+/* sort parameters */
+extern H5_index_t sort_by; /*sort_by [creation_order | name] */
+extern H5_iter_order_t sort_order; /*sort_order [ascending | descending] */
+
+#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 */
+extern unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
+
+/* packed bits display parameters */
+extern int packed_offset[PACKED_BITS_MAX];
+extern int packed_length[PACKED_BITS_MAX];
+
+/*
+ * The global table is set to either ddl_function_table or
+ * xml_function_table in the initialization.
+ */
+extern const dump_functions *dump_function_table;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void add_prefix(char **prfx, size_t *prfx_len, const char *name);
+hid_t h5_fileaccess(void);
+ssize_t table_list_add(hid_t oid, unsigned long file_no);
+ssize_t table_list_visited(unsigned long file_no);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !H5DUMP_EXTERN_H__ */
diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c
new file mode 100644
index 0000000..e6f8043
--- /dev/null
+++ b/tools/h5dump/h5dump_xml.c
@@ -0,0 +1,4456 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_dump.h"
+#include "h5tools_utils.h"
+#include "h5tools_ref.h"
+#include "h5trav.h"
+#include "h5dump_extern.h"
+#include "h5dump_xml.h"
+
+const char *xmlnsprefix="hdf5:";
+
+/* internal functions */
+static int xml_name_to_XID(const char *, char *, int , int );
+
+/* internal functions used by XML option */
+static void xml_print_datatype(hid_t, unsigned);
+static void xml_print_enum(hid_t);
+static int xml_print_refs(hid_t, int);
+static int xml_print_strs(hid_t, int);
+static char *xml_escape_the_string(const char *, int);
+static char *xml_escape_the_name(const char *);
+
+/*-------------------------------------------------------------------------
+ * Function: dump_all_cb
+ *
+ * Purpose: function callback called by H5Literate,
+ * displays everything in the specified object
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Ruey-Hsia Li
+ *
+ * Modifications:
+ * RMcG, November 2000
+ * Added XML support. Also, optionally checks the op_data argument
+ *
+ * PVN, May 2008
+ * Dump external links
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED *op_data)
+{
+ hid_t obj;
+ herr_t ret = SUCCEED;
+ char *obj_path = NULL; /* Full path of object */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ /* Build the object's path name */
+ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ if(!obj_path) {
+ ret = FAIL;
+ goto done;
+ }
+
+ HDstrcpy(obj_path, prefix);
+ HDstrcat(obj_path, "/");
+ HDstrcat(obj_path, name);
+
+ if(linfo->type == H5L_TYPE_HARD) {
+ H5O_info_t oinfo;
+
+ /* Stat the object */
+ if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) {
+ error_msg("unable to get object information for \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ goto done;
+ } /* end if */
+
+ switch(oinfo.type) {
+ case H5O_TYPE_GROUP:
+ if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump group \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ char *old_prefix; /* Pointer to previous prefix */
+
+ /* Keep copy of prefix before iterating into group */
+ old_prefix = HDstrdup(prefix);
+ HDassert(old_prefix);
+
+ /* Append group name to prefix */
+ add_prefix(&prefix, &prefix_len, name);
+
+ /* Iterate into group */
+ dump_function_table->dump_group_function(obj, name);
+
+ /* Restore old prefix name */
+ HDstrcpy(prefix, old_prefix);
+ HDfree(old_prefix);
+
+ /* Close group */
+ H5Gclose(obj);
+ }
+ break;
+
+ case H5O_TYPE_DATASET:
+ if((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) {
+ if(oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
+
+ found_obj = search_obj(dset_table, oinfo.addr);
+
+ if(found_obj == NULL) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if(HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ H5Dclose(obj);
+ goto done;
+ }
+ else if(found_obj->displayed) {
+ /* the XML version */
+ char *t_obj_path = xml_escape_the_name(obj_path);
+ 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];
+
+ /* 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);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" "
+ "H5Path=\"%s\" Parents=\"%s\" "
+ "H5ParentPaths=\"%s\">",
+ xmlnsprefix,
+ t_name, /* Dataset Name */
+ dsetxid, get_next_xid(), /* OBJ-XID */
+ t_obj_path, /* H5Path */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ xml_name_to_XID(found_obj->objname, pointerxid, sizeof(pointerxid), 1);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>",
+ xmlnsprefix,
+ pointerxid,t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataset>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(t_name);
+ HDfree(t_obj_path);
+ HDfree(t_prefix);
+ HDfree(t_objname);
+
+ H5Dclose(obj);
+ goto done;
+ }
+ else {
+ found_obj->displayed = TRUE;
+ }
+ } /* end if */
+
+ dump_function_table->dump_dataset_function(obj, name, NULL);
+ H5Dclose(obj);
+ }
+ else {
+ error_msg("unable to dump dataset \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump datatype \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ dump_function_table->dump_named_datatype_function(obj, name);
+ H5Tclose(obj);
+ }
+ break;
+
+ default:
+ error_msg("unknown object \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ } /* end if */
+ else {
+ char *targbuf;
+
+ switch(linfo->type) {
+ case H5L_TYPE_SOFT:
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
+ HDassert(targbuf);
+
+ if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ error_msg("unable to get link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ /* print the value of a soft link */
+ /* XML */
+ char linkxid[100];
+ char parentxid[100];
+ char targetxid[100];
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
+ char *t_name = xml_escape_the_name(name);
+ char *t_targbuf = xml_escape_the_name(targbuf);
+ char *t_obj_path = xml_escape_the_name(obj_path);
+ char *t_link_path;
+ int res;
+
+ t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
+ if(targbuf[0] == '/')
+ HDstrcpy(t_link_path, targbuf);
+ else {
+ HDstrcpy(t_link_path, prefix);
+ HDstrcat(HDstrcat(t_link_path, "/"), targbuf);
+ } /* end else */
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
+ xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
+
+ /* Try to create an OBJ-XID for the object pointed to */
+ res = xml_name_to_XID(t_link_path, targetxid, sizeof(targetxid), 0);
+ if (res == 0) {
+ /* target obj found */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "TargetPath=\"%s\" TargetObj=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix,
+ t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ t_targbuf, /* TargetPath */
+ targetxid, /* TargetObj */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ /* dangling link -- omit from xml attributes */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "TargetPath=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix,
+ t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ t_targbuf, /* TargetPath */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(t_targbuf);
+ HDfree(t_obj_path);
+ HDfree(t_link_path);
+ }
+
+ HDfree(targbuf);
+ break;
+
+ case H5L_TYPE_EXTERNAL:
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
+ HDassert(targbuf);
+
+ if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ error_msg("unable to get external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ } /* end if */
+ else {
+ const char *filename;
+ const char *targname;
+
+ if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
+ error_msg("unable to unpack external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ } /* end if */
+ else {
+ char linkxid[100];
+ char parentxid[100];
+ char *t_name = xml_escape_the_name(name);
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
+ char *t_obj_path = xml_escape_the_name(obj_path);
+ char *t_filename = xml_escape_the_name(filename);
+ char *t_targname = xml_escape_the_name(targname);
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
+ xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sExternalLink LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "TargetFilename=\"%s\" "
+ "TargetPath=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix,
+ t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ filename, /* TargetFilename */
+ targname, /* TargetPath*/
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(t_filename);
+ HDfree(t_targname);
+ HDfree(t_obj_path);
+ } /* end else */
+ } /* end else */
+ HDfree(targbuf);
+ break;
+
+ default:
+ {
+ char linkxid[100];
+ char parentxid[100];
+ char *t_name = xml_escape_the_name(name);
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
+ char *t_obj_path = xml_escape_the_name(obj_path);
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
+ xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sUserDefined LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "LinkClass=\"%d\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix,
+ t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ linfo->type, /* LinkClass */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(t_obj_path);
+ }
+ break;
+ } /* end switch */
+ } /* end else */
+
+done:
+
+ h5tools_str_close(&buffer);
+
+ if(obj_path)
+ HDfree(obj_path);
+ return ret;
+}
+
+/*
+ * create a string suitable for and XML NCNAME. Uses the
+ * object reference to create the string.
+ *
+ * '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)
+{
+ haddr_t objno; /* Object ID for object at path */
+
+ if (outlen < 22) return 1;
+
+ objno = ref_path_table_lookup(str);
+ if (objno == HADDR_UNDEF) {
+ if (HDstrlen(str) == 0) {
+ objno = ref_path_table_lookup("/");
+ if (objno == HADDR_UNDEF) {
+ if (gen) {
+ objno = ref_path_table_gen_fake(str);
+ sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ return 0;
+ }
+ else {
+ return 1;
+ }
+ }
+ }
+ else {
+ if (gen) {
+ objno = ref_path_table_gen_fake(str);
+ sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ return 0;
+ }
+ else {
+ return 1;
+ }
+ }
+ }
+
+ sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+
+ return(0);
+}
+
+static const char *quote = "&quot;";
+static const char *amp = "&amp;";
+static const char *lt = "&lt;";
+static const char *gt = "&gt;";
+static const char *apos = "&apos;";
+
+/*-------------------------------------------------------------------------
+ * Function: xml_escape_the_name
+ *
+ * Purpose: Escape XML reserved chars in a name, so HDF5 strings
+ * and paths can be correctly read back in XML element.
+ *
+ * Return: The revised string.
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+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;
+
+ if (!str)
+ return NULL;
+
+ cp = str;
+ len = HDstrlen(str);
+ extra = 0;
+
+ for (i = 0; i < len; i++) {
+ if (*cp == '\"') {
+ extra += (HDstrlen(quote) - 1);
+ }
+ else if (*cp == '\'') {
+ extra += (HDstrlen(apos) - 1);
+ }
+ else if (*cp == '<') {
+ extra += (HDstrlen(lt) - 1);
+ }
+ else if (*cp == '>') {
+ extra += (HDstrlen(gt) - 1);
+ }
+ else if (*cp == '&') {
+ extra += (HDstrlen(amp) - 1);
+ }
+
+ cp++;
+ }
+
+ if (extra == 0)
+ return HDstrdup(str);
+
+ cp = str;
+ rcp = ncp = (char *)HDmalloc(len + extra + 1);
+
+ if (!ncp)
+ return NULL; /* ?? */
+
+ for (i = 0; i < len; i++) {
+ if (*cp == '\'') {
+ HDstrncpy(ncp, apos, HDstrlen(apos));
+ ncp += HDstrlen(apos);
+ cp++;
+ }
+ else if (*cp == '<') {
+ HDstrncpy(ncp, lt, HDstrlen(lt));
+ ncp += HDstrlen(lt);
+ cp++;
+ }
+ else if (*cp == '>') {
+ HDstrncpy(ncp, gt, HDstrlen(gt));
+ ncp += HDstrlen(gt);
+ cp++;
+ }
+ else if (*cp == '\"') {
+ HDstrncpy(ncp, quote, HDstrlen(quote));
+ ncp += HDstrlen(quote);
+ cp++;
+ }
+ else if (*cp == '&') {
+ HDstrncpy(ncp, amp, HDstrlen(amp));
+ ncp += HDstrlen(amp);
+ cp++;
+ }
+ else {
+ *ncp++ = *cp++;
+ }
+ }
+
+ *ncp = '\0';
+ return rcp;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_escape_the_string
+ *
+ * Purpose: Escape XML reserved chars in a string, so HDF5 strings
+ * and paths can be correctly read back in XML CDATA.
+ *
+ * Return: The revised string.
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+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;
+
+ if (!str)
+ return NULL;
+
+ cp = str;
+
+ if (slen < 0)
+ len = HDstrlen(str);
+ else
+ len = slen;
+
+ extra = 0;
+
+ for (i = 0; i < len; i++) {
+ if (*cp == '\\') {
+ extra++;
+ }
+ else if (*cp == '\"') {
+ extra++;
+ }
+ else if (*cp == '\'') {
+ extra += (HDstrlen(apos) - 1);
+ }
+ else if (*cp == '<') {
+ extra += (HDstrlen(lt) - 1);
+ }
+ else if (*cp == '>') {
+ extra += (HDstrlen(gt) - 1);
+ }
+ else if (*cp == '&') {
+ extra += (HDstrlen(amp) - 1);
+ }
+ cp++;
+ }
+
+ cp = str;
+ rcp = ncp = (char *) HDcalloc((len + extra + 1), sizeof(char));
+
+ if (ncp == NULL)
+ return NULL; /* ?? */
+
+ for (i = 0; i < len; i++) {
+ if (*cp == '\\') {
+ *ncp++ = '\\';
+ *ncp++ = *cp++;
+ }
+ else if (*cp == '\"') {
+ *ncp++ = '\\';
+ *ncp++ = *cp++;
+ }
+ else if (*cp == '\'') {
+ HDstrncpy(ncp, apos, HDstrlen(apos));
+ ncp += HDstrlen(apos);
+ cp++;
+ }
+ else if (*cp == '<') {
+ HDstrncpy(ncp, lt, HDstrlen(lt));
+ ncp += HDstrlen(lt);
+ cp++;
+ }
+ else if (*cp == '>') {
+ HDstrncpy(ncp, gt, HDstrlen(gt));
+ ncp += HDstrlen(gt);
+ cp++;
+ }
+ else if (*cp == '&') {
+ HDstrncpy(ncp, amp, HDstrlen(amp));
+ ncp += HDstrlen(amp);
+ cp++;
+ }
+ else {
+ *ncp++ = *cp++;
+ }
+ }
+
+ *ncp = '\0';
+ return rcp;
+}
+
+/**
+ ** XML print functions--these replace some functions in the
+ ** h5tools.c suite.
+ **/
+
+/*-------------------------------------------------------------------------
+ * Function: xml_print_datatype
+ *
+ * Purpose: Print description of a datatype in XML.
+ * Note: this is called inside a <DataType> element.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+xml_print_datatype(hid_t type, unsigned in_group)
+{
+ char *mname;
+ hid_t mtype;
+ unsigned nmembers;
+ unsigned ndims;
+ unsigned i;
+ size_t size;
+ hsize_t dims[H5DUMP_MAX_RANK];
+ H5T_str_t str_pad;
+ H5T_cset_t cset;
+ hid_t super;
+ H5T_order_t ord;
+ H5T_sign_t sgn;
+ size_t sz;
+ size_t spos;
+ size_t epos;
+ size_t esize;
+ size_t mpos;
+ size_t msize;
+ int nmembs;
+ htri_t is_vlstr=FALSE;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ if(!in_group && H5Tcommitted(type) > 0) {
+ H5O_info_t oinfo;
+ obj_t *found_obj; /* Found object */
+
+ /* detect a shared datatype, output only once */
+ H5Oget_info(type, &oinfo);
+ found_obj = search_obj(type_table, oinfo.addr);
+
+ if(found_obj) {
+ /* This should be defined somewhere else */
+ /* These 2 cases are handled the same right now, but
+ probably will have something different eventually */
+ char * dtxid = (char *)HDmalloc(100);
+
+ xml_name_to_XID(found_obj->objname, dtxid, 100, 1);
+ if (!found_obj->recorded) {
+ /* 'anonymous' NDT. Use it's object num.
+ as it's name. */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>",
+ xmlnsprefix, dtxid);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ /* point to the NDT by name */
+ char *t_objname = xml_escape_the_name(found_obj->objname);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>",
+ xmlnsprefix, dtxid, t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_objname);
+ }
+ HDfree(dtxid);
+ }
+ else {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- h5dump error: unknown committed type. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ }
+ else {
+
+ switch (H5Tget_class(type)) {
+ case H5T_INTEGER:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */
+ ord = H5Tget_order(type);
+ sgn = H5Tget_sign(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"",xmlnsprefix);
+ switch (ord) {
+ case H5T_ORDER_LE:
+ h5tools_str_append(&buffer, "LE");
+ break;
+ case H5T_ORDER_BE:
+ h5tools_str_append(&buffer, "BE");
+ break;
+ case H5T_ORDER_VAX:
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ }
+
+ h5tools_str_append(&buffer, "\" Sign=\"");
+
+ switch (sgn) {
+ case H5T_SGN_NONE:
+ h5tools_str_append(&buffer, "false");
+ break;
+ case H5T_SGN_2:
+ h5tools_str_append(&buffer, "true");
+ break;
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ }
+
+ h5tools_str_append(&buffer, "\" Size=\"");
+ sz = H5Tget_size(type);
+ h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
+ h5tools_str_append(&buffer, "\" />");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_FLOAT:
+ /* <hdf5:FloatType ByteOrder="bo" Size="bytes"
+ SignBitLocation="bytes"
+ ExponentBits="eb" ExponentLocation="el"
+ MantissaBits="mb" MantissaLocation="ml" /> */
+ ord = H5Tget_order(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"",xmlnsprefix);
+
+ switch (ord) {
+ case H5T_ORDER_LE:
+ h5tools_str_append(&buffer, "LE");
+ break;
+ case H5T_ORDER_BE:
+ h5tools_str_append(&buffer, "BE");
+ break;
+ case H5T_ORDER_VAX:
+ h5tools_str_append(&buffer, "VAX");
+ break;
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ }
+
+ h5tools_str_append(&buffer, "\" Size=\"");
+ sz = H5Tget_size(type);
+ h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
+ H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize);
+ h5tools_str_append(&buffer, "\" SignBitLocation=\"%lu\" ", (unsigned long)spos);
+ h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos);
+ h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />", (unsigned long)msize, (unsigned long)mpos);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_TIME:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sTimeType />",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ h5tools_str_append(&buffer, "<!-- H5T_TIME: not yet implemented -->");
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ 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);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sStringType Cset=\"",xmlnsprefix);
+ if (cset == H5T_CSET_ASCII) {
+ h5tools_str_append(&buffer, "H5T_CSET_ASCII\" ");
+ }
+ else {
+ h5tools_str_append(&buffer, "unknown_cset\" ");
+ }
+ if(is_vlstr)
+ h5tools_str_append(&buffer, "StrSize=\"H5T_VARIABLE\" StrPad=\"");
+ else
+ h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int) size);
+ if (str_pad == H5T_STR_NULLTERM) {
+ h5tools_str_append(&buffer, "H5T_STR_NULLTERM\"/>");
+ }
+ else if (str_pad == H5T_STR_NULLPAD) {
+ h5tools_str_append(&buffer, "H5T_STR_NULLPAD\"/>");
+ }
+ else if (str_pad == H5T_STR_SPACEPAD) {
+ h5tools_str_append(&buffer, "H5T_STR_SPACEPAD\"/>");
+ }
+ else {
+ h5tools_str_append(&buffer, "H5T_STR_ERROR\"/>");
+ }
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_BITFIELD:
+ /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */
+ ord = H5Tget_order(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"",xmlnsprefix);
+
+ switch (ord) {
+ case H5T_ORDER_LE:
+ h5tools_str_append(&buffer, "LE");
+ break;
+ case H5T_ORDER_BE:
+ h5tools_str_append(&buffer, "BE");
+ break;
+ case H5T_ORDER_VAX:
+ default:
+ h5tools_str_append(&buffer, "ERROR_UNKNOWN");
+ }
+
+ size = H5Tget_size(type);
+ h5tools_str_append(&buffer, "\" Size=\"%lu\"/>", (unsigned long)size);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_OPAQUE:
+ /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ mname = H5Tget_tag(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname);
+ HDfree(mname);
+ size = H5Tget_size(type);
+ h5tools_str_append(&buffer, "Size=\"%lu\"/>", (unsigned long)size);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_COMPOUND:
+ /* recursively describe the components of a compound datatype */
+
+ /* type of a dataset */
+ nmembers = H5Tget_nmembers(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sCompoundType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ /* List each member Field of the type */
+ /* <hdf5:Field FieldName="name" > */
+ /* <hdf5:DataType > */
+ ctx.indent_level++;
+ dump_indent += COL;
+ for (i = 0; i < nmembers; i++) {
+ char *t_fname;
+
+ mname = H5Tget_member_name(type, i);
+ mtype = H5Tget_member_type(type, i);
+ t_fname = xml_escape_the_name(mname);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">",xmlnsprefix, t_fname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(mname);
+ HDfree(t_fname);
+ dump_indent += COL;
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ dump_indent += COL;
+ xml_print_datatype(mtype,0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sField>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sCompoundType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_REFERENCE:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ /* Only Object references supported at this time */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sReferenceType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sObjectReferenceType />",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sReferenceType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_ENUM:
+ /* <hdf5:EnumType Nelems="ne" > list Name, values of enum */
+ nmembs = H5Tget_nmembers(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_indent += COL;
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">",xmlnsprefix, nmembs);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ xml_print_enum(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sEnumType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_VLEN:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sVLType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ super = H5Tget_super(type);
+ dump_indent += COL;
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_indent += COL;
+ ctx.indent_level++;
+ xml_print_datatype(super,0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sVLType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ H5Tclose(super);
+
+ break;
+
+ case H5T_ARRAY:
+ /* Get array base type */
+ super = H5Tget_super(type);
+
+ /* Print lead-in */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sArrayType Ndims=\"",xmlnsprefix);
+ ndims = H5Tget_array_ndims(type);
+ h5tools_str_append(&buffer, "%u\">", ndims);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ /* Get array information */
+ H5Tget_array_dims2(type, dims);
+
+ /* list of dimensions */
+ ctx.indent_level++;
+ for (i = 0; i < ndims; i++) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix, (int) dims[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ ctx.indent_level--;
+
+ dump_indent += COL;
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_indent += COL;
+ ctx.indent_level++;
+ xml_print_datatype(super,0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_indent -= COL;
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sArrayType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ /* Close array base type */
+ H5Tclose(super);
+ break;
+
+ default:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- unknown datatype -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ h5tools_setstatus(EXIT_FAILURE);
+ break;
+ }
+ } /* end else */
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_dump_datatype
+ *
+ * Purpose: Dump description of a datatype in XML.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+xml_dump_datatype(hid_t type)
+{
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ if(H5Tcommitted(type) > 0) {
+ H5O_info_t oinfo;
+ obj_t *found_obj; /* Found object */
+
+ /* Datatype is a shared or named datatype */
+ H5Oget_info(type, &oinfo);
+ found_obj = search_obj(type_table, oinfo.addr);
+
+ if(found_obj) {
+ /* Shared datatype, must be entered as an object */
+ /* These 2 cases are the same now, but may change */
+ char *dtxid = (char *)HDmalloc(100);
+
+ xml_name_to_XID(found_obj->objname, dtxid, 100, 1);
+ if (!found_obj->recorded) {
+ /* anonymous stored datatype:
+ following the dumper's current
+ practice:
+ use it's object ref as its name
+ */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>",
+ xmlnsprefix, dtxid);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ /* pointer to a named datatype already in XML */
+ char *t_objname = xml_escape_the_name(found_obj->objname);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />",
+ xmlnsprefix, dtxid, t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_objname);
+ }
+ HDfree(dtxid);
+ }
+ else {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- h5dump error: unknown committed type. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ }
+ else {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ dump_indent += COL;
+ xml_print_datatype(type, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_dump_dataspace
+ *
+ * Purpose: Dump description of a dataspace in XML.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+xml_dump_dataspace(hid_t space)
+{
+ hsize_t size[H5DUMP_MAX_RANK];
+ hsize_t maxsize[H5DUMP_MAX_RANK];
+ int i;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ int ndims = H5Sget_simple_extent_dims(space, size, maxsize);
+ H5S_class_t space_type = H5Sget_simple_extent_type(space);
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataspace>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ switch (space_type) {
+ case H5S_SCALAR:
+ /* scalar dataspace (just a tag, no XML attrs. defined */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sScalarDataspace />",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5S_SIMPLE:
+ /* simple dataspace */
+ /* <hdf5:SimpleDataspace Ndims="nd"> */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sSimpleDataspace Ndims=\"%d\">",xmlnsprefix, ndims);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ /* print the <hdf5:Dimension> elements */
+ ctx.indent_level++;
+ for (i = 0; i < ndims; i++) {
+ if (maxsize[i] == H5S_UNLIMITED) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"UNLIMITED\"/>",
+ xmlnsprefix,size[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else if (maxsize[i] == (hsize_t) 0) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>",
+ xmlnsprefix,size[i], size[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>",
+ xmlnsprefix, size[i], maxsize[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ }
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sSimpleDataspace>", xmlnsprefix );
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+#ifdef TMP
+ /* Commented out: wait until the schema is updated first */
+ case H5S_NULL:
+ /* null dataspace (just a tag, no XML attrs. defined */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNullDataspace />",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+#endif /* TMP */
+
+ case H5S_NO_CLASS:
+ default:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- unknown dataspace -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataspace>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_dump_data
+ *
+ * Purpose: Dump description of data in XML.
+ * Note that this calls the h5dump_xxx calls in
+ * the h5tools library.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNUSED pindex)
+{
+ hid_t space = -1;
+ hid_t type = -1;
+ hid_t p_type = -1;
+ hsize_t size[64];
+ hsize_t nelmts = 1;
+ int ndims;
+ int i;
+ int depth;
+ int status = -1;
+ int stdindent = COL; /* should be 3 */
+ void *buf = NULL;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ /* Print all the values. */
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+ string_dataformat.cmpd_sep = " ";
+ string_dataformat.cmpd_pre = "";
+ string_dataformat.cmpd_suf = "";
+ string_dataformat.cmpd_end = "";
+ string_dataformat.arr_linebreak = 0;
+ string_dataformat.arr_pre = "";
+ outputformat = &string_dataformat;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ dump_indent += COL;
+ ctx.indent_level++;
+
+ 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) {
+ status = xml_print_strs(obj_id, DATASET_DATA);
+ }
+ else {
+ h5tools_context_t datactx;
+ HDmemset(&datactx, 0, sizeof(datactx));
+ datactx.need_prefix = TRUE;
+ datactx.indent_level = ctx.indent_level;
+ datactx.cur_column = ctx.cur_column;
+ status = h5tools_dump_dset(rawoutstream, outputformat, &datactx, obj_id, -1, NULL);
+ }
+ }
+ else {
+ /* Attribute data */
+ type = H5Aget_type(obj_id);
+
+ if (H5Tget_class(type) == H5T_REFERENCE) {
+ /* references are done differently than
+ the standard output:
+ XML dumps a path to the object
+ referenced.
+ */
+ status = xml_print_refs(obj_id, ATTRIBUTE_DATA);
+ H5Tclose(type);
+ }
+ else if (H5Tget_class(type) == H5T_STRING) {
+ status = xml_print_strs(obj_id, ATTRIBUTE_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_str(p_type) == TRUE)
+ vl_data = TRUE;
+ if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
+ vl_data = TRUE;
+
+ H5Tclose(type);
+
+ space = H5Aget_space(obj_id);
+
+ ndims = H5Sget_simple_extent_dims(space, size, NULL);
+
+ for (i = 0; i < ndims; i++)
+ nelmts *= size[i];
+
+ buf = HDmalloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type))));
+ HDassert(buf);
+
+ if (H5Aread(obj_id, p_type, buf) >= 0) {
+ h5tools_context_t datactx;
+ HDmemset(&datactx, 0, sizeof(datactx));
+ datactx.need_prefix = TRUE;
+ datactx.indent_level = ctx.indent_level;
+ datactx.cur_column = ctx.cur_column;
+ status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id, p_type, space, buf);
+ }
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf);
+
+ HDfree(buf);
+ H5Tclose(p_type);
+ H5Sclose(space);
+ H5Tclose(type);
+ }
+ }
+
+ if (status == FAIL) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "Unable to print data.");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ status = 1;
+ }
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_dump_attr
+ *
+ * Purpose: Dump a description of an HDF5 attribute in XML.
+ *
+ * Return: herr_t
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+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 = -1;
+ hid_t type = -1;
+ hid_t space = -1;
+ H5S_class_t space_type;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+
+ char *t_aname = xml_escape_the_name(attr_name);
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sAttribute Name=\"%s\">", xmlnsprefix, t_aname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_aname);
+
+ if ((attr_id = H5Aopen(attr, attr_name, H5P_DEFAULT)) >= 0) {
+ type = H5Aget_type(attr_id);
+ space = H5Aget_space(attr_id);
+ space_type = H5Sget_simple_extent_type(space);
+
+ dump_function_table->dump_dataspace_function(space);
+ dump_function_table->dump_datatype_function(type);
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ 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_TIME:
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<hdf5:Data>");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
+
+ case H5T_COMPOUND:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
+ break;
+
+ case H5T_REFERENCE:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ xml_print_refs(attr_id, ATTRIBUTE_DATA);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_VLEN:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
+ break;
+ default:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ }
+ }
+ else {
+ /* The case of an attribute never yet written ??
+ * Or dataspace is H5S_NULL. */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ H5Tclose(type);
+ H5Sclose(space);
+ H5Aclose(attr_id);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAttribute>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+ return SUCCEED;
+ }
+ else {
+ /* ?? failed */
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- h5dump error: unable to open attribute. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sAttribute>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+
+ h5tools_setstatus(EXIT_FAILURE);
+ return FAIL;
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_dump_named_datatype
+ *
+ * Purpose: Dump a description of an HDF5 NDT in XML.
+ *
+ * Return: herr_t
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+xml_dump_named_datatype(hid_t type, const char *name)
+{
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ 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);
+ HDstrcat(tmp, "/");
+ HDstrcat(tmp, name);
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ dtxid = (char *)HDmalloc(100);
+ parentxid = (char *)HDmalloc(100);
+ t_tmp = xml_escape_the_name(tmp);
+ t_prefix = xml_escape_the_name(prefix);
+ t_name = xml_escape_the_name(name);
+
+ xml_name_to_XID(tmp, dtxid, 100, 1);
+ xml_name_to_XID(prefix, parentxid, 100, 1);
+ if(HDstrncmp(name, "#", 1) == 0) {
+ /* Special: this is an 'anonymous' NDT, deleted but
+ still in use.
+ We follow the dumper's undocumented practice, and
+ use its object id as its name.
+ Exactly the same as normal, but a separate case
+ in the event we want to do something else in
+ the future.
+ */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix,
+ name, dtxid,
+ parentxid, HDstrcmp(prefix,"") ? t_prefix : "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ H5O_info_t oinfo; /* Object info */
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
+ "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix,
+ t_name, dtxid,
+ t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/"));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ /* Check uniqueness of named datatype */
+ H5Oget_info(type, &oinfo);
+ if(oinfo.rc > 1) {
+ obj_t *found_obj; /* Found object */
+
+ /* Group with more than one link to it... */
+ found_obj = search_obj(type_table, oinfo.addr);
+
+ if (found_obj == NULL) {
+ indentation(dump_indent);
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ else if(found_obj->displayed) {
+ /* We have already printed this named datatype, print it as a
+ * NamedDatatypePtr
+ */
+ char pointerxid[100];
+ char *t_objname = xml_escape_the_name(found_obj->objname);
+
+ ctx.indent_level++;
+
+ xml_name_to_XID(found_obj->objname, pointerxid, sizeof(pointerxid), 1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix, pointerxid, t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sNamedDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_objname);
+ goto done;
+ }
+ else
+ found_obj->displayed = TRUE;
+ }
+ }
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+ dump_indent += COL;
+ xml_print_datatype(type,1);
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sNamedDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+done:
+
+ h5tools_str_close(&buffer);
+
+ HDfree(dtxid);
+ HDfree(parentxid);
+ HDfree(t_tmp);
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(tmp);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_dump_group
+ *
+ * Purpose: Dump a description of an HDF5 Group (and its members) in XML.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ * Pedro Vicente, October 9, 2007
+ * added parameters to H5A(L)iterate to allow for other iteration orders
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+xml_dump_group(hid_t gid, const char *name)
+{
+ H5O_info_t oinfo;
+ hid_t gcpl_id;
+ hid_t dset, type;
+ unsigned crt_order_flags;
+ unsigned attr_crt_order_flags;
+ int isRoot = 0;
+ char type_name[1024];
+ char *t_objname = NULL;
+ char *par_name = NULL;
+ char *cp = NULL;
+ char *tmp = NULL;
+ char *par = NULL;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ 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) {
+ 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) {
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ if(H5Pclose(gcpl_id) < 0) {
+ error_msg("error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ if(HDstrcmp(name, "/") == 0) {
+ isRoot = 1;
+ tmp = HDstrdup("/");
+ }
+ else {
+ tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ HDstrcpy(tmp, prefix);
+ par = HDstrdup(tmp);
+ cp = HDstrrchr(par, '/');
+ if(cp) {
+ if((cp == par) && HDstrlen(par) > 1)
+ *(cp + 1) = '\0';
+ else
+ *cp = '\0';
+ }
+ }
+
+ H5Oget_info(gid, &oinfo);
+
+ if(oinfo.rc > 1) {
+ obj_t *found_obj; /* Found object */
+
+ /* Group with more than one link to it... */
+ found_obj = search_obj(group_table, oinfo.addr);
+
+ if (found_obj == NULL) {
+ indentation(dump_indent);
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ else {
+ char *t_name = xml_escape_the_name(name);
+ char *grpxid = (char *)HDmalloc(100);
+ char *parentxid = (char *)HDmalloc(100);
+
+ if(found_obj->displayed) {
+ char *ptrstr = (char *)HDmalloc(100);
+
+ /* already seen: enter a groupptr */
+ if(isRoot) {
+ /* probably can't happen! */
+ xml_name_to_XID("/", grpxid, 100, 1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">",
+ xmlnsprefix, grpxid, "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ 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);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix,t_name, grpxid, get_next_xid(),
+ t_objname, parentxid, par_name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_objname);
+ HDfree(par_name);
+
+ ctx.indent_level++;
+
+ t_objname = xml_escape_the_name(found_obj->objname);/* point to the NDT by 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);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix,
+ ptrstr, t_objname, parentxid, par_name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+
+ HDfree(t_objname);
+ HDfree(par_name);
+ }
+ HDfree(ptrstr);
+ }
+ else {
+
+ /* first time this group has been seen -- describe it */
+ if(isRoot) {
+ xml_name_to_XID("/", grpxid, 100, 1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">",
+ xmlnsprefix, grpxid, "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ 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);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" >",
+ xmlnsprefix,t_name, grpxid, t_tmp, parentxid, par_name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(t_tmp);
+ HDfree(par_name);
+ }
+ found_obj->displayed = TRUE;
+
+ /* 1. do all the attributes of the group */
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
+ if(H5Aiterate2(gid, 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(gid, 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 */
+ } /* end else */
+
+ if(isRoot && unamedtype) {
+ unsigned u;
+
+ /* Very special case: dump unamed type in root group */
+ for(u = 0; u < type_table->nobjs; u++) {
+ if(!type_table->objs[u].recorded) {
+ dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
+ type = H5Dget_type(dset);
+ sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+ dump_function_table->dump_named_datatype_function(type, type_name);
+ H5Tclose(type);
+ H5Dclose(dset);
+ }
+ }
+ }
+
+ /* iterate through all the links */
+
+ if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
+ H5Literate(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL);
+ else
+ H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL);
+
+ dump_indent -= COL;
+ ctx.indent_level--;
+ }
+ HDfree(t_name);
+ HDfree(grpxid);
+ HDfree(parentxid);
+ }
+ }
+ else {
+ /* only link -- must be first time! */
+ char *t_name = xml_escape_the_name(name);
+ char *grpxid = (char *)HDmalloc(100);
+ char *parentxid = (char *)HDmalloc(100);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+
+ if(isRoot) {
+ xml_name_to_XID("/", grpxid, 100, 1);
+ h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", 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);
+ h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" >",
+ xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name);
+ HDfree(t_tmp);
+ HDfree(par_name);
+ }
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(t_name);
+ HDfree(grpxid);
+ HDfree(parentxid);
+
+ /* 1. do all the attributes of the group */
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
+ if(H5Aiterate2(gid, 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(gid, 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 */
+ } /* end else */
+
+ if(isRoot && unamedtype) {
+ unsigned u;
+
+ /* Very special case: dump unamed type in root group */
+ for(u = 0; u < type_table->nobjs; u++) {
+ if(!type_table->objs[u].recorded) {
+ dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
+ type = H5Dget_type(dset);
+ sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+ dump_function_table->dump_named_datatype_function(type, type_name);
+ H5Tclose(type);
+ H5Dclose(dset);
+ }
+ }
+ }
+
+ /* iterate through all the links */
+
+ if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
+ H5Literate(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL);
+ else
+ H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL);
+
+ dump_indent -= COL;
+ ctx.indent_level--;
+ }
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if(isRoot)
+ h5tools_str_append(&buffer, "</%sRootGroup>", xmlnsprefix);
+ else
+ h5tools_str_append(&buffer, "</%sGroup>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+
+ if(par)
+ HDfree(par);
+ if(tmp)
+ HDfree(tmp);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_print_refs
+ *
+ * Purpose: Print a path to the objects referenced by HDF5 Referneces.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+xml_print_refs(hid_t did, int source)
+{
+ herr_t e;
+ hid_t type;
+ hid_t space;
+ hssize_t ssiz;
+ hsize_t i;
+ size_t tsiz;
+ hobj_ref_t *refbuf = NULL;
+ char *buf = NULL;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ if (source == DATASET_DATA) {
+ type = H5Dget_type(did);
+ }
+ else if (source == ATTRIBUTE_DATA) {
+ type = H5Aget_type(did);
+ }
+ else {
+ /* return an error */
+ return FAIL;
+ }
+ if (H5Tget_class(type) != H5T_REFERENCE) {
+ /* return an error */
+ goto error;
+ }
+ if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
+ /* region ref not supported yet... */
+ /* return an error */
+ goto error;
+ }
+ if (source == DATASET_DATA) {
+ space = H5Dget_space(did);
+ if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
+ goto error;
+ if ((tsiz = H5Tget_size(type)) == 0)
+ goto error;
+
+ buf = (char *) HDcalloc((size_t)(ssiz * tsiz), sizeof(char));
+ if (buf == NULL)
+ goto error;
+ e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ /* need to check result here */
+ if (e < 0) {
+ goto error;
+ }
+ }
+ else if (source == ATTRIBUTE_DATA) {
+ space = H5Aget_space(did);
+ if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
+ goto error;
+ if ((tsiz = H5Tget_size(type)) == 0)
+ goto error;
+
+ buf = (char *) HDcalloc((size_t)(ssiz * tsiz), sizeof(char));
+ if (buf == NULL) {
+ goto error;
+ }
+ e = H5Aread(did, H5T_STD_REF_OBJ, buf);
+ /* need to check the result here */
+ if (e < 0) {
+ goto error;
+ }
+ }
+
+ refbuf = (hobj_ref_t *) buf;
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ for (i = 0; i < ssiz; i++) {
+ const char *path = lookup_ref_path(*refbuf);
+ ctx.indent_level++;
+
+ if (!path) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%s\"", "NULL");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ char *t_path = xml_escape_the_string(path, -1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%s\"", t_path);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_path);
+ }
+ ctx.indent_level--;
+
+ refbuf++;
+ }
+
+ h5tools_str_close(&buffer);
+
+ HDfree(buf);
+ H5Tclose(type);
+ H5Sclose(space);
+ return SUCCEED;
+
+error:
+ if(buf)
+ HDfree(buf);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(type);
+ H5Sclose(space);
+ } H5E_END_TRY;
+ return FAIL;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_print_strs
+ *
+ * Purpose: Print strings.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+xml_print_strs(hid_t did, int source)
+{
+ 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;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ if (source == DATASET_DATA) {
+ type = H5Dget_type(did);
+ }
+ else if (source == ATTRIBUTE_DATA) {
+ type = H5Aget_type(did);
+ }
+ else {
+ /* return an error */
+ return FAIL;
+ }
+ if (H5Tget_class(type) != H5T_STRING) {
+ /* return an error */
+ goto error;
+ }
+ /* Check if we have VL data in the dataset's datatype */
+ is_vlstr = H5Tis_variable_str(type);
+
+ if (source == DATASET_DATA) {
+ space = H5Dget_space(did);
+ if((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
+ goto error;
+ if((tsiz = H5Tget_size(type)) == 0)
+ goto error;
+
+ buf = HDmalloc((size_t)(ssiz * tsiz));
+ if (buf == NULL)
+ goto error;
+
+ e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ if (e < 0) {
+ goto error;
+ }
+ }
+ else if (source == ATTRIBUTE_DATA) {
+ space = H5Aget_space(did);
+ if((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
+ goto error;
+ if((tsiz = H5Tget_size(type)) == 0)
+ goto error;
+
+ buf = HDmalloc((size_t)(ssiz * tsiz));
+ if (buf == NULL)
+ goto error;
+
+ e = H5Aread(did, type, buf);
+ if (e < 0) {
+ goto error;
+ }
+ }
+
+ bp = (char*) buf;
+ if (!is_vlstr)
+ onestring = (char *) HDcalloc(tsiz, sizeof(char));
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ for (i = 0; i < ssiz; i++) {
+ if (is_vlstr) {
+ onestring = *(char **) bp;
+ if (onestring)
+ str_size = (size_t) HDstrlen(onestring);
+ }
+ else {
+ HDstrncpy(onestring, bp, tsiz);
+ str_size = tsiz;
+ }
+
+ if (!onestring) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ char *t_onestring = xml_escape_the_string(onestring, (int) str_size);
+ if (t_onestring) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%s\"", t_onestring);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_onestring);
+ }
+ }
+ bp += tsiz;
+ }
+
+ h5tools_str_close(&buffer);
+
+ /* Reclaim any VL memory, if necessary */
+ if (!is_vlstr)
+ if (onestring)
+ HDfree(onestring);
+ if (buf) {
+ if (is_vlstr)
+ H5Dvlen_reclaim(type, space, H5P_DEFAULT, buf);
+ HDfree(buf);
+ }
+ H5Tclose(type);
+ H5Sclose(space);
+ return SUCCEED;
+
+error:
+ if(buf)
+ HDfree(buf);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(type);
+ H5Sclose(space);
+ } H5E_END_TRY;
+ return FAIL;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: check_filters
+ *
+ * Purpose: private function to check for the filters and
+ * put tags in the XML.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+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;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ 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);
+ if (filter == H5Z_FILTER_DEFLATE) {
+ ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDeflate Level=\"", xmlnsprefix);
+ if (cd_nelmts < 1) {
+ /* not sure what this means? */
+ h5tools_str_append(&buffer, "6");
+ }
+ else {
+ h5tools_str_append(&buffer, "%d", cd_values[0]);
+ }
+ h5tools_str_append(&buffer, "\"/>");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+ else if (filter == H5Z_FILTER_FLETCHER32) {
+ ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sFletcher32 />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+ else if (filter == H5Z_FILTER_SHUFFLE) {
+ ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sShuffle />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+ else if (filter == H5Z_FILTER_SZIP) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sSZIP ", xmlnsprefix);
+ if (cd_nelmts < 2) {
+ /* no pixels ? */
+ h5tools_str_append(&buffer, "Pixels_per_block=\"-1\" ");
+ }
+ else {
+ h5tools_str_append(&buffer, "Pixels_per_block=\"%d\" ", cd_values[1]);
+ }
+ /* analyse the options mask */
+ if (cd_values[0] & H5_SZIP_CHIP_OPTION_MASK) {
+ h5tools_str_append(&buffer, "Mode =\"Hardware\" ");
+ }
+ else if (cd_values[0] & H5_SZIP_ALLOW_K13_OPTION_MASK) {
+ h5tools_str_append(&buffer, "Mode =\"K13\" ");
+ }
+ h5tools_str_append(&buffer, "Coding=\"");
+ if (cd_values[0] & H5_SZIP_EC_OPTION_MASK) {
+ h5tools_str_append(&buffer, "Entropy");
+ }
+ else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) {
+ h5tools_str_append(&buffer, "NN");
+ }
+ h5tools_str_append(&buffer, "\" ");
+
+ h5tools_str_append(&buffer, "ByteOrder=\"");
+ if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) {
+ h5tools_str_append(&buffer, "LSB");
+ }
+ else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) {
+ h5tools_str_append(&buffer, "MSB");
+ }
+ h5tools_str_append(&buffer, "\" ");
+
+ if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) {
+ h5tools_str_append(&buffer, "Header=\"Raw\"");
+ }
+ h5tools_str_append(&buffer, "/>");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+ else {
+ /* unknown option */
+ }
+ }
+
+ h5tools_str_close(&buffer);
+}
+
+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;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ space = H5Tget_size(type);
+ buf = HDmalloc((size_t) space);
+
+ H5Pget_fill_value(dcpl, type, buf);
+
+ if (H5Tget_class(type) == H5T_REFERENCE) {
+ const char * path = lookup_ref_path(*(hobj_ref_t *) buf);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ if (!path) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%s\"", "NULL");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ char *t_path = xml_escape_the_string(path, -1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%s\"", t_path);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_path);
+ }
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else if (H5Tget_class(type) == H5T_STRING) {
+ /* ????? */
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- String fill values not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ /* all other data */
+ switch (H5Tget_class(type)) {
+ case H5T_INTEGER:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%d\"", *(int *) buf);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ case H5T_FLOAT:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%f\"", *(float *) buf);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ sz = H5Tget_size(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"");
+ for (i = 0; i < sz; i++) {
+ h5tools_str_append(&buffer, "%x ", *(unsigned int *) buf);
+ buf = (char *) buf + sizeof(unsigned int);
+ }
+ h5tools_str_append(&buffer, "\"");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ case H5T_ENUM:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ name = H5Tget_member_name(type, *(unsigned *) buf);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%s\"", name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ case H5T_ARRAY:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Array fill values not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ case H5T_TIME:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Time fill not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ case H5T_COMPOUND:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Compound fill not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ case H5T_VLEN:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- VL fill not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ default:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Unknown fill datatype: %d -->", H5Tget_class(type));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ }
+ }
+ HDfree(buf);
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_dump_dataset
+ *
+ * Purpose: Dump a description of an HDF5 dataset in XML.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ * Pedro Vicente, October 9, 2007
+ * added parameters to H5Aiterate2 to allow for other iteration orders
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
+{
+ 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;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ char *rstr = (char*) HDmalloc(100);
+ char *pstr = (char*) HDmalloc(100);
+
+ tmp = (char*) HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ HDstrcpy(tmp, prefix);
+ HDstrcat(tmp, "/");
+ HDstrcat(tmp, name);
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ t_name = xml_escape_the_name(name);
+ t_tmp = xml_escape_the_name(tmp);
+ t_prefix = xml_escape_the_name(prefix);
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ xml_name_to_XID(tmp, rstr, 100, 1);
+ xml_name_to_XID(prefix, pstr, 100, 1);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix, t_name, rstr, t_tmp, pstr,
+ strcmp(prefix, "") ? t_prefix : "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ HDfree(t_name);
+ HDfree(t_tmp);
+ HDfree(t_prefix);
+ HDfree(rstr);
+ HDfree(pstr);
+ HDfree(tmp);
+
+ dcpl = H5Dget_create_plist(did);
+ type = H5Dget_type(did);
+ space = H5Dget_space(did);
+
+ /* 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)) {
+ maxdims = H5Sget_simple_extent_ndims(space);
+ chsize = (hsize_t *) HDmalloc(maxdims * sizeof(hsize_t));
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sChunkedLayout ", xmlnsprefix);
+ ndims = H5Pget_chunk(dcpl, maxdims, chsize);
+ h5tools_str_append(&buffer, "Ndims=\"%d\">", ndims);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ for (i = 0; i < ndims; i++) {
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" />", xmlnsprefix, chsize[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sRequiredFilter>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+ dump_indent += COL;
+ check_filters(dcpl);
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sRequiredFilter>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sChunkedLayout>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ HDfree(chsize);
+ }
+ else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sContiguousLayout/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+ else if (H5D_COMPACT == H5Pget_layout(dcpl)) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sCompactLayout/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+ /* and check for external.... ?? */
+
+ /* fill value */
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sFillValueInfo ", xmlnsprefix);
+ H5Pget_fill_time(dcpl, &ft);
+ h5tools_str_append(&buffer, "FillTime=\"");
+ switch (ft) {
+ case H5D_FILL_TIME_ALLOC:
+ h5tools_str_append(&buffer, "FillOnAlloc");
+ break;
+ case H5D_FILL_TIME_NEVER:
+ h5tools_str_append(&buffer, "FillNever");
+ break;
+ case H5D_FILL_TIME_IFSET:
+ h5tools_str_append(&buffer, "FillIfSet");
+ break;
+ default:
+ h5tools_str_append(&buffer, "?");
+ break;
+ }
+ h5tools_str_append(&buffer, "\" ");
+ H5Pget_alloc_time(dcpl, &at);
+ h5tools_str_append(&buffer, "AllocationTime=\"");
+ switch (at) {
+ case H5D_ALLOC_TIME_EARLY:
+ h5tools_str_append(&buffer, "Early");
+ break;
+ case H5D_ALLOC_TIME_INCR:
+ h5tools_str_append(&buffer, "Incremental");
+ break;
+ case H5D_ALLOC_TIME_LATE:
+ h5tools_str_append(&buffer, "Late");
+ break;
+ case H5D_ALLOC_TIME_DEFAULT:
+ default:
+ h5tools_str_append(&buffer, "?");
+ break;
+ }
+ h5tools_str_append(&buffer, "\"");
+ h5tools_str_append(&buffer, ">");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sFillValue>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ H5Pfill_value_defined(dcpl, &fvstatus);
+ if (fvstatus == H5D_FILL_VALUE_UNDEFINED || (fvstatus == H5D_FILL_VALUE_DEFAULT && ft == H5D_FILL_TIME_IFSET)) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoFill/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+ else {
+ xml_dump_fill_value(dcpl, type);
+ }
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sFillValue>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sFillValueInfo>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ dump_function_table->dump_dataspace_function(space);
+ dump_function_table->dump_datatype_function(type);
+
+ ctx.indent_level++;
+ dump_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) {
+ 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) {
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+ } /* end else */
+
+ ctx.indent_level--;
+ dump_indent -= COL;
+ tempi = H5Dget_storage_size(did);
+
+ 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:
+ ctx.indent_level++;
+ dump_indent += COL;
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
+
+ case H5T_TIME:
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level--;
+ break;
+
+ case H5T_COMPOUND:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.indent_level++;
+ dump_indent += COL;
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
+
+ case H5T_REFERENCE:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ else {
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ xml_print_refs(did, DATASET_DATA);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+
+ case H5T_VLEN:
+ ctx.indent_level--;
+ dump_indent -= COL;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ dump_indent += COL;
+
+ ctx.indent_level++;
+ dump_indent += COL;
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
+ default:
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ break;
+ }
+ }
+ else {
+ /* no data written */
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+ }
+
+ H5Tclose(type);
+ H5Sclose(space);
+ H5Pclose(dcpl);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataset>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ h5tools_str_close(&buffer);
+}
+
+/*-------------------------------------------------------------------------
+ * Function: xml_print_enum
+ *
+ * Purpose: Print the values of an HDF5 ENUM in XML.
+ * Very similar to regular DDL output.
+ *
+ * Return: void
+ *
+ * Programmer: REMcG
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+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;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ /* setup */
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level = dump_indent/COL;
+ ctx.cur_column = dump_indent;
+
+ string_dataformat = *outputformat;
+
+ if (fp_format) {
+ string_dataformat.fmt_double = fp_format;
+ string_dataformat.fmt_float = fp_format;
+ }
+
+ if (h5tools_nCols==0) {
+ string_dataformat.line_ncols = 65535;
+ string_dataformat.line_per_line = 1;
+ }
+ else
+ string_dataformat.line_ncols = h5tools_nCols;
+
+ string_dataformat.do_escape = display_escape;
+ outputformat = &string_dataformat;
+
+ nmembs = (unsigned)H5Tget_nmembers(type);
+ super = H5Tget_super(type);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ xml_print_datatype(super,0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ /*
+ * 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
+ */
+ if (H5Tget_size(type) <= sizeof(long long)) {
+ dst_size = sizeof(long long);
+
+ if (H5T_SGN_NONE == H5Tget_sign(type)) {
+ native = H5T_NATIVE_ULLONG;
+ }
+ else {
+ native = H5T_NATIVE_LLONG;
+ }
+ }
+ else {
+ dst_size = H5Tget_size(type);
+ }
+
+ /* Get the names and raw values of all members */
+ name = (char **)HDcalloc(nmembs, sizeof(char *));
+ value = (unsigned char *)HDcalloc(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));
+ }
+
+ /* Convert values to native datatype */
+ if (native > 0)
+ H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT);
+
+ /* Sort members by increasing value */
+ /*not implemented yet */
+
+ /* Print members */
+ ctx.indent_level++;
+ dump_indent += COL;
+ for (i = 0; i < nmembs; i++) {
+ char *t_name = xml_escape_the_name(name[i]);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sEnumElement>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", t_name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ HDfree(t_name);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sEnumElement>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sEnumValue>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level++;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if (native < 0) {
+ h5tools_str_append(&buffer, "0x");
+
+ for (j = 0; j < dst_size; j++)
+ h5tools_str_append(&buffer, "%02x", value[i * dst_size + j]);
+ }
+ else if (H5T_SGN_NONE == H5Tget_sign(native)) {
+ h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *)
+ ((void *) (value + i * dst_size))));
+ }
+ else {
+ h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "d",
+ *((long long *) ((void *) (value + i * dst_size))));
+ }
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, 0, 0);
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sEnumValue>",xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, outputformat->line_ncols, 0, 0);
+ }
+ ctx.indent_level--;
+ dump_indent -= COL;
+
+ h5tools_str_close(&buffer);
+
+ /* Release resources */
+ for (i = 0; i < nmembs; i++)
+ HDfree(name[i]);
+
+ HDfree(name);
+ HDfree(value);
+ H5Tclose(super);
+}
+
diff --git a/tools/h5dump/h5dump_xml.h b/tools/h5dump/h5dump_xml.h
new file mode 100644
index 0000000..28485f8
--- /dev/null
+++ b/tools/h5dump/h5dump_xml.h
@@ -0,0 +1,128 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#ifndef H5DUMP_XML_H__
+#define H5DUMP_XML_H__
+
+extern const char *xmlnsprefix;
+
+/*
+ * Alternative formating for data dumped to XML
+ * In general, the numbers are the same, but separators
+ * except spaces are not used.
+ *
+ * Some of these are not used, as some kinds of data are
+ * dumped in completely new subroutines.
+ *
+ * Some of this formatting may yet need to change.
+ *
+ * This table only affects XML output.
+ */
+static h5tool_format_t xml_dataformat = {
+ 0, /*raw */
+
+ "", /*fmt_raw */
+ "%d", /*fmt_int */
+ "%u", /*fmt_uint */
+ "%hhd", /*fmt_schar */
+ "%u", /*fmt_uchar */
+ "%d", /*fmt_short */
+ "%u", /*fmt_ushort */
+ "%ld", /*fmt_long */
+ "%lu", /*fmt_ulong */
+ NULL, /*fmt_llong */
+ NULL, /*fmt_ullong */
+ "%g", /*fmt_double */
+ "%g", /*fmt_float */
+
+ 0, /*ascii */
+ 0, /*str_locale */
+ 0, /*str_repeat */
+
+ "", /*arr_pre */
+ "", /*arr_sep */
+ "", /*arr_suf */
+ 1, /*arr_linebreak */
+
+ "", /*cmpd_name */
+ "", /*cmpd_sep */
+ "", /*cmpd_pre */
+ "", /*cmpd_suf */
+ "", /*cmpd_end */
+
+ " ", /*vlen_sep */
+ " ", /*vlen_pre */
+ "", /*vlen_suf */
+ "", /*vlen_end */
+
+ "%s", /*elmt_fmt */
+ "", /*elmt_suf1 */
+ " ", /*elmt_suf2 */
+
+ "", /*idx_n_fmt */
+ "", /*idx_sep */
+ "", /*idx_fmt */
+
+ 80, /*line_ncols *//*standard default columns */
+ 0, /*line_per_line */
+ "", /*line_pre */
+ "%s", /*line_1st */
+ "%s", /*line_cont */
+ "", /*line_suf */
+ "", /*line_sep */
+ 1, /*line_multi_new */
+ " ", /*line_indent */
+
+ 1, /*skip_first */
+
+ 1, /*obj_hidefileno */
+ " "H5_PRINTF_HADDR_FMT, /*obj_format */
+
+ 1, /*dset_hidefileno */
+ "DATASET %s ", /*dset_format */
+ "%s", /*dset_blockformat_pre */
+ "%s", /*dset_ptformat_pre */
+ "%s", /*dset_ptformat */
+ 0, /*array indices */
+ 0 /*escape non printable characters */
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* internal functions used by XML option */
+static void xml_print_datatype(hid_t, unsigned);
+static void xml_print_enum(hid_t);
+static int xml_print_refs(hid_t, int);
+static int xml_print_strs(hid_t, int);
+static char *xml_escape_the_string(const char *, int);
+static char *xml_escape_the_name(const char *);
+
+/* The dump functions of the dump_function_table */
+/* XML format: same interface, alternative output */
+
+void xml_dump_group(hid_t, const char *);
+void xml_dump_named_datatype(hid_t, const char *);
+void xml_dump_dataset(hid_t, const char *, struct subset_t *);
+void xml_dump_dataspace(hid_t space);
+void xml_dump_datatype(hid_t type);
+herr_t xml_dump_attr(hid_t, const char *, const H5A_info_t *, void *);
+void xml_dump_data(hid_t, int, struct subset_t *, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !H5DUMP_XML_H__ */
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index ab67db8..ba9741b 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -1941,9 +1941,9 @@ static void gent_objref(void)
const char *write_comment = "Foo!"; /* Comments for group */
/* Allocate write & read buffers */
- wbuf = (hobj_ref_t*) malloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
- rbuf = (hobj_ref_t*) malloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
- tbuf = (hobj_ref_t*) malloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
+ wbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
+ rbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
+ tbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
/* Create file */
fid1 = H5Fcreate(FILE16, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -2022,9 +2022,9 @@ static void gent_objref(void)
H5Fclose(fid1);
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
- free(tbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
+ HDfree(tbuf);
}
static void gent_datareg(void)
@@ -2051,10 +2051,10 @@ static void gent_datareg(void)
int i; /* counting variables */
/* Allocate write & read buffers */
- wbuf = (hdset_reg_ref_t*) calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
- rbuf = (hdset_reg_ref_t*) malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1);
- dwbuf = (uint8_t*) malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
- drbuf = (uint8_t*) calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2);
+ wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
+ rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1);
+ dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
+ drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2);
/* Create file */
fid1 = H5Fcreate(FILE17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -2128,10 +2128,10 @@ static void gent_datareg(void)
H5Fclose(fid1);
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
- free(dwbuf);
- free(drbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
+ HDfree(dwbuf);
+ HDfree(drbuf);
}
static void gent_attrreg(void)
@@ -2160,13 +2160,13 @@ static void gent_attrreg(void)
int i; /* counting variables */
/* Allocate write & read buffers */
- wbuf = (hdset_reg_ref_t*) calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
- rbuf = (hdset_reg_ref_t*) malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1);
- dwbuf = (uint8_t*) malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
- drbuf = (uint8_t*) calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2);
+ wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
+ rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1);
+ dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2);
+ drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2);
/* Create file */
- fid1 = H5Fcreate(FILE65, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ fid1 = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create dataspace for datasets */
sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
@@ -2248,10 +2248,10 @@ static void gent_attrreg(void)
H5Fclose(fid1);
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
- free(dwbuf);
- free(drbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
+ HDfree(dwbuf);
+ HDfree(drbuf);
}
/*taken from Elena's compound test file*/
@@ -2466,7 +2466,7 @@ static void gent_vldatatypes(void)
for(i = 0; i < SPACE1_DIM1; i++) {
int j;
- wdata[i].p = malloc((i + 1) * sizeof(int));
+ wdata[i].p = HDmalloc((i + 1) * sizeof(int));
wdata[i].len = i + 1;
for(j = 0; j < i + 1; j++)
@@ -2478,22 +2478,22 @@ static void gent_vldatatypes(void)
type = H5Tvlen_create(H5T_NATIVE_INT);
dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(type);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(space);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Allocate and initialize VL dataset to write */
for(i = 0; i < SPACE1_DIM1; i++) {
int j;
- wdata[i].p = malloc((i + 1) * sizeof(float));
+ wdata[i].p = HDmalloc((i + 1) * sizeof(float));
wdata[i].len = i + 1;
for(j = 0; j < i + 1; j++)
@@ -2505,19 +2505,19 @@ static void gent_vldatatypes(void)
type = H5Tvlen_create(H5T_NATIVE_FLOAT);
dset = H5Dcreate2(file, "Dataset2.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(type);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(space);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Allocate and initialize a scalar VL dataset to write */
- adata.p = malloc(37 * sizeof(int));
+ adata.p = HDmalloc(37 * sizeof(int));
adata.len = 37;
for(i = 0; i < 37; i++)
@@ -2528,18 +2528,18 @@ static void gent_vldatatypes(void)
type = H5Tvlen_create(H5T_NATIVE_INT);
dset = H5Dcreate2(file, "Dataset3.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &adata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &adata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(type);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(space);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(file);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void
@@ -2557,14 +2557,14 @@ gent_vldatatypes2(void)
/* Allocate and initialize VL data to write */
for(i = 0; i < SPACE1_DIM1; i++) {
- wdata[i].p = (hvl_t *)malloc((i + 1) * sizeof(hvl_t));
+ wdata[i].p = (hvl_t *)HDmalloc((i + 1) * sizeof(hvl_t));
if(wdata[i].p == NULL) {
printf("Cannot allocate memory for VL data! i=%u\n", i);
return;
} /* end if */
wdata[i].len = i + 1;
for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) {
- t1->p = (unsigned *)malloc((j + 1) * sizeof(unsigned));
+ t1->p = (unsigned *)HDmalloc((j + 1) * sizeof(unsigned));
if(t1->p == NULL) {
printf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
return;
@@ -2592,23 +2592,23 @@ gent_vldatatypes2(void)
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Reclaim the write VL data */
ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
@@ -2632,7 +2632,7 @@ static void gent_vldatatypes3(void)
for(i=0; i<SPACE1_DIM1; i++) {
wdata[i].i=i*10;
wdata[i].f=(float)((i*20)/3.0);
- wdata[i].v.p=malloc((i+1)*sizeof(unsigned int));
+ wdata[i].v.p=HDmalloc((i+1)*sizeof(unsigned int));
wdata[i].v.len=i+1;
for(j=0; j<(i+1); j++)
((unsigned int *)wdata[i].v.p)[j]=i*10+j;
@@ -2652,34 +2652,34 @@ static void gent_vldatatypes3(void)
/* Insert fields */
ret = H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_INT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tinsert(tid2, "f", HOFFSET(s1, f), H5T_NATIVE_FLOAT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tinsert(tid2, "v", HOFFSET(s1, v), tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a dataset */
dataset = H5Dcreate2(fid1, "Dataset1", tid2, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Reclaim the write VL data */
ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void gent_vldatatypes4(void)
@@ -2699,7 +2699,7 @@ static void gent_vldatatypes4(void)
/* Allocate and initialize VL data to write */
for(i=0; i<SPACE1_DIM1; i++) {
- wdata[i].p=malloc((i+1)*sizeof(s1));
+ wdata[i].p=HDmalloc((i+1)*sizeof(s1));
wdata[i].len=i+1;
for(j=0; j<(i+1); j++) {
((s1 *)wdata[i].p)[j].i=i*10+j;
@@ -2718,9 +2718,9 @@ static void gent_vldatatypes4(void)
/* Insert fields */
ret = H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_INT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tinsert(tid2, "f", HOFFSET(s1, f), H5T_NATIVE_FLOAT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a datatype to refer to */
tid1 = H5Tvlen_create(tid2);
@@ -2730,23 +2730,23 @@ static void gent_vldatatypes4(void)
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Reclaim the write VL data */
ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
/* Generate a variable-length dataset with NULL values in it */
@@ -2769,7 +2769,7 @@ static void gent_vldatatypes5(void)
} /* end if */
else {
wdata[i].len=i+5;
- wdata[i].p=malloc(sizeof(unsigned)*(i+5));
+ wdata[i].p=HDmalloc(sizeof(unsigned)*(i+5));
for(j=0; j<i+5; j++)
((unsigned *)wdata[i].p)[j]=j*2;
} /* end else */
@@ -2777,37 +2777,37 @@ static void gent_vldatatypes5(void)
/* Create file */
fid1 = H5Fcreate(FILE43, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid1>0);
+ HDassert(fid1>0);
/* Create dataspace for datasets */
sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
- assert(sid1>0);
+ HDassert(sid1>0);
/* Create a datatype to refer to */
tid1 = H5Tvlen_create(H5T_NATIVE_UINT);
- assert(tid1>0);
+ HDassert(tid1>0);
/* Create a dataset */
dataset = H5Dcreate2(fid1, F43_DSETNAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(dataset>0);
+ HDassert(dataset>0);
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose (sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose (fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
/* This is big enough to make h5dump to use hyperslap to read
@@ -2848,8 +2848,8 @@ static void gent_array1_big(void)
block[0] = 1;
/* Allocate write & read buffers */
- wbuf = (hdset_reg_ref_t*) calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
- wdata = (int *)malloc(sizeof(int) * (size_t)(SPACE_ARRAY1BIG_DIM * ARRAY1BIG_DIM));
+ wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
+ wdata = (int *)HDmalloc(sizeof(int) * (size_t)(SPACE_ARRAY1BIG_DIM * ARRAY1BIG_DIM));
/* Allocate and initialize array data to write */
for(i = 0; i < SPACE_ARRAY1BIG_DIM; i++)
@@ -2873,7 +2873,7 @@ static void gent_array1_big(void)
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*---------------------------
* Region Reference dataset
@@ -2897,17 +2897,17 @@ static void gent_array1_big(void)
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Release memory */
- free(wbuf);
- free(wdata);
+ HDfree(wbuf);
+ HDfree(wdata);
}
static void gent_array1(void)
@@ -2941,17 +2941,17 @@ static void gent_array1(void)
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void gent_array2(void)
@@ -2987,17 +2987,17 @@ static void gent_array2(void)
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void gent_array3(void)
@@ -3038,19 +3038,19 @@ static void gent_array3(void)
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void gent_array4(void)
@@ -3088,35 +3088,35 @@ static void gent_array4(void)
/* Insert integer field */
ret = H5Tinsert(tid2, "i", HOFFSET(s2_t, i), H5T_NATIVE_INT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Insert float field */
ret = H5Tinsert(tid2, "f", HOFFSET(s2_t, f), H5T_NATIVE_FLOAT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create an array datatype to refer to */
tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1);
/* Close compound datatype */
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a dataset */
dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void gent_array5(void)
@@ -3156,42 +3156,42 @@ static void gent_array5(void)
/* Insert integer field */
ret = H5Tinsert (tid2, "i", HOFFSET(s2_t,i), H5T_NATIVE_INT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create an array of floats datatype */
tid3 = H5Tarray_create2(H5T_NATIVE_FLOAT, ARRAY1_RANK, tdims1);
/* Insert float array field */
ret = H5Tinsert (tid2, "f", HOFFSET(s2_t,f), tid3);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close array of floats field datatype */
ret = H5Tclose(tid3);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create an array datatype to refer to */
tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1);
/* Close compound datatype */
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a dataset */
dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void gent_array6(void)
@@ -3210,7 +3210,7 @@ static void gent_array6(void)
/* Initialize array data to write */
for(i=0; i<SPACE1_DIM1; i++)
for(j=0; j<ARRAY1_DIM1; j++) {
- wdata[i][j].p=malloc((i+j+1)*sizeof(unsigned int));
+ wdata[i][j].p=HDmalloc((i+j+1)*sizeof(unsigned int));
wdata[i][j].len=i+j+1;
for(k=0; k<(i+j+1); k++)
((unsigned int *)wdata[i][j].p)[k]=i*100+j*10+k;
@@ -3230,28 +3230,28 @@ static void gent_array6(void)
/* Close VL datatype */
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a dataset */
dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Reclaim the write VL data */
ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void gent_array7(void)
@@ -3271,7 +3271,7 @@ static void gent_array7(void)
/* Initialize array data to write */
for(i=0; i<SPACE1_DIM1; i++)
for(j=0; j<ARRAY1_DIM1; j++) {
- wdata[i][j].p=malloc((i+j+1)*(sizeof(unsigned int)*ARRAY1_DIM1));
+ wdata[i][j].p=HDmalloc((i+j+1)*(sizeof(unsigned int)*ARRAY1_DIM1));
wdata[i][j].len=i+j+1;
for(k=0; k<(i+j+1); k++)
for(l=0; l<ARRAY1_DIM1; l++)
@@ -3292,35 +3292,35 @@ static void gent_array7(void)
/* Close nested array datatype */
ret = H5Tclose(tid3);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create an array datatype to refer to */
tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1);
/* Close VL datatype */
ret = H5Tclose(tid2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a dataset */
dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write dataset to disk */
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Reclaim the write VL data */
ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close Dataset */
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
/* Test the boundary of the display output buffer at the reallocation event */
@@ -3397,30 +3397,30 @@ static void gent_empty(void)
dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Don't write any data */
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(type);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* write out an empty native integer dataset dataset */
dset = H5Dcreate2(file, "Dataset2.0", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Don't write any data */
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* write out an empty native floating-point dataset dataset */
dset = H5Dcreate2(file, "Dataset3.0", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Don't write any data */
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* write out an empty array dataset */
type = H5Tarray_create2(H5T_NATIVE_INT, SPACE1_RANK, dims);
dset = H5Dcreate2(file, "Dataset4.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Don't write any data */
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(type);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* write out an empty compound dataset */
type = H5Tcreate(H5T_COMPOUND,sizeof(empty_struct));
@@ -3430,15 +3430,15 @@ static void gent_empty(void)
dset = H5Dcreate2(file, "Dataset5.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Don't write any data */
ret = H5Dclose(dset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(type);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(space);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(file);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
static void
@@ -3519,7 +3519,7 @@ void gent_split_file(void)
root = H5Gopen2(fid, "/", H5P_DEFAULT);
atype = H5Tcopy(H5T_C_S1);
- H5Tset_size(atype, strlen(meta) + 1);
+ H5Tset_size(atype, HDstrlen(meta) + 1);
H5Tset_strpad(atype, H5T_STR_NULLTERM);
dims[0] = 1;
@@ -3602,7 +3602,7 @@ void gent_multi(void)
HDmemset(memb_name, 0, sizeof memb_name);
HDmemset(memb_addr, 0, sizeof memb_addr);
- assert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES);
+ HDassert(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;
@@ -3720,7 +3720,7 @@ static void gent_char(void)
hid_t sid1; /* Dataspace ID */
hsize_t dims1[1];
- dims1[0] = strlen(wdata);
+ dims1[0] = HDstrlen(wdata);
/* Create file */
fid1 = H5Fcreate(FILE39, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -3886,10 +3886,10 @@ static void write_attr_in(hid_t loc_id,
/* Allocate and initialize VL dataset to write */
buf5[0].len = 1;
- buf5[0].p = malloc(1 * sizeof(int));
+ buf5[0].p = HDmalloc(1 * sizeof(int));
((int *)buf5[0].p)[0] = 1;
buf5[1].len = 2;
- buf5[1].p = malloc(2 * sizeof(int));
+ buf5[1].p = HDmalloc(2 * sizeof(int));
((int *)buf5[1].p)[0] = 2;
((int *)buf5[1].p)[1] = 3;
@@ -3897,9 +3897,9 @@ static void write_attr_in(hid_t loc_id,
tid = H5Tvlen_create(H5T_NATIVE_INT);
aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT);
status = H5Awrite(aid, tid, buf5);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Aclose(aid);
status = H5Tclose(tid);
status = H5Sclose(sid);
@@ -3997,7 +3997,7 @@ static void write_attr_in(hid_t loc_id,
for(j = 0; j < 2; j++) {
int l;
- buf52[i][j].p = malloc((i + 1) * sizeof(int));
+ buf52[i][j].p = HDmalloc((i + 1) * sizeof(int));
buf52[i][j].len = i + 1;
for(l = 0; l < i + 1; l++)
((int *)buf52[i][j].p)[l] = n++;
@@ -4008,9 +4008,9 @@ static void write_attr_in(hid_t loc_id,
tid = H5Tvlen_create(H5T_NATIVE_INT);
aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT);
status = H5Awrite(aid, tid, buf52);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Aclose(aid);
status = H5Tclose(tid);
status = H5Sclose(sid);
@@ -4129,7 +4129,7 @@ static void write_attr_in(hid_t loc_id,
for(k = 0; k < 2; k++) {
int l;
- buf53[i][j][k].p = malloc((i + 1) * sizeof(int));
+ buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int));
buf53[i][j][k].len = i + 1;
for(l = 0; l < i + 1; l++)
((int *)buf53[i][j][k].p)[l] = n++;
@@ -4141,9 +4141,9 @@ static void write_attr_in(hid_t loc_id,
tid = H5Tvlen_create(H5T_NATIVE_INT);
aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT);
status = H5Awrite(aid, tid, buf53);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Aclose(aid);
status = H5Tclose(tid);
status = H5Sclose(sid);
@@ -4328,10 +4328,10 @@ static void write_dset_in(hid_t loc_id,
/* Allocate and initialize VL dataset to write */
buf5[0].len = 1;
- buf5[0].p = malloc( 1 * sizeof(int));
+ buf5[0].p = HDmalloc( 1 * sizeof(int));
((int *)buf5[0].p)[0]=1;
buf5[1].len = 2;
- buf5[1].p = malloc( 2 * sizeof(int));
+ buf5[1].p = HDmalloc( 2 * sizeof(int));
((int *)buf5[1].p)[0]=2;
((int *)buf5[1].p)[1]=3;
@@ -4339,9 +4339,9 @@ static void write_dset_in(hid_t loc_id,
tid = H5Tvlen_create(H5T_NATIVE_INT);
did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dclose(did);
status = H5Tclose(tid);
status = H5Sclose(sid);
@@ -4439,7 +4439,7 @@ static void write_dset_in(hid_t loc_id,
for(j = 0; j < 2; j++) {
int l;
- buf52[i][j].p = malloc((i + 1) * sizeof(int));
+ buf52[i][j].p = HDmalloc((i + 1) * sizeof(int));
buf52[i][j].len = i + 1;
for(l = 0; l < i + 1; l++)
((int *)buf52[i][j].p)[l] = n++;
@@ -4449,9 +4449,9 @@ static void write_dset_in(hid_t loc_id,
tid = H5Tvlen_create(H5T_NATIVE_INT);
did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dclose(did);
status = H5Tclose(tid);
status = H5Sclose(sid);
@@ -4583,7 +4583,7 @@ static void write_dset_in(hid_t loc_id,
for(k = 0; k < 2; k++) {
int l;
- buf53[i][j][k].p = malloc((i + 1) * sizeof(int));
+ buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int));
buf53[i][j][k].len = i + 1;
for(l = 0; l < i + 1; l++)
((int *)buf53[i][j][k].p)[l] = n++;
@@ -4593,9 +4593,9 @@ static void write_dset_in(hid_t loc_id,
tid = H5Tvlen_create(H5T_NATIVE_INT);
did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dclose(did);
status = H5Tclose(tid);
status = H5Sclose(sid);
@@ -4667,7 +4667,7 @@ static void gent_attr_all(void)
sid = H5Screate_simple(1,dims,NULL);
did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
status = H5Sclose(sid);
- assert(status >= 0);
+ HDassert(status >= 0);
/* Create groups */
group_id = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -4692,17 +4692,17 @@ static void gent_attr_all(void)
/* Close */
status = H5Dclose(did);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Gclose(group_id);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Gclose(group2_id);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Gclose(root_id);
- assert(status >= 0);
+ HDassert(status >= 0);
/* Close file */
status = H5Fclose(fid);
- assert(status >= 0);
+ HDassert(status >= 0);
}
@@ -4854,73 +4854,73 @@ static void gent_compound_complex(void)
/* Create the dataspace */
dataspace = H5Screate_simple(F41_RANK, dim, NULL);
- assert(dataspace >= 0);
+ HDassert(dataspace >= 0);
/* Create the file */
datafile = H5Fcreate(FILE41, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT);
- assert(datafile >= 0);
+ HDassert(datafile >= 0);
/* Copy the array data type for the string array */
array_tid = H5Tcopy (H5T_C_S1);
- assert(array_tid >= 0);
+ HDassert(array_tid >= 0);
/* Set the string array size to Variable */
status = H5Tset_size (array_tid,H5T_VARIABLE);
- assert(status >= 0);
+ HDassert(status >= 0);
/* Create the array data type for the string array */
str_array_id = H5Tarray_create2(array_tid, F41_ARRAY_RANK, array_dimb);
- assert(str_array_id >= 0);
+ HDassert(str_array_id >= 0);
/* Copy the array data type for the character array */
array1_tid = H5Tcopy (H5T_C_S1);
- assert(array1_tid >= 0);
+ HDassert(array1_tid >= 0);
/* Set the character array size */
status = H5Tset_size (array1_tid, F41_ARRAY_DIMc);
- assert(status >= 0);
+ HDassert(status >= 0);
/* Create the array data type for the character array */
array2_tid = H5Tarray_create2(H5T_NATIVE_SHORT, F41_ARRAY_RANKd, array_dimd);
- assert(array2_tid >= 0);
+ HDassert(array2_tid >= 0);
/* Create the array data type for the character array */
array4_tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F41_ARRAY_RANK, array_dimf);
- assert(array4_tid >= 0);
+ HDassert(array4_tid >= 0);
/* Create the memory data type */
Array1Structid = H5Tcreate (H5T_COMPOUND, sizeof(Array1Struct));
- assert(Array1Structid >= 0);
+ HDassert(Array1Structid >= 0);
/* Insert the arrays and variables into the structure */
status = H5Tinsert(Array1Structid, "a_name",
HOFFSET(Array1Struct, a), H5T_NATIVE_INT);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tinsert(Array1Structid, "b_name",
HOFFSET(Array1Struct, b), str_array_id);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tinsert(Array1Structid, "c_name",
HOFFSET(Array1Struct, c), array1_tid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tinsert(Array1Structid, "d_name",
HOFFSET(Array1Struct, d), array2_tid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tinsert(Array1Structid, "e_name",
HOFFSET(Array1Struct, e), H5T_NATIVE_FLOAT);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tinsert(Array1Structid, "f_name",
HOFFSET(Array1Struct, f), array4_tid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tinsert(Array1Structid, "g_name",
HOFFSET(Array1Struct, g), H5T_NATIVE_CHAR);
- assert(status >= 0);
+ HDassert(status >= 0);
/* Create the dataset */
dataset = H5Dcreate2(datafile, F41_DATASETNAME, Array1Structid,
@@ -4929,35 +4929,35 @@ static void gent_compound_complex(void)
/* Write data to the dataset */
status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL,
H5P_DEFAULT, Array1);
- assert(status >= 0);
+ HDassert(status >= 0);
/* Release resources */
status = H5Tclose(Array1Structid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tclose(array_tid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tclose(array1_tid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tclose(array2_tid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tclose(array4_tid);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Tclose(str_array_id);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Sclose(dataspace);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Dclose(dataset);
- assert(status >= 0);
+ HDassert(status >= 0);
status = H5Fclose(datafile);
- assert(status >= 0);
+ HDassert(status >= 0);
}
@@ -4974,7 +4974,7 @@ static void gent_named_dtype_attr(void)
/* Create a file */
fid=H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>0);
+ HDassert(fid>0);
/*-------------------------------------------------------------------------
* datatype
@@ -4983,27 +4983,27 @@ static void gent_named_dtype_attr(void)
/* Create a datatype to commit and use */
tid=H5Tcopy(H5T_NATIVE_INT);
- assert(tid>0);
+ HDassert(tid>0);
/* Commit datatype to file */
ret = H5Tcommit2(fid, F42_TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a hard link to the datatype */
ret = H5Lcreate_hard(fid, F42_TYPENAME, fid, F42_LINKNAME, H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Create a scalar dataspace used for all objects */
sid = H5Screate(H5S_SCALAR);
- assert(sid > 0);
+ HDassert(sid > 0);
/* Create attribute on commited datatype */
aid = H5Acreate2(tid, F42_ATTRNAME, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT);
- assert(aid > 0);
+ HDassert(aid > 0);
/* Write data into the attribute */
ret = H5Awrite(aid, H5T_NATIVE_INT, &data);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* dataset
@@ -5012,15 +5012,15 @@ static void gent_named_dtype_attr(void)
/* Create dataset */
did = H5Dcreate2(fid, F42_DSETNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(did > 0);
+ HDassert(did > 0);
/* Create attribute on dataset */
aid = H5Acreate2(did, F42_ATTRNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
- assert(aid > 0);
+ HDassert(aid > 0);
/* Write data into the attribute */
ret = H5Awrite(aid, H5T_NATIVE_INT, &data);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* group
@@ -5029,15 +5029,15 @@ static void gent_named_dtype_attr(void)
/* Create a group */
gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(gid > 0);
+ HDassert(gid > 0);
/* Create attribute on group */
aid = H5Acreate2(gid, F42_ATTRNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
- assert(aid > 0);
+ HDassert(aid > 0);
/* Write data into the attribute */
ret = H5Awrite(aid, H5T_NATIVE_INT, &data);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* close
@@ -5046,23 +5046,23 @@ static void gent_named_dtype_attr(void)
/* Close attribute */
ret = H5Aclose(aid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close dataset */
ret = H5Dclose(did);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close dataspace */
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close datatype */
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Close file */
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
@@ -5109,7 +5109,7 @@ static void gent_null_space(void)
static void gent_zero_dim_size(void)
{
hid_t fid, root, dataset, space, attr;
- hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2};
+ hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2};
int dset_buf = 10;
int point = 4;
@@ -5199,25 +5199,25 @@ make_external(hid_t fid)
dcpl = H5Pcreate(H5P_DATASET_CREATE);
ret = H5Pset_external(dcpl, "ext1.bin", (off_t)0, size);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_external(dcpl, "ext2.bin", (off_t)0, size);
- assert(ret >= 0);
+ HDassert(ret >= 0);
sid = H5Screate_simple(1, cur_size, max_size);
- assert(ret >= 0);
+ HDassert(ret >= 0);
dsid = H5Dcreate2(fid, "external", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
H5Dclose(dsid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
H5Pclose(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
/*-------------------------------------------------------------------------
@@ -5250,7 +5250,7 @@ static void gent_filters(void)
/* create a file */
fid = H5Fcreate(FILE44, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ HDassert(fid>=0);
/* create a space */
sid = H5Screate_simple(SPACE2_RANK, dims1, NULL);
@@ -5264,34 +5264,34 @@ static void gent_filters(void)
*-------------------------------------------------------------------------
*/
ret = H5Pset_layout(dcpl, H5D_COMPACT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"compact",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Oset_comment_by_name(fid, "compact", "This is a dataset with compact storage", H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_layout(dcpl, H5D_CONTIGUOUS);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"contiguous",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Oset_comment_by_name(fid, "contiguous", "This is a dataset with contiguous storage", H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_layout(dcpl, H5D_CHUNKED);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"chunked",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Oset_comment_by_name(fid, "chunked", "This is a dataset with chunked storage", H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* make several dataset with filters
@@ -5300,7 +5300,7 @@ static void gent_filters(void)
/* set up chunk */
ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* SZIP
@@ -5310,14 +5310,14 @@ static void gent_filters(void)
if(h5tools_can_encode(H5Z_FILTER_SZIP) == 1) {
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* set szip data */
ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"szip",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
#endif /* H5_HAVE_FILTER_SZIP */
@@ -5328,14 +5328,14 @@ static void gent_filters(void)
#if defined (H5_HAVE_FILTER_DEFLATE)
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* set deflate data */
ret = H5Pset_deflate(dcpl, 9);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"deflate",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
@@ -5346,14 +5346,14 @@ static void gent_filters(void)
#if defined (H5_HAVE_FILTER_SHUFFLE)
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* set the shuffle filter */
ret = H5Pset_shuffle(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"shuffle",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
@@ -5364,14 +5364,14 @@ static void gent_filters(void)
#if defined (H5_HAVE_FILTER_FLETCHER32)
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* set the checksum filter */
ret = H5Pset_fletcher32(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"fletcher32",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
/*-------------------------------------------------------------------------
@@ -5381,16 +5381,16 @@ static void gent_filters(void)
#if defined (H5_HAVE_FILTER_NBIT)
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* set the checksum filter */
ret = H5Pset_nbit(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
tid=H5Tcopy(H5T_NATIVE_INT);
H5Tset_precision(tid,H5Tget_size(tid)-1);
ret=make_dset(fid,"nbit",sid,tid,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
/*-------------------------------------------------------------------------
@@ -5400,14 +5400,14 @@ static void gent_filters(void)
#if defined (H5_HAVE_FILTER_SCALEOFFSET)
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* set the scaleoffset filter */
ret = H5Pset_scaleoffset(dcpl,H5Z_SO_INT,(int)H5Tget_size(H5T_NATIVE_INT));
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"scaleoffset",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
/*-------------------------------------------------------------------------
@@ -5416,12 +5416,12 @@ static void gent_filters(void)
*/
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#if defined (H5_HAVE_FILTER_SHUFFLE)
/* set the shuffle filter */
ret = H5Pset_shuffle(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
#ifdef H5_HAVE_FILTER_SZIP
@@ -5429,30 +5429,30 @@ static void gent_filters(void)
szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK;
/* set szip data */
ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
#endif /* H5_HAVE_FILTER_SZIP */
#if defined (H5_HAVE_FILTER_DEFLATE)
/* set deflate data */
ret = H5Pset_deflate(dcpl, 5);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
#if defined (H5_HAVE_FILTER_FLETCHER32)
/* set the checksum filter */
ret = H5Pset_fletcher32(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
#if defined (H5_HAVE_FILTER_NBIT)
/* set the nbit filter */
ret = H5Pset_nbit(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
#endif
ret=make_dset(fid,"all",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
@@ -5461,20 +5461,20 @@ static void gent_filters(void)
*/
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Zregister (H5Z_MYFILTER);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_filter (dcpl, MYFILTER_ID, 0, 0, NULL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"myfilter",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* remove the filters from the dcpl */
ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* make an external dataset
@@ -5487,27 +5487,27 @@ static void gent_filters(void)
*-------------------------------------------------------------------------
*/
ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"alloc_time_early",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* H5D_ALLOC_TIME_INCR
*-------------------------------------------------------------------------
*/
ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"alloc_time_incr",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* H5D_ALLOC_TIME_LATE
*-------------------------------------------------------------------------
*/
ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"alloc_time_late",sid,H5T_NATIVE_INT,dcpl,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* commit a H5G_TYPE type with a comment
@@ -5515,26 +5515,26 @@ static void gent_filters(void)
*/
tid = H5Tcopy(H5T_STD_B8LE);
ret = H5Tcommit2(fid, "mytype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Oset_comment_by_name(fid, "mytype", "This is a commited datatype", H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pclose(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
@@ -5601,7 +5601,7 @@ static void gent_fcontents(void)
/* create a file */
fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ HDassert(fid>=0);
write_dset(fid,1,dims,"dset",H5T_NATIVE_INT,buf);
@@ -5633,30 +5633,30 @@ static void gent_fcontents(void)
/* hard link to "dset" */
ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset3", H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* hard link to "dset" */
ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset4", H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* soft link to itself */
ret = H5Lcreate_soft("mylink", fid, "mylink", H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* soft link to "dset" */
ret = H5Lcreate_soft("/dset", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* dangling external link */
ret = H5Lcreate_external("fname", "oname", fid, "extlink", H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* dangling udlink */
ret = H5Lcreate_ud(fid, "udlink", (H5L_type_t)MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* datatypes
@@ -5664,20 +5664,20 @@ static void gent_fcontents(void)
*/
tid = H5Tcopy(H5T_NATIVE_INT);
ret = H5Tcommit2(fid, "mytype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* no name datatype */
tid = H5Tcopy(H5T_NATIVE_INT);
ret = H5Tcommit2(fid, "mytype2", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
write_dset(fid, 1, dims, "dsetmytype2", tid, buf);
ret = H5Ldelete(fid, "mytype2", H5P_DEFAULT);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
@@ -5687,16 +5687,16 @@ static void gent_fcontents(void)
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* create a file for the bootblock test */
fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ HDassert(fid>=0);
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
/*-------------------------------------------------------------------------
@@ -5734,7 +5734,7 @@ static void gent_fvalues(void)
/* create a file */
fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ HDassert(fid>=0);
/* create a space */
sid = H5Screate_simple(1, dims, NULL);
@@ -5748,42 +5748,42 @@ static void gent_fvalues(void)
*-------------------------------------------------------------------------
*/
ret = H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"fill_time_ifset",sid,H5T_NATIVE_INT,dcpl,buf);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* H5D_FILL_TIME_NEVER
*-------------------------------------------------------------------------
*/
ret = H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"fill_time_never",sid,H5T_NATIVE_INT,dcpl,buf);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* H5D_FILL_TIME_ALLOC
*-------------------------------------------------------------------------
*/
ret = H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"fill_time_alloc",sid,H5T_NATIVE_INT,dcpl,buf);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pclose(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* dataset with no fill value
@@ -5800,23 +5800,23 @@ static void gent_fvalues(void)
H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_CHAR);
H5Tinsert(tid, "b", HOFFSET(c_t, b), H5T_NATIVE_DOUBLE);
ret = H5Pset_fill_value(dcpl, tid, &fillval2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret=make_dset(fid,"fill_compound",sid,tid,dcpl,buf2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Pclose(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* dataset with a H5T_VLEN fill value
*-------------------------------------------------------------------------
*/
buf3[0].len = 1;
- buf3[0].p = malloc( 1 * sizeof(int));
+ buf3[0].p = HDmalloc( 1 * sizeof(int));
((int *)buf3[0].p)[0]=1;
buf3[1].len = 2;
- buf3[1].p = malloc(2 * sizeof(int));
+ buf3[1].p = HDmalloc(2 * sizeof(int));
((int *)buf3[1].p)[0] = 2;
((int *)buf3[1].p)[1] = 3;
@@ -5825,17 +5825,17 @@ static void gent_fvalues(void)
fillval3.p=NULL; fillval3.len=0;
ret = H5Pset_fill_value(dcpl, tid, &fillval3);
- assert(ret >= 0);
+ HDassert(ret >= 0);
did = H5Dcreate2(fid, "fill_vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
ret = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf3);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf3);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dclose(did);
ret = H5Tclose(tid);
ret = H5Pclose(dcpl);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* dataset with a H5T_ARRAY fill value
@@ -5851,9 +5851,9 @@ static void gent_fvalues(void)
*-------------------------------------------------------------------------
*/
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
@@ -5896,7 +5896,7 @@ static void gent_string(void)
/* create a file */
fid = H5Fcreate(FILE49, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ HDassert(fid>=0);
/*-------------------------------------------------------------------------
* str1
@@ -5905,11 +5905,11 @@ static void gent_string(void)
tid=H5Tcopy(H5T_C_S1);
ret = H5Tset_size(tid, sizeof(buf1));
- assert(ret >= 0);
+ HDassert(ret >= 0);
write_dset(fid,1,dims1,"str1",tid,buf1);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* str2
@@ -5918,16 +5918,16 @@ static void gent_string(void)
sid = H5Screate_simple(SPACE1_RANK, dims2, NULL);
tid = H5Tcopy(H5T_C_S1);
ret = H5Tset_size(tid, H5T_VARIABLE);
- assert(ret >= 0);
+ HDassert(ret >= 0);
did = H5Dcreate2(fid, "str2", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
ret = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Dclose(did);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* str3
@@ -5940,13 +5940,13 @@ static void gent_string(void)
H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_INT);
H5Tinsert(tid, "str", HOFFSET(c_t, str), str_tid );
ret=make_dset(fid,"str3",sid,tid,H5P_DEFAULT,&buf3);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Tclose(str_tid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* str4
@@ -5955,14 +5955,14 @@ static void gent_string(void)
sid = H5Screate_simple(SPACE1_RANK, dims4, NULL);
ret=make_dset(fid,"str4",sid,H5T_NATIVE_CHAR,H5P_DEFAULT,buf4);
ret = H5Sclose(sid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
@@ -6005,7 +6005,7 @@ static void gent_aindices(void)
/* create a file */
fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ HDassert(fid>=0);
/*-------------------------------------------------------------------------
* root datasets
@@ -6038,7 +6038,7 @@ static void gent_aindices(void)
*-------------------------------------------------------------------------
*/
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
}
@@ -6060,34 +6060,34 @@ static void gent_longlinks(void)
/* Create files */
fid = H5Fcreate(FILE51, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid >= 0);
+ HDassert(fid >= 0);
/* Create group with short name in file (used as target for hard links) */
gid = H5Gcreate2(fid, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(gid >= 0);
+ HDassert(gid >= 0);
/* Construct very long file name */
objname = (char*) HDmalloc((size_t)(F51_MAX_NAME_LEN + 1));
- assert(objname);
+ HDassert(objname);
for(u = 0; u < F51_MAX_NAME_LEN; u++)
objname[u] = 'a';
objname[F51_MAX_NAME_LEN] = '\0';
/* Create hard link to existing object */
- assert(H5Lcreate_hard(fid, "grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) >= 0);
+ HDassert(H5Lcreate_hard(fid, "grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) >= 0);
/* Create soft link to existing object */
objname[0] = 'b';
- assert(H5Lcreate_soft("grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) >= 0);
+ HDassert(H5Lcreate_soft("grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) >= 0);
/* Create group with long name in existing group */
gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(gid2 >= 0);
+ HDassert(gid2 >= 0);
/* Close objects */
- assert(H5Gclose(gid2) >= 0);
- assert(H5Gclose(gid) >= 0);
- assert(H5Fclose(fid) >= 0);
+ HDassert(H5Gclose(gid2) >= 0);
+ HDassert(H5Gclose(gid) >= 0);
+ HDassert(H5Fclose(fid) >= 0);
/* Release memory */
HDfree(objname);
@@ -6237,7 +6237,7 @@ gent_bigdims(void)
/* create a file */
fid = H5Fcreate(FILE56, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid >= 0);
+ HDassert(fid >= 0);
/* create dataset */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
@@ -6263,7 +6263,7 @@ gent_bigdims(void)
if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0)
goto out;
- buf=(char *) malloc((unsigned)(nelmts*size));
+ buf=(char *) HDmalloc((unsigned)(nelmts*size));
for(i=0, c=0; i<nelmts; i++, c++)
{
@@ -6276,7 +6276,7 @@ gent_bigdims(void)
goto out;
- free(buf);
+ HDfree(buf);
buf=NULL;
/* close */
@@ -6297,7 +6297,7 @@ gent_bigdims(void)
did = -1;
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
return;
@@ -6331,20 +6331,20 @@ gent_hyperslab(void)
double *buf;
int i, ret;
- buf = (double*) malloc(32 * 4097 * sizeof(double) );
+ buf = (double*) HDmalloc(32 * 4097 * sizeof(double) );
for(i = 0; i < 32 * 4097; i++)
buf[i] = 1;
/* create a file */
fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ HDassert(fid>=0);
write_dset(fid,2,dims,"stripmine",H5T_NATIVE_DOUBLE,buf);
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
- free(buf);
+ HDfree(buf);
}
/*-------------------------------------------------------------------------
@@ -6913,8 +6913,8 @@ gent_extlinks(void)
* Three more datasets of 1, 2 and 4 bytes of signed int types are created.
* Fill them with raw data such that no bit will be all zero in a dataset.
* A dummy dataset of double type is created for failure test.
- * Created: Albert Cheng, 2010/5/10.
- * Modified:
+ * Created: Albert Cheng, 2010/5/10.
+ * Modified: Allen Byrne, 2011/1/5 Use file to test Signed/Unsigned datatypes
*-------------------------------------------------------------------------
*/
static void
@@ -6940,13 +6940,13 @@ gent_packedbits(void)
space = H5Screate_simple(2, dims, NULL);
dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- valu8bits = (uint8_t) ~0u; /* all 1s */
+ valu8bits = (uint8_t) ~0u; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dsetu8[i][0] = valu8bits;
- for(j = 1; j < dims[1]; j++) {
+ dsetu8[i][0] = valu8bits;
+ for(j = 1; j < dims[1]; j++) {
dsetu8[i][j] = dsetu8[i][j-1] << 1;
- }
- valu8bits <<= 1;
+ }
+ valu8bits <<= 1;
}
H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8);
@@ -6960,11 +6960,11 @@ gent_packedbits(void)
valu16bits = (uint16_t) ~0u; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dsetu16[i][0] = valu16bits;
- for(j = 1; j < dims[1]; j++) {
+ dsetu16[i][0] = valu16bits;
+ for(j = 1; j < dims[1]; j++) {
dsetu16[i][j] = dsetu16[i][j-1] << 1;
- }
- valu16bits <<= 1;
+ }
+ valu16bits <<= 1;
}
H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16);
@@ -6978,10 +6978,10 @@ gent_packedbits(void)
valu32bits = (uint32_t) ~0u; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dsetu32[i][0] = valu32bits;
- for(j = 1; j < dims[1]; j++) {
+ dsetu32[i][0] = valu32bits;
+ for(j = 1; j < dims[1]; j++) {
dsetu32[i][j] = dsetu32[i][j-1] << 1;
- }
+ }
valu32bits <<= 1;
}
@@ -6996,11 +6996,11 @@ gent_packedbits(void)
valu64bits = (uint64_t) ~0Lu; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dsetu64[i][0] = valu64bits;
- for(j = 1; j < dims[1]; j++) {
+ dsetu64[i][0] = valu64bits;
+ for(j = 1; j < dims[1]; j++) {
dsetu64[i][j] = dsetu64[i][j-1] << 1;
- }
- valu64bits <<= 1;
+ }
+ valu64bits <<= 1;
}
H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64);
@@ -7014,11 +7014,11 @@ gent_packedbits(void)
val8bits = (int8_t) ~0; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dset8[i][0] = val8bits;
- for(j = 1; j < dims[1]; j++) {
+ dset8[i][0] = val8bits;
+ for(j = 1; j < dims[1]; j++) {
dset8[i][j] = dset8[i][j-1] << 1;
- }
- val8bits <<= 1;
+ }
+ val8bits <<= 1;
}
H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8);
@@ -7032,11 +7032,11 @@ gent_packedbits(void)
val16bits = (int16_t) ~0; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dset16[i][0] = val16bits;
- for(j = 1; j < dims[1]; j++) {
+ dset16[i][0] = val16bits;
+ for(j = 1; j < dims[1]; j++) {
dset16[i][j] = dset16[i][j-1] << 1;
- }
- val16bits <<= 1;
+ }
+ val16bits <<= 1;
}
H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16);
@@ -7050,11 +7050,11 @@ gent_packedbits(void)
val32bits = (int32_t) ~0; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dset32[i][0] = val32bits;
- for(j = 1; j < dims[1]; j++) {
+ dset32[i][0] = val32bits;
+ for(j = 1; j < dims[1]; j++) {
dset32[i][j] = dset32[i][j-1] << 1;
- }
- val32bits <<= 1;
+ }
+ val32bits <<= 1;
}
H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32);
@@ -7068,11 +7068,11 @@ gent_packedbits(void)
val64bits = (int64_t) ~0L; /* all 1s */
for(i = 0; i < dims[0]; i++){
- dset64[i][0] = val64bits;
- for(j = 1; j < dims[1]; j++) {
+ dset64[i][0] = val64bits;
+ for(j = 1; j < dims[1]; j++) {
dset64[i][j] = dset64[i][j-1] << 1;
- }
- val64bits <<= 1;
+ }
+ val64bits <<= 1;
}
H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64);
@@ -7095,7 +7095,6 @@ gent_packedbits(void)
H5Fclose(fid);
}
-
/*-------------------------------------------------------------------------
* Function: main
*
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 8cac31f..03f399b 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -136,6 +136,7 @@ $SRC_H5DUMP_TESTFILES/tmulti-r.h5
$SRC_H5DUMP_TESTFILES/tmulti-s.h5
$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.h5
$SRC_H5DUMP_TESTFILES/tnestedcomp.h5
+$SRC_H5DUMP_TESTFILES/tno-subset.h5
$SRC_H5DUMP_TESTFILES/tnullspace.h5
$SRC_H5DUMP_TESTFILES/zerodim.h5
$SRC_H5DUMP_TESTFILES/torderattr.h5
@@ -244,7 +245,7 @@ $SRC_H5DUMP_TESTFILES/tmulti.ddl
$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.ddl
$SRC_H5DUMP_TESTFILES/tnestcomp-1.ddl
$SRC_H5DUMP_TESTFILES/tnbit.ddl
-$SRC_H5DUMP_TESTFILES/tnofilename.ddl
+$SRC_H5DUMP_TESTFILES/tno-subset.ddl
$SRC_H5DUMP_TESTFILES/tnullspace.ddl
$SRC_H5DUMP_TESTFILES/zerodim.ddl
$SRC_H5DUMP_TESTFILES/tordergr1.ddl
@@ -282,6 +283,7 @@ $SRC_H5DUMP_TESTFILES/tvlstr.ddl
$SRC_H5DUMP_TESTFILES/tvms.ddl
$SRC_H5DUMP_TESTFILES/h5dump-help.txt
$SRC_H5DUMP_TESTFILES/out3.h5import
+$SRC_H5DUMP_TESTFILES/tnofilename-with-packed-bits.ddl
$SRC_H5DUMP_TESTFILES/tpbitsArray.ddl
$SRC_H5DUMP_TESTFILES/tpbitsCompound.ddl
$SRC_H5DUMP_TESTFILES/tpbitsIncomplete.ddl
@@ -484,7 +486,7 @@ TOOLTEST() {
TESTING $DUMPER $@
(
cd $TESTDIR
- $RUNSERIAL $DUMPER_BIN $@
+ $RUNSERIAL $DUMPER_BIN "$@"
) >$actual 2>$actual_err
# save actual and actual_err in case they are needed later.
@@ -531,7 +533,7 @@ TOOLTEST2() {
TESTING $DUMPER $@
(
cd $TESTDIR
- $RUNSERIAL $DUMPER_BIN $@
+ $RUNSERIAL $DUMPER_BIN "$@"
) >$actual 2>$actual_err
cat $actual_err >> $actual
@@ -582,7 +584,7 @@ TOOLTEST3() {
TESTING $DUMPER $@
(
cd $TESTDIR
- $RUNSERIAL $DUMPER_BIN $@
+ $RUNSERIAL $DUMPER_BIN "$@"
) >$actual 2>$actual_err
# save actual and actual_err in case they are needed later.
@@ -696,175 +698,178 @@ IMPORTTEST()
# prepare for test
COPY_TESTFILES_TO_TESTDIR
+#TOOLTEST h5dump-help.txt -h
+
# test for signed/unsigned datasets
-TOOLTEST packedbits.ddl packedbits.h5
+TOOLTEST packedbits.ddl --enable-error-stack packedbits.h5
# test for displaying groups
-TOOLTEST tgroup-1.ddl tgroup.h5
+TOOLTEST tgroup-1.ddl --enable-error-stack tgroup.h5
# test for displaying the selected groups
TOOLTEST tgroup-2.ddl --group=/g2 --group / -g /y tgroup.h5
# test for displaying simple space datasets
-TOOLTEST tdset-1.ddl tdset.h5
+TOOLTEST tdset-1.ddl --enable-error-stack tdset.h5
# test for displaying selected datasets
TOOLTEST tdset-2.ddl -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5
# test for displaying attributes
-TOOLTEST tattr-1.ddl tattr.h5
+TOOLTEST tattr-1.ddl --enable-error-stack tattr.h5
# test for displaying the selected attributes of string type and scalar space
-TOOLTEST tattr-2.ddl -a /attr1 --attribute /attr4 --attribute=/attr5 tattr.h5
+TOOLTEST tattr-2.ddl --enable-error-stack -a /attr1 --attribute /attr4 --attribute=/attr5 tattr.h5
# test for header and error messages
TOOLTEST tattr-3.ddl --header -a /attr2 --attribute=/attr tattr.h5
# test for displaying at least 9 attributes on root from a BE machine
-TOOLTEST tattr-4_be.ddl tattr4_be.h5
+TOOLTEST tattr-4_be.ddl --enable-error-stack tattr4_be.h5
# test for displaying attributes in shared datatype (also in group and dataset)
-TOOLTEST tnamed_dtype_attr.ddl tnamed_dtype_attr.h5
+TOOLTEST tnamed_dtype_attr.ddl --enable-error-stack tnamed_dtype_attr.h5
# test for displaying soft links and user-defined links
-TOOLTEST tslink-1.ddl tslink.h5
-TOOLTEST tudlink-1.ddl tudlink.h5
+TOOLTEST tslink-1.ddl --enable-error-stack tslink.h5
+TOOLTEST tudlink-1.ddl --enable-error-stack tudlink.h5
# test for displaying the selected link
-TOOLTEST tslink-2.ddl -l slink2 tslink.h5
-TOOLTEST tudlink-2.ddl -l udlink2 tudlink.h5
+TOOLTEST tslink-2.ddl --enable-error-stack -l slink2 tslink.h5
+TOOLTEST tudlink-2.ddl --enable-error-stack -l udlink2 tudlink.h5
# tests for hard links
-TOOLTEST thlink-1.ddl thlink.h5
-TOOLTEST thlink-2.ddl -d /g1/dset2 --dataset /dset1 --dataset=/g1/g1.1/dset3 thlink.h5
-TOOLTEST thlink-3.ddl -d /g1/g1.1/dset3 --dataset /g1/dset2 --dataset=/dset1 thlink.h5
-TOOLTEST thlink-4.ddl -g /g1 thlink.h5
-TOOLTEST thlink-5.ddl -d /dset1 -g /g2 -d /g1/dset2 thlink.h5
+TOOLTEST thlink-1.ddl --enable-error-stack thlink.h5
+TOOLTEST thlink-2.ddl --enable-error-stack -d /g1/dset2 --dataset /dset1 --dataset=/g1/g1.1/dset3 thlink.h5
+TOOLTEST thlink-3.ddl --enable-error-stack -d /g1/g1.1/dset3 --dataset /g1/dset2 --dataset=/dset1 thlink.h5
+TOOLTEST thlink-4.ddl --enable-error-stack -g /g1 thlink.h5
+TOOLTEST thlink-5.ddl --enable-error-stack -d /dset1 -g /g2 -d /g1/dset2 thlink.h5
# tests for compound data types
-TOOLTEST tcomp-1.ddl tcompound.h5
+TOOLTEST tcomp-1.ddl --enable-error-stack tcompound.h5
# test for named data types
-TOOLTEST tcomp-2.ddl -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5
+TOOLTEST tcomp-2.ddl --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5
# test for unamed type
+# JIRA HDFFV-7936 TOOLTEST tcomp-3.ddl --enable-error-stack -t /#6632 -g /group2 tcompound.h5
TOOLTEST tcomp-3.ddl -t /#6632 -g /group2 tcompound.h5
# test complicated compound datatype
-TOOLTEST tcomp-4.ddl tcompound_complex.h5
+TOOLTEST tcomp-4.ddl --enable-error-stack tcompound_complex.h5
#test for the nested compound type
-TOOLTEST tnestcomp-1.ddl tnestedcomp.h5
+TOOLTEST tnestcomp-1.ddl --enable-error-stack tnestedcomp.h5
# test for options
+# JIRA HDFFV-7936 TOOLTEST tall-1.ddl --enable-error-stack tall.h5
TOOLTEST tall-1.ddl tall.h5
-TOOLTEST tall-2.ddl --header -g /g1/g1.1 -a attr2 tall.h5
-TOOLTEST tall-3.ddl -d /g2/dset2.1 -l /g1/g1.2/g1.2.1/slink tall.h5
+TOOLTEST tall-2.ddl --enable-error-stack --header -g /g1/g1.1 -a attr2 tall.h5
+TOOLTEST tall-3.ddl --enable-error-stack -d /g2/dset2.1 -l /g1/g1.2/g1.2.1/slink tall.h5
# test for loop detection
-TOOLTEST tloop-1.ddl tloop.h5
+TOOLTEST tloop-1.ddl --enable-error-stack tloop.h5
# test for string
-TOOLTEST tstr-1.ddl tstr.h5
-TOOLTEST tstr-2.ddl tstr2.h5
+TOOLTEST tstr-1.ddl --enable-error-stack tstr.h5
+TOOLTEST tstr-2.ddl --enable-error-stack tstr2.h5
# test for file created by Lib SAF team
-TOOLTEST tsaf.ddl tsaf.h5
+TOOLTEST tsaf.ddl --enable-error-stack tsaf.h5
# test for file with variable length data
-TOOLTEST tvldtypes1.ddl tvldtypes1.h5
-TOOLTEST tvldtypes2.ddl tvldtypes2.h5
-TOOLTEST tvldtypes3.ddl tvldtypes3.h5
-TOOLTEST tvldtypes4.ddl tvldtypes4.h5
-TOOLTEST tvldtypes5.ddl tvldtypes5.h5
+TOOLTEST tvldtypes1.ddl --enable-error-stack tvldtypes1.h5
+TOOLTEST tvldtypes2.ddl --enable-error-stack tvldtypes2.h5
+TOOLTEST tvldtypes3.ddl --enable-error-stack tvldtypes3.h5
+TOOLTEST tvldtypes4.ddl --enable-error-stack tvldtypes4.h5
+TOOLTEST tvldtypes5.ddl --enable-error-stack tvldtypes5.h5
#test for file with variable length string data
-TOOLTEST tvlstr.ddl tvlstr.h5
+TOOLTEST tvlstr.ddl --enable-error-stack tvlstr.h5
# test for files with array data
-TOOLTEST tarray1.ddl tarray1.h5
+TOOLTEST tarray1.ddl --enable-error-stack tarray1.h5
# # added for bug# 2092 - tarray1_big.h
+# JIRA HDFFV-7936 TOOLTEST tarray1_big.ddl --enable-error-stack -R tarray1_big.h5
TOOLTEST tarray1_big.ddl -R tarray1_big.h5
-TOOLTEST tarray2.ddl tarray2.h5
-TOOLTEST tarray3.ddl tarray3.h5
-TOOLTEST tarray4.ddl tarray4.h5
-TOOLTEST tarray5.ddl tarray5.h5
-TOOLTEST tarray6.ddl tarray6.h5
-TOOLTEST tarray7.ddl tarray7.h5
-TOOLTEST tarray8.ddl tarray8.h5
+TOOLTEST tarray2.ddl --enable-error-stack tarray2.h5
+TOOLTEST tarray3.ddl --enable-error-stack tarray3.h5
+TOOLTEST tarray4.ddl --enable-error-stack tarray4.h5
+TOOLTEST tarray5.ddl --enable-error-stack tarray5.h5
+TOOLTEST tarray6.ddl --enable-error-stack tarray6.h5
+TOOLTEST tarray7.ddl --enable-error-stack tarray7.h5
+TOOLTEST tarray8.ddl --enable-error-stack tarray8.h5
# test for files with empty data
-TOOLTEST tempty.ddl tempty.h5
+TOOLTEST tempty.ddl --enable-error-stack tempty.h5
# test for files with groups that have comments
-TOOLTEST tgrp_comments.ddl tgrp_comments.h5
+TOOLTEST tgrp_comments.ddl --enable-error-stack tgrp_comments.h5
# test the --filedriver flag
-TOOLTEST tsplit_file.ddl --filedriver=split tsplit_file
-TOOLTEST tfamily.ddl --filedriver=family tfamily%05d.h5
-TOOLTEST tmulti.ddl --filedriver=multi tmulti
+TOOLTEST tsplit_file.ddl --enable-error-stack --filedriver=split tsplit_file
+TOOLTEST tfamily.ddl --enable-error-stack --filedriver=family tfamily%05d.h5
+TOOLTEST tmulti.ddl --enable-error-stack --filedriver=multi tmulti
# test for files with group names which reach > 1024 bytes in size
-TOOLTEST tlarge_objname.ddl -w157 tlarge_objname.h5
+TOOLTEST tlarge_objname.ddl --enable-error-stack -w157 tlarge_objname.h5
# test '-A' to suppress data but print attr's
+# JIRA HDFFV-7936 TOOLTEST tall-2A.ddl --enable-error-stack -A tall.h5
TOOLTEST tall-2A.ddl -A tall.h5
# test '-r' to print attributes in ASCII instead of decimal
+# JIRA HDFFV-7936 TOOLTEST tall-2B.ddl --enable-error-stack -A -r tall.h5
TOOLTEST tall-2B.ddl -A -r tall.h5
# test Subsetting
-TOOLTEST tall-4s.ddl --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5
-TOOLTEST tall-5s.ddl -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5
-TOOLTEST tdset-3s.ddl -d "/dset1[1,1;;;]" tdset.h5
-
+TOOLTEST tall-4s.ddl --enable-error-stack --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5
+TOOLTEST tall-5s.ddl --enable-error-stack -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5
+TOOLTEST tdset-3s.ddl --enable-error-stack -d "/dset1[1,1;;;]" tdset.h5
+TOOLTEST tno-subset.ddl --no-compact-subset -d "AHFINDERDIRECT::ah_centroid_t[0] it=0 tl=0" tno-subset.h5
# test printing characters in ASCII instead of decimal
-TOOLTEST tchar1.ddl -r tchar.h5
-
-# test failure handling
-# Missing file name
-TOOLTEST tnofilename.ddl
+TOOLTEST tchar1.ddl --enable-error-stack -r tchar.h5
# rev. 2004
# tests for super block
-TOOLTEST tboot1.ddl -H -B -d dset tfcontents1.h5
-TOOLTEST tboot2.ddl -B tfcontents2.h5
+TOOLTEST tboot1.ddl --enable-error-stack -H -B -d dset tfcontents1.h5
+TOOLTEST tboot2.ddl --enable-error-stack -B tfcontents2.h5
# test -p with a non existing dataset
TOOLTEST tperror.ddl -p -d bogus tfcontents1.h5
# test for file contents
-TOOLTEST tcontents.ddl -n tfcontents1.h5
+TOOLTEST tcontents.ddl --enable-error-stack -n tfcontents1.h5
# tests for storage layout
# compact
-TOOLTEST tcompact.ddl -H -p -d compact tfilters.h5
+TOOLTEST tcompact.ddl --enable-error-stack -H -p -d compact tfilters.h5
# contiguous
-TOOLTEST tcontiguos.ddl -H -p -d contiguous tfilters.h5
+TOOLTEST tcontiguos.ddl --enable-error-stack -H -p -d contiguous tfilters.h5
# chunked
-TOOLTEST tchunked.ddl -H -p -d chunked tfilters.h5
+TOOLTEST tchunked.ddl --enable-error-stack -H -p -d chunked tfilters.h5
# external
-TOOLTEST texternal.ddl -H -p -d external tfilters.h5
+TOOLTEST texternal.ddl --enable-error-stack -H -p -d external tfilters.h5
# fill values
-TOOLTEST tfill.ddl -p tfvalues.h5
+TOOLTEST tfill.ddl --enable-error-stack -p tfvalues.h5
# several datatype, with references , print path
-TOOLTEST treference.ddl tattr2.h5
+TOOLTEST treference.ddl --enable-error-stack tattr2.h5
# escape/not escape non printable characters
-TOOLTEST tstringe.ddl -e tstr3.h5
-TOOLTEST tstring.ddl tstr3.h5
+TOOLTEST tstringe.ddl --enable-error-stack -e tstr3.h5
+TOOLTEST tstring.ddl --enable-error-stack tstr3.h5
# char data as ASCII with non escape
-TOOLTEST tstring2.ddl -r -d str4 tstr3.h5
+TOOLTEST tstring2.ddl --enable-error-stack -r -d str4 tstr3.h5
# array indices print/not print
-TOOLTEST tindicesyes.ddl taindices.h5
-TOOLTEST tindicesno.ddl -y taindices.h5
+TOOLTEST tindicesyes.ddl --enable-error-stack taindices.h5
+TOOLTEST tindicesno.ddl --enable-error-stack -y taindices.h5
########## array indices with subsetting
# 1D case
-TOOLTEST tindicessub1.ddl -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5
+TOOLTEST tindicessub1.ddl --enable-error-stack -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5
# 2D case
-TOOLTEST tindicessub2.ddl -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5
+TOOLTEST tindicessub2.ddl --enable-error-stack -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5
# 3D case
-TOOLTEST tindicessub3.ddl -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5
+TOOLTEST tindicessub3.ddl --enable-error-stack -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5
# 4D case
-TOOLTEST tindicessub4.ddl -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5
+TOOLTEST tindicessub4.ddl --enable-error-stack -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5
#Exceed the dimensions for subsetting
TOOLTEST texceedsubstart.ddl -d 1d -s 1,3 taindices.h5
@@ -924,48 +929,48 @@ else
TOOLTEST tallfilters.ddl $option
fi
# user defined
-TOOLTEST tuserfilter.ddl -H -p -d myfilter tfilters.h5
+TOOLTEST tuserfilter.ddl --enable-error-stack -H -p -d myfilter tfilters.h5
# test for displaying objects with very long names
-TOOLTEST tlonglinks.ddl tlonglinks.h5
+TOOLTEST tlonglinks.ddl --enable-error-stack tlonglinks.h5
# dimensions over 4GB, print boundary
-TOOLTEST tbigdims.ddl -d dset4gb -s 4294967284 -c 22 tbigdims.h5
+TOOLTEST tbigdims.ddl --enable-error-stack -d dset4gb -s 4294967284 -c 22 tbigdims.h5
# hyperslab read
-TOOLTEST thyperslab.ddl thyperslab.h5
+TOOLTEST thyperslab.ddl --enable-error-stack thyperslab.h5
#
# test for displaying dataset and attribute of null space
-TOOLTEST tnullspace.ddl tnullspace.h5
+TOOLTEST tnullspace.ddl --enable-error-stack tnullspace.h5
# test for displaying dataset and attribute of space with 0 dimension size
-TOOLTEST zerodim.ddl zerodim.h5
+TOOLTEST zerodim.ddl --enable-error-stack zerodim.h5
# test for long double (some systems do not have long double)
-#TOOLTEST tldouble.ddl tldouble.h5
+#TOOLTEST tldouble.ddl --enable-error-stack tldouble.h5
# test for vms
-TOOLTEST tvms.ddl tvms.h5
+TOOLTEST tvms.ddl --enable-error-stack tvms.h5
# test for binary output
-TOOLTEST tbin1.ddl -d integer -o out1.bin -b LE tbinary.h5
+TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b LE tbinary.h5
# NATIVE default. the NATIVE test can be validated with h5import/h5diff
-TOOLTEST tbin1.ddl -d integer -o out1.bin -b tbinary.h5
+TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b tbinary.h5
IMPORTTEST out1.bin -c out3.h5import -o out1.h5
DIFFTEST tbinary.h5 out1.h5 /integer /integer
-TOOLTEST tbin2.ddl -b BE -d float -o out2.bin tbinary.h5
+TOOLTEST tbin2.ddl --enable-error-stack -b BE -d float -o out2.bin tbinary.h5
# the NATIVE test can be validated with h5import/h5diff
-TOOLTEST tbin3.ddl -d integer -o out3.bin -b NATIVE tbinary.h5
+TOOLTEST tbin3.ddl --enable-error-stack -d integer -o out3.bin -b NATIVE tbinary.h5
IMPORTTEST out3.bin -c out3.h5import -o out3.h5
DIFFTEST tbinary.h5 out3.h5 /integer /integer
-TOOLTEST tbin4.ddl -d double -b FILE -o out4.bin tbinary.h5
+TOOLTEST tbin4.ddl --enable-error-stack -d double -b FILE -o out4.bin tbinary.h5
# Clean up binary output files
if test -z "$HDF5_NOCLEANUP"; then
@@ -975,12 +980,14 @@ if test -z "$HDF5_NOCLEANUP"; then
fi
# test for dataset region references
-TOOLTEST tdatareg.ddl tdatareg.h5
+TOOLTEST tdatareg.ddl --enable-error-stack tdatareg.h5
+# JIRA HDFFV-7936 TOOLTEST tdataregR.ddl --enable-error-stack -R tdatareg.h5
TOOLTEST tdataregR.ddl -R tdatareg.h5
-TOOLTEST tattrreg.ddl tattrreg.h5
+TOOLTEST tattrreg.ddl --enable-error-stack tattrreg.h5
+# JIRA HDFFV-7936 TOOLTEST tattrregR.ddl --enable-error-stack -R tattrreg.h5
TOOLTEST tattrregR.ddl -R tattrreg.h5
-TOOLTEST2 tbinregR.exp -d /Dataset1 -s 0 -R -y -o tbinregR.txt tdatareg.h5
+TOOLTEST2 tbinregR.exp --enable-error-stack -d /Dataset1 -s 0 -R -y -o tbinregR.txt tdatareg.h5
# Clean up text output files
if test -z "$HDF5_NOCLEANUP"; then
@@ -989,35 +996,42 @@ fi
# tests for group creation order
# "1" tracked, "2" name, root tracked
-TOOLTEST tordergr1.ddl --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5
-TOOLTEST tordergr2.ddl --group=1 --sort_by=creation_order --sort_order=descending tordergr.h5
-TOOLTEST tordergr3.ddl -g 2 -q name -z ascending tordergr.h5
-TOOLTEST tordergr4.ddl -g 2 -q name -z descending tordergr.h5
-TOOLTEST tordergr5.ddl -q creation_order tordergr.h5
+TOOLTEST tordergr1.ddl --enable-error-stack --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5
+TOOLTEST tordergr2.ddl --enable-error-stack --group=1 --sort_by=creation_order --sort_order=descending tordergr.h5
+TOOLTEST tordergr3.ddl --enable-error-stack -g 2 -q name -z ascending tordergr.h5
+TOOLTEST tordergr4.ddl --enable-error-stack -g 2 -q name -z descending tordergr.h5
+TOOLTEST tordergr5.ddl --enable-error-stack -q creation_order tordergr.h5
# tests for attribute order
-TOOLTEST torderattr1.ddl -H --sort_by=name --sort_order=ascending torderattr.h5
-TOOLTEST torderattr2.ddl -H --sort_by=name --sort_order=descending torderattr.h5
-TOOLTEST torderattr3.ddl -H --sort_by=creation_order --sort_order=ascending torderattr.h5
-TOOLTEST torderattr4.ddl -H --sort_by=creation_order --sort_order=descending torderattr.h5
+TOOLTEST torderattr1.ddl --enable-error-stack -H --sort_by=name --sort_order=ascending torderattr.h5
+TOOLTEST torderattr2.ddl --enable-error-stack -H --sort_by=name --sort_order=descending torderattr.h5
+TOOLTEST torderattr3.ddl --enable-error-stack -H --sort_by=creation_order --sort_order=ascending torderattr.h5
+TOOLTEST torderattr4.ddl --enable-error-stack -H --sort_by=creation_order --sort_order=descending torderattr.h5
# tests for floating point user defined printf format
-TOOLTEST tfpformat.ddl -m %.7f tfpformat.h5
+TOOLTEST tfpformat.ddl --enable-error-stack -m %.7f tfpformat.h5
# tests for traversal of external links
+# JIRA HDFFV-7936 TOOLTEST textlinksrc.ddl --enable-error-stack textlinksrc.h5
TOOLTEST textlinksrc.ddl textlinksrc.h5
+# JIRA HDFFV-7936 TOOLTEST textlinkfar.ddl --enable-error-stack textlinkfar.h5
TOOLTEST textlinkfar.ddl textlinkfar.h5
# test for dangling external links
+# JIRA HDFFV-7936 TOOLTEST textlink.ddl --enable-error-stack textlink.h5
TOOLTEST textlink.ddl textlink.h5
# test for error stack display (BZ2048)
TOOLTEST3 filter_fail.ddl --enable-error-stack filter_fail.h5
# test for -o -y for dataset with attributes
-TOOLTEST tall-6.ddl -y -o data -d /g1/g1.1/dset1.1.1 tall.h5
+TOOLTEST tall-6.ddl --enable-error-stack -y -o data -d /g1/g1.1/dset1.1.1 tall.h5
+
+####### test for dataset packed bits ######
-# test for dataset packed bits
+# test failure handling
+# Missing file name
+TOOLTEST tnofilename-with-packed-bits.ddl
# Limits:
# Maximum number of packed bits is 8 (for now).
# Maximum integer size is 64 (for now).
@@ -1027,70 +1041,70 @@ TOOLTEST tall-6.ddl -y -o data -d /g1/g1.1/dset1.1.1 tall.h5
# Normal operation on both signed and unsigned int datasets.
# Sanity check
# Their rawdata output should be the same.
-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
+TOOLTEST tpbitsSignedWhole.ddl --enable-error-stack -d /DS08BITS -M 0,8 packedbits.h5
+TOOLTEST tpbitsUnsignedWhole.ddl --enable-error-stack -d /DU08BITS -M 0,8 packedbits.h5
+TOOLTEST tpbitsSignedIntWhole.ddl --enable-error-stack -d /DS16BITS -M 0,16 packedbits.h5
+TOOLTEST tpbitsUnsignedIntWhole.ddl --enable-error-stack -d /DU16BITS -M 0,16 packedbits.h5
+TOOLTEST tpbitsSignedLongWhole.ddl --enable-error-stack -d /DS32BITS -M 0,32 packedbits.h5
+TOOLTEST tpbitsUnsignedLongWhole.ddl --enable-error-stack -d /DU32BITS -M 0,32 packedbits.h5
+TOOLTEST tpbitsSignedLongLongWhole.ddl --enable-error-stack -d /DS64BITS -M 0,64 packedbits.h5
+TOOLTEST tpbitsUnsignedLongLongWhole.ddl --enable-error-stack -d /DU64BITS -M 0,64 packedbits.h5
+TOOLTEST tpbitsSignedLongLongWhole63.ddl --enable-error-stack -d /DS64BITS -M 0,63 packedbits.h5
+TOOLTEST tpbitsUnsignedLongLongWhole63.ddl --enable-error-stack -d /DU64BITS -M 0,63 packedbits.h5
+TOOLTEST tpbitsSignedLongLongWhole1.ddl --enable-error-stack -d /DS64BITS -M 1,63 packedbits.h5
+TOOLTEST tpbitsUnsignedLongLongWhole1.ddl --enable-error-stack -d /DU64BITS -M 1,63 packedbits.h5
# Half sections
-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
+TOOLTEST tpbitsSigned4.ddl --enable-error-stack -d /DS08BITS -M 0,4,4,4 packedbits.h5
+TOOLTEST tpbitsUnsigned4.ddl --enable-error-stack -d /DU08BITS -M 0,4,4,4 packedbits.h5
+TOOLTEST tpbitsSignedInt8.ddl --enable-error-stack -d /DS16BITS -M 0,8,8,8 packedbits.h5
+TOOLTEST tpbitsUnsignedInt8.ddl --enable-error-stack -d /DU16BITS -M 0,8,8,8 packedbits.h5
+TOOLTEST tpbitsSignedLong16.ddl --enable-error-stack -d /DS32BITS -M 0,16,16,16 packedbits.h5
+TOOLTEST tpbitsUnsignedLong16.ddl --enable-error-stack -d /DU32BITS -M 0,16,16,16 packedbits.h5
+TOOLTEST tpbitsSignedLongLong32.ddl --enable-error-stack -d /DS64BITS -M 0,32,32,32 packedbits.h5
+TOOLTEST tpbitsUnsignedLongLong32.ddl --enable-error-stack -d /DU64BITS -M 0,32,32,32 packedbits.h5
# Quarter sections
-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
+TOOLTEST tpbitsSigned2.ddl --enable-error-stack -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5
+TOOLTEST tpbitsUnsigned2.ddl --enable-error-stack -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5
+TOOLTEST tpbitsSignedInt4.ddl --enable-error-stack -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5
+TOOLTEST tpbitsUnsignedInt4.ddl --enable-error-stack -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5
+TOOLTEST tpbitsSignedLong8.ddl --enable-error-stack -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5
+TOOLTEST tpbitsUnsignedLong8.ddl --enable-error-stack -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5
+TOOLTEST tpbitsSignedLongLong16.ddl --enable-error-stack -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5
+TOOLTEST tpbitsUnsignedLongLong16.ddl --enable-error-stack -d /DU64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5
# Begin and End
-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
+TOOLTEST tpbitsSigned.ddl --enable-error-stack -d /DS08BITS -M 0,2,2,6 packedbits.h5
+TOOLTEST tpbitsUnsigned.ddl --enable-error-stack -d /DU08BITS -M 0,2,2,6 packedbits.h5
+TOOLTEST tpbitsSignedInt.ddl --enable-error-stack -d /DS16BITS -M 0,2,10,6 packedbits.h5
+TOOLTEST tpbitsUnsignedInt.ddl --enable-error-stack -d /DU16BITS -M 0,2,10,6 packedbits.h5
+TOOLTEST tpbitsSignedLong.ddl --enable-error-stack -d /DS32BITS -M 0,2,26,6 packedbits.h5
+TOOLTEST tpbitsUnsignedLong.ddl --enable-error-stack -d /DU32BITS -M 0,2,26,6 packedbits.h5
+TOOLTEST tpbitsSignedLongLong.ddl --enable-error-stack -d /DS64BITS -M 0,2,58,6 packedbits.h5
+TOOLTEST tpbitsUnsignedLongLong.ddl --enable-error-stack -d /DU64BITS -M 0,2,58,6 packedbits.h5
# Overlapped packed bits.
-TOOLTEST tpbitsOverlapped.ddl -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5
+TOOLTEST tpbitsOverlapped.ddl --enable-error-stack -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5
# Maximum number of packed bits.
-TOOLTEST 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 --enable-error-stack -d /DS08BITS -M 0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5
# Compound type.
-TOOLTEST tpbitsCompound.ddl -d /dset1 -M 0,1,1,1 tcompound.h5
+TOOLTEST tpbitsCompound.ddl --enable-error-stack -d /dset1 -M 0,1,1,1 tcompound.h5
# Array type.
-TOOLTEST tpbitsArray.ddl -d /Dataset1 -M 0,1,1,1 tarray1.h5
+TOOLTEST tpbitsArray.ddl --enable-error-stack -d /Dataset1 -M 0,1,1,1 tarray1.h5
# Test Error handling.
# Too many packed bits requested. Max is 8 for now.
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.
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
+TOOLTEST tpbitsCharOffsetExceeded.ddl --enable-error-stack -d /DS08BITS -M 8,1 packedbits.h5
+TOOLTEST tpbitsIntOffsetExceeded.ddl --enable-error-stack -d /DS16BITS -M 16,1 packedbits.h5
+TOOLTEST tpbitsLongOffsetExceeded.ddl --enable-error-stack -d /DS32BITS -M 32,1 packedbits.h5
# Bad offset, must not be negative.
TOOLTEST tpbitsOffsetNegative.ddl -d /DS08BITS -M -1,1 packedbits.h5
# Bad length, must not be positive.
TOOLTEST tpbitsLengthPositive.ddl -d /DS08BITS -M 4,0 packedbits.h5
# Offset+Length is too large. Max is 8 for now.
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
+TOOLTEST tpbitsCharLengthExceeded.ddl --enable-error-stack -d /DS08BITS -M 2,7 packedbits.h5
+TOOLTEST tpbitsIntLengthExceeded.ddl --enable-error-stack -d /DS16BITS -M 10,7 packedbits.h5
+TOOLTEST tpbitsLongLengthExceeded.ddl --enable-error-stack -d /DS32BITS -M 26,7 packedbits.h5
# Incomplete pair of packed bits request.
TOOLTEST tpbitsIncomplete.ddl -d /DS08BITS -M 0,2,2,1,0,2,2, packedbits.h5