From 759096a9fea4f644d43ee97bb10a738eda543811 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Oct 2004 11:11:28 -0500 Subject: [svn-r9372] Purpose: Refactor code Description: Refactor common code for determining the native type for using in the tools into separate routine. Also, reduce diffs between the two branches and bring back some fixes from the development branch to the release branch. Platforms tested: FreeBSD 4.10 (sleipnir) too minor to require h5committest --- tools/h5dump/h5dump.c | 823 +++++++++++++++++++++-------------------- tools/h5ls/h5ls.c | 545 ++++++++++++++------------- tools/h5repack/h5repack_copy.c | 34 +- tools/h5repack/h5repack_refs.c | 28 +- tools/lib/Makefile.in | 2 +- tools/lib/h5diff_attr.c | 23 +- tools/lib/h5diff_dset.c | 45 +-- tools/lib/h5tools.c | 300 ++++++++------- tools/lib/h5tools.h | 13 +- tools/lib/h5tools_str.c | 12 +- tools/lib/h5tools_type.c | 1 + tools/lib/h5tools_utils.c | 2 +- tools/lib/h5trav.c | 9 +- tools/lib/h5trav.h | 2 +- tools/lib/talign.c | 7 +- 15 files changed, 910 insertions(+), 936 deletions(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 237cbaf..6cab57d 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -38,7 +38,7 @@ int d_status = EXIT_SUCCESS; static int unamedtype = 0; /* shared data type with no name */ static size_t prefix_len = 1024; static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; -char *prefix; +char *prefix; static const char *driver = NULL; /* The driver to open the file with. */ static const dump_header *dump_header_format; @@ -145,8 +145,8 @@ static h5dump_t dataformat = { "%s", /*dset_blockformat_pre */ "%s", /*dset_ptformat_pre */ "%s", /*dset_ptformat */ - 1 , /*array indices */ - 1 /*escape non printable characters */ + 1, /*array indices */ + 1 /*escape non printable characters */ }; /** @@ -229,8 +229,8 @@ static h5dump_t xml_dataformat = { "%s", /*dset_blockformat_pre */ "%s", /*dset_ptformat_pre */ "%s", /*dset_ptformat */ - 0, /*array indices */ - 0 /*escape non printable characters */ + 0, /*array indices */ + 0 /*escape non printable characters */ }; /** XML **/ @@ -522,6 +522,30 @@ static const dump_functions xml_function_table = { */ static const dump_functions *dump_function_table; + +/*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Shutdown MPI & HDF5 and call exit() + * + * Return: Does not return + * + * Programmer: Quincey Koziol + * Saturday, 31. January 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + h5tools_close(); + + exit(ret); +} + + /*------------------------------------------------------------------------- * Function: usage * @@ -621,8 +645,11 @@ static void print_datatype(hid_t type,unsigned in_group) { char *fname; - hid_t nmembers, mtype, str_type; - int i, j, ndims, perm[H5DUMP_MAX_RANK]; + hid_t mtype, str_type; + unsigned nmembers; + int perm[H5DUMP_MAX_RANK]; + unsigned ndims; + unsigned i; size_t size=0; hsize_t dims[H5DUMP_MAX_RANK]; H5T_str_t str_pad; @@ -631,17 +658,18 @@ print_datatype(hid_t type,unsigned in_group) hid_t super; hid_t tmp_type; htri_t is_vlstr=FALSE; + herr_t ret; /* Generic return value */ if (!in_group && H5Tcommitted(type) > 0) { H5Gget_objinfo(type, ".", TRUE, &statbuf); - i = search_obj(type_table, statbuf.objno); + ret = search_obj(type_table, statbuf.objno); - if (i >= 0) { - if (!type_table->objs[i].recorded) - printf("\"/#%lu:%lu\"", type_table->objs[i].objno[0], - type_table->objs[i].objno[1]); + if (ret >= 0) { + if (!type_table->objs[ret].recorded) + printf("\"/#%lu:%lu\"", type_table->objs[ret].objno[0], + type_table->objs[ret].objno[1]); else - printf("\"%s\"", type_table->objs[i].objname); + printf("\"%s\"", type_table->objs[ret].objname); } else { error_msg(progname, "unknown committed type.\n"); d_status = EXIT_FAILURE; @@ -904,8 +932,8 @@ print_datatype(hid_t type,unsigned in_group) H5Tget_array_dims(type, dims, perm); /* Print array dimensions */ - for (j = 0; j < ndims; j++) - printf("[%d]", (int) dims[j]); + for (i = 0; i < ndims; i++) + printf("[%d]", (int) dims[i]); printf(" "); @@ -1259,236 +1287,227 @@ dump_all(hid_t group, const char *name, void * op_data) switch (statbuf.type) { case H5G_LINK: - - - indentation(indent); - targbuf = malloc(statbuf.linklen); - - if (!doxml) { - begin_obj(dump_header_format->softlinkbegin, name, + indentation(indent); + targbuf = malloc(statbuf.linklen); + + if (!doxml) { + begin_obj(dump_header_format->softlinkbegin, name, dump_header_format->softlinkblockbegin); - indentation(indent + COL); - } - - if (H5Gget_linkval(group, name, statbuf.linklen, targbuf) < 0) { - error_msg(progname, "unable to get link value\n"); - d_status = EXIT_FAILURE; - ret = FAIL; - } else { - /* print the value of a soft link */ - if (!doxml) { - /* Standard DDL: no modification */ - printf("LINKTARGET \"%s\"\n", targbuf); - } else { - /* XML */ - char *linkxid = malloc(100); - char *parentxid = malloc(100); - char *targetxid = malloc(100); - char *t_prefix = xml_escape_the_name(strcmp(prefix,"") ? prefix : "/"); - char *t_name = xml_escape_the_name(name); - char *t_targbuf = xml_escape_the_name(targbuf); - char *tmp2, *t_tmp; - int res; - - tmp2 = malloc(strlen(prefix) + statbuf.linklen + 1); - strcpy(tmp2, prefix); - - if (targbuf && targbuf[0] == '/') - strcpy(tmp2, targbuf); - else - strcat(strcat(tmp2, "/"), targbuf); - - t_tmp = xml_escape_the_name(strcat(strcat(tmp, "/"), name)); - res = xml_name_to_XID(t_tmp,linkxid,100,1); - res = xml_name_to_XID(prefix,parentxid,100,1); - - res = xml_name_to_XID(tmp2,targetxid,100,0); - - if (res == 0) { - /* target obj found */ - printf("<%sSoftLink LinkName=\"%s\" " + indentation(indent + COL); + } + + if (H5Gget_linkval(group, name, statbuf.linklen, targbuf) < 0) { + error_msg(progname, "unable to get link value\n"); + d_status = EXIT_FAILURE; + ret = FAIL; + } else { + /* print the value of a soft link */ + if (!doxml) { + /* Standard DDL: no modification */ + printf("LINKTARGET \"%s\"\n", targbuf); + } else { + /* XML */ + char *linkxid = malloc(100); + char *parentxid = malloc(100); + char *targetxid = malloc(100); + char *t_prefix = xml_escape_the_name(strcmp(prefix,"") ? prefix : "/"); + char *t_name = xml_escape_the_name(name); + char *t_targbuf = xml_escape_the_name(targbuf); + char *tmp2, *t_tmp; + int res; + + tmp2 = malloc(strlen(prefix) + statbuf.linklen + 1); + strcpy(tmp2, prefix); + + if (targbuf && targbuf[0] == '/') + strcpy(tmp2, targbuf); + else + strcat(strcat(tmp2, "/"), targbuf); + + t_tmp = xml_escape_the_name(strcat(strcat(tmp, "/"), name)); + xml_name_to_XID(t_tmp,linkxid,100,1); + xml_name_to_XID(prefix,parentxid,100,1); + + res = xml_name_to_XID(tmp2,targetxid,100,0); + + if (res == 0) { + /* target obj found */ + printf("<%sSoftLink LinkName=\"%s\" " "OBJ-XID=\"%s\" " "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" TargetObj=\"%s\" " + "TargetPath=\"%s\" TargetObj=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, - linkxid, - t_tmp, - t_targbuf, targetxid, - parentxid, t_prefix); - free(targetxid); - } else { - /* dangling link -- omit from xml attributes */ - printf("<%sSoftLink LinkName=\"%s\" " + xmlnsprefix, + t_name, + linkxid, + t_tmp, + t_targbuf, targetxid, + parentxid, t_prefix); + free(targetxid); + } else { + /* dangling link -- omit from xml attributes */ + printf("<%sSoftLink LinkName=\"%s\" " "OBJ-XID=\"%s\" " "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" " + "TargetPath=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, - linkxid, - t_tmp, - t_targbuf, - parentxid, t_prefix); - } - - free(t_name); - free(t_targbuf); - free(t_tmp); - free(tmp2); - free(linkxid); - free(parentxid); - } - } - - if (!doxml) { - indentation(indent); - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); - } - - free(targbuf); - - break; + xmlnsprefix, + t_name, + linkxid, + t_tmp, + t_targbuf, + parentxid, t_prefix); + } + + free(t_name); + free(t_targbuf); + free(t_tmp); + free(tmp2); + free(linkxid); + free(parentxid); + } + } + + if (!doxml) { + indentation(indent); + end_obj(dump_header_format->softlinkend, + dump_header_format->softlinkblockend); + } + + free(targbuf); + break; case H5G_GROUP: - - if ((obj = H5Gopen(group, name)) < 0) { - error_msg(progname, "unable to dump group \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; - } else { - size_t new_len = strlen(prefix) + strlen(name) + 2; - - if (prefix_len <= new_len) { - prefix_len = new_len + 1; - prefix = realloc(prefix, prefix_len); - } - - strcat(strcat(prefix, "/"), name); - dump_function_table->dump_group_function(obj, name); - strcpy(prefix, tmp); - H5Gclose(obj); - } - break; + if ((obj = H5Gopen(group, name)) < 0) { + error_msg(progname, "unable to dump group \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + } else { + size_t new_len = strlen(prefix) + strlen(name) + 2; + + if (prefix_len <= new_len) { + prefix_len = new_len + 1; + prefix = realloc(prefix, prefix_len); + } + + strcat(strcat(prefix, "/"), name); + dump_function_table->dump_group_function(obj, name); + strcpy(prefix, tmp); + H5Gclose(obj); + } + + break; case H5G_DATASET: + if ((obj = H5Dopen(group, name)) >= 0) { + /* hard link */ + H5Gget_objinfo(obj, ".", TRUE, &statbuf); + + if (statbuf.nlink > 1) { + i = search_obj(dset_table, statbuf.objno); + + if (i < 0) { + indentation(indent); + begin_obj(dump_header_format->datasetbegin, name, + dump_header_format->datasetblockbegin); + indentation(indent + COL); + error_msg(progname, + "internal error (file %s:line %d)\n", + __FILE__, __LINE__); + indentation(indent); + end_obj(dump_header_format->datasetend, + dump_header_format->datasetblockend); + d_status = EXIT_FAILURE; + ret = FAIL; + H5Dclose(obj); + goto done; + } else if (dset_table->objs[i].displayed) { + indentation(indent); + + if (!doxml) { + begin_obj(dump_header_format->datasetbegin, name, + dump_header_format->datasetblockbegin); + indentation(indent + COL); + printf("%s \"%s\"\n", HARDLINK, + dset_table->objs[i].objname); + indentation(indent); + end_obj(dump_header_format->datasetend, + dump_header_format->datasetblockend); + } else { + /* the XML version */ + char *t_tmp; + char *t_prefix; + char *t_name; + char *dsetxid = malloc(100); + char *parentxid = malloc(100); + char *pointerxid = malloc(100); + char *tx_tmp = malloc(strlen(tmp)+strlen(name)+1); + strcpy(tx_tmp,tmp); + t_tmp = xml_escape_the_name(strcat(strcat(tx_tmp, "/"), name)); + t_prefix = xml_escape_the_name(prefix); + t_name = xml_escape_the_name(name); + xml_name_to_XID( strcat(strcat(tmp,"/"),name), dsetxid,100,1); + xml_name_to_XID( prefix ,parentxid,100,1); + + printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " + "H5Path=\"%s\" Parents=\"%s\" " + "H5ParentPaths=\"%s\">\n", + xmlnsprefix, + t_name, dsetxid, get_next_xid(), + t_tmp, parentxid, + (strcmp(prefix, "") ? t_prefix : "/")); + + indentation(indent + COL); + xml_name_to_XID(dset_table->objs[i].objname,pointerxid,100,1); + printf("<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", + xmlnsprefix, + pointerxid,t_tmp); + indentation(indent); + printf("\n", xmlnsprefix); + + free(t_name); + free(dsetxid); + free(parentxid); + free(pointerxid); + free(t_tmp); + free(tx_tmp); + free(t_prefix); + } + + H5Dclose(obj); + goto done; + } else { + dset_table->objs[i].displayed = 1; + + } + } + + dump_function_table->dump_dataset_function(obj, name, NULL); + H5Dclose(obj); + } else { + error_msg(progname, "unable to dump dataset \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + } + break; - if ((obj = H5Dopen(group, name)) >= 0) { - /* hard link */ - H5Gget_objinfo(obj, ".", TRUE, &statbuf); - - if (statbuf.nlink > 1) { - i = search_obj(dset_table, statbuf.objno); - - if (i < 0) { - indentation(indent); - begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); - indentation(indent + COL); - error_msg(progname, - "internal error (file %s:line %d)\n", - __FILE__, __LINE__); - indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); - d_status = EXIT_FAILURE; - ret = FAIL; - H5Dclose(obj); - goto done; - } else if (dset_table->objs[i].displayed) { - indentation(indent); - - if (!doxml) { - begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); - indentation(indent + COL); - printf("%s \"%s\"\n", HARDLINK, - dset_table->objs[i].objname); - indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); - } else { - /* the XML version */ - char *t_tmp; - char *t_prefix; - char *t_name; - char *dsetxid = malloc(100); - char *parentxid = malloc(100); - char *pointerxid = malloc(100); - char *tx_tmp = malloc(strlen(tmp)+strlen(name)+1); - strcpy(tx_tmp,tmp); - t_tmp = xml_escape_the_name(strcat(strcat(tx_tmp, "/"), name)); - t_prefix = xml_escape_the_name(prefix); - t_name = xml_escape_the_name(name); - xml_name_to_XID( strcat(strcat(tmp,"/"),name), dsetxid,100,1); - xml_name_to_XID( prefix ,parentxid,100,1); - - printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " - "H5Path=\"%s\" Parents=\"%s\" " - "H5ParentPaths=\"%s\">\n", - xmlnsprefix, - t_name, dsetxid, get_next_xid(), - t_tmp, parentxid, - (strcmp(prefix, "") ? t_prefix : "/")); - - indentation(indent + COL); - xml_name_to_XID(dset_table->objs[i].objname,pointerxid,100,1); - printf("<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", - xmlnsprefix, - pointerxid,t_tmp); - indentation(indent); - printf("\n", xmlnsprefix); - - free(t_name); - free(dsetxid); - free(parentxid); - free(pointerxid); - free(t_tmp); -#ifdef WIN32 - /* free(tx_tmp);*/ -#else - free(tx_tmp); -#endif - free(t_prefix); - } - - H5Dclose(obj); - goto done; - } else { - dset_table->objs[i].displayed = 1; - - } - } - - dump_function_table->dump_dataset_function(obj, name, NULL); - H5Dclose(obj); - } else { - error_msg(progname, "unable to dump dataset \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; - } - break; - case H5G_TYPE: - - if ((obj = H5Topen(group, name)) < 0) { - error_msg(progname, "unable to dump data type \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; - } else { - dump_function_table->dump_named_datatype_function(obj, name); - H5Tclose(obj); - } - break; - + if ((obj = H5Topen(group, name)) < 0) { + error_msg(progname, "unable to dump data type \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + } else { + dump_function_table->dump_named_datatype_function(obj, name); + H5Tclose(obj); + } + break; + default: - error_msg(progname, "unknown object \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; + error_msg(progname, "unknown object \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; } - + done: free(tmp); return ret; @@ -1520,7 +1539,6 @@ dump_named_datatype(hid_t type, const char *name) indentation(indent + COL); print_datatype(type,1); printf(";\n"); - dump_comment(type); } end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend); @@ -1627,20 +1645,19 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) indentation(indent); begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin); - type = H5Dget_type(did); - space = H5Dget_space(did); - dcpl_id = H5Dget_create_plist(did); - + type = H5Dget_type(did); + space = H5Dget_space(did); + dcpl_id = H5Dget_create_plist(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); + dump_oid(did); + + if (display_dcpl) + dump_dcpl(dcpl_id, type, did); if (display_data) switch (H5Tget_class(type)) { @@ -1671,7 +1688,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) indent -= COL; H5Tclose(type); H5Sclose(space); - H5Pclose(dcpl_id); + H5Pclose(dcpl_id); indentation(indent); end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); @@ -1906,20 +1923,13 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) outputformat = &string_dataformat; } - - status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth); - H5Tclose(f_type); + 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 */ - H5T_class_t type_class; - type = H5Aget_type(obj_id); - type_class = H5Tget_class(type); - if(type_class==H5T_BITFIELD) - p_type=H5Tcopy(type); - else - p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT); + p_type = h5tools_get_native_type(type); space = H5Aget_space(obj_id); ndims = H5Sget_simple_extent_dims(space, size, NULL); @@ -2025,35 +2035,29 @@ static void dump_comment(hid_t obj_id) 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; - void *buf=NULL; - int nelmts=1; - h5dump_t *outputformat = &dataformat; - hid_t n_type; - H5T_class_t type_class; - - memset(&ctx, 0, sizeof(ctx)); - ctx.indent_level=2; - - type_class = H5Tget_class(type_id); - if(type_class==H5T_BITFIELD) - n_type=H5Tcopy(type_id); - else - n_type = H5Tget_native_type(type_id,H5T_DIR_DEFAULT); + h5tools_context_t ctx; /*print context */ + size_t size; + void *buf=NULL; + int nelmts=1; + h5dump_t *outputformat = &dataformat; + hid_t n_type; - size = H5Tget_size(n_type); - buf = malloc(size); + memset(&ctx, 0, sizeof(ctx)); + ctx.indent_level=2; - 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); + n_type = h5tools_get_native_type(type_id); + + size = H5Tget_size(n_type); + buf = malloc(size); + + H5Pget_fill_value(dcpl, n_type, buf); - H5Tclose(n_type); + h5tools_dump_simple_data(stdout, outputformat, obj_id, &ctx, START_OF_DATA | END_OF_DATA, nelmts, n_type, buf); - if (buf) - free (buf); + H5Tclose(n_type); + + if (buf) + free (buf); } @@ -2396,7 +2400,7 @@ dump_fcpl(hid_t fid) int freelist; /* free list version # */ int stab; /* symbol table entry version # */ int shhdr; /* shared object header version # */ - hid_t driver; /* file driver */ + hid_t fdriver; /* file driver */ char dname[15]; /* buffer to store driver name */ fcpl=H5Fget_create_plist(fid); @@ -2406,10 +2410,10 @@ dump_fcpl(hid_t fid) H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); H5Pget_istore_k(fcpl,&istore_ik); H5Pclose(fcpl); - fapl = h5_fileaccess(); - driver = H5Pget_driver(fapl); + fapl=h5_fileaccess(); + fdriver=H5Pget_driver(fapl); H5Pclose(fapl); - + /*------------------------------------------------------------------------- * SUPER_BLOCK *------------------------------------------------------------------------- @@ -2432,40 +2436,40 @@ dump_fcpl(hid_t fid) indentation(indent + COL); printf("%s %d\n","BTREE_LEAF", sym_lk); - if (H5FD_CORE==driver) + if (H5FD_CORE==fdriver) { strcpy(dname,"H5FD_CORE"); } - else if (H5FD_FAMILY==driver) + else if (H5FD_FAMILY==fdriver) { strcpy(dname,"H5FD_FAMILY"); } - else if (H5FD_GASS==driver) + else if (H5FD_GASS==fdriver) { strcpy(dname,"H5FD_GASS"); } - else if (H5FD_LOG==driver) + else if (H5FD_LOG==fdriver) { strcpy(dname,"H5FD_LOG"); } - else if (H5FD_MPIO==driver) + else if (H5FD_MPIO==fdriver) { strcpy(dname,"H5FD_MPIO"); } - else if (H5FD_MULTI==driver) + else if (H5FD_MULTI==fdriver) { strcpy(dname,"H5FD_MULTI"); } - else if (H5FD_SEC2==driver) + else if (H5FD_SEC2==fdriver) { strcpy(dname,"H5FD_SEC2"); } - else if (H5FD_STDIO==driver) + else if (H5FD_STDIO==fdriver) { strcpy(dname,"H5FD_STDIO"); } #ifdef H5_HAVE_STREAM - else if (H5FD_STREAM==driver) + else if (H5FD_STREAM==fdriver) { strcpy(dname,"H5FD_STREAM"); } @@ -2808,7 +2812,6 @@ handle_datasets(hid_t fid, char *dset, void *data) end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); } else { - dset_table->objs[idx].displayed = 1; dump_dataset(dsetid, dset, sset); } @@ -2959,9 +2962,8 @@ handle_datatypes(hid_t fid, char *type, void UNUSED * data) type_table->objs[idx].objno[0], type_table->objs[idx].objno[1]); - if (!strncmp(name, type, strlen(type)) || - !strncmp(name1, type, strlen(type))) - break; + if (!strncmp(name, type, strlen(type)) || !strncmp(name1, type, strlen(type))) + break; } idx++; @@ -3059,7 +3061,7 @@ parse_start: break; case 'V': print_version(progname); - exit(EXIT_SUCCESS); + leave(EXIT_SUCCESS); break; case 'w': nCols = atoi(opt_arg); @@ -3134,7 +3136,7 @@ parse_start: if (set_output_file(opt_arg) < 0){ /* failed to set output file */ usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } usingdasho = TRUE; @@ -3166,7 +3168,7 @@ parse_start: /* To Do: check format of this value? */ if (!useschema) { usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } if (strcmp(opt_arg,":") == 0) { xmlnsprefix = ""; @@ -3187,7 +3189,7 @@ parse_start: error_msg(progname, "option `-%c' can only be used after --dataset option\n", opt); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } if (last_dset->subset_info) { @@ -3233,11 +3235,11 @@ end_collect: case 'h': usage(progname); - exit(EXIT_SUCCESS); + leave(EXIT_SUCCESS); case '?': default: usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } } @@ -3246,7 +3248,7 @@ parse_end: if (argc <= opt_ind) { error_msg(progname, "missing file name\n"); usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } return hand; } @@ -3329,7 +3331,7 @@ main(int argc, const char *argv[]) hid_t fid, gid; const char *fname = NULL; void *edata; - hid_t (*func)(void*); + H5E_auto_t func; find_objs_t info; struct handler_t *hand; int i; @@ -3350,23 +3352,23 @@ main(int argc, const char *argv[]) if (!display_all) { error_msg(progname, "option \"%s\" not available for XML\n", "to display selected objects"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (display_bb) { error_msg(progname, "option \"%s\" not available for XML\n", "--boot-block"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (display_oid == 1) { error_msg(progname, "option \"%s\" not available for XML\n", "--object-ids"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (display_char == TRUE) { error_msg(progname, "option \"%s\" not available for XML\n", "--string"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } else if (usingdasho) { error_msg(progname, "option \"%s\" not available for XML\n", "--output"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } } else { if (xml_dtd_uri) { @@ -3378,15 +3380,15 @@ main(int argc, const char *argv[]) if (argc <= opt_ind) { error_msg(progname, "missing file name\n"); usage(progname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } fname = argv[opt_ind]; - fid = h5tools_fopen(fname, driver, NULL, 0); + fid = h5tools_fopen(fname, driver, NULL, 0, argc, argv); if (fid < 0) { error_msg(progname, "unable to open file \"%s\"\n", fname); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } /* allocate and initialize internal data structure */ @@ -3404,7 +3406,7 @@ main(int argc, const char *argv[]) info.dset_table = dset_table; info.status = d_status; - thefile = fid; + thefile = fid; /* find all objects that might be targets of a refernce */ if ((gid = H5Gopen(fid, "/")) < 0) { error_msg(progname, "unable to open root group\n"); @@ -3432,7 +3434,7 @@ main(int argc, const char *argv[]) } else { if (useschema && strcmp(xmlnsprefix,"")) { error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); - exit(EXIT_FAILURE); + leave(EXIT_FAILURE); } } } @@ -3454,8 +3456,6 @@ main(int argc, const char *argv[]) goto done; } - - /* start to dump */ if (!doxml) { begin_obj(dump_header_format->filebegin, fname, @@ -3563,9 +3563,9 @@ done: /* To Do: clean up XML table */ - h5tools_close(); H5Eset_auto(func, edata); - return d_status; + + leave(d_status); } /*------------------------------------------------------------------------- @@ -3587,14 +3587,15 @@ print_enum(hid_t type) { char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ - int nmembs; /*number of members */ + unsigned 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; + unsigned i; nmembs = H5Tget_nmembers(type); + assert(nmembs>0); super = H5Tget_super(type); /* @@ -3617,9 +3618,8 @@ print_enum(hid_t type) } /* Get the names and raw values of all members */ - assert(nmembs>0); - name = calloc((size_t)nmembs, sizeof(char *)); - value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); + name = calloc(nmembs, sizeof(char *)); + value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { name[i] = H5Tget_member_name(type, i); @@ -3683,42 +3683,42 @@ print_enum(hid_t type) int xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) { - struct ref_path_table_entry_t *r; - char *os; - - if (outlen < 22) return 1; - - os = outstr; - - r = ref_path_table_lookup(str); - if (r == NULL) { - if (strlen(str) == 0) { - r = ref_path_table_lookup("/"); - if (r == NULL) { - if (gen) { - sprintf(os," "); /* ?? */ - r = ref_path_table_gen_fake(str); - sprintf(os,"xid_%lu-%lu",r->statbuf.objno[0],r->statbuf.objno[1]); - return 0; - } else { - return 1; - } - } - } else { - if (gen) { - sprintf(os," "); /* ?? */ - r = ref_path_table_gen_fake(str); - sprintf(os,"xid_%lu-%lu",r->statbuf.objno[0],r->statbuf.objno[1]); - return 0; - } else { - return 1; - } - } - } + ref_path_table_entry_t *r; + char *os; + + if (outlen < 22) return 1; + + os = outstr; + + r = ref_path_table_lookup(str); + if (r == NULL) { + if (strlen(str) == 0) { + r = ref_path_table_lookup("/"); + if (r == NULL) { + if (gen) { + sprintf(os," "); /* ?? */ + r = ref_path_table_gen_fake(str); + sprintf(os,"xid_%lu-%lu",r->statbuf.objno[0],r->statbuf.objno[1]); + return 0; + } else { + return 1; + } + } + } else { + if (gen) { + sprintf(os," "); /* ?? */ + r = ref_path_table_gen_fake(str); + sprintf(os,"xid_%lu-%lu",r->statbuf.objno[0],r->statbuf.objno[1]); + return 0; + } else { + return 1; + } + } + } - sprintf(os,"xid_%lu-%lu",r->statbuf.objno[0],r->statbuf.objno[1]); + sprintf(os,"xid_%lu-%lu",r->statbuf.objno[0],r->statbuf.objno[1]); - return(0); + return(0); } static const char *quote = """; @@ -3927,8 +3927,11 @@ static void xml_print_datatype(hid_t type, unsigned in_group) { char *fname; - hid_t nmembers, mtype; - int i, j, ndims, perm[H5DUMP_MAX_RANK]; + hid_t mtype; + unsigned nmembers; + int perm[H5DUMP_MAX_RANK]; + unsigned ndims; + unsigned i; size_t size; hsize_t dims[H5DUMP_MAX_RANK]; H5T_str_t str_pad; @@ -3945,19 +3948,20 @@ xml_print_datatype(hid_t type, unsigned in_group) size_t msize; int nmembs; htri_t is_vlstr=FALSE; - + herr_t ret; + 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); + ret = search_obj(type_table, statbuf.objno); - if (i >= 0) { + if (ret >= 0) { /* This should be defined somewhere else */ /* These 2 cases are handled the same right now, but probably will have something different eventually */ char * dtxid = malloc(100); - xml_name_to_XID(type_table->objs[i].objname,dtxid,100,1); - if (!type_table->objs[i].recorded) { + xml_name_to_XID(type_table->objs[ret].objname,dtxid,100,1); + if (!type_table->objs[ret].recorded) { /* 'anonymous' NDT. Use it's object num. as it's name. */ printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n", @@ -3965,7 +3969,7 @@ xml_print_datatype(hid_t type, unsigned in_group) dtxid); } else { /* point to the NDT by name */ - char *t_objname = xml_escape_the_name(type_table->objs[i].objname); + char *t_objname = xml_escape_the_name(type_table->objs[ret].objname); printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", xmlnsprefix, dtxid,t_objname); @@ -4245,7 +4249,7 @@ xml_print_datatype(hid_t type, unsigned in_group) indentation(indent); printf("<%sArrayType Ndims=\"",xmlnsprefix); ndims = H5Tget_array_ndims(type); - printf("%d\">\n", ndims); + printf("%u\">\n", ndims); /* Get array information */ H5Tget_array_dims(type, dims, perm); @@ -4254,17 +4258,17 @@ xml_print_datatype(hid_t type, unsigned in_group) indent += COL; if (perm != NULL) { /* for each dimension, list */ - for (j = 0; j < ndims; j++) { + for (i = 0; i < ndims; i++) { indentation(indent); printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"%u\"/>\n", - xmlnsprefix,(int) dims[j], (int) perm[j]); + xmlnsprefix,(int) dims[i], (int) perm[i]); } } else { - for (j = 0; j < ndims; j++) { + for (i = 0; i < ndims; i++) { indentation(indent); printf("<%sArrayDimension DimSize=\"%u\" DimPerm=\"0\"/>\n", xmlnsprefix, - (int) dims[j]); + (int) dims[i]); } } indent -= COL; @@ -4490,13 +4494,7 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU status = xml_print_strs(obj_id, ATTRIBUTE_DATA); } else { /* all other data */ - H5T_class_t type_class; - - type_class = H5Tget_class(type); - if(type_class==H5T_BITFIELD) - p_type=H5Tcopy(type); - else - p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT); + p_type = h5tools_get_native_type(type); H5Tclose(type); @@ -4594,7 +4592,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) case H5T_COMPOUND: indentation(indent); printf("\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL,0); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); break; case H5T_REFERENCE: @@ -4617,7 +4615,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) case H5T_VLEN: printf("\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL,0); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); break; default: indentation(indent); @@ -4632,11 +4630,11 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) } } else { /* The case of an attribute never yet written ?? */ - indentation(indent); - printf("<%sData>\n",xmlnsprefix); indentation(indent + COL); + printf("<%sData>\n",xmlnsprefix); + indentation(indent + COL + COL); printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); + indentation(indent + COL); printf("\n",xmlnsprefix); } @@ -4720,6 +4718,7 @@ xml_dump_named_datatype(hid_t type, const char *name) free(t_tmp); free(t_prefix); free(t_name); + free(tmp); indent += COL; indentation(indent); @@ -5037,7 +5036,7 @@ xml_print_refs(hid_t did, int source) ssiz = H5Sget_simple_extent_npoints(space); for (i = 0; i < ssiz; i++) { - path = lookup_ref_path(refbuf); + path = lookup_ref_path(*refbuf); indentation(indent + COL); if (!path) { @@ -5052,6 +5051,8 @@ xml_print_refs(hid_t did, int source) refbuf++; } + free(buf); + return SUCCEED; } @@ -5144,9 +5145,9 @@ xml_print_strs(hid_t did, int source) if(is_vlstr) { onestring = *(char **)bp; if(onestring) - str_size = (size_t)strlen(onestring); + str_size = (size_t)HDstrlen(onestring); } else { - strncpy(onestring, bp, tsiz); + HDstrncpy(onestring, bp, tsiz); str_size = tsiz; } indentation(indent + COL); @@ -5308,7 +5309,7 @@ static void xml_dump_fill_value(hid_t dcpl, hid_t type) size_t sz; size_t i; hsize_t space; -void * buf=NULL; +void * buf; char * path; char * name; indent += COL; @@ -5416,8 +5417,8 @@ char * name; printf("<%sNoData/>\n",xmlnsprefix); break; } - free(buf); } + free(buf); indent -= COL; indentation(indent); printf("\n",xmlnsprefix); @@ -5592,7 +5593,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) printf("<%sFillValue>\n",xmlnsprefix); indent += COL; H5Pfill_value_defined(dcpl, &fvstatus); - if (fvstatus == H5D_FILL_VALUE_UNDEFINED) { + if (fvstatus == H5D_FILL_VALUE_UNDEFINED || + (fvstatus==H5D_FILL_VALUE_DEFAULT && ft==H5D_FILL_TIME_IFSET)) { indentation(indent + COL); printf("<%sNoFill/>\n",xmlnsprefix); } else { @@ -5625,7 +5627,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) case H5T_OPAQUE: case H5T_ENUM: case H5T_ARRAY: - dump_function_table->dump_data_function(did, DATASET_DATA, NULL,0); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); break; case H5T_TIME: @@ -5644,7 +5646,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) case H5T_COMPOUND: indentation(indent); printf("\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL,0); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); break; case H5T_REFERENCE: @@ -5667,7 +5669,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) case H5T_VLEN: printf("\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL,0); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); break; default: indentation(indent); @@ -5682,16 +5684,17 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) } } else { /* no data written */ - indentation(indent); + indentation(indent + COL); printf("<%sData>\n",xmlnsprefix); - indentation(indent); + indentation(indent + COL + COL); printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); + indentation(indent + COL); printf("\n",xmlnsprefix); } H5Tclose(type); H5Sclose(space); + H5Pclose(dcpl); indentation(indent); printf("\n", xmlnsprefix); } @@ -5715,11 +5718,11 @@ xml_print_enum(hid_t type) { char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ - int nmembs; /*number of members */ + unsigned nmembs; /*number of members */ 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 */ + unsigned i; /*miscellaneous counters */ size_t j; nmembs = H5Tget_nmembers(type); @@ -5751,8 +5754,8 @@ xml_print_enum(hid_t type) } /* Get the names and raw values of all members */ - name = calloc((size_t)nmembs, sizeof(char *)); - value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); + name = calloc(nmembs, sizeof(char *)); + value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { name[i] = H5Tget_member_name(type, i); @@ -5831,24 +5834,14 @@ xml_print_enum(hid_t type) * *------------------------------------------------------------------------- */ - - - -static hid_t h5_fileaccess(void) +static hid_t +h5_fileaccess(void) { - static const char *multi_letters = "msbrglo"; - + static const char *multi_letters = "msbrglo"; const char *val = NULL; const char *name; char s[1024]; hid_t fapl = -1; - hsize_t fam_size = 100*1024*1024; /*100 MB*/ -#ifdef H5_WANT_H5_V1_4_COMPAT - long verbosity = 1; -#else /* H5_WANT_H5_V1_4_COMPAT */ - long log_flags = H5FD_LOG_LOC_IO; -#endif /* H5_WANT_H5_V1_4_COMPAT */ - H5FD_mem_t mt; /* First use the environment variable, then the constant */ val = HDgetenv("HDF5_DRIVER"); @@ -5885,6 +5878,7 @@ static hid_t h5_fileaccess(void) 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); @@ -5904,13 +5898,21 @@ static hid_t h5_fileaccess(void) return -1; } } else if (!HDstrcmp(name, "family")) { + hsize_t fam_size = 100*1024*1024; /*100 MB*/ + /* Family of files, each 1MB and using the default driver */ - if ((val=HDstrtok(NULL, " \t\n\r"))) { + if ((val=HDstrtok(NULL, " \t\n\r"))) fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - } - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; + if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) + return -1; } else if (!HDstrcmp(name, "log")) { #ifdef H5_WANT_H5_V1_4_COMPAT + long verbosity = 1; +#else /* H5_WANT_H5_V1_4_COMPAT */ + long log_flags = H5FD_LOG_LOC_IO; +#endif /* H5_WANT_H5_V1_4_COMPAT */ + +#ifdef H5_WANT_H5_V1_4_COMPAT /* Log file access */ if ((val = strtok(NULL, " \t\n\r"))) verbosity = strtol(val, NULL, 0); @@ -5932,4 +5934,3 @@ static hid_t h5_fileaccess(void) return fapl; } - diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index ca0140d..07b53d1 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -711,11 +711,14 @@ display_cmpd_type(hid_t type, int ind) char *name=NULL; /* member name */ size_t size; /* total size of type in bytes */ hid_t subtype; /* member data type */ - int i, n; /* miscellaneous counters */ + unsigned nmembs; /* number of members */ + int n; /* miscellaneous counters */ + unsigned i; /* miscellaneous counters */ if (H5T_COMPOUND!=H5Tget_class(type)) return FALSE; printf("struct {"); - for (i=0; i0); super = H5Tget_super(type); printf("enum "); display_type(super, ind+4); @@ -779,23 +783,22 @@ display_enum_type(hid_t type, int ind) * 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; - } + 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); + dst_size = H5Tget_size(type); } /* Get the names and raw values of all members */ - assert(nmembs>0); - name = calloc((size_t)nmembs, sizeof(char*)); - value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); + name = calloc(nmembs, sizeof(char*)); + value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); for (i=0; i=0) { + if (p_type>=0) { temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)); assert(temp_need==(hsize_t)((size_t)temp_need)); need = (size_t)temp_need; - buf = malloc(need); - assert(buf); - if (H5Aread(attr, p_type, buf)>=0) { - h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1); - } - free(buf); - H5Tclose(p_type); - } - - H5Sclose(space); - H5Tclose(type); - H5Aclose(attr); + buf = malloc(need); + assert(buf); + if (H5Aread(attr, p_type, buf)>=0) + h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1); + free(buf); + H5Tclose(p_type); + } + + H5Sclose(space); + H5Tclose(type); + H5Aclose(attr); } else { - putchar('\n'); + putchar('\n'); } return 0; @@ -1442,8 +1439,8 @@ dataset_list1(hid_t dset) { hsize_t cur_size[64]; /* current dataset dimensions */ hsize_t max_size[64]; /* maximum dataset dimensions */ - hid_t space; /* data space */ - int ndims; /* dimensionality */ + hid_t space; /* data space */ + int ndims; /* dimensionality */ int i; /* Information that goes on the same row as the name. The name has @@ -1970,6 +1967,29 @@ get_width(void) /*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Close HDF5 and MPI and call exit() + * + * Return: Does not return + * + * Programmer: Quincey Koziol + * Saturday, January 31, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + h5tools_close(); + + exit(ret); +} + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Opens a file and lists the specified group @@ -1986,7 +2006,7 @@ get_width(void) *------------------------------------------------------------------------- */ int -main (int argc, char *argv[]) +main (int argc, const char *argv[]) { hid_t file=-1, root=-1; char *fname=NULL, *oname=NULL, *x; @@ -2023,132 +2043,132 @@ main (int argc, char *argv[]) /* Switches come before non-switch arguments */ for (argno=1; argno=argc) { - usage(progname); - exit(1); - } else { - s = argv[++argno]; - } - width_g = (int)strtol(s, &rest, 0); - if (width_g<=0 || *rest) { - usage(progname); - exit(1); - } - } else if (!strcmp(argv[argno], "--verbose")) { - verbose_g++; - } else if (!strcmp(argv[argno], "--version")) { + if (!strcmp(argv[argno], "--")) { + /* Last switch */ + argno++; + break; + } else if (!strcmp(argv[argno], "--help")) { + usage(progname); + leave(0); + } else if (!strcmp(argv[argno], "--address")) { + address_g = TRUE; + } else if (!strcmp(argv[argno], "--data")) { + data_g = TRUE; + } else if (!strcmp(argv[argno], "--errors")) { + show_errors_g = TRUE; + } else if (!strcmp(argv[argno], "--full")) { + fullname_g = TRUE; + } else if (!strcmp(argv[argno], "--group")) { + grp_literal_g = TRUE; + } else if (!strcmp(argv[argno], "--label")) { + label_g = TRUE; + } else if (!strcmp(argv[argno], "--recursive")) { + recursive_g = TRUE; + fullname_g = TRUE; + } else if (!strcmp(argv[argno], "--simple")) { + simple_output_g = TRUE; + } else if (!strcmp(argv[argno], "--string")) { + string_g = TRUE; + } else if (!strncmp(argv[argno], "--width=", 8)) { + width_g = (int)strtol(argv[argno]+8, &rest, 0); + if (width_g<=0 || *rest) { + usage(progname); + leave(1); + } + } else if (!strcmp(argv[argno], "--width")) { + if (argno+1>=argc) { + usage(progname); + leave(1); + } else { + s = argv[++argno]; + } + width_g = (int)strtol(s, &rest, 0); + if (width_g<=0 || *rest) { + usage(progname); + leave(1); + } + } else if (!strcmp(argv[argno], "--verbose")) { + verbose_g++; + } else if (!strcmp(argv[argno], "--version")) { print_version(progname); - exit(0); - } else if (!strcmp(argv[argno], "--hexdump")) { - hexdump_g = TRUE; - } else if (!strncmp(argv[argno], "-w", 2)) { - if (argv[argno][2]) { - s = argv[argno]+2; - } else if (argno+1>=argc) { - usage(progname); - exit(1); - } else { - s = argv[++argno]; - } - width_g = (int)strtol(s, &rest, 0); - if (width_g<=0 || *rest) { - usage(progname); - exit(1); - } - } else if ('-'!=argv[argno][1]) { - /* Single-letter switches */ - for (s=argv[argno]+1; *s; s++) { - switch (*s) { - case '?': - case 'h': /* --help */ - usage(progname); - exit(0); - case 'a': /* --address */ - address_g = TRUE; - break; - case 'd': /* --data */ - data_g = TRUE; - break; - case 'e': /* --errors */ - show_errors_g = TRUE; - break; - case 'f': /* --full */ - fullname_g = TRUE; - break; - case 'g': /* --group */ - grp_literal_g = TRUE; - break; - case 'l': /* --label */ - label_g = TRUE; - break; - case 'r': /* --recursive */ - recursive_g = TRUE; - fullname_g = TRUE; - break; - case 'S': /* --simple */ - simple_output_g = TRUE; - break; - case 's': /* --string */ - string_g = TRUE; - break; - case 'v': /* --verbose */ - verbose_g++; - break; - case 'V': /* --version */ - print_version(progname); - exit(0); - case 'x': /* --hexdump */ - hexdump_g = TRUE; - break; - default: - usage(progname); - exit(1); - } - } - } else { - usage(progname); - exit(1); - } + leave(0); + } else if (!strcmp(argv[argno], "--hexdump")) { + hexdump_g = TRUE; + } else if (!strncmp(argv[argno], "-w", 2)) { + if (argv[argno][2]) { + s = argv[argno]+2; + } else if (argno+1>=argc) { + usage(progname); + leave(1); + } else { + s = argv[++argno]; + } + width_g = (int)strtol(s, &rest, 0); + if (width_g<=0 || *rest) { + usage(progname); + leave(1); + } + } else if ('-'!=argv[argno][1]) { + /* Single-letter switches */ + for (s=argv[argno]+1; *s; s++) { + switch (*s) { + case '?': + case 'h': /* --help */ + usage(progname); + leave(0); + case 'a': /* --address */ + address_g = TRUE; + break; + case 'd': /* --data */ + data_g = TRUE; + break; + case 'e': /* --errors */ + show_errors_g = TRUE; + break; + case 'f': /* --full */ + fullname_g = TRUE; + break; + case 'g': /* --group */ + grp_literal_g = TRUE; + break; + case 'l': /* --label */ + label_g = TRUE; + break; + case 'r': /* --recursive */ + recursive_g = TRUE; + fullname_g = TRUE; + break; + case 'S': /* --simple */ + simple_output_g = TRUE; + break; + case 's': /* --string */ + string_g = TRUE; + break; + case 'v': /* --verbose */ + verbose_g++; + break; + case 'V': /* --version */ + print_version(progname); + leave(0); + case 'x': /* --hexdump */ + hexdump_g = TRUE; + break; + default: + usage(progname); + leave(1); + } + } + } else { + usage(progname); + leave(1); + } } /* If no arguments remain then print a usage message (instead of doing * absolutely nothing ;-) */ if (argno>=argc) { - usage(progname); - exit(1); + usage(progname); + leave(1); } /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ @@ -2169,58 +2189,57 @@ main (int argc, char *argv[]) * doesn't exist). */ show_file_name_g = (argc-argno > 1); /*show file names if more than one*/ while (argno=0) { - if (verbose_g) { - printf("Opened \"%s\" with %s driver.\n", - fname, drivername); - } - break; /*success*/ - } - - /* Shorten the file name; lengthen the object name */ - x = oname; - oname = strrchr(fname, '/'); - if (x) *x = '/'; - if (!oname) break; - *oname = '\0'; - } - if (file<0) { - fprintf(stderr, "%s: unable to open file\n", argv[argno-1]); + fname = HDstrdup(argv[argno++]); + oname = NULL; + file = -1; + + while (fname && *fname) { + file = h5tools_fopen(fname, NULL, drivername, sizeof drivername, argc, argv); + + if (file>=0) { + if (verbose_g) { + printf("Opened \"%s\" with %s driver.\n", + fname, drivername); + } + break; /*success*/ + } + + /* Shorten the file name; lengthen the object name */ + x = oname; + oname = strrchr(fname, '/'); + if (x) *x = '/'; + if (!oname) break; + *oname = '\0'; + } + if (file<0) { + fprintf(stderr, "%s: unable to open file\n", argv[argno-1]); continue; - } - if (oname) oname++; - if (!oname || !*oname) oname = root_name; + } + if (oname) oname++; + if (!oname || !*oname) oname = root_name; - /* Open the object and display it's information */ - if (H5Gget_objinfo(file, oname, TRUE, &sb)>=0 && - H5G_GROUP==sb.type && !grp_literal_g) { + /* Open the object and display it's information */ + if (H5Gget_objinfo(file, oname, TRUE, &sb)>=0 && + H5G_GROUP==sb.type && !grp_literal_g) { /* Specified name is a group. List the complete contents of the * group. */ - sym_insert(&sb, oname); + sym_insert(&sb, oname); iter.container = container = fix_name(show_file_name_g?fname:"", oname); - H5Giterate(file, oname, NULL, list, &iter); - free(container); + H5Giterate(file, oname, NULL, list, &iter); + free(container); - } else if ((root=H5Gopen(file, "/"))<0) { - exit(1); /*major problem!*/ - - } else { + } else if ((root=H5Gopen(file, "/"))<0) { + leave(1); /*major problem!*/ + + } else { /* Specified name is a non-group object -- list that object. The - * container for the object is everything up to the base name. */ + * container for the object is everything up to the base name. */ iter.container = show_file_name_g ? fname : "/"; - list(root, oname, &iter); - if (H5Gclose(root)<0) exit(1); - } - H5Fclose(file); + list(root, oname, &iter); + if (H5Gclose(root)<0) leave(1); + } + H5Fclose(file); + free(fname); } - h5tools_close(); - - return 0; + leave(0); } diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 8ec99b6..b9e69bb 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -30,7 +30,7 @@ * *------------------------------------------------------------------------- */ -static void print_obj(hid_t dcpl, char *name) +static void print_obj(hid_t dcpl_id, char *name) { char str[255]; #if defined (PRINT_DEBUG ) @@ -47,13 +47,13 @@ static void print_obj(hid_t dcpl, char *name) strcpy(str,"\0"); /* get information about input filters */ - if ((nfilters = H5Pget_nfilters(dcpl))<0) + if ((nfilters = H5Pget_nfilters(dcpl_id))<0) return; for ( i=0; i=0) { + H5Pset_fapl_family(fapl, (hsize_t)0, H5P_DEFAULT); + + if(drivernum) + *drivernum = FAMILY_IDX; + } /* end if */ + } else if (!strcmp(driver, drivernames[SPLIT_IDX])) { + /* SPLIT Driver */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0) { + H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); + + if(drivernum) + *drivernum = SPLIT_IDX; + } /* end if */ + } else if (!strcmp(driver, drivernames[MULTI_IDX])) { + /* MULTI Driver */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0) { + H5Pset_fapl_multi(fapl, NULL, NULL, NULL, NULL, TRUE); + + if(drivernum) + *drivernum = MULTI_IDX; + } /* end if */ +#ifdef H5_HAVE_STREAM + } else if (!strcmp(driver, drivernames[STREAM_IDX])) { + /* STREAM Driver */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0) { + H5Pset_fapl_stream(fapl, NULL); + + if(drivernum) + *drivernum = STREAM_IDX; + } /* end if */ +#endif /* H5_HAVE_STREAM */ +#ifdef H5_HAVE_PARALLEL + } else if (!strcmp(driver, drivernames[MPIO_IDX])) { + /* MPI-I/O Driver */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0) { + H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); + + /* Initialize the MPI library, if it wasn't already */ + if(!h5tools_mpi_init_g) { + MPI_Init(&argc, (char ***)&argv); + + h5tools_mpi_init_g=1; + } /* end if */ + + if(drivernum) + *drivernum = MPIO_IDX; + } /* end if */ + } else if (!strcmp(driver, drivernames[MPIPOSIX_IDX])) { + /* MPI-I/O Driver */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0) { + H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD, TRUE); + + /* Initialize the MPI library, if it wasn't already */ + if(!h5tools_mpi_init_g) { + MPI_Init(&argc, (char ***)&argv); + + h5tools_mpi_init_g=1; + } /* end if */ + + if(drivernum) + *drivernum = MPIPOSIX_IDX; + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + } else { + fapl=(-1); + } + + return(fapl); +} + +/*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library * Purpose: Open a file with various VFL drivers. @@ -165,145 +307,49 @@ h5tools_close(void) */ hid_t h5tools_fopen(const char *fname, const char *driver, char *drivername, - size_t drivername_size) + size_t drivername_size, int argc, const char *argv[]) { - static struct d_list { - const char *name; - hid_t fapl; - } drivers_list[] = { - { "sec2", FAIL } - ,{ "family", FAIL } - ,{ "split", FAIL } - ,{ "multi", FAIL } -#ifdef H5_HAVE_STREAM - ,{ "stream", FAIL } -#endif /* H5_HAVE_STREAM */ - }; - /* This enum should match the entries in the above drivers_list since they - * are indexes into the drivers_list array. */ - enum { - SEC2_IDX = 0 - ,FAMILY_IDX - ,SPLIT_IDX - ,MULTI_IDX -#ifdef H5_HAVE_STREAM - ,STREAM_IDX -#endif /* H5_HAVE_STREAM */ - }; -#define NUM_DRIVERS (sizeof(drivers_list) / sizeof(struct d_list)) - - static int initialized = 0; - register unsigned drivernum; - hid_t fid = FAIL; -#ifndef VERSION12 - hid_t fapl = H5P_DEFAULT; -#endif /* !VERSION12 */ - - if (!initialized) { - /* Build a list of file access property lists which we should try - * when opening the file. Eventually we'd like some way for the - * user to augment/replace this list interactively. */ - ++initialized; - - /* SEC2 Driver */ - drivers_list[SEC2_IDX].fapl = H5P_DEFAULT; - -#ifndef VERSION12 - /* FAMILY Driver */ - drivers_list[FAMILY_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_family(fapl, (hsize_t)0, H5P_DEFAULT); - - /* SPLIT Driver */ - drivers_list[SPLIT_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); - - /* MULTI Driver */ - drivers_list[MULTI_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_multi(fapl, NULL, NULL, NULL, NULL, TRUE); - -#ifdef H5_HAVE_STREAM - /* STREAM Driver */ - drivers_list[STREAM_IDX].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_stream(fapl, NULL); -#endif /* H5_HAVE_STREAM */ -#endif /* !VERSION12 */ - } + unsigned drivernum; + hid_t fid = FAIL; + hid_t fapl = H5P_DEFAULT; if (driver && *driver) { - /* Determine which driver the user wants to open the file with. Try - * that driver. If it can't open it, then fail. */ - if (!strcmp(driver, drivers_list[SEC2_IDX].name)) { - H5E_BEGIN_TRY { - fid = H5Fopen(fname, H5F_ACC_RDONLY, - drivers_list[SEC2_IDX].fapl); - } H5E_END_TRY; - - if (fid == FAIL) - goto done; - - drivernum = SEC2_IDX; - } else if (!strcmp(driver, drivers_list[FAMILY_IDX].name)) { - H5E_BEGIN_TRY { - fid = H5Fopen(fname, H5F_ACC_RDONLY, - drivers_list[FAMILY_IDX].fapl); - } H5E_END_TRY; - - if (fid == FAIL) - goto done; - - drivernum = FAMILY_IDX; - } else if (!strcmp(driver, drivers_list[SPLIT_IDX].name)) { - H5E_BEGIN_TRY { - fid = H5Fopen(fname, H5F_ACC_RDONLY, - drivers_list[SPLIT_IDX].fapl); - } H5E_END_TRY; - - if (fid == FAIL) - goto done; - - drivernum = SPLIT_IDX; - } else if (!strcmp(driver, drivers_list[MULTI_IDX].name)) { - H5E_BEGIN_TRY { - fid = H5Fopen(fname, H5F_ACC_RDONLY, - drivers_list[MULTI_IDX].fapl); - } H5E_END_TRY; - - if (fid == FAIL) - goto done; - - drivernum = MULTI_IDX; -#ifdef H5_HAVE_STREAM - } else if (!strcmp(driver, drivers_list[STREAM_IDX].name)) { - H5E_BEGIN_TRY { - fid = H5Fopen(fname, H5F_ACC_RDONLY, - drivers_list[STREAM_IDX].fapl); - } H5E_END_TRY; + /* Get the correct FAPL for the given driver */ + if((fapl=h5tools_get_fapl(driver,&drivernum,argc,argv))<0) + goto done; - if (fid == FAIL) - goto done; + H5E_BEGIN_TRY { + fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl); + } H5E_END_TRY; - drivernum = STREAM_IDX; -#endif /* H5_HAVE_STREAM */ - } else { + if (fid == FAIL) goto done; - } + } else { /* Try to open the file using each of the drivers */ for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) { + /* Get the correct FAPL for the given driver */ + if((fapl=h5tools_get_fapl(drivernames[drivernum],NULL,argc,argv))<0) + goto done; + H5E_BEGIN_TRY { - fid = H5Fopen(fname, H5F_ACC_RDONLY, - drivers_list[drivernum].fapl); + fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl); } H5E_END_TRY; if (fid != FAIL) break; + else { + /* Close the FAPL */ + H5Pclose(fapl); + fapl=H5P_DEFAULT; + } /* end else */ } } /* Save the driver name */ if (drivername && drivername_size) { if (fid != FAIL) { - strncpy(drivername, drivers_list[drivernum].name, drivername_size); + strncpy(drivername, drivernames[drivernum], drivername_size); drivername[drivername_size - 1] = '\0'; } else { /*no file opened*/ @@ -312,6 +358,8 @@ h5tools_fopen(const char *fname, const char *driver, char *drivername, } done: + if(fapl!=H5P_DEFAULT) + H5Pclose(fapl); return fid; } @@ -418,7 +466,7 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info, else fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); - templength = h5tools_str_len(&prefix); + templength = h5tools_str_len(&prefix); for (i = 0; i < indentlevel; i++){ /*we already made the indent for the array indices case */ @@ -504,7 +552,6 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) @@ -1087,15 +1134,8 @@ h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type, if (info->raw) p_type = H5Tcopy(f_type); - else { - H5T_class_t type_class; - - type_class = H5Tget_class(f_type); - if(type_class==H5T_BITFIELD) - p_type=H5Tcopy(f_type); - else - p_type = H5Tget_native_type(f_type,H5T_DIR_DEFAULT); - } + else + p_type = h5tools_get_native_type(f_type); H5Tclose(f_type); diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index d7f0cdf..f43941f 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -23,10 +23,6 @@ #include "hdf5.h" -#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 2 -#define VERSION12 -#endif /* H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 2 */ - #define ESCAPE_HTML 1 #define OPT(X,S) ((X) ? (X) : (S)) #define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */ @@ -106,7 +102,6 @@ typedef struct h5dump_t { * str_repeat: If set to non-zero then any character value repeated N * or more times is printed as 'C'*N * - * * Numeric data is also subject to the formats for individual elements. */ hbool_t raw; @@ -326,7 +321,6 @@ typedef struct h5dump_t { /*escape non printable characters */ int do_escape; - } h5dump_t; typedef struct dump_header{ @@ -493,7 +487,6 @@ extern FILE *rawdatastream; /*output stream for raw data */ #define FILE_CONTENTS "FILE_CONTENTS" - #define BEGIN "{" #define END "}" @@ -501,11 +494,14 @@ extern FILE *rawdatastream; /*output stream for raw data */ extern void h5tools_init(void); extern void h5tools_close(void); extern hid_t h5tools_fopen(const char *fname, const char *driver, - char *drivername, size_t drivername_len); + char *drivername, size_t drivername_len, + int argc, const char *argv[]); extern int h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t p_typ, struct subset_t *sset, int indentlevel); extern int h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel); +extern hid_t h5tools_get_native_type(hid_t type); + extern void h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem); @@ -513,5 +509,4 @@ extern void h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid extern int h5tools_canreadf(const char* name, hid_t dcpl_id); - #endif /* H5TOOLS_H__ */ diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index cee0928..1bf3ec0 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -574,7 +574,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, unsigned char *ucp_vp = (unsigned char *)vp; char *cp_vp = (char *)vp; hid_t memb, obj, region; - int nmembs, otype; + unsigned nmembs; + int otype; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; H5G_stat_t sb; @@ -641,6 +642,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, } pad = H5Tget_strpad(type); + /* Check for NULL pointer for string */ if(s==NULL) { h5tools_str_append(str, "NULL"); } @@ -748,7 +750,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); } } else if (H5Tget_class(type) == H5T_COMPOUND) { - int j; + unsigned j; nmembs = H5Tget_nmembers(type); h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); @@ -877,12 +879,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, } /* Print OID */ - if (info->obj_hidefileno) { + if (info->obj_hidefileno) h5tools_str_append(str, info->obj_format, sb.objno[1], sb.objno[0]); - } else { + else h5tools_str_append(str, info->obj_format, sb.fileno[1], sb.fileno[0], sb.objno[1], sb.objno[0]); - } /* Print name */ path = lookup_ref_path(vp); @@ -1122,4 +1123,3 @@ h5tools_is_zero(const void *_mem, size_t size) return TRUE; } - diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index 53a3505..1ef2579 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -45,3 +45,4 @@ h5tools_get_native_type(hid_t type) return(p_type); } + diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 26f894f..a942c17 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -246,7 +246,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti } -/*---------------------/---------------------------------------------------- +/*------------------------------------------------------------------------- * Function: indentation * * Purpose: Print spaces for indentation diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 78c5650..babbac0 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -344,7 +344,7 @@ int traverse( hid_t loc_id, H5E_BEGIN_TRY { /* get info */ - H5Gget_objinfo( loc_id, path, FALSE, &statbuf); + H5Gget_objinfo( loc_id, path, FALSE, &statbuf); } H5E_END_TRY; /* add to array */ @@ -383,7 +383,7 @@ int traverse( hid_t loc_id, inserted_objs += traverse( loc_id, path, table, info, idx, print ); } - /* search table + /* search table group with more than one link to it */ if (statbuf.nlink > 1) { @@ -426,10 +426,9 @@ int traverse( hid_t loc_id, /* print it */ if (print) printf(" %-10s %s\n", "dataset", path ); - } - /* search table + /* search table dataset with more than one link to it */ if (statbuf.nlink > 1) { @@ -469,7 +468,7 @@ int traverse( hid_t loc_id, /* add object to table */ trav_table_add(statbuf.objno, path, H5G_TYPE, table ); - /* print it */ + /* print it */ if (print) printf(" %-10s %s\n", "datatype", path ); } diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index 4d7f0cf..b6522e6 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -41,7 +41,7 @@ #endif typedef struct trav_info_t { - char *name; + char *name; H5G_obj_t1 type; } trav_info_t; diff --git a/tools/lib/talign.c b/tools/lib/talign.c index 082e37e..bb9f96e 100644 --- a/tools/lib/talign.c +++ b/tools/lib/talign.c @@ -29,7 +29,6 @@ int main(void) hsize_t dim[2]; hsize_t cdim[4]; - H5T_class_t type_class; char string5[5]; float fok[2] = {1234., 2341.}; @@ -73,11 +72,7 @@ int main(void) H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt); H5Tclose(array_dt); - type_class = H5Tget_class(cmp); - if(type_class==H5T_BITFIELD) - fix=H5Tcopy(cmp); - else - fix=H5Tget_native_type(cmp, H5T_DIR_DEFAULT); + fix=h5tools_get_native_type(cmp); cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok)); -- cgit v0.12