diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools_dump.c | 17 | ||||
-rw-r--r-- | tools/lib/h5trav.c | 121 | ||||
-rw-r--r-- | tools/lib/h5trav.h | 2 |
3 files changed, 128 insertions, 12 deletions
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index ae43722..8805793 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -262,7 +262,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) { - HERR_INIT(int, SUCCEED) + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ unsigned char *mem = (unsigned char*) _mem; hsize_t i; /*element counter */ size_t size; /*size of each datum */ @@ -391,7 +391,6 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai h5tools_str_close(&buffer); }/* else bin */ -CATCH return ret_value; } @@ -782,7 +781,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, hsize_t curr_pos = 0; hsize_t total_size[H5S_MAX_RANK]; size_t jndx; - int indx; + unsigned indx; int type_size; int ret_value = SUCCEED; unsigned int region_flags; /* buffer extent flags */ @@ -2186,6 +2185,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ case H5T_CSET_RESERVED_14: case H5T_CSET_RESERVED_15: h5tools_str_append(buffer, "H5T_CSET_UNKNOWN;"); + break; case H5T_CSET_ERROR: h5tools_str_append(buffer, "H5T_CSET_ERROR;"); break; @@ -2341,7 +2341,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ ctx->indent_level++; for (i = 0; i < nmembers; i++) { mname = H5Tget_member_name(type, i); - if((mtype = H5Tget_member_type(type, i))>=0) { + if((mtype = H5Tget_member_type(type, i)) >= 0) { ctx->need_prefix = TRUE; h5tools_simple_prefix(stream, info, ctx, 0, 0); @@ -2378,7 +2378,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ case H5T_ENUM: if((super = H5Tget_super(type)) < 0) - H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed"); h5tools_str_append(buffer, "H5T_ENUM %s", h5tools_dump_header_format->enumblockbegin); h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0); @@ -2410,7 +2410,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ case H5T_VLEN: if((super = H5Tget_super(type)) < 0) - H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed"); h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin); @@ -2898,7 +2898,6 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, hsize_t size; /* size of external file */ hsize_t storage_size; hsize_t curr_pos = 0; /* total data element position */ - haddr_t ioffset; h5tools_str_t buffer; /* string into which to render */ /* setup */ @@ -2908,7 +2907,6 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, storage_size = H5Dget_storage_size(obj_id); nfilters = H5Pget_nfilters(dcpl_id); - ioffset = H5Dget_offset(obj_id); HDstrcpy(f_name,"\0"); /*------------------------------------------------------------------------- @@ -3091,6 +3089,8 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0); } else { + haddr_t ioffset; + ctx->indent_level++; ctx->need_prefix = TRUE; @@ -3111,6 +3111,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); h5tools_str_reset(&buffer); + ioffset = H5Dget_offset(obj_id); h5tools_str_append(&buffer,"OFFSET "H5_PRINTF_HADDR_FMT, ioffset); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0); diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index ad8b9fe..0215c46 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -48,6 +48,9 @@ typedef struct { hid_t fid; /* File ID being traversed */ } trav_print_udata_t; +/* format for hsize_t */ +#define HSIZE_T_FORMAT "%"H5_PRINTF_LL_WIDTH"u" + /*------------------------------------------------------------------------- * local functions *------------------------------------------------------------------------- @@ -61,6 +64,46 @@ static void trav_table_addlink(trav_table_t *table, const char *path); /*------------------------------------------------------------------------- + * local variables + *------------------------------------------------------------------------- + */ +static H5_index_t trav_index_by = H5_INDEX_NAME; +static H5_iter_order_t trav_index_order = H5_ITER_INC; + +static int trav_verbosity = 0; + +/*------------------------------------------------------------------------- + * Function: h5trav_set_index + * + * Purpose: Set indexing properties for the objects & links in the file + * + * Return: none + * + *------------------------------------------------------------------------- + */ +void +h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order) +{ + trav_index_by = print_index_by; + trav_index_order = print_index_order; +} + +/*------------------------------------------------------------------------- + * Function: h5trav_set_verbose + * + * Purpose: Set verbosity of file contents 1=>attributes + * + * Return: none + * + *------------------------------------------------------------------------- + */ +void +h5trav_set_verbose(int print_verbose) +{ + trav_verbosity = print_verbose; +} + +/*------------------------------------------------------------------------- * "h5trav info" public functions. used in h5diff *------------------------------------------------------------------------- */ @@ -255,12 +298,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, /* Check for iteration of links vs. visiting all links recursively */ if(recurse) { /* Visit all links in group, recursively */ - if(H5Lvisit_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, traverse_cb, &udata, H5P_DEFAULT) < 0) + if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0) return -1; } /* end if */ else { /* Iterate over links in group */ - if(H5Literate_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0) + if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0) return -1; } /* end else */ @@ -821,6 +864,72 @@ void trav_table_free( trav_table_t *table ) HDfree(table); } +static herr_t +trav_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo, void *op_data) +{ + char *buf; + + buf = (char*)op_data; + if((strlen(buf)==1) && (*buf=='/')) + printf(" %-10s %s%s", "attribute", buf, attr_name); + else + printf(" %-10s %s/%s", "attribute", buf, attr_name); + +#ifdef H5TRAV_PRINT_SPACE + if(trav_verbosity < 2) { +#endif + printf("\n"); +#ifdef H5TRAV_PRINT_SPACE + } + else { + hid_t attr = -1; + hid_t space = -1; + hsize_t size[H5S_MAX_RANK]; + int ndims; + int i; + H5S_class_t space_type; + + if((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) { + space = H5Aget_space(attr); + + /* Data space */ + ndims = H5Sget_simple_extent_dims(space, size, NULL); + space_type = H5Sget_simple_extent_type(space); + switch(space_type) { + case H5S_SCALAR: + /* scalar dataspace */ + printf(" scalar\n"); + break; + + case H5S_SIMPLE: + /* simple dataspace */ + printf(" {"); + for (i=0; i<ndims; i++) { + printf("%s" HSIZE_T_FORMAT, i?", ":"", size[i]); + } + printf("}\n"); + break; + + case H5S_NULL: + /* null dataspace */ + printf(" null\n"); + break; + + default: + /* Unknown dataspace type */ + printf(" unknown\n"); + break; + } /* end switch */ + + H5Sclose(space); + H5Aclose(attr); + } + } +#endif + + return(0); +} + /*------------------------------------------------------------------------- * Function: trav_print_visit_obj @@ -837,8 +946,9 @@ void trav_table_free( trav_table_t *table ) */ static int trav_print_visit_obj(const char *path, const H5O_info_t *oinfo, - const char *already_visited, void UNUSED *udata) + const char *already_visited, void *udata) { + trav_print_udata_t *print_udata = (trav_print_udata_t *)udata; /* Print the name of the object */ /* (no new-line, so that objects that we've encountered before can print * the name of the original object) @@ -862,9 +972,12 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo, } /* end switch */ /* Check if we've already seen this object */ - if(NULL == already_visited) + if(NULL == already_visited) { /* Finish printing line about object */ printf("\n"); + if(trav_verbosity > 0) + H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order, NULL, trav_attr, path, H5P_DEFAULT); + } else /* Print the link's original name */ printf(" -> %s\n", already_visited); diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index da8dc69..c416cf8 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -131,6 +131,7 @@ extern "C" { * "h5trav general" public functions *------------------------------------------------------------------------- */ +H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order); H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata); @@ -159,6 +160,7 @@ H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt); *------------------------------------------------------------------------- */ H5TOOLS_DLL int h5trav_print(hid_t fid); +H5TOOLS_DLL void h5trav_set_verbose(int print_verbose); #ifdef __cplusplus } |