summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5dump/h5dump.c')
-rw-r--r--tools/h5dump/h5dump.c104
1 files changed, 59 insertions, 45 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index b4a8728..b6e3856 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -25,6 +25,23 @@
/* module-scoped variables */
const char *progname = "h5dump";
+/* Macros for displaying objects */
+#define begin_obj(obj,name,begin) \
+ if (name) \
+ printf("%s \"%s\" %s\n", (obj), (name), (begin)); \
+ else \
+ printf("%s %s\n", (obj), (begin));
+
+#define end_obj(obj,end) \
+ if(HDstrlen(end)) { \
+ printf("%s", end); \
+ if(HDstrlen(obj)) \
+ printf(" "); \
+ } \
+ if(HDstrlen(obj)) \
+ printf("%s", obj); \
+ printf("\n");
+
/* 3 private values: can't be set, but can be read.
Note: these are defined in H5Zprivate, they are
duplicated here.
@@ -3542,7 +3559,7 @@ main(int argc, const char *argv[])
goto done;
}
- /* start to dump */
+ /* start to dump - display file header information */
if (!doxml) {
begin_obj(dump_header_format->filebegin, fname,
dump_header_format->fileblockbegin);
@@ -3550,40 +3567,39 @@ main(int argc, const char *argv[])
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",
- xml_dtd_uri);
- } else {
+ if (strcmp(xmlnsprefix,"") == 0) {
+ printf("<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 = strdup(xmlnsprefix);
- indx = strrchr(ns,(int)':');
- if (indx) *indx = '\0';
-
- printf("<%sHDF5-File xmlns:%s=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File\" "
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
- "xsi:schemaLocation=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5File "
- "http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns);
- }
+ char * ns;
+ char *indx;
+
+ ns = strdup(xmlnsprefix);
+ indx = strrchr(ns,(int)':');
+ if (indx) *indx = '\0';
+
+ printf("<%sHDF5-File xmlns:%s=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:schemaLocation=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5File "
+ "http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns);
+ }
} else {
- printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n",
- xml_dtd_uri);
- printf("<HDF5-File>\n");
+ printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n",
+ xml_dtd_uri);
+ printf("<HDF5-File>\n");
}
}
- if (!doxml)
- {
- if (display_fi)
- {
- dump_fcontents(fid);
- end_obj(dump_header_format->fileend,dump_header_format->fileblockend);
- goto done;
- }
+ if (!doxml) {
+ if (display_fi) {
+ dump_fcontents(fid);
+ end_obj(dump_header_format->fileend,dump_header_format->fileblockend);
+ goto done;
+ }
- if (display_bb)
- dump_fcpl(fid);
+ if (display_bb)
+ dump_fcpl(fid);
}
@@ -3866,7 +3882,7 @@ xml_escape_the_name(const char *str)
return HDstrdup(str);
cp = str;
- rcp = ncp = calloc((size_t)(len + extra + 1), sizeof(char));
+ rcp = ncp = HDmalloc(len + extra + 1);
if (!ncp)
return NULL; /* ?? */
@@ -4053,14 +4069,12 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* 'anonymous' NDT. Use it's object num.
as it's name. */
printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n",
- xmlnsprefix,
- dtxid);
+ xmlnsprefix, dtxid);
} else {
/* point to the NDT by name */
char *t_objname = xml_escape_the_name(type_table->objs[ret].objname);
printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n",
- xmlnsprefix,
- dtxid,t_objname);
+ xmlnsprefix, dtxid,t_objname);
free(t_objname);
}
free(dtxid);
@@ -4423,15 +4437,13 @@ xml_dump_datatype(hid_t type)
use it's object ref as its name
*/
printf("<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n",
- xmlnsprefix,
- dtxid);
+ xmlnsprefix, dtxid);
} else {
/* pointer to a named data type already in XML */
char *t_objname = xml_escape_the_name(type_table->objs[i].objname);
printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n",
- xmlnsprefix,
- dtxid,t_objname);
+ xmlnsprefix, dtxid,t_objname);
free(t_objname);
}
free(dtxid);
@@ -5081,7 +5093,6 @@ xml_print_refs(hid_t did, int source)
hid_t type, space;
char *buf;
hobj_ref_t *refbuf;
- char *path;
hsize_t ssiz;
hsize_t i;
@@ -5139,6 +5150,8 @@ xml_print_refs(hid_t did, int source)
ssiz = H5Sget_simple_extent_npoints(space);
for (i = 0; i < ssiz; i++) {
+ const char *path;
+
path = lookup_ref_path(*refbuf);
indentation(indent + COL);
@@ -5419,7 +5432,8 @@ check_filters(hid_t dcpl)
}
}
-static void xml_dump_fill_value(hid_t dcpl, hid_t type)
+static void
+xml_dump_fill_value(hid_t dcpl, hid_t type)
{
size_t sz;
size_t i;
@@ -5533,11 +5547,11 @@ char * name;
break;
}
}
- free(buf);
- indent -= COL;
- indentation(indent);
- printf("</%sData>\n",xmlnsprefix);
- indent -= COL;
+ free(buf);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sData>\n",xmlnsprefix);
+ indent -= COL;
}
/*-------------------------------------------------------------------------
* Function: xml_dump_group