From da12109cfa2c1350a97c3a5ef7d3eccafdb6c0aa Mon Sep 17 00:00:00 2001 From: Patrick Lu Date: Sun, 13 Jun 1999 21:40:52 -0500 Subject: [PATCH] [svn-r1339] added a print_enum function to it that is just taken from a similar funtion in h5ls.c --- tools/h5dump.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/tools/h5dump.c b/tools/h5dump.c index 234a8957ef..1b4322b0c5 100644 --- a/tools/h5dump.c +++ b/tools/h5dump.c @@ -30,6 +30,7 @@ static void dump_data (hid_t, int); static void dump_named_datatype (hid_t , const char *); static int search_obj (table_t, unsigned long *); void indentation(int); +static void print_enum(hid_t type); extern int print_data(hid_t, hid_t, int); @@ -326,8 +327,9 @@ H5G_stat_t statbuf; printf("H5T_ENUM "); super = H5Tget_super(type); print_datatype(super); - printf(" {\n"); - /* print_enum(type);*/ + printf(" {"); + print_enum(type); + printf("\n"); indentation (indent + 3); printf("}\n"); break; @@ -788,6 +790,7 @@ size_t dims[H5DUMP_MAX_RANK]; indentation (indent+COL); if (H5T_ENUM == H5Tget_class(type)) { print_datatype(type); + break; } else { print_datatype(mtype); @@ -1587,3 +1590,97 @@ done: return status; } + + +/*------------------------------------------------------------------------- + * 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 */ + int nmembs; /*number of members */ + int nchars; /*number of output characters */ + hid_t super; /*enum base integer type */ + hid_t native=-1; /*native integer data type */ + size_t dst_size; /*destination value type size */ + int i; /*miscellaneous counters */ + size_t j; + + nmembs = H5Tget_nmembers(type); + super = H5Tget_super(type); + /* + * Determine what data type 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 = calloc(nmembs, sizeof(char*)); + value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); + for (i=0; i0) H5Tconvert(super, native, nmembs, value, NULL); + + /* Sort members by increasing value */ + /*not implemented yet*/ + + /* Print members */ + for (i=0; i", indent+4, ""); + /* printf("\n%*s}", indent, "");*/ + /* return TRUE;*/ +} + + +