summaryrefslogtreecommitdiffstats
path: root/tools/src/h5dump
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-04-21 18:36:10 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-04-21 18:36:10 (GMT)
commit8cd9d8349e5984d8a6f78c9c0c1bb566a9960b23 (patch)
tree5c5dce61c112c4f31ec0bfb5b65b00f2157269a7 /tools/src/h5dump
parentc6097935d5be4c3750b9bf9167783ad28158905b (diff)
downloadhdf5-8cd9d8349e5984d8a6f78c9c0c1bb566a9960b23.zip
hdf5-8cd9d8349e5984d8a6f78c9c0c1bb566a9960b23.tar.gz
hdf5-8cd9d8349e5984d8a6f78c9c0c1bb566a9960b23.tar.bz2
Added VOL command-line options to (p)h5diff, h5ls, h5dump, and h5mkgrp.
Diffstat (limited to 'tools/src/h5dump')
-rw-r--r--tools/src/h5dump/h5dump.c128
-rw-r--r--tools/src/h5dump/h5dump.h1
2 files changed, 83 insertions, 46 deletions
diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c
index d292b75..dfaff17 100644
--- a/tools/src/h5dump/h5dump.c
+++ b/tools/src/h5dump/h5dump.c
@@ -18,15 +18,18 @@
/* Name of tool */
#define PROGRAMNAME "h5dump"
-static const char *driver = NULL; /* The driver to open the file with. */
-const char *outfname=NULL;
-static int doxml = 0;
-static int useschema = 1;
-static const char *xml_dtd_uri = NULL;
+static const char *driver_name_g = NULL; /* The driver to open the file with. */
+const char *outfname_g = NULL;
+static hbool_t doxml_g = FALSE;
+static hbool_t useschema_g = TRUE;
+static const char *xml_dtd_uri_g = NULL;
+
+static hbool_t use_custom_vol_g = FALSE;
+static h5tools_vol_info_t vol_info_g;
#ifdef H5_HAVE_ROS3_VFD
/* Default "anonymous" S3 configuration */
-static H5FD_ros3_fapl_t ros3_fa = {
+static H5FD_ros3_fapl_t ros3_fa_g = {
1, /* Structure Version */
false, /* Authenticate? */
"", /* AWS Region */
@@ -37,7 +40,7 @@ static H5FD_ros3_fapl_t ros3_fa = {
#ifdef H5_HAVE_LIBHDFS
/* "Default" HDFS configuration */
-static H5FD_hdfs_fapl_t hdfs_fa = {
+static H5FD_hdfs_fapl_t hdfs_fa_g = {
1, /* Structure Version */
"localhost", /* Namenode Name */
0, /* Namenode Port */
@@ -213,6 +216,9 @@ static struct long_options l_opts[] = {
{ "vds-gap-size", require_arg, 'G' },
{ "s3-cred", require_arg, '$' },
{ "hdfs-attrs", require_arg, '#' },
+ { "vol-value", require_arg, '1' },
+ { "vol-name", require_arg, '2' },
+ { "vol-info", require_arg, '3' },
{ NULL, 0, '\0' }
};
@@ -270,6 +276,12 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, " <kerberos cache path>,<username>,\n");
PRINTVALSTREAM(rawoutstream, " <buffer size>)\n");
PRINTVALSTREAM(rawoutstream, " Any absent attribute will use a default value.\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n");
PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n");
PRINTVALSTREAM(rawoutstream, " If an attribute name contains a slash (/), escape the\n");
@@ -863,7 +875,7 @@ parse_command_line(int argc, const char *argv[])
int opt;
int last_was_dset = FALSE;
- /* no arguments */
+ /* no arguments */
if (argc == 1) {
usage(h5tools_getprogname());
goto error;
@@ -981,7 +993,7 @@ parse_start:
last_was_dset = TRUE;
break;
case 'f':
- driver = opt_arg;
+ driver_name_g = opt_arg;
break;
case 'g':
display_all = 0;
@@ -1051,7 +1063,7 @@ parse_start:
usingdasho = TRUE;
last_was_dset = FALSE;
- outfname = opt_arg;
+ outfname_g = opt_arg;
break;
case 'b':
@@ -1063,8 +1075,8 @@ parse_start:
}
}
bin_output = TRUE;
- if (outfname!=NULL) {
- if (h5tools_set_data_output_file(outfname, 1) < 0) {
+ if (outfname_g != NULL) {
+ if (h5tools_set_data_output_file(outfname_g, 1) < 0) {
/* failed to set output file */
usage(h5tools_getprogname());
goto error;
@@ -1115,15 +1127,15 @@ parse_start:
/** begin XML parameters **/
case 'x':
/* select XML output */
- doxml = TRUE;
- useschema = TRUE;
+ doxml_g = TRUE;
+ useschema_g = TRUE;
h5tools_dump_header_format = NULL;
dump_function_table = &xml_function_table;
h5tools_nCols = 0;
break;
case 'u':
- doxml = TRUE;
- useschema = FALSE;
+ doxml_g = TRUE;
+ useschema_g = FALSE;
xmlnsprefix = "";
h5tools_dump_header_format = NULL;
dump_function_table = &xml_function_table;
@@ -1132,7 +1144,7 @@ parse_start:
case 'D':
/* specify alternative XML DTD or schema */
/* To Do: check format of this value? */
- xml_dtd_uri = opt_arg;
+ xml_dtd_uri_g = opt_arg;
h5tools_nCols = 0;
break;
@@ -1145,7 +1157,7 @@ parse_start:
case 'X':
/* specify XML namespace (default="hdf5:"), or none */
/* To Do: check format of this value? */
- if (!useschema) {
+ if (!useschema_g) {
usage(h5tools_getprogname());
goto error;
}
@@ -1254,7 +1266,7 @@ end_collect:
case '$':
#ifdef H5_HAVE_ROS3_VFD
- if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa) < 0) {
+ if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa_g) < 0) {
error_msg("failed to parse S3 VFD credential info\n");
usage(h5tools_getprogname());
free_handler(hand, argc);
@@ -1271,7 +1283,7 @@ end_collect:
case '#':
#ifdef H5_HAVE_LIBHDFS
- if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa) < 0) {
+ if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa_g) < 0) {
error_msg("failed to parse HDFS VFD configuration info\n");
usage(h5tools_getprogname());
free_handler(hand, argc);
@@ -1286,6 +1298,22 @@ end_collect:
#endif
break;
+ case '1':
+ vol_info_g.type = VOL_BY_VALUE;
+ vol_info_g.u.value = (H5VL_class_value_t)HDatoi(opt_arg);
+ use_custom_vol_g = TRUE;
+ break;
+
+ case '2':
+ vol_info_g.type = VOL_BY_NAME;
+ vol_info_g.u.name = opt_arg;
+ use_custom_vol_g = TRUE;
+ break;
+
+ case '3':
+ vol_info_g.info_string = opt_arg;
+ break;
+
case '?':
default:
usage(h5tools_getprogname());
@@ -1360,7 +1388,7 @@ main(int argc, const char *argv[])
goto done;
}
- if (bin_output && outfname == NULL) {
+ if (bin_output && outfname_g == NULL) {
error_msg("binary output requires a file name, use -o <filename>\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -1372,7 +1400,7 @@ main(int argc, const char *argv[])
}
/* Check for conflicting options */
- if (doxml) {
+ if (doxml_g) {
if (!display_all) {
error_msg("option \"%s\" not available for XML\n", "to display selected objects");
h5tools_setstatus(EXIT_FAILURE);
@@ -1400,8 +1428,8 @@ main(int argc, const char *argv[])
}
}
else {
- if (xml_dtd_uri) {
- warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri);
+ if (xml_dtd_uri_g) {
+ warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri_g);
}
}
@@ -1414,24 +1442,24 @@ main(int argc, const char *argv[])
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
- if (driver != NULL) {
+ if (driver_name_g != NULL) {
h5tools_vfd_info_t vfd_info;
vfd_info.info = NULL;
- vfd_info.name = driver;
+ vfd_info.name = driver_name_g;
- if (!HDstrcmp(driver, drivernames[ROS3_VFD_IDX])) {
+ if (!HDstrcmp(driver_name_g, drivernames[ROS3_VFD_IDX])) {
#ifdef H5_HAVE_ROS3_VFD
- vfd_info.info = (void *)&ros3_fa;
+ vfd_info.info = (void *)&ros3_fa_g;
#else
error_msg("Read-Only S3 VFD not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
#endif
}
- else if (!HDstrcmp(driver, drivernames[HDFS_VFD_IDX])) {
+ else if (!HDstrcmp(driver_name_g, drivernames[HDFS_VFD_IDX])) {
#ifdef H5_HAVE_LIBHDFS
- vfd_info.info = (void *)&hdfs_fa;
+ vfd_info.info = (void *)&hdfs_fa_g;
#else
error_msg("The HDFS VFD is not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
@@ -1444,7 +1472,15 @@ main(int argc, const char *argv[])
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- } /* driver defined */
+ } /* driver name defined */
+
+ if (use_custom_vol_g) {
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &vol_info_g, NULL)) < 0) {
+ error_msg("unable to create FAPL for file access\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
while(opt_ind < argc) {
fname = HDstrdup(argv[opt_ind++]);
@@ -1464,23 +1500,23 @@ main(int argc, const char *argv[])
/* Prepare to find objects that might be targets of a reference */
fill_ref_path_table(fid);
- if(doxml) {
+ if(doxml_g) {
/* 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;
+ if (xml_dtd_uri_g == NULL) {
+ if (useschema_g) {
+ xml_dtd_uri_g = DEFAULT_XSD;
}
else {
- xml_dtd_uri = DEFAULT_DTD;
+ xml_dtd_uri_g = DEFAULT_DTD;
xmlnsprefix = "";
}
}
else {
- if (useschema && HDstrcmp(xmlnsprefix,"")) {
+ if (useschema_g && 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;
@@ -1513,16 +1549,16 @@ main(int argc, const char *argv[])
} /* end if */
/* start to dump - display file header information */
- if (!doxml) {
+ if (!doxml_g) {
begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin);
}
else {
PRINTVALSTREAM(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
/* alternative first element, depending on schema or DTD. */
- if (useschema) {
+ if (useschema_g) {
if (HDstrcmp(xmlnsprefix,"") == 0) {
- PRINTSTREAM(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", xml_dtd_uri);
+ PRINTSTREAM(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", xml_dtd_uri_g);
}
else {
/* TO DO: make -url option work in this case (may need new option) */
@@ -1542,12 +1578,12 @@ main(int argc, const char *argv[])
}
}
else {
- PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri);
+ PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri_g);
PRINTVALSTREAM(rawoutstream, "<HDF5-File>\n");
}
}
- if (!doxml) {
+ if (!doxml_g) {
if (display_fi) {
PRINTVALSTREAM(rawoutstream, "\n");
dump_fcontents(fid);
@@ -1566,10 +1602,10 @@ main(int argc, const char *argv[])
h5tools_setstatus(EXIT_FAILURE);
}
else {
- if (!doxml)
+ if (!doxml_g)
dump_indent += COL;
dump_function_table->dump_group_function(gid, "/" );
- if (!doxml)
+ if (!doxml_g)
dump_indent -= COL;
PRINTVALSTREAM(rawoutstream, "\n");
}
@@ -1582,7 +1618,7 @@ main(int argc, const char *argv[])
}
else {
/* Note: this option is not supported for XML */
- if(doxml) {
+ if(doxml_g) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -1596,7 +1632,7 @@ main(int argc, const char *argv[])
PRINTVALSTREAM(rawoutstream, "\n");
}
- if (!doxml) {
+ if (!doxml_g) {
end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
PRINTVALSTREAM(rawoutstream, "\n");
}
diff --git a/tools/src/h5dump/h5dump.h b/tools/src/h5dump/h5dump.h
index 801f60d..ca1fef6 100644
--- a/tools/src/h5dump/h5dump.h
+++ b/tools/src/h5dump/h5dump.h
@@ -43,6 +43,7 @@ typedef struct h5dump_table_items_t {
table_t *dset_table; /* Table of datasets */
table_t *type_table; /* Table of datatypes */
} h5dump_table_items_t;
+
typedef struct h5dump_table_list_t {
size_t nalloc;
size_t nused;