diff options
Diffstat (limited to 'tools/h5dump/h5dump.c')
-rw-r--r-- | tools/h5dump/h5dump.c | 2332 |
1 files changed, 1166 insertions, 1166 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("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - /* alternative first element, depending on schema or DTD. */ + printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + /* alternative first element, depending on schema or DTD. */ if (useschema) { if (strcmp(xmlnsprefix,"") == 0) { printf("<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\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("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri); printf("<HDF5-File>\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("</%sHDF5-File>\n", xmlnsprefix); + printf("</%sHDF5-File>\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 <empty>", indent + 4, ""); + printf("\n%*s <empty>", 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("<!-- h5dump error: unknown committed type. -->\n"); - } - indent -= COL; - return; + printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n", + xmlnsprefix, dtxid,t_objname); + free(t_objname); + } + free(dtxid); + } else { + printf("<!-- h5dump error: unknown committed type. -->\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 */ - /* <hdf5:SimpleDataspace Ndims="nd"> */ - printf("<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); - - /* print the <hdf5:Dimension> 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("</%sSimpleDataspace>\n", xmlnsprefix ); + /* simple dataspace */ + /* <hdf5:SimpleDataspace Ndims="nd"> */ + printf("<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); + + /* print the <hdf5:Dimension> 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("</%sSimpleDataspace>\n", xmlnsprefix ); break; case H5S_COMPLEX: - printf("<!-- not yet implemented -->\n"); + printf("<!-- not yet implemented -->\n"); break; case H5S_NO_CLASS: default: - printf("<!-- unknown dataspace -->\n"); + printf("<!-- unknown dataspace -->\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("<!-- Time data not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("<hdf5:Data>\n"); - printf("</%sData>\n",xmlnsprefix); - indent -= COL; - break; - - case H5T_COMPOUND: - indentation(indent); - printf("<!-- Note: format of compound data not specified -->\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("<!-- Time data not yet implemented. -->\n"); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("<hdf5:Data>\n"); + printf("</%sData>\n",xmlnsprefix); + indent -= COL; + break; + + case H5T_COMPOUND: + indentation(indent); + printf("<!-- Note: format of compound data not specified -->\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("<!-- Note: Region references not supported -->\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(attr_id, ATTRIBUTE_DATA); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); + printf("<%sDataFromFile>\n",xmlnsprefix); + xml_print_refs(attr_id, ATTRIBUTE_DATA); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); } - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; - - case H5T_VLEN: - printf("<!-- Note: format of VL data not specified -->\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - default: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("</%sData>\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("</%sData>\n",xmlnsprefix); - } - - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr_id); - indentation(indent); - printf("</%sAttribute>\n", xmlnsprefix ); - return SUCCEED; + indentation(indent); + printf("</%sData>\n",xmlnsprefix); + break; + + case H5T_VLEN: + printf("<!-- Note: format of VL data not specified -->\n"); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + default: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("</%sData>\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("</%sData>\n",xmlnsprefix); + } + + H5Tclose(type); + H5Sclose(space); + H5Aclose(attr_id); + indentation(indent); + printf("</%sAttribute>\n", xmlnsprefix ); + return SUCCEED; } else { - /* ?? failed */ - indentation(indent + COL); - printf("<!-- h5dump error: unable to open attribute. -->\n"); - indentation(indent); - printf("</%sAttribute>\n", xmlnsprefix ); - d_status = EXIT_FAILURE; - return FAIL; + /* ?? failed */ + indentation(indent + COL); + printf("<!-- h5dump error: unable to open attribute. -->\n"); + indentation(indent); + printf("</%sAttribute>\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("</%sRootGroup>\n",xmlnsprefix); + printf("</%sRootGroup>\n",xmlnsprefix); } else { - printf("</%sGroup>\n" ,xmlnsprefix); + printf("</%sGroup>\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("</%sRequiredFilter>\n",xmlnsprefix); - - indent -= COL; - - indentation(indent); - printf("</%sChunkedLayout>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sStorageLayout>\n",xmlnsprefix); - indent -= COL; - free(chsize); + } + + indentation(indent); + printf("<%sRequiredFilter>\n",xmlnsprefix); + indent += COL; + check_filters(dcpl); + indent -= COL; + indentation(indent); + printf("</%sRequiredFilter>\n",xmlnsprefix); + + indent -= COL; + + indentation(indent); + printf("</%sChunkedLayout>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("</%sStorageLayout>\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("</%sStorageLayout>\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("</%sStorageLayout>\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("</%sStorageLayout>\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("</%sStorageLayout>\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("<!-- Time data not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indent -= COL; - break; - - case H5T_COMPOUND: - indentation(indent); - printf("<!-- Note: format of compound data not specified -->\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("<!-- Time data not yet implemented. -->\n"); + indentation(indent); + printf("<%sNoData />\n",xmlnsprefix); + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indent -= COL; + break; + + case H5T_COMPOUND: + indentation(indent); + printf("<!-- Note: format of compound data not specified -->\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("<!-- Note: Region references not supported -->\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(did, DATASET_DATA); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); + printf("<%sDataFromFile>\n",xmlnsprefix); + xml_print_refs(did, DATASET_DATA); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); } - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; - - case H5T_VLEN: - printf("<!-- Note: format of VL data not specified -->\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; - default: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; - } + indentation(indent); + printf("</%sData>\n",xmlnsprefix); + break; + + case H5T_VLEN: + printf("<!-- Note: format of VL data not specified -->\n"); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; + default: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("</%sData>\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("</%sData>\n",xmlnsprefix); + /* no data written */ + indentation(indent + COL); + printf("<%sData>\n",xmlnsprefix); + indentation(indent + COL + COL); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent + COL); + printf("</%sData>\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("</%sEnumElement>\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("</%sEnumValue>\n",xmlnsprefix); + indentation(indent); + printf("</%sEnumElement>\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("</%sEnumValue>\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<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - memb_fapl[mt] = H5P_DEFAULT; - sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10); - } - - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE)<0) { - return -1; - } + /* 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<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { + memb_fapl[mt] = H5P_DEFAULT; + sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); + memb_name[mt] = sv[mt]; + memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10); + } + + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, + memb_addr, FALSE)<0) { + return -1; + } } else if (!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ - /* Family of files, each 1MB and using the default driver */ - if ((val=HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) + /* Family of files, each 1MB and using the default driver */ + if ((val=HDstrtok(NULL, " \t\n\r"))) + fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); + if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; } else if (!HDstrcmp(name, "log")) { #ifdef H5_WANT_H5_V1_4_COMPAT @@ -5940,18 +5940,18 @@ h5_fileaccess(void) verbosity = strtol(val, NULL, 0); if (H5Pset_fapl_log(fapl, NULL, (int)verbosity) < 0) - return -1; + return -1; #else /* H5_WANT_H5_V1_4_COMPAT */ /* Log file access */ if ((val = HDstrtok(NULL, " \t\n\r"))) log_flags = HDstrtol(val, NULL, 0); if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0) - return -1; + return -1; #endif /* H5_WANT_H5_V1_4_COMPAT */ } else { - /* Unknown driver */ - return -1; + /* Unknown driver */ + return -1; } return fapl; |