2003-04-01 02:10:51 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
2021-02-17 22:52:36 +08:00
|
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2017-04-18 03:32:16 +08:00
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*
|
2020-01-29 08:18:38 +08:00
|
|
|
* Purpose: A library for routines that are common
|
|
|
|
* amongst the various HDF5 tools.
|
2001-02-23 05:55:15 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "h5tools.h"
|
2012-02-18 05:41:58 +08:00
|
|
|
#include "h5tools_dump.h"
|
2005-08-26 04:16:40 +08:00
|
|
|
#include "h5tools_ref.h"
|
2001-03-09 04:21:05 +08:00
|
|
|
#include "h5tools_utils.h"
|
2001-02-23 05:55:15 +08:00
|
|
|
#include "H5private.h"
|
|
|
|
|
2020-01-24 00:20:34 +08:00
|
|
|
#ifdef H5_TOOLS_DEBUG
|
|
|
|
/* global debug variables */
|
2020-09-30 22:27:10 +08:00
|
|
|
int H5tools_INDENT_g = 0;
|
2020-01-24 00:20:34 +08:00
|
|
|
#endif
|
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* global variables */
|
2020-07-16 00:20:16 +08:00
|
|
|
H5E_auto2_t lib_func;
|
|
|
|
H5E_auto2_t tools_func;
|
2022-07-27 05:45:46 +08:00
|
|
|
void *lib_edata;
|
|
|
|
void *tools_edata;
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
hid_t H5tools_ERR_STACK_g = H5I_INVALID_HID;
|
|
|
|
hid_t H5tools_ERR_CLS_g = H5I_INVALID_HID;
|
|
|
|
hid_t H5E_tools_g = H5I_INVALID_HID;
|
|
|
|
hid_t H5E_tools_min_id_g = H5I_INVALID_HID;
|
|
|
|
hid_t H5E_tools_min_info_id_g = H5I_INVALID_HID;
|
|
|
|
hid_t H5E_tools_min_dbg_id_g = H5I_INVALID_HID;
|
|
|
|
|
|
|
|
FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */
|
|
|
|
FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */
|
|
|
|
FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */
|
|
|
|
FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */
|
|
|
|
FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */
|
|
|
|
|
|
|
|
int bin_output; /* binary output */
|
|
|
|
int bin_form = 0; /* binary form, default NATIVE */
|
|
|
|
int region_output; /* region output */
|
|
|
|
int oid_output; /* oid output */
|
|
|
|
int data_output; /* data output */
|
|
|
|
int attr_data_output; /* attribute data output */
|
|
|
|
|
|
|
|
unsigned packed_bits_num; /* number of packed bits to display */
|
|
|
|
unsigned packed_data_offset; /* offset of packed bits to display */
|
|
|
|
unsigned packed_data_length; /* length of packed bits to display */
|
|
|
|
unsigned long long packed_data_mask; /* mask in which packed bits to display */
|
|
|
|
|
|
|
|
int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2017-05-23 02:10:40 +08:00
|
|
|
/* sort parameters */
|
2020-09-30 22:27:10 +08:00
|
|
|
H5_index_t sort_by = H5_INDEX_NAME; /* sort_by [creation_order | name] */
|
|
|
|
H5_iter_order_t sort_order = H5_ITER_INC; /* sort_order [ascending | descending] */
|
2017-05-23 02:10:40 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/* module-scoped variables */
|
2020-09-30 22:27:10 +08:00
|
|
|
static int h5tools_init_g; /* if h5tools lib has been initialized */
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
/* Names of VOL connectors */
|
|
|
|
const char *volnames[] = {
|
|
|
|
H5VL_NATIVE_NAME,
|
|
|
|
H5VL_PASSTHRU_NAME,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Names of VFDs. These names are always available so that
|
|
|
|
* the tools can emit special messages when a VFD is asked
|
|
|
|
* for by name but is not compiled into the library or is
|
|
|
|
* somehow otherwise not enabled.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
const char *drivernames[] = {
|
2024-03-23 10:31:16 +08:00
|
|
|
[SEC2_VFD_IDX] = "sec2", [DIRECT_VFD_IDX] = "direct", [LOG_VFD_IDX] = "log",
|
|
|
|
[WINDOWS_VFD_IDX] = "windows", [STDIO_VFD_IDX] = "stdio", [CORE_VFD_IDX] = "core",
|
|
|
|
[FAMILY_VFD_IDX] = "family", [SPLIT_VFD_IDX] = "split", [MULTI_VFD_IDX] = "multi",
|
|
|
|
[MPIO_VFD_IDX] = "mpio", [MIRROR_VFD_IDX] = "mirror", [SPLITTER_VFD_IDX] = "splitter",
|
|
|
|
[ROS3_VFD_IDX] = "ros3", [HDFS_VFD_IDX] = "hdfs", [SUBFILING_VFD_IDX] = H5FD_SUBFILING_NAME,
|
|
|
|
[ONION_VFD_IDX] = "onion",
|
2004-02-05 06:43:00 +08:00
|
|
|
};
|
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
#define NUM_VOLS (sizeof(volnames) / sizeof(volnames[0]))
|
|
|
|
#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_init
|
|
|
|
*
|
|
|
|
* Purpose: This should be called before any other h5tools function is called.
|
|
|
|
* Effect of any h5tools function called before this has been called is
|
|
|
|
* undetermined.
|
|
|
|
*
|
|
|
|
* Return None
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_init(void)
|
|
|
|
{
|
2020-07-16 00:20:16 +08:00
|
|
|
/* Disable error reporting */
|
|
|
|
H5Eget_auto2(H5E_DEFAULT, &lib_func, &lib_edata);
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
if (!h5tools_init_g) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_INIT_ERROR();
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (!rawattrstream)
|
|
|
|
rawattrstream = stdout;
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!rawdatastream)
|
|
|
|
rawdatastream = stdout;
|
2013-07-31 01:04:23 +08:00
|
|
|
if (!rawinstream)
|
|
|
|
rawinstream = stdin;
|
2012-02-25 05:14:47 +08:00
|
|
|
if (!rawoutstream)
|
|
|
|
rawoutstream = stdout;
|
|
|
|
if (!rawerrorstream)
|
|
|
|
rawerrorstream = stderr;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_dump_init();
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_init_g++;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
2020-07-16 00:20:16 +08:00
|
|
|
|
|
|
|
/* Disable tools error reporting */
|
|
|
|
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
|
|
|
|
H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_error_report
|
|
|
|
*
|
|
|
|
* Purpose: Enable error stack reporting after command line is parsed.
|
|
|
|
*
|
|
|
|
* Return: None
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_error_report(void)
|
|
|
|
{
|
|
|
|
if (h5tools_init_g) {
|
|
|
|
if (enable_error_stack > 0) {
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata);
|
|
|
|
H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
|
|
|
|
}
|
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_close
|
|
|
|
*
|
|
|
|
* Purpose: Close or release resources such as files opened by the library. This
|
|
|
|
* should be called after all other h5tools functions have been called.
|
|
|
|
* Effect of any h5tools function called after this has been called is
|
|
|
|
* undetermined.
|
|
|
|
*
|
|
|
|
* Return: None
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_close(void)
|
|
|
|
{
|
|
|
|
if (h5tools_init_g) {
|
2013-02-05 04:15:59 +08:00
|
|
|
/* special case where only data is output to stdout */
|
2020-02-12 07:57:19 +08:00
|
|
|
if ((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
|
2023-06-28 23:31:32 +08:00
|
|
|
fprintf(rawdatastream, "\n");
|
2013-02-01 04:51:23 +08:00
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
if (tools_func)
|
2012-03-13 22:38:37 +08:00
|
|
|
H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (rawattrstream && rawattrstream != stdout) {
|
|
|
|
if (fclose(rawattrstream))
|
|
|
|
perror("closing rawattrstream");
|
|
|
|
else
|
|
|
|
rawattrstream = NULL;
|
|
|
|
}
|
2007-09-13 23:44:56 +08:00
|
|
|
if (rawdatastream && rawdatastream != stdout) {
|
|
|
|
if (fclose(rawdatastream))
|
2009-09-04 22:50:13 +08:00
|
|
|
perror("closing rawdatastream");
|
2007-09-13 23:44:56 +08:00
|
|
|
else
|
2009-09-04 22:50:13 +08:00
|
|
|
rawdatastream = NULL;
|
2007-09-13 23:44:56 +08:00
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
if (rawinstream && rawinstream != stdin) {
|
|
|
|
if (fclose(rawinstream))
|
|
|
|
perror("closing rawinstream");
|
|
|
|
else
|
|
|
|
rawinstream = NULL;
|
|
|
|
}
|
2012-02-25 05:14:47 +08:00
|
|
|
if (rawoutstream && rawoutstream != stdout) {
|
|
|
|
if (fclose(rawoutstream))
|
|
|
|
perror("closing rawoutstream");
|
|
|
|
else
|
|
|
|
rawoutstream = NULL;
|
|
|
|
}
|
|
|
|
if (rawerrorstream && rawerrorstream != stderr) {
|
|
|
|
if (fclose(rawerrorstream))
|
|
|
|
perror("closing rawerrorstream");
|
|
|
|
else
|
|
|
|
rawerrorstream = NULL;
|
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
/* Clean up the reference path table, if it's been used */
|
|
|
|
term_ref_path_table();
|
|
|
|
|
2020-07-16 00:20:16 +08:00
|
|
|
/* Restore error stacks from init */
|
|
|
|
H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata);
|
|
|
|
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_CLOSE_ERROR();
|
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
/* Shut down the library */
|
|
|
|
H5close();
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_init_g = 0;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 01:04:23 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_set_data_output_file
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Open fname as the output file for dataset raw data.
|
|
|
|
* Set rawdatastream as its file stream.
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
2013-07-31 01:04:23 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
h5tools_set_data_output_file(const char *fname, int is_bin)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawdatastream is changed only when succeeded */
|
2013-07-31 01:04:23 +08:00
|
|
|
|
|
|
|
if (rawdatastream && rawdatastream != stdout) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if (fclose(rawdatastream))
|
2023-09-16 06:13:18 +08:00
|
|
|
perror("closing rawdatastream");
|
2013-07-31 01:04:23 +08:00
|
|
|
else
|
|
|
|
rawdatastream = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "wb")) != NULL) {
|
2013-07-31 01:04:23 +08:00
|
|
|
rawdatastream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "w")) != NULL) {
|
2013-07-31 01:04:23 +08:00
|
|
|
rawdatastream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawdatastream = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_set_attr_output_file
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Open fname as the output file for attribute raw data.
|
|
|
|
* Set rawattrstream as its file stream.
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
2013-07-31 01:04:23 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
h5tools_set_attr_output_file(const char *fname, int is_bin)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawattrstream is changed only when succeeded */
|
2013-07-31 01:04:23 +08:00
|
|
|
|
|
|
|
if (rawattrstream && rawattrstream != stdout) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if (fclose(rawattrstream))
|
2023-09-16 06:13:18 +08:00
|
|
|
perror("closing rawattrstream");
|
2013-07-31 01:04:23 +08:00
|
|
|
else
|
|
|
|
rawattrstream = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
2013-08-01 00:22:40 +08:00
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "wb")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawattrstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
2013-08-01 00:22:40 +08:00
|
|
|
}
|
|
|
|
else {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "w")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawattrstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawattrstream = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_set_input_file
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Open fname as the input file for raw input.
|
|
|
|
* Set rawinstream as its file stream.
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2013-08-01 00:22:40 +08:00
|
|
|
h5tools_set_input_file(const char *fname, int is_bin)
|
2013-07-31 01:04:23 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawinstream is changed only when succeeded */
|
2013-07-31 01:04:23 +08:00
|
|
|
|
|
|
|
if (rawinstream && rawinstream != stdin) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if (fclose(rawinstream))
|
2023-09-16 06:13:18 +08:00
|
|
|
perror("closing rawinstream");
|
2013-07-31 01:04:23 +08:00
|
|
|
else
|
2017-05-09 23:41:00 +08:00
|
|
|
rawinstream = NULL;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
2013-08-01 00:22:40 +08:00
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "rb")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawinstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
2013-08-01 00:22:40 +08:00
|
|
|
}
|
|
|
|
else {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "r")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawinstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawinstream = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_set_output_file
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Open fname as the output file for raw output.
|
|
|
|
* Set rawoutstream as its file stream.
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2013-08-01 00:22:40 +08:00
|
|
|
h5tools_set_output_file(const char *fname, int is_bin)
|
2013-07-31 01:04:23 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawoutstream is changed only when succeeded */
|
2013-07-31 01:04:23 +08:00
|
|
|
|
|
|
|
if (rawoutstream && rawoutstream != stdout) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if (fclose(rawoutstream))
|
2023-09-16 06:13:18 +08:00
|
|
|
perror("closing rawoutstream");
|
2013-07-31 01:04:23 +08:00
|
|
|
else
|
|
|
|
rawoutstream = NULL;
|
|
|
|
}
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
2013-08-01 00:22:40 +08:00
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "wb")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawoutstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
2013-08-01 00:22:40 +08:00
|
|
|
}
|
|
|
|
else {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "w")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawoutstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawoutstream = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_set_error_file
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Open fname as the error output file for dataset raw error.
|
|
|
|
* Set rawerrorstream as its file stream.
|
2013-07-31 01:04:23 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
2013-07-31 01:04:23 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2013-08-01 00:22:40 +08:00
|
|
|
h5tools_set_error_file(const char *fname, int is_bin)
|
2013-07-31 01:04:23 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawerrorstream is changed only when succeeded */
|
2013-07-31 01:04:23 +08:00
|
|
|
|
|
|
|
if (rawerrorstream && rawerrorstream != stderr) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if (fclose(rawerrorstream))
|
2023-09-16 06:13:18 +08:00
|
|
|
perror("closing rawerrorstream");
|
2013-07-31 01:04:23 +08:00
|
|
|
else
|
|
|
|
rawerrorstream = NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-01 00:22:40 +08:00
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
2020-09-30 22:27:10 +08:00
|
|
|
/* binary output */
|
2017-05-09 23:41:00 +08:00
|
|
|
if (is_bin) {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "wb")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawerrorstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
2013-08-01 00:22:40 +08:00
|
|
|
}
|
|
|
|
else {
|
2023-06-29 23:19:31 +08:00
|
|
|
if ((f = fopen(fname, "w")) != NULL) {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawerrorstream = f;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2017-05-09 23:41:00 +08:00
|
|
|
}
|
|
|
|
}
|
2013-08-01 00:22:40 +08:00
|
|
|
}
|
|
|
|
else {
|
2017-05-09 23:41:00 +08:00
|
|
|
rawerrorstream = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
retvalue = SUCCEED;
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2020-04-21 08:38:45 +08:00
|
|
|
* Function: h5tools_set_fapl_vfd
|
2017-10-23 22:26:15 +08:00
|
|
|
*
|
2021-09-30 02:28:12 +08:00
|
|
|
* Purpose: Given a VFL driver name or ID, sets the appropriate driver on
|
|
|
|
* the specified FAPL.
|
2020-02-12 07:57:19 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: positive - succeeded
|
|
|
|
* negative - failed
|
2004-02-05 06:43:00 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2020-02-12 07:57:19 +08:00
|
|
|
static herr_t
|
2020-04-21 08:38:45 +08:00
|
|
|
h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info)
|
2004-02-05 06:43:00 +08:00
|
|
|
{
|
2019-12-28 16:16:44 +08:00
|
|
|
herr_t ret_value = SUCCEED;
|
2007-02-14 21:54:11 +08:00
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
switch (vfd_info->type) {
|
|
|
|
case VFD_BY_NAME:
|
|
|
|
/* Determine which driver the user wants to open the file with */
|
2023-09-16 06:13:18 +08:00
|
|
|
if (!strcmp(vfd_info->u.name, drivernames[SEC2_VFD_IDX])) {
|
2021-09-30 02:28:12 +08:00
|
|
|
/* SEC2 Driver */
|
|
|
|
if (H5Pset_fapl_sec2(fapl_id) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[DIRECT_VFD_IDX])) {
|
2020-02-12 07:57:19 +08:00
|
|
|
#ifdef H5_HAVE_DIRECT
|
2021-09-30 02:28:12 +08:00
|
|
|
/* Direct Driver */
|
|
|
|
if (H5Pset_fapl_direct(fapl_id, 1024, 4096, 8 * 4096) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_direct failed");
|
2020-02-12 07:57:19 +08:00
|
|
|
#else
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Direct VFD is not enabled");
|
2020-02-12 07:57:19 +08:00
|
|
|
#endif
|
2021-09-30 02:28:12 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[LOG_VFD_IDX])) {
|
2021-09-30 02:28:12 +08:00
|
|
|
unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
/* Log Driver */
|
|
|
|
if (H5Pset_fapl_log(fapl_id, NULL, log_flags, (size_t)0) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_log failed");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[WINDOWS_VFD_IDX])) {
|
2020-02-12 07:57:19 +08:00
|
|
|
#ifdef H5_HAVE_WINDOWS
|
2021-09-30 02:28:12 +08:00
|
|
|
/* There is no Windows VFD - use SEC2 */
|
|
|
|
if (H5Pset_fapl_sec2(fapl_id) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
|
2020-02-12 07:57:19 +08:00
|
|
|
#else
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Windows VFD is not enabled");
|
2020-02-12 07:57:19 +08:00
|
|
|
#endif
|
2021-09-30 02:28:12 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[STDIO_VFD_IDX])) {
|
2021-09-30 02:28:12 +08:00
|
|
|
/* Stdio Driver */
|
|
|
|
if (H5Pset_fapl_stdio(fapl_id) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[CORE_VFD_IDX])) {
|
2021-09-30 02:28:12 +08:00
|
|
|
/* Core Driver */
|
2023-09-06 02:50:06 +08:00
|
|
|
if (H5Pset_fapl_core(fapl_id, (size_t)H5_MB, true) < 0)
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_core failed");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[FAMILY_VFD_IDX])) {
|
2021-09-30 02:28:12 +08:00
|
|
|
/* FAMILY Driver */
|
|
|
|
/* Set member size to be 0 to indicate the current first member size
|
|
|
|
* is the member size.
|
|
|
|
*/
|
|
|
|
if (H5Pset_fapl_family(fapl_id, (hsize_t)0, H5P_DEFAULT) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[SPLIT_VFD_IDX])) {
|
2021-09-30 02:28:12 +08:00
|
|
|
/* SPLIT Driver */
|
|
|
|
if (H5Pset_fapl_split(fapl_id, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[MULTI_VFD_IDX])) {
|
2021-09-30 02:28:12 +08:00
|
|
|
/* MULTI Driver */
|
2023-09-06 02:50:06 +08:00
|
|
|
if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, true) < 0)
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed");
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[MPIO_VFD_IDX])) {
|
2014-03-22 07:02:24 +08:00
|
|
|
#ifdef H5_HAVE_PARALLEL
|
2021-09-30 02:28:12 +08:00
|
|
|
int mpi_initialized, mpi_finalized;
|
2015-06-11 01:57:32 +08:00
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
/* MPI-I/O Driver */
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
/* check if MPI is available. */
|
|
|
|
MPI_Initialized(&mpi_initialized);
|
|
|
|
MPI_Finalized(&mpi_finalized);
|
2015-06-11 01:57:32 +08:00
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
if (mpi_initialized && !mpi_finalized) {
|
|
|
|
if (H5Pset_fapl_mpio(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_mpio failed");
|
|
|
|
}
|
2020-02-12 07:57:19 +08:00
|
|
|
#else
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "MPI-I/O VFD is not enabled");
|
2014-03-22 07:02:24 +08:00
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
2021-09-30 02:28:12 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[ROS3_VFD_IDX])) {
|
2020-02-12 07:57:19 +08:00
|
|
|
#ifdef H5_HAVE_ROS3_VFD
|
2021-09-30 02:28:12 +08:00
|
|
|
if (!vfd_info->info)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid");
|
2023-07-15 04:15:11 +08:00
|
|
|
if (H5Pset_fapl_ros3(fapl_id, &((const H5FD_ros3_fapl_ext_t *)vfd_info->info)->fa) < 0)
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed");
|
2023-07-15 04:15:11 +08:00
|
|
|
|
|
|
|
if (H5Pset_fapl_ros3_token(fapl_id, ((const H5FD_ros3_fapl_ext_t *)vfd_info->info)->token) <
|
|
|
|
0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3_token() failed");
|
2020-02-12 07:57:19 +08:00
|
|
|
#else
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled");
|
2020-02-12 07:57:19 +08:00
|
|
|
#endif
|
2021-09-30 02:28:12 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[HDFS_VFD_IDX])) {
|
2020-02-12 07:57:19 +08:00
|
|
|
#ifdef H5_HAVE_LIBHDFS
|
2021-09-30 02:28:12 +08:00
|
|
|
if (!vfd_info->info)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "HDFS VFD info is invalid");
|
|
|
|
if (H5Pset_fapl_hdfs(fapl_id, (H5FD_hdfs_fapl_t *)vfd_info->info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_hdfs() failed");
|
2020-02-12 07:57:19 +08:00
|
|
|
#else
|
2021-09-30 02:28:12 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "The HDFS VFD is not enabled");
|
2022-08-05 01:56:48 +08:00
|
|
|
#endif
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[SUBFILING_VFD_IDX])) {
|
2022-08-12 04:52:25 +08:00
|
|
|
#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
|
2024-01-10 00:38:35 +08:00
|
|
|
if (H5Pset_fapl_subfiling(fapl_id, (const H5FD_subfiling_config_t *)vfd_info->info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_subfiling() failed");
|
2022-08-05 01:56:48 +08:00
|
|
|
#else
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "The Subfiling VFD is not enabled");
|
2020-02-12 07:57:19 +08:00
|
|
|
#endif
|
2021-09-30 02:28:12 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vfd_info->u.name, drivernames[ONION_VFD_IDX])) {
|
2022-08-03 03:54:40 +08:00
|
|
|
/* Onion driver */
|
|
|
|
if (!vfd_info->info)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "Onion VFD info is invalid");
|
|
|
|
if (H5Pset_fapl_onion(fapl_id, (const H5FD_onion_fapl_info_t *)vfd_info->info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_onion() failed");
|
|
|
|
}
|
2021-09-30 02:28:12 +08:00
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Try to load VFD plugin.
|
|
|
|
*
|
|
|
|
* Currently, driver configuration strings are unsupported.
|
|
|
|
*/
|
|
|
|
if (H5Pset_driver_by_name(fapl_id, vfd_info->u.name, (const char *)vfd_info->info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't load VFD plugin by driver name '%s'", vfd_info->u.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VFD_BY_VALUE:
|
|
|
|
/*
|
|
|
|
* Try to load VFD plugin.
|
|
|
|
*
|
|
|
|
* Currently, driver configuration strings are unsupported.
|
|
|
|
*/
|
2024-01-10 00:38:35 +08:00
|
|
|
|
|
|
|
if (vfd_info->u.value == H5_VFD_SUBFILING) {
|
|
|
|
#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
|
|
|
|
if (H5Pset_fapl_subfiling(fapl_id, (const H5FD_subfiling_config_t *)vfd_info->info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_subfiling() failed");
|
|
|
|
#else
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "The Subfiling VFD is not enabled");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (H5Pset_driver_by_value(fapl_id, vfd_info->u.value, (const char *)vfd_info->info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't load VFD plugin by driver value '%ld'",
|
|
|
|
(long int)vfd_info->u.value);
|
|
|
|
}
|
2021-09-30 02:28:12 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD retrieval type");
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2021-09-30 02:28:12 +08:00
|
|
|
if (ret_value < 0) {
|
|
|
|
/* Clear error message unless asked for */
|
2022-05-07 02:06:07 +08:00
|
|
|
if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
|
2021-09-30 02:28:12 +08:00
|
|
|
H5Epop(H5tools_ERR_STACK_g, 1);
|
|
|
|
}
|
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2020-04-21 08:38:45 +08:00
|
|
|
* Function: h5tools_set_fapl_vol
|
2020-02-12 07:57:19 +08:00
|
|
|
*
|
|
|
|
* Purpose: Given a VOL connector name or ID, sets the appropriate
|
|
|
|
* connector on the specified FAPL.
|
|
|
|
*
|
|
|
|
* Return: positive - succeeded
|
|
|
|
* negative - failed
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static herr_t
|
2020-04-21 08:38:45 +08:00
|
|
|
h5tools_set_fapl_vol(hid_t fapl_id, h5tools_vol_info_t *vol_info)
|
2020-02-12 07:57:19 +08:00
|
|
|
{
|
|
|
|
htri_t connector_is_registered;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t connector_id = H5I_INVALID_HID;
|
2022-07-27 05:45:46 +08:00
|
|
|
void *connector_info = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
herr_t ret_value = SUCCEED;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2020-04-21 08:38:45 +08:00
|
|
|
switch (vol_info->type) {
|
2020-04-01 07:58:24 +08:00
|
|
|
case VOL_BY_NAME:
|
2020-03-27 23:48:11 +08:00
|
|
|
/* Retrieve VOL connector by name */
|
2020-04-21 08:38:45 +08:00
|
|
|
if ((connector_is_registered = H5VLis_connector_registered_by_name(vol_info->u.name)) < 0)
|
2020-03-27 23:48:11 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered");
|
|
|
|
if (connector_is_registered) {
|
2020-04-21 08:38:45 +08:00
|
|
|
if ((connector_id = H5VLget_connector_id_by_name(vol_info->u.name)) < 0)
|
2020-03-27 23:48:11 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID");
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
|
|
|
else {
|
2020-04-21 08:38:45 +08:00
|
|
|
/* Check for VOL connectors that ship with the library, then try
|
|
|
|
* registering by name if that fails.
|
2020-09-30 22:27:10 +08:00
|
|
|
*/
|
2023-09-16 06:13:18 +08:00
|
|
|
if (!strcmp(vol_info->u.name, H5VL_NATIVE_NAME)) {
|
2020-03-27 23:48:11 +08:00
|
|
|
connector_id = H5VL_NATIVE;
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (!strcmp(vol_info->u.name, H5VL_PASSTHRU_NAME)) {
|
2020-03-27 23:48:11 +08:00
|
|
|
connector_id = H5VL_PASSTHRU;
|
|
|
|
}
|
|
|
|
else {
|
2020-04-21 08:38:45 +08:00
|
|
|
/* NOTE: Not being able to pass in a VIPL may be a limitation for some
|
|
|
|
* connectors.
|
|
|
|
*/
|
|
|
|
if ((connector_id = H5VLregister_connector_by_name(vol_info->u.name, H5P_DEFAULT)) < 0)
|
2020-03-27 23:48:11 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector");
|
|
|
|
}
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
|
|
|
|
2020-03-27 23:48:11 +08:00
|
|
|
break;
|
|
|
|
|
2020-04-14 19:31:01 +08:00
|
|
|
case VOL_BY_VALUE:
|
2020-03-27 23:48:11 +08:00
|
|
|
/* Retrieve VOL connector by ID */
|
2020-04-21 08:38:45 +08:00
|
|
|
if ((connector_is_registered = H5VLis_connector_registered_by_value(vol_info->u.value)) < 0)
|
2020-03-27 23:48:11 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered");
|
|
|
|
if (connector_is_registered) {
|
2020-04-21 08:38:45 +08:00
|
|
|
if ((connector_id = H5VLget_connector_id_by_value(vol_info->u.value)) < 0)
|
2020-03-27 23:48:11 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID");
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
|
|
|
else {
|
2020-03-27 23:48:11 +08:00
|
|
|
/* Check for VOL connectors that ship with the library */
|
2020-04-21 08:38:45 +08:00
|
|
|
if (vol_info->u.value == H5VL_NATIVE_VALUE) {
|
2020-03-27 23:48:11 +08:00
|
|
|
connector_id = H5VL_NATIVE;
|
|
|
|
}
|
2020-04-21 08:38:45 +08:00
|
|
|
else if (vol_info->u.value == H5VL_PASSTHRU_VALUE) {
|
2020-03-27 23:48:11 +08:00
|
|
|
connector_id = H5VL_PASSTHRU;
|
|
|
|
}
|
|
|
|
else {
|
2020-04-21 08:38:45 +08:00
|
|
|
/* NOTE: Not being able to pass in a VIPL may be a limitation for some
|
|
|
|
* connectors.
|
|
|
|
*/
|
|
|
|
if ((connector_id = H5VLregister_connector_by_value(vol_info->u.value, H5P_DEFAULT)) < 0)
|
2020-03-27 23:48:11 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector");
|
|
|
|
}
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
2020-03-27 23:48:11 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "invalid VOL retrieval type");
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
|
|
|
|
2020-04-21 08:38:45 +08:00
|
|
|
/* Convert the info string, if provided */
|
|
|
|
if (vol_info->info_string)
|
|
|
|
if (H5VLconnector_str_to_info(vol_info->info_string, connector_id, &connector_info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector info from string");
|
|
|
|
|
|
|
|
/* Set the VOL connector on the fapl */
|
|
|
|
if (H5Pset_vol(fapl_id, connector_id, connector_info) < 0)
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "can't set VOL connector on FAPL");
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2017-10-23 22:26:15 +08:00
|
|
|
done:
|
2020-04-21 08:38:45 +08:00
|
|
|
if (connector_info)
|
|
|
|
if (H5VLfree_connector_info(connector_id, connector_info))
|
2020-04-09 23:40:41 +08:00
|
|
|
H5TOOLS_ERROR(FAIL, "failed to free VOL connector-specific info");
|
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
if (ret_value < 0) {
|
|
|
|
if (connector_id >= 0 && H5Idec_ref(connector_id) < 0)
|
|
|
|
H5TOOLS_ERROR(FAIL, "failed to decrement refcount on VOL connector ID");
|
2021-09-30 02:28:12 +08:00
|
|
|
|
|
|
|
/* Clear error message unless asked for */
|
2022-05-07 02:06:07 +08:00
|
|
|
if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
|
2021-09-30 02:28:12 +08:00
|
|
|
H5Epop(H5tools_ERR_STACK_g, 1);
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_get_fapl
|
|
|
|
*
|
2020-04-21 08:38:45 +08:00
|
|
|
* Purpose: Copies an input fapl and then sets a VOL and/or a VFD on it.
|
|
|
|
*
|
|
|
|
* The returned fapl must be closed by the caller.
|
2020-02-12 07:57:19 +08:00
|
|
|
*
|
|
|
|
* Return: positive - succeeded
|
|
|
|
* negative - failed
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
hid_t
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, h5tools_vfd_info_t *vfd_info)
|
2020-02-12 07:57:19 +08:00
|
|
|
{
|
2020-04-09 23:40:41 +08:00
|
|
|
hid_t new_fapl_id = H5I_INVALID_HID;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t ret_value = H5I_INVALID_HID;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2020-04-09 23:40:41 +08:00
|
|
|
if (prev_fapl_id < 0)
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL");
|
|
|
|
|
2020-04-21 08:38:45 +08:00
|
|
|
/* Make a copy of the FAPL or create one if H5P_DEFAULT is specified. */
|
2020-04-09 23:40:41 +08:00
|
|
|
if (H5P_DEFAULT == prev_fapl_id) {
|
|
|
|
if ((new_fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcreate failed");
|
2020-04-21 08:38:45 +08:00
|
|
|
}
|
2020-02-12 07:57:19 +08:00
|
|
|
else {
|
2020-04-09 23:40:41 +08:00
|
|
|
if ((new_fapl_id = H5Pcopy(prev_fapl_id)) < 0)
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcopy failed");
|
|
|
|
}
|
|
|
|
|
2020-04-21 08:38:45 +08:00
|
|
|
/* Set non-default VOL connector, if requested */
|
|
|
|
if (vol_info)
|
|
|
|
if (h5tools_set_fapl_vol(new_fapl_id, vol_info) < 0)
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VOL on FAPL");
|
2020-04-21 08:38:45 +08:00
|
|
|
|
|
|
|
/* Set non-default virtual file driver, if requested */
|
|
|
|
if (vfd_info)
|
|
|
|
if (h5tools_set_fapl_vfd(new_fapl_id, vfd_info) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VFD on FAPL");
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2020-04-09 23:40:41 +08:00
|
|
|
ret_value = new_fapl_id;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
|
|
|
done:
|
2021-09-30 02:28:12 +08:00
|
|
|
if (ret_value < 0) {
|
|
|
|
if (new_fapl_id >= 0) {
|
|
|
|
H5Pclose(new_fapl_id);
|
|
|
|
new_fapl_id = H5I_INVALID_HID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear error message unless asked for */
|
2022-05-07 02:06:07 +08:00
|
|
|
if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
|
2021-09-30 02:28:12 +08:00
|
|
|
H5Epop(H5tools_ERR_STACK_g, 1);
|
2017-10-23 22:26:15 +08:00
|
|
|
}
|
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_get_vfd_name
|
|
|
|
*
|
|
|
|
* Purpose: Given a FAPL, retrieves the name of the VFL driver set on it
|
|
|
|
* if using a native-terminal VOL connector. If a
|
|
|
|
* non-native-terminal VOL connector is set on the FAPL, the
|
|
|
|
* first byte of the returned driver name will be set to the null
|
|
|
|
* terminator.
|
|
|
|
*
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
2023-01-10 05:49:29 +08:00
|
|
|
h5tools_get_vfd_name(hid_t fid, hid_t fapl_id, char *drivername, size_t drivername_size)
|
2020-02-12 07:57:19 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
hid_t fapl_vol_id = H5I_INVALID_HID;
|
|
|
|
bool is_native = false;
|
|
|
|
herr_t ret_value = SUCCEED;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
|
|
|
if (fapl_id < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL");
|
|
|
|
if (!drivername)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "drivername is NULL");
|
|
|
|
if (drivername && !drivername_size)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "drivername_size must be non-zero");
|
|
|
|
|
|
|
|
/* Initialize the driver name */
|
|
|
|
drivername[0] = '\0';
|
|
|
|
|
|
|
|
if (fapl_id == H5P_DEFAULT)
|
|
|
|
fapl_id = H5P_FILE_ACCESS_DEFAULT;
|
|
|
|
|
|
|
|
/* Retrieve ID of the VOL connector set on the FAPL */
|
|
|
|
if (H5Pget_vol_id(fapl_id, &fapl_vol_id) < 0)
|
|
|
|
H5TOOLS_ERROR(FAIL, "failed to retrieve VOL ID from FAPL");
|
|
|
|
|
2023-01-10 05:49:29 +08:00
|
|
|
/* Query if the file ID is native-terminal */
|
|
|
|
if (H5VLobject_is_native(fid, &is_native) < 0)
|
|
|
|
H5TOOLS_ERROR(FAIL, "failed to determine if file ID is native-terminal");
|
|
|
|
|
|
|
|
if (is_native) {
|
2020-02-12 07:57:19 +08:00
|
|
|
const char *driver_name;
|
|
|
|
hid_t driver_id;
|
|
|
|
|
|
|
|
if ((driver_id = H5Pget_driver(fapl_id)) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "failed to retrieve VFL driver ID from FAPL");
|
|
|
|
|
|
|
|
if (driver_id == H5FD_SEC2)
|
|
|
|
driver_name = drivernames[SEC2_VFD_IDX];
|
|
|
|
#ifdef H5_HAVE_DIRECT
|
|
|
|
else if (driver_id == H5FD_DIRECT)
|
|
|
|
driver_name = drivernames[DIRECT_VFD_IDX];
|
|
|
|
#endif
|
|
|
|
else if (driver_id == H5FD_LOG)
|
|
|
|
driver_name = drivernames[LOG_VFD_IDX];
|
|
|
|
#ifdef H5_HAVE_WINDOWS
|
|
|
|
else if (driver_id == H5FD_WINDOWS)
|
|
|
|
driver_name = drivernames[WINDOWS_VFD_IDX];
|
|
|
|
#endif
|
|
|
|
else if (driver_id == H5FD_STDIO)
|
|
|
|
driver_name = drivernames[STDIO_VFD_IDX];
|
|
|
|
else if (driver_id == H5FD_CORE)
|
|
|
|
driver_name = drivernames[CORE_VFD_IDX];
|
|
|
|
else if (driver_id == H5FD_FAMILY)
|
|
|
|
driver_name = drivernames[FAMILY_VFD_IDX];
|
|
|
|
else if (driver_id == H5FD_MULTI)
|
|
|
|
driver_name = drivernames[MULTI_VFD_IDX];
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
else if (driver_id == H5FD_MPIO)
|
|
|
|
driver_name = drivernames[MPIO_VFD_IDX];
|
|
|
|
#endif
|
|
|
|
#ifdef H5_HAVE_ROS3_VFD
|
|
|
|
else if (driver_id == H5FD_ROS3)
|
|
|
|
driver_name = drivernames[ROS3_VFD_IDX];
|
|
|
|
#endif
|
|
|
|
#ifdef H5_HAVE_LIBHDFS
|
|
|
|
else if (driver_id == H5FD_HDFS)
|
|
|
|
driver_name = drivernames[HDFS_VFD_IDX];
|
|
|
|
#endif
|
2022-08-06 11:17:16 +08:00
|
|
|
#ifdef H5_HAVE_SUBFILING_VFD
|
|
|
|
else if (driver_id == H5FD_SUBFILING)
|
|
|
|
driver_name = drivernames[SUBFILING_VFD_IDX];
|
|
|
|
#endif
|
|
|
|
else if (driver_id == H5FD_ONION)
|
|
|
|
driver_name = drivernames[ONION_VFD_IDX];
|
2020-02-12 07:57:19 +08:00
|
|
|
else
|
|
|
|
driver_name = "unknown";
|
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
strncpy(drivername, driver_name, drivername_size);
|
2020-02-12 07:57:19 +08:00
|
|
|
drivername[drivername_size - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
/* Close retrieved VOL ID */
|
|
|
|
if (fapl_vol_id >= 0)
|
|
|
|
if (H5VLclose(fapl_vol_id) < 0)
|
|
|
|
H5TOOLS_ERROR(FAIL, "failed to close VOL ID");
|
|
|
|
|
|
|
|
return ret_value;
|
2004-02-05 06:43:00 +08:00
|
|
|
}
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_fopen
|
|
|
|
*
|
2020-02-12 07:57:19 +08:00
|
|
|
* Purpose: Opens file FNAME using the specified flags and FAPL.
|
|
|
|
*
|
|
|
|
* The 'use_specific_driver' parameter is used to control the
|
|
|
|
* VFD/VOL connector that this routine uses to open the file
|
2023-09-06 02:50:06 +08:00
|
|
|
* with. If 'use_specific_driver' is set to true, this routine
|
2020-02-12 07:57:19 +08:00
|
|
|
* assumes that the caller has already set a specific VFD or VOL
|
|
|
|
* connector on the given FAPL and will attempt to directly use
|
|
|
|
* the FAPL for opening the file. We assume that the caller knows
|
|
|
|
* what they are doing; if the file is unable to be opened using
|
|
|
|
* that FAPL, this routine will return H5I_INVALID_HID.
|
|
|
|
*
|
2023-09-06 02:50:06 +08:00
|
|
|
* However, if 'use_specific_driver' is set to false, this
|
2020-02-12 07:57:19 +08:00
|
|
|
* routine assumes that the caller HAS NOT set a specific VFD or
|
|
|
|
* VOL connector on the given FAPL and will instead loop through
|
|
|
|
* the various available VFL drivers and VOL connectors trying to
|
|
|
|
* open FNAME.
|
|
|
|
*
|
|
|
|
* The list of available VFL drivers is as follows:
|
|
|
|
* - If the HDF5 library is version 1.2 or less, then we have
|
|
|
|
* only the SEC2 driver to try out.
|
|
|
|
* - If the HDF5 library is greater than version 1.2, then we
|
|
|
|
* have the FAMILY, SPLIT, and MULTI drivers to play with.
|
2001-07-31 05:55:46 +08:00
|
|
|
*
|
2020-02-12 07:57:19 +08:00
|
|
|
* The list of available VOL connectors is as follows:
|
|
|
|
* - "Native" VOL connector
|
|
|
|
* - Pass-through VOL connector
|
2017-10-23 22:26:15 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Return:
|
2020-02-12 07:57:19 +08:00
|
|
|
* On success, returns a file ID for the opened file. If DRIVERNAME is
|
|
|
|
* non-null and the native VOL connector is the terminal connector,
|
|
|
|
* then the first DRIVERNAME_SIZE-1 characters of the driver name are
|
|
|
|
* copied into the DRIVERNAME array and null terminated. If the
|
|
|
|
* native VOL connector is NOT the terminal connector, then the first
|
|
|
|
* byte of DRIVERNAME will be set to the null terminator.
|
2001-04-11 03:54:08 +08:00
|
|
|
*
|
2020-02-12 07:57:19 +08:00
|
|
|
* On failure, the function returns H5I_INVALID_HID and DRIVERNAME
|
|
|
|
* will not be set.
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-03-09 04:21:05 +08:00
|
|
|
hid_t
|
2023-09-06 02:50:06 +08:00
|
|
|
h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, bool use_specific_driver, char *drivername,
|
2020-09-30 22:27:10 +08:00
|
|
|
size_t drivername_size)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t fid = H5I_INVALID_HID;
|
|
|
|
hid_t tmp_fapl_id = H5I_INVALID_HID;
|
2020-04-21 08:38:45 +08:00
|
|
|
hid_t used_fapl_id = H5I_INVALID_HID;
|
2020-02-12 07:57:19 +08:00
|
|
|
unsigned volnum, drivernum;
|
|
|
|
hid_t ret_value = H5I_INVALID_HID;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First try to open the file using just the given FAPL. If the
|
|
|
|
* HDF5_VOL_CONNECTOR environment variable has been set, this will
|
|
|
|
* allow us to attempt to open the file using the specified VOL
|
|
|
|
* connector before we go looping through all available ones,
|
|
|
|
* which will override any VOL connector set by use of the
|
|
|
|
* environment variable.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Allow error stack display if --enable-error-stack has optional arg number */
|
|
|
|
if (enable_error_stack > 1) {
|
2020-04-21 08:38:45 +08:00
|
|
|
fid = H5Fopen(fname, flags, fapl_id);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
2021-03-17 23:25:39 +08:00
|
|
|
H5E_BEGIN_TRY
|
|
|
|
{
|
|
|
|
fid = H5Fopen(fname, flags, fapl_id);
|
|
|
|
}
|
2023-06-16 12:49:02 +08:00
|
|
|
H5E_END_TRY
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
2001-07-31 05:55:46 +08:00
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
/* If we succeeded in opening the file, we're done. */
|
|
|
|
if (fid >= 0) {
|
2020-04-21 08:38:45 +08:00
|
|
|
used_fapl_id = fapl_id;
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_DONE(fid);
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
/*
|
|
|
|
* If we failed to open the file and the caller specified 'use_specific_driver'
|
2023-09-06 02:50:06 +08:00
|
|
|
* as true, we should return failure now since the file couldn't be opened with
|
2020-02-12 07:57:19 +08:00
|
|
|
* the VFL driver/VOL connector that was set on the FAPL by the caller.
|
|
|
|
*/
|
2022-02-05 00:53:55 +08:00
|
|
|
if (use_specific_driver)
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to open file using specified FAPL");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As a final resort, try to open the file using each of the available
|
|
|
|
* VOL connectors. When the native VOL connector is the current "terminal"
|
|
|
|
* connector being looked at, also try using each of the available VFL drivers.
|
|
|
|
*/
|
|
|
|
for (volnum = 0; volnum < NUM_VOLS; volnum++) {
|
2020-04-21 08:38:45 +08:00
|
|
|
h5tools_vol_info_t vol_info;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
vol_info.type = VOL_BY_NAME;
|
|
|
|
vol_info.info_string = NULL;
|
|
|
|
vol_info.u.name = volnames[volnum];
|
2020-02-12 07:57:19 +08:00
|
|
|
|
|
|
|
/* TODO: For now, we have no way of determining if an arbitrary
|
2020-04-21 08:38:45 +08:00
|
|
|
* VOL connector is native-terminal so we only try VFDs with the
|
|
|
|
* actual native VOL connector.
|
|
|
|
*/
|
2020-02-12 07:57:19 +08:00
|
|
|
if (NATIVE_VOL_IDX == volnum) {
|
|
|
|
/*
|
|
|
|
* If using the native VOL connector, or a VOL connector which has the
|
|
|
|
* native connector as its terminal connector, loop through all of the
|
|
|
|
* VFL drivers as well.
|
|
|
|
*/
|
|
|
|
for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) {
|
2020-04-21 08:38:45 +08:00
|
|
|
h5tools_vfd_info_t vfd_info;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2020-04-01 07:58:24 +08:00
|
|
|
/* Skip the log VFD as it prints out to standard out
|
|
|
|
* and is fundamentally SEC2 anyway.
|
|
|
|
*/
|
2020-02-12 07:57:19 +08:00
|
|
|
if (drivernum == LOG_VFD_IDX)
|
|
|
|
continue;
|
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
vfd_info.type = VFD_BY_NAME;
|
|
|
|
vfd_info.info = NULL;
|
|
|
|
vfd_info.u.name = drivernames[drivernum];
|
2020-02-12 07:57:19 +08:00
|
|
|
|
2020-04-21 08:38:45 +08:00
|
|
|
/* Get a fapl reflecting the selected VOL connector and VFD */
|
|
|
|
if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, &vfd_info)) < 0)
|
2020-02-12 07:57:19 +08:00
|
|
|
continue;
|
|
|
|
|
2020-04-21 08:38:45 +08:00
|
|
|
/* Can we open the file with this combo? */
|
2022-08-06 11:17:16 +08:00
|
|
|
H5E_BEGIN_TRY
|
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
fid = h5tools_fopen(fname, flags, tmp_fapl_id, true, drivername, drivername_size);
|
2022-08-06 11:17:16 +08:00
|
|
|
}
|
2023-06-16 12:49:02 +08:00
|
|
|
H5E_END_TRY
|
2022-08-06 11:17:16 +08:00
|
|
|
|
|
|
|
if (fid >= 0) {
|
2020-04-21 08:38:45 +08:00
|
|
|
used_fapl_id = tmp_fapl_id;
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_DONE(fid);
|
|
|
|
}
|
|
|
|
else {
|
2020-04-21 08:38:45 +08:00
|
|
|
/* Close the temporary fapl */
|
|
|
|
H5Pclose(tmp_fapl_id);
|
|
|
|
tmp_fapl_id = H5I_INVALID_HID;
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
2020-04-21 08:38:45 +08:00
|
|
|
/* NOT the native VOL connector */
|
|
|
|
|
|
|
|
/* Get a FAPL for the current VOL connector */
|
|
|
|
if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, NULL)) < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Can we open the file with this connector? */
|
2023-09-06 02:50:06 +08:00
|
|
|
if ((fid = h5tools_fopen(fname, flags, tmp_fapl_id, true, drivername, drivername_size)) >= 0) {
|
2020-04-21 08:38:45 +08:00
|
|
|
used_fapl_id = tmp_fapl_id;
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_GOTO_DONE(fid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Close the temporary VOL FAPL */
|
2020-04-21 08:38:45 +08:00
|
|
|
H5Pclose(tmp_fapl_id);
|
|
|
|
tmp_fapl_id = H5I_INVALID_HID;
|
2020-02-12 07:57:19 +08:00
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
/* File was unable to be opened at all */
|
|
|
|
ret_value = H5I_INVALID_HID;
|
|
|
|
|
2001-07-31 05:55:46 +08:00
|
|
|
done:
|
2020-02-12 07:57:19 +08:00
|
|
|
/* Save the driver name if using a native-terminal VOL connector */
|
|
|
|
if (drivername && drivername_size && ret_value >= 0)
|
2023-01-10 05:49:29 +08:00
|
|
|
if (used_fapl_id >= 0 &&
|
|
|
|
h5tools_get_vfd_name(ret_value, used_fapl_id, drivername, drivername_size) < 0)
|
2020-02-12 07:57:19 +08:00
|
|
|
H5TOOLS_ERROR(H5I_INVALID_HID, "failed to retrieve name of VFD used to open file");
|
|
|
|
|
2020-04-21 08:38:45 +08:00
|
|
|
if (tmp_fapl_id >= 0)
|
|
|
|
H5Pclose(tmp_fapl_id);
|
2009-09-15 05:48:32 +08:00
|
|
|
|
2021-09-30 02:28:12 +08:00
|
|
|
/* Clear error message unless asked for */
|
2022-05-07 02:06:07 +08:00
|
|
|
if (ret_value < 0) {
|
|
|
|
if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
|
|
|
|
H5Epop(H5tools_ERR_STACK_g, 1);
|
|
|
|
}
|
2021-09-30 02:28:12 +08:00
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
return ret_value;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_count_ncols
|
|
|
|
*
|
|
|
|
* Purpose: Count the number of columns in a string. This is the number of
|
|
|
|
* characters in the string not counting line-control characters.
|
|
|
|
*
|
|
|
|
* Return: success - returns the width of the string.
|
|
|
|
* failure - 0.
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE static size_t
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_count_ncols(const char *s)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2022-03-11 06:14:05 +08:00
|
|
|
size_t i;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
for (i = 0; *s; s++)
|
|
|
|
if (*s >= ' ')
|
|
|
|
i++;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
return i;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 02:50:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2011-03-22 07:02:31 +08:00
|
|
|
* Function: h5tools_detect_vlen
|
2011-03-19 02:50:19 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Recursive check for any variable length data in given type.
|
2011-03-19 02:50:19 +08:00
|
|
|
*
|
2023-09-06 02:50:06 +08:00
|
|
|
* Return: true : type contains any variable length data
|
|
|
|
* false : type doesn't contain any variable length data
|
2017-10-25 00:03:00 +08:00
|
|
|
* Negative value: failed
|
2011-03-19 02:50:19 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
htri_t
|
2011-03-22 07:02:31 +08:00
|
|
|
h5tools_detect_vlen(hid_t tid)
|
2011-03-19 02:50:19 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
htri_t ret = false;
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
/* recursive detect any vlen data values in type (compound, array ...) */
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
ret = H5Tdetect_class(tid, H5T_VLEN);
|
2023-09-06 02:50:06 +08:00
|
|
|
if ((ret == true) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-19 02:50:19 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
/* recursive detect any vlen string in type (compound, array ...) */
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
ret = h5tools_detect_vlen_str(tid);
|
2023-09-06 02:50:06 +08:00
|
|
|
if ((ret == true) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
2011-03-19 02:50:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-10 04:00:20 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2011-03-15 05:03:20 +08:00
|
|
|
* Function: h5tools_detect_vlen_str
|
2011-03-10 04:00:20 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Recursive check for variable length string of a datatype.
|
2011-03-10 04:00:20 +08:00
|
|
|
*
|
2023-09-06 02:50:06 +08:00
|
|
|
* Return: true : type contains any variable length string
|
|
|
|
* false : type doesn't contain any variable length string
|
2017-10-25 00:03:00 +08:00
|
|
|
* Negative value: failed
|
2011-03-10 04:00:20 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
htri_t
|
2011-03-15 05:03:20 +08:00
|
|
|
h5tools_detect_vlen_str(hid_t tid)
|
2011-03-10 04:00:20 +08:00
|
|
|
{
|
|
|
|
H5T_class_t tclass = -1;
|
2023-09-06 02:50:06 +08:00
|
|
|
htri_t ret = false;
|
2011-03-10 04:00:20 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
ret = H5Tis_variable_str(tid);
|
2023-09-06 02:50:06 +08:00
|
|
|
if ((ret == true) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-10 04:00:20 +08:00
|
|
|
|
|
|
|
tclass = H5Tget_class(tid);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (tclass == H5T_ARRAY || tclass == H5T_VLEN) {
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
hid_t btid = H5Tget_super(tid);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (btid < 0) {
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
ret = (htri_t)btid;
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ret = h5tools_detect_vlen_str(btid);
|
2023-09-06 02:50:06 +08:00
|
|
|
if ((ret == true) || (ret < 0)) {
|
2011-03-22 07:02:31 +08:00
|
|
|
H5Tclose(btid);
|
|
|
|
goto done;
|
|
|
|
}
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else if (tclass == H5T_COMPOUND) {
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
unsigned nmembs;
|
2020-09-30 22:27:10 +08:00
|
|
|
int snmembs = H5Tget_nmembers(tid);
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
unsigned u;
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (snmembs < 0) {
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
ret = FAIL;
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
}
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
nmembs = (unsigned)snmembs;
|
2011-03-22 07:02:31 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < nmembs; u++) {
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
hid_t mtid = H5Tget_member_type(tid, u);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
ret = h5tools_detect_vlen_str(mtid);
|
2023-09-06 02:50:06 +08:00
|
|
|
if ((ret == true) || (ret < 0)) {
|
2011-03-10 04:00:20 +08:00
|
|
|
H5Tclose(mtid);
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
|
|
|
H5Tclose(mtid);
|
|
|
|
}
|
|
|
|
}
|
2011-03-22 07:02:31 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_simple_prefix
|
|
|
|
*
|
|
|
|
* Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
|
|
|
|
* applicable), calculate the prefix string, and display it at the start
|
|
|
|
* of a line.
|
|
|
|
*
|
|
|
|
* Return: None
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno,
|
|
|
|
int secnum)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2001-03-09 04:21:05 +08:00
|
|
|
h5tools_str_t prefix;
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t str; /*temporary for indentation */
|
|
|
|
size_t templength = 0;
|
|
|
|
unsigned u, indentlevel = 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (stream == NULL)
|
|
|
|
return;
|
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
if (!ctx->need_prefix)
|
2009-09-04 22:50:13 +08:00
|
|
|
return;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&prefix, 0, sizeof(h5tools_str_t));
|
|
|
|
memset(&str, 0, sizeof(h5tools_str_t));
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Terminate previous line, if any */
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_DEBUG("before CR elmtno=%ld, ctx->cur_column=%d, info->idx_fmt=%s, info->line_suf=%s", elmtno,
|
|
|
|
ctx->cur_column, info->idx_fmt, info->line_suf);
|
2001-03-09 04:21:05 +08:00
|
|
|
if (ctx->cur_column) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_suf, ""), stream);
|
2023-09-16 06:13:18 +08:00
|
|
|
putc('\n', stream);
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_sep, ""), stream);
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("after CR elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Calculate new prefix */
|
2020-07-16 00:20:16 +08:00
|
|
|
h5tools_str_prefix(&prefix, info, elmtno, ctx);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("prefix=%s - str=%s", prefix.s, str.s);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Write new prefix to output */
|
2016-06-29 05:53:48 +08:00
|
|
|
if (ctx->indent_level > 0)
|
2001-03-09 04:21:05 +08:00
|
|
|
indentlevel = ctx->indent_level;
|
2016-06-29 05:53:48 +08:00
|
|
|
else
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* This is because sometimes we don't print out all the header
|
|
|
|
* info for the data (like the tattr-2.ddl example). If that happens
|
|
|
|
* the ctx->indent_level is negative so we need to skip the above and
|
|
|
|
* just print out the default indent levels.
|
|
|
|
*/
|
|
|
|
indentlevel = ctx->default_indent_level;
|
|
|
|
|
|
|
|
/* when printing array indices, print the indentation before the prefix
|
|
|
|
the prefix is printed one indentation level before */
|
2016-06-29 05:53:48 +08:00
|
|
|
if (info->pindex)
|
|
|
|
for (u = 0; u < indentlevel - 1; u++)
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2016-06-29 05:53:48 +08:00
|
|
|
if (elmtno == 0 && secnum == 0 && info->line_1st)
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
|
2016-06-29 05:53:48 +08:00
|
|
|
else if (secnum && info->line_cont)
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
|
2016-06-29 05:53:48 +08:00
|
|
|
else
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
templength = h5tools_str_len(&prefix);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("prefix=%s - templength=%d", prefix.s, templength);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
for (u = 0; u < indentlevel; u++) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/*we already made the indent for the array indices case */
|
|
|
|
if (!info->pindex) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
templength += h5tools_str_len(&prefix);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*we cannot count the prefix for the array indices case */
|
|
|
|
templength += h5tools_str_len(&str);
|
|
|
|
}
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("prefix=%s - templength=%d", prefix.s, templength);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
ctx->cur_column = ctx->prev_prefix_len = templength;
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->cur_elmt = 0;
|
|
|
|
ctx->need_prefix = 0;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("prefix=%s - str=%s", prefix.s, str.s);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Free string */
|
|
|
|
h5tools_str_close(&prefix);
|
|
|
|
h5tools_str_close(&str);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_region_simple_prefix
|
|
|
|
*
|
|
|
|
* Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
|
|
|
|
* applicable), calculate the prefix string, and display it at the start
|
|
|
|
* of a line. Calls region specific function.
|
|
|
|
*
|
|
|
|
* Return: None
|
2009-09-04 22:50:13 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
void
|
2020-07-16 00:20:16 +08:00
|
|
|
h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t elmtno, hsize_t *ptdata, int secnum)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
|
|
|
h5tools_str_t prefix;
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t str; /*temporary for indentation */
|
|
|
|
size_t templength = 0;
|
|
|
|
unsigned u, indentlevel = 0;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (stream == NULL)
|
|
|
|
return;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!ctx->need_prefix)
|
|
|
|
return;
|
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&prefix, 0, sizeof(h5tools_str_t));
|
|
|
|
memset(&str, 0, sizeof(h5tools_str_t));
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Terminate previous line, if any */
|
|
|
|
if (ctx->cur_column) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_suf, ""), stream);
|
2023-09-16 06:13:18 +08:00
|
|
|
putc('\n', stream);
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_sep, ""), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate new prefix */
|
2020-07-16 00:20:16 +08:00
|
|
|
h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Write new prefix to output */
|
2016-06-29 05:53:48 +08:00
|
|
|
if (ctx->indent_level > 0)
|
2009-09-04 22:50:13 +08:00
|
|
|
indentlevel = ctx->indent_level;
|
2014-03-22 07:02:24 +08:00
|
|
|
else
|
2001-03-09 04:21:05 +08:00
|
|
|
/*
|
2001-04-11 03:54:08 +08:00
|
|
|
* This is because sometimes we don't print out all the header
|
|
|
|
* info for the data (like the tattr-2.ddl example). If that happens
|
|
|
|
* the ctx->indent_level is negative so we need to skip the above and
|
|
|
|
* just print out the default indent levels.
|
2001-03-09 04:21:05 +08:00
|
|
|
*/
|
2009-09-04 22:50:13 +08:00
|
|
|
indentlevel = ctx->default_indent_level;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2004-07-01 02:45:14 +08:00
|
|
|
/* when printing array indices, print the indentation before the prefix
|
|
|
|
the prefix is printed one indentation level before */
|
2014-03-22 07:02:24 +08:00
|
|
|
if (info->pindex)
|
2016-06-29 05:53:48 +08:00
|
|
|
for (u = 0; u < indentlevel - 1; u++)
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
|
2004-07-01 02:45:14 +08:00
|
|
|
|
2016-06-29 05:53:48 +08:00
|
|
|
if (elmtno == 0 && secnum == 0 && info->line_1st)
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
|
2016-06-29 05:53:48 +08:00
|
|
|
else if (secnum && info->line_cont)
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
|
2016-06-29 05:53:48 +08:00
|
|
|
else
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
templength = h5tools_str_len(&prefix);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2016-06-29 05:53:48 +08:00
|
|
|
for (u = 0; u < indentlevel; u++)
|
2004-07-01 02:45:14 +08:00
|
|
|
/*we already made the indent for the array indices case */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!info->pindex) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
templength += h5tools_str_len(&prefix);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*we cannot count the prefix for the array indices case */
|
|
|
|
templength += h5tools_str_len(&str);
|
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
ctx->cur_column = ctx->prev_prefix_len = templength;
|
2020-09-30 22:27:10 +08:00
|
|
|
ctx->cur_elmt = 0;
|
|
|
|
ctx->need_prefix = 0;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/* Free string */
|
|
|
|
h5tools_str_close(&prefix);
|
2004-07-01 02:45:14 +08:00
|
|
|
h5tools_str_close(&str);
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_render_element
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Prints the string buffer to the output STREAM. The string is
|
|
|
|
* printed according to the format described in INFO. The CTX struct
|
|
|
|
* contains context information shared between calls to this function.
|
|
|
|
*
|
|
|
|
* Return: False if a dimension end is reached
|
|
|
|
* True otherwise
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2017-10-23 22:26:15 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* h5tools_str_t *buffer
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
2017-10-23 22:26:15 +08:00
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t local_elmt_counter is the local element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-07-16 00:20:16 +08:00
|
|
|
h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter,
|
|
|
|
hsize_t elmt_counter)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
|
|
|
char *s = NULL;
|
|
|
|
char *section = NULL; /* a section of output */
|
|
|
|
int secnum; /* section sequence number */
|
|
|
|
int multiline; /* datum was multiline */
|
2007-01-11 03:15:16 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (stream == NULL)
|
|
|
|
return dimension_break;
|
|
|
|
|
2020-01-24 00:20:34 +08:00
|
|
|
H5TOOLS_START_DEBUG(" need_prefix=%d", ctx->need_prefix);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2013-10-11 05:57:04 +08:00
|
|
|
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("s=%s", s);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the element would split on multiple lines if printed at our
|
|
|
|
* current location...
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
2023-09-16 06:13:18 +08:00
|
|
|
(ctx->cur_column + h5tools_count_ncols(s) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
if (ctx->prev_multiline) {
|
|
|
|
/*
|
|
|
|
* ... and the previous element also occupied more than one
|
|
|
|
* line, then start this element at the beginning of a line.
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) <= ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* ...but *could* fit on one line otherwise, then we
|
|
|
|
* should end the current line and start this element on its
|
|
|
|
* own line.
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2001-04-11 03:54:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* We need to break after each row of a dimension---> we should
|
|
|
|
* break at the end of the each last dimension well that is the
|
|
|
|
* way the dumper did it before
|
|
|
|
*/
|
|
|
|
if (info->arr_linebreak && ctx->cur_elmt) {
|
|
|
|
if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (elmt_counter == ctx->size_last_dim) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
|
|
|
dimension_break = false;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_DEBUG("elmt_counter=%ld - ctx->size_last_dim=%ld info->line_suf=%s", elmt_counter,
|
|
|
|
ctx->size_last_dim, info->line_suf);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*
|
2009-09-04 22:50:13 +08:00
|
|
|
* If the previous element occupied multiple lines and this element
|
|
|
|
* is too long to fit on a line then start this element at the
|
|
|
|
* beginning of the line.
|
2001-02-23 05:55:15 +08:00
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
if (info->line_multi_new == 1 && ctx->prev_multiline &&
|
2023-09-16 06:13:18 +08:00
|
|
|
(ctx->cur_column + h5tools_count_ncols(s) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If too many elements have already been printed then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
|
|
|
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
|
|
|
|
* the data to split across multiple lines. We display the sections
|
|
|
|
* one-at a time.
|
|
|
|
*/
|
|
|
|
multiline = 0;
|
2023-09-16 06:13:18 +08:00
|
|
|
for (secnum = 0, multiline = 0; (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the current section plus possible suffix and end-of-line
|
|
|
|
* information would cause the output to wrap then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
2011-02-16 03:28:48 +08:00
|
|
|
* check for displaying prefix for each section
|
2009-09-04 22:50:13 +08:00
|
|
|
*/
|
2023-09-16 06:13:18 +08:00
|
|
|
if ((ctx->cur_column + strlen(section) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = 1;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Print the prefix or separate the beginning of this element
|
|
|
|
* from the previous element.
|
|
|
|
*/
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
|
2009-09-04 22:50:13 +08:00
|
|
|
if (ctx->need_prefix) {
|
|
|
|
if (secnum)
|
|
|
|
multiline++;
|
2007-01-11 03:15:16 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* pass to the prefix in h5tools_simple_prefix the total
|
|
|
|
* position instead of the current stripmine position i;
|
|
|
|
* this is necessary to print the array indices
|
|
|
|
*/
|
|
|
|
*curr_pos = ctx->sm_pos + local_elmt_counter;
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_DEBUG("curr_pos=%ld - ctx->sm_pos=%ld - ctx->ndims=%ld", *curr_pos, ctx->sm_pos,
|
|
|
|
ctx->ndims);
|
2008-01-15 02:47:50 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum);
|
|
|
|
}
|
|
|
|
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
|
2023-09-16 06:13:18 +08:00
|
|
|
ctx->cur_column += strlen(OPT(info->elmt_suf2, " "));
|
2008-01-15 02:47:50 +08:00
|
|
|
}
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("section=%s", section);
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Print the section */
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(section, stream);
|
2023-09-16 06:13:18 +08:00
|
|
|
ctx->cur_column += strlen(section);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2008-01-11 05:31:28 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->prev_multiline = multiline;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
return dimension_break;
|
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_render_region_element
|
|
|
|
*
|
|
|
|
* Purpose: Prints the string buffer to the output STREAM. The string is
|
|
|
|
* printed according to the format described in INFO. The CTX struct
|
|
|
|
* contains context information shared between calls to this function.
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return:
|
2017-10-23 22:26:15 +08:00
|
|
|
* False if a dimension end is reached
|
|
|
|
* True otherwise
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2017-10-23 22:26:15 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* h5tools_str_t *buffer
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
2017-10-23 22:26:15 +08:00
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t *ptdata
|
|
|
|
* hsize_t local_elmt_counter is the local element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
2009-09-04 22:50:13 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-07-16 00:20:16 +08:00
|
|
|
h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t *ptdata,
|
|
|
|
hsize_t local_elmt_counter, hsize_t elmt_counter)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
2023-09-06 02:50:06 +08:00
|
|
|
bool dimension_break = true;
|
|
|
|
char *s = NULL;
|
|
|
|
char *section = NULL; /* a section of output */
|
|
|
|
int secnum; /* section sequence number */
|
|
|
|
int multiline; /* datum was multiline */
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter);
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2013-10-11 05:57:04 +08:00
|
|
|
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the element would split on multiple lines if printed at our
|
|
|
|
* current location...
|
|
|
|
*/
|
2020-07-16 00:20:16 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
2023-09-16 06:13:18 +08:00
|
|
|
(ctx->cur_column + h5tools_count_ncols(s) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
if (ctx->prev_multiline) {
|
|
|
|
/*
|
|
|
|
* ... and the previous element also occupied more than one
|
|
|
|
* line, then start this element at the beginning of a line.
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) <= ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* ...but *could* fit on one line otherwise, then we
|
|
|
|
* should end the current line and start this element on its
|
|
|
|
* own line.
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2007-01-11 03:15:16 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* We need to break after each row of a dimension---> we should
|
|
|
|
* break at the end of the each last dimension well that is the
|
|
|
|
* way the dumper did it before
|
|
|
|
*/
|
|
|
|
if (info->arr_linebreak && ctx->cur_elmt) {
|
|
|
|
if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (elmt_counter == ctx->size_last_dim) {
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
|
|
|
dimension_break = false;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the previous element occupied multiple lines and this element
|
|
|
|
* is too long to fit on a line then start this element at the
|
|
|
|
* beginning of the line.
|
|
|
|
*/
|
2019-11-07 23:48:56 +08:00
|
|
|
if (info->line_multi_new == 1 && ctx->prev_multiline &&
|
2023-09-16 06:13:18 +08:00
|
|
|
(ctx->cur_column + h5tools_count_ncols(s) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If too many elements have already been printed then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
|
|
|
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
|
2023-09-06 02:50:06 +08:00
|
|
|
ctx->need_prefix = true;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
|
|
|
|
* the data to split across multiple lines. We display the sections
|
|
|
|
* one-at a time.
|
|
|
|
*/
|
|
|
|
multiline = 0;
|
2023-09-16 06:13:18 +08:00
|
|
|
for (secnum = 0, multiline = 0; (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the current section plus possible suffix and end-of-line
|
|
|
|
* information would cause the output to wrap then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Added the info->skip_first because the dumper does not want
|
|
|
|
* this check to happen for the first line
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if ((!info->skip_first || local_elmt_counter) &&
|
2023-09-16 06:13:18 +08:00
|
|
|
(ctx->cur_column + strlen(section) + strlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
strlen(OPT(info->line_suf, ""))) > ncols)
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = 1;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Print the prefix or separate the beginning of this element
|
|
|
|
* from the previous element.
|
|
|
|
*/
|
|
|
|
if (ctx->need_prefix) {
|
|
|
|
if (secnum)
|
|
|
|
multiline++;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
/* pass to the prefix in h5tools_region_simple_prefix the total
|
2009-09-04 22:50:13 +08:00
|
|
|
* position instead of the current stripmine position i;
|
|
|
|
* this is necessary to print the array indices
|
|
|
|
*/
|
|
|
|
*curr_pos = ctx->sm_pos + local_elmt_counter;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("curr_pos=%ld - ctx->sm_pos=%ld", *curr_pos, ctx->sm_pos);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum);
|
2001-04-11 03:54:08 +08:00
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
|
2023-09-16 06:13:18 +08:00
|
|
|
ctx->cur_column += strlen(OPT(info->elmt_suf2, " "));
|
2001-04-11 03:54:08 +08:00
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Print the section */
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(section, stream);
|
2023-09-16 06:13:18 +08:00
|
|
|
ctx->cur_column += strlen(section);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->prev_multiline = multiline;
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
return dimension_break;
|
|
|
|
}
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: init_acc_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: initialize accumulator and matrix position
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: void
|
2009-09-15 03:52:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
void
|
2021-03-10 00:59:44 +08:00
|
|
|
init_acc_pos(unsigned ndims, const hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx)
|
2010-10-21 21:08:44 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int i;
|
2012-05-26 01:39:07 +08:00
|
|
|
unsigned j;
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2020-07-16 00:20:16 +08:00
|
|
|
for (i = 0; (unsigned)i < ndims; i++)
|
|
|
|
p_min_idx[i] = 0;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (ndims > 0) {
|
2020-07-16 00:20:16 +08:00
|
|
|
acc[ndims - 1] = 1;
|
|
|
|
for (i = ((int)ndims - 2); i >= 0; i--) {
|
|
|
|
acc[i] = acc[i + 1] * dims[i + 1];
|
|
|
|
H5TOOLS_DEBUG("acc[%d]=%ld", i, acc[i]);
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2020-07-16 00:20:16 +08:00
|
|
|
for (j = 0; j < ndims; j++)
|
|
|
|
pos[j] = 0;
|
2017-08-24 05:12:40 +08:00
|
|
|
}
|
2019-11-07 23:48:56 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2009-09-15 03:52:42 +08:00
|
|
|
}
|
|
|
|
|
2020-07-16 00:20:16 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: calc_acc_pos
|
|
|
|
*
|
|
|
|
* Purpose: Calculate the number of elements represented by a unit change
|
|
|
|
* in a certain index position.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
hsize_t
|
2021-03-10 00:59:44 +08:00
|
|
|
calc_acc_pos(unsigned ndims, hsize_t elmtno, const hsize_t *acc, hsize_t *pos)
|
2020-07-16 00:20:16 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int i;
|
|
|
|
hsize_t curr_pos = elmtno;
|
2020-07-16 00:20:16 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-07-16 00:20:16 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (ndims > 0) {
|
|
|
|
for (i = 0; i < (int)ndims; i++) {
|
|
|
|
if (curr_pos > 0) {
|
2020-07-16 00:20:16 +08:00
|
|
|
H5TOOLS_DEBUG("curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, acc[i]);
|
|
|
|
pos[i] = curr_pos / acc[i];
|
|
|
|
curr_pos -= acc[i] * pos[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pos[i] = 0;
|
|
|
|
H5TOOLS_DEBUG("curr_pos=%ld - pos[%d]=%ld - acc[%d]=%ld", curr_pos, i, pos[i], i, acc[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2020-07-16 00:20:16 +08:00
|
|
|
|
|
|
|
return curr_pos;
|
|
|
|
}
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
* Function: render_bin_output
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Write one element of memory buffer to a binary file stream
|
2006-06-26 22:41:59 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
2006-06-26 22:41:59 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-07-26 06:17:48 +08:00
|
|
|
int
|
2020-09-30 22:27:10 +08:00
|
|
|
render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts)
|
2012-07-26 06:17:48 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned char *mem = (unsigned char *)_mem;
|
|
|
|
size_t size; /* datum size */
|
2019-12-28 16:16:44 +08:00
|
|
|
hsize_t block_index;
|
|
|
|
H5T_class_t type_class;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
int ret_value = 0;
|
2012-07-26 06:17:48 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((size = H5Tget_size(tid)) == 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_size failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_class = H5Tget_class(tid)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_class failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
|
|
|
|
switch (type_class) {
|
|
|
|
case H5T_INTEGER:
|
|
|
|
case H5T_FLOAT:
|
|
|
|
case H5T_ENUM:
|
2017-05-10 23:59:13 +08:00
|
|
|
case H5T_BITFIELD:
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("numbers");
|
2012-07-26 06:17:48 +08:00
|
|
|
block_index = block_nelmts * size;
|
2020-09-30 22:27:10 +08:00
|
|
|
while (block_index > 0) {
|
|
|
|
size_t bytes_in = 0; /* # of bytes to write */
|
|
|
|
size_t bytes_wrote = 0; /* # of bytes written */
|
2012-07-26 06:17:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (block_index > sizeof(size_t))
|
2012-07-26 06:17:48 +08:00
|
|
|
bytes_in = sizeof(size_t);
|
|
|
|
else
|
|
|
|
bytes_in = (size_t)block_index;
|
|
|
|
|
2023-06-29 23:19:31 +08:00
|
|
|
bytes_wrote = fwrite(mem, 1, bytes_in, stream);
|
2012-07-26 06:17:48 +08:00
|
|
|
|
2023-06-29 23:19:31 +08:00
|
|
|
if (bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(stream)))
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "fwrite failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
|
|
|
|
block_index -= (hsize_t)bytes_wrote;
|
|
|
|
mem = mem + bytes_wrote;
|
|
|
|
}
|
|
|
|
break;
|
2020-09-30 22:27:10 +08:00
|
|
|
case H5T_STRING: {
|
|
|
|
unsigned int i;
|
|
|
|
H5T_str_t pad;
|
2022-07-27 05:45:46 +08:00
|
|
|
char *s = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned char tempuchar;
|
2012-07-26 06:17:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_DEBUG("H5T_STRING");
|
|
|
|
pad = H5Tget_strpad(tid);
|
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
|
|
|
mem = ((unsigned char *)_mem) + block_index * size;
|
|
|
|
|
|
|
|
if (H5Tis_variable_str(tid)) {
|
|
|
|
s = *(char **)((void *)mem);
|
|
|
|
if (s != NULL)
|
2023-09-16 06:13:18 +08:00
|
|
|
size = strlen(s);
|
2020-09-30 22:27:10 +08:00
|
|
|
else
|
|
|
|
H5TOOLS_THROW((-1), "NULL string");
|
2017-08-24 05:12:40 +08:00
|
|
|
}
|
|
|
|
else {
|
2020-09-30 22:27:10 +08:00
|
|
|
s = (char *)mem;
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
|
2023-06-30 03:33:46 +08:00
|
|
|
memcpy(&tempuchar, &s[i], sizeof(unsigned char));
|
2023-06-29 23:19:31 +08:00
|
|
|
if (1 != fwrite(&tempuchar, sizeof(unsigned char), 1, stream))
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_THROW((-1), "fwrite failed");
|
|
|
|
} /* i */
|
|
|
|
} /* for (block_index = 0; block_index < block_nelmts; block_index++) */
|
|
|
|
} break;
|
|
|
|
case H5T_COMPOUND: {
|
|
|
|
int snmembs;
|
|
|
|
unsigned nmembs;
|
|
|
|
|
|
|
|
H5TOOLS_DEBUG("H5T_COMPOUND");
|
|
|
|
if ((snmembs = H5Tget_nmembers(tid)) < 0)
|
|
|
|
H5TOOLS_THROW((-1), "H5Tget_nmembers of compound failed");
|
|
|
|
nmembs = (unsigned)snmembs;
|
2012-07-26 06:17:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
|
|
|
unsigned j;
|
|
|
|
|
|
|
|
mem = ((unsigned char *)_mem) + block_index * size;
|
|
|
|
for (j = 0; j < nmembs; j++) {
|
|
|
|
hid_t memb = H5I_INVALID_HID;
|
|
|
|
size_t offset;
|
|
|
|
|
|
|
|
offset = H5Tget_member_offset(tid, j);
|
|
|
|
memb = H5Tget_member_type(tid, j);
|
|
|
|
|
|
|
|
if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) {
|
2013-09-06 04:44:14 +08:00
|
|
|
H5Tclose(memb);
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_THROW((-1), "render_bin_output of compound member failed");
|
2013-09-06 04:44:14 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
H5Tclose(memb);
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
} break;
|
|
|
|
case H5T_ARRAY: {
|
|
|
|
int k, ndims;
|
2021-02-20 01:25:44 +08:00
|
|
|
hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts = 0;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t memb = H5I_INVALID_HID;
|
|
|
|
|
|
|
|
H5TOOLS_DEBUG("H5T_ARRAY");
|
|
|
|
/* get the array's base datatype for each element */
|
|
|
|
memb = H5Tget_super(tid);
|
|
|
|
ndims = H5Tget_array_ndims(tid);
|
|
|
|
H5Tget_array_dims2(tid, dims);
|
|
|
|
if (ndims >= 1 && ndims <= H5S_MAX_RANK) {
|
|
|
|
/* calculate the number of array elements */
|
|
|
|
for (k = 0, nelmts = 1; k < ndims; k++) {
|
|
|
|
temp_nelmts = nelmts;
|
|
|
|
temp_nelmts *= dims[k];
|
|
|
|
nelmts = (size_t)temp_nelmts;
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else {
|
2012-07-26 06:17:48 +08:00
|
|
|
H5Tclose(memb);
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_THROW((-1), "calculate the number of array elements failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
|
|
|
mem = ((unsigned char *)_mem) + block_index * size;
|
|
|
|
/* dump the array element */
|
|
|
|
if (render_bin_output(stream, container, memb, mem, nelmts) < 0) {
|
|
|
|
H5Tclose(memb);
|
|
|
|
H5TOOLS_THROW((-1), "render_bin_output failed");
|
2019-11-07 23:48:56 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
H5Tclose(memb);
|
|
|
|
} break;
|
|
|
|
case H5T_VLEN: {
|
|
|
|
hsize_t nelmts;
|
|
|
|
hid_t memb = H5I_INVALID_HID;
|
|
|
|
|
|
|
|
H5TOOLS_DEBUG("H5T_VLEN");
|
|
|
|
/* get the VL sequences's base datatype for each element */
|
|
|
|
memb = H5Tget_super(tid);
|
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
|
|
|
mem = ((unsigned char *)_mem) + block_index * size;
|
|
|
|
/* Get the number of sequence elements */
|
|
|
|
nelmts = ((hvl_t *)((void *)mem))->len;
|
|
|
|
|
|
|
|
/* dump the array element */
|
|
|
|
if (render_bin_output(stream, container, memb, ((char *)(((hvl_t *)((void *)mem))->p)),
|
|
|
|
nelmts) < 0) {
|
|
|
|
H5Tclose(memb);
|
|
|
|
H5TOOLS_THROW((-1), "render_bin_output failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Tclose(memb);
|
|
|
|
} break;
|
|
|
|
case H5T_REFERENCE: {
|
|
|
|
H5TOOLS_DEBUG("reference class type");
|
|
|
|
if (H5Tequal(tid, H5T_STD_REF)) {
|
|
|
|
H5TOOLS_DEBUG("H5T_STD_REF");
|
|
|
|
if (region_output) {
|
|
|
|
/* region data */
|
|
|
|
hid_t region_id = H5I_INVALID_HID;
|
|
|
|
hid_t region_space = H5I_INVALID_HID;
|
|
|
|
H5S_sel_type region_type;
|
2021-11-23 22:05:01 +08:00
|
|
|
H5R_ref_t tref;
|
|
|
|
|
|
|
|
if (size > sizeof(tref))
|
|
|
|
H5TOOLS_THROW((-1), "unexpectedly large ref");
|
|
|
|
|
2023-06-30 03:33:46 +08:00
|
|
|
memset(&tref, 0, sizeof(tref));
|
2020-09-30 22:27:10 +08:00
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
|
|
|
mem = ((unsigned char *)_mem) + block_index * size;
|
2023-06-30 03:33:46 +08:00
|
|
|
memcpy(&tref, mem, size);
|
2021-11-23 22:05:01 +08:00
|
|
|
if ((region_id = H5Ropen_object(&tref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
2020-09-30 22:27:10 +08:00
|
|
|
H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed");
|
|
|
|
else {
|
2021-11-23 22:05:01 +08:00
|
|
|
if ((region_space = H5Ropen_region(&tref, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
|
|
|
|
if (!h5tools_is_zero(&tref, H5Tget_size(H5T_STD_REF))) {
|
2022-04-16 04:19:21 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
region_type = H5Sget_select_type(region_space);
|
|
|
|
if (region_type == H5S_SEL_POINTS)
|
|
|
|
render_bin_output_region_points(region_space, region_id, stream,
|
|
|
|
container);
|
|
|
|
else
|
|
|
|
render_bin_output_region_blocks(region_space, region_id, stream,
|
|
|
|
container);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
H5TOOLS_INFO("H5Ropen_object H5T_STD_REF NULL");
|
|
|
|
}
|
|
|
|
H5Sclose(region_space);
|
|
|
|
} /* end if (region_space >= 0) */
|
|
|
|
H5Dclose(region_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* end if (region_output... */
|
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
|
|
|
|
/* if (size == H5R_DSET_REG_REF_BUF_SIZE) */
|
|
|
|
H5TOOLS_DEBUG("H5T_STD_REF_DSETREG");
|
|
|
|
}
|
|
|
|
else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
|
|
|
|
/* if (size == H5R_OBJ_REF_BUF_SIZE) */
|
|
|
|
H5TOOLS_DEBUG("H5T_STD_REF_OBJ");
|
|
|
|
}
|
|
|
|
} break;
|
2015-09-01 03:04:23 +08:00
|
|
|
|
|
|
|
case H5T_TIME:
|
|
|
|
case H5T_OPAQUE:
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_DEBUG("H5T_OPAQUE");
|
2012-07-26 06:17:48 +08:00
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
2020-09-30 22:27:10 +08:00
|
|
|
mem = ((unsigned char *)_mem) + block_index * size;
|
2023-06-29 23:19:31 +08:00
|
|
|
if (size != fwrite(mem, sizeof(char), size, stream))
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "fwrite failed");
|
2015-09-01 03:04:23 +08:00
|
|
|
} /* end for */
|
2012-07-26 06:17:48 +08:00
|
|
|
break;
|
2015-09-01 03:04:23 +08:00
|
|
|
|
|
|
|
case H5T_NO_CLASS:
|
|
|
|
case H5T_NCLASSES:
|
|
|
|
default:
|
|
|
|
/* Badness */
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "bad type class");
|
2015-09-01 03:04:23 +08:00
|
|
|
break;
|
|
|
|
} /* end switch */
|
2012-07-26 06:17:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2012-07-26 06:17:48 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: render_bin_output_region_data_blocks
|
2010-08-10 02:15:37 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Print the data values from a dataset referenced by region blocks.
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type blocks.
|
2010-08-10 02:15:37 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: FAIL if there was an error
|
|
|
|
* SUCCEED otherwise
|
2010-08-10 02:15:37 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
int
|
2020-09-30 22:27:10 +08:00
|
|
|
render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, unsigned ndims,
|
2021-03-10 00:59:44 +08:00
|
|
|
hid_t type_id, hsize_t nblocks, const hsize_t *ptdata)
|
2010-08-13 05:11:00 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
hsize_t *start = NULL;
|
|
|
|
hsize_t *count = NULL;
|
|
|
|
hsize_t numelem;
|
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
|
|
|
unsigned jndx;
|
|
|
|
size_t type_size;
|
|
|
|
hid_t mem_space = H5I_INVALID_HID;
|
2022-07-27 05:45:46 +08:00
|
|
|
void *region_buf = NULL;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t blkndx;
|
|
|
|
hid_t sid1 = H5I_INVALID_HID;
|
|
|
|
int ret_value = -1;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2010-08-10 02:15:37 +08:00
|
|
|
/* Get the dataspace of the dataset */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sid1 = H5Dget_space(region_id)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Dget_space failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((dims1 = (hsize_t *)malloc(sizeof(hsize_t) * ndims)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate buffer for dims");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* find the dimensions of each data space from the block coordinates */
|
|
|
|
numelem = 1;
|
|
|
|
for (jndx = 0; jndx < ndims; jndx++) {
|
|
|
|
dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1;
|
2020-09-30 22:27:10 +08:00
|
|
|
numelem = dims1[jndx] * numelem;
|
2010-08-10 02:15:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create dataspace for reading buffer */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Screate_simple failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_size = H5Tget_size(type_id)) == 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "H5Tget_size failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((region_buf = malloc(type_size * (size_t)numelem)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate region buffer");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
|
|
|
|
/* 1 2 n 1 2 n */
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((start = (hsize_t *)malloc(sizeof(hsize_t) * ndims)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate buffer for start");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((count = (hsize_t *)malloc(sizeof(hsize_t) * ndims)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_THROW((-1), "Could not allocate buffer for count");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
for (blkndx = 0; blkndx < nblocks; blkndx++) {
|
|
|
|
for (jndx = 0; jndx < ndims; jndx++) {
|
|
|
|
start[jndx] = ptdata[jndx + blkndx * ndims * 2];
|
|
|
|
count[jndx] = dims1[jndx];
|
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (render_bin_output(stream, container, type_id, (char *)region_buf, numelem) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data region failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
/* Render the region data element end */
|
2020-09-30 22:27:10 +08:00
|
|
|
done:;
|
2010-08-10 02:15:37 +08:00
|
|
|
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2023-06-29 06:48:12 +08:00
|
|
|
free(start);
|
|
|
|
free(count);
|
|
|
|
free(region_buf);
|
|
|
|
free(dims1);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(mem_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sclose failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(sid1) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sclose failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2010-08-10 02:15:37 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: render_bin_output_region_blocks
|
2010-08-10 02:15:37 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Print some values from a dataset referenced by region blocks.
|
|
|
|
* This is a special case subfunction to dump a region reference using blocks.
|
2010-08-10 02:15:37 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: False if ERROR
|
|
|
|
* True otherwise
|
2010-08-10 02:15:37 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-09-30 22:27:10 +08:00
|
|
|
render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container)
|
2010-08-13 05:11:00 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
hssize_t snblocks;
|
|
|
|
hsize_t nblocks;
|
|
|
|
hsize_t alloc_size;
|
|
|
|
hsize_t *ptdata = NULL;
|
|
|
|
int sndims;
|
|
|
|
unsigned ndims;
|
|
|
|
hid_t dtype = H5I_INVALID_HID;
|
|
|
|
hid_t type_id = H5I_INVALID_HID;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
|
|
|
bool ret_value = true;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_THROW(false, "H5Sget_select_hyper_nblocks failed");
|
2013-02-02 09:53:32 +08:00
|
|
|
nblocks = (hsize_t)snblocks;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Print block information */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_THROW(false, "H5Sget_simple_extent_ndims failed");
|
2016-06-29 05:53:48 +08:00
|
|
|
ndims = (unsigned)sndims;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((ptdata = (hsize_t *)malloc((size_t)alloc_size)) == NULL)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(false, "Could not allocate buffer for ptdata");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(false, "H5Rget_select_hyper_blocklist failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((dtype = H5Dget_type(region_id)) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(false, "H5Dget_type failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(false, "H5Tget_native_type failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
render_bin_output_region_data_blocks(region_id, stream, container, ndims, type_id, nblocks, ptdata);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
done:
|
2023-06-29 06:48:12 +08:00
|
|
|
free(ptdata);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (type_id > 0 && H5Tclose(type_id) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_ERROR(false, "H5Tclose failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (dtype > 0 && H5Tclose(dtype) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_ERROR(false, "H5Tclose failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
H5_LEAVE(true);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2010-08-10 02:15:37 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: H5Tools Library
|
2010-08-10 02:15:37 +08:00
|
|
|
* Purpose: Print the data values from a dataset referenced by region points.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type points.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns FAIL on error, otherwise SUCCEED
|
|
|
|
*
|
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* size_t ncols
|
|
|
|
* int ndims is the number of dimensions of the region element
|
|
|
|
* hssize_t npoints is the number of points in the region
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2013-07-31 01:04:23 +08:00
|
|
|
int
|
2020-09-30 22:27:10 +08:00
|
|
|
render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container,
|
|
|
|
unsigned ndims, hid_t type_id, hsize_t npoints)
|
2010-08-13 05:11:00 +08:00
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
2016-06-29 05:53:48 +08:00
|
|
|
size_t type_size;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t mem_space = H5I_INVALID_HID;
|
2022-07-27 05:45:46 +08:00
|
|
|
void *region_buf = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
int ret_value = 0;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_size = H5Tget_size(type_id)) == 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((region_buf = malloc(type_size * (size_t)npoints)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for region");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
2023-06-29 06:48:12 +08:00
|
|
|
if ((dims1 = (hsize_t *)malloc(sizeof(hsize_t) * ndims)) == NULL)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for dims");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
dims1[0] = npoints;
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Screate_simple failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (render_bin_output(stream, container, type_id, (char *)region_buf, npoints) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data points failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
done:
|
2023-06-29 06:48:12 +08:00
|
|
|
free(region_buf);
|
|
|
|
free(dims1);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Sclose(mem_space) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_ERROR((-1), "H5Sclose failed");
|
2010-10-21 21:08:44 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2010-08-10 02:15:37 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: render_bin_output_region_points
|
2010-08-10 02:15:37 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Print some values from a dataset referenced by region points.
|
2017-10-25 00:03:00 +08:00
|
|
|
* This is a special case function to dump a region reference using points.
|
2010-08-10 02:15:37 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Return: False if the last dimension has been reached
|
|
|
|
* True otherwise
|
2010-08-10 02:15:37 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-09-30 22:27:10 +08:00
|
|
|
render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container)
|
2010-08-13 05:11:00 +08:00
|
|
|
{
|
2016-06-29 05:53:48 +08:00
|
|
|
hssize_t snpoints;
|
|
|
|
hsize_t npoints;
|
|
|
|
int sndims;
|
|
|
|
unsigned ndims;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t dtype = H5I_INVALID_HID;
|
|
|
|
hid_t type_id = H5I_INVALID_HID;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool past_catch = false;
|
|
|
|
bool ret_value = true;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_START_DEBUG(" ");
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_THROW(false, "H5Sget_select_elem_npoints failed");
|
2016-06-29 05:53:48 +08:00
|
|
|
npoints = (hsize_t)snpoints;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_THROW(false, "H5Sget_simple_extent_ndims failed");
|
2016-06-29 05:53:48 +08:00
|
|
|
ndims = (unsigned)sndims;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((dtype = H5Dget_type(region_id)) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(false, "H5Dget_type failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(false, "H5Tget_native_type failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2019-11-07 23:48:56 +08:00
|
|
|
render_bin_output_region_data_points(region_space, region_id, stream, container, ndims, type_id, npoints);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
done:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (type_id > 0 && H5Tclose(type_id) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_ERROR(false, "H5Tclose failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (dtype > 0 && H5Tclose(dtype) < 0)
|
2023-09-06 02:50:06 +08:00
|
|
|
H5TOOLS_ERROR(false, "H5Tclose failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2023-07-25 05:18:04 +08:00
|
|
|
H5_LEAVE(ret_value);
|
2020-09-30 22:27:10 +08:00
|
|
|
CATCH
|
2021-05-06 06:08:10 +08:00
|
|
|
H5TOOLS_ENDDEBUG(" ");
|
2010-08-10 02:15:37 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_is_zero
|
2009-09-04 22:50:13 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Determines if memory is initialized to all zero bytes.
|
2009-09-04 22:50:13 +08:00
|
|
|
*
|
2023-09-06 02:50:06 +08:00
|
|
|
* Return: true if all bytes are zero
|
|
|
|
* false otherwise
|
2009-09-04 22:50:13 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
H5_ATTR_PURE bool
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_is_zero(const void *_mem, size_t size)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
const unsigned char *mem = (const unsigned char *)_mem;
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
while (size-- > 0)
|
|
|
|
if (mem[size])
|
2023-09-06 02:50:06 +08:00
|
|
|
return false;
|
2006-06-26 22:41:59 +08:00
|
|
|
|
2023-09-06 02:50:06 +08:00
|
|
|
return true;
|
2006-06-26 22:41:59 +08:00
|
|
|
}
|
|
|
|
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-23 22:26:15 +08:00
|
|
|
* Function: h5tools_is_obj_same
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
*
|
2017-10-23 22:26:15 +08:00
|
|
|
* Purpose: Check if two given object IDs or link names point to the same object.
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
*
|
|
|
|
* Parameters:
|
2017-10-23 22:26:15 +08:00
|
|
|
* hid_t loc_id1: location of the first object
|
|
|
|
* char *name1: link name of the first object.
|
|
|
|
* Use "." or NULL if loc_id1 is the object to be compared.
|
|
|
|
* hid_t loc_id2: location of the second object
|
|
|
|
* char *name1: link name of the first object.
|
|
|
|
* Use "." or NULL if loc_id2 is the object to be compared.
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
*
|
2023-09-06 02:50:06 +08:00
|
|
|
* Return: true if it is the same object
|
|
|
|
* false otherwise.
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2023-09-06 02:50:06 +08:00
|
|
|
bool
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2)
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
{
|
2020-01-17 05:29:34 +08:00
|
|
|
H5O_info2_t oinfo1, oinfo2;
|
2023-09-06 02:50:06 +08:00
|
|
|
bool ret_val = false;
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (name1 && strcmp(name1, ".") != 0)
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Oget_info_by_name3(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
else
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Oget_info3(loc_id1, &oinfo1, H5O_INFO_BASIC);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
2023-09-16 06:13:18 +08:00
|
|
|
if (name2 && strcmp(name2, ".") != 0)
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Oget_info_by_name3(loc_id2, name2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
else
|
2020-09-30 22:27:10 +08:00
|
|
|
H5Oget_info3(loc_id2, &oinfo2, H5O_INFO_BASIC);
|
2020-01-17 05:29:34 +08:00
|
|
|
|
|
|
|
if (oinfo1.fileno == oinfo2.fileno) {
|
|
|
|
int token_cmp_val;
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
H5Otoken_cmp(loc_id1, &oinfo1.token, &oinfo2.token, &token_cmp_val);
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!token_cmp_val)
|
2023-09-06 02:50:06 +08:00
|
|
|
ret_val = true;
|
2020-01-17 05:29:34 +08:00
|
|
|
}
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|