diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools_str.c | 92 | ||||
-rw-r--r-- | tools/lib/h5tools_str.h | 1 |
2 files changed, 88 insertions, 5 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 4e8dcc1..22d6677 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1052,7 +1052,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai H5TOOLS_DEBUG("H5T_ENUM"); if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) - h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); + h5tools_str_append(str, "%s", h5tools_escape(enum_name, sizeof(enum_name))); else { size_t i; if (1 == nsize) @@ -1181,10 +1181,49 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai else if (H5Tequal(type, H5T_STD_REF_DSETREG)) { /* if(nsize == H5R_DSET_REG_REF_BUF_SIZE) */ H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF_DSETREG"); + h5tools_str_append(str, H5_TOOLS_DATASET); + h5tools_str_sprint_old_reference(str, container, vp); } else if (H5Tequal(type, H5T_STD_REF_OBJ)) { /* if (nsize == H5R_OBJ_REF_BUF_SIZE) */ + /* + * Object references -- show the type and OID of the referenced object. + */ + H5O_info1_t oi; + H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF_OBJ"); + obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); + H5Oget_info2(obj, &oi, H5O_INFO_BASIC); + + /* Print object type and close object */ + switch (oi.type) { + case H5O_TYPE_GROUP: + h5tools_str_append(str, H5_TOOLS_GROUP); + break; + + case H5O_TYPE_DATASET: + h5tools_str_append(str, H5_TOOLS_DATASET); + break; + + case H5O_TYPE_NAMED_DATATYPE: + h5tools_str_append(str, H5_TOOLS_DATATYPE); + break; + + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + h5tools_str_append(str, "%u-", (unsigned)oi.type); + break; + } /* end switch */ + H5Oclose(obj); + + /* Print OID */ + if (info->obj_hidefileno) + h5tools_str_append(str, info->obj_format, oi.addr); + else + h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); + + h5tools_str_sprint_old_reference(str, container, vp); } /* end else if (H5Tequal(type, H5T_STD_REF_OBJ)) */ } break; @@ -1265,6 +1304,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai nelmts = ((hvl_t *)((void *)cp_vp))->len; for (i = 0; i < nelmts; i++) { + H5TOOLS_DEBUG("H5T_VLEN %d of %ld", i, nelmts); if (i) h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); @@ -1326,6 +1366,48 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /*------------------------------------------------------------------------- + * Function: h5tools_str_sprint_old_reference + * + * Purpose: Object reference -- show the name of the old referenced object. + * + * Return: Nothing + *------------------------------------------------------------------------- + */ +void +h5tools_str_sprint_old_reference(h5tools_str_t *str, hid_t container, void *vp) +{ + hid_t obj = H5I_INVALID_HID; + hid_t region = H5I_INVALID_HID; + char ref_name[1024]; + + H5TOOLS_START_DEBUG(" "); + + h5tools_str_append(str, " \""); + obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, vp); + if (obj >= 0) { + region = H5Rget_region(container, H5R_DATASET_REGION, vp); + if (region >= 0) { + H5Rget_name(obj, H5R_DATASET_REGION, vp, (char *)ref_name, 1024); + h5tools_str_append(str, "%s", ref_name); + + H5Sclose(region); + } /* end if (region >= 0) */ + H5Dclose(obj); + } /* end if (obj >= 0) */ + else { + obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); + if (obj >= 0) { + H5Rget_name(obj, H5R_OBJECT, vp, (char *)ref_name, 1024); + h5tools_str_append(str, "%s", ref_name); + H5Dclose(obj); + } + } + h5tools_str_append(str, "\""); + + H5TOOLS_ENDDEBUG(" "); +} + +/*------------------------------------------------------------------------- * Function: h5tools_str_sprint_reference * * Purpose: Object reference -- show the name of the referenced object. @@ -1402,10 +1484,10 @@ h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *ref_vp) static char * h5tools_escape(char *s /*in,out*/, size_t size) { - register size_t i; - const char * escape; - char octal[8]; - size_t n = HDstrlen(s); + size_t i; + const char *escape; + char octal[8]; + size_t n = HDstrlen(s); for (i = 0; i < n; i++) { switch (s[i]) { diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index eee87c9..15834bb 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -41,6 +41,7 @@ H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5t h5tools_context_t *ctx); H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *); H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *); +H5TOOLS_DLL void h5tools_str_sprint_old_reference(h5tools_str_t *str, hid_t container, void *vp); H5TOOLS_DLL void h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *vp); H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, hid_t type, void *vp, h5tools_context_t *ctx); |