summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/h5dump/h5dump.c1284
-rw-r--r--tools/h5dump/h5dump.h8
-rw-r--r--tools/h5dump/h5dumpgentest.c69
-rwxr-xr-xtools/h5dump/testh5dump.sh2
-rwxr-xr-xtools/h5dump/testh5dumpxml.sh1
5 files changed, 687 insertions, 677 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 37c67a2..84bf544 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -100,7 +100,7 @@ static h5dump_t dataformat = {
0, /*str_repeat */
"[ ", /*arr_pre */
- ", ", /*arr_sep */
+ ",", /*arr_sep */
" ]", /*arr_suf */
1, /*arr_linebreak */
@@ -110,7 +110,7 @@ static h5dump_t dataformat = {
"}", /*cmpd_suf */
"\n", /*cmpd_end */
- ",", /*vlen_sep */
+ ", ", /*vlen_sep */
"(", /*vlen_pre */
")", /*vlen_suf */
"", /*vlen_end */
@@ -182,8 +182,8 @@ static h5dump_t xml_dataformat = {
0, /*str_repeat */
" ", /*arr_pre */
- " ", /*arr_sep */
- " ", /*arr_suf */
+ "", /*arr_sep */
+ "", /*arr_suf */
1, /*arr_linebreak */
"", /*cmpd_name */
@@ -194,12 +194,12 @@ static h5dump_t xml_dataformat = {
" ", /*vlen_sep */
" ", /*vlen_pre */
- " ", /*vlen_suf */
+ "", /*vlen_suf */
"", /*vlen_end */
"%s", /*elmt_fmt */
- " ", /*elmt_suf1 */
- "", /*elmt_suf2 */
+ "", /*elmt_suf1 */
+ " ", /*elmt_suf2 */
"", /*idx_n_fmt */
"", /*idx_sep */
@@ -307,7 +307,7 @@ static const dump_header standardformat = {
** Added for XML **
**/
/* internal functions used by XML option */
-static void xml_print_datatype(hid_t);
+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);
@@ -616,7 +616,7 @@ usage(const char *prog)
*-------------------------------------------------------------------------
*/
static void
-print_datatype(hid_t type)
+print_datatype(hid_t type,unsigned in_group)
{
char *fname;
hid_t nmembers, mtype, str_type;
@@ -630,300 +630,299 @@ print_datatype(hid_t type)
hid_t tmp_type;
htri_t is_vlstr=FALSE;
- switch (H5Tget_class(type)) {
- case H5T_INTEGER:
- if (H5Tequal(type, H5T_STD_I8BE)) {
- printf("H5T_STD_I8BE");
- } else if (H5Tequal(type, H5T_STD_I8LE)) {
- printf("H5T_STD_I8LE");
- } else if (H5Tequal(type, H5T_STD_I16BE)) {
- printf("H5T_STD_I16BE");
- } else if (H5Tequal(type, H5T_STD_I16LE)) {
- printf("H5T_STD_I16LE");
- } else if (H5Tequal(type, H5T_STD_I32BE)) {
- printf("H5T_STD_I32BE");
- } else if (H5Tequal(type, H5T_STD_I32LE)) {
- printf("H5T_STD_I32LE");
- } else if (H5Tequal(type, H5T_STD_I64BE)) {
- printf("H5T_STD_I64BE");
- } else if (H5Tequal(type, H5T_STD_I64LE)) {
- printf("H5T_STD_I64LE");
- } else if (H5Tequal(type, H5T_STD_U8BE)) {
- printf("H5T_STD_U8BE");
- } else if (H5Tequal(type, H5T_STD_U8LE)) {
- printf("H5T_STD_U8LE");
- } else if (H5Tequal(type, H5T_STD_U16BE)) {
- printf("H5T_STD_U16BE");
- } else if (H5Tequal(type, H5T_STD_U16LE)) {
- printf("H5T_STD_U16LE");
- } else if (H5Tequal(type, H5T_STD_U32BE)) {
- printf("H5T_STD_U32BE");
- } else if (H5Tequal(type, H5T_STD_U32LE)) {
- printf("H5T_STD_U32LE");
- } else if (H5Tequal(type, H5T_STD_U64BE)) {
- printf("H5T_STD_U64BE");
- } else if (H5Tequal(type, H5T_STD_U64LE)) {
- printf("H5T_STD_U64LE");
- } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
- printf("H5T_NATIVE_SCHAR");
- } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
- printf("H5T_NATIVE_UCHAR");
- } else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- printf("H5T_NATIVE_SHORT");
- } else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- printf("H5T_NATIVE_USHORT");
- } else if (H5Tequal(type, H5T_NATIVE_INT)) {
- printf("H5T_NATIVE_INT");
- } else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- printf("H5T_NATIVE_UINT");
- } else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- printf("H5T_NATIVE_LONG");
- } else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- printf("H5T_NATIVE_ULONG");
- } else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
- printf("H5T_NATIVE_LLONG");
- } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
- printf("H5T_NATIVE_ULLONG");
- } else {
- printf("undefined integer");
- d_status = EXIT_FAILURE;
- }
- break;
-
- case H5T_FLOAT:
- if (H5Tequal(type, H5T_IEEE_F32BE)) {
- printf("H5T_IEEE_F32BE");
- } else if (H5Tequal(type, H5T_IEEE_F32LE)) {
- printf("H5T_IEEE_F32LE");
- } else if (H5Tequal(type, H5T_IEEE_F64BE)) {
- printf("H5T_IEEE_F64BE");
- } else if (H5Tequal(type, H5T_IEEE_F64LE)) {
- printf("H5T_IEEE_F64LE");
- } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
- printf("H5T_NATIVE_FLOAT");
- } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
- printf("H5T_NATIVE_DOUBLE");
- } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
- printf("H5T_NATIVE_LDOUBLE");
- } else {
- printf("undefined float");
- d_status = EXIT_FAILURE;
- }
- break;
-
- case H5T_TIME:
- printf("H5T_TIME: not yet implemented");
- break;
+ if (!in_group && H5Tcommitted(type) > 0) {
+ H5Gget_objinfo(type, ".", TRUE, &statbuf);
+ i = search_obj(type_table, statbuf.objno);
- 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);
-
- printf("H5T_STRING %s\n", dump_header_format->strblockbegin);
- indent += COL;
-
- indentation(indent + COL);
- if(is_vlstr)
- printf("%s H5T_VARIABLE;\n", STRSIZE);
- else
- printf("%s %d;\n", STRSIZE, (int) size);
+ if (i >= 0) {
+ if (!type_table->objs[i].recorded)
+ HDfprintf(stdout,"\"/#%a\"", type_table->objs[i].objno);
+ else
+ printf("\"%s\"", type_table->objs[i].objname);
+ } else {
+ error_msg(progname, "unknown committed type.\n");
+ d_status = EXIT_FAILURE;
+ }
+ } else {
+ switch (H5Tget_class(type)) {
+ case H5T_INTEGER:
+ if (H5Tequal(type, H5T_STD_I8BE)) {
+ printf("H5T_STD_I8BE");
+ } else if (H5Tequal(type, H5T_STD_I8LE)) {
+ printf("H5T_STD_I8LE");
+ } else if (H5Tequal(type, H5T_STD_I16BE)) {
+ printf("H5T_STD_I16BE");
+ } else if (H5Tequal(type, H5T_STD_I16LE)) {
+ printf("H5T_STD_I16LE");
+ } else if (H5Tequal(type, H5T_STD_I32BE)) {
+ printf("H5T_STD_I32BE");
+ } else if (H5Tequal(type, H5T_STD_I32LE)) {
+ printf("H5T_STD_I32LE");
+ } else if (H5Tequal(type, H5T_STD_I64BE)) {
+ printf("H5T_STD_I64BE");
+ } else if (H5Tequal(type, H5T_STD_I64LE)) {
+ printf("H5T_STD_I64LE");
+ } else if (H5Tequal(type, H5T_STD_U8BE)) {
+ printf("H5T_STD_U8BE");
+ } else if (H5Tequal(type, H5T_STD_U8LE)) {
+ printf("H5T_STD_U8LE");
+ } else if (H5Tequal(type, H5T_STD_U16BE)) {
+ printf("H5T_STD_U16BE");
+ } else if (H5Tequal(type, H5T_STD_U16LE)) {
+ printf("H5T_STD_U16LE");
+ } else if (H5Tequal(type, H5T_STD_U32BE)) {
+ printf("H5T_STD_U32BE");
+ } else if (H5Tequal(type, H5T_STD_U32LE)) {
+ printf("H5T_STD_U32LE");
+ } else if (H5Tequal(type, H5T_STD_U64BE)) {
+ printf("H5T_STD_U64BE");
+ } else if (H5Tequal(type, H5T_STD_U64LE)) {
+ printf("H5T_STD_U64LE");
+ } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
+ printf("H5T_NATIVE_SCHAR");
+ } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
+ printf("H5T_NATIVE_UCHAR");
+ } else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
+ printf("H5T_NATIVE_SHORT");
+ } else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
+ printf("H5T_NATIVE_USHORT");
+ } else if (H5Tequal(type, H5T_NATIVE_INT)) {
+ printf("H5T_NATIVE_INT");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT)) {
+ printf("H5T_NATIVE_UINT");
+ } else if (H5Tequal(type, H5T_NATIVE_LONG)) {
+ printf("H5T_NATIVE_LONG");
+ } else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
+ printf("H5T_NATIVE_ULONG");
+ } else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
+ printf("H5T_NATIVE_LLONG");
+ } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
+ printf("H5T_NATIVE_ULLONG");
+ } else {
+ printf("undefined integer");
+ d_status = EXIT_FAILURE;
+ }
+ break;
- indentation(indent + COL);
- printf("%s ", STRPAD);
- if (str_pad == H5T_STR_NULLTERM)
- printf("H5T_STR_NULLTERM;\n");
- else if (str_pad == H5T_STR_NULLPAD)
- printf("H5T_STR_NULLPAD;\n");
- else if (str_pad == H5T_STR_SPACEPAD)
- printf("H5T_STR_SPACEPAD;\n");
- else
- printf("H5T_STR_ERROR;\n");
+ case H5T_FLOAT:
+ if (H5Tequal(type, H5T_IEEE_F32BE)) {
+ printf("H5T_IEEE_F32BE");
+ } else if (H5Tequal(type, H5T_IEEE_F32LE)) {
+ printf("H5T_IEEE_F32LE");
+ } else if (H5Tequal(type, H5T_IEEE_F64BE)) {
+ printf("H5T_IEEE_F64BE");
+ } else if (H5Tequal(type, H5T_IEEE_F64LE)) {
+ printf("H5T_IEEE_F64LE");
+ } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
+ printf("H5T_NATIVE_FLOAT");
+ } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
+ printf("H5T_NATIVE_DOUBLE");
+ } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
+ printf("H5T_NATIVE_LDOUBLE");
+ } else {
+ printf("undefined float");
+ d_status = EXIT_FAILURE;
+ }
+ break;
- indentation(indent + COL);
- printf("%s ", CSET);
+ case H5T_TIME:
+ printf("H5T_TIME: not yet implemented");
+ break;
- if (cset == H5T_CSET_ASCII)
- printf("H5T_CSET_ASCII;\n");
- else
- printf("unknown_cset;\n");
+ 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);
+
+ printf("H5T_STRING %s\n", dump_header_format->strblockbegin);
+ indent += COL;
+
+ indentation(indent + COL);
+ if(is_vlstr)
+ printf("%s H5T_VARIABLE;\n", STRSIZE);
+ else
+ printf("%s %d;\n", STRSIZE, (int) size);
+
+ indentation(indent + COL);
+ printf("%s ", STRPAD);
+ if (str_pad == H5T_STR_NULLTERM)
+ printf("H5T_STR_NULLTERM;\n");
+ else if (str_pad == H5T_STR_NULLPAD)
+ printf("H5T_STR_NULLPAD;\n");
+ else if (str_pad == H5T_STR_SPACEPAD)
+ printf("H5T_STR_SPACEPAD;\n");
+ else
+ printf("H5T_STR_ERROR;\n");
- 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);
+ printf("%s ", CSET);
- indentation(indent + COL);
- printf("%s ", CTYPE);
+ if (cset == H5T_CSET_ASCII)
+ printf("H5T_CSET_ASCII;\n");
+ else
+ printf("unknown_cset;\n");
- if (H5Tequal(tmp_type, str_type)) {
- printf("H5T_C_S1;\n");
- H5Tclose(str_type);
- } else {
- 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);
-
- if (H5Tequal(tmp_type, str_type)) {
- printf("H5T_FORTRAN_S1;\n");
- } else {
- printf("unknown_one_character_type;\n ");
- d_status = EXIT_FAILURE;
- }
+ 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);
- H5Tclose(str_type);
- }
+ indentation(indent + COL);
+ printf("%s ", CTYPE);
- H5Tclose(tmp_type);
+ if (H5Tequal(tmp_type, str_type)) {
+ printf("H5T_C_S1;\n");
+ H5Tclose(str_type);
+ } else {
+ 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);
+
+ if (H5Tequal(tmp_type, str_type)) {
+ printf("H5T_FORTRAN_S1;\n");
+ } else {
+ printf("unknown_one_character_type;\n ");
+ d_status = EXIT_FAILURE;
+ }
- indent -= COL;
- indentation(indent + COL);
- printf("%s", dump_header_format->strblockend);
- break;
+ H5Tclose(str_type);
+ }
- case H5T_BITFIELD:
- if (H5Tequal(type, H5T_STD_B8BE)) {
- printf("H5T_STD_B8BE");
- } else if (H5Tequal(type, H5T_STD_B8LE)) {
- printf("H5T_STD_B8LE");
- } else if (H5Tequal(type, H5T_STD_B16BE)) {
- printf("H5T_STD_B16BE");
- } else if (H5Tequal(type, H5T_STD_B16LE)) {
- printf("H5T_STD_B16LE");
- } else if (H5Tequal(type, H5T_STD_B32BE)) {
- printf("H5T_STD_B32BE");
- } else if (H5Tequal(type, H5T_STD_B32LE)) {
- printf("H5T_STD_B32LE");
- } else if (H5Tequal(type, H5T_STD_B64BE)) {
- printf("H5T_STD_B64BE");
- } else if (H5Tequal(type, H5T_STD_B64LE)) {
- printf("H5T_STD_B64LE");
- } else {
- printf("undefined bitfield");
- d_status = EXIT_FAILURE;
- }
- break;
+ H5Tclose(tmp_type);
- case H5T_OPAQUE:
- printf("\n");
- indentation(indent + COL);
- printf("H5T_OPAQUE;\n");
- indentation(indent + COL);
- printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type));
- indentation(indent);
- break;
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s", dump_header_format->strblockend);
+ break;
- case H5T_COMPOUND:
- if (H5Tcommitted(type) > 0) {
- H5Gget_objinfo(type, ".", TRUE, &statbuf);
- i = search_obj(type_table, statbuf.objno);
+ case H5T_BITFIELD:
+ if (H5Tequal(type, H5T_STD_B8BE)) {
+ printf("H5T_STD_B8BE");
+ } else if (H5Tequal(type, H5T_STD_B8LE)) {
+ printf("H5T_STD_B8LE");
+ } else if (H5Tequal(type, H5T_STD_B16BE)) {
+ printf("H5T_STD_B16BE");
+ } else if (H5Tequal(type, H5T_STD_B16LE)) {
+ printf("H5T_STD_B16LE");
+ } else if (H5Tequal(type, H5T_STD_B32BE)) {
+ printf("H5T_STD_B32BE");
+ } else if (H5Tequal(type, H5T_STD_B32LE)) {
+ printf("H5T_STD_B32LE");
+ } else if (H5Tequal(type, H5T_STD_B64BE)) {
+ printf("H5T_STD_B64BE");
+ } else if (H5Tequal(type, H5T_STD_B64LE)) {
+ printf("H5T_STD_B64LE");
+ } else {
+ printf("undefined bitfield");
+ d_status = EXIT_FAILURE;
+ }
+ break;
- if (i >= 0) {
- if (!type_table->objs[i].recorded)
- HDfprintf(stdout,"\"/#%a\"\n", type_table->objs[i].objno);
- else
- printf("\"%s\"", type_table->objs[i].objname);
- } else {
- error_msg(progname, "unknown committed type.\n");
- d_status = EXIT_FAILURE;
- }
- } else {
- nmembers = H5Tget_nmembers(type);
- printf("H5T_COMPOUND %s\n", dump_header_format->structblockbegin);
+ case H5T_OPAQUE:
+ printf("\n");
+ indentation(indent + COL);
+ printf("H5T_OPAQUE;\n");
+ indentation(indent + COL);
+ printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type));
+ indentation(indent);
+ break;
- for (i = 0; i < nmembers; i++) {
- fname = H5Tget_member_name(type, i);
- mtype = H5Tget_member_type(type, i);
- indentation(indent + COL);
+ case H5T_COMPOUND:
+ nmembers = H5Tget_nmembers(type);
+ printf("H5T_COMPOUND %s\n", dump_header_format->structblockbegin);
- if (H5Tget_class(mtype) == H5T_COMPOUND)
- indent += COL;
+ for (i = 0; i < nmembers; i++) {
+ fname = H5Tget_member_name(type, i);
+ mtype = H5Tget_member_type(type, i);
+ indentation(indent + COL);
- print_datatype(mtype);
+ if (H5Tget_class(mtype) == H5T_COMPOUND)
+ indent += COL;
- if (H5Tget_class(mtype) == H5T_COMPOUND)
- indent -= COL;
+ print_datatype(mtype,0);
- printf(" \"%s\";\n", fname);
- free(fname);
- }
+ if (H5Tget_class(mtype) == H5T_COMPOUND)
+ indent -= COL;
- indentation(indent);
- printf("%s", dump_header_format->structblockend);
- }
+ printf(" \"%s\";\n", fname);
+ free(fname);
+ }
- break;
+ indentation(indent);
+ printf("%s", dump_header_format->structblockend);
+ break;
- case H5T_REFERENCE:
- printf("H5T_REFERENCE");
- break;
+ case H5T_REFERENCE:
+ printf("H5T_REFERENCE");
+ break;
- case H5T_ENUM:
- printf("H5T_ENUM %s\n", dump_header_format->enumblockbegin);
- indent += COL;
- indentation(indent + COL);
- super = H5Tget_super(type);
- print_datatype(super);
- printf(";\n");
- print_enum(type);
- indent -= COL;
- indentation(indent + COL);
- printf("%s", dump_header_format->enumblockend);
- break;
+ case H5T_ENUM:
+ printf("H5T_ENUM %s\n", dump_header_format->enumblockbegin);
+ indent += COL;
+ indentation(indent + COL);
+ super = H5Tget_super(type);
+ print_datatype(super,0);
+ printf(";\n");
+ print_enum(type);
+ indent -= COL;
+ indentation(indent + COL);
+ printf("%s", dump_header_format->enumblockend);
+ break;
- case H5T_VLEN:
- printf("H5T_VLEN %s ", dump_header_format->vlenblockbegin);
- super = H5Tget_super(type);
- print_datatype(super);
- H5Tclose(super);
+ case H5T_VLEN:
+ printf("H5T_VLEN %s ", dump_header_format->vlenblockbegin);
+ super = H5Tget_super(type);
+ print_datatype(super,0);
+ H5Tclose(super);
- /* Print closing */
- printf("%s", dump_header_format->vlenblockend);
- break;
+ /* Print closing */
+ printf("%s", dump_header_format->vlenblockend);
+ break;
- case H5T_ARRAY:
- /* Get array base type */
- super = H5Tget_super(type);
+ case H5T_ARRAY:
+ /* Get array base type */
+ super = H5Tget_super(type);
- /* Print lead-in */
- printf("H5T_ARRAY { ");
+ /* Print lead-in */
+ printf("H5T_ARRAY { ");
- /* Get array information */
- ndims = H5Tget_array_ndims(type);
- H5Tget_array_dims(type, dims, perm);
+ /* Get array information */
+ ndims = H5Tget_array_ndims(type);
+ H5Tget_array_dims(type, dims, perm);
- /* Print array dimensions */
- for (j = 0; j < ndims; j++)
- printf("[%d]", (int) dims[j]);
+ /* Print array dimensions */
+ for (j = 0; j < ndims; j++)
+ printf("[%d]", (int) dims[j]);
- printf(" ");
+ printf(" ");
- /* Print base type */
- print_datatype(super);
+ /* Print base type */
+ print_datatype(super,0);
- /* Close array base type */
- H5Tclose(super);
+ /* Close array base type */
+ H5Tclose(super);
- /* Print closing */
- printf(" }");
+ /* Print closing */
+ printf(" }");
- break;
+ break;
- default:
- printf("unknown data type");
- d_status = EXIT_FAILURE;
- break;
- }
+ default:
+ printf("unknown data type");
+ d_status = EXIT_FAILURE;
+ break;
+ }
+ } /* end else */
}
/*-------------------------------------------------------------------------
@@ -969,13 +968,10 @@ dump_datatype(hid_t type)
printf("%s %s ", dump_header_format->datatypebegin,
dump_header_format->datatypeblockbegin);
- print_datatype(type);
+ print_datatype(type,0);
- if (H5Tget_class(type) == H5T_COMPOUND || H5Tget_class(type) == H5T_STRING)
- indentation(indent);
-
- printf(" %s %s\n", dump_header_format->datatypeblockend,
- dump_header_format->datatypeend);
+ end_obj(dump_header_format->datatypeend,
+ dump_header_format->datatypeblockend);
indent -= COL;
}
@@ -1007,7 +1003,7 @@ dump_dataspace(hid_t space)
if (H5Sis_simple(space)) {
if (ndims == 0) {
/* scalar dataspace */
- HDfprintf(stdout, "%s %s ",
+ HDfprintf(stdout, "%s %s",
dump_header_format->dataspacedescriptionbegin, SCALAR);
} else {
/* simple dataspace */
@@ -1532,17 +1528,12 @@ dump_named_datatype(hid_t type, const char *name)
dump_header_format->datatypeblockbegin);
if (H5Tget_class(type) == H5T_COMPOUND) {
- hid_t temp_type = H5Tcopy(type);
-
- print_datatype(temp_type);
- H5Tclose(temp_type);
+ print_datatype(type,1);
} else {
indentation(indent + COL);
- print_datatype(type);
+ print_datatype(type,1);
printf(";\n");
}
-
- indentation(indent);
end_obj(dump_header_format->datatypeend,
dump_header_format->datatypeblockend);
}
@@ -3630,7 +3621,7 @@ xml_escape_the_string(const char *str, int slen)
*-------------------------------------------------------------------------
*/
static void
-xml_print_datatype(hid_t type)
+xml_print_datatype(hid_t type, unsigned in_group)
{
char *fname;
hid_t nmembers, mtype;
@@ -3651,350 +3642,352 @@ xml_print_datatype(hid_t type)
size_t msize;
int nmembs;
htri_t is_vlstr=FALSE;
-
- switch (H5Tget_class(type)) {
- case H5T_INTEGER:
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */
- ord = H5Tget_order(type);
- sgn = H5Tget_sign(type);
- indentation(indent);
- printf("<%sIntegerType ByteOrder=\"",xmlnsprefix);
- switch (ord) {
- case H5T_ORDER_LE:
- printf("LE");
- break;
- case H5T_ORDER_BE:
- printf("BE");
- break;
- case H5T_ORDER_VAX:
- default:
- printf("ERROR_UNKNOWN");
- }
- printf("\" Sign=\"");
- switch (sgn) {
- case H5T_SGN_NONE:
- printf("false");
- break;
- case H5T_SGN_2:
- printf("true");
- break;
- default:
- printf("ERROR_UNKNOWN");
- }
- printf("\" Size=\"");
- sz = H5Tget_size(type);
- printf("%lu", (unsigned long)sz);
- printf("\" />\n");
- indent -= COL;
- indentation(indent);
- printf("</%sAtomicType>\n",xmlnsprefix);
- break;
- case H5T_FLOAT:
- /* <hdf5:FloatType ByteOrder="bo" Size="bytes"
- SignBitLocation="bytes"
- ExponentBits="eb" ExponentLocation="el"
- MantissaBits="mb" MantissaLocation="ml" /> */
- ord = H5Tget_order(type);
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- printf("<%sFloatType ByteOrder=\"",xmlnsprefix);
- switch (ord) {
- case H5T_ORDER_LE:
- printf("LE");
- break;
- case H5T_ORDER_BE:
- printf("BE");
- break;
- case H5T_ORDER_VAX:
- default:
- printf("ERROR_UNKNOWN");
- }
- printf("\" Size=\"");
- sz = H5Tget_size(type);
- printf("%lu", (unsigned long)sz);
- H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize);
- printf("\" SignBitLocation=\"%lu\" ", (unsigned long)spos);
- printf("ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos);
- printf("MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />\n",
- (unsigned long)msize, (unsigned long)mpos);
- indent -= COL;
- indentation(indent);
- printf("</%sAtomicType>\n",xmlnsprefix);
- break;
-
- case H5T_TIME:
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- printf("<%sTimeType />\n",xmlnsprefix);
- printf("<!-- H5T_TIME: not yet implemented -->");
- indent -= COL;
- indentation(indent);
- printf("</%sAtomicType>\n",xmlnsprefix);
- break;
+ if (!in_group && H5Tcommitted(type) > 0) {
+ /* detect a shared datatype, output only once */
+ H5Gget_objinfo(type, ".", TRUE, &statbuf);
+ i = search_obj(type_table, statbuf.objno);
+
+ if (i >= 0) {
+ /* This should be defined somewhere else */
+ /* These 2 cases are handled the same right now, but
+ probably will have something different eventually */
+ int res;
+ char * dtxid = malloc(100);
+ res = xml_name_to_XID(type_table->objs[i].objname,dtxid,100,1);
+ if (!type_table->objs[i].recorded) {
+ /* 'anonymous' NDT. Use it's object num.
+ as it's name. */
+ printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n",
+ xmlnsprefix,
+ dtxid);
+ } else {
+ /* point to the NDT by name */
+ char *t_objname = xml_escape_the_name(type_table->objs[i].objname);
+ printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n",
+ xmlnsprefix,
+ dtxid,t_objname);
+ free(t_objname);
+ }
+ free(dtxid);
+ } else {
+ printf("<!-- h5dump error: unknown committed type. -->\n");
+ d_status = EXIT_FAILURE;
+ }
- 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);
+ } else {
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- printf("<%sStringType Cset=\"",xmlnsprefix);
- if (cset == H5T_CSET_ASCII) {
- printf("H5T_CSET_ASCII\" ");
- } else {
- printf("unknown_cset\" ");
- }
- if(is_vlstr)
- printf("StrSize=\"H5T_VARIABLE\" StrPad=\"");
- else
- printf("StrSize=\"%d\" StrPad=\"", (int) size);
- if (str_pad == H5T_STR_NULLTERM) {
- printf("H5T_STR_NULLTERM\"/>\n");
- } else if (str_pad == H5T_STR_NULLPAD) {
- printf("H5T_STR_NULLPAD\"/>\n");
- } else if (str_pad == H5T_STR_SPACEPAD) {
- printf("H5T_STR_SPACEPAD\"/>\n");
- } else {
- printf("H5T_STR_ERROR\"/>\n");
- }
- indent -= COL;
- indentation(indent);
- printf("</%sAtomicType>\n",xmlnsprefix);
- break;
-
- case H5T_BITFIELD:
- /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */
- ord = H5Tget_order(type);
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- printf("<%sBitfieldType ByteOrder=\"",xmlnsprefix);
- switch (ord) {
- case H5T_ORDER_LE:
- printf("LE");
- break;
- case H5T_ORDER_BE:
- printf("BE");
- break;
- case H5T_ORDER_VAX:
- default:
- printf("ERROR_UNKNOWN");
- }
- size = H5Tget_size(type);
- printf("\" Size=\"%lu\"/>\n", (unsigned long)size);
- indent -= COL;
- indentation(indent);
- printf("</%sAtomicType>\n",xmlnsprefix);
- break;
+ switch (H5Tget_class(type)) {
+ case H5T_INTEGER:
+ indentation(indent);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */
+ ord = H5Tget_order(type);
+ sgn = H5Tget_sign(type);
+ indentation(indent);
+ printf("<%sIntegerType ByteOrder=\"",xmlnsprefix);
+ switch (ord) {
+ case H5T_ORDER_LE:
+ printf("LE");
+ break;
+ case H5T_ORDER_BE:
+ printf("BE");
+ break;
+ case H5T_ORDER_VAX:
+ default:
+ printf("ERROR_UNKNOWN");
+ }
+ printf("\" Sign=\"");
+ switch (sgn) {
+ case H5T_SGN_NONE:
+ printf("false");
+ break;
+ case H5T_SGN_2:
+ printf("true");
+ break;
+ default:
+ printf("ERROR_UNKNOWN");
+ }
+ printf("\" Size=\"");
+ sz = H5Tget_size(type);
+ printf("%lu", (unsigned long)sz);
+ printf("\" />\n");
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- case H5T_OPAQUE:
- /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- printf("<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, H5Tget_tag(type));
- size = H5Tget_size(type);
- printf("Size=\"%lu\"/>\n", (unsigned long)size);
- indent -= COL;
- indentation(indent);
- printf("</%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);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ indentation(indent);
+ printf("<%sFloatType ByteOrder=\"",xmlnsprefix);
+ switch (ord) {
+ case H5T_ORDER_LE:
+ printf("LE");
+ break;
+ case H5T_ORDER_BE:
+ printf("BE");
+ break;
+ case H5T_ORDER_VAX:
+ default:
+ printf("ERROR_UNKNOWN");
+ }
+ printf("\" Size=\"");
+ sz = H5Tget_size(type);
+ printf("%lu", (unsigned long)sz);
+ H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize);
+ printf("\" SignBitLocation=\"%lu\" ", (unsigned long)spos);
+ printf("ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos);
+ printf("MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />\n",
+ (unsigned long)msize, (unsigned long)mpos);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- case H5T_COMPOUND:
- /* recursively describe the components of a compound datatype */
- if (H5Tcommitted(type) > 0) {
- /* detect a shared datatype, output only once */
- H5Gget_objinfo(type, ".", TRUE, &statbuf);
- i = search_obj(type_table, statbuf.objno);
-
- if (i >= 0) {
- /* This should be defined somewhere else */
- /* These 2 cases are handled the same right now, but
- probably will have something different eventually */
- int res;
- char * dtxid = malloc(100);
- res = xml_name_to_XID(type_table->objs[i].objname,dtxid,100,1);
- if (!type_table->objs[i].recorded) {
- /* 'anonymous' NDT. Use it's object num.
- as it's name. */
- printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n",
- xmlnsprefix,
- dtxid);
- } else {
- /* point to the NDT by name */
- char *t_objname = xml_escape_the_name(type_table->objs[i].objname);
- printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n",
- xmlnsprefix,
- dtxid,t_objname);
- free(t_objname);
- }
- free(dtxid);
- } else {
- printf("<!-- h5dump error: unknown committed type. -->\n");
- d_status = EXIT_FAILURE;
- }
+ case H5T_TIME:
+ indentation(indent);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ indentation(indent);
+ printf("<%sTimeType />\n",xmlnsprefix);
+ printf("<!-- H5T_TIME: not yet implemented -->");
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- } else {
- /* type of a dataset */
- nmembers = H5Tget_nmembers(type);
+ case H5T_STRING:
+ /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */
+ size = H5Tget_size(type);
+ str_pad = H5Tget_strpad(type);
+ cset = H5Tget_cset(type);
+ is_vlstr = H5Tis_variable_str(type);
+
+ indentation(indent);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ indentation(indent);
+ printf("<%sStringType Cset=\"",xmlnsprefix);
+ if (cset == H5T_CSET_ASCII) {
+ printf("H5T_CSET_ASCII\" ");
+ } else {
+ printf("unknown_cset\" ");
+ }
+ if(is_vlstr)
+ printf("StrSize=\"H5T_VARIABLE\" StrPad=\"");
+ else
+ printf("StrSize=\"%d\" StrPad=\"", (int) size);
+ if (str_pad == H5T_STR_NULLTERM) {
+ printf("H5T_STR_NULLTERM\"/>\n");
+ } else if (str_pad == H5T_STR_NULLPAD) {
+ printf("H5T_STR_NULLPAD\"/>\n");
+ } else if (str_pad == H5T_STR_SPACEPAD) {
+ printf("H5T_STR_SPACEPAD\"/>\n");
+ } else {
+ printf("H5T_STR_ERROR\"/>\n");
+ }
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- indentation(indent);
- printf("<%sCompoundType>\n",xmlnsprefix);
+ case H5T_BITFIELD:
+ /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */
+ ord = H5Tget_order(type);
+ indentation(indent);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ indentation(indent);
+ printf("<%sBitfieldType ByteOrder=\"",xmlnsprefix);
+ switch (ord) {
+ case H5T_ORDER_LE:
+ printf("LE");
+ break;
+ case H5T_ORDER_BE:
+ printf("BE");
+ break;
+ case H5T_ORDER_VAX:
+ default:
+ printf("ERROR_UNKNOWN");
+ }
+ size = H5Tget_size(type);
+ printf("\" Size=\"%lu\"/>\n", (unsigned long)size);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- /* List each member Field of the type */
- /* <hdf5:Field FieldName="name" > */
- /* <hdf5:DataType > */
- indent += COL;
- for (i = 0; i < nmembers; i++) {
- char *t_fname;
+ case H5T_OPAQUE:
+ /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */
+ indentation(indent);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ indentation(indent);
+ printf("<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, H5Tget_tag(type));
+ size = H5Tget_size(type);
+ printf("Size=\"%lu\"/>\n", (unsigned long)size);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- fname = H5Tget_member_name(type, i);
- mtype = H5Tget_member_type(type, i);
- indentation(indent);
- t_fname = xml_escape_the_name(fname);
- printf("<%sField FieldName=\"%s\">\n",xmlnsprefix, t_fname);
+ case H5T_COMPOUND:
+ /* recursively describe the components of a compound datatype */
- free(fname);
- free(t_fname);
- indent += COL;
- indentation(indent);
- printf("<%sDataType>\n",xmlnsprefix);
- indent += COL;
- xml_print_datatype(mtype);
- indent -= COL;
- indentation(indent);
- printf("</%sDataType>\n",xmlnsprefix);
- indent -= COL;
+ /* type of a dataset */
+ nmembers = H5Tget_nmembers(type);
- indentation(indent);
- printf("</%sField>\n",xmlnsprefix);
- }
- indent -= COL;
- indentation(indent);
- printf("</%sCompoundType>\n",xmlnsprefix);
- }
- break;
+ indentation(indent);
+ printf("<%sCompoundType>\n",xmlnsprefix);
- case H5T_REFERENCE:
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- /* Only Object references supported at this time */
- printf("<%sReferenceType>\n",xmlnsprefix);
- indentation(indent + COL);
- printf("<%sObjectReferenceType />\n",xmlnsprefix);
- indentation(indent);
- printf("</%sReferenceType>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- printf("</%sAtomicType>\n",xmlnsprefix);
- break;
+ /* List each member Field of the type */
+ /* <hdf5:Field FieldName="name" > */
+ /* <hdf5:DataType > */
+ indent += COL;
+ for (i = 0; i < nmembers; i++) {
+ char *t_fname;
- case H5T_ENUM:
- /* <hdf5:EnumType Nelems="ne" >
- list Name, values of enum
- */
- nmembs = H5Tget_nmembers(type);
- indentation(indent);
- printf("<%sAtomicType>\n",xmlnsprefix);
- indent += COL;
- indentation(indent);
- printf("<%sEnumType Nelems=\"%d\">\n",xmlnsprefix, nmembs);
- xml_print_enum(type);
- indentation(indent);
- printf("</%sEnumType>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- printf("</%sAtomicType>\n",xmlnsprefix);
- break;
+ fname = H5Tget_member_name(type, i);
+ mtype = H5Tget_member_type(type, i);
+ indentation(indent);
+ t_fname = xml_escape_the_name(fname);
+ printf("<%sField FieldName=\"%s\">\n",xmlnsprefix, t_fname);
- case H5T_VLEN:
- indentation(indent);
- printf("<%sVLType>\n",xmlnsprefix);
- super = H5Tget_super(type);
- indent += COL;
- indentation(indent);
- printf("<%sDataType>\n",xmlnsprefix);
- indent += COL;
- xml_print_datatype(super);
- indent -= COL;
- indentation(indent);
- printf("</%sDataType>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- printf("</%sVLType>\n",xmlnsprefix);
- H5Tclose(super);
+ free(fname);
+ free(t_fname);
+ indent += COL;
+ indentation(indent);
+ printf("<%sDataType>\n",xmlnsprefix);
+ indent += COL;
+ xml_print_datatype(mtype,0);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sDataType>\n",xmlnsprefix);
+ indent -= COL;
- break;
+ indentation(indent);
+ printf("</%sField>\n",xmlnsprefix);
+ }
+ indent -= COL;
+ indentation(indent);
+ printf("</%sCompoundType>\n",xmlnsprefix);
+ break;
- case H5T_ARRAY:
- /* Get array base type */
- super = H5Tget_super(type);
+ case H5T_REFERENCE:
+ indentation(indent);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ indentation(indent);
+ /* Only Object references supported at this time */
+ printf("<%sReferenceType>\n",xmlnsprefix);
+ indentation(indent + COL);
+ printf("<%sObjectReferenceType />\n",xmlnsprefix);
+ indentation(indent);
+ printf("</%sReferenceType>\n",xmlnsprefix);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- /* Print lead-in */
- indentation(indent);
- printf("<%sArrayType Ndims=\"",xmlnsprefix);
- ndims = H5Tget_array_ndims(type);
- printf("%d\">\n", ndims);
+ case H5T_ENUM:
+ /* <hdf5:EnumType Nelems="ne" >
+ list Name, values of enum
+ */
+ nmembs = H5Tget_nmembers(type);
+ indentation(indent);
+ printf("<%sAtomicType>\n",xmlnsprefix);
+ indent += COL;
+ indentation(indent);
+ printf("<%sEnumType Nelems=\"%d\">\n",xmlnsprefix, nmembs);
+ xml_print_enum(type);
+ indentation(indent);
+ printf("</%sEnumType>\n",xmlnsprefix);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sAtomicType>\n",xmlnsprefix);
+ break;
- /* Get array information */
- H5Tget_array_dims(type, dims, perm);
+ case H5T_VLEN:
+ indentation(indent);
+ printf("<%sVLType>\n",xmlnsprefix);
+ super = H5Tget_super(type);
+ indent += COL;
+ indentation(indent);
+ printf("<%sDataType>\n",xmlnsprefix);
+ indent += COL;
+ xml_print_datatype(super,0);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sDataType>\n",xmlnsprefix);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sVLType>\n",xmlnsprefix);
+ H5Tclose(super);
- /* list of dimensions */
- indent += COL;
- if (perm != NULL) {
- /* for each dimension, list */
- for (j = 0; j < ndims; j++) {
- indentation(indent);
- printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"%u\"/>\n",
- xmlnsprefix,(int) dims[j], (int) perm[j]);
- }
- } else {
- for (j = 0; j < ndims; j++) {
- indentation(indent);
- printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"0\"/>\n",
- xmlnsprefix,
- (int) dims[j]);
- }
- }
- indent -= COL;
+ break;
- indent += COL;
- indentation(indent);
- printf("<%sDataType>\n",xmlnsprefix);
- indent += COL;
- xml_print_datatype(super);
- indent -= COL;
- indentation(indent);
- printf("</%sDataType>\n",xmlnsprefix);
- indent -= COL;
- indentation(indent);
- printf("</%sArrayType>\n",xmlnsprefix);
- /* Close array base type */
- H5Tclose(super);
- break;
+ case H5T_ARRAY:
+ /* Get array base type */
+ super = H5Tget_super(type);
+
+ /* Print lead-in */
+ indentation(indent);
+ printf("<%sArrayType Ndims=\"",xmlnsprefix);
+ ndims = H5Tget_array_ndims(type);
+ printf("%d\">\n", ndims);
+
+ /* Get array information */
+ H5Tget_array_dims(type, dims, perm);
+
+ /* list of dimensions */
+ indent += COL;
+ if (perm != NULL) {
+ /* for each dimension, list */
+ for (j = 0; j < ndims; j++) {
+ indentation(indent);
+ printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"%u\"/>\n",
+ xmlnsprefix,(int) dims[j], (int) perm[j]);
+ }
+ } else {
+ for (j = 0; j < ndims; j++) {
+ indentation(indent);
+ printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"0\"/>\n",
+ xmlnsprefix,
+ (int) dims[j]);
+ }
+ }
+ indent -= COL;
+
+ indent += COL;
+ indentation(indent);
+ printf("<%sDataType>\n",xmlnsprefix);
+ indent += COL;
+ xml_print_datatype(super,0);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sDataType>\n",xmlnsprefix);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sArrayType>\n",xmlnsprefix);
+ /* Close array base type */
+ H5Tclose(super);
+ break;
- default:
- printf("<!-- unknown data type -->");
- d_status = EXIT_FAILURE;
- break;
- }
+ default:
+ printf("<!-- unknown data type -->");
+ d_status = EXIT_FAILURE;
+ break;
+ }
+ } /* end else */
}
/*-------------------------------------------------------------------------
@@ -4057,7 +4050,7 @@ xml_dump_datatype(hid_t type)
}
printf("<%sDataType>\n",xmlnsprefix);
indent += COL;
- xml_print_datatype(type);
+ xml_print_datatype(type,0);
indent -= COL;
indentation(indent);
printf("</%sDataType>\n",xmlnsprefix);
@@ -4373,10 +4366,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data)
static void
xml_dump_named_datatype(hid_t type, const char *name)
{
- int nmembers = 1, x;
int res;
- hid_t mtype;
- char *fname;
char *tmp;
char * dtxid;
char * parentxid;
@@ -4426,73 +4416,15 @@ xml_dump_named_datatype(hid_t type, const char *name)
free(tmp);
indent += COL;
+ indentation(indent);
+ printf("<%sDataType>\n",xmlnsprefix);
- if (H5Tget_class(type) == H5T_COMPOUND) {
- /* Dump this here for sure. */
- nmembers = H5Tget_nmembers(type);
-
- indentation(indent);
- printf("<%sDataType>\n",xmlnsprefix);
- indentation(indent);
- printf("<%sCompoundType>\n",xmlnsprefix);
-
- indent += COL;
- for (x = 0; x < nmembers; x++) {
- char *t_fname;
-
- fname = H5Tget_member_name(type, x);
- mtype = H5Tget_member_type(type, x);
- indentation(indent);
- t_fname = xml_escape_the_name(fname);
- printf("<%sField FieldName=\"%s\">\n",xmlnsprefix, t_fname);
- free(fname);
- free(t_fname);
-
- if ((H5Tget_class(mtype) == H5T_COMPOUND)
- || (H5Tget_class(mtype) == H5T_VLEN)
- || (H5Tget_class(mtype) == H5T_ARRAY)) {
- indent += COL;
-
- /* Nested compound type: recur */
- indentation(indent);
- printf("<%sDataType>\n",xmlnsprefix);
- indent += COL;
- xml_print_datatype(mtype);
- indent -= COL;
- indentation(indent);
- printf("</%sDataType>\n",xmlnsprefix);
- indent -= COL;
- } else {
- indent += COL;
- indentation(indent);
- printf("<%sDataType>\n",xmlnsprefix);
- indent += COL;
- xml_print_datatype(mtype);
- indent -= COL;
- indentation(indent);
- printf("</%sDataType>\n",xmlnsprefix);
- indent -= COL;
- }
-
- indentation(indent);
- printf("</%sField>\n",xmlnsprefix);
- }
+ indent += COL;
+ xml_print_datatype(type,1);
- indent -= COL;
- indentation(indent);
- printf("</%sCompoundType>\n",xmlnsprefix);
- indentation(indent);
- printf("</%sDataType>\n",xmlnsprefix);
- } else {
- /* Other data types: call print_datatype */
- indentation(indent);
- printf("<%sDataType>\n",xmlnsprefix);
- indent += COL;
- xml_print_datatype(type);
- indent -= COL;
- indentation(indent);
- printf("</%sDataType>\n",xmlnsprefix);
- }
+ indent -= COL;
+ indentation(indent);
+ printf("</%sDataType>\n",xmlnsprefix);
indent -= COL;
indentation(indent);
@@ -5492,7 +5424,7 @@ xml_print_enum(hid_t type)
indentation(indent);
printf("<%sDataType>\n",xmlnsprefix);
- xml_print_datatype(super);
+ xml_print_datatype(super,0);
indentation(indent);
printf("</%sDataType>\n",xmlnsprefix);
diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h
index 77cd247..ba1eab2 100644
--- a/tools/h5dump/h5dump.h
+++ b/tools/h5dump/h5dump.h
@@ -25,6 +25,12 @@
printf("%s %s\n", (obj), (begin));
#define end_obj(obj,end) \
- printf("%s %s\n", (end), (obj));
+ if(HDstrlen(end)) \
+ printf("%s", end); \
+ if(HDstrlen(end) && HDstrlen(obj)) \
+ printf(" "); \
+ if(HDstrlen(obj)) \
+ printf("%s", obj); \
+ printf("\n");
#endif /* !H5DUMP_H__ */
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index b2edb8d..0356b2b 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -67,6 +67,7 @@
#define FILE39 "tchar.h5"
#define FILE40 "tattr2.h5"
#define FILE41 "tcompound_complex.h5"
+#define FILE42 "tnamed_dtype_attr.h5"
/* prototypes */
@@ -138,6 +139,12 @@ typedef struct s1_t {
#define F41_ARRAY_DIMd2 6
#define F41_ARRAY_DIMf 10
+/* "File 42" macros */
+/* Name of dataset to create in datafile */
+#define F42_DSETNAME "Dataset"
+#define F42_TYPENAME "Datatype"
+#define F42_ATTRNAME "Attribute"
+
static void gent_group(void)
{
hid_t fid, group;
@@ -4180,6 +4187,66 @@ static void gent_compound_complex(void)
}
+static void gent_named_dtype_attr(void)
+{
+ hid_t file_id;
+ hid_t dset_id;
+ hid_t space_id;
+ hid_t type_id;
+ hid_t attr_id;
+ int data=8;
+ herr_t ret;
+
+ /* Create a file */
+ file_id=H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert(file_id>0);
+
+ /* Create a datatype to commit and use */
+ type_id=H5Tcopy(H5T_NATIVE_INT);
+ assert(type_id>0);
+
+ /* Commit datatype to file */
+ ret=H5Tcommit(file_id,F42_TYPENAME,type_id);
+ assert(ret>=0);
+
+ /* Create dataspace for dataset */
+ space_id=H5Screate(H5S_SCALAR);
+ assert(space_id>0);
+
+ /* Create dataset */
+ dset_id=H5Dcreate(file_id,F42_DSETNAME,type_id,space_id,H5P_DEFAULT);
+ assert(dset_id>0);
+
+ /* Create attribute on dataset */
+ attr_id=H5Acreate(dset_id,F42_ATTRNAME,type_id,space_id,H5P_DEFAULT);
+ assert(dset_id>0);
+
+ /* Write data into the attribute */
+ ret=H5Awrite(attr_id,H5T_NATIVE_INT,&data);
+ assert(ret>=0);
+
+ /* Close attribute */
+ ret=H5Aclose(attr_id);
+ assert(ret>=0);
+
+ /* Close dataset */
+ ret=H5Dclose(dset_id);
+ assert(ret>=0);
+
+ /* Close dataspace */
+ ret=H5Sclose(space_id);
+ assert(ret>=0);
+
+ /* Close datatype */
+ ret=H5Tclose(type_id);
+ assert(ret>=0);
+
+ /* Close file */
+ ret=H5Fclose(file_id);
+ assert(ret>=0);
+}
+
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -4244,5 +4311,7 @@ int main(void)
gent_compound_complex();
+ gent_named_dtype_attr();
+
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh b/tools/h5dump/testh5dump.sh
index d1dfe0c..2e214d8 100755
--- a/tools/h5dump/testh5dump.sh
+++ b/tools/h5dump/testh5dump.sh
@@ -100,6 +100,8 @@ TOOLTEST tattr-1.ddl tattr.h5
TOOLTEST tattr-2.ddl -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 shared datatype in attribute
+TOOLTEST tnamed_dtype_attr.ddl -A tnamed_dtype_attr.h5
# test for displaying soft links
TOOLTEST tslink-1.ddl tslink.h5
diff --git a/tools/h5dump/testh5dumpxml.sh b/tools/h5dump/testh5dumpxml.sh
index bd10949..b7c6f54 100755
--- a/tools/h5dump/testh5dumpxml.sh
+++ b/tools/h5dump/testh5dumpxml.sh
@@ -129,6 +129,7 @@ TOOLTEST tvldtypes3.h5.xml --xml tvldtypes3.h5
TOOLTEST tvlstr.h5.xml --xml tvlstr.h5
TOOLTEST tsaf.h5.xml --xml tsaf.h5
TOOLTEST tempty.h5.xml --xml tempty.h5
+TOOLTEST tnamed_dtype_attr.h5.xml --xml tnamed_dtype_attr.h5
# other options for xml