summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-08-01 16:18:18 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-08-01 16:18:18 (GMT)
commit1ae6daaa807f2bfd63076215950d9c412bfa08d7 (patch)
treed60f5aa4158d275f953561b47089add1ea76ecd2 /tools/src
parent0a64f3e8106a1ced78ae7c4a6744b3509d7ca0fc (diff)
downloadhdf5-1ae6daaa807f2bfd63076215950d9c412bfa08d7.zip
hdf5-1ae6daaa807f2bfd63076215950d9c412bfa08d7.tar.gz
hdf5-1ae6daaa807f2bfd63076215950d9c412bfa08d7.tar.bz2
Sync with develop
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/h5copy/h5copy.c22
-rw-r--r--tools/src/h5diff/h5diff_common.c368
-rw-r--r--tools/src/h5diff/h5diff_main.c36
-rw-r--r--tools/src/h5dump/h5dump.c397
-rw-r--r--tools/src/h5dump/h5dump.h39
-rw-r--r--tools/src/h5dump/h5dump_ddl.c106
-rw-r--r--tools/src/h5dump/h5dump_extern.h43
-rw-r--r--tools/src/h5dump/h5dump_xml.c82
-rw-r--r--tools/src/h5format_convert/h5format_convert.c175
-rw-r--r--tools/src/h5import/h5import.c45
-rw-r--r--tools/src/h5jam/h5jam.c82
-rw-r--r--tools/src/h5jam/h5unjam.c20
-rw-r--r--tools/src/h5ls/h5ls.c609
-rw-r--r--tools/src/h5repack/h5repack.c9
-rw-r--r--tools/src/h5repack/h5repack.h4
-rw-r--r--tools/src/h5repack/h5repack_copy.c82
-rw-r--r--tools/src/h5repack/h5repack_main.c230
-rw-r--r--tools/src/h5repack/h5repack_verify.c22
-rw-r--r--tools/src/h5stat/h5stat.c214
-rw-r--r--tools/src/misc/h5clear.c9
-rw-r--r--tools/src/misc/h5debug.c403
-rw-r--r--tools/src/misc/h5mkgrp.c240
22 files changed, 1621 insertions, 1616 deletions
diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c
index e1370e2..5b19ae7 100644
--- a/tools/src/h5copy/h5copy.c
+++ b/tools/src/h5copy/h5copy.c
@@ -207,10 +207,6 @@ static int parse_flag(const char* s_flag, unsigned *flag)
int
main (int argc, const char *argv[])
{
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
hid_t fid_src = H5I_INVALID_HID;
hid_t fid_dst = H5I_INVALID_HID;
unsigned flag = 0;
@@ -226,17 +222,9 @@ main (int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
-
/* init linkinfo struct */
HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t));
@@ -330,10 +318,8 @@ main (int argc, const char *argv[])
leave(EXIT_FAILURE);
}
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
- }
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/*-------------------------------------------------------------------------
* open output file
@@ -342,13 +328,13 @@ main (int argc, const char *argv[])
/* Attempt to open an existing HDF5 file first. Need to open the dst file
before the src file just in case that the dst and src are the same file
*/
- fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0);
+ fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0);
/*-------------------------------------------------------------------------
* open input file
*-------------------------------------------------------------------------*/
- fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0);
+ fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, 0);
/*-------------------------------------------------------------------------
* test for error in opening input file
diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c
index 3b0fe1c..a02ad5a 100644
--- a/tools/src/h5diff/h5diff_common.c
+++ b/tools/src/h5diff/h5diff_common.c
@@ -25,7 +25,7 @@ static int check_d_input(const char*);
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "hVrv:qn:d:p:NcelxE:S";
+static const char *s_opts = "hVrv:qn:d:p:NcelxE:A:S";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "version", no_arg, 'V' },
@@ -41,7 +41,14 @@ static struct long_options l_opts[] = {
{ "follow-symlinks", no_arg, 'l' },
{ "no-dangling-links", no_arg, 'x' },
{ "exclude-path", require_arg, 'E' },
+ { "exclude-attribute", require_arg, 'A' },
{ "enable-error-stack", no_arg, 'S' },
+ { "vol-value-1", require_arg, '1' },
+ { "vol-name-1", require_arg, '2' },
+ { "vol-info-1", require_arg, '3' },
+ { "vol-value-2", require_arg, '4' },
+ { "vol-name-2", require_arg, '5' },
+ { "vol-info-2", require_arg, '6' },
{ NULL, 0, '\0' }
};
@@ -49,7 +56,6 @@ static struct long_options l_opts[] = {
* Function: check_options
*
* Purpose: parse command line input
- *
*-------------------------------------------------------------------------
*/
static void check_options(diff_opt_t* opts)
@@ -61,7 +67,7 @@ static void check_options(diff_opt_t* opts)
/* check between -d , -p, --use-system-epsilon.
* These options are mutually exclusive.
*/
- if ((opts->d + opts->p + opts->use_system_epsilon) > 1) {
+ if ((opts->delta_bool + opts->percent_bool + opts->use_system_epsilon) > 1) {
HDprintf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME);
HDprintf("use no more than one.\n");
HDprintf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 Reference Manual'.\n", PROGRAMNAME);
@@ -69,12 +75,127 @@ static void check_options(diff_opt_t* opts)
}
}
+/*-------------------------------------------------------------------------
+ * Function: parse_hsize_list
+ *
+ * Purpose: Parse a list of comma or space separated integers and return
+ * them in a list. The string being passed into this function
+ * should be at the start of the list you want to parse. You are
+ * responsible for freeing the array returned from here.
+ *
+ * Lists in the so-called "terse" syntax are separated by
+ * semicolons (;). The lists themselves can be separated by
+ * either commas (,) or white spaces.
+ *
+ * Return: <none>
+ *-------------------------------------------------------------------------
+ */
+static void
+parse_hsize_list(const char *h_list, subset_d *d)
+{
+ hsize_t *p_list;
+ const char *ptr;
+ unsigned int size_count = 0;
+ unsigned int i = 0;
+ unsigned int last_digit = 0;
+
+ if (!h_list || !*h_list || *h_list == ';')
+ return;
+
+ H5TOOLS_START_DEBUG(" - h_list:%s", h_list);
+ /* count how many integers do we have */
+ for (ptr = h_list; ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
+ if (HDisdigit(*ptr)) {
+ if (!last_digit)
+ /* the last read character wasn't a digit */
+ size_count++;
+
+ last_digit = 1;
+ }
+ else
+ last_digit = 0;
+
+ if (size_count == 0) {
+ /* there aren't any integers to read */
+ H5TOOLS_ENDDEBUG("No integers to read");
+ return;
+ }
+ H5TOOLS_DEBUG("Number integers to read=%ld", size_count);
+
+ /* allocate an array for the integers in the list */
+ if((p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t))) == NULL)
+ H5TOOLS_INFO("Unable to allocate space for subset data");
+
+ for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
+ if(HDisdigit(*ptr)) {
+ /* we should have an integer now */
+ p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0);
+
+ while (HDisdigit(*ptr))
+ /* scroll to end of integer */
+ ptr++;
+ }
+ d->data = p_list;
+ d->len = size_count;
+ H5TOOLS_ENDDEBUG("");
+}
+
+/*-------------------------------------------------------------------------
+ * Function: parse_subset_params
+ *
+ * Purpose: Parse the so-called "terse" syntax for specifying subsetting parameters.
+ *
+ * Return: Success: struct subset_t object
+ * Failure: NULL
+ *-------------------------------------------------------------------------
+ */
+static struct subset_t *
+parse_subset_params(const char *dset)
+{
+ struct subset_t *s = NULL;
+ char *brace;
+
+ H5TOOLS_START_DEBUG(" - dset:%s", dset);
+ if ((brace = HDstrrchr(dset, '[')) != NULL) {
+ *brace++ = '\0';
+
+ s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
+ parse_hsize_list(brace, &s->start);
+
+ while (*brace && *brace != ';')
+ brace++;
+
+ if (*brace)
+ brace++;
+
+ parse_hsize_list(brace, &s->stride);
+
+ while (*brace && *brace != ';')
+ brace++;
+
+ if (*brace)
+ brace++;
+
+ parse_hsize_list(brace, &s->count);
+
+ while (*brace && *brace != ';')
+ brace++;
+
+ if (*brace)
+ brace++;
+
+ parse_hsize_list(brace, &s->block);
+ }
+ H5TOOLS_ENDDEBUG("");
+
+ return s;
+}
+
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
* Purpose: parse command line input
- *
*-------------------------------------------------------------------------
*/
@@ -83,9 +204,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
int i;
int opt;
struct exclude_path_list *exclude_head, *exclude_prev, *exclude_node;
+ struct exclude_path_list *exclude_attr_head, *exclude_attr_prev, *exclude_attr_node;
+ H5TOOLS_START_DEBUG("");
/* process the command-line */
- memset(opts, 0, sizeof (diff_opt_t));
+ HDmemset(opts, 0, sizeof (diff_opt_t));
/* assume equal contents initially */
opts->contents = 1;
@@ -94,15 +217,18 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
opts->do_nans = 1;
/* not Listing objects that are not comparable */
- opts->m_list_not_cmp = 0;
+ opts->mode_list_not_cmp = 0;
/* initially no not-comparable. */
/**this is bad in mixing option with results**/
- opts->not_cmp=0;
+ opts->not_cmp = 0;
/* init for exclude-path option */
exclude_head = NULL;
+ /* init for exclude-attribute option */
+ exclude_attr_head = NULL;
+
/* parse command line options */
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
@@ -122,7 +248,7 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
break;
case 'v':
- opts->m_verbose = 1;
+ opts->mode_verbose = 1;
/* This for loop is for handling style like
* -v, -v1, --verbose, --verbose=1.
*/
@@ -132,11 +258,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
*/
if (!strcmp (argv[i], "-v")) { /* no arg */
opt_ind--;
- opts->m_verbose_level = 0;
+ opts->mode_verbose_level = 0;
break;
}
else if (!strncmp (argv[i], "-v", (size_t)2)) {
- opts->m_verbose_level = atoi(&argv[i][2]);
+ opts->mode_verbose_level = atoi(&argv[i][2]);
break;
}
@@ -144,11 +270,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
* long opt
*/
if (!strcmp (argv[i], "--verbose")) { /* no arg */
- opts->m_verbose_level = 0;
+ opts->mode_verbose_level = 0;
break;
}
- else if ( !strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') {
- opts->m_verbose_level = atoi(&argv[i][10]);
+ else if (!strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') {
+ opts->mode_verbose_level = atoi(&argv[i][10]);
break;
}
}
@@ -156,11 +282,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
case 'q':
/* use quiet mode; supress the message "0 differences found" */
- opts->m_quiet = 1;
+ opts->mode_quiet = 1;
break;
case 'r':
- opts->m_report = 1;
+ opts->mode_report = 1;
break;
case 'l':
@@ -185,7 +311,7 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
}
/* init */
- exclude_node->obj_path = (char*)opt_arg;
+ exclude_node->obj_path = opt_arg;
exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN;
exclude_prev = exclude_head;
@@ -202,38 +328,62 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
}
break;
+ case 'A':
+ opts->exclude_attr_path = 1;
+
+ /* create linked list of excluding objects */
+ if( (exclude_attr_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) {
+ HDprintf("Error: lack of memory!\n");
+ h5diff_exit(EXIT_FAILURE);
+ }
+
+ /* init */
+ exclude_attr_node->obj_path = opt_arg;
+ exclude_attr_node->obj_type = H5TRAV_TYPE_UNKNOWN;
+ exclude_attr_prev = exclude_attr_head;
+
+ if (NULL == exclude_attr_head) {
+ exclude_attr_head = exclude_attr_node;
+ exclude_attr_head->next = NULL;
+ }
+ else {
+ while(NULL != exclude_attr_prev->next)
+ exclude_attr_prev = exclude_attr_prev->next;
+
+ exclude_attr_node->next = NULL;
+ exclude_attr_prev->next = exclude_attr_node;
+ }
+ break;
+
case 'd':
- opts->d = 1;
+ opts->delta_bool = 1;
- if (check_d_input(opt_arg) == - 1) {
+ if (check_d_input(opt_arg) == -1) {
HDprintf("<-d %s> is not a valid option\n", opt_arg);
usage();
h5diff_exit(EXIT_FAILURE);
}
- opts->delta = atof(opt_arg);
-
- /* -d 0 is the same as default */
- if (H5_DBL_ABS_EQUAL(opts->delta, (double)0.0F))
- opts->d=0;
+ opts->delta = HDatof(opt_arg);
+ /* do not check against default, the DBL_EPSILON is being replaced by user */
break;
case 'p':
- opts->p = 1;
+ opts->percent_bool = 1;
if (check_p_input(opt_arg) == -1) {
HDprintf("<-p %s> is not a valid option\n", opt_arg);
usage();
h5diff_exit(EXIT_FAILURE);
}
- opts->percent = atof(opt_arg);
+ opts->percent = HDatof(opt_arg);
/* -p 0 is the same as default */
if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F))
- opts->p = 0;
+ opts->percent_bool = 0;
break;
case 'n':
- opts->n = 1;
- if ( check_n_input(opt_arg) == -1) {
+ opts->count_bool = 1;
+ if (check_n_input(opt_arg) == -1) {
HDprintf("<-n %s> is not a valid option\n", opt_arg);
usage();
h5diff_exit(EXIT_FAILURE);
@@ -246,12 +396,44 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
break;
case 'c':
- opts->m_list_not_cmp = 1;
+ opts->mode_list_not_cmp = 1;
break;
case 'e':
opts->use_system_epsilon = 1;
break;
+
+ case '1':
+ opts->vol_info[0].type = VOL_BY_VALUE;
+ opts->vol_info[0].u.value = (H5VL_class_value_t)HDatoi(opt_arg);
+ opts->custom_vol[0] = TRUE;
+ break;
+
+ case '2':
+ opts->vol_info[0].type = VOL_BY_NAME;
+ opts->vol_info[0].u.name = opt_arg;
+ opts->custom_vol[0] = TRUE;
+ break;
+
+ case '3':
+ opts->vol_info[0].info_string = opt_arg;
+ break;
+
+ case '4':
+ opts->vol_info[1].type = VOL_BY_VALUE;
+ opts->vol_info[1].u.value = (H5VL_class_value_t)HDatoi(opt_arg);
+ opts->custom_vol[1] = TRUE;
+ break;
+
+ case '5':
+ opts->vol_info[1].type = VOL_BY_NAME;
+ opts->vol_info[1].u.name = opt_arg;
+ opts->custom_vol[1] = TRUE;
+ break;
+
+ case '6':
+ opts->vol_info[1].info_string = opt_arg;
+ break;
}
}
@@ -262,30 +444,46 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
if (opts->exclude_path)
opts->exclude = exclude_head;
+ /* if exclude-attribute option is used, keep the exclude attr list */
+ if (opts->exclude_attr_path)
+ opts->exclude_attr = exclude_attr_head;
+
/* check for file names to be processed */
- if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) {
+ if (argc <= opt_ind || argv[opt_ind + 1] == NULL) {
error_msg("missing file names\n");
usage();
h5diff_exit(EXIT_FAILURE);
}
- *fname1 = argv[ opt_ind ];
- *fname2 = argv[ opt_ind + 1 ];
- *objname1 = argv[ opt_ind + 2 ];
+ *fname1 = argv[opt_ind];
+ *fname2 = argv[opt_ind + 1];
+ *objname1 = argv[opt_ind + 2];
+ H5TOOLS_DEBUG("file1 = %s", *fname1);
+ H5TOOLS_DEBUG("file2 = %s", *fname2);
if (*objname1 == NULL) {
*objname2 = NULL;
+ H5TOOLS_ENDDEBUG("No obj names");
return;
}
+ H5TOOLS_DEBUG("objname1 = %s", *objname1);
- if (argv[ opt_ind + 3 ] != NULL) {
- *objname2 = argv[ opt_ind + 3 ];
+ if (argv[opt_ind + 3] != NULL) {
+ *objname2 = argv[opt_ind + 3];
}
else {
*objname2 = *objname1;
}
+ H5TOOLS_DEBUG("objname2 = %s", *objname2);
+ /*
+ * TRILABS-227 is complete except for an issue with printing indices
+ * the following calls will enable subsetting
+ opts->sset[0] = parse_subset_params(*objname1);
+ opts->sset[1] = parse_subset_params(*objname2);
+ */
+ H5TOOLS_ENDDEBUG("");
}
@@ -293,26 +491,25 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const
* Function: print_info
*
* Purpose: print several information messages after h5diff call
- *
*-------------------------------------------------------------------------
*/
void print_info(diff_opt_t* opts)
{
- if (opts->m_quiet || opts->err_stat)
+ if (opts->mode_quiet || opts->err_stat)
return;
if (opts->cmn_objs == 0) {
HDprintf("No common objects found. Files are not comparable.\n");
- if (!opts->m_verbose)
+ if (!opts->mode_verbose)
HDprintf("Use -v for a list of objects.\n");
}
if (opts->not_cmp == 1) {
- if (opts->m_list_not_cmp == 0) {
+ if (opts->mode_list_not_cmp == 0) {
HDprintf("--------------------------------\n");
HDprintf("Some objects are not comparable\n");
HDprintf("--------------------------------\n");
- if (opts->m_verbose)
+ if (opts->mode_verbose)
HDprintf("Use -c for a list of objects without details of differences.\n");
else
HDprintf("Use -c for a list of objects.\n");
@@ -326,19 +523,10 @@ void print_info(diff_opt_t* opts)
* Purpose: check for valid input
*
* Return: 1 for ok, -1 for fail
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
- * Comments:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
H5_ATTR_PURE static int
-check_n_input( const char *str )
+check_n_input(const char *str)
{
unsigned i;
char c;
@@ -362,28 +550,21 @@ check_n_input( const char *str )
* Purpose: check for a valid p option input
*
* Return: 1 for ok, -1 for fail
- *
- * Date: May 9, 2003
- *
- * Comments:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
-check_p_input( const char *str )
+check_p_input(const char *str)
{
double x;
/*
- the atof return value on a hexadecimal input is different
- on some systems; we do a character check for this
- */
+ * the atof return value on a hexadecimal input is different
+ * on some systems; we do a character check for this
+ */
if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x')
return -1;
- x = atof(str);
+ x = HDatof(str);
if (x < 0)
return -1;
@@ -396,28 +577,21 @@ check_p_input( const char *str )
* Purpose: check for a valid d option input
*
* Return: 1 for ok, -1 for fail
- *
- * Date: November 11, 2007
- *
- * Comments:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
-check_d_input( const char *str )
+check_d_input(const char *str)
{
double x;
/*
- the atof return value on a hexadecimal input is different
- on some systems; we do a character check for this
- */
+ * the atof return value on a hexadecimal input is different
+ * on some systems; we do a character check for this
+ */
if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x')
return -1;
- x = atof(str);
+ x = HDatof(str);
if (x < 0)
return -1;
@@ -430,7 +604,6 @@ check_d_input( const char *str )
* Purpose: print a usage message
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
@@ -455,14 +628,25 @@ void usage(void)
PRINTVALSTREAM(rawoutstream, " Verbose mode with level. Print differences and list of objects.\n");
PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n");
PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n");
- PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute\n");
- PRINTVALSTREAM(rawoutstream, " status summary.\n");
- PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute\n");
- PRINTVALSTREAM(rawoutstream, " status report.\n");
+ PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute status summary.\n");
+ PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute status report.\n");
+ PRINTVALSTREAM(rawoutstream, " 3 : All level 2 information plus file names.\n");
PRINTVALSTREAM(rawoutstream, " -q, --quiet\n");
PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n");
PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n");
PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-value-1 Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " first HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-name-1 Name of the VOL connector to use for opening the first\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-info-1 VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the first HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-value-2 Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " second HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-name-2 Name of the VOL connector to use for opening the second\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-info-2 VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n");
PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links and compare the)\n");
PRINTVALSTREAM(rawoutstream, " links' target objects.\n");
@@ -535,7 +719,14 @@ void usage(void)
PRINTVALSTREAM(rawoutstream, " excluded.\n");
PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n");
PRINTVALSTREAM(rawoutstream, "\n");
-
+ PRINTVALSTREAM(rawoutstream, " --exclude-attribute \"path/to/object/with/attribute\"\n");
+ PRINTVALSTREAM(rawoutstream, " Exclude attributes on the specified path to an object when comparing files or groups.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " If there are multiple paths to an object, only the specified path(s)\n");
+ PRINTVALSTREAM(rawoutstream, " will be excluded; the comparison will include any path not explicitly\n");
+ PRINTVALSTREAM(rawoutstream, " excluded.\n");
+ PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " Modes of output:\n");
PRINTVALSTREAM(rawoutstream, " Default mode: print the number of differences found and where they occured\n");
PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n");
@@ -566,7 +757,22 @@ void usage(void)
PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n");
PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n");
PRINTVALSTREAM(rawoutstream, "\n");
-
+ /*
+ * TRILABS-227 is complete except for an issue with printing indices
+ * the following will be needed for subsetting
+ PRINTVALSTREAM(rawoutstream, " Subsetting options:\n");
+ PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the fcompact form of subsetting, as follows:\n");
+ PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK]\n");
+ PRINTVALSTREAM(rawoutstream, " It is not required to use all parameters, but until the last parameter value used,\n");
+ PRINTVALSTREAM(rawoutstream, " all of the semicolons (;) are required, even when a parameter value is not specified. Example:\n");
+ PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;;COUNT;BLOCK]\n");
+ PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START]\n");
+ PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n");
+ PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n");
+ PRINTVALSTREAM(rawoutstream, " Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with\n");
+ PRINTVALSTREAM(rawoutstream, " one integer for each dimension of the dataset.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+*/
PRINTVALSTREAM(rawoutstream, " Exit code:\n");
PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n");
PRINTVALSTREAM(rawoutstream, "\n");
diff --git a/tools/src/h5diff/h5diff_main.c b/tools/src/h5diff/h5diff_main.c
index c5a0cbf..33d6570 100644
--- a/tools/src/h5diff/h5diff_main.c
+++ b/tools/src/h5diff/h5diff_main.c
@@ -69,10 +69,7 @@
int main(int argc, const char *argv[])
{
int ret;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
+ int i;
const char *fname1 = NULL;
const char *fname2 = NULL;
const char *objname1 = NULL;
@@ -83,27 +80,17 @@ int main(int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
-
/*-------------------------------------------------------------------------
* process the command-line
*-------------------------------------------------------------------------
*/
parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts);
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
- }
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/*-------------------------------------------------------------------------
* do the diff
@@ -130,6 +117,23 @@ int main(int argc, const char *argv[])
if (opts.err_stat)
ret = 2;
+ /* free any buffers */
+ for (i = 0; i < 2; i++) {
+ if (opts.sset[i]) {
+ if(opts.sset[i]->start.data)
+ HDfree(opts.sset[i]->start.data);
+ if(opts.sset[i]->stride.data)
+ HDfree(opts.sset[i]->stride.data);
+ if(opts.sset[i]->count.data)
+ HDfree(opts.sset[i]->count.data);
+ if(opts.sset[i]->block.data)
+ HDfree(opts.sset[i]->block.data);
+
+ HDfree(opts.sset[i]);
+ opts.sset[i]=NULL;
+ }
+ }
+
h5diff_exit(ret);
}
diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c
index d9ea4b0..2b21b1c 100644
--- a/tools/src/h5dump/h5dump.c
+++ b/tools/src/h5dump/h5dump.c
@@ -18,30 +18,35 @@
/* 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
-static H5FD_ros3_fapl_t ros3_fa = {
- 1, /* version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+/* Default "anonymous" S3 configuration */
+static H5FD_ros3_fapl_t ros3_fa_g = {
+ 1, /* Structure Version */
+ false, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
-static H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+/* "Default" HDFS configuration */
+static H5FD_hdfs_fapl_t hdfs_fa_g = {
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
@@ -211,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' }
};
@@ -268,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");
@@ -641,12 +655,12 @@ parse_hsize_list(const char *h_list, subset_d *d)
*-------------------------------------------------------------------------
*/
static struct subset_t *
-parse_subset_params(char *dset)
+parse_subset_params(const char *dset)
{
struct subset_t *s = NULL;
char *brace;
- if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
+ if (!dump_opts.disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
*brace++ = '\0';
s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
@@ -877,50 +891,50 @@ parse_command_line(int argc, const char *argv[])
parse_start:
switch ((char)opt) {
case 'R':
- display_region = TRUE;
+ dump_opts.display_region = TRUE;
region_output = TRUE;
break;
case 'B':
- display_bb = TRUE;
+ dump_opts.display_bb = TRUE;
last_was_dset = FALSE;
break;
case 'n':
- display_fi = TRUE;
+ dump_opts.display_fi = TRUE;
last_was_dset = FALSE;
if (opt_arg != NULL)
h5trav_set_verbose(HDatoi(opt_arg));
break;
case 'p':
- display_dcpl = TRUE;
+ dump_opts.display_dcpl = TRUE;
break;
case 'y':
- display_ai = FALSE;
+ dump_opts.display_ai = FALSE;
break;
case 'e':
- display_escape = TRUE;
+ dump_opts.display_escape = TRUE;
break;
case 'H':
- display_data = FALSE;
- display_attr_data = FALSE;
+ dump_opts.display_data = FALSE;
+ dump_opts.display_attr_data = FALSE;
last_was_dset = FALSE;
break;
case 'A':
if (opt_arg != NULL) {
if(0 == HDatoi(opt_arg))
- include_attrs = FALSE;
+ dump_opts.include_attrs = FALSE;
}
else {
- display_data = FALSE;
- display_attr_data = TRUE;
+ dump_opts.display_data = FALSE;
+ dump_opts.display_attr_data = TRUE;
last_was_dset = FALSE;
}
break;
case 'i':
- display_oid = TRUE;
+ dump_opts.display_oid = TRUE;
last_was_dset = FALSE;
break;
case 'r':
- display_char = TRUE;
+ dump_opts.display_char = TRUE;
break;
case 'V':
print_version(h5tools_getprogname());
@@ -941,7 +955,7 @@ parse_start:
}
break;
case 'N':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -953,7 +967,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 'a':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -965,7 +979,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 'd':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -979,10 +993,10 @@ parse_start:
last_was_dset = TRUE;
break;
case 'f':
- driver = opt_arg;
+ driver_name_g = opt_arg;
break;
case 'g':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -994,7 +1008,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 'l':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -1006,7 +1020,7 @@ parse_start:
last_was_dset = FALSE;
break;
case 't':
- display_all = 0;
+ dump_opts.display_all = 0;
for (i = 0; i < argc; i++)
if (!hand[i].func) {
@@ -1033,13 +1047,13 @@ parse_start:
}
}
else {
- if(display_attr_data && !display_data) {
+ if(dump_opts.display_attr_data && !dump_opts.display_data) {
if (h5tools_set_attr_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
}
}
- if(display_data || display_all) {
+ if(dump_opts.display_data || dump_opts.display_all) {
if (h5tools_set_data_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
@@ -1047,9 +1061,9 @@ parse_start:
}
}
- usingdasho = TRUE;
+ dump_opts.usingdasho = TRUE;
last_was_dset = FALSE;
- outfname = opt_arg;
+ outfname_g = opt_arg;
break;
case 'b':
@@ -1061,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;
@@ -1097,14 +1111,14 @@ parse_start:
usage(h5tools_getprogname());
goto error;
}
- display_packed_bits = TRUE;
+ dump_opts.display_packed_bits = TRUE;
break;
case 'v':
- display_vds_first = TRUE;
+ dump_opts.display_vds_first = TRUE;
break;
case 'G':
- vds_gap_size = HDatoi(opt_arg);
- if (vds_gap_size < 0) {
+ dump_opts.vds_gap_size = HDatoi(opt_arg);
+ if (dump_opts.vds_gap_size < 0) {
usage(h5tools_getprogname());
goto error;
}
@@ -1113,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;
@@ -1130,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;
@@ -1143,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;
}
@@ -1241,7 +1255,7 @@ end_collect:
enable_error_stack = 1;
break;
case 'C':
- disable_compact_subset = TRUE;
+ dump_opts.disable_compact_subset = TRUE;
break;
case 'h':
usage(h5tools_getprogname());
@@ -1251,106 +1265,53 @@ end_collect:
goto done;
case '$':
-#ifndef H5_HAVE_ROS3_VFD
+#ifdef H5_HAVE_ROS3_VFD
+ 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);
+ hand = NULL;
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- /* s3 credential */
- {
- char **s3_cred = NULL;
- char *s3_cred_string = NULL;
- const char *ccred[3];
- unsigned nelems = 0;
- if (FAIL == parse_tuple(opt_arg, ',', &s3_cred_string, &nelems, &s3_cred)) {
- error_msg("unable to parse malformed s3 credentials\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- if (nelems != 3) {
- error_msg("s3 credentials expects 3 elements\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- ccred[0] = (const char *)s3_cred[0];
- ccred[1] = (const char *)s3_cred[1];
- ccred[2] = (const char *)s3_cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- error_msg("Invalid S3 credentials\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- HDfree(s3_cred);
- HDfree(s3_cred_string);
- } /* s3 credential block */
+#endif
break;
-#endif /* H5_HAVE_ROS3_VFD */
case '#':
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- goto error;
+#ifdef H5_HAVE_LIBHDFS
+ 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);
+ hand = NULL;
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
#else
- {
- /* read hdfs properties tuple and store values in `hdfs_fa` */
- unsigned nelems = 0;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
- if (FAIL == parse_tuple((const char *)opt_arg, ',', &props_src, &nelems, &props)) {
- error_msg("unable to parse hdfs properties tuple\n");
- goto error;
- }
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- /* Populate fapl configuration structure with given
- * properties.
- * WARNING: No error-checking is done on length of input
- * strings... Silent overflow is possible, albeit
- * unlikely.
- */
- if (strncmp(props[0], "", 1))
- HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0]));
+ error_msg("HDFS VFD not enabled.\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+#endif
+ break;
- if (strncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (strncmp(props[2], "", 1))
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
+ 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;
- if (strncmp(props[3], "", 1))
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
+ case '2':
+ vol_info_g.type = VOL_BY_NAME;
+ vol_info_g.u.name = opt_arg;
+ use_custom_vol_g = TRUE;
+ break;
- if (strncmp(props[4], "", 1)) {
- k = strtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
- }
-#endif /* H5_HAVE_LIBHDFS */
+ case '3':
+ vol_info_g.info_string = opt_arg;
break;
case '?':
@@ -1396,14 +1357,10 @@ main(int argc, const char *argv[])
hid_t fid = H5I_INVALID_HID;
hid_t gid = H5I_INVALID_HID;
hid_t fapl_id = H5P_DEFAULT;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
H5O_info2_t oi;
struct handler_t *hand = NULL;
int i;
unsigned u;
- void *edata;
- void *tools_edata;
char *fname = NULL;
h5tools_setprogname(PROGRAMNAME);
@@ -1412,63 +1369,50 @@ main(int argc, const char *argv[])
dump_function_table = &ddl_function_table;
dump_indent = 0;
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
-
if((hand = parse_command_line(argc, argv))==NULL) {
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;
}
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
- }
-
/* Check for conflicting options */
- if (doxml) {
- if (!display_all) {
+ if (doxml_g) {
+ if (!dump_opts.display_all) {
error_msg("option \"%s\" not available for XML\n", "to display selected objects");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_bb) {
+ else if (dump_opts.display_bb) {
error_msg("option \"%s\" not available for XML\n", "--boot-block");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_oid == 1) {
+ else if (dump_opts.display_oid == 1) {
error_msg("option \"%s\" not available for XML\n", "--object-ids");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_char == TRUE) {
+ else if (dump_opts.display_char == TRUE) {
error_msg("option \"%s\" not available for XML\n", "--string");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (usingdasho) {
+ else if (dump_opts.usingdasho) {
error_msg("option \"%s\" not available for XML\n", "--output");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
}
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);
}
}
@@ -1478,57 +1422,58 @@ main(int argc, const char *argv[])
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
- if (driver != NULL) {
- void *conf_fa = NULL;
+ if (driver_name_g != NULL) {
+ h5tools_vfd_info_t vfd_info;
- if (!strcmp(driver, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
+ vfd_info.info = NULL;
+ vfd_info.name = driver_name_g;
+
+ if (!HDstrcmp(driver_name_g, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ 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_name_g, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ vfd_info.info = (void *)&hdfs_fa_g;
#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+ error_msg("The HDFS VFD is not enabled.\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+#endif
}
- else if (!HDstrcmp(driver, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
+
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) {
+ error_msg("unable to create FAPL for file access\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
}
+ } /* driver name defined */
- if (conf_fa != NULL) {
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- error_msg("unable to create fapl entry\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- /* driver guaranteed "ros3" or "hdfs" */
- /* conf_fa appropriate to driver */
- if (0 == h5tools_set_configured_fapl(fapl_id, driver, conf_fa)) {
- error_msg("unable to set fapl\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
+ 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;
}
- } /* driver defined */
+ }
while(opt_ind < argc) {
fname = HDstrdup(argv[opt_ind++]);
- if (fapl_id != H5P_DEFAULT) {
- fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- }
- else {
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
- }
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id,
+ (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0);
if (fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
@@ -1542,23 +1487,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;
@@ -1591,16 +1536,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) */
@@ -1620,13 +1565,13 @@ 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 (display_fi) {
+ if (!doxml_g) {
+ if (dump_opts.display_fi) {
PRINTVALSTREAM(rawoutstream, "\n");
dump_fcontents(fid);
end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend);
@@ -1634,20 +1579,20 @@ main(int argc, const char *argv[])
goto done;
}
- if (display_bb)
+ if (dump_opts.display_bb)
dump_fcpl(fid);
}
- if(display_all) {
+ if(dump_opts.display_all) {
if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
error_msg("unable to open root group\n");
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");
}
@@ -1660,7 +1605,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;
@@ -1674,7 +1619,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");
}
@@ -1703,8 +1648,6 @@ main(int argc, const char *argv[])
/* To Do: clean up XML table */
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
leave(h5tools_getstatus());
done:
@@ -1734,8 +1677,6 @@ done:
/* To Do: clean up XML table */
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
leave(h5tools_getstatus());
} /* main */
diff --git a/tools/src/h5dump/h5dump.h b/tools/src/h5dump/h5dump.h
index ca1fef6..548af09 100644
--- a/tools/src/h5dump/h5dump.h
+++ b/tools/src/h5dump/h5dump.h
@@ -52,8 +52,8 @@ typedef struct h5dump_table_list_t {
h5dump_table_list_t table_list = {0, 0, NULL};
table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
-unsigned dump_indent = 0; /*how far in to indent the line */
+unsigned dump_indent = 0; /* how far in to indent the line */
int unamedtype = 0; /* shared datatype with no name */
hbool_t hit_elink = FALSE; /* whether we have traversed an external link */
size_t prefix_len = 1024;
@@ -61,23 +61,26 @@ char *prefix = NULL;
const char *fp_format = NULL;
/* things to display or which are set via command line parameters */
-int display_all = TRUE;
-int display_oid = FALSE;
-int display_data = TRUE;
-int display_attr_data = TRUE;
-int display_char = FALSE; /*print 1-byte numbers as ASCII */
-int usingdasho = FALSE;
-int display_bb = FALSE; /*superblock */
-int display_dcpl = FALSE; /*dcpl */
-int display_fi = FALSE; /*file index */
-int display_ai = TRUE; /*array index */
-int display_escape = FALSE; /*escape non printable characters */
-int display_region = FALSE; /*print region reference data */
-int disable_compact_subset= FALSE; /* disable compact form of subset notation */
-int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/
-int include_attrs = TRUE; /* Display attributes */
-int display_vds_first = FALSE; /* vds display to all by default*/
-int vds_gap_size = 0; /* vds skip missing files default is none */
+typedef struct {
+ int display_all;
+ int display_oid;
+ int display_data;
+ int display_attr_data;
+ int display_char; /* print 1-byte numbers as ASCII */
+ int usingdasho;
+ int display_bb; /* superblock */
+ int display_dcpl; /* dcpl */
+ int display_fi; /* file index */
+ int display_ai; /* array index */
+ int display_escape; /* escape non printable characters */
+ int display_region; /* print region reference data */
+ int disable_compact_subset; /* disable compact form of subset notation */
+ int display_packed_bits; /* print 1-8 byte numbers as packed bits */
+ int include_attrs; /* Display attributes */
+ int display_vds_first; /* vds display to all by default */
+ int vds_gap_size; /* vds skip missing files default is none */
+} dump_opt_t;
+dump_opt_t dump_opts = {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0};
#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
#define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c
index a410fda..b50ce52 100644
--- a/tools/src/h5dump/h5dump_ddl.c
+++ b/tools/src/h5dump/h5dump_ddl.c
@@ -103,13 +103,13 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
- ctx.display_index = display_ai;
- ctx.display_char = display_char;
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
- oid_output = display_oid;
- data_output = display_data;
- attr_data_output = display_attr_data;
+ oid_output = dump_opts.display_oid;
+ data_output = dump_opts.display_data;
+ attr_data_output = dump_opts.display_attr_data;
string_dataformat = *outputformat;
@@ -125,7 +125,7 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
h5dump_type_table = type_table;
@@ -185,7 +185,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATT
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
/* Build the object's path name */
@@ -242,16 +242,16 @@ dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATT
break;
case H5O_TYPE_DATASET:
- if(display_data) {
+ if(dump_opts.display_data) {
if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) {
error_msg("error in creating default access property list ID\n");
}
- if (display_vds_first) {
+ if (dump_opts.display_vds_first) {
if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0)
error_msg("error in setting access property list ID, virtual_view\n");
}
- if (vds_gap_size > 0) {
- if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)vds_gap_size) < 0)
+ if (dump_opts.vds_gap_size > 0) {
+ if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0)
error_msg("error in setting access property list ID, virtual_printf_gap\n");
}
}
@@ -565,7 +565,7 @@ attr_iteration(hid_t gid, unsigned attr_crt_order_flags)
{
/* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
in the group for attributes, then, sort by creation order, otherwise by name */
- if(include_attrs) {
+ if(dump_opts.include_attrs) {
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
error_msg("error getting attribute information\n");
@@ -642,7 +642,7 @@ dump_named_datatype(hid_t tid, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if ((tcpl_id = H5Tget_create_plist(tid)) < 0) {
@@ -795,7 +795,7 @@ dump_group(hid_t gid, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.need_prefix = TRUE;
@@ -816,14 +816,14 @@ dump_group(hid_t gid, const char *name)
/* dump unamed type in root group */
for(u = 0; u < type_table->nobjs; u++)
if(!type_table->objs[u].recorded) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str);
- HDsprintf(type_name, "#%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsprintf(type_name, "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
@@ -831,7 +831,7 @@ dump_group(hid_t gid, const char *name)
}
} /* end if */
- if(display_oid)
+ if(dump_opts.display_oid)
h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid);
h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid);
@@ -926,7 +926,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if ((dcpl_id = H5Dget_create_plist(did)) < 0) {
@@ -967,11 +967,11 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space);
H5Sclose(space);
- if(display_oid) {
+ if(dump_opts.display_oid) {
h5tools_dump_oid(rawoutstream, outputformat, &ctx, did);
}
- if(display_dcpl) {
+ if(dump_opts.display_dcpl) {
h5dump_type_table = type_table;
h5tools_dump_dcpl(rawoutstream, outputformat, &ctx, dcpl_id, type, did);
h5dump_type_table = NULL;
@@ -979,16 +979,16 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
H5Pclose(dcpl_id);
ctx.sset = sset;
- ctx.display_index = display_ai;
- ctx.display_char = display_char;
- if(display_data) {
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
+ if(dump_opts.display_data) {
unsigned data_loop = 1;
unsigned u;
- if(display_packed_bits)
+ if(dump_opts.display_packed_bits)
data_loop = packed_bits_num;
for(u = 0; u < data_loop; u++) {
- if(display_packed_bits) {
+ if(dump_opts.display_packed_bits) {
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
@@ -1091,7 +1091,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
@@ -1099,7 +1099,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
ctx.cur_column = dump_indent;
ctx.sset = sset;
ctx.display_index = display_index;
- ctx.display_char = display_char;
+ ctx.display_char = dump_opts.display_char;
if(obj_data == DATASET_DATA)
print_dataset = TRUE;
@@ -1136,6 +1136,18 @@ dump_fcpl(hid_t fid)
unsigned sym_ik; /* symbol table B-tree internal 'K' value */
unsigned istore_ik; /* indexed storage B-tree internal 'K' value */
+ hbool_t supported = FALSE;
+
+ /* Dumping the information here only makes sense for the native
+ * VOL connector. The only VOL call here is H5Fget_info(), so we'll
+ * use that as a proxy for "native-ness". If that isn't supported, we'll
+ * just return.
+ */
+ H5VLquery_optional(fid, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_GET_INFO, &supported);
+
+ if (!supported)
+ return;
+
fcpl=H5Fget_create_plist(fid);
H5Fget_info2(fid, &finfo);
H5Pget_userblock(fcpl,&userblock);
@@ -1258,11 +1270,11 @@ dump_fcontents(hid_t fid)
for (u = 0; u < type_table->nobjs; u++) {
if (!type_table->objs[u].recorded) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
- H5Otoken_to_str(fid, &type_table->objs[u].obj_token, &obj_addr_str);
- PRINTSTREAM(rawoutstream, " %-10s /#%s\n", "datatype", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(fid, &type_table->objs[u].obj_token, &obj_tok_str);
+ PRINTSTREAM(rawoutstream, " %-10s /#%s\n", "datatype", obj_tok_str);
+ H5free_memory(obj_tok_str);
}
}
}
@@ -1515,8 +1527,8 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
ctx.cur_column = dump_indent;
- ctx.display_index = display_ai;
- ctx.display_char = display_char;
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
string_dataformat = *outputformat;
@@ -1532,7 +1544,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/");
@@ -1571,9 +1583,9 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5
} /* end if */
attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
- oid_output = display_oid;
- data_output = display_data;
- attr_data_output = display_attr_data;
+ oid_output = dump_opts.display_oid;
+ data_output = dump_opts.display_data;
+ attr_data_output = dump_opts.display_attr_data;
h5dump_type_table = type_table;
h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id);
@@ -1625,16 +1637,16 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
struct subset_t *sset = (struct subset_t *)data;
const char *real_name = display_name ? display_name : dset;
- if(display_data) {
+ if(dump_opts.display_data) {
if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) {
error_msg("error in creating default access property list ID\n");
}
- if (display_vds_first) {
+ if (dump_opts.display_vds_first) {
if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0)
error_msg("error in setting access property list ID, virtual_view\n");
}
- if (vds_gap_size > 0) {
- if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)vds_gap_size) < 0)
+ if (dump_opts.vds_gap_size > 0) {
+ if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0)
error_msg("error in setting access property list ID, virtual_printf_gap\n");
}
}
@@ -1914,12 +1926,12 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe
char name[128];
if(!type_table->objs[idx].recorded) {
- char *obj_addr_string = NULL;
+ char *obj_tok_str = NULL;
/* unamed datatype */
- H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_addr_string);
- HDsprintf(name, "/#%s", obj_addr_string);
- H5free_memory(obj_addr_string);
+ H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_tok_str);
+ HDsprintf(name, "/#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
if(!HDstrcmp(name, real_name))
break;
diff --git a/tools/src/h5dump/h5dump_extern.h b/tools/src/h5dump/h5dump_extern.h
index 00d3bd2..c615621 100644
--- a/tools/src/h5dump/h5dump_extern.h
+++ b/tools/src/h5dump/h5dump_extern.h
@@ -50,32 +50,35 @@ typedef struct h5dump_table_list_t {
extern h5dump_table_list_t table_list;
extern table_t *group_table, *dset_table, *type_table;
-extern unsigned dump_indent; /*how far in to indent the line */
-extern int unamedtype; /* shared datatype with no name */
-extern hbool_t hit_elink; /* whether we have traversed an external link */
+extern unsigned dump_indent; /* how far in to indent the line */
+extern int unamedtype; /* shared datatype with no name */
+extern hbool_t hit_elink; /* whether we have traversed an external link */
extern size_t prefix_len;
extern char *prefix;
extern const char *fp_format;
/* things to display or which are set via command line parameters */
-extern int display_all;
-extern int display_oid;
-extern int display_data;
-extern int display_attr_data;
-extern int display_char; /*print 1-byte numbers as ASCII */
-extern int usingdasho;
-extern int display_bb; /*superblock */
-extern int display_dcpl; /*dcpl */
-extern int display_fi; /*file index */
-extern int display_ai; /*array index */
-extern int display_escape; /*escape non printable characters */
-extern int display_region; /*print region reference data */
-extern int disable_compact_subset; /* disable compact form of subset notation */
-extern int display_packed_bits; /*print 1-8 byte numbers as packed bits*/
-extern int include_attrs; /* Display attributes */
-extern int display_vds_first; /* vds display to first missing */
-extern int vds_gap_size; /* vds skip missing files */
+typedef struct {
+ int display_all;
+ int display_oid;
+ int display_data;
+ int display_attr_data;
+ int display_char; /* print 1-byte numbers as ASCII */
+ int usingdasho;
+ int display_bb; /* superblock */
+ int display_dcpl; /* dcpl */
+ int display_fi; /* file index */
+ int display_ai; /* array index */
+ int display_escape; /* escape non printable characters */
+ int display_region; /* print region reference data */
+ int disable_compact_subset; /* disable compact form of subset notation */
+ int display_packed_bits; /* print 1-8 byte numbers as packed bits */
+ int include_attrs; /* Display attributes */
+ int display_vds_first; /* vds display to all by default */
+ int vds_gap_size; /* vds skip missing files default is none */
+} dump_opt_t;
+extern dump_opt_t dump_opts;
#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c
index 1a7c3ce..bb47f77 100644
--- a/tools/src/h5dump/h5dump_xml.c
+++ b/tools/src/h5dump/h5dump_xml.c
@@ -162,7 +162,7 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
/* Build the object's path name */
@@ -578,7 +578,7 @@ int
xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen)
{
H5O_token_t obj_token;
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
int lookup_ret;
if (outlen < 22) return 1;
@@ -591,9 +591,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
if (gen) {
ref_path_table_gen_fake(str, &obj_token);
- H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str);
- HDsprintf(outstr, "xid_%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsprintf(outstr, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
return 0;
}
@@ -606,9 +606,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
if (gen) {
ref_path_table_gen_fake(str, &obj_token);
- H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str);
- HDsprintf(outstr, "xid_%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsprintf(outstr, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
return 0;
}
@@ -618,9 +618,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
}
}
- H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str);
- HDsprintf(outstr, "xid_%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsprintf(outstr, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
return 0;
}
@@ -738,9 +738,9 @@ xml_escape_the_string(const char *str, int slen)
size_t extra;
size_t len;
size_t i;
- const char *cp;
- char *ncp;
- char *rcp;
+ const char *cp = NULL;
+ char *ncp = NULL;
+ char *rcp = NULL;
size_t ncp_len;
if (!str)
@@ -783,29 +783,31 @@ xml_escape_the_string(const char *str, int slen)
if (*cp == '\\') {
*ncp++ = '\\';
+ ncp_len--;
*ncp = *cp;
esc_len = 1;
}
else if (*cp == '\"') {
*ncp++ = '\\';
+ ncp_len--;
*ncp = *cp;
esc_len = 1;
}
else if (*cp == '\'') {
+ HDstrncpy(ncp, apos, ncp_len);
esc_len = HDstrlen(apos);
- HDstrncpy(ncp, apos, esc_len);
}
else if (*cp == '<') {
+ HDstrncpy(ncp, lt, ncp_len);
esc_len = HDstrlen(lt);
- HDstrncpy(ncp, lt, esc_len);
}
else if (*cp == '>') {
+ HDstrncpy(ncp, gt, ncp_len);
esc_len = HDstrlen(gt);
- HDstrncpy(ncp, gt, esc_len);
}
else if (*cp == '&') {
+ HDstrncpy(ncp, amp, ncp_len);
esc_len = HDstrlen(amp);
- HDstrncpy(ncp, amp, esc_len);
}
else {
*ncp = *cp;
@@ -886,7 +888,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if(!in_group && H5Tcommitted(type) > 0) {
@@ -1536,7 +1538,7 @@ xml_dump_datatype(hid_t type)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.indent_level++;
@@ -1667,7 +1669,7 @@ xml_dump_dataspace(hid_t space)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.indent_level++;
@@ -1990,7 +1992,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.need_prefix = TRUE;
@@ -2012,7 +2014,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
ctx.indent_level++;
dump_indent += COL;
- if (display_attr_data && space_type != H5S_NULL) {
+ if (dump_opts.display_attr_data && space_type != H5S_NULL) {
switch (H5Tget_class(type)) {
case H5T_INTEGER:
case H5T_FLOAT:
@@ -2291,7 +2293,7 @@ xml_dump_named_datatype(hid_t type, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
dtxid = (char *)HDmalloc((size_t)100);
@@ -2504,7 +2506,7 @@ xml_dump_group(hid_t gid, const char *name)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
if(HDstrcmp(name, "/") == 0) {
@@ -2659,14 +2661,14 @@ 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) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str);
- HDsprintf(type_name, "#%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsprintf(type_name, "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
@@ -2747,14 +2749,14 @@ 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) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str);
- HDsprintf(type_name, "#%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsprintf(type_name, "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
@@ -2887,7 +2889,7 @@ xml_print_refs(hid_t did, int source)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
for (i = 0; i < (hsize_t)ssiz; i++) {
@@ -3037,7 +3039,7 @@ xml_print_strs(hid_t did, int source)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
for (i = 0; i < (hsize_t)ssiz; i++) {
@@ -3149,7 +3151,7 @@ check_filters(hid_t dcpl)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
nfilt = H5Pget_nfilters(dcpl);
@@ -3285,7 +3287,7 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
ctx.indent_level++;
@@ -3625,7 +3627,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
xml_name_to_XID(did, tmp, rstr, 100, 1);
@@ -3914,7 +3916,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss
dump_indent -= COL;
tempi = H5Dget_storage_size(did);
- if (display_data && (tempi > 0)) {
+ if (dump_opts.display_data && (tempi > 0)) {
switch (H5Tget_class(type)) {
case H5T_INTEGER:
case H5T_FLOAT:
@@ -4170,7 +4172,7 @@ xml_print_enum(hid_t type)
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
+ string_dataformat.do_escape = dump_opts.display_escape;
outputformat = &string_dataformat;
nmembs = (unsigned)H5Tget_nmembers(type);
diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c
index 8e0d857..e60097b 100644
--- a/tools/src/h5format_convert/h5format_convert.c
+++ b/tools/src/h5format_convert/h5format_convert.c
@@ -60,6 +60,7 @@ static struct long_options l_opts[] = {
{ "noop", no_arg, 'n' },
{ "noo", no_arg, 'n' },
{ "no", no_arg, 'n' },
+ { "enable-error-stack", no_arg, 'E' },
{ NULL, 0, '\0' }
};
@@ -108,7 +109,7 @@ static void usage(const char *prog)
* Purpose: parse command line input
*
* Return: Success: 0
- * Failure: 1
+ * Failure: 1
*
*-------------------------------------------------------------------------
*/
@@ -126,47 +127,47 @@ parse_command_line(int argc, const char **argv)
/* parse command line options */
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char) opt) {
- case 'h':
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- goto error;
-
- case 'V':
- print_version(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- goto error;
-
- case 'v':
- verbose_g = TRUE;
- break;
-
- case 'd': /* -d dname */
- if(opt_arg != NULL && *opt_arg)
- dname_g = HDstrdup(opt_arg);
- if(dname_g == NULL) {
- h5tools_setstatus(EXIT_FAILURE);
- error_msg("No dataset name\n", opt_arg);
- usage(h5tools_getprogname());
- goto error;
- }
- dset_g = TRUE;
- break;
-
- case 'n': /* -n */
- noop_g = TRUE;
- break;
-
- case 'E':
- enable_error_stack = 1;
- break;
-
- default:
- h5tools_setstatus(EXIT_FAILURE);
- usage(h5tools_getprogname());
- goto error;
- break;
- } /* switch */
+ switch((char) opt) {
+ case 'h':
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto error;
+
+ case 'V':
+ print_version(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto error;
+
+ case 'v':
+ verbose_g = TRUE;
+ break;
+
+ case 'd': /* -d dname */
+ if(opt_arg != NULL && *opt_arg)
+ dname_g = HDstrdup(opt_arg);
+ if(dname_g == NULL) {
+ h5tools_setstatus(EXIT_FAILURE);
+ error_msg("No dataset name\n", opt_arg);
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ dset_g = TRUE;
+ break;
+
+ case 'n': /* -n */
+ noop_g = TRUE;
+ break;
+
+ case 'E':
+ enable_error_stack = 1;
+ break;
+
+ default:
+ h5tools_setstatus(EXIT_FAILURE);
+ usage(h5tools_getprogname());
+ goto error;
+ break;
+ } /* switch */
} /* while */
if (argc <= opt_ind) {
@@ -206,17 +207,17 @@ leave(int ret)
* Function: convert()
*
* Purpose: To downgrade a dataset's indexing type or layout version:
- * For chunked:
- * Downgrade the chunk indexing type to version 1 B-tree
- * If type is already version 1 B-tree, no further action
- * For compact/contiguous:
- * Downgrade the layout version from 4 to 3
- * If version is already <= 3, no further action
- * For virtual:
- * No further action
+ * For chunked:
+ * Downgrade the chunk indexing type to version 1 B-tree
+ * If type is already version 1 B-tree, no further action
+ * For compact/contiguous:
+ * Downgrade the layout version from 4 to 3
+ * If version is already <= 3, no further action
+ * For virtual:
+ * No further action
*
* Return: Success: 0
- * Failure: 1
+ * Failure: 1
*
*-------------------------------------------------------------------------
*/
@@ -311,7 +312,7 @@ convert(hid_t fid, const char *dname)
}
if(verbose_g)
- HDfprintf(stdout, "Converting the dataset...\n");
+ HDfprintf(stdout, "Converting the dataset...\n");
/* Downgrade the dataset */
if(H5Dformat_convert(did) < 0) {
@@ -376,7 +377,7 @@ convert_dsets_cb(const char *path, const H5O_info2_t *oi, const char *already_vi
if(verbose_g)
HDfprintf(stdout, "Going to process dataset:%s...\n", path);
if(convert(fid, path) < 0)
- goto error;
+ goto error;
} /* end if */
} /* end if */
@@ -391,57 +392,56 @@ error:
* Function: main
*
* Purpose: To convert the chunk indexing type of a dataset in a file to
- * version 1 B-tree.
+ * version 1 B-tree.
*
* Return: Success: 0
- * Failure: 1
+ * Failure: 1
*
*-------------------------------------------------------------------------
*/
int
main(int argc, const char *argv[])
{
- H5E_auto2_t func;
- void *edata;
hid_t fid = H5I_INVALID_HID;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
/* Parse command line options */
if(parse_command_line(argc, argv) < 0)
- goto done;
+ goto done;
else if(verbose_g)
- HDfprintf(stdout, "Process command line options\n");
+ HDfprintf(stdout, "Process command line options\n");
if(noop_g && verbose_g)
- HDfprintf(stdout, "It is noop...\n");
+ HDfprintf(stdout, "It is noop...\n");
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/* Open the HDF5 file */
- if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0)) < 0) {
- error_msg("unable to open file \"%s\"\n", fname_g);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- } else if(verbose_g)
- HDfprintf(stdout, "Open the file %s\n", fname_g);
+ if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0)) < 0) {
+ error_msg("unable to open file \"%s\"\n", fname_g);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ else if(verbose_g)
+ HDfprintf(stdout, "Open the file %s\n", fname_g);
if(dset_g) { /* Convert a specified dataset in the file */
- if(verbose_g)
- HDfprintf(stdout, "Going to process dataset: %s...\n", dname_g);
- if(convert(fid, dname_g) < 0)
- goto done;
- } else { /* Convert all datasets in the file */
- if(verbose_g)
- HDfprintf(stdout, "Processing all datasets in the file...\n");
- if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0)
- goto done;
+ if(verbose_g)
+ HDfprintf(stdout, "Going to process dataset: %s...\n", dname_g);
+ if(convert(fid, dname_g) < 0)
+ goto done;
+ }
+ else { /* Convert all datasets in the file */
+ if(verbose_g)
+ HDfprintf(stdout, "Processing all datasets in the file...\n");
+ if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0)
+ goto done;
} /* end else */
if(verbose_g) {
@@ -463,19 +463,20 @@ main(int argc, const char *argv[])
done:
/* Close the file */
if(fid >= 0) {
- if(H5Fclose(fid) < 0) {
- error_msg("unable to close file \"%s\"\n", fname_g);
- h5tools_setstatus(EXIT_FAILURE);
- } else if(verbose_g)
- HDfprintf(stdout, "Close the file\n");
+ if(H5Fclose(fid) < 0) {
+ error_msg("unable to close file \"%s\"\n", fname_g);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ else if(verbose_g) {
+ HDfprintf(stdout, "Close the file\n");
+ }
} /* end if */
if(fname_g)
- HDfree(fname_g);
+ HDfree(fname_g);
if(dname_g)
- HDfree(dname_g);
+ HDfree(dname_g);
- H5Eset_auto2(H5E_DEFAULT, func, edata);
leave(h5tools_getstatus());
} /* end main() */
diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c
index f87f371..4a642e0 100644
--- a/tools/src/h5import/h5import.c
+++ b/tools/src/h5import/h5import.c
@@ -72,7 +72,7 @@ uint64_t swap_uint64(uint64_t val);
int main(int argc, char *argv[])
{
- struct Options opt;
+ struct Options *opt;
int outfile_named = FALSE;
int token;
int i;
@@ -99,8 +99,8 @@ int main(int argc, char *argv[])
(void) HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0);
(void) HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0);
- /* Initialize the file structure to 0 */
- HDmemset(&opt, 0, sizeof(struct Options));
+ if((opt = (struct Options *)HDcalloc(1, sizeof(struct Options))) == NULL)
+ goto err;
if (argv[1] && (HDstrcmp("-V", argv[1]) == 0)) {
print_version(PROGRAMNAME);
@@ -130,12 +130,12 @@ int main(int argc, char *argv[])
switch (state) {
case 1: /* counting input files */
- if (opt.fcount < 29) {
- (void) HDstrcpy(opt.infiles[opt.fcount].datafile, argv[i]);
- in = &(opt.infiles[opt.fcount].in);
- opt.infiles[opt.fcount].config = 0;
- setDefaultValues(in, opt.fcount);
- opt.fcount++;
+ if (opt->fcount < 29) {
+ (void) HDstrcpy(opt->infiles[opt->fcount].datafile, argv[i]);
+ in = &(opt->infiles[opt->fcount].in);
+ opt->infiles[opt->fcount].config = 0;
+ setDefaultValues(in, opt->fcount);
+ opt->fcount++;
}
else {
(void) HDfprintf(stderr, err9, argv[i]);
@@ -148,8 +148,8 @@ int main(int argc, char *argv[])
break;
case 3: /* get configfile name */
- (void) HDstrcpy(opt.infiles[opt.fcount-1].configfile, argv[i]);
- opt.infiles[opt.fcount - 1].config = 1;
+ (void) HDstrcpy(opt->infiles[opt->fcount-1].configfile, argv[i]);
+ opt->infiles[opt->fcount - 1].config = 1;
break;
case 4: /* -o found; look for outfile */
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
(void) HDfprintf(stderr, err10, argv[i]);
goto err;
}
- (void) HDstrcpy(opt.outfile, argv[i]);
+ (void) HDstrcpy(opt->outfile, argv[i]);
outfile_named = TRUE;
break;
@@ -232,11 +232,11 @@ int main(int argc, char *argv[])
goto err;
}
- if (process(&opt) == -1)
+ if (process(opt) == -1)
goto err;
- for (i = 0; i < opt.fcount; i++) {
- in = &(opt.infiles[i].in);
+ for (i = 0; i < opt->fcount; i++) {
+ in = &(opt->infiles[i].in);
if (in->sizeOfDimension)
HDfree(in->sizeOfDimension);
if (in->sizeOfChunk)
@@ -248,12 +248,13 @@ int main(int argc, char *argv[])
if (in->data)
HDfree(in->data);
}
+ HDfree(opt);
- return (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
err:
(void) HDfprintf(stderr, "%s", err4);
- for (i = 0; i < opt.fcount; i++) {
- in = &(opt.infiles[i].in);
+ for (i = 0; i < opt->fcount; i++) {
+ in = &(opt->infiles[i].in);
if (in->sizeOfDimension)
HDfree(in->sizeOfDimension);
if (in->sizeOfChunk)
@@ -265,7 +266,9 @@ err:
if (in->data)
HDfree(in->data);
}
- return (EXIT_FAILURE);
+ HDfree(opt);
+
+ return EXIT_FAILURE;
}
static int gtoken(char *s)
@@ -3732,8 +3735,8 @@ static int getExternalFilename(struct Input *in, FILE *strm)
return (-1);
}
- in->externFilename = (char *) HDmalloc ((size_t) (HDstrlen(temp)) * sizeof(char));
- (void) HDstrcpy(in->externFilename, temp);
+ in->externFilename = (char *) HDmalloc ((size_t) (HDstrlen(temp) + 1) * sizeof(char));
+ (void) HDstrncpy(in->externFilename, temp, HDstrlen(temp) + 1);
return (0);
}
diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c
index 009e527..8b61112 100644
--- a/tools/src/h5jam/h5jam.c
+++ b/tools/src/h5jam/h5jam.c
@@ -120,13 +120,6 @@ usage (const char *prog)
static void
leave(int ret)
{
- if (ub_file)
- HDfree (ub_file);
- if (input_file)
- HDfree (input_file);
- if (output_file)
- HDfree (output_file);
-
h5tools_close();
HDexit(ret);
@@ -195,8 +188,6 @@ main (int argc, const char *argv[])
int ufid = -1;
int h5fid = -1;
int ofid = -1;
- void *edata;
- H5E_auto2_t func;
hid_t ifile = H5I_INVALID_HID;
hid_t plist = H5I_INVALID_HID;
herr_t status;
@@ -214,20 +205,20 @@ main (int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
parse_command_line(argc, argv);
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
if (ub_file == NULL) {
/* no user block */
error_msg("missing argument for -u <user_file>.\n");
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
testval = H5Fis_accessible(ub_file, H5P_DEFAULT);
@@ -235,13 +226,15 @@ main (int argc, const char *argv[])
if (testval > 0) {
error_msg("-u <user_file> cannot be HDF5 file, but it appears to be an HDF5 file.\n");
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
if (input_file == NULL) {
error_msg("missing argument for -i <HDF5 file>.\n");
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
testval = H5Fis_accessible(input_file, H5P_DEFAULT);
@@ -249,45 +242,49 @@ main (int argc, const char *argv[])
if (testval <= 0) {
error_msg("Input HDF5 file \"%s\" is not HDF5 format.\n", input_file);
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
ifile = H5Fopen(input_file, H5F_ACC_RDONLY, H5P_DEFAULT);
if (ifile < 0) {
error_msg("Can't open input HDF5 file \"%s\"\n", input_file);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
plist = H5Fget_create_plist(ifile);
if (plist < 0) {
error_msg("Can't get file creation plist for file \"%s\"\n", input_file);
- H5Fclose(ifile);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
status = H5Pget_userblock(plist, &usize);
if (status < 0) {
error_msg("Can't get user block for file \"%s\"\n", input_file);
- H5Pclose(plist);
- H5Fclose(ifile);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
H5Pclose(plist);
+ plist = H5I_INVALID_HID;
H5Fclose(ifile);
+ ifile = H5I_INVALID_HID;
ufid = HDopen(ub_file, O_RDONLY);
if(ufid < 0) {
error_msg("unable to open user block file \"%s\"\n", ub_file);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
res = HDfstat(ufid, &sbuf);
if(res < 0) {
error_msg("Can't stat file \"%s\"\n", ub_file);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
fsize = (off_t)sbuf.st_size;
@@ -295,16 +292,15 @@ main (int argc, const char *argv[])
h5fid = HDopen(input_file, O_RDONLY);
if(h5fid < 0) {
error_msg("unable to open HDF5 file for read \"%s\"\n", input_file);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
res = HDfstat(h5fid, &sbuf2);
if(res < 0) {
error_msg("Can't stat file \"%s\"\n", input_file);
- HDclose (h5fid);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
h5fsize = (hsize_t)sbuf2.st_size;
@@ -314,9 +310,8 @@ main (int argc, const char *argv[])
if (ofid < 0) {
error_msg("unable to open output file \"%s\"\n", output_file);
- HDclose (h5fid);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
}
else {
@@ -324,9 +319,8 @@ main (int argc, const char *argv[])
if (ofid < 0) {
error_msg("unable to create output file \"%s\"\n", output_file);
- HDclose (h5fid);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
}
@@ -365,12 +359,11 @@ main (int argc, const char *argv[])
/* pad the ub */
if(write_pad(ofid, where, &where) < 0) {
error_msg("Can't pad file \"%s\"\n", output_file);
- HDclose (h5fid);
- HDclose (ufid);
- HDclose (ofid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
} /* end if */
+done:
if(ub_file)
HDfree(ub_file);
if(input_file)
@@ -378,6 +371,11 @@ main (int argc, const char *argv[])
if(output_file)
HDfree(output_file);
+ if(plist >= 0)
+ H5Pclose(plist);
+ if(ifile >= 0)
+ H5Fclose(ifile);
+
if(ufid >= 0)
HDclose(ufid);
if(h5fid >= 0)
@@ -385,7 +383,7 @@ main (int argc, const char *argv[])
if(ofid >= 0)
HDclose(ofid);
- return h5tools_getstatus();
+ leave(h5tools_getstatus());
}
/*-------------------------------------------------------------------------
diff --git a/tools/src/h5jam/h5unjam.c b/tools/src/h5jam/h5unjam.c
index 203522b..b48e2c1 100644
--- a/tools/src/h5jam/h5unjam.c
+++ b/tools/src/h5jam/h5unjam.c
@@ -185,6 +185,13 @@ done:
return EXIT_FAILURE;
}
+static void
+leave(int ret)
+{
+ h5tools_close();
+ HDexit(ret);
+}
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -197,8 +204,6 @@ done:
int
main(int argc, const char *argv[])
{
- void *edata;
- H5E_auto2_t func;
hid_t ifile = H5I_INVALID_HID;
hid_t plist = H5I_INVALID_HID;
off_t fsize;
@@ -211,16 +216,15 @@ main(int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
if(EXIT_FAILURE == parse_command_line(argc, argv))
goto done;
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
if (input_file == NULL) {
/* no user block */
error_msg("missing argument for HDF5 file input.\n");
@@ -319,9 +323,7 @@ done:
HDfree(ub_file);
}
- h5tools_close();
-
- return h5tools_getstatus();
+ leave(h5tools_getstatus());
}
/*-------------------------------------------------------------------------
diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c
index f3f9ede..e239cbc 100644
--- a/tools/src/h5ls/h5ls.c
+++ b/tools/src/h5ls/h5ls.c
@@ -218,6 +218,12 @@ usage (void)
PRINTVALSTREAM(rawoutstream, " ...<kerberos cache path>,<username>,<buffer size>)\n");
PRINTVALSTREAM(rawoutstream, " If absent or A == '(,,,,)', all default values are used.\n");
PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag is not 'hdfs'.\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, "\n");
PRINTVALSTREAM(rawoutstream, " file/OBJECT\n");
PRINTVALSTREAM(rawoutstream, " Each object consists of an HDF5 file name optionally followed by a\n");
@@ -1292,230 +1298,6 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind)
h5tools_str_append(buffer,"%lu-byte class-%u unknown", (unsigned long)H5Tget_size(type), (unsigned)data_class);
}
-/*
- *
- */
-static void
-dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, H5R_ref_t *ref_buf, int ndims)
-{
- hid_t new_obj_id = H5I_INVALID_HID;
- hid_t new_obj_sid = H5I_INVALID_HID;
- hsize_t elmt_counter = 0; /*counts the # elements printed. */
- size_t ncols = 80; /* available output width */
- int i;
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t datactx; /* print context */
-
- H5TOOLS_START_DEBUG("");
-
- datactx = *ctx; /* print context */
- /* Assume entire data space to be printed */
- if (datactx.ndims > 0)
- for (i = 0; (unsigned)i < datactx.ndims; i++)
- datactx.p_min_idx[i] = 0;
- datactx.need_prefix = TRUE;
-
- HDmemset(&buffer, 0, sizeof(h5tools_str_t));
- for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) {
- H5O_type_t obj_type = -1; /* Object type */
- H5R_type_t ref_type; /* Reference type */
-
- H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos);
-
- datactx.need_prefix = TRUE;
- h5tools_str_reset(&buffer);
- H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i);
- h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx);
- h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims);
-
- ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]);
- switch (ref_type) {
- case H5R_OBJECT1:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
- if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
- switch (obj_type) {
- case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- datactx.indent_level++;
- h5tools_dump_dset(stream, info, &datactx, new_obj_id);
- datactx.indent_level--;
- if(H5Dclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
- if(H5Rdestroy(&ref_buf[i]) < 0)
- H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1:H5O_TYPE_DATASET failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed");
- break;
-
- case H5O_TYPE_GROUP:
- case H5O_TYPE_NAMED_DATATYPE:
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- break;
- } /* end switch */
- }
- else
- H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed");
- break;
- case H5R_DATASET_REGION1:
- H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- datactx.indent_level++;
- h5tools_dump_dset(stream, info, &datactx, new_obj_id);
- datactx.indent_level--;
- if(H5Dclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed");
- if(H5Rdestroy(&ref_buf[i]) < 0)
- H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION1 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
- break;
- case H5R_OBJECT2:
- H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
- if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
- switch (obj_type) {
- case H5O_TYPE_GROUP:
- break;
-
- case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- datactx.indent_level++;
- h5tools_dump_dset(stream, info, &datactx, new_obj_id);
- datactx.indent_level--;
- if(H5Oclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
- if(H5Rdestroy(&ref_buf[i]) < 0)
- H5TOOLS_INFO("H5Rdestroy H5R_OBJECT2 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed");
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- break;
-
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- break;
- } /* end switch */
- }
- else
- H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed");
- break;
- case H5R_DATASET_REGION2:
- H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
-
- if (info->line_ncols > 0)
- ncols = info->line_ncols;
-
- /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
- H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
- else {
- if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
- H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " {");
- h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- datactx.need_prefix = TRUE;
- datactx.indent_level++;
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NULL");
- h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- datactx.indent_level--;
- datactx.need_prefix = TRUE;
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "}");
- h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- }
- else {
- H5S_sel_type region_type;
-
- region_type = H5Sget_select_type(new_obj_sid);
- if(region_type == H5S_SEL_POINTS) {
- /* Print point information */
- H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2");
- h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info, &datactx,
- &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
- }
- else if(region_type == H5S_SEL_HYPERSLABS) {
- /* Print block information */
- H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2");
- h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info, &datactx,
- &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter);
- }
- else
- H5TOOLS_INFO("invalid region type");
- } /* end else to if (h5tools_is_zero(... */
- if(H5Sclose(new_obj_sid) < 0)
- H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
- }
- else
- H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
- if(H5Dclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
- if(H5Rdestroy(&ref_buf[i]) < 0)
- H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION2 failed");
- }
- break;
- case H5R_ATTR:
- H5TOOLS_DEBUG("ref_type is H5R_ATTR");
- if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- if(H5Aclose(new_obj_id) < 0)
- H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
- if(H5Rdestroy(&ref_buf[i]) < 0)
- H5TOOLS_INFO("H5Rdestroy H5R_ATTR failed");
- }
- else {
- H5TOOLS_DEBUG("NULL H5R_ATTR");
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " {");
- h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- datactx.need_prefix = TRUE;
- datactx.indent_level++;
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NULL");
- h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- datactx.indent_level--;
- datactx.need_prefix = TRUE;
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "}");
- h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
-
- H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
- }
- break;
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- default:
- break;
- } /* end switch */
-
- H5TOOLS_DEBUG("finished reference loop:%d",i);
- } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */
-
- h5tools_str_close(&buffer);
-
- PRINTVALSTREAM(stream, "\n");
-
- H5TOOLS_ENDDEBUG("");
-}
-
/*-------------------------------------------------------------------------
* Function: dump_dataset_values
*
@@ -1531,7 +1313,6 @@ dump_dataset_values(hid_t dset)
hid_t space = H5I_INVALID_HID;
hsize_t total_size[H5S_MAX_RANK];
int ndims;
- size_t i;
char string_prefix[64];
static char fmt_double[16];
static char fmt_float[16];
@@ -1647,13 +1428,9 @@ dump_dataset_values(hid_t dset)
H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims);
/* Assume entire data space to be printed */
- if (ctx.ndims > 0)
- for (i = 0; i < (size_t)ctx.ndims; i++)
- ctx.p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(space, total_size, NULL);
- if (ctx.ndims > 0)
- init_acc_pos(&ctx, total_size);
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
+
ctx.need_prefix = TRUE;
if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
@@ -1663,7 +1440,9 @@ dump_dataset_values(hid_t dset)
H5TOOLS_INFO("H5Dread reference failed");
H5TOOLS_GOTO_DONE_NO_RET();
}
- dump_reference(rawoutstream, info, &ctx, dset, ref_buf, ndims);
+ h5tools_dump_reference(rawoutstream, info, &ctx, dset, ref_buf, ndims);
+
+ PRINTVALSTREAM(rawoutstream, "\n");
HDfree(ref_buf);
}
}
@@ -1701,7 +1480,6 @@ dump_attribute_values(hid_t attr)
hid_t space = H5I_INVALID_HID;
hsize_t total_size[H5S_MAX_RANK];
int ndims;
- size_t i;
char string_prefix[64];
static char fmt_double[16];
static char fmt_float[16];
@@ -1818,13 +1596,9 @@ dump_attribute_values(hid_t attr)
H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims);
/* Assume entire data space to be printed */
- if (ctx.ndims > 0)
- for (i = 0; i < (size_t)ctx.ndims; i++)
- ctx.p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(space, total_size, NULL);
- if (ctx.ndims > 0)
- init_acc_pos(&ctx, total_size);
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
+
ctx.need_prefix = TRUE;
if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
@@ -1835,7 +1609,9 @@ dump_attribute_values(hid_t attr)
H5TOOLS_GOTO_DONE_NO_RET();
}
ctx.indent_level++;
- dump_reference(rawoutstream, info, &ctx, attr, ref_buf, ndims);
+ h5tools_dump_reference(rawoutstream, info, &ctx, attr, ref_buf, ndims);
+
+ PRINTVALSTREAM(rawoutstream, "\n");
ctx.indent_level--;
HDfree(ref_buf);
}
@@ -2334,13 +2110,13 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
} /* end if */
else {
- hid_t obj = H5I_INVALID_HID; /* ID of object opened */
+ hid_t obj_id = H5I_INVALID_HID; /* ID of object opened */
/* Open the object. Not all objects can be opened. If this is the case
* then return right away.
*/
H5TOOLS_DEBUG("Open object name=%s", name);
- if (obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
+ if (obj_type >= 0 && (obj_id = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " *ERROR*\n");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
@@ -2350,7 +2126,7 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
/* List the first line of information for the object. */
H5TOOLS_DEBUG("Object type:%d", obj_type);
if (obj_type >= 0 && dispatch_g[obj_type].list1)
- (dispatch_g[obj_type].list1)(obj);
+ (dispatch_g[obj_type].list1)(obj_id);
if (!iter->symlink_target || (verbose_g > 0)) {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\n");
@@ -2362,23 +2138,24 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
if (verbose_g > 0) {
size_t buf_size = 0;
char* comment = NULL;
- char* obj_addr_str = NULL;
+ char* obj_tok_str = NULL;
ssize_t cmt_bufsize = -1;
+ hbool_t supported = FALSE;
/* Display attributes */
H5TOOLS_DEBUG("Display attributes");
if (obj_type >= 0)
- H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
+ H5Aiterate2(obj_id, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
/* Object location & reference count */
- H5Otoken_to_str(obj, &oinfo->token, &obj_addr_str);
+ H5Otoken_to_str(obj_id, &oinfo->token, &obj_tok_str);
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_addr_str);
+ h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_tok_str);
h5tools_str_append(&buffer, " %-10s %u\n", "Links:", (unsigned)oinfo->rc);
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- H5free_memory(obj_addr_str);
+ H5free_memory(obj_tok_str);
/* Modification time */
if (oinfo->mtime > 0) {
@@ -2397,36 +2174,42 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
} /* end if */
} /* end if */
- /* Object comment */
- cmt_bufsize = H5Oget_comment(obj, comment, buf_size);
-
- /* if the actual length of the comment is longer than cmt_bufsize, then call
- * H5Oget_comment again with the correct value.
- * If the call to H5Oget_comment returned an error, skip this block */
- if (cmt_bufsize > 0) {
- comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */
- if (comment) {
- cmt_bufsize = H5Oget_comment(obj, comment, (size_t)cmt_bufsize);
- if (cmt_bufsize > 0) {
- comment[cmt_bufsize] = 0;
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " %-10s \"", "Comment:");
- print_string(&buffer, comment, FALSE);
- h5tools_str_append(&buffer, "\"\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- } /* end if */
- HDfree(comment);
+ /* Only emit comments if the VOL connector supports that */
+ H5VLquery_optional(obj_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported);
+
+ if (supported) {
+
+ /* Object comment */
+ cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
+
+ /* if the actual length of the comment is longer than cmt_bufsize, then call
+ * H5Oget_comment again with the correct value.
+ */
+ if (cmt_bufsize > 0) {
+ comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */
+ if (comment) {
+ cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize);
+ if (cmt_bufsize > 0) {
+ comment[cmt_bufsize] = 0;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " %-10s \"", "Comment:");
+ print_string(&buffer, comment, FALSE);
+ h5tools_str_append(&buffer, "\"\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ } /* end if */
+ HDfree(comment);
+ }
}
}
} /* end if */
/* Detailed list for object */
if (obj_type >= 0 && dispatch_g[obj_type].list2)
- (dispatch_g[obj_type].list2)(obj, name);
+ (dispatch_g[obj_type].list2)(obj_id, name);
/* Close the object. */
if (obj_type >= 0)
- H5Oclose(obj);
+ H5Oclose(obj_id);
} /* end else */
done:
@@ -2833,57 +2616,50 @@ leave(int ret)
int
main(int argc, const char *argv[])
{
- hid_t file_id = H5I_INVALID_HID;
- char *fname = NULL, *oname = NULL, *x;
- const char *s = NULL;
- char *rest;
- int argno;
- static char root_name[] = "/";
- char drivername[50];
- const char *preferred_driver = NULL;
- int err_exit = 0;
- hid_t fapl_id = H5P_DEFAULT;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
+ hid_t file_id = H5I_INVALID_HID;
+ char *fname = NULL, *oname = NULL, *x;
+ const char *s = NULL;
+ char *rest;
+ int argno;
+ static char root_name[] = "/";
+ char drivername[50];
+ const char *preferred_driver = NULL;
+ int err_exit = 0;
+ hid_t fapl_id = H5P_DEFAULT;
+ hbool_t custom_vol_fapl = FALSE;
+ h5tools_vol_info_t vol_info;
#ifdef H5_HAVE_ROS3_VFD
- /* default "anonymous" s3 configuration */
+ /* Default "anonymous" S3 configuration */
H5FD_ros3_fapl_t ros3_fa = {
- 1, /* fapl version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+ 1, /* Structure Version */
+ false, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
-#endif /* H5_HVAE_ROS3_VFD */
+#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
- /* "default" HDFS configuration */
+ /* "Default" HDFS configuration */
H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
+ /* Initialize fapl info struct */
+ HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t));
/* Build object display table */
DISPATCH(H5O_TYPE_GROUP, "Group", NULL, NULL);
@@ -2948,6 +2724,19 @@ main(int argc, const char *argv[])
else if (!HDstrncmp(argv[argno], "--vfd=", (size_t)6)) {
preferred_driver = argv[argno]+6;
}
+ else if (!HDstrncmp(argv[argno], "--vol-value=", (size_t)12)) {
+ vol_info.type = VOL_BY_VALUE;
+ vol_info.u.value = (H5VL_class_value_t)HDatoi(argv[argno]+12);
+ custom_vol_fapl = TRUE;
+ }
+ else if (!HDstrncmp(argv[argno], "--vol-name=", (size_t)11)) {
+ vol_info.type = VOL_BY_NAME;
+ vol_info.u.name = argv[argno]+11;
+ custom_vol_fapl = TRUE;
+ }
+ else if (!HDstrncmp(argv[argno], "--vol-info=", (size_t)11)) {
+ vol_info.info_string = argv[argno]+11;
+ }
else if (!HDstrncmp(argv[argno], "--width=", (size_t)8)) {
width_g = (int)HDstrtol(argv[argno]+8, &rest, 0);
@@ -3005,18 +2794,9 @@ main(int argc, const char *argv[])
}
else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) {
-#ifndef H5_HAVE_ROS3_VFD
- HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
- usage();
- leave(EXIT_FAILURE);
-#else
- unsigned nelems = 0;
- char *start = NULL;
- char *s3cred_src = NULL;
- char **s3cred = NULL;
- char const *ccred[3];
- /* try to parse s3 credentials tuple
- */
+#ifdef H5_HAVE_ROS3_VFD
+ char const *start = NULL;
+
start = strchr(argv[argno], '=');
if (start == NULL) {
HDfprintf(rawerrorstream, "Error: Unable to parse null credentials tuple\n"
@@ -3025,124 +2805,38 @@ main(int argc, const char *argv[])
leave(EXIT_FAILURE);
}
start++;
- if (FAIL == parse_tuple((const char *)start, ',', &s3cred_src, &nelems, &s3cred)) {
- HDfprintf(rawerrorstream, "Error: Unable to parse S3 credentials\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
- /* sanity-check tuple count
- */
- if (nelems != 3) {
- HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
- ccred[0] = (const char *)s3cred[0];
- ccred[1] = (const char *)s3cred[1];
- ccred[2] = (const char *)s3cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n");
+
+ if (h5tools_parse_ros3_fapl_tuple(start, ',', &ros3_fa) < 0) {
+ HDfprintf(rawerrorstream, "Error: failed to parse S3 VFD credential info\n\n");
usage();
leave(EXIT_FAILURE);
}
- HDfree(s3cred);
- HDfree(s3cred_src);
-#endif /* H5_HAVE_ROS3_VFD */
-
+#else
+ HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
+ usage();
+ leave(EXIT_FAILURE);
+#endif
}
else if (!HDstrncmp(argv[argno], "--hdfs-attrs=", (size_t)13)) {
-#ifndef H5_HAVE_LIBHDFS
- PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n");
- leave(EXIT_FAILURE);
-#else
- /* Parse received configuration data and set fapl config struct */
-
- hbool_t _debug = FALSE;
- unsigned nelems = 0;
- char const *start = NULL;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
-
- /* try to parse tuple
- */
- if (_debug) {
- HDfprintf(stderr, "configuring hdfs...\n");
- }
+#ifdef H5_HAVE_LIBHDFS
+ char const *start = NULL;
+
start = argv[argno]+13; /* should never segfault: worst case of */
if (*start != '(') { /* null-termintor after '='. */
-
- if (_debug) {
- HDfprintf(stderr, " no tuple.\n");
- }
- usage();
- leave(EXIT_FAILURE);
- }
- if (FAIL == parse_tuple((const char *)start, ',', &props_src, &nelems, &props)) {
- HDfprintf(stderr, " unable to parse tuple.\n");
usage();
leave(EXIT_FAILURE);
}
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- HDfprintf(stderr, " expected 5-ple, got `%d`\n", nelems);
+ if (h5tools_parse_hdfs_fapl_tuple(start, ',', &hdfs_fa) < 0) {
+ HDfprintf(rawerrorstream, "Error: failed to parse HDFS VFD configuration info\n\n");
usage();
leave(EXIT_FAILURE);
}
- if (_debug) {
- HDfprintf(stderr, " got hdfs-attrs tuple: `(%s,%s,%s,%s,%s)`\n", props[0], props[1], props[2], props[3], props[4]);
- }
-
- /* Populate fapl configuration structure with given properties.
- * WARNING: No error-checking is done on length of input strings...
- * Silent overflow is possible, albeit unlikely.
- */
- if (HDstrncmp(props[0], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting namenode name: %s\n", props[0]);
- }
- HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0]));
- }
- if (HDstrncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- HDfprintf(stderr, " supposed port number wasn't.\n");
- leave(EXIT_FAILURE);
- }
- if (_debug) {
- HDfprintf(stderr, " setting namenode port: %lu\n", k);
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (HDstrncmp(props[2], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting kerb cache path: %s\n", props[2]);
- }
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
- }
- if (HDstrncmp(props[3], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting username: %s\n", props[3]);
- }
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
- }
- if (HDstrncmp(props[4], "", 1)) {
- k = HDstrtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- HDfprintf(stderr, " supposed buffersize number wasn't.\n");
- leave(EXIT_FAILURE);
- }
- if (_debug) {
- HDfprintf(stderr, " setting stream buffer size: %lu\n", k);
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
-#endif /* H5_HAVE_LIBHDFS */
-
+#else
+ HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n");
+ usage();
+ leave(EXIT_FAILURE);
+#endif
}
else if('-'!=argv[argno][1]) {
/* Single-letter switches */
@@ -3222,6 +2916,9 @@ main(int argc, const char *argv[])
}
} /* end for */
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* If no arguments remain then print a usage message (instead of doing
* absolutely nothing ;-) */
if (argno >= argc) {
@@ -3235,46 +2932,41 @@ main(int argc, const char *argv[])
leave(EXIT_FAILURE);
}
+ /* Setup a custom fapl for file accesses */
+ if (custom_vol_fapl) {
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &vol_info, NULL)) < 0) {
+ error_msg("failed to setup file access property list (fapl) for file\n");
+ leave(EXIT_FAILURE);
+ }
+ }
+
if (preferred_driver) {
- void *conf_fa = NULL;
+ h5tools_vfd_info_t vfd_info;
- if (!HDstrcmp(preferred_driver, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
- HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD not enabled.\n\n");
- usage();
- leave(EXIT_FAILURE);
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+ vfd_info.info = NULL;
+ vfd_info.name = preferred_driver;
- }
- else if (!HDstrcmp(preferred_driver, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n");
+ if (!HDstrcmp(preferred_driver, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ vfd_info.info = (void *)&ros3_fa;
+#else
+ HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
leave(EXIT_FAILURE);
+#endif
+ }
+ else if (!HDstrcmp(preferred_driver, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ vfd_info.info = (void *)&hdfs_fa;
#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
+ HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n");
+ leave(EXIT_FAILURE);
+#endif
}
- if (conf_fa != NULL) {
- HDassert(fapl_id == H5P_DEFAULT);
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- HDfprintf(rawerrorstream, "Error: Unable to create fapl entry\n\n");
- leave(EXIT_FAILURE);
- }
- if (0 == h5tools_set_configured_fapl(fapl_id, preferred_driver, conf_fa)) {
- HDfprintf(rawerrorstream, "Error: Unable to set fapl\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) {
+ HDfprintf(rawerrorstream, "Error: Unable to create FAPL for file access\n\n");
+ leave(EXIT_FAILURE);
}
- } /* preferred_driver defined */
-
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
}
/* Each remaining argument is an hdf5 file followed by an optional slash
@@ -3301,12 +2993,8 @@ main(int argc, const char *argv[])
file_id = H5I_INVALID_HID;
while (fname && *fname) {
- if (fapl_id != H5P_DEFAULT) {
- file_id = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- }
- else {
- file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, preferred_driver, drivername, sizeof drivername);
- }
+ file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id,
+ (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, drivername, sizeof drivername);
if (file_id >= 0) {
if (verbose_g)
@@ -3339,7 +3027,6 @@ main(int argc, const char *argv[])
x = oname;
if (NULL == (oname = HDstrdup(oname))) {
HDfprintf(rawerrorstream, "memory allocation failed\n");
- H5Eset_auto2(H5E_DEFAULT, func, edata);
leave(EXIT_FAILURE);
}
*x = '\0';
@@ -3384,7 +3071,6 @@ main(int argc, const char *argv[])
h5tools_str_reset(&buffer);
print_obj_name(&buffer, &iter, oname, "**NOT FOUND**");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- H5Eset_auto2(H5E_DEFAULT, func, edata);
leave(EXIT_FAILURE);
} /* end if */
} /* end if */
@@ -3394,7 +3080,6 @@ main(int argc, const char *argv[])
/* Open the object and display it's information */
if (li.type == H5L_TYPE_HARD) {
if (visit_obj(file_id, oname, &iter) < 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
leave(EXIT_FAILURE);
}
} /* end if(li.type == H5L_TYPE_HARD) */
@@ -3425,12 +3110,10 @@ main(int argc, const char *argv[])
if (fapl_id != H5P_DEFAULT) {
if (0 < H5Pclose(fapl_id)) {
HDfprintf(rawerrorstream, "Error: Unable to set close fapl entry\n\n");
- H5Eset_auto2(H5E_DEFAULT, func, edata);
leave(EXIT_FAILURE);
}
}
- H5Eset_auto2(H5E_DEFAULT, func, edata);
if (err_exit)
leave(EXIT_FAILURE);
else
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index 8eeaa0e..b2cb02b 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -79,6 +79,8 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest)
options->layout_g = H5D_LAYOUT_ERROR;
options->low_bound = H5F_LIBVER_EARLIEST;
options->high_bound = H5F_LIBVER_LATEST;
+ options->fin_fapl = H5P_DEFAULT;
+ options->fout_fapl = H5P_DEFAULT;
for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) {
options->filter_g[n].filtn = -1;
@@ -257,7 +259,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
dt->next = *named_dt_head_p;
*named_dt_head_p = dt;
- /* Update the address and id */
+ /* Update the token/address and id */
HDmemcpy(&dt->obj_token, &travt->objs[i].obj_token, sizeof(H5O_token_t));
dt->id_out = H5I_INVALID_HID;
@@ -280,7 +282,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
dt_ret->next = *named_dt_head_p;
*named_dt_head_p = dt_ret;
- /* Update the address and id */
+ /* Update the token/address and id */
HDmemcpy(&dt_ret->obj_token, &oinfo.token, sizeof(H5O_token_t));
dt_ret->id_out = H5I_INVALID_HID;
} /* end if requested datatype not found */
@@ -751,7 +753,8 @@ check_objects(const char* fname, pack_opt_t *options)
* open the file
*-------------------------------------------------------------------------
*/
- if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0)
+ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl,
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR);
/*-------------------------------------------------------------------------
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index 52ecb0e..caa1166 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -114,6 +114,8 @@ typedef struct {
hbool_t latest; /*pack file with the latest file format */
H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */
H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */
+ hid_t fin_fapl; /* FAPL to use for opening the input file */
+ hid_t fout_fapl; /* FAPL to use for opening/creating the output file */
int grp_compact; /* Set the maximum number of links to store as header messages in the group */
int grp_indexed; /* Set the minimum number of links to store in the indexed format */
int msg_size[8]; /* Minimum size of shared messages: dataspace,
@@ -151,7 +153,7 @@ int h5repack_addlayout(const char* str, pack_opt_t *options);
int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest);
int h5repack_end(pack_opt_t *options);
int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options);
-int h5repack_cmp_pl(const char *fname1, const char *fname2);
+int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl);
/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr()
* and struct named_dt_t were located in h5repack_copy.c as static prior to
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index 1044244..b1d6ab4 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -67,7 +67,6 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
hid_t grp_in = H5I_INVALID_HID; /* group ID */
hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
- hid_t fapl = H5P_DEFAULT; /* file access property list ID */
trav_table_t *travt = NULL;
hsize_t ub_size = 0; /* size of user block */
H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */
@@ -85,7 +84,8 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
* open input file
*-------------------------------------------------------------------------
*/
- if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0)
+ if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl,
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t) 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR);
/* get user block size and file space strategy/persist/threshold */
@@ -122,12 +122,14 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
if(options->latest)
options->low_bound = options->high_bound = H5F_LIBVER_LATEST;
+
/* Create file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
+ if (options->fout_fapl == H5P_DEFAULT)
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
/* It can be default, latest or other settings by users */
- if(H5Pset_libver_bounds(fapl, options->low_bound, options->high_bound) < 0)
+ if(H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds");
/* Check if we need to create a non-default file creation property list */
@@ -218,12 +220,12 @@ print_user_block(fnamein, fidin);
*/
if (options->alignment > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT)
+ if (options->fout_fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
- if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
+ if (H5Pset_alignment(options->fout_fapl, options->threshold, options->alignment) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_alignment failed to set alignment");
}
@@ -233,12 +235,12 @@ print_user_block(fnamein, fidin);
*/
if (options->meta_block_size > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT)
+ if (options->fout_fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
- if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0)
+ if (H5Pset_meta_block_size(options->fout_fapl, options->meta_block_size) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_meta_block_size failed to set metadata block size");
}
@@ -297,7 +299,7 @@ print_user_block(fnamein, fidin);
if (options->verbose)
HDprintf("Making new file ...\n");
- if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, options->fout_fapl)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Fcreate could not create file <%s>:", fnameout);
/*-------------------------------------------------------------------------
@@ -352,7 +354,6 @@ done:
H5E_BEGIN_TRY {
H5Pclose(fcpl_in);
H5Pclose(gcpl_in);
- H5Pclose(fapl);
H5Pclose(fcpl);
H5Gclose(grp_in);
H5Fclose(fidin);
@@ -702,11 +703,14 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
break;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_DATASET
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_DATASET
+ *-------------------------------------------------------------------------
+ */
case H5TRAV_TYPE_DATASET:
+ {
+ hbool_t use_h5ocopy;
+
has_filter = 0;
req_filter = 0;
@@ -764,9 +768,47 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
* otherwise we do a copy using H5Ocopy
*-------------------------------------------------------------------------
*/
- if (options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref || is_named) {
+ use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1
+ || options->all_layout == 1 || is_ref || is_named);
+
+ /*
+ * Check if we are using different source and destination VOL connectors.
+ * In this case, we currently have to avoid usage of H5Ocopy since it
+ * doesn't support this.
+ */
+ if (use_h5ocopy && (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) {
+ hid_t in_vol_id;
+ hid_t out_vol_id;
+ hid_t default_vol_id;
+
+ if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+
+ if (options->fin_fapl == H5P_DEFAULT)
+ in_vol_id = default_vol_id;
+ else
+ if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+ if (options->fout_fapl == H5P_DEFAULT)
+ out_vol_id = default_vol_id;
+ else
+ if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+
+ if (in_vol_id != out_vol_id)
+ use_h5ocopy = FALSE;
+
+ if (in_vol_id != default_vol_id)
+ if (H5VLclose(in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (out_vol_id != default_vol_id)
+ if (H5VLclose(out_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (H5VLclose(default_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ }
+ if (!use_h5ocopy) {
int j;
if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
@@ -1135,7 +1177,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
} /* end whether we have request for filter/chunking */
+
break;
+ } /* H5TRAV_TYPE_DATASET */
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_NAMED_DATATYPE
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index 72ed7d7..0ad61c0 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -62,6 +62,12 @@ static struct long_options l_opts[] = {
{ "sort_by", require_arg, 'q' },
{ "sort_order", require_arg, 'z' },
{ "enable-error-stack", no_arg, 'E' },
+ { "src-vol-value", require_arg, '1' },
+ { "src-vol-name", require_arg, '2' },
+ { "src-vol-info", require_arg, '3' },
+ { "dst-vol-value", require_arg, '4' },
+ { "dst-vol-name", require_arg, '5' },
+ { "dst-vol-info", require_arg, '6' },
{ NULL, 0, '\0' }
};
@@ -86,6 +92,18 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n");
PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
PRINTVALSTREAM(rawoutstream, " occur\n");
+ PRINTVALSTREAM(rawoutstream, " --src-vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " input HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --src-vol-name Name of the VOL connector to use for opening the input\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --src-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --dst-vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " output HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --dst-vol-name Name of the VOL connector to use for opening the output\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n");
PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n");
PRINTVALSTREAM(rawoutstream, " --low and --high\n");
@@ -139,7 +157,8 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 3: This is H5F_LIBVER_V112 in H5F_libver_t struct\n");
- PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V112 for this release\n");
+ PRINTVALSTREAM(rawoutstream, " 4: This is H5F_LIBVER_V114 in H5F_libver_t struct\n");
+ PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n");
PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n");
@@ -292,6 +311,8 @@ int read_info(const char *filename, pack_opt_t *options)
/* cycle until end of file reached */
while (1) {
+ if (EOF == fscanf(fp, "%9s", stype))
+ break;
/* Info indicator must be for layout or filter */
if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) {
@@ -333,7 +354,7 @@ int read_info(const char *filename, pack_opt_t *options)
if (!HDstrcmp(stype, "-l")) {
if (h5repack_addlayout(comp_info, options) == -1) {
- error_msg("could not add chunck option\n");
+ error_msg("could not add chunk option\n");
h5tools_setstatus(EXIT_FAILURE);
ret_value = EXIT_FAILURE;
goto done;
@@ -411,9 +432,18 @@ set_sort_order(const char *form)
static
int parse_command_line(int argc, const char **argv, pack_opt_t* options)
{
+ h5tools_vol_info_t in_vol_info;
+ h5tools_vol_info_t out_vol_info;
+ hbool_t custom_in_fapl = FALSE;
+ hbool_t custom_out_fapl = FALSE;
+ hid_t tmp_fapl = H5I_INVALID_HID;
int bound, opt;
int ret_value = 0;
+ /* Initialize fapl info structs */
+ HDmemset(&in_vol_info, 0, sizeof(h5tools_vol_info_t));
+ HDmemset(&out_vol_info, 0, sizeof(h5tools_vol_info_t));
+
/* parse command line options */
while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) {
switch ((char) opt) {
@@ -433,13 +463,13 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'h':
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'V':
print_version(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'v':
@@ -477,9 +507,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'e':
- ret_value = read_info(opt_arg, options);
- if (ret_value < 0)
+ if ((ret_value = read_info(opt_arg, options)) < 0) {
+ error_msg("failed to read from repack options file <%s>\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
+ }
break;
case 'n':
@@ -494,6 +527,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
bound = HDatoi(opt_arg);
if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing low bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
options->low_bound = bound;
@@ -503,6 +538,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
bound = HDatoi(opt_arg);
if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing high bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
options->high_bound = bound;
@@ -624,8 +661,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'q':
- if (H5_INDEX_UNKNOWN == set_sort_by(opt_arg)) {
- error_msg(" failed to set sort by form <%s>\n", opt_arg);
+ if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(opt_arg))) {
+ error_msg("failed to set sort by form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -633,8 +670,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'z':
- if (set_sort_order(opt_arg) == H5_ITER_UNKNOWN) {
- error_msg(" failed to set sort order form <%s>\n", opt_arg);
+ if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(opt_arg))) {
+ error_msg("failed to set sort order form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -645,6 +682,38 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
enable_error_stack = 1;
break;
+ case '1':
+ in_vol_info.type = VOL_BY_VALUE;
+ in_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg);
+ custom_in_fapl = TRUE;
+ break;
+
+ case '2':
+ in_vol_info.type = VOL_BY_NAME;
+ in_vol_info.u.name = opt_arg;
+ custom_in_fapl = TRUE;
+ break;
+
+ case '3':
+ in_vol_info.info_string = opt_arg;
+ break;
+
+ case '4':
+ out_vol_info.type = VOL_BY_VALUE;
+ out_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg);
+ custom_out_fapl = TRUE;
+ break;
+
+ case '5':
+ out_vol_info.type = VOL_BY_NAME;
+ out_vol_info.u.name = opt_arg;
+ custom_out_fapl = TRUE;
+ break;
+
+ case '6':
+ out_vol_info.info_string = opt_arg;
+ break;
+
default:
break;
} /* end switch */
@@ -652,30 +721,71 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* If neither -i nor -o given, get in and out files positionally */
if (0 == (has_i + has_o)) {
- if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
- infile = argv[opt_ind];
- outfile = argv[opt_ind + 1];
-
- if (!HDstrcmp(infile, outfile)) {
- error_msg("file names cannot be the same\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
- }
- else {
- error_msg("file names missing\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
- }
- else if (has_i != 1 || has_o != 1) {
- error_msg("filenames must be either both -i -o or both positional\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
+ if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
+ infile = argv[opt_ind];
+ outfile = argv[opt_ind + 1];
+
+ if (!HDstrcmp(infile, outfile)) {
+ error_msg("file names cannot be the same\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+ }
+ else {
+ error_msg("file names missing\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+ }
+ else if (has_i != 1 || has_o != 1) {
+ error_msg("filenames must be either both -i -o or both positional\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+
+ /* Setup FAPL for input and output file accesses */
+ if (custom_in_fapl) {
+ if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, &in_vol_info, NULL)) < 0) {
+ error_msg("failed to setup FAPL for input file\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ /* Close old FAPL */
+ if (options->fin_fapl != H5P_DEFAULT)
+ if (H5Pclose(options->fin_fapl) < 0) {
+ error_msg("failed to close FAPL\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ options->fin_fapl = tmp_fapl;
+ }
+
+ if (custom_out_fapl) {
+ if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, &out_vol_info, NULL)) < 0) {
+ error_msg("failed to setup FAPL for output file\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ /* Close old FAPL */
+ if (options->fout_fapl != H5P_DEFAULT)
+ if (H5Pclose(options->fout_fapl) < 0) {
+ error_msg("failed to close FAPL\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ options->fout_fapl = tmp_fapl;
+ }
done:
return ret_value;
@@ -693,54 +803,64 @@ done:
*/
int main(int argc, const char **argv)
{
- pack_opt_t options; /*the global options */
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
+ pack_opt_t options; /*the global options */
+ int parse_ret;
HDmemset(&options, 0, sizeof(pack_opt_t));
- h5tools_setprogname(PROGRAMNAME);
- h5tools_setstatus(EXIT_SUCCESS);
-
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
/* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */
if (h5tools_getenv_update_hyperslab_bufsize() < 0) {
+ HDprintf("Error occurred while retrieving H5TOOLS_BUFSIZE value\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* initialize options */
if (h5repack_init(&options, 0, FALSE) < 0) {
+ HDprintf("Error occurred while initializing repack options\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+
/* Initialize default indexing options */
sort_by = H5_INDEX_CRT_ORDER;
- if (parse_command_line(argc, argv, &options) < 0)
+ parse_ret = parse_command_line(argc, argv, &options);
+ if (parse_ret < 0) {
+ HDprintf("Error occurred while parsing command-line options\n");
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
-
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
}
+ else if (parse_ret > 0) {
+ /* Short-circuit success */
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+ }
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/* pack it */
- h5tools_setstatus(h5repack(infile, outfile, &options));
+ if (h5repack(infile, outfile, &options) < 0) {
+ HDprintf("Error occurred while repacking\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
+ h5tools_setstatus(EXIT_SUCCESS);
done:
+ if (options.fin_fapl >= 0 && options.fin_fapl != H5P_DEFAULT)
+ H5Pclose(options.fin_fapl);
+ if (options.fout_fapl >= 0 && options.fout_fapl != H5P_DEFAULT)
+ H5Pclose(options.fout_fapl);
+
/* free tables */
h5repack_end(&options);
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index 683988c..7bb5dfd 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -353,16 +353,16 @@ int verify_layout(hid_t pid, pack_info_t *obj)
*-------------------------------------------------------------------------
*/
-int h5repack_cmp_pl(const char *fname1, const char *fname2)
+int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl)
{
- hid_t fid1 =H5I_INVALID_HID; /* file ID */
- hid_t fid2 =H5I_INVALID_HID; /* file ID */
- hid_t dset1 =H5I_INVALID_HID; /* dataset ID */
- hid_t dset2 =H5I_INVALID_HID; /* dataset ID */
- hid_t gid =H5I_INVALID_HID; /* group ID */
- hid_t dcpl1 =H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t dcpl2 =H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t gcplid =H5I_INVALID_HID; /* group creation property list */
+ hid_t fid1 = H5I_INVALID_HID; /* file ID */
+ hid_t fid2 = H5I_INVALID_HID; /* file ID */
+ hid_t dset1 = H5I_INVALID_HID; /* dataset ID */
+ hid_t dset2 = H5I_INVALID_HID; /* dataset ID */
+ hid_t gid = H5I_INVALID_HID; /* group ID */
+ hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t gcplid = H5I_INVALID_HID; /* group creation property list */
unsigned crt_order_flag1; /* group creation order flag */
unsigned crt_order_flag2; /* group creation order flag */
trav_table_t *trav = NULL;
@@ -374,9 +374,9 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
*-------------------------------------------------------------------------
*/
/* Open the files */
- if ((fid1 = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
- if ((fid2 = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
/*-------------------------------------------------------------------------
diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c
index adc905a..ec4b5ab 100644
--- a/tools/src/h5stat/h5stat.c
+++ b/tools/src/h5stat/h5stat.c
@@ -118,30 +118,28 @@ typedef struct iter_t {
} iter_t;
-static const char *drivername = "";
+static const char *drivername = NULL;
#ifdef H5_HAVE_ROS3_VFD
-/* default "anonymous" s3 configuration
- */
+/* Default "anonymous" S3 configuration */
static H5FD_ros3_fapl_t ros3_fa = {
- 1, /* fapl version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+ 1, /* Structure Version */
+ false, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
-/* default HDFS access configuration
- */
+/* "Default" HDFS configuration */
static H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
@@ -1065,103 +1063,32 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret)
break;
case 'w':
-#ifndef H5_HAVE_ROS3_VFD
+#ifdef H5_HAVE_ROS3_VFD
+ if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa) < 0) {
+ error_msg("failed to parse S3 VFD credential info\n");
+ goto error;
+ }
+
+ drivername = drivernames[ROS3_VFD_IDX];
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
goto error;
-#else
- {
- char *cred_str = NULL;
- unsigned nelems = 0;
- char **cred = NULL;
- char const *ccred[3];
-
- if (FAIL == parse_tuple((const char *)opt_arg, ',', &cred_str, &nelems, &cred)) {
- error_msg("Unable to parse s3 credential\n");
- goto error;
- }
- if (nelems != 3) {
- error_msg("s3 credential must have three elements\n");
- goto error;
- }
- ccred[0] = (const char *)cred[0];
- ccred[1] = (const char *)cred[1];
- ccred[2] = (const char *)cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- error_msg("Unable to set ros3 fapl config\n");
- goto error;
- }
- HDfree(cred);
- HDfree(cred_str);
- } /* parse s3-cred block */
- drivername = "ros3";
+#endif
break;
-#endif /* H5_HAVE_ROS3_VFD */
case 'H':
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- goto error;
-#else
- {
- unsigned nelems = 0;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
- if (FAIL == parse_tuple((const char *)opt_arg,
- ',', &props_src, &nelems, &props)) {
- error_msg("unable to parse hdfs properties tuple\n");
- goto error;
- }
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- char str[64] = "";
- HDsprintf(str,
- "expected 5 elements in hdfs properties tuple "
- "but found %u\n",
- nelems);
- HDfree(props);
- HDfree(props_src);
- error_msg(str);
- goto error;
- }
- /* Populate fapl configuration structure with given
- * properties.
- * TODO/WARNING: No error-checking is done on length of
- * input strings... Silent overflow is possible,
- * albeit unlikely.
- */
- if (HDstrncmp(props[0], "", 1)) {
- HDstrncpy(hdfs_fa.namenode_name,(const char *)props[0], HDstrlen(props[0]));
- }
- if (HDstrncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- error_msg("supposed port number wasn't.\n");
- goto error;
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (HDstrncmp(props[2], "", 1)) {
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
- }
- if (HDstrncmp(props[3], "", 1)) {
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
- }
- if (strncmp(props[4], "", 1)) {
- k = HDstrtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- error_msg("supposed buffersize number wasn't.\n");
- goto error;
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
- drivername = "hdfs";
+#ifdef H5_HAVE_LIBHDFS
+ if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa) < 0) {
+ error_msg("failed to parse HDFS VFD configuration info\n");
+ goto error;
}
+
+ drivername = drivernames[HDFS_VFD_IDX];
+#else
+ error_msg("HDFS VFD not enabled.\n");
+ goto error;
+#endif
break;
-#endif /* H5_HAVE_LIBHDFS */
default:
usage(h5tools_getprogname());
@@ -1859,75 +1786,54 @@ main(int argc, const char *argv[])
iter_t iter;
const char *fname = NULL;
hid_t fid = H5I_INVALID_HID;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
struct handler_t *hand = NULL;
hid_t fapl_id = H5P_DEFAULT;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
-
HDmemset(&iter, 0, sizeof(iter));
if(parse_command_line(argc, argv, &hand) < 0)
goto done;
- /* if drivername is not null, probably need to set the fapl */
- if (HDstrcmp(drivername, "")) {
- void *conf_fa = NULL;
+ /* enable error reporting if command line option */
+ h5tools_error_report();
- if (!HDstrcmp(drivername, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
- error_msg("Read-Only S3 VFD not enabled.\n\n");
- goto done;
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+ if (drivername) {
+ h5tools_vfd_info_t vfd_info;
- }
- else if (!HDstrcmp(drivername, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD not enabled.\n\n");
+ vfd_info.info = NULL;
+ vfd_info.name = drivername;
+
+ if (!HDstrcmp(drivername, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ vfd_info.info = (void *)&ros3_fa;
+#else
+ error_msg("Read-Only S3 VFD not enabled.\n");
goto done;
+#endif
+ }
+ else if (!HDstrcmp(drivername, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ vfd_info.info = (void *)&hdfs_fa;
#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
+ error_msg("HDFS VFD not enabled.\n");
+ goto done;
+#endif
}
- if (conf_fa != NULL) {
- HDassert(fapl_id == H5P_DEFAULT);
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- error_msg("Unable to create fapl entry\n");
- goto done;
- }
- if (1 > h5tools_set_configured_fapl(fapl_id, drivername, conf_fa)) {
- error_msg("Unable to set fapl\n");
- goto done;
- }
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) {
+ error_msg("Unable to create FAPL for file access\n");
+ goto done;
}
- } /* drivername set */
+ }
fname = argv[opt_ind];
- if(enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
- }
-
/* Check for filename given */
if(fname) {
hid_t fcpl;
@@ -1935,7 +1841,9 @@ main(int argc, const char *argv[])
HDprintf("Filename: %s\n", fname);
- fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id,
+ (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0);
+
if(fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
h5tools_setstatus(EXIT_FAILURE);
@@ -2030,8 +1938,6 @@ done:
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
leave(h5tools_getstatus());
} /* end main() */
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index 42bb4ff..96cbf9c 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -266,9 +266,6 @@ main (int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable the HDF5 library's error reporting */
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* initialize h5tools lib */
h5tools_init();
@@ -279,6 +276,9 @@ main (int argc, const char *argv[])
if(fname_g == NULL)
goto done;
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Print usage/exit if not using at least one of the options */
if(!clear_status_flags && !remove_cache_image &&
!increment_eoa_eof && !print_filesize) {
@@ -344,7 +344,7 @@ main (int argc, const char *argv[])
}
/* Open the file */
- if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) {
+ if((fid = h5tools_fopen(fname, flags, fapl, FALSE, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -385,7 +385,6 @@ main (int argc, const char *argv[])
warn_msg("No cache image in the file\n");
}
-
h5tools_setstatus(EXIT_SUCCESS);
done:
diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c
index a167709..e9a783b 100644
--- a/tools/src/misc/h5debug.c
+++ b/tools/src/misc/h5debug.c
@@ -77,65 +77,64 @@ static const H5B2_class_t *
get_H5B2_class(const uint8_t *sig)
{
H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5B2_class_t *cls;
+ const H5B2_class_t *cls = NULL;
switch(subtype) {
- case H5B2_TEST_ID:
- cls = H5B2_TEST;
- break;
-
- case H5B2_FHEAP_HUGE_INDIR_ID:
- cls = H5HF_HUGE_BT2_INDIR;
- break;
-
- case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
- cls = H5HF_HUGE_BT2_FILT_INDIR;
- break;
-
- case H5B2_FHEAP_HUGE_DIR_ID:
- cls = H5HF_HUGE_BT2_DIR;
- break;
-
- case H5B2_FHEAP_HUGE_FILT_DIR_ID:
- cls = H5HF_HUGE_BT2_FILT_DIR;
- break;
-
- case H5B2_GRP_DENSE_NAME_ID:
- cls = H5G_BT2_NAME;
- break;
-
- case H5B2_GRP_DENSE_CORDER_ID:
- cls = H5G_BT2_CORDER;
- break;
-
- case H5B2_SOHM_INDEX_ID:
- cls = H5SM_INDEX;
- break;
-
- case H5B2_ATTR_DENSE_NAME_ID:
- cls = H5A_BT2_NAME;
- break;
-
- case H5B2_ATTR_DENSE_CORDER_ID:
- cls = H5A_BT2_CORDER;
- break;
-
- case H5B2_CDSET_ID:
- cls = H5D_BT2;
- break;
-
- case H5B2_CDSET_FILT_ID:
- cls = H5D_BT2_FILT;
- break;
-
- case H5B2_TEST2_ID:
- cls = H5B2_TEST2;
- break;
-
- case H5B2_NUM_BTREE_ID:
- default:
- HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
+ case H5B2_TEST_ID:
+ cls = H5B2_TEST;
+ break;
+
+ case H5B2_FHEAP_HUGE_INDIR_ID:
+ cls = H5HF_HUGE_BT2_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_DIR_ID:
+ cls = H5HF_HUGE_BT2_DIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_DIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_DIR;
+ break;
+
+ case H5B2_GRP_DENSE_NAME_ID:
+ cls = H5G_BT2_NAME;
+ break;
+
+ case H5B2_GRP_DENSE_CORDER_ID:
+ cls = H5G_BT2_CORDER;
+ break;
+
+ case H5B2_SOHM_INDEX_ID:
+ cls = H5SM_INDEX;
+ break;
+
+ case H5B2_ATTR_DENSE_NAME_ID:
+ cls = H5A_BT2_NAME;
+ break;
+
+ case H5B2_ATTR_DENSE_CORDER_ID:
+ cls = H5A_BT2_CORDER;
+ break;
+
+ case H5B2_CDSET_ID:
+ cls = H5D_BT2;
+ break;
+
+ case H5B2_CDSET_FILT_ID:
+ cls = H5D_BT2_FILT;
+ break;
+
+ case H5B2_TEST2_ID:
+ cls = H5B2_TEST2;
+ break;
+
+ case H5B2_NUM_BTREE_ID:
+ default:
+ HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype));
} /* end switch */
return(cls);
@@ -161,25 +160,24 @@ static const H5EA_class_t *
get_H5EA_class(const uint8_t *sig)
{
H5EA_cls_id_t clsid = (H5EA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5EA_class_t *cls;
+ const H5EA_class_t *cls = NULL;
switch(clsid) {
- case H5EA_CLS_TEST_ID:
- cls = H5EA_CLS_TEST;
- break;
-
- case H5EA_CLS_CHUNK_ID:
- cls = H5EA_CLS_CHUNK;
- break;
-
- case H5EA_CLS_FILT_CHUNK_ID:
- cls = H5EA_CLS_FILT_CHUNK;
- break;
-
- case H5EA_NUM_CLS_ID:
- default:
- HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid));
- HDexit(4);
+ case H5EA_CLS_TEST_ID:
+ cls = H5EA_CLS_TEST;
+ break;
+
+ case H5EA_CLS_CHUNK_ID:
+ cls = H5EA_CLS_CHUNK;
+ break;
+
+ case H5EA_CLS_FILT_CHUNK_ID:
+ cls = H5EA_CLS_FILT_CHUNK;
+ break;
+
+ case H5EA_NUM_CLS_ID:
+ default:
+ HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid));
} /* end switch */
return(cls);
@@ -205,25 +203,24 @@ static const H5FA_class_t *
get_H5FA_class(const uint8_t *sig)
{
H5FA_cls_id_t clsid = (H5FA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5FA_class_t *cls;
+ const H5FA_class_t *cls = NULL;
switch(clsid) {
- case H5FA_CLS_TEST_ID:
- cls = H5FA_CLS_TEST;
- break;
-
- case H5FA_CLS_CHUNK_ID:
- cls = H5FA_CLS_CHUNK;
- break;
-
- case H5FA_CLS_FILT_CHUNK_ID:
- cls = H5FA_CLS_FILT_CHUNK;
- break;
-
- case H5FA_NUM_CLS_ID:
- default:
- HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid));
- HDexit(4);
+ case H5FA_CLS_TEST_ID:
+ cls = H5FA_CLS_TEST;
+ break;
+
+ case H5FA_CLS_CHUNK_ID:
+ cls = H5FA_CLS_CHUNK;
+ break;
+
+ case H5FA_CLS_FILT_CHUNK_ID:
+ cls = H5FA_CLS_FILT_CHUNK;
+ break;
+
+ case H5FA_NUM_CLS_ID:
+ default:
+ HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid));
} /* end switch */
return(cls);
@@ -248,26 +245,32 @@ get_H5FA_class(const uint8_t *sig)
int
main(int argc, char *argv[])
{
- hid_t fid, fapl;
+ hid_t fid = H5I_INVALID_HID;
+ hid_t fapl = H5I_INVALID_HID;
H5VL_object_t *vol_obj;
H5F_t *f;
- haddr_t addr = 0, extra = 0, extra2 = 0, extra3 = 0, extra4 = 0;
+ haddr_t addr = 0;
+ int extra_count = 0; /* Number of extra arguments */
+ haddr_t extra[10];
uint8_t sig[H5F_SIGNATURE_LEN];
size_t u;
H5E_auto2_t func;
void *edata;
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t status = SUCCEED;
+ int exit_value = 0;
if(argc == 1) {
- HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]]\n", argv[0]);
- HDexit(1);
+ HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]*]\n", argv[0]);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Initialize the library */
if(H5open() < 0) {
HDfprintf(stderr, "cannot initialize the library\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Disable error reporting */
@@ -279,54 +282,71 @@ main(int argc, char *argv[])
*/
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
HDfprintf(stderr, "cannot create file access property list\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
if(HDstrchr(argv[1], '%'))
if(H5Pset_fapl_family (fapl, (hsize_t)0, H5P_DEFAULT) < 0) {
HDfprintf(stderr, "cannot set file access property list\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
if((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) {
HDfprintf(stderr, "cannot open file\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Push API context */
if(H5CX_push() < 0) {
HDfprintf(stderr, "cannot set API context\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
api_ctx_pushed = TRUE;
if(NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(fid))) {
HDfprintf(stderr, "cannot obtain vol_obj pointer\n");
- HDexit(2);
+ exit_value = 2;
+ goto done;
} /* end if */
if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj))) {
HDfprintf(stderr, "cannot obtain H5F_t pointer\n");
- HDexit(2);
+ exit_value = 2;
+ goto done;
} /* end if */
/* Ignore metadata tags while using h5debug */
if(H5AC_ignore_tags(f) < 0) {
HDfprintf(stderr, "cannot ignore metadata tags\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
/*
* Parse command arguments.
*/
+
+ /* Primary data structure to dump */
if(argc > 2)
addr = (haddr_t)HDstrtoll(argv[2], NULL, 0);
- if(argc > 3)
- extra = (haddr_t)HDstrtoll(argv[3], NULL, 0);
- if(argc > 4)
- extra2 = (haddr_t)HDstrtoll(argv[4], NULL, 0);
- if(argc > 5)
- extra3 = (haddr_t)HDstrtoll(argv[5], NULL, 0);
- if(argc > 6)
- extra4 = (haddr_t)HDstrtoll(argv[6], NULL, 0);
+
+ /* Extra arguments for primary data structure */
+ HDmemset(extra, 0, sizeof(extra));
+ if(argc > 3) {
+ /* Number of extra arguments */
+ extra_count = argc - 3;
+
+ /* Range check against 'extra' array size */
+ if(extra_count > (int)(sizeof(extra) / sizeof(haddr_t))) {
+ HDfprintf(stderr, "\nWARNING: Only using first %d extra parameters\n\n", (int)(sizeof(extra) / sizeof(haddr_t)));
+ extra_count = (int)(sizeof(extra) / sizeof(haddr_t));
+ } /* end if */
+
+ for(u = 0; u < (size_t)extra_count; u++)
+ extra[u] = (haddr_t)HDstrtoll(argv[u + 3], NULL, 0);
+ } /* end if */
/*
* Read the signature at the specified file position.
@@ -334,7 +354,8 @@ main(int argc, char *argv[])
HDfprintf(stdout, "Reading signature at address %a (rel)\n", addr);
if(H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), sig) < 0) {
HDfprintf(stderr, "cannot read signature\n");
- HDexit(3);
+ exit_value = 3;
+ goto done;
}
if(!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) {
/*
@@ -362,13 +383,13 @@ main(int argc, char *argv[])
*/
/* Check for extra parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
HDfprintf(stderr, "Symbol table node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Symbol table node address> <address of local heap>\n\n");
} /* end if */
- status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra);
+ status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]);
}
else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -384,46 +405,51 @@ main(int argc, char *argv[])
switch(subtype) {
case H5B_SNODE_ID:
/* Check for extra parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
HDfprintf(stderr, "B-tree symbol table node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <address of local heap>\n\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra);
+ status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]);
break;
case H5B_CHUNK_ID:
/* Check for extra parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n");
HDfprintf(stderr, "B-tree chunked storage node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- /* Build array of chunk dimensions */
- ndims = (unsigned)extra;
- dim[0] = (uint32_t)extra2;
- if(ndims > 1)
- dim[1] = (uint32_t)extra3;
- if(ndims > 2)
- dim[2] = (uint32_t)extra4;
+ /* Set # of dimensions */
+ ndims = (unsigned)extra[0];
/* Check for dimension error */
- if(ndims > 3) {
- HDfprintf(stderr, "ERROR: Only 3 dimensions support currently (fix h5debug)\n");
+ if(ndims > 9) {
+ HDfprintf(stderr, "ERROR: Only 9 dimensions support currently (fix h5debug)\n");
HDfprintf(stderr, "B-tree chunked storage node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end for */
+
+ /* Build array of chunk dimensions */
+ for(u = 0; u < ndims; u++)
+ dim[u] = (uint32_t)extra[u + 1];
+
+ /* Check for dimension error */
for(u = 0; u < ndims; u++)
if(0 == dim[u]) {
HDfprintf(stderr, "ERROR: Chunk dimensions should be >0\n");
HDfprintf(stderr, "B-tree chunked storage node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
/* Set the last dimension (the element size) to zero */
@@ -435,7 +461,8 @@ main(int argc, char *argv[])
case H5B_NUM_BTREE_ID:
default:
HDfprintf(stderr, "Unknown v1 B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
+ exit_value = 4;
+ goto done;
}
}
@@ -446,14 +473,15 @@ main(int argc, char *argv[])
const H5B2_class_t *cls = get_H5B2_class(sig);
HDassert(cls);
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && extra == 0) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0)) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "v2 B-tree hdr usage:\n");
HDfprintf(stderr, "\th5debug <filename> <v2 B-tree header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra);
+ status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra[0]);
}
else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -464,23 +492,25 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 || extra4 == 0)) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 || extra[3] == 0)) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object header address containing the layout message in order to dump internal node\n");
HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
}
- else if(extra == 0 || extra2 == 0 || extra3 == 0) {
+ else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and depth in order to dump internal node\n");
HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (unsigned)extra3, (haddr_t)extra4);
+ status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (unsigned)extra[2], (haddr_t)extra[3]);
}
else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -491,22 +521,24 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 )) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 )) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header address containing the layout message in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
}
- else if(extra == 0 || extra2 == 0) {
+ else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (haddr_t)extra3);
+ status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (haddr_t)extra[2]);
}
else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -522,14 +554,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to dump direct block\n");
HDfprintf(stderr, "Fractal heap direct block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <direct block address> <heap header address> <size of direct block>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra, (size_t)extra2);
+ status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra[0], (size_t)extra[1]);
}
else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -538,14 +571,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump indirect block\n");
HDfprintf(stderr, "Fractal heap indirect block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <indirect block address> <heap header address> <number of rows>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra, (unsigned)extra2);
+ status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra[0], (unsigned)extra[1]);
}
else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -562,14 +596,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump serialized sections\n");
HDfprintf(stderr, "Free space serialized sections usage:\n");
HDfprintf(stderr, "\th5debug <filename> <serialized sections address> <free space header address> <client address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra, extra2);
+ status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra[0], extra[1]);
}
else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -586,14 +621,15 @@ main(int argc, char *argv[])
*/
/* Check for enough valid parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need shared message header address in order to shared message list\n");
HDfprintf(stderr, "Shared message list usage:\n");
HDfprintf(stderr, "\th5debug <filename> <shared message list address> <shared message header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra);
+ status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra[0]);
}
else if(!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -604,14 +640,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "Extensible array header block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Extensible Array header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra);
+ status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]);
}
else if(!HDmemcmp(sig, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -622,14 +659,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need extensible array header address and object header address containing the layout message in order to dump index block\n");
HDfprintf(stderr, "Extensible array index block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <index block address> <array header address> <object header address\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__iblock_debug(f, addr, stdout, 0, VCOL, cls, extra, extra2);
+ status = H5EA__iblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]);
}
else if(!HDmemcmp(sig, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -640,14 +678,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
HDfprintf(stderr, "ERROR: Need extensible array header address, super block index and object header address containing the layout message in order to dump super block\n");
HDfprintf(stderr, "Extensible array super block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <super block address> <array header address> <super block index> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, extra3);
+ status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], extra[2]);
}
else if(!HDmemcmp(sig, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -658,14 +697,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
HDfprintf(stderr, "ERROR: Need extensible array header address, # of elements in data block and object header address containing the layout message in order to dump data block\n");
HDfprintf(stderr, "Extensible array data block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <data block address> <array header address> <# of elements in data block> <object header address\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra, (size_t)extra2, extra3);
+ status = H5EA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (size_t)extra[1], extra[2]);
}
else if(!HDmemcmp(sig, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -676,14 +716,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0) {
+ if(extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "Fixed array header block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Fixed Array header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra);
+ status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]);
}
else if(!HDmemcmp(sig, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -694,14 +735,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
HDfprintf(stderr, "ERROR: Need fixed array header address and object header address containing the layout message in order to dump data block\n");
HDfprintf(stderr, "fixed array data block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <data block address> <array header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra, extra2);
+ status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]);
}
else if(!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -738,24 +780,27 @@ main(int argc, char *argv[])
HDputchar('\n');
HDfprintf(stderr, "unknown signature\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end else */
/* Check for an error when dumping information */
if(status < 0) {
HDfprintf(stderr, "An error occurred!\n");
H5Eprint2(H5E_DEFAULT, stderr);
- HDexit(5);
+ exit_value = 5;
+ goto done;
} /* end if */
- H5Pclose(fapl);
- H5Fclose(fid);
+done:
+ if(fapl > 0) H5Pclose(fapl);
+ if(fid > 0) H5Fclose(fid);
/* Pop API context */
if(api_ctx_pushed) H5CX_pop();
H5Eset_auto2(H5E_DEFAULT, func, edata);
- return 0;
+ return exit_value;
} /* main() */
diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c
index feb60d4..ad3b7b8 100644
--- a/tools/src/misc/h5mkgrp.c
+++ b/tools/src/misc/h5mkgrp.c
@@ -25,24 +25,29 @@ int d_status = EXIT_SUCCESS;
/* command-line options: short and long-named parameters */
static const char *s_opts = "hlpvV";
static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "latest", no_arg, 'l' },
- { "parents", no_arg, 'p' },
- { "verbose", no_arg, 'v' },
- { "version", no_arg, 'V' },
+ { "help", no_arg, 'h' },
+ { "latest", no_arg, 'l' },
+ { "parents", no_arg, 'p' },
+ { "verbose", no_arg, 'v' },
+ { "version", no_arg, 'V' },
+ { "vol-value", require_arg, '1' },
+ { "vol-name", require_arg, '2' },
+ { "vol-info", require_arg, '3' },
{ NULL, 0, '\0' }
};
/* Command line parameter settings */
-typedef struct {
+typedef struct mkgrp_opt_t {
char *fname; /* File name to operate on */
hbool_t latest; /* Whether file should use latest format versions */
hbool_t verbose; /* Whether output should be verbose */
hbool_t parents; /* Whether to create intermediate groups */
size_t ngroups; /* Number of groups to create */
char **groups; /* Pointer to array of group names */
-} param_t;
-param_t params; /* Command line parameter settings */
+ hid_t fapl_id; /* fapl to use when opening the file */
+} mkgrp_opt_t;
+
+mkgrp_opt_t params_g; /* Command line parameter settings */
/*-------------------------------------------------------------------------
@@ -61,13 +66,17 @@ leave(int ret)
{
size_t curr_group;
- if (params.fname)
- HDfree (params.fname);
- if (params.ngroups) {
- for(curr_group = 0; curr_group < params.ngroups; curr_group++)
- HDfree (params.groups[curr_group]);
- HDfree (params.groups);
+ if (params_g.fname)
+ HDfree(params_g.fname);
+ if (params_g.ngroups) {
+ for (curr_group = 0; curr_group < params_g.ngroups; curr_group++)
+ HDfree(params_g.groups[curr_group]);
+ HDfree(params_g.groups);
}
+ if (H5I_INVALID_HID != params_g.fapl_id && H5P_DEFAULT != params_g.fapl_id)
+ if (H5Pclose(params_g.fapl_id) < 0)
+ error_msg("Could not close file access property list\n");
+
h5tools_close();
HDexit(ret);
} /* end leave() */
@@ -85,65 +94,79 @@ leave(int ret)
*-------------------------------------------------------------------------
*/
static void
-usage(void)
+usage(const char *prog)
{
- HDfprintf(stdout, "\
-usage: h5mkgrp [OPTIONS] FILE GROUP...\n\
- OPTIONS\n\
- -h, --help Print a usage message and exit\n\
- -l, --latest Use latest version of file format to create groups\n\
- -p, --parents No error if existing, make parent groups as needed\n\
- -v, --verbose Print information about OBJECTS and OPTIONS\n\
- -V, --version Print version number and exit\n");
+ FLUSHSTREAM(rawoutstream);
+ PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] FILE GROUP...\n", prog);
+ PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
+ PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n");
+ PRINTVALSTREAM(rawoutstream, " -l, --latest Use latest version of file format to create groups\n");
+ PRINTVALSTREAM(rawoutstream, " -p, --parents No error if existing, make parent groups as needed\n");
+ PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n");
+ PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\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, "\n");
} /* end usage() */
/*-------------------------------------------------------------------------
- * Function: parse_command_line
+ * Function: parse_command_line
*
- * Purpose: Parses command line and sets up global variable to control output
+ * Purpose: Parses command line and sets up global variable to control
+ * output
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
* Programmer: Quincey Koziol, 2/13/2007
*
*-------------------------------------------------------------------------
*/
static int
-parse_command_line(int argc, const char *argv[], param_t *parms)
+parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options)
{
int opt; /* Option from command line */
size_t curr_group; /* Current group name to copy */
+ hbool_t custom_fapl = FALSE;
+ h5tools_vol_info_t vol_info;
+ hid_t tmp_fapl_id = H5I_INVALID_HID;
/* Check for empty command line */
if(argc == 1) {
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
- } /* end if */
+ }
+
+ /* Initialize fapl info struct */
+ HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t));
/* Parse command line options */
while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch((char)opt) {
/* Display 'help' */
case 'h':
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
/* Create objects with the latest version of the format */
case 'l':
- parms->latest = TRUE;
+ options->latest = TRUE;
break;
/* Create parent groups */
case 'p':
- parms->parents = TRUE;
+ options->parents = TRUE;
break;
/* Verbose output */
case 'v':
- parms->verbose = TRUE;
+ options->verbose = TRUE;
break;
/* Display version */
@@ -152,9 +175,25 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
leave(EXIT_SUCCESS);
break;
+ case '1':
+ vol_info.type = VOL_BY_VALUE;
+ vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg);
+ custom_fapl = TRUE;
+ break;
+
+ case '2':
+ vol_info.type = VOL_BY_NAME;
+ vol_info.u.name = opt_arg;
+ custom_fapl = TRUE;
+ break;
+
+ case '3':
+ vol_info.info_string = opt_arg;
+ break;
+
/* Bad command line argument */
default:
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end switch */
} /* end while */
@@ -162,43 +201,51 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
/* Check for file name to be processed */
if(argc <= opt_ind) {
error_msg("missing file name\n");
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Retrieve file name */
- parms->fname = HDstrdup(argv[opt_ind]);
+ options->fname = HDstrdup(argv[opt_ind]);
opt_ind++;
/* Check for group(s) to be created */
if(argc <= opt_ind) {
error_msg("missing group name(s)\n");
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Allocate space for the group name pointers */
- parms->ngroups = (size_t)(argc - opt_ind);
- parms->groups = (char **)HDmalloc(parms->ngroups * sizeof(char *));
+ options->ngroups = (size_t)(argc - opt_ind);
+ options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *));
/* Retrieve the group names */
curr_group = 0;
while(opt_ind < argc) {
- parms->groups[curr_group] = HDstrdup(argv[opt_ind]);
+ options->groups[curr_group] = HDstrdup(argv[opt_ind]);
curr_group++;
opt_ind++;
- } /* end while */
+ }
-#ifdef QAK
-HDfprintf(stderr, "parms->parents = %t\n", parms->parents);
-HDfprintf(stderr, "parms->verbose = %t\n", parms->verbose);
-HDfprintf(stderr, "parms->fname = '%s'\n", parms->fname);
-HDfprintf(stderr, "parms->ngroups = %Zu\n", parms->ngroups);
-for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
- HDfprintf(stderr, "parms->group[%Zu] = '%s'\n", curr_group, parms->groups[curr_group]);
-#endif /* QAK */
+ /* Setup a custom fapl for file accesses */
+ if (custom_fapl) {
+ if ((tmp_fapl_id = h5tools_get_fapl(options->fapl_id, &vol_info, NULL)) < 0) {
+ error_msg("failed to setup file access property list (fapl) for file\n");
+ leave(EXIT_FAILURE);
+ }
+
+ /* Close the old fapl */
+ if (options->fapl_id != H5P_DEFAULT)
+ if (H5Pclose(options->fapl_id) < 0) {
+ error_msg("failed to close file access property list (fapl)\n");
+ leave(EXIT_FAILURE);
+ }
+
+ options->fapl_id = tmp_fapl_id;
+ }
- return(0);
+ return 0;
} /* parse_command_line() */
@@ -214,117 +261,112 @@ for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
int
main(int argc, const char *argv[])
{
- hid_t fid; /* HDF5 file ID */
- hid_t fapl_id; /* File access property list ID */
- hid_t lcpl_id; /* Link creation property list ID */
- size_t curr_group; /* Current group to create */
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t lcpl_id = H5I_INVALID_HID; /* Link creation property list ID */
+ size_t curr_group; /* Current group to create */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable the HDF5 library's error reporting */
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Parse command line */
- HDmemset(&params, 0, sizeof(params));
- if(parse_command_line(argc, argv, &params) < 0) {
- error_msg("unable to parse command line arguments\n");
- leave(EXIT_FAILURE);
- } /* end if */
+ /* Initialize the parameters */
+ HDmemset(&params_g, 0, sizeof(params_g));
/* Create file access property list */
- if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if((params_g.fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("Could not create file access property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
+
+ /* Parse command line */
+ if(parse_command_line(argc, argv, &params_g) < 0) {
+ error_msg("unable to parse command line arguments\n");
+ leave(EXIT_FAILURE);
+ }
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/* Check for creating groups with new format version */
- if(params.latest) {
+ if(params_g.latest) {
/* Set the "use the latest version of the format" bounds */
- if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ if(H5Pset_libver_bounds(params_g.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
error_msg("Could not set property for using latest version of the format\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
+ if(params_g.verbose)
HDprintf("%s: Creating groups with latest version of the format\n", h5tools_getprogname());
- } /* end if */
+ }
/* Attempt to open an existing HDF5 file first */
- fid = h5tools_fopen(params.fname, H5F_ACC_RDWR, fapl_id, NULL, NULL, 0);
+ fid = h5tools_fopen(params_g.fname, H5F_ACC_RDWR, params_g.fapl_id, FALSE, NULL, 0);
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
if(fid < 0)
- fid = H5Fcreate(params.fname, H5F_ACC_EXCL, H5P_DEFAULT, fapl_id);
+ fid = H5Fcreate(params_g.fname, H5F_ACC_EXCL, H5P_DEFAULT, params_g.fapl_id);
/* Test for error in opening file */
if(fid < 0) {
- error_msg("Could not open output file '%s'\n", params.fname);
+ error_msg("Could not open output file '%s'\n", params_g.fname);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Create link creation property list */
if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
error_msg("Could not create link creation property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Check for creating intermediate groups */
- if(params.parents) {
+ if(params_g.parents) {
/* Set the intermediate group creation property */
if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
error_msg("Could not set property for creating parent groups\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
+ if(params_g.verbose)
HDprintf("%s: Creating parent groups\n", h5tools_getprogname());
- } /* end if */
+ }
/* Loop over creating requested groups */
- for(curr_group = 0; curr_group < params.ngroups; curr_group++) {
+ for(curr_group = 0; curr_group < params_g.ngroups; curr_group++) {
hid_t gid; /* Group ID */
/* Attempt to create a group */
- if((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- error_msg("Could not create group '%s'\n", params.groups[curr_group]);
+ if((gid = H5Gcreate2(fid, params_g.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ error_msg("Could not create group '%s'\n", params_g.groups[curr_group]);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Close the group */
if(H5Gclose(gid) < 0) {
- error_msg("Could not close group '%s'??\n", params.groups[curr_group]);
+ error_msg("Could not close group '%s'??\n", params_g.groups[curr_group]);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
- HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params.groups[curr_group]);
+ if(params_g.verbose)
+ HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params_g.groups[curr_group]);
} /* end for */
/* Close link creation property list */
if(H5Pclose(lcpl_id) < 0) {
error_msg("Could not close link creation property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Close file */
if(H5Fclose(fid) < 0) {
- error_msg("Could not close output file '%s'??\n", params.fname);
- leave(EXIT_FAILURE);
- } /* end if */
-
- /* Close file access property list */
- if(H5Pclose(fapl_id) < 0) {
- error_msg("Could not close file access property list\n");
+ error_msg("Could not close output file '%s'??\n", params_g.fname);
leave(EXIT_FAILURE);
- } /* end if */
+ }
leave(EXIT_SUCCESS);
} /* end main() */