summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dump.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-03-19 14:26:04 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-03-19 14:26:04 (GMT)
commit19206f5687a4366f077ae47ae8e206f4a972144f (patch)
tree1022864b6b9015dcb035f33775d3fb0da24cddf2 /tools/h5dump/h5dump.c
parentb1a2c642a7105d808f884a27111236dd77df3ce0 (diff)
downloadhdf5-19206f5687a4366f077ae47ae8e206f4a972144f.zip
hdf5-19206f5687a4366f077ae47ae8e206f4a972144f.tar.gz
hdf5-19206f5687a4366f077ae47ae8e206f4a972144f.tar.bz2
[svn-r22088] HDFFV-7957(7958): Correct use of ERROR_STACK for h5dump and tools.
Tested: local linux after week in trunk
Diffstat (limited to 'tools/h5dump/h5dump.c')
-rw-r--r--tools/h5dump/h5dump.c266
1 files changed, 135 insertions, 131 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 23c8ea9..650846a 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -231,7 +231,7 @@ static void
usage(const char *prog)
{
HDfflush(rawoutstream);
- HDfprintf(rawoutstream, "usage: %s [OPTIONS] file\n", prog);
+ HDfprintf(rawoutstream, "usage: %s [OPTIONS] files\n", prog);
HDfprintf(rawoutstream, " OPTIONS\n");
HDfprintf(rawoutstream, " -h, --help Print a usage message and exit\n");
HDfprintf(rawoutstream, " -n, --contents Print a list of the file contents and exit\n");
@@ -329,6 +329,10 @@ usage(const char *prog)
HDfprintf(rawoutstream, "\n");
HDfprintf(rawoutstream, " h5dump -d /dset -M 0,1,4,3 quux.h5\n");
HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " 5) Dataset foo in files multi1.h5 multi2.h5 multi3.h5\n");
+ HDfprintf(rawoutstream, "\n");
+ HDfprintf(rawoutstream, " h5dump -d /foo multi1.h5 multi2.h5 multi3.h5\n");
+ HDfprintf(rawoutstream, "\n");
}
@@ -1453,161 +1457,161 @@ main(int argc, const char *argv[])
while(opt_ind < argc) {
fname = HDstrdup(argv[opt_ind++]);
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
-
- if (fid < 0) {
- error_msg("unable to open file \"%s\"\n", fname);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
- /* allocate and initialize internal data structure */
- init_prefix(&prefix, prefix_len);
+ if (fid < 0) {
+ error_msg("unable to open file \"%s\"\n", fname);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
- /* Prepare to find objects that might be targets of a reference */
- fill_ref_path_table(fid);
+ /* allocate and initialize internal data structure */
+ init_prefix(&prefix, prefix_len);
- if(doxml) {
- /* initialize XML */
- /* reset prefix! */
- HDstrcpy(prefix, "");
+ /* Prepare to find objects that might be targets of a reference */
+ fill_ref_path_table(fid);
- /* make sure the URI is initialized to something */
- if (xml_dtd_uri == NULL) {
- if (useschema) {
- xml_dtd_uri = DEFAULT_XSD;
+ 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 {
- xml_dtd_uri = DEFAULT_DTD;
- xmlnsprefix = "";
- }
- }
- else {
- if (useschema && HDstrcmp(xmlnsprefix,"")) {
- error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
+ if (useschema && HDstrcmp(xmlnsprefix,"")) {
+ error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
}
}
- }
- /* Get object info for root group */
- if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) {
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
-
- /* Initialize object tables */
- if(table_list_add(fid, oi.fileno) < 0) {
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- group_table = table_list.tables[0].group_table;
- dset_table = table_list.tables[0].dset_table;
- type_table = table_list.tables[0].type_table;
-
- /* does there exist unamed committed datatype */
- for (u = 0; u < type_table->nobjs; u++)
- if (!type_table->objs[u].recorded) {
- unamedtype = 1;
- break;
- } /* end if */
+ /* Get object info for root group */
+ if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) {
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
- /* start to dump - display file header information */
- if (!doxml) {
- begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin);
- }
- else {
- HDfprintf(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ /* Initialize object tables */
+ if(table_list_add(fid, oi.fileno) < 0) {
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ group_table = table_list.tables[0].group_table;
+ dset_table = table_list.tables[0].dset_table;
+ type_table = table_list.tables[0].type_table;
+
+ /* does there exist unamed committed datatype */
+ for (u = 0; u < type_table->nobjs; u++)
+ if (!type_table->objs[u].recorded) {
+ unamedtype = 1;
+ break;
+ } /* end if */
+
+ /* start to dump - display file header information */
+ if (!doxml) {
+ begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin);
+ }
+ else {
+ HDfprintf(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- /* alternative first element, depending on schema or DTD. */
- if (useschema) {
- if (HDstrcmp(xmlnsprefix,"") == 0) {
- HDfprintf(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n",
- xml_dtd_uri);
+ /* alternative first element, depending on schema or DTD. */
+ if (useschema) {
+ if (HDstrcmp(xmlnsprefix,"") == 0) {
+ HDfprintf(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n",
+ xml_dtd_uri);
+ }
+ else {
+ /* TO DO: make -url option work in this case (may need new option) */
+ char *ns;
+ char *indx;
+
+ ns = HDstrdup(xmlnsprefix);
+ indx = HDstrrchr(ns,(int)':');
+ if (indx) *indx = '\0';
+
+ HDfprintf(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File "
+ "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns);
+ HDfree(ns);
+ }
}
else {
-/* TO DO: make -url option work in this case (may need new option) */
- char *ns;
- char *indx;
-
- ns = HDstrdup(xmlnsprefix);
- indx = HDstrrchr(ns,(int)':');
- if (indx) *indx = '\0';
-
- HDfprintf(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File\" "
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
- "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File "
- "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns);
- HDfree(ns);
+ HDfprintf(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri);
+ HDfprintf(rawoutstream, "<HDF5-File>\n");
}
- }
- else {
- HDfprintf(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri);
- HDfprintf(rawoutstream, "<HDF5-File>\n");
}
- }
- if (!doxml) {
- if (display_fi) {
- HDfprintf(rawoutstream, "\n");
- dump_fcontents(fid);
- end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend);
- HDfprintf(rawoutstream, "\n");
- goto done;
+ if (!doxml) {
+ if (display_fi) {
+ HDfprintf(rawoutstream, "\n");
+ dump_fcontents(fid);
+ end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend);
+ HDfprintf(rawoutstream, "\n");
+ goto done;
+ }
+
+ if (display_bb)
+ dump_fcpl(fid);
}
- if (display_bb)
- dump_fcpl(fid);
- }
+ if(display_all) {
+ if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
+ error_msg("unable to open root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ else {
+ if (!doxml)
+ dump_indent += COL;
+ dump_function_table->dump_group_function(gid, "/" );
+ if (!doxml)
+ dump_indent -= COL;
+ HDfprintf(rawoutstream, "\n");
+ }
- if(display_all) {
- if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
- error_msg("unable to open root group\n");
- h5tools_setstatus(EXIT_FAILURE);
- }
- else {
- if (!doxml)
- dump_indent += COL;
- dump_function_table->dump_group_function(gid, "/" );
- if (!doxml)
- dump_indent -= COL;
- HDfprintf(rawoutstream, "\n");
- }
+ if(H5Gclose(gid) < 0) {
+ error_msg("unable to close root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
- if(H5Gclose(gid) < 0) {
- error_msg("unable to close root group\n");
- h5tools_setstatus(EXIT_FAILURE);
}
+ else {
+ /* Note: this option is not supported for XML */
+ if(doxml) {
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ } /* end if */
- }
- else {
- /* Note: this option is not supported for XML */
- if(doxml) {
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- } /* end if */
-
- for(i = 0; i < argc; i++) {
- if(hand[i].func) {
- hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL);
+ for(i = 0; i < argc; i++) {
+ if(hand[i].func) {
+ hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL);
+ }
}
+ HDfprintf(rawoutstream, "\n");
}
- HDfprintf(rawoutstream, "\n");
- }
- if (!doxml) {
- end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
- HDfprintf(rawoutstream, "\n");
- }
- else {
- HDfprintf(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix);
- }
- /* Free tables for objects */
- table_list_free();
+ if (!doxml) {
+ end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
+ HDfprintf(rawoutstream, "\n");
+ }
+ else {
+ HDfprintf(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix);
+ }
+ /* Free tables for objects */
+ table_list_free();
if(fid >=0)
if (H5Fclose(fid) < 0)