From 680315d69baa9bef364b80af8e1dbaf827dd64e2 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Mon, 12 Mar 2007 11:35:58 -0500 Subject: [svn-r13502] Preparation for making 1.6 and 1.7 h5dump more similar and 1.6 to have 1.7 fixed bugs incorporated --- tools/h5dump/h5dump.c | 2332 +++++++++++++++++++++--------------------- tools/h5dump/h5dump.h | 2 +- tools/h5dump/h5dumpgentest.c | 10 +- tools/lib/h5tools.c | 254 ++--- tools/lib/h5tools.h | 6 +- tools/lib/h5tools_filters.c | 4 +- tools/lib/h5tools_ref.c | 40 +- tools/lib/h5tools_str.c | 356 +++---- tools/lib/h5tools_str.h | 6 +- tools/lib/h5tools_type.c | 12 +- tools/lib/h5tools_utils.c | 42 +- tools/lib/h5tools_utils.h | 18 +- 12 files changed, 1541 insertions(+), 1541 deletions(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 366fb85..db1a6ac 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -101,70 +101,70 @@ static void init_prefix(char **prfx, size_t prfx_len); static void add_prefix(char **prfx, size_t *prfx_len, const char *name); static h5tool_format_t dataformat = { - 0, /*raw */ - - "", /*fmt_raw */ - "%d", /*fmt_int */ - "%u", /*fmt_uint */ - "%d", /*fmt_schar */ - "%u", /*fmt_uchar */ - "%d", /*fmt_short */ - "%u", /*fmt_ushort */ - "%ld", /*fmt_long */ - "%lu", /*fmt_ulong */ - NULL, /*fmt_llong */ - NULL, /*fmt_ullong */ - "%g", /*fmt_double */ - "%g", /*fmt_float */ - - 0, /*ascii */ - 0, /*str_locale */ - 0, /*str_repeat */ - - "[ ", /*arr_pre */ - ",", /*arr_sep */ - " ]", /*arr_suf */ - 1, /*arr_linebreak */ - - "", /*cmpd_name */ - ",\n", /*cmpd_sep */ - "{\n", /*cmpd_pre */ - "}", /*cmpd_suf */ - "\n", /*cmpd_end */ - - ", ", /*vlen_sep */ - "(", /*vlen_pre */ - ")", /*vlen_suf */ - "", /*vlen_end */ - - "%s", /*elmt_fmt */ - ",", /*elmt_suf1 */ - " ", /*elmt_suf2 */ - - "", /*idx_n_fmt */ - "", /*idx_sep */ - "", /*idx_fmt */ - - 80, /*line_ncols *//*standard default columns */ - 0, /*line_per_line */ - "", /*line_pre */ - "%s", /*line_1st */ - "%s", /*line_cont */ - "", /*line_suf */ - "", /*line_sep */ - 1, /*line_multi_new */ - " ", /*line_indent */ - - 1, /*skip_first */ - - 1, /*obj_hidefileno */ - " %lu:%lu", /*obj_format */ - - 1, /*dset_hidefileno */ - "DATASET %lu:%lu ", /*dset_format */ - "%s", /*dset_blockformat_pre */ - "%s", /*dset_ptformat_pre */ - "%s", /*dset_ptformat */ + 0, /*raw */ + + "", /*fmt_raw */ + "%d", /*fmt_int */ + "%u", /*fmt_uint */ + "%d", /*fmt_schar */ + "%u", /*fmt_uchar */ + "%d", /*fmt_short */ + "%u", /*fmt_ushort */ + "%ld", /*fmt_long */ + "%lu", /*fmt_ulong */ + NULL, /*fmt_llong */ + NULL, /*fmt_ullong */ + "%g", /*fmt_double */ + "%g", /*fmt_float */ + + 0, /*ascii */ + 0, /*str_locale */ + 0, /*str_repeat */ + + "[ ", /*arr_pre */ + ",", /*arr_sep */ + " ]", /*arr_suf */ + 1, /*arr_linebreak */ + + "", /*cmpd_name */ + ",\n", /*cmpd_sep */ + "{\n", /*cmpd_pre */ + "}", /*cmpd_suf */ + "\n", /*cmpd_end */ + + ", ", /*vlen_sep */ + "(", /*vlen_pre */ + ")", /*vlen_suf */ + "", /*vlen_end */ + + "%s", /*elmt_fmt */ + ",", /*elmt_suf1 */ + " ", /*elmt_suf2 */ + + "", /*idx_n_fmt */ + "", /*idx_sep */ + "", /*idx_fmt */ + + 80, /*line_ncols *//*standard default columns */ + 0, /*line_per_line */ + "", /*line_pre */ + "%s", /*line_1st */ + "%s", /*line_cont */ + "", /*line_suf */ + "", /*line_sep */ + 1, /*line_multi_new */ + " ", /*line_indent */ + + 1, /*skip_first */ + + 1, /*obj_hidefileno */ + " %lu:%lu", /*obj_format */ + + 1, /*dset_hidefileno */ + "DATASET %lu:%lu ", /*dset_format */ + "%s", /*dset_blockformat_pre */ + "%s", /*dset_ptformat_pre */ + "%s", /*dset_ptformat */ 1, /*array indices */ 1 /*escape non printable characters */ }; @@ -185,70 +185,70 @@ static h5tool_format_t dataformat = { * This table only affects XML output. */ static h5tool_format_t xml_dataformat = { - 0, /*raw */ - - "", /*fmt_raw */ - "%d", /*fmt_int */ - "%u", /*fmt_uint */ - "%d", /*fmt_schar */ - "%u", /*fmt_uchar */ - "%d", /*fmt_short */ - "%u", /*fmt_ushort */ - "%ld", /*fmt_long */ - "%lu", /*fmt_ulong */ - NULL, /*fmt_llong */ - NULL, /*fmt_ullong */ - "%g", /*fmt_double */ - "%g", /*fmt_float */ - - 0, /*ascii */ - 0, /*str_locale */ - 0, /*str_repeat */ - - " ", /*arr_pre */ - "", /*arr_sep */ - "", /*arr_suf */ - 1, /*arr_linebreak */ - - "", /*cmpd_name */ - " ", /*cmpd_sep */ - "", /*cmpd_pre */ - "", /*cmpd_suf */ - "", /*cmpd_end */ - - " ", /*vlen_sep */ - " ", /*vlen_pre */ - "", /*vlen_suf */ - "", /*vlen_end */ - - "%s", /*elmt_fmt */ - "", /*elmt_suf1 */ - " ", /*elmt_suf2 */ - - "", /*idx_n_fmt */ - "", /*idx_sep */ - "", /*idx_fmt */ - - 80, /*line_ncols *//*standard default columns */ - 0, /*line_per_line */ - "", /*line_pre */ - "%s", /*line_1st */ - "%s", /*line_cont */ - "", /*line_suf */ - "", /*line_sep */ - 1, /*line_multi_new */ - " ", /*line_indent */ - - 1, /*skip_first */ - - 1, /*obj_hidefileno */ - " %lu:%lu", /*obj_format */ - - 1, /*dset_hidefileno */ - "DATASET %lu:%lu ", /*dset_format */ - "%s", /*dset_blockformat_pre */ - "%s", /*dset_ptformat_pre */ - "%s", /*dset_ptformat */ + 0, /*raw */ + + "", /*fmt_raw */ + "%d", /*fmt_int */ + "%u", /*fmt_uint */ + "%d", /*fmt_schar */ + "%u", /*fmt_uchar */ + "%d", /*fmt_short */ + "%u", /*fmt_ushort */ + "%ld", /*fmt_long */ + "%lu", /*fmt_ulong */ + NULL, /*fmt_llong */ + NULL, /*fmt_ullong */ + "%g", /*fmt_double */ + "%g", /*fmt_float */ + + 0, /*ascii */ + 0, /*str_locale */ + 0, /*str_repeat */ + + " ", /*arr_pre */ + "", /*arr_sep */ + "", /*arr_suf */ + 1, /*arr_linebreak */ + + "", /*cmpd_name */ + " ", /*cmpd_sep */ + "", /*cmpd_pre */ + "", /*cmpd_suf */ + "", /*cmpd_end */ + + " ", /*vlen_sep */ + " ", /*vlen_pre */ + "", /*vlen_suf */ + "", /*vlen_end */ + + "%s", /*elmt_fmt */ + "", /*elmt_suf1 */ + " ", /*elmt_suf2 */ + + "", /*idx_n_fmt */ + "", /*idx_sep */ + "", /*idx_fmt */ + + 80, /*line_ncols *//*standard default columns */ + 0, /*line_per_line */ + "", /*line_pre */ + "%s", /*line_1st */ + "%s", /*line_cont */ + "", /*line_suf */ + "", /*line_sep */ + 1, /*line_multi_new */ + " ", /*line_indent */ + + 1, /*skip_first */ + + 1, /*obj_hidefileno */ + " %lu:%lu", /*obj_format */ + + 1, /*dset_hidefileno */ + "DATASET %lu:%lu ", /*dset_format */ + "%s", /*dset_blockformat_pre */ + "%s", /*dset_ptformat_pre */ + "%s", /*dset_ptformat */ 0, /*array indices */ 0 /*escape non printable characters */ }; @@ -256,62 +256,62 @@ static h5tool_format_t xml_dataformat = { /** XML **/ static const h5dump_header_t standardformat = { - "standardformat", /*name */ - "HDF5", /*fileebgin */ - "", /*fileend */ - SUPER_BLOCK, /*bootblockbegin */ - "", /*bootblockend */ - GROUP, /*groupbegin */ - "", /*groupend */ - DATASET, /*datasetbegin */ - "", /*datasetend */ - ATTRIBUTE, /*attributebegin */ - "", /*attributeend */ - DATATYPE, /*datatypebegin */ - "", /*datatypeend */ - DATASPACE, /*dataspacebegin */ - "", /*dataspaceend */ - DATA, /*databegin */ - "", /*dataend */ - SOFTLINK, /*softlinkbegin */ - "", /*softlinkend */ - SUBSET, /*subsettingbegin */ - "", /*subsettingend */ - START, /*startbegin */ - "", /*startend */ - STRIDE, /*stridebegin */ - "", /*strideend */ - COUNT, /*countbegin */ - "", /*countend */ - BLOCK, /*blockbegin */ - "", /*blockend */ - - "{", /*fileblockbegin */ - "}", /*fileblockend */ - "{", /*bootblockblockbegin */ - "}", /*bootblockblockend */ - "{", /*groupblockbegin */ - "}", /*groupblockend */ - "{", /*datasetblockbegin */ - "}", /*datasetblockend */ - "{", /*attributeblockbegin */ - "}", /*attributeblockend */ - "", /*datatypeblockbegin */ - "", /*datatypeblockend */ - "", /*dataspaceblockbegin */ - "", /*dataspaceblockend */ - "{", /*datablockbegin */ - "}", /*datablockend */ - "{", /*softlinkblockbegin */ - "}", /*softlinkblockend */ - "{", /*strblockbegin */ - "}", /*strblockend */ - "{", /*enumblockbegin */ - "}", /*enumblockend */ - "{", /*structblockbegin */ - "}", /*structblockend */ - "{", /*vlenblockbegin */ - "}", /*vlenblockend */ + "standardformat", /*name */ + "HDF5", /*fileebgin */ + "", /*fileend */ + SUPER_BLOCK, /*bootblockbegin */ + "", /*bootblockend */ + GROUP, /*groupbegin */ + "", /*groupend */ + DATASET, /*datasetbegin */ + "", /*datasetend */ + ATTRIBUTE, /*attributebegin */ + "", /*attributeend */ + DATATYPE, /*datatypebegin */ + "", /*datatypeend */ + DATASPACE, /*dataspacebegin */ + "", /*dataspaceend */ + DATA, /*databegin */ + "", /*dataend */ + SOFTLINK, /*softlinkbegin */ + "", /*softlinkend */ + SUBSET, /*subsettingbegin */ + "", /*subsettingend */ + START, /*startbegin */ + "", /*startend */ + STRIDE, /*stridebegin */ + "", /*strideend */ + COUNT, /*countbegin */ + "", /*countend */ + BLOCK, /*blockbegin */ + "", /*blockend */ + + "{", /*fileblockbegin */ + "}", /*fileblockend */ + "{", /*bootblockblockbegin */ + "}", /*bootblockblockend */ + "{", /*groupblockbegin */ + "}", /*groupblockend */ + "{", /*datasetblockbegin */ + "}", /*datasetblockend */ + "{", /*attributeblockbegin */ + "}", /*attributeblockend */ + "", /*datatypeblockbegin */ + "", /*datatypeblockend */ + "", /*dataspaceblockbegin */ + "", /*dataspaceblockend */ + "{", /*datablockbegin */ + "}", /*datablockend */ + "{", /*softlinkblockbegin */ + "}", /*softlinkblockend */ + "{", /*strblockbegin */ + "}", /*strblockend */ + "{", /*enumblockbegin */ + "}", /*enumblockend */ + "{", /*structblockbegin */ + "}", /*structblockend */ + "{", /*vlenblockbegin */ + "}", /*vlenblockend */ "{", /*subsettingblockbegin */ "}", /*subsettingblockend */ "(", /*startblockbegin */ @@ -323,10 +323,10 @@ static const h5dump_header_t standardformat = { "(", /*blockblockbegin */ ");", /*blockblockend */ - "", /*dataspacedescriptionbegin */ - "", /*dataspacedescriptionend */ - "(", /*dataspacedimbegin */ - ")", /*dataspacedimend */ + "", /*dataspacedescriptionbegin */ + "", /*dataspacedescriptionend */ + "(", /*dataspacedimbegin */ + ")", /*dataspacedimend */ }; /** @@ -687,7 +687,7 @@ print_datatype(hid_t type,unsigned in_group) if (obj) { if (!obj->recorded) { - unsigned long objno[2]; /*object number */ + unsigned long objno[2]; /*object number */ objno[0] = (unsigned long)(obj->objno); #if H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG @@ -1041,7 +1041,7 @@ dump_datatype(hid_t type) print_datatype(type,0); end_obj(dump_header_format->datatypeend, - dump_header_format->datatypeblockend); + dump_header_format->datatypeblockend); indent -= COL; } @@ -1073,48 +1073,48 @@ dump_dataspace(hid_t space) switch (space_type) { case H5S_SCALAR: - /* scalar dataspace */ - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedescriptionbegin, S_SCALAR); + /* scalar dataspace */ + HDfprintf(stdout, "%s %s", + dump_header_format->dataspacedescriptionbegin, S_SCALAR); break; case H5S_SIMPLE: - /* simple dataspace */ - HDfprintf(stdout, "%s %s { %s %Hu", - dump_header_format->dataspacedescriptionbegin, S_SIMPLE, - dump_header_format->dataspacedimbegin, size[0]); - - for (i = 1; i < ndims; i++) - HDfprintf(stdout, ", %Hu", size[i]); - - printf(" %s / ", dump_header_format->dataspacedimend); - - if (maxsize[0] == H5S_UNLIMITED) - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedimbegin, - "H5S_UNLIMITED"); - else - HDfprintf(stdout, "%s %Hu", + /* simple dataspace */ + HDfprintf(stdout, "%s %s { %s %Hu", + dump_header_format->dataspacedescriptionbegin, S_SIMPLE, + dump_header_format->dataspacedimbegin, size[0]); + + for (i = 1; i < ndims; i++) + HDfprintf(stdout, ", %Hu", size[i]); + + printf(" %s / ", dump_header_format->dataspacedimend); + + if (maxsize[0] == H5S_UNLIMITED) + HDfprintf(stdout, "%s %s", + dump_header_format->dataspacedimbegin, + "H5S_UNLIMITED"); + else + HDfprintf(stdout, "%s %Hu", dump_header_format->dataspacedimbegin, maxsize[0]); - for (i = 1; i < ndims; i++) - if (maxsize[i] == H5S_UNLIMITED) - HDfprintf(stdout, ", %s", "H5S_UNLIMITED"); - else - HDfprintf(stdout, ", %Hu", maxsize[i]); + for (i = 1; i < ndims; i++) + if (maxsize[i] == H5S_UNLIMITED) + HDfprintf(stdout, ", %s", "H5S_UNLIMITED"); + else + HDfprintf(stdout, ", %Hu", maxsize[i]); - printf(" %s }", dump_header_format->dataspacedimend); + printf(" %s }", dump_header_format->dataspacedimend); - break; + break; case H5S_COMPLEX: - printf("%s not yet implemented %s\n", BEGIN, END); + printf("%s not yet implemented %s\n", BEGIN, END); break; case H5S_NO_CLASS: default: - printf("%s unknown dataspace %s\n", BEGIN, END); + printf("%s unknown dataspace %s\n", BEGIN, END); } end_obj(dump_header_format->dataspaceend, - dump_header_format->dataspaceblockend); + dump_header_format->dataspaceblockend); } /*------------------------------------------------------------------------- @@ -1140,34 +1140,34 @@ dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) indentation(indent); begin_obj(dump_header_format->attributebegin, attr_name, - dump_header_format->attributeblockbegin); + dump_header_format->attributeblockbegin); if ((attr_id = H5Aopen_name(attr, attr_name)) < 0) { - indentation(indent + COL); + indentation(indent + COL); error_msg(progname, "unable to open attribute \"%s\"\n", attr_name); - indentation(indent); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - ret = FAIL; + indentation(indent); + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; + ret = FAIL; } else { - type = H5Aget_type(attr_id); - space = H5Aget_space(attr_id); - dump_datatype(type); - dump_dataspace(space); - - if (display_oid) - dump_oid(attr_id); - - if (display_data || display_attr_data) - dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai); - - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr_id); - indentation(indent); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); + type = H5Aget_type(attr_id); + space = H5Aget_space(attr_id); + dump_datatype(type); + dump_dataspace(space); + + if (display_oid) + dump_oid(attr_id); + + if (display_data || display_attr_data) + dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai); + + H5Tclose(type); + H5Sclose(space); + H5Aclose(attr_id); + indentation(indent); + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); } return ret; @@ -1202,11 +1202,11 @@ dump_selected_attr(hid_t loc_id, const char *name) /* find the last / */ while (name[j] != '/' && j >= 0) - j--; + j--; /* object name */ if (j == -1) { - strcpy(obj_name, "/"); + strcpy(obj_name, "/"); } else { strncpy(obj_name, name, (size_t)j + 1); obj_name[j + 1] = '\0'; @@ -1214,101 +1214,101 @@ dump_selected_attr(hid_t loc_id, const char *name) attr_name = name + j + 1; begin_obj(dump_header_format->attributebegin, name, - dump_header_format->attributeblockbegin); + dump_header_format->attributeblockbegin); H5Gget_objinfo(loc_id, obj_name, FALSE, &statbuf); switch (statbuf.type) { case H5G_GROUP: - if ((oid = H5Gopen(loc_id, obj_name)) < 0) { - indentation(COL); + if ((oid = H5Gopen(loc_id, obj_name)) < 0) { + indentation(COL); error_msg(progname, "unable to open group \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; - } - break; + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; + return FAIL; + } + break; case H5G_DATASET: - if ((oid = H5Dopen(loc_id, obj_name)) < 0) { - indentation(COL); + if ((oid = H5Dopen(loc_id, obj_name)) < 0) { + indentation(COL); error_msg(progname, "unable to open dataset \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; - } - break; + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; + return FAIL; + } + break; case H5G_TYPE: - if ((oid = H5Topen(loc_id, obj_name)) < 0) { - indentation(COL); + if ((oid = H5Topen(loc_id, obj_name)) < 0) { + indentation(COL); error_msg(progname, "unable to open datatype \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; - } - break; + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; + return FAIL; + } + break; default: - indentation(COL); + indentation(COL); error_msg(progname, "unable to open unknown \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; + return FAIL; } if ((attr_id = H5Aopen_name(oid, attr_name)) >= 0) { - type = H5Aget_type(attr_id); - space = H5Aget_space(attr_id); - dump_datatype(type); - dump_dataspace(space); - - if (display_oid) - dump_oid(attr_id); - - if (display_data || display_attr_data) - dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai); - - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr_id); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); + type = H5Aget_type(attr_id); + space = H5Aget_space(attr_id); + dump_datatype(type); + dump_dataspace(space); + + if (display_oid) + dump_oid(attr_id); + + if (display_data || display_attr_data) + dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai); + + H5Tclose(type); + H5Sclose(space); + H5Aclose(attr_id); + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); } else { - indentation(COL); + indentation(COL); error_msg(progname, "unable to open attribute \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; } switch (statbuf.type) { case H5G_GROUP: - if (H5Gclose(oid) < 0) { - d_status = EXIT_FAILURE; - return FAIL; - } - break; + if (H5Gclose(oid) < 0) { + d_status = EXIT_FAILURE; + return FAIL; + } + break; case H5G_DATASET: - if (H5Dclose(oid) < 0) { - d_status = EXIT_FAILURE; - return FAIL; - } - break; + if (H5Dclose(oid) < 0) { + d_status = EXIT_FAILURE; + return FAIL; + } + break; case H5G_TYPE: - if (H5Tclose(oid) < 0) { - d_status = EXIT_FAILURE; - return FAIL; - } - break; + if (H5Tclose(oid) < 0) { + d_status = EXIT_FAILURE; + return FAIL; + } + break; default: - d_status = EXIT_FAILURE; - return FAIL; + d_status = EXIT_FAILURE; + return FAIL; } free(obj_name); @@ -1615,17 +1615,17 @@ dump_named_datatype(hid_t type, const char *name) { indentation(indent); printf("%s \"%s\" %s", dump_header_format->datatypebegin, name, - dump_header_format->datatypeblockbegin); + dump_header_format->datatypeblockbegin); if (H5Tget_class(type) == H5T_COMPOUND) { - print_datatype(type,1); + print_datatype(type,1); } else { - indentation(indent + COL); - print_datatype(type,1); - printf(";\n"); + indentation(indent + COL); + print_datatype(type,1); + printf(";\n"); } end_obj(dump_header_format->datatypeend, - dump_header_format->datatypeblockend); + dump_header_format->datatypeblockend); } /*------------------------------------------------------------------------- @@ -1655,7 +1655,7 @@ dump_group(hid_t gid, const char *name) HDstrcpy(tmp, prefix); indentation(indent); begin_obj(dump_header_format->groupbegin, name, - dump_header_format->groupblockbegin); + dump_header_format->groupblockbegin); indent += COL; if (display_oid) @@ -1666,13 +1666,13 @@ dump_group(hid_t gid, const char *name) if (!HDstrcmp(name, "/") && unamedtype) { unsigned u; /* Local index variable */ - /* dump unamed type in root group */ - for (u = 0; u < type_table->nobjs; u++) - if (!type_table->objs[u].recorded) { - unsigned long objno[2]; /*object number */ + /* dump unamed type in root group */ + for (u = 0; u < type_table->nobjs; u++) + if (!type_table->objs[u].recorded) { + unsigned long objno[2]; /*object number */ - dset = H5Dopen(gid, type_table->objs[u].objname); - type = H5Dget_type(dset); + dset = H5Dopen(gid, type_table->objs[u].objname); + type = H5Dget_type(dset); objno[0] = (unsigned long)(type_table->objs[u].objno); #if H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG @@ -1680,12 +1680,12 @@ dump_group(hid_t gid, const char *name) #else /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ objno[1] = 0; #endif /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ - sprintf(type_name, "#%lu:%lu", objno[0], objno[1]); + sprintf(type_name, "#%lu:%lu", objno[0], objno[1]); dump_function_table->dump_named_datatype_function(type, type_name); - H5Tclose(type); - H5Dclose(dset); - } + H5Tclose(type); + H5Dclose(dset); + } } /* end if */ H5Gget_objinfo(gid, ".", TRUE, &statbuf); @@ -1695,22 +1695,22 @@ dump_group(hid_t gid, const char *name) found_obj = search_obj(group_table, statbuf.objno); - if (found_obj == NULL) { - indentation(indent); + if (found_obj == NULL) { + indentation(indent); error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; - } else if (found_obj->displayed) { - indentation(indent); - printf("%s \"%s\"\n", HARDLINK, found_obj->objname); - } else { - found_obj->displayed = TRUE; - H5Aiterate(gid, NULL, dump_attr, NULL); - H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); - } + d_status = EXIT_FAILURE; + } else if (found_obj->displayed) { + indentation(indent); + printf("%s \"%s\"\n", HARDLINK, found_obj->objname); } else { - H5Aiterate(gid, NULL, dump_attr, NULL); - H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); + found_obj->displayed = TRUE; + H5Aiterate(gid, NULL, dump_attr, NULL); + H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); + } + } else { + H5Aiterate(gid, NULL, dump_attr, NULL); + H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); } indent -= COL; @@ -1739,7 +1739,7 @@ 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); + dump_header_format->datasetblockbegin); type = H5Dget_type(did); space = H5Dget_space(did); dcpl_id = H5Dget_create_plist(did); @@ -1755,7 +1755,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) dump_dcpl(dcpl_id, type, did); if (display_data) - switch (H5Tget_class(type)) { + switch (H5Tget_class(type)) { case H5T_TIME: indentation(indent + COL); printf("DATA{ not yet implemented.}\n"); @@ -1776,7 +1776,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) default: break; - } + } indent += COL; H5Aiterate(did, NULL, dump_attr, NULL); @@ -1786,7 +1786,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) H5Pclose(dcpl_id); indentation(indent); end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); + dump_header_format->datasetblockend); } /*------------------------------------------------------------------------- @@ -1888,8 +1888,8 @@ dump_subsetting_header(struct subset_t *sset, int dims) * Programmer: Ruey-Hsia Li * * Modifications: pvn, print the matrix indices - * Albert Cheng, 2004/11/18 - * Add --string printing for attributes too. + * Albert Cheng, 2004/11/18 + * Add --string printing for attributes too. * *------------------------------------------------------------------------- */ @@ -1904,7 +1904,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) int ndims, i; hsize_t size[64], nelmts = 1, alloc_size; int depth; - int stdindent = COL; /* should be 3 */ + int stdindent = COL; /* should be 3 */ outputformat->line_ncols = nCols; outputformat->do_escape=display_escape; @@ -1939,7 +1939,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) indentation(indent); begin_obj(dump_header_format->databegin, (const char *)NULL, - dump_header_format->datablockbegin); + dump_header_format->datablockbegin); /* Print all the values. */ if (obj_data == DATASET_DATA) { @@ -1975,7 +1975,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) } - status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth); + 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 */ @@ -1984,8 +1984,8 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) if(space_type == H5S_NO_CLASS || space_type == H5S_COMPLEX) { status = SUCCEED; } else { - char string_prefix[64]; - h5tool_format_t string_dataformat; + char string_prefix[64]; + h5tool_format_t string_dataformat; type = H5Aget_type(obj_id); p_type = h5tools_get_native_type(type); @@ -2002,32 +2002,32 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) assert(buf); if (H5Aread(obj_id, p_type, buf) >= 0) - if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) { - /* - * Print 1-byte integer data as an ASCII character string - * instead of integers if the `-r' or `--string' command-line - * option was given. - * - * We don't want to modify the global dataformat, so make a - * copy of it instead. - */ - string_dataformat = *outputformat; - string_dataformat.idx_fmt = " "; - string_dataformat.line_multi_new = 1; - string_dataformat.line_1st = " %s\""; - string_dataformat.line_pre = " %s"; - string_dataformat.line_cont = " %s"; - string_dataformat.str_repeat = 8; - string_dataformat.ascii = TRUE; - string_dataformat.elmt_suf1 = ""; - string_dataformat.elmt_suf2 = ""; - string_dataformat.line_indent = ""; - strcpy(string_prefix, string_dataformat.line_pre); - strcat(string_prefix, "\""); - string_dataformat.line_pre = string_prefix; - string_dataformat.line_suf = "\""; - outputformat = &string_dataformat; - } + if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) { + /* + * Print 1-byte integer data as an ASCII character string + * instead of integers if the `-r' or `--string' command-line + * option was given. + * + * We don't want to modify the global dataformat, so make a + * copy of it instead. + */ + string_dataformat = *outputformat; + string_dataformat.idx_fmt = " "; + string_dataformat.line_multi_new = 1; + string_dataformat.line_1st = " %s\""; + string_dataformat.line_pre = " %s"; + string_dataformat.line_cont = " %s"; + string_dataformat.str_repeat = 8; + string_dataformat.ascii = TRUE; + string_dataformat.elmt_suf1 = ""; + string_dataformat.elmt_suf2 = ""; + string_dataformat.line_indent = ""; + strcpy(string_prefix, string_dataformat.line_pre); + strcat(string_prefix, "\""); + string_dataformat.line_pre = string_prefix; + string_dataformat.line_suf = "\""; + outputformat = &string_dataformat; + } status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, space, buf, depth); @@ -2121,7 +2121,7 @@ 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 */ + h5tools_context_t ctx; /*print context */ size_t size; void *buf=NULL; hsize_t nelmts=1; @@ -2172,9 +2172,9 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) unsigned szip_pixels_per_block; hsize_t chsize[64]; /* chunk size in elements */ int rank; /* rank */ - char name[256]; /* external file name */ - off_t offset; /* offset of external file */ - hsize_t size; /* size of external file */ + char name[256]; /* external file name */ + off_t offset; /* offset of external file */ + hsize_t size; /* size of external file */ H5D_fill_value_t fvstatus; H5D_alloc_time_t at; H5D_fill_time_t ft; @@ -2465,7 +2465,7 @@ static void dump_fcpl(hid_t fid) { hid_t fcpl; /* file creation property list ID */ - hid_t fapl; /* file access property list ID */ + hid_t fapl; /* file access property list ID */ hsize_t userblock; /* userblock size retrieved from FCPL */ size_t off_size; /* size of offsets in the file */ size_t len_size; /* size of lengths in the file */ @@ -2578,7 +2578,7 @@ static void dump_fcontents(hid_t fid) for (u = 0; u < type_table->nobjs; u++) { if (!type_table->objs[u].recorded) { - unsigned long objno[2]; /*object number */ + unsigned long objno[2]; /*object number */ objno[0] = (unsigned long)(type_table->objs[u].objno); #if H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG @@ -2602,10 +2602,10 @@ static void dump_fcontents(hid_t fid) * Function: set_output_file * * Purpose: Open fname as the output file for dataset raw data. - * Set rawdatastream as its file stream. + * Set rawdatastream as its file stream. * * Return: 0 -- succeeded - * negative -- failed + * negative -- failed * * Programmer: Albert Cheng, 2000/09/30 * @@ -2616,12 +2616,12 @@ static void dump_fcontents(hid_t fid) static int set_output_file(const char *fname) { - FILE *f; /* temporary holding place for the stream pointer + FILE *f; /* temporary holding place for the stream pointer * so that rawdatastream is changed only when succeeded */ if ((f = fopen(fname, "w")) != NULL) { - rawdatastream = f; - return 0; + rawdatastream = f; + return 0; } return -1; @@ -3004,7 +3004,7 @@ handle_datatypes(hid_t fid, char *type, void UNUSED * data) char name[128]; if (!type_table->objs[idx].recorded) { - unsigned long objno[2]; /*object number */ + unsigned long objno[2]; /*object number */ /* unamed data type */ objno[0] = (unsigned long)(type_table->objs[idx].objno); @@ -3219,15 +3219,15 @@ parse_start: case 'X': /* specify XML namespace (default="hdf5:"), or none */ /* To Do: check format of this value? */ - if (!useschema) { + if (!useschema) { usage(progname); leave(EXIT_FAILURE); - } - if (strcmp(opt_arg,":") == 0) { + } + if (strcmp(opt_arg,":") == 0) { xmlnsprefix = ""; - } else { + } else { xmlnsprefix = opt_arg; - } + } break; /** end XML parameters **/ @@ -3403,27 +3403,27 @@ main(int argc, const char *argv[]) /* Check for conflicting options */ if (doxml) { - if (!display_all) { + if (!display_all) { error_msg(progname, "option \"%s\" not available for XML\n", - "to display selected objects"); - leave(EXIT_FAILURE); - } else if (display_bb) { + "to display selected objects"); + leave(EXIT_FAILURE); + } else if (display_bb) { error_msg(progname, "option \"%s\" not available for XML\n", - "--boot-block"); - leave(EXIT_FAILURE); - } else if (display_oid == 1) { + "--boot-block"); + leave(EXIT_FAILURE); + } else if (display_oid == 1) { error_msg(progname, "option \"%s\" not available for XML\n", - "--object-ids"); - leave(EXIT_FAILURE); + "--object-ids"); + leave(EXIT_FAILURE); } else if (display_char == TRUE) { error_msg(progname, "option \"%s\" not available for XML\n", - "--string"); - leave(EXIT_FAILURE); - } else if (usingdasho) { + "--string"); + leave(EXIT_FAILURE); + } else if (usingdasho) { error_msg(progname, "option \"%s\" not available for XML\n", - "--output"); - leave(EXIT_FAILURE); - } + "--output"); + leave(EXIT_FAILURE); + } } else { if (xml_dtd_uri) { warn_msg(progname, "option \"%s\" only applies with XML: %s\n", @@ -3453,25 +3453,25 @@ main(int argc, const char *argv[]) H5Giterate(fid, (const char *)"/", NULL, fill_ref_path_table, (void *)""); if (doxml) { - /* initialize XML */ - - /* reset prefix! */ - HDstrcpy(prefix, ""); - - /* make sure the URI is initialized to something */ - if (xml_dtd_uri == NULL) { - if (useschema) { - xml_dtd_uri = DEFAULT_XSD; - } else { - xml_dtd_uri = DEFAULT_DTD; - xmlnsprefix = ""; - } - } else { - if (useschema && strcmp(xmlnsprefix,"")) { + /* initialize XML */ + + /* reset prefix! */ + HDstrcpy(prefix, ""); + + /* make sure the URI is initialized to something */ + if (xml_dtd_uri == NULL) { + if (useschema) { + xml_dtd_uri = DEFAULT_XSD; + } else { + xml_dtd_uri = DEFAULT_DTD; + xmlnsprefix = ""; + } + } else { + if (useschema && strcmp(xmlnsprefix,"")) { error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); - leave(EXIT_FAILURE); - } - } + leave(EXIT_FAILURE); + } + } } /* find all shared objects */ @@ -3495,11 +3495,11 @@ main(int argc, const char *argv[]) /* start to dump - display file header information */ if (!doxml) { - begin_obj(dump_header_format->filebegin, fname, - dump_header_format->fileblockbegin); + begin_obj(dump_header_format->filebegin, fname, + dump_header_format->fileblockbegin); } else { - printf("\n"); - /* alternative first element, depending on schema or DTD. */ + printf("\n"); + /* alternative first element, depending on schema or DTD. */ if (useschema) { if (strcmp(xmlnsprefix,"") == 0) { printf("\n", @@ -3518,11 +3518,11 @@ main(int argc, const char *argv[]) "xsi:schemaLocation=\"http://hdfgroup.org/DTDs/HDF5File " "http://hdfgroup.org/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns); } - } else { + } else { printf("\n", xml_dtd_uri); printf("\n"); - } + } } if (!doxml) { @@ -3542,7 +3542,7 @@ main(int argc, const char *argv[]) error_msg(progname, "unable to open root group\n"); d_status = EXIT_FAILURE; } else { - dump_function_table->dump_group_function(gid, "/"); + dump_function_table->dump_group_function(gid, "/"); } if (H5Gclose(gid) < 0) { @@ -3550,13 +3550,13 @@ main(int argc, const char *argv[]) d_status = EXIT_FAILURE; } } else { - if (doxml) { - /* Note: this option is not supported for XML */ + if (doxml) { + /* Note: this option is not supported for XML */ error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__); d_status = EXIT_FAILURE; - goto done; - } + goto done; + } for (i = 0; i < argc; i++) if (hand[i].func) @@ -3564,15 +3564,15 @@ main(int argc, const char *argv[]) } if (!doxml) { - end_obj(dump_header_format->fileend, - dump_header_format->fileblockend); + end_obj(dump_header_format->fileend, + dump_header_format->fileblockend); } else { - printf("\n", xmlnsprefix); + printf("\n", xmlnsprefix); } done: if (H5Fclose(fid) < 0) - d_status = EXIT_FAILURE; + d_status = EXIT_FAILURE; free_handler(hand, argc); @@ -3629,15 +3629,15 @@ print_enum(hid_t type) * 3. raw format */ if (H5Tget_size(type) <= sizeof(long_long)) { - dst_size = sizeof(long_long); + dst_size = sizeof(long_long); - if (H5T_SGN_NONE == H5Tget_sign(type)) { - native = H5T_NATIVE_ULLONG; - } else { - native = H5T_NATIVE_LLONG; - } + 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 */ @@ -3645,8 +3645,8 @@ print_enum(hid_t type) value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { - name[i] = H5Tget_member_name(type, i); - H5Tget_member_value(type, i, value + i * H5Tget_size(type)); + name[i] = H5Tget_member_name(type, i); + H5Tget_member_value(type, i, value + i * H5Tget_size(type)); } /* Convert values to native data type */ @@ -3660,44 +3660,44 @@ print_enum(hid_t type) /* Print members */ for (i = 0; i < nmembs; i++) { - indentation(indent + COL); - nchars = printf("\"%s\"", name[i]); - printf("%*s ", MAX(0, 16 - nchars), ""); + indentation(indent + COL); + nchars = printf("\"%s\"", name[i]); + printf("%*s ", MAX(0, 16 - nchars), ""); - if (native < 0) { + if (native < 0) { size_t j; - printf("0x"); - - for (j = 0; j < dst_size; j++) - printf("%02x", value[i * dst_size + j]); - } else if (H5T_SGN_NONE == H5Tget_sign(native)) { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *) - ((void *)copy))); - } else { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", - *((long_long *) ((void *)copy))); - } - - printf(";\n"); + printf("0x"); + + for (j = 0; j < dst_size; j++) + printf("%02x", value[i * dst_size + j]); + } else if (H5T_SGN_NONE == H5Tget_sign(native)) { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value+i*dst_size; + HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *) + ((void *)copy))); + } else { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value+i*dst_size; + HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", + *((long_long *) ((void *)copy))); + } + + printf(";\n"); } /* Release resources */ for (i = 0; i < nmembs; i++) - free(name[i]); + free(name[i]); free(name); free(value); H5Tclose(super); if (0 == nmembs) - printf("\n%*s ", indent + 4, ""); + printf("\n%*s ", indent + 4, ""); } @@ -3713,7 +3713,7 @@ int xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) { haddr_t objno; /* Object ID for object at path */ - unsigned long _objno[2]; /*object number */ + unsigned long _objno[2]; /*object number */ if (outlen < 22) return 1; @@ -3730,7 +3730,7 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) #else /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ _objno[1] = 0; #endif /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ - sprintf(outstr,"xid_%lu-%lu", _objno[0], _objno[1]); + sprintf(outstr,"xid_%lu-%lu", _objno[0], _objno[1]); return 0; } else { return 1; @@ -3795,30 +3795,30 @@ xml_escape_the_name(const char *str) char *rcp; if (!str) - return NULL; + return NULL; cp = str; len = strlen(str); extra = 0; for (i = 0; i < len; i++) { - if (*cp == '\"') { - extra += (strlen(quote) - 1); - } else if (*cp == '\'') { - extra += (strlen(apos) - 1); - } else if (*cp == '<') { - extra += (strlen(lt) - 1); - } else if (*cp == '>') { - extra += (strlen(gt) - 1); - } else if (*cp == '&') { - extra += (strlen(amp) - 1); - } - - cp++; + if (*cp == '\"') { + extra += (strlen(quote) - 1); + } else if (*cp == '\'') { + extra += (strlen(apos) - 1); + } else if (*cp == '<') { + extra += (strlen(lt) - 1); + } else if (*cp == '>') { + extra += (strlen(gt) - 1); + } else if (*cp == '&') { + extra += (strlen(amp) - 1); + } + + cp++; } if (extra == 0) - return HDstrdup(str); + return HDstrdup(str); cp = str; rcp = ncp = HDmalloc(len + extra + 1); @@ -3881,66 +3881,66 @@ xml_escape_the_string(const char *str, int slen) char *rcp; if (!str) - return NULL; + return NULL; cp = str; if (slen < 0) - len = strlen(str); + len = strlen(str); else - len = slen; + len = slen; extra = 0; for (i = 0; i < len; i++) { - if (*cp == '\\') { - extra++; - } else if (*cp == '\"') { - extra++; - } else if (*cp == '\'') { - extra += (strlen(apos) - 1); - } else if (*cp == '<') { - extra += (strlen(lt) - 1); - } else if (*cp == '>') { - extra += (strlen(gt) - 1); - } else if (*cp == '&') { - extra += (strlen(amp) - 1); - } - cp++; + if (*cp == '\\') { + extra++; + } else if (*cp == '\"') { + extra++; + } else if (*cp == '\'') { + extra += (strlen(apos) - 1); + } else if (*cp == '<') { + extra += (strlen(lt) - 1); + } else if (*cp == '>') { + extra += (strlen(gt) - 1); + } else if (*cp == '&') { + extra += (strlen(amp) - 1); + } + cp++; } cp = str; rcp = ncp = calloc((len + extra + 1), sizeof(char)); if (ncp == NULL) - return NULL; /* ?? */ + return NULL; /* ?? */ for (i = 0; i < len; i++) { - if (*cp == '\\') { - *ncp++ = '\\'; - *ncp++ = *cp++; - } else if (*cp == '\"') { - *ncp++ = '\\'; - *ncp++ = *cp++; - } else if (*cp == '\'') { - strncpy(ncp, apos, strlen(apos)); - ncp += strlen(apos); - cp++; - } else if (*cp == '<') { - strncpy(ncp, lt, strlen(lt)); - ncp += strlen(lt); - cp++; - } else if (*cp == '>') { - strncpy(ncp, gt, strlen(gt)); - ncp += strlen(gt); - cp++; - } else if (*cp == '&') { - strncpy(ncp, amp, strlen(amp)); - ncp += strlen(amp); - cp++; - } else { - *ncp++ = *cp++; - } + if (*cp == '\\') { + *ncp++ = '\\'; + *ncp++ = *cp++; + } else if (*cp == '\"') { + *ncp++ = '\\'; + *ncp++ = *cp++; + } else if (*cp == '\'') { + strncpy(ncp, apos, strlen(apos)); + ncp += strlen(apos); + cp++; + } else if (*cp == '<') { + strncpy(ncp, lt, strlen(lt)); + ncp += strlen(lt); + cp++; + } else if (*cp == '>') { + strncpy(ncp, gt, strlen(gt)); + ncp += strlen(gt); + cp++; + } else if (*cp == '&') { + strncpy(ncp, amp, strlen(amp)); + ncp += strlen(amp); + cp++; + } else { + *ncp++ = *cp++; + } } *ncp = '\0'; @@ -4362,37 +4362,37 @@ xml_dump_datatype(hid_t type) if (H5Tcommitted(type) > 0) { obj_t *found_obj; /* Found object */ - /* Data type is a shared or named data type */ - H5Gget_objinfo(type, ".", TRUE, &statbuf); - found_obj = search_obj(type_table, statbuf.objno); - - if (found_obj) { - /* Shared data type, must be entered as an object */ - /* These 2 cases are the same now, but may change */ - char * dtxid = malloc(100); - xml_name_to_XID(found_obj->objname,dtxid,100,1); - if (!found_obj->recorded) { - /* anonymous stored data type: - following the dumper's current - practice: - use it's object ref as its name - */ - printf("<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n", - xmlnsprefix, dtxid); - - } else { - /* pointer to a named data type already in XML */ + /* Data type is a shared or named data type */ + H5Gget_objinfo(type, ".", TRUE, &statbuf); + found_obj = search_obj(type_table, statbuf.objno); + + if (found_obj) { + /* Shared data type, must be entered as an object */ + /* These 2 cases are the same now, but may change */ + char * dtxid = malloc(100); + xml_name_to_XID(found_obj->objname,dtxid,100,1); + if (!found_obj->recorded) { + /* anonymous stored data type: + following the dumper's current + practice: + use it's object ref as its name + */ + printf("<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n", + xmlnsprefix, dtxid); + + } else { + /* pointer to a named data type already in XML */ char *t_objname = xml_escape_the_name(found_obj->objname); - printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n", - xmlnsprefix, dtxid,t_objname); - free(t_objname); - } - free(dtxid); - } else { - printf("\n"); - } - indent -= COL; - return; + printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n", + xmlnsprefix, dtxid,t_objname); + free(t_objname); + } + free(dtxid); + } else { + printf("\n"); + } + indent -= COL; + return; } printf("<%sDataType>\n",xmlnsprefix); indent += COL; @@ -4422,7 +4422,7 @@ xml_dump_dataspace(hid_t space) hsize_t size[H5DUMP_MAX_RANK]; hsize_t maxsize[H5DUMP_MAX_RANK]; int ndims = - H5Sget_simple_extent_dims(space, size, maxsize); + H5Sget_simple_extent_dims(space, size, maxsize); H5S_class_t space_type = H5Sget_simple_extent_type(space); int i; @@ -4432,43 +4432,43 @@ xml_dump_dataspace(hid_t space) switch (space_type) { case H5S_SCALAR: - /* scalar dataspace (just a tag, no XML attrs. defined */ - printf("<%sScalarDataspace />\n",xmlnsprefix); + /* scalar dataspace (just a tag, no XML attrs. defined */ + printf("<%sScalarDataspace />\n",xmlnsprefix); break; case H5S_SIMPLE: - /* simple dataspace */ - /* */ - printf("<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); - - /* print the elements */ - for (i = 0; i < ndims; i++) { - indentation(indent + COL + COL + COL); - if (maxsize[i] == H5S_UNLIMITED) { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"UNLIMITED\"/>\n", - xmlnsprefix,size[i]); - } else if (maxsize[i] == (hsize_t) 0) { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", - xmlnsprefix,size[i], size[i]); - } else { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", - xmlnsprefix, size[i], maxsize[i]); - } - } - indentation(indent + COL + COL); - printf("\n", xmlnsprefix ); + /* simple dataspace */ + /* */ + printf("<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); + + /* print the elements */ + for (i = 0; i < ndims; i++) { + indentation(indent + COL + COL + COL); + if (maxsize[i] == H5S_UNLIMITED) { + HDfprintf(stdout, + "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"UNLIMITED\"/>\n", + xmlnsprefix,size[i]); + } else if (maxsize[i] == (hsize_t) 0) { + HDfprintf(stdout, + "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", + xmlnsprefix,size[i], size[i]); + } else { + HDfprintf(stdout, + "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", + xmlnsprefix, size[i], maxsize[i]); + } + } + indentation(indent + COL + COL); + printf("\n", xmlnsprefix ); break; case H5S_COMPLEX: - printf("\n"); + printf("\n"); break; case H5S_NO_CLASS: default: - printf("\n"); + printf("\n"); } indentation(indent + COL); @@ -4500,7 +4500,7 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU int ndims, i; hsize_t size[64], nelmts = 1; int depth; - int stdindent = COL; /* should be 3 */ + int stdindent = COL; /* should be 3 */ outputformat->line_ncols = nCols; indent += COL; @@ -4519,60 +4519,60 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU indentation(indent + COL); printf("<%sDataFromFile>\n",xmlnsprefix); if (obj_data == DATASET_DATA) { - type = H5Dget_type(obj_id); - if (H5Tget_class(type) == H5T_REFERENCE) { - status = xml_print_refs(obj_id, DATASET_DATA); - } else if (H5Tget_class(type) == H5T_STRING) { - status = xml_print_strs(obj_id, DATASET_DATA); - } else { - status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, NULL, depth); - } + type = H5Dget_type(obj_id); + if (H5Tget_class(type) == H5T_REFERENCE) { + status = xml_print_refs(obj_id, DATASET_DATA); + } else if (H5Tget_class(type) == H5T_STRING) { + status = xml_print_strs(obj_id, DATASET_DATA); + } else { + status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, NULL, depth); + } + } else { + /* Attribute data */ + type = H5Aget_type(obj_id); + + if (H5Tget_class(type) == H5T_REFERENCE) { + /* references are done differently than + the standard output: + XML dumps a path to the object + referenced. + */ + status = xml_print_refs(obj_id, ATTRIBUTE_DATA); + H5Tclose(type); + } else if (H5Tget_class(type) == H5T_STRING) { + status = xml_print_strs(obj_id, ATTRIBUTE_DATA); } else { - /* Attribute data */ - type = H5Aget_type(obj_id); - - if (H5Tget_class(type) == H5T_REFERENCE) { - /* references are done differently than - the standard output: - XML dumps a path to the object - referenced. - */ - status = xml_print_refs(obj_id, ATTRIBUTE_DATA); - H5Tclose(type); - } else if (H5Tget_class(type) == H5T_STRING) { - status = xml_print_strs(obj_id, ATTRIBUTE_DATA); - } else { - /* all other data */ + /* all other data */ p_type = h5tools_get_native_type(type); - H5Tclose(type); + H5Tclose(type); - space = H5Aget_space(obj_id); + space = H5Aget_space(obj_id); - ndims = H5Sget_simple_extent_dims(space, size, NULL); + ndims = H5Sget_simple_extent_dims(space, size, NULL); - for (i = 0; i < ndims; i++) - nelmts *= size[i]; + for (i = 0; i < ndims; i++) + nelmts *= size[i]; - buf = - malloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)))); - assert(buf); + buf = + malloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)))); + assert(buf); - if (H5Aread(obj_id, p_type, buf) >= 0) + if (H5Aread(obj_id, p_type, buf) >= 0) status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, space, buf, depth); - free(buf); - H5Tclose(p_type); - H5Sclose(space); - H5Tclose(type); - } + free(buf); + H5Tclose(p_type); + H5Sclose(space); + H5Tclose(type); + } } if (status == FAIL) { - indentation(indent + COL); - printf("Unable to print data.\n"); - status = 1; + indentation(indent + COL); + printf("Unable to print data.\n"); + status = 1; } indentation(indent + COL); @@ -4606,102 +4606,102 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) free(t_aname); if ((attr_id = H5Aopen_name(attr, attr_name)) >= 0) { - type = H5Aget_type(attr_id); - space = H5Aget_space(attr_id); - - dump_function_table->dump_dataspace_function(space); - dump_function_table->dump_datatype_function(type); - - if (display_attr_data) { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - - case H5T_TIME: - indent += COL; - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("\n"); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("\n"); - printf("\n",xmlnsprefix); - indent -= COL; - break; - - case H5T_COMPOUND: - indentation(indent); - printf("\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - - case H5T_REFERENCE: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); + type = H5Aget_type(attr_id); + space = H5Aget_space(attr_id); + + dump_function_table->dump_dataspace_function(space); + dump_function_table->dump_datatype_function(type); + + if (display_attr_data) { + switch (H5Tget_class(type)) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + + case H5T_TIME: + indent += COL; + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("\n"); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("\n"); + printf("\n",xmlnsprefix); + indent -= COL; + break; + + case H5T_COMPOUND: + indentation(indent); + printf("\n"); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + + case H5T_REFERENCE: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); if (!H5Tequal(type, H5T_STD_REF_OBJ)) { printf("\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(attr_id, ATTRIBUTE_DATA); - indentation(indent); - printf("\n",xmlnsprefix); + printf("<%sDataFromFile>\n",xmlnsprefix); + xml_print_refs(attr_id, ATTRIBUTE_DATA); + indentation(indent); + printf("\n",xmlnsprefix); } - indentation(indent); - printf("\n",xmlnsprefix); - break; - - case H5T_VLEN: - printf("\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - default: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("\n",xmlnsprefix); - break; - } - } else { - /* The case of an attribute never yet written ?? */ - indentation(indent + COL); - printf("<%sData>\n",xmlnsprefix); - indentation(indent + COL + COL); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent + COL); - printf("\n",xmlnsprefix); - } - - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr_id); - indentation(indent); - printf("\n", xmlnsprefix ); - return SUCCEED; + indentation(indent); + printf("\n",xmlnsprefix); + break; + + case H5T_VLEN: + printf("\n"); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + default: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("\n", H5Tget_class(type)); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("\n",xmlnsprefix); + break; + } + } else { + /* The case of an attribute never yet written ?? */ + indentation(indent + COL); + printf("<%sData>\n",xmlnsprefix); + indentation(indent + COL + COL); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent + COL); + printf("\n",xmlnsprefix); + } + + H5Tclose(type); + H5Sclose(space); + H5Aclose(attr_id); + indentation(indent); + printf("\n", xmlnsprefix ); + return SUCCEED; } else { - /* ?? failed */ - indentation(indent + COL); - printf("\n"); - indentation(indent); - printf("\n", xmlnsprefix ); - d_status = EXIT_FAILURE; - return FAIL; + /* ?? failed */ + indentation(indent + COL); + printf("\n"); + indentation(indent); + printf("\n", xmlnsprefix ); + d_status = EXIT_FAILURE; + return FAIL; } } @@ -4742,25 +4742,25 @@ xml_dump_named_datatype(hid_t type, const char *name) xml_name_to_XID(tmp,dtxid,100,1); xml_name_to_XID(prefix,parentxid,100,1); if (strncmp(name, "#", 1) == 0) { - /* Special: this is an 'anonymous' NDT, deleted but - still in use. - We follow the dumper's undocumented practice, and - use its object id as its name. - Exactly the same as normal, but a separate case - in the event we want to do something else in - the future. - */ - printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\">\n", - xmlnsprefix, - name, dtxid, - parentxid,(HDstrcmp(prefix, "") ? t_prefix : "/")); + /* Special: this is an 'anonymous' NDT, deleted but + still in use. + We follow the dumper's undocumented practice, and + use its object id as its name. + Exactly the same as normal, but a separate case + in the event we want to do something else in + the future. + */ + printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\">\n", + xmlnsprefix, + name, dtxid, + parentxid,(HDstrcmp(prefix, "") ? t_prefix : "/")); } else { - printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " - "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n", - xmlnsprefix, - t_name, dtxid, - t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/")); + printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n", + xmlnsprefix, + t_name, dtxid, + t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/")); } HDfree(dtxid); HDfree(parentxid); @@ -4813,21 +4813,21 @@ xml_dump_group(hid_t gid, const char *name) char *par_name; if (HDstrcmp(name, "/") == 0) { - isRoot = 1; - tmp = HDmalloc(2); - HDstrcpy(tmp, "/"); + isRoot = 1; + tmp = HDmalloc(2); + HDstrcpy(tmp, "/"); } else { - tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - HDstrcpy(tmp, prefix); - par = HDstrdup(tmp); - cp = HDstrrchr(par, '/'); - if (cp != NULL) { - if ((cp == par) && HDstrlen(par) > 1) { - *(cp + 1) = '\0'; - } else { - *cp = '\0'; - } - } + tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + HDstrcpy(tmp, prefix); + par = HDstrdup(tmp); + cp = HDstrrchr(par, '/'); + if (cp != NULL) { + if ((cp == par) && HDstrlen(par) > 1) { + *(cp + 1) = '\0'; + } else { + *cp = '\0'; + } + } } indentation(indent); @@ -4838,15 +4838,15 @@ xml_dump_group(hid_t gid, const char *name) if (statbuf.nlink > 1) { obj_t *found_obj; /* Found object */ - /* Group with more than one link to it... */ - found_obj = search_obj(group_table, statbuf.objno); + /* Group with more than one link to it... */ + found_obj = search_obj(group_table, statbuf.objno); - if (found_obj == NULL) { - indentation(indent); + if (found_obj == NULL) { + indentation(indent); error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; - } else { + d_status = EXIT_FAILURE; + } else { char *t_name = xml_escape_the_name(name); char *grpxid = malloc(100); char *parentxid = malloc(100); @@ -4914,7 +4914,7 @@ xml_dump_group(hid_t gid, const char *name) /* Very special case: dump unamed type in root group */ for (u = 0; u < type_table->nobjs; u++) { if (!type_table->objs[u].recorded) { - unsigned long objno[2]; /*object number */ + unsigned long objno[2]; /*object number */ dset = H5Dopen(gid, type_table->objs[u].objname); type = H5Dget_type(dset); @@ -4951,42 +4951,42 @@ xml_dump_group(hid_t gid, const char *name) } } else { - /* only link -- must be first time! */ + /* only link -- must be first time! */ char *t_name = xml_escape_the_name(name); - char *grpxid = malloc(100); - char *parentxid = malloc(100); - if (isRoot) { - xml_name_to_XID("/",grpxid,100,1); - printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", - xmlnsprefix,grpxid,"/"); - } else { - char *t_tmp = xml_escape_the_name(tmp); - par_name = xml_escape_the_name(par); - xml_name_to_XID(tmp,grpxid,100,1); - xml_name_to_XID(par,parentxid,100,1); - printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" >\n", - xmlnsprefix,t_name, grpxid, t_tmp, - parentxid, par_name); - free(t_tmp); - free(par_name); - } + char *grpxid = malloc(100); + char *parentxid = malloc(100); + if (isRoot) { + xml_name_to_XID("/",grpxid,100,1); + printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", + xmlnsprefix,grpxid,"/"); + } else { + char *t_tmp = xml_escape_the_name(tmp); + par_name = xml_escape_the_name(par); + xml_name_to_XID(tmp,grpxid,100,1); + xml_name_to_XID(par,parentxid,100,1); + printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" >\n", + xmlnsprefix,t_name, grpxid, t_tmp, + parentxid, par_name); + free(t_tmp); + free(par_name); + } free(t_name); - free(grpxid); - free(parentxid); - /* 1. do all the attributes of the group */ - H5Aiterate(gid, NULL, dump_function_table->dump_attribute_function, NULL); + free(grpxid); + free(parentxid); + /* 1. do all the attributes of the group */ + H5Aiterate(gid, NULL, dump_function_table->dump_attribute_function, NULL); - if (!strcmp(name, "/") && unamedtype) { + if (!strcmp(name, "/") && unamedtype) { unsigned u; - /* Very special case: dump unamed type in root group */ - for (u = 0; u < type_table->nobjs; u++) { - if (!type_table->objs[u].recorded) { - unsigned long objno[2]; /*object number */ + /* Very special case: dump unamed type in root group */ + for (u = 0; u < type_table->nobjs; u++) { + if (!type_table->objs[u].recorded) { + unsigned long objno[2]; /*object number */ - dset = H5Dopen(gid, type_table->objs[u].objname); - type = H5Dget_type(dset); + dset = H5Dopen(gid, type_table->objs[u].objname); + type = H5Dget_type(dset); objno[0] = (unsigned long)(type_table->objs[u].objno); #if H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG @@ -4994,33 +4994,33 @@ xml_dump_group(hid_t gid, const char *name) #else /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ objno[1] = 0; #endif /* H5_SIZEOF_UINT64_T>H5_SIZEOF_LONG */ - sprintf(type_name, "#%lu:%lu", objno[0], objno[1]); - dump_function_table->dump_named_datatype_function(type, type_name); - - H5Tclose(type); - H5Dclose(dset); - } - } - } - - /* iterate through all the members */ - xtype = H5G_TYPE; - H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); - xtype = H5G_DATASET; - H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); - xtype = H5G_GROUP; - H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); - xtype = H5G_LINK; - H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); + sprintf(type_name, "#%lu:%lu", objno[0], objno[1]); + dump_function_table->dump_named_datatype_function(type, type_name); + + H5Tclose(type); + H5Dclose(dset); + } + } + } + + /* iterate through all the members */ + xtype = H5G_TYPE; + H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); + xtype = H5G_DATASET; + H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); + xtype = H5G_GROUP; + H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); + xtype = H5G_LINK; + H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); } indent -= COL; indentation(indent); if (isRoot) { - printf("\n",xmlnsprefix); + printf("\n",xmlnsprefix); } else { - printf("\n" ,xmlnsprefix); + printf("\n" ,xmlnsprefix); } free(tmp); } @@ -5049,53 +5049,53 @@ xml_print_refs(hid_t did, int source) hsize_t i; if (source == DATASET_DATA) { - type = H5Dget_type(did); + type = H5Dget_type(did); } else if (source == ATTRIBUTE_DATA) { - type = H5Aget_type(did); + type = H5Aget_type(did); } else { - /* return an error */ - return FAIL; + /* return an error */ + return FAIL; } if (H5Tget_class(type) != H5T_REFERENCE) { - /* return an error */ - return FAIL; + /* return an error */ + return FAIL; } if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - /* region ref not supported yet... */ - /* return an error */ - return FAIL; + /* region ref not supported yet... */ + /* return an error */ + return FAIL; } if (source == DATASET_DATA) { - space = H5Dget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); - - buf = calloc((size_t)ssiz, sizeof(char)); - if (buf == NULL) { - return FAIL; - } - e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - /* need to check result here */ - if (e < 0) { - free(buf); - return FAIL; - } + space = H5Dget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); + + buf = calloc((size_t)ssiz, sizeof(char)); + if (buf == NULL) { + return FAIL; + } + e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + /* need to check result here */ + if (e < 0) { + free(buf); + return FAIL; + } } else if (source == ATTRIBUTE_DATA) { - space = H5Aget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); - - buf = calloc((size_t)ssiz, sizeof(char)); - if (buf == NULL) { - free(buf); - return FAIL; - } - e = H5Aread(did, H5T_STD_REF_OBJ, buf); - /* need to check the result here */ + space = H5Aget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); + + buf = calloc((size_t)ssiz, sizeof(char)); + if (buf == NULL) { + free(buf); + return FAIL; + } + e = H5Aread(did, H5T_STD_REF_OBJ, buf); + /* need to check the result here */ } else { - /* error */ - return FAIL; + /* error */ + return FAIL; } refbuf = (hobj_ref_t *) buf; @@ -5104,19 +5104,19 @@ xml_print_refs(hid_t did, int source) for (i = 0; i < ssiz; i++) { const char *path; - path = lookup_ref_path(*refbuf); - indentation(indent + COL); + path = lookup_ref_path(*refbuf); + indentation(indent + COL); - if (!path) { - printf("\"%s\"\n", "NULL"); - } else { + if (!path) { + printf("\"%s\"\n", "NULL"); + } else { char *t_path = xml_escape_the_string(path, -1); - printf("\"%s\"\n", t_path); + printf("\"%s\"\n", t_path); free(t_path); - } + } - refbuf++; + refbuf++; } free(buf); @@ -5151,54 +5151,54 @@ xml_print_strs(hid_t did, int source) htri_t is_vlstr; if (source == DATASET_DATA) { - type = H5Dget_type(did); + type = H5Dget_type(did); } else if (source == ATTRIBUTE_DATA) { - type = H5Aget_type(did); + type = H5Aget_type(did); } else { - /* return an error */ - return FAIL; + /* return an error */ + return FAIL; } if (H5Tget_class(type) != H5T_STRING) { - /* return an error */ - return FAIL; + /* return an error */ + return FAIL; } is_vlstr = H5Tis_variable_str(type); if (source == DATASET_DATA) { - space = H5Dget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); + space = H5Dget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); - buf = malloc((size_t)ssiz); + buf = malloc((size_t)ssiz); - if (buf == NULL) { - return FAIL; - } + if (buf == NULL) { + return FAIL; + } - e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (e < 0) { - free(buf); - return FAIL; - } + if (e < 0) { + free(buf); + return FAIL; + } } else if (source == ATTRIBUTE_DATA) { - space = H5Aget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); - - buf = malloc((size_t)ssiz); - if (buf == NULL) { - return FAIL; - } - - e = H5Aread(did, type, buf); - if (e < 0) { - free(buf); - return FAIL; - } + space = H5Aget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); + + buf = malloc((size_t)ssiz); + if (buf == NULL) { + return FAIL; + } + + e = H5Aread(did, type, buf); + if (e < 0) { + free(buf); + return FAIL; + } } else { - /* error */ - return FAIL; + /* error */ + return FAIL; } /* pull out each string... */ @@ -5215,19 +5215,19 @@ xml_print_strs(hid_t did, int source) if(onestring) str_size = (size_t)HDstrlen(onestring); } else { - HDstrncpy(onestring, bp, tsiz); + HDstrncpy(onestring, bp, tsiz); str_size = tsiz; } - indentation(indent + COL); + indentation(indent + COL); - if (!onestring) { - printf("NULL\n"); - } else { + if (!onestring) { + printf("NULL\n"); + } else { char *t_onestring = xml_escape_the_string(onestring, (int)str_size); - printf("\"%s\"\n", t_onestring); + printf("\"%s\"\n", t_onestring); free(t_onestring); - } + } bp += tsiz; } @@ -5262,45 +5262,45 @@ check_filters(hid_t dcpl) nfilt = H5Pget_nfilters(dcpl); if (nfilt <= 0) - return; + return; for (i = 0; i < nfilt; i++) { - filter = H5Pget_filter(dcpl, (unsigned)i, &flags, - (size_t *) &cd_nelmts, - cd_values, 120, namebuf); - if (filter == H5Z_FILTER_DEFLATE) { - indentation(indent + COL); - printf("<%sDeflate Level=\"",xmlnsprefix); + filter = H5Pget_filter(dcpl, (unsigned)i, &flags, + (size_t *) &cd_nelmts, + cd_values, 120, namebuf); + if (filter == H5Z_FILTER_DEFLATE) { + indentation(indent + COL); + printf("<%sDeflate Level=\"",xmlnsprefix); if (cd_nelmts < 1) { - /* not sure what this means? */ - printf("6"); + /* not sure what this means? */ + printf("6"); } else { - printf("%d",cd_values[0]); + printf("%d",cd_values[0]); } - printf("\"/>\n"); - } else if (filter == H5Z_FILTER_FLETCHER32) { - indentation(indent + COL); - printf("<%sFletcher32 />",xmlnsprefix); - } else if (filter == H5Z_FILTER_SHUFFLE) { - indentation(indent + COL); - printf("<%sShuffle />",xmlnsprefix); - } else if (filter == H5Z_FILTER_SZIP) { - - indentation(indent + COL); - printf("<%sSZIP ",xmlnsprefix); + printf("\"/>\n"); + } else if (filter == H5Z_FILTER_FLETCHER32) { + indentation(indent + COL); + printf("<%sFletcher32 />",xmlnsprefix); + } else if (filter == H5Z_FILTER_SHUFFLE) { + indentation(indent + COL); + printf("<%sShuffle />",xmlnsprefix); + } else if (filter == H5Z_FILTER_SZIP) { + + indentation(indent + COL); + printf("<%sSZIP ",xmlnsprefix); if (cd_nelmts < 2) { - /* no pixels ? */ - printf("Pixels_per_block=\"-1\" "); + /* no pixels ? */ + printf("Pixels_per_block=\"-1\" "); } else { - printf("Pixels_per_block=\"%d\" ",cd_values[1]); + printf("Pixels_per_block=\"%d\" ",cd_values[1]); } - /* analyse the options mask */ - if (cd_values[0] & H5_SZIP_CHIP_OPTION_MASK) { + /* analyse the options mask */ + if (cd_values[0] & H5_SZIP_CHIP_OPTION_MASK) { printf("Mode =\"Hardware\" "); } else if (cd_values[0] & H5_SZIP_ALLOW_K13_OPTION_MASK) { printf("Mode =\"K13\" "); } printf("Coding=\""); - if (cd_values[0] & H5_SZIP_EC_OPTION_MASK) { + if (cd_values[0] & H5_SZIP_EC_OPTION_MASK) { printf("Entropy"); } else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) { printf("NN"); @@ -5308,20 +5308,20 @@ check_filters(hid_t dcpl) printf("\" "); printf("ByteOrder=\""); - if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) { + if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) { printf("LSB"); } else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) { printf("MSB"); } printf("\" "); - if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) { + if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) { printf("Header=\"Raw\""); } - printf("/>\n"); - } else { - /* unknown option */ - } + printf("/>\n"); + } else { + /* unknown option */ + } } } @@ -5493,7 +5493,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) xml_name_to_XID(tmp, rstr, 100, 1); xml_name_to_XID(prefix, pstr, 100, 1); printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n",xmlnsprefix, - t_name, rstr, t_tmp, pstr, strcmp(prefix, "") ? t_prefix : "/"); + t_name, rstr, t_tmp, pstr, strcmp(prefix, "") ? t_prefix : "/"); HDfree(t_name); HDfree(t_tmp); @@ -5508,66 +5508,66 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) /* Print information about storage layout */ if (H5D_CHUNKED == H5Pget_layout(dcpl)) { - maxdims = H5Sget_simple_extent_ndims(space); - chsize = (hsize_t *) malloc(maxdims * sizeof(hsize_t)); - indent += COL; - indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sChunkedLayout ",xmlnsprefix); - ndims = H5Pget_chunk(dcpl, maxdims, chsize); - printf("Ndims=\"%d\">\n", ndims); - - indent += COL; - - for (i = 0; i < ndims; i++) { - indentation(indent); - HDfprintf(stdout, "<%sChunkDimension DimSize=\"%Hu\" />\n", + maxdims = H5Sget_simple_extent_ndims(space); + chsize = (hsize_t *) malloc(maxdims * sizeof(hsize_t)); + indent += COL; + indentation(indent); + printf("<%sStorageLayout>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sChunkedLayout ",xmlnsprefix); + ndims = H5Pget_chunk(dcpl, maxdims, chsize); + printf("Ndims=\"%d\">\n", ndims); + + indent += COL; + + for (i = 0; i < ndims; i++) { + indentation(indent); + HDfprintf(stdout, "<%sChunkDimension DimSize=\"%Hu\" />\n", xmlnsprefix, chsize[i]); - } - - indentation(indent); - printf("<%sRequiredFilter>\n",xmlnsprefix); - indent += COL; - check_filters(dcpl); - indent -= COL; - indentation(indent); - printf("\n",xmlnsprefix); - - indent -= COL; - - indentation(indent); - printf("\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("\n",xmlnsprefix); - indent -= COL; - free(chsize); + } + + indentation(indent); + printf("<%sRequiredFilter>\n",xmlnsprefix); + indent += COL; + check_filters(dcpl); + indent -= COL; + indentation(indent); + printf("\n",xmlnsprefix); + + indent -= COL; + + indentation(indent); + printf("\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("\n",xmlnsprefix); + indent -= COL; + free(chsize); } else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) { - indent += COL; - indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sContiguousLayout/>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("\n",xmlnsprefix); - indent -= COL; - indentation(indent); + indent += COL; + indentation(indent); + printf("<%sStorageLayout>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sContiguousLayout/>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("\n",xmlnsprefix); + indent -= COL; + indentation(indent); } else if (H5D_COMPACT == H5Pget_layout(dcpl)) { - indent += COL; - indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sCompactLayout/>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("\n",xmlnsprefix); - indent -= COL; - indentation(indent); + indent += COL; + indentation(indent); + printf("<%sStorageLayout>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sCompactLayout/>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("\n",xmlnsprefix); + indent -= COL; + indentation(indent); } /* and check for external.... ?? */ @@ -5579,36 +5579,36 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) H5Pget_fill_time(dcpl, &ft); printf("FillTime=\""); switch ( ft ) { - case H5D_FILL_TIME_ALLOC: + case H5D_FILL_TIME_ALLOC: printf("FillOnAlloc"); - break; - case H5D_FILL_TIME_NEVER: + break; + case H5D_FILL_TIME_NEVER: printf("FillNever"); - break; - case H5D_FILL_TIME_IFSET: + break; + case H5D_FILL_TIME_IFSET: printf("FillIfSet"); - break; - default: + break; + default: printf("?"); - break; + break; } printf("\" "); H5Pget_alloc_time(dcpl, &at); printf("AllocationTime=\""); switch ( at ) { - case H5D_ALLOC_TIME_EARLY: + case H5D_ALLOC_TIME_EARLY: printf("Early"); - break; - case H5D_ALLOC_TIME_INCR: + break; + case H5D_ALLOC_TIME_INCR: printf("Incremental"); - break; - case H5D_ALLOC_TIME_LATE: + break; + case H5D_ALLOC_TIME_LATE: printf("Late"); - break; - case H5D_ALLOC_TIME_DEFAULT: - default: + break; + case H5D_ALLOC_TIME_DEFAULT: + default: printf("?"); - break; + break; } printf("\""); printf(">\n"); @@ -5644,77 +5644,77 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) tempi = H5Dget_storage_size(did); if (display_data && (tempi > 0)) { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; - - case H5T_TIME: - indent += COL; - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indent -= COL; - break; - - case H5T_COMPOUND: - indentation(indent); - printf("\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; - - case H5T_REFERENCE: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); + switch (H5Tget_class(type)) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; + + case H5T_TIME: + indent += COL; + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("\n"); + indentation(indent); + printf("<%sNoData />\n",xmlnsprefix); + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indent -= COL; + break; + + case H5T_COMPOUND: + indentation(indent); + printf("\n"); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; + + case H5T_REFERENCE: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); if (!H5Tequal(type, H5T_STD_REF_OBJ)) { printf("\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(did, DATASET_DATA); - indentation(indent); - printf("\n",xmlnsprefix); + printf("<%sDataFromFile>\n",xmlnsprefix); + xml_print_refs(did, DATASET_DATA); + indentation(indent); + printf("\n",xmlnsprefix); } - indentation(indent); - printf("\n",xmlnsprefix); - break; - - case H5T_VLEN: - printf("\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; - default: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("\n",xmlnsprefix); - break; - } + indentation(indent); + printf("\n",xmlnsprefix); + break; + + case H5T_VLEN: + printf("\n"); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; + default: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("\n", H5Tget_class(type)); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("\n",xmlnsprefix); + break; + } } else { - /* no data written */ - indentation(indent + COL); - printf("<%sData>\n",xmlnsprefix); - indentation(indent + COL + COL); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent + COL); - printf("\n",xmlnsprefix); + /* no data written */ + indentation(indent + COL); + printf("<%sData>\n",xmlnsprefix); + indentation(indent + COL + COL); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent + COL); + printf("\n",xmlnsprefix); } H5Tclose(type); @@ -5741,13 +5741,13 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) static void xml_print_enum(hid_t type) { - char **name = NULL; /*member names */ - unsigned char *value = NULL; /*value array */ - 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 */ - unsigned i; /*miscellaneous counters */ + char **name = NULL; /*member names */ + unsigned char *value = NULL; /*value array */ + 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 */ + unsigned i; /*miscellaneous counters */ size_t j; nmembs = H5Tget_nmembers(type); @@ -5767,15 +5767,15 @@ xml_print_enum(hid_t type) * 3. raw format */ if (H5Tget_size(type) <= sizeof(long_long)) { - dst_size = sizeof(long_long); + dst_size = sizeof(long_long); - if (H5T_SGN_NONE == H5Tget_sign(type)) { - native = H5T_NATIVE_ULLONG; - } else { - native = H5T_NATIVE_LLONG; - } + if (H5T_SGN_NONE == H5Tget_sign(type)) { + native = H5T_NATIVE_ULLONG; } else { - dst_size = H5Tget_size(type); + native = H5T_NATIVE_LLONG; + } + } else { + dst_size = H5Tget_size(type); } /* Get the names and raw values of all members */ @@ -5783,13 +5783,13 @@ xml_print_enum(hid_t type) value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { - name[i] = H5Tget_member_name(type, i); - H5Tget_member_value(type, i, value + i * H5Tget_size(type)); + name[i] = H5Tget_member_name(type, i); + H5Tget_member_value(type, i, value + i * H5Tget_size(type)); } /* Convert values to native data type */ if (native > 0) - H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); + H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); /* Sort members by increasing value */ /*not implemented yet */ @@ -5799,38 +5799,38 @@ xml_print_enum(hid_t type) for (i = 0; i < nmembs; i++) { char *t_name = xml_escape_the_name(name[i]); - indentation(indent); - printf("<%sEnumElement>\n",xmlnsprefix); - indentation(indent + COL); - printf("%s\n", t_name); + indentation(indent); + printf("<%sEnumElement>\n",xmlnsprefix); + indentation(indent + COL); + printf("%s\n", t_name); free(t_name); - indentation(indent); - printf("\n",xmlnsprefix); - indentation(indent); - printf("<%sEnumValue>\n",xmlnsprefix); - indentation(indent + COL); - if (native < 0) { - printf("0x"); - - for (j = 0; j < dst_size; j++) - printf("%02x", value[i * dst_size + j]); - } else if (H5T_SGN_NONE == H5Tget_sign(native)) { - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *) - ((void *) (value + i * dst_size)))); - } else { - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", - *((long_long *) ((void *) (value + i * dst_size)))); - } - printf("\n"); - indentation(indent); - printf("\n",xmlnsprefix); + indentation(indent); + printf("\n",xmlnsprefix); + indentation(indent); + printf("<%sEnumValue>\n",xmlnsprefix); + indentation(indent + COL); + if (native < 0) { + printf("0x"); + + for (j = 0; j < dst_size; j++) + printf("%02x", value[i * dst_size + j]); + } else if (H5T_SGN_NONE == H5Tget_sign(native)) { + HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *) + ((void *) (value + i * dst_size)))); + } else { + HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", + *((long_long *) ((void *) (value + i * dst_size)))); + } + printf("\n"); + indentation(indent); + printf("\n",xmlnsprefix); } indent -= COL; /* Release resources */ for (i = 0; i < nmembs; i++) - free(name[i]); + free(name[i]); free(name); free(value); @@ -5839,17 +5839,17 @@ xml_print_enum(hid_t type) /*------------------------------------------------------------------------- - * Function: h5_fileaccess + * Function: h5_fileaccess * - * Purpose: Returns a file access template which is the default template - * but with a file driver set according to the constant or - * environment variable HDF5_DRIVER + * Purpose: Returns a file access template which is the default template + * but with a file driver set according to the constant or + * environment variable HDF5_DRIVER * - * Return: Success: A file access property list + * Return: Success: A file access property list * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, November 19, 1998 * * Modifications: @@ -5860,8 +5860,8 @@ static hid_t h5_fileaccess(void) { static const char *multi_letters = "msbrglo"; - const char *val = NULL; - const char *name; + const char *val = NULL; + const char *name; char s[1024]; hid_t fapl = -1; @@ -5879,53 +5879,53 @@ h5_fileaccess(void) if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl; if (!HDstrcmp(name, "sec2")) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; + /* Unix read() and write() system calls */ + if (H5Pset_fapl_sec2(fapl)<0) return -1; } else if (!HDstrcmp(name, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl)<0) return -1; + /* Standard C fread() and fwrite() system calls */ + if (H5Pset_fapl_stdio(fapl)<0) return -1; } else if (!HDstrcmp(name, "core")) { - /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; + /* In-core temporary file with 1MB increment */ + if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; } else if (!HDstrcmp(name, "split")) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT)<0) - return -1; + /* Split meta data and raw data each using default driver */ + if (H5Pset_fapl_split(fapl, + "-m.h5", H5P_DEFAULT, + "-r.h5", H5P_DEFAULT)<0) + return -1; } else if (!HDstrcmp(name, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - 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); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for (mt=H5FD_MEM_DEFAULT; mt * Thursday, July 23, 1998 * - * Purpose: A library for displaying the values of a dataset in a human - * readable format. + * Purpose: A library for displaying the values of a dataset in a human + * readable format. */ #include @@ -42,11 +42,11 @@ #define H5TOOLS_BUFSIZE (1024) #endif /* 1 */ -#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) +#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) /* global variables */ int compound_data; -FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */ +FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */ /* module-scoped variables */ static int h5tools_init_g; /* if h5tools lib has been initialized */ @@ -62,7 +62,7 @@ static const char *drivernames[]={ "multi", #ifdef H5_HAVE_STREAM "stream", -#endif /* H5_HAVE_STREAM */ +#endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL "mpio", "mpiposix" @@ -78,7 +78,7 @@ enum { ,MULTI_IDX #ifdef H5_HAVE_STREAM ,STREAM_IDX -#endif /* H5_HAVE_STREAM */ +#endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL ,MPIO_IDX ,MPIPOSIX_IDX @@ -105,17 +105,17 @@ void h5tools_init(void) { if (!h5tools_init_g) { - if (!rawdatastream) - rawdatastream = stdout; + if (!rawdatastream) + rawdatastream = stdout; - h5tools_init_g++; + h5tools_init_g++; } } /*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library - * Purpose: Close the H5 Tools library + * Purpose: Close the H5 Tools library * Description: * Close or release resources such as files opened by the library. This * should be called after all other h5tools functions have been called. @@ -132,12 +132,12 @@ void h5tools_close(void) { if (h5tools_init_g) { - if (rawdatastream && rawdatastream != stdout) { - if (fclose(rawdatastream)) - perror("closing rawdatastream"); - else - rawdatastream = NULL; - } + if (rawdatastream && rawdatastream != stdout) { + if (fclose(rawdatastream)) + perror("closing rawdatastream"); + else + rawdatastream = NULL; + } /* Clean up the reference path table, if it's been used */ term_ref_path_table(); @@ -145,14 +145,14 @@ h5tools_close(void) /* Shut down the library */ H5close(); - h5tools_init_g = 0; + h5tools_init_g = 0; } } /*------------------------------------------------------------------------- * Audience: Private * Chapter: H5Tools Library - * Purpose: Get a FAPL for a driver + * Purpose: Get a FAPL for a driver * Description: * Get a FAPL for a given VFL driver name. * Return: @@ -208,32 +208,32 @@ h5tools_get_fapl(const char *driver, unsigned *drivernum) if(drivernum) *drivernum = STREAM_IDX; } /* end if */ -#endif /* H5_HAVE_STREAM */ +#endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL } else if (!strcmp(driver, drivernames[MPIO_IDX])) { /* MPI-I/O Driver */ - /* check if MPI has been initialized. */ - if (!h5tools_mpi_init_g) - MPI_Initialized(&h5tools_mpi_init_g); + /* check if MPI has been initialized. */ + if (!h5tools_mpi_init_g) + MPI_Initialized(&h5tools_mpi_init_g); if (h5tools_mpi_init_g && ((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0)) { if (H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL)<0) - goto error; + goto error; if(drivernum) *drivernum = MPIO_IDX; } /* end if */ } else if (!strcmp(driver, drivernames[MPIPOSIX_IDX])) { /* MPI-I/O Driver */ - /* check if MPI has been initialized. */ - if (!h5tools_mpi_init_g) - MPI_Initialized(&h5tools_mpi_init_g); + /* check if MPI has been initialized. */ + if (!h5tools_mpi_init_g) + MPI_Initialized(&h5tools_mpi_init_g); if (h5tools_mpi_init_g && ((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0)) { #ifdef H5_WANT_H5_V1_4_COMPAT if (H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD)<0) #else - if (H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD, TRUE)<0) + if (H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD, TRUE)<0) #endif - goto error; + goto error; if(drivernum) *drivernum = MPIPOSIX_IDX; @@ -405,8 +405,8 @@ h5tools_ncols(const char *s) * Robb Matzke, Monday, April 26, 1999 * Modifications: * Robb Matzke, 1999-09-29 - * If a new prefix is printed then the current element number is set back - * to zero. + * If a new prefix is printed then the current element number is set back + * to zero. * pvn, 2004-07-08 * Added support for printing array indices: * the indentation is printed before the prefix (printed one indentation @@ -423,16 +423,16 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, int i, indentlevel = 0; if (!ctx->need_prefix) - return; + return; memset(&prefix, 0, sizeof(h5tools_str_t)); memset(&str, 0, sizeof(h5tools_str_t)); /* Terminate previous line, if any */ if (ctx->cur_column) { - fputs(OPT(info->line_suf, ""), stream); + fputs(OPT(info->line_suf, ""), stream); putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + fputs(OPT(info->line_sep, ""), stream); } /* Calculate new prefix */ @@ -449,7 +449,7 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, * the ctx->indent_level is negative so we need to skip the above and * just print out the default indent levels. */ - indentlevel = ctx->default_indent_level; + indentlevel = ctx->default_indent_level; } /* when printing array indices, print the indentation before the prefix @@ -507,23 +507,23 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, * Programmer: * Robb Matzke, Monday, April 26, 1999 * Modifications: - * Robb Matzke, 1999-06-04 - * The `container' argument is the optional dataset for reference types. + * Robb Matzke, 1999-06-04 + * The `container' argument is the optional dataset for reference types. * - * Robb Matzke, 1999-09-29 - * Understands the `per_line' property which indicates that every Nth - * element should begin a new line. + * Robb Matzke, 1999-09-29 + * Understands the `per_line' property which indicates that every Nth + * element should begin a new line. * * Robb Matzke, LLNL, 2003-06-05 * Do not dereference the memory for a variable-length string here. * Deref in h5tools_str_sprint() instead so recursive types are * handled correctly. - * - * Pedro Vicente Nunes, THG, 2005-10-19 + * + * Pedro Vicente Nunes, THG, 2005-10-19 * pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - * new field sm_pos in h5tools_context_t, the current stripmine element position + * instead of the current stripmine position i; this is necessary + * to print the array indices + * new field sm_pos in h5tools_context_t, the current stripmine element position *------------------------------------------------------------------------- */ void @@ -531,15 +531,15 @@ 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) { - unsigned char *mem = (unsigned char*)_mem; - hsize_t i; /*element counter */ - char *s, *section; /*a section of output */ - int secnum; /*section sequence number */ - size_t size; /*size of each datum */ - size_t ncols = 80; /*available output width */ - h5tools_str_t buffer; /*string into which to render */ - int multiline; /*datum was multiline */ - hsize_t curr_pos; /* total data element position */ + unsigned char *mem = (unsigned char*)_mem; + hsize_t i; /*element counter */ + char *s, *section; /*a section of output */ + int secnum; /*section sequence number */ + size_t size; /*size of each datum */ + size_t ncols = 80; /*available output width */ + h5tools_str_t buffer; /*string into which to render */ + int multiline; /*datum was multiline */ + hsize_t curr_pos; /* total data element position */ int elmt_counter = 0;/*counts the # elements printed. *I (ptl?) needed something that *isn't going to get reset when a new @@ -553,7 +553,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai size = H5Tget_size(type); if (info->line_ncols > 0) - ncols = info->line_ncols; + ncols = info->line_ncols; /* pass to the prefix in h5tools_simple_prefix the total position instead of the current stripmine position i; this is necessary @@ -664,8 +664,8 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai multiline++; /* pass to the prefix in h5tools_simple_prefix the total position - instead of the current stripmine position i; this is necessary - to print the array indices */ + instead of the current stripmine position i; this is necessary + to print the array indices */ curr_pos = ctx->sm_pos + i; h5tools_simple_prefix(stream, info, ctx, curr_pos, secnum); @@ -705,22 +705,22 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset int indentlevel) { herr_t ret; /*the value to return */ - hid_t f_space; /*file data space */ - int i, j; /*counters */ - hsize_t zero = 0; /*vector of zeros */ - unsigned int flags; /*buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ + hid_t f_space; /*file data space */ + int i, j; /*counters */ + hsize_t zero = 0; /*vector of zeros */ + unsigned int flags; /*buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ /* Print info */ - h5tools_context_t ctx; /*print context */ - size_t p_type_nbytes; /*size of memory type */ + h5tools_context_t ctx; /*print context */ + size_t p_type_nbytes; /*size of memory type */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ - unsigned char *sm_buf = NULL; /*buffer for raw data */ - hid_t sm_space; /*stripmine data space */ + hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ + hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nelmts; /*elements per stripmine*/ + unsigned char *sm_buf = NULL; /*buffer for raw data */ + hid_t sm_space; /*stripmine data space */ hsize_t count; @@ -871,7 +871,7 @@ done: /*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library - * Purpose: Print some values from a dataset with a simple data space. + * Purpose: Print some values from a dataset with a simple data space. * Description: * This is a special case of h5tools_dump_dset(). This function only * intended for dumping datasets -- it does strip mining and some other @@ -890,30 +890,30 @@ static int h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t p_type, int indentlevel) { - hid_t f_space; /*file data space */ - hsize_t elmtno; /*counter */ - int i; /*counter */ - int carry; /*counter carry value */ - hsize_t zero[8]; /*vector of zeros */ - unsigned int flags; /*buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ + hid_t f_space; /*file data space */ + hsize_t elmtno; /*counter */ + int i; /*counter */ + int carry; /*counter carry value */ + hsize_t zero[8]; /*vector of zeros */ + unsigned int flags; /*buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ /* Print info */ - h5tools_context_t ctx; /*print context */ - size_t p_type_nbytes; /*size of memory type */ - hsize_t p_nelmts; /*total selected elmts */ + h5tools_context_t ctx; /*print context */ + size_t p_type_nbytes; /*size of memory type */ + hsize_t p_nelmts; /*total selected elmts */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ - unsigned char *sm_buf = NULL; /*buffer for raw data */ - hid_t sm_space; /*stripmine data space */ + hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ + hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nelmts; /*elements per stripmine*/ + unsigned char *sm_buf = NULL; /*buffer for raw data */ + hid_t sm_space; /*stripmine data space */ /* Hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ - hsize_t hs_nelmts; /*elements in request */ + hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ + hsize_t hs_nelmts; /*elements in request */ /* VL data special information */ unsigned int vl_data = 0; /*contains VL datatypes */ @@ -1065,16 +1065,16 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, } /*------------------------------------------------------------------------- - * Function: h5tools_dump_simple_mem + * Function: h5tools_dump_simple_mem * - * Purpose: Print some values from memory with a simple data space. - * This is a special case of h5tools_dump_mem(). + * Purpose: Print some values from memory with a simple data space. + * This is a special case of h5tools_dump_mem(). * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: @@ -1085,9 +1085,9 @@ static int h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel) { - int i; /*counters */ - hsize_t nelmts; /*total selected elmts */ - h5tools_context_t ctx; /*printing context */ + int i; /*counters */ + hsize_t nelmts; /*total selected elmts */ + h5tools_context_t ctx; /*printing context */ /* * Check that everything looks okay. The dimensionality must not be too @@ -1139,34 +1139,34 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, } /*------------------------------------------------------------------------- - * Function: h5tools_dump_dset + * Function: h5tools_dump_dset * - * Purpose: Print some values from a dataset DSET to the file STREAM - * after converting all types to P_TYPE (which should be a - * native type). If P_TYPE is a negative value then it will be - * computed from the dataset type using only native types. + * Purpose: Print some values from a dataset DSET to the file STREAM + * after converting all types to P_TYPE (which should be a + * native type). If P_TYPE is a negative value then it will be + * computed from the dataset type using only native types. * - * Note: This function is intended only for datasets since it does - * some things like strip mining which are unnecessary for - * smaller objects such as attributes. The easiest way to print - * small objects is to read the object into memory and call - * h5tools_dump_mem(). + * Note: This function is intended only for datasets since it does + * some things like strip mining which are unnecessary for + * smaller objects such as attributes. The easiest way to print + * small objects is to read the object into memory and call + * h5tools_dump_mem(). * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: - * Robb Matzke, 1999-06-07 - * If info->raw is set then the memory datatype will be the same - * as the file datatype. + * Robb Matzke, 1999-06-07 + * If info->raw is set then the memory datatype will be the same + * as the file datatype. * - * Bill Wendling, 2001-02-27 - * Renamed to ``h5tools_dump_dset'' and added the subsetting - * parameter. + * Bill Wendling, 2001-02-27 + * Renamed to ``h5tools_dump_dset'' and added the subsetting + * parameter. * *------------------------------------------------------------------------- */ @@ -1231,17 +1231,17 @@ done: } /*------------------------------------------------------------------------- - * Function: h5tools_dump_mem + * Function: h5tools_dump_mem * - * Purpose: Displays the data contained in MEM. MEM must have the - * specified data TYPE and SPACE. Currently only simple data - * spaces are allowed and only the `all' selection. + * Purpose: Displays the data contained in MEM. MEM must have the + * specified data TYPE and SPACE. Currently only simple data + * spaces are allowed and only the `all' selection. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, January 20, 1999 * * Modifications: @@ -1256,16 +1256,16 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t /* Use default values */ if (!stream) - stream = stdout; + stream = stdout; if (!info) { - memset(&info_dflt, 0, sizeof(info_dflt)); - info = &info_dflt; + memset(&info_dflt, 0, sizeof(info_dflt)); + info = &info_dflt; } /* Check the data space */ if (H5Sis_simple(space) <= 0) - return -1; + return -1; return h5tools_dump_simple_mem(stream, info, obj_id, type, space, mem, indentlevel); @@ -1284,7 +1284,7 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t * *------------------------------------------------------------------------- */ -void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) +void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) { int i; diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 7dba8f5..bbb4d40 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -27,8 +27,8 @@ #define ESCAPE_HTML 1 #define OPT(X,S) ((X) ? (X) : (S)) #define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */ -#define START_OF_DATA 0x0001 -#define END_OF_DATA 0x0002 +#define START_OF_DATA 0x0001 +#define END_OF_DATA 0x0002 /* * The output functions need a temporary buffer to hold a piece of the @@ -402,5 +402,5 @@ extern int h5tools_can_encode(H5Z_filter_t filtn); void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); -#endif /* H5TOOLS_H__ */ +#endif /* H5TOOLS_H__ */ diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 907448d..7966f04 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -93,7 +93,7 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr return 0; /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE 1 , deflation like gzip + * H5Z_FILTER_DEFLATE 1 , deflation like gzip *------------------------------------------------------------------------- */ case H5Z_FILTER_DEFLATE: @@ -186,7 +186,7 @@ int h5tools_can_encode( H5Z_filter_t filtn) switch (filtn) { - /* user defined filter */ + /* user defined filter */ default: return 0; diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index d136fa2..ab893f3 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -75,15 +75,15 @@ init_ref_path_table(hid_t fid) /* Create skip list to store reference path information */ if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) - return (-1); + return (-1); if((root_path = HDstrdup("/")) == NULL) - return (-1); + return (-1); if(H5Gget_objinfo(fid, "/", TRUE, &sb)<0) { - /* fatal error? */ - HDfree(root_path); - return (-1); + /* fatal error? */ + HDfree(root_path); + return (-1); } /* Insert into table (takes ownership of path) */ @@ -164,8 +164,8 @@ ref_path_table_lookup(const char *thepath) /* Get object ID for object at path */ if(H5Gget_objinfo(thefile, thepath, TRUE, &sb)<0) - /* fatal error ? */ - return HADDR_UNDEF; + /* fatal error ? */ + return HADDR_UNDEF; /* Return OID or HADDR_UNDEF */ objno = ((haddr_t)sb.objno[1] << (8*sizeof(long))) | (haddr_t)sb.objno[0]; @@ -300,10 +300,10 @@ lookup_ref_path(haddr_t ref) { uint8_t *p; /* Pointer to reference to translate */ haddr_t addr; /* Resulting address */ - unsigned i; /* Local index variable */ - haddr_t tmp; /* Temporary portion of address */ - uint8_t c; /* Byte from address */ - hbool_t all_zero = TRUE; /* If the address is all zeros, make into HADDR_UNDEF */ + unsigned i; /* Local index variable */ + haddr_t tmp; /* Temporary portion of address */ + uint8_t c; /* Byte from address */ + hbool_t all_zero = TRUE; /* If the address is all zeros, make into HADDR_UNDEF */ ref_path_node_t *node; /* Ref path node found for address */ /* Be safer for h5ls */ @@ -315,17 +315,17 @@ lookup_ref_path(haddr_t ref) addr = 0; for (i=0; is || str->nalloc <= 0) { - str->nalloc = STR_INIT_LEN; - str->s = malloc(str->nalloc); - assert(str->s); - str->s[0] = '\0'; - str->len = 0; + str->nalloc = STR_INIT_LEN; + str->s = malloc(str->nalloc); + assert(str->s); + str->s[0] = '\0'; + str->len = 0; } if (strlen(fmt) == 0) { @@ -143,37 +143,37 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) /* Format the arguments and append to the value already in `str' */ while (1) { /* How many bytes available for new value, counting the new NUL */ - size_t avail = str->nalloc - str->len; + size_t avail = str->nalloc - str->len; - int nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap); + int nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap); - if (nchars<0) { + if (nchars<0) { /* failure, such as bad format */ va_end(ap); - return NULL; + return NULL; } - if ((size_t)nchars>=avail || - (0==nchars && (strcmp(fmt,"%s") ))) { - /* Truncation return value as documented by C99, or zero return value with either of the + if ((size_t)nchars>=avail || + (0==nchars && (strcmp(fmt,"%s") ))) { + /* Truncation return value as documented by C99, or zero return value with either of the * following conditions, each of which indicates that the proper C99 return value probably * should have been positive when the format string is * something other than "%s" * Alocate at least twice as much space and try again. */ - size_t newsize = MAX(str->len+nchars+1, 2*str->nalloc); - assert(newsize > str->nalloc); /*overflow*/ + size_t newsize = MAX(str->len+nchars+1, 2*str->nalloc); + assert(newsize > str->nalloc); /*overflow*/ #ifndef H5_HAVE_VSNPRINTF - /* If we even made it this far... the HDvsnprintf() clobbered memory: SIGSEGV probable*/ - abort(); + /* If we even made it this far... the HDvsnprintf() clobbered memory: SIGSEGV probable*/ + abort(); #endif - str->s = realloc(str->s, newsize); - assert(str->s); - str->nalloc = newsize; - } else { - /* Success */ - str->len += nchars; - break; + str->s = realloc(str->s, newsize); + assert(str->s); + str->nalloc = newsize; + } else { + /* Success */ + str->len += nchars; + break; } } va_end(ap); @@ -181,17 +181,17 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) } /*------------------------------------------------------------------------- - * Function: h5tools_str_reset + * Function: h5tools_str_reset * - * Purpose: Reset the string to the empty value. If no memory is - * allocated yet then initialize the h5tools_str_t struct. + * Purpose: Reset the string to the empty value. If no memory is + * allocated yet then initialize the h5tools_str_t struct. * - * Return: Success: Ptr to the buffer which contains a null - * character as the first element. + * Return: Success: Ptr to the buffer which contains a null + * character as the first element. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -202,9 +202,9 @@ char * h5tools_str_reset(h5tools_str_t *str/*in,out*/) { if (!str->s || str->nalloc <= 0) { - str->nalloc = STR_INIT_LEN; - str->s = malloc(str->nalloc); - assert(str->s); + str->nalloc = STR_INIT_LEN; + str->s = malloc(str->nalloc); + assert(str->s); } str->s[0] = '\0'; @@ -213,15 +213,15 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/) } /*------------------------------------------------------------------------- - * Function: h5tools_str_trunc + * Function: h5tools_str_trunc * - * Purpose: Truncate a string to be at most SIZE characters. + * Purpose: Truncate a string to be at most SIZE characters. * - * Return: Success: Pointer to the string + * Return: Success: Pointer to the string * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -232,27 +232,27 @@ char * h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size) { if (size < str->len) { - str->len = size; - str->s[size] = '\0'; + str->len = size; + str->s[size] = '\0'; } return str->s; } /*------------------------------------------------------------------------- - * Function: h5tools_str_fmt + * Function: h5tools_str_fmt * - * Purpose: Reformat a string contents beginning at character START - * according to printf format FMT. FMT should contain no format - * specifiers except possibly the `%s' variety. For example, if - * the input string is `hello' and the format is "<<%s>>" then - * the output value will be "<>". + * Purpose: Reformat a string contents beginning at character START + * according to printf format FMT. FMT should contain no format + * specifiers except possibly the `%s' variety. For example, if + * the input string is `hello' and the format is "<<%s>>" then + * the output value will be "<>". * - * Return: Success: A pointer to the resulting string. + * Return: Success: A pointer to the resulting string. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -293,15 +293,15 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) } /*------------------------------------------------------------------------- - * Function: h5tools_str_prefix + * Function: h5tools_str_prefix * - * Purpose: Renders the line prefix value into string STR. + * Purpose: Renders the line prefix value into string STR. * - * Return: Success: Pointer to the prefix. + * Return: Success: Pointer to the prefix. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: @@ -352,16 +352,16 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Function: h5tools_str_dump_region + * Function: h5tools_str_dump_region * - * Purpose: Prints information about a dataspace region by appending - * the information to the specified string. + * Purpose: Prints information about a dataspace region by appending + * the information to the specified string. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, June 7, 1999 * * Modifications: @@ -371,10 +371,10 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, int h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t *info) { - hssize_t nblocks, npoints; + hssize_t nblocks, npoints; hsize_t alloc_size; hsize_t *ptdata; - int ndims = H5Sget_simple_extent_ndims(region); + int ndims = H5Sget_simple_extent_ndims(region); /* * These two functions fail if the region does not have blocks or points, @@ -452,13 +452,13 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t } /*------------------------------------------------------------------------- - * Function: h5tools_print_char + * Function: h5tools_print_char * - * Purpose: Shove a character into the STR. + * Purpose: Shove a character into the STR. * - * Return: Nothing + * Return: Nothing * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Tuesday, 20. February 2001 * * Modifications: @@ -534,28 +534,28 @@ h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned cha /*------------------------------------------------------------------------- - * Function: h5tools_str_sprint + * Function: h5tools_str_sprint * - * Purpose: Renders the value pointed to by VP of type TYPE into variable - * length string STR. + * Purpose: Renders the value pointed to by VP of type TYPE into variable + * length string STR. * - * Return: A pointer to memory containing the result or NULL on error. + * Return: A pointer to memory containing the result or NULL on error. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: - * Robb Matzke, 1999-04-26 - * Made this function safe from overflow problems by allowing it - * to reallocate the output string. + * Robb Matzke, 1999-04-26 + * Made this function safe from overflow problems by allowing it + * to reallocate the output string. * - * Robb Matzke, 1999-06-04 - * Added support for object references. The new `container' - * argument is the dataset where the reference came from. + * Robb Matzke, 1999-06-04 + * Added support for object references. The new `container' + * argument is the dataset where the reference came from. * - * Robb Matzke, 1999-06-07 - * Added support for printing raw data. If info->raw is non-zero - * then data is printed in hexadecimal format. + * Robb Matzke, 1999-06-07 + * Added support for printing raw data. If info->raw is non-zero + * then data is printed in hexadecimal format. * * Robb Matzke, 2003-01-10 * Binary output format is dd:dd:... instead of 0xdddd... so it @@ -578,7 +578,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai char *cp_vp = (char *)vp; hid_t memb, obj, region; unsigned nmembs; - int otype; + int otype; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; H5G_stat_t sb; @@ -898,7 +898,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } } else if (H5Tget_class(type) == H5T_ARRAY) { int k, ndims; - hsize_t i, dims[H5S_MAX_RANK],temp_nelmts; + hsize_t i, dims[H5S_MAX_RANK],temp_nelmts; /* Get the array's base datatype for each element */ memb = H5Tget_super(type); @@ -909,11 +909,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Calculate the number of array elements */ for (k = 0, nelmts = 1; k < ndims; k++){ - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - assert(temp_nelmts==(hsize_t)((size_t)temp_nelmts)); + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + assert(temp_nelmts==(hsize_t)((size_t)temp_nelmts)); nelmts = (size_t)temp_nelmts; - } + } /* Print the opening bracket */ h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); @@ -949,7 +949,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /* end for */ /* Print the closing bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); + h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); H5Tclose(memb); } else if (H5Tget_class(type) == H5T_VLEN) { unsigned int i; @@ -1012,18 +1012,18 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /*------------------------------------------------------------------------- - * Function: h5tools_escape + * Function: h5tools_escape * - * Purpose: Changes all "funny" characters in S into standard C escape - * sequences. + * Purpose: Changes all "funny" characters in S into standard C escape + * sequences. * - * Return: Success: S + * Return: Success: S * - * Failure: NULL if the buffer would overflow. The - * buffer has as many left-to-right escapes as - * possible before overflow would have happened. + * Failure: NULL if the buffer would overflow. The + * buffer has as many left-to-right escapes as + * possible before overflow would have happened. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -1039,76 +1039,76 @@ h5tools_escape(char *s/*in,out*/, size_t size) char octal[8]; for (i = 0; i < n; i++) { - switch (s[i]) { - case '\'': - escape = "\\\'"; - break; - case '\"': - escape = "\\\""; - break; - case '\\': - escape = "\\\\"; - break; - case '\?': - escape = "\\\?"; - break; - case '\a': - escape = "\\a"; - break; - case '\b': - escape = "\\b"; - break; - case '\f': - escape = "\\f"; - break; - case '\n': - escape = "\\n"; - break; - case '\r': - escape = "\\r"; - break; - case '\t': - escape = "\\t"; - break; - case '\v': - escape = "\\v"; - break; - default: - if (!isprint(s[i])) { - sprintf(octal, "\\%03o", (unsigned char)s[i]); - escape = octal; - } else { - escape = NULL; - } - - break; - } - - if (escape) { - size_t esc_size = strlen(escape); - - if (n + esc_size + 1 > size) - /*would overflow*/ - return NULL; - - memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ - memcpy(s + i, escape, esc_size); /*insert*/ - n += esc_size - 1; /* adjust total string size */ - i += esc_size; /* adjust string position */ - } + switch (s[i]) { + case '\'': + escape = "\\\'"; + break; + case '\"': + escape = "\\\""; + break; + case '\\': + escape = "\\\\"; + break; + case '\?': + escape = "\\\?"; + break; + case '\a': + escape = "\\a"; + break; + case '\b': + escape = "\\b"; + break; + case '\f': + escape = "\\f"; + break; + case '\n': + escape = "\\n"; + break; + case '\r': + escape = "\\r"; + break; + case '\t': + escape = "\\t"; + break; + case '\v': + escape = "\\v"; + break; + default: + if (!isprint(s[i])) { + sprintf(octal, "\\%03o", (unsigned char)s[i]); + escape = octal; + } else { + escape = NULL; + } + + break; + } + + if (escape) { + size_t esc_size = strlen(escape); + + if (n + esc_size + 1 > size) + /*would overflow*/ + return NULL; + + memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ + memcpy(s + i, escape, esc_size); /*insert*/ + n += esc_size - 1; /* adjust total string size */ + i += esc_size; /* adjust string position */ + } } return s; } /*------------------------------------------------------------------------- - * Function: h5tools_is_zero + * Function: h5tools_is_zero * - * Purpose: Determines if memory is initialized to all zero bytes. + * Purpose: Determines if memory is initialized to all zero bytes. * - * Return: TRUE if all bytes are zero; FALSE otherwise + * Return: TRUE if all bytes are zero; FALSE otherwise * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, June 7, 1999 * * Modifications: @@ -1121,8 +1121,8 @@ h5tools_is_zero(const void *_mem, size_t size) const unsigned char *mem = (const unsigned char *)_mem; while (size-- > 0) - if (mem[size]) - return FALSE; + if (mem[size]) + return FALSE; return TRUE; } diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index c8874b3..1910bb5 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -21,9 +21,9 @@ #define H5TOOLS_STR_H__ typedef struct h5tools_str_t { - char *s; /*allocate string */ - size_t len; /*length of actual value */ - size_t nalloc; /*allocated size of string */ + char *s; /*allocate string */ + size_t len; /*length of actual value */ + size_t nalloc; /*allocated size of string */ } h5tools_str_t; extern void h5tools_str_close(h5tools_str_t *str); diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index 6306773..77e6af3 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -16,16 +16,16 @@ #include "h5tools.h" /*------------------------------------------------------------------------- - * Function: h5tools_get_native_type + * Function: h5tools_get_native_type * - * Purpose: Wrapper around H5Tget_native_type() to work around - * Problems with bitfields. + * Purpose: Wrapper around H5Tget_native_type() to work around + * Problems with bitfields. * - * Return: Success: datatype ID + * Return: Success: datatype ID * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 5, 2004 * * Modifications: diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 52d938e..33718c8 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -50,14 +50,14 @@ static herr_t find_objs_cb(hid_t group, const char *name, void *op_data); /*------------------------------------------------------------------------- - * Function: error_msg + * Function: error_msg * - * Purpose: Print a nicely formatted error message to stderr flushing the + * Purpose: Print a nicely formatted error message to stderr flushing the * stdout stream first. * - * Return: Nothing + * Return: Nothing * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Tuesday, 20. February 2001 * * Modifications: @@ -79,14 +79,14 @@ error_msg(const char *progname, const char *fmt, ...) /*------------------------------------------------------------------------- - * Function: warn_msg + * Function: warn_msg * - * Purpose: Print a nicely formatted warning message to stderr flushing + * Purpose: Print a nicely formatted warning message to stderr flushing * the stdout stream first. * - * Return: Nothing + * Return: Nothing * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Tuesday, 20. February 2001 * * Modifications: @@ -112,18 +112,18 @@ warn_msg(const char *progname, const char *fmt, ...) /*------------------------------------------------------------------------- - * Function: get_option + * Function: get_option * - * Purpose: Determine the command-line options a user specified. We can - * accept both short and long type command-lines. + * Purpose: Determine the command-line options a user specified. We can + * accept both short and long type command-lines. * - * Return: Success: The short valued "name" of the command line - * parameter or EOF if there are no more - * parameters to process. + * Return: Success: The short valued "name" of the command line + * parameter or EOF if there are no more + * parameters to process. * - * Failure: A question mark. + * Failure: A question mark. * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Friday, 5. January 2001 * * Modifications: @@ -283,7 +283,7 @@ indentation(int x) * Function: print_version * * Purpose: Print the program name and the version information which is - * defined the same as the HDF5 library version. + * defined the same as the HDF5 library version. * * Return: void * @@ -378,9 +378,9 @@ dump_table(char* tablename, table_t *table) printf("%s: # of entries = %d\n", tablename,table->nobjs); for (u = 0; u < table->nobjs; u++) - HDfprintf(stdout,"%a %s %d %d\n", table->objs[u].objno, - table->objs[u].objname, - table->objs[u].displayed, table->objs[u].recorded); + HDfprintf(stdout,"%a %s %d %d\n", table->objs[u].objno, + table->objs[u].objname, + table->objs[u].displayed, table->objs[u].recorded); } @@ -430,7 +430,7 @@ search_obj(table_t *table, unsigned long *_objno) for (u = 0; u < table->nobjs; u++) if (table->objs[u].objno == objno) - return &(table->objs[u]); + return &(table->objs[u]); return NULL; } diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index 685a6e4..c8be65c 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -33,7 +33,7 @@ extern const char *opt_arg; /* flag argument (or value) */ enum { no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ + require_arg, /* requires an argument */ optional_arg /* argument is optional */ }; @@ -44,23 +44,23 @@ enum { * the option. The long options are specified in the following way: * * struct long_options foo[] = { - * { "filename", require_arg, 'f' }, - * { "append", no_arg, 'a' }, - * { "width", require_arg, 'w' }, - * { NULL, 0, 0 } + * { "filename", require_arg, 'f' }, + * { "append", no_arg, 'a' }, + * { "width", require_arg, 'w' }, + * { NULL, 0, 0 } * }; * * Long named options can have arguments specified as either: * - * ``--param=arg'' or ``--param arg'' + * ``--param=arg'' or ``--param arg'' * * Short named options can have arguments specified as either: * - * ``-w80'' or ``-w 80'' + * ``-w80'' or ``-w 80'' * * and can have more than one short named option specified at one time: * - * -aw80 + * -aw80 * * in which case those options which expect an argument need to come at the * end. @@ -116,4 +116,4 @@ extern herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table); extern obj_t *search_obj(table_t *temp, unsigned long *objno); -#endif /* H5TOOLS_UTILS_H__ */ +#endif /* H5TOOLS_UTILS_H__ */ -- cgit v0.12