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
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* 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-03-09 04:18:42 +08:00
|
|
|
/*
|
|
|
|
* Portions of this work are derived from _Obfuscated C and Other Mysteries_,
|
|
|
|
* by Don Libes, copyright (c) 1993 by John Wiley & Sons, Inc.
|
|
|
|
*/
|
|
|
|
|
2012-02-25 05:14:47 +08:00
|
|
|
#include "h5tools.h"
|
2001-03-09 04:18:42 +08:00
|
|
|
#include "h5tools_utils.h"
|
|
|
|
#include "H5private.h"
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
#include "h5trav.h"
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2019-07-26 00:36:37 +08:00
|
|
|
#ifdef H5_HAVE_ROS3_VFD
|
|
|
|
#include "H5FDros3.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/* global variables */
|
2016-06-29 05:53:48 +08:00
|
|
|
unsigned h5tools_nCols = 80;
|
2001-03-09 04:18:42 +08:00
|
|
|
/* ``get_option'' variables */
|
2020-09-30 22:27:10 +08:00
|
|
|
int opt_err = 1; /*get_option prints errors if this is on */
|
|
|
|
int opt_ind = 1; /*token pointer */
|
|
|
|
const char * opt_arg; /*flag argument (or value) */
|
|
|
|
static int h5tools_d_status = 0;
|
|
|
|
static const char *h5tools_progname = "h5tools";
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2011-10-15 06:44:11 +08:00
|
|
|
/*
|
|
|
|
* The output functions need a temporary buffer to hold a piece of the
|
|
|
|
* dataset while it's being printed. This constant sets the limit on the
|
|
|
|
* size of that temporary buffer in bytes. For efficiency's sake, choose the
|
|
|
|
* largest value suitable for your machine (for testing use a small value).
|
|
|
|
*/
|
|
|
|
/* Maximum size used in a call to malloc for a dataset */
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t H5TOOLS_MALLOCSIZE = (256 * 1024 * 1024); /* 256 MB */
|
2011-10-15 06:44:11 +08:00
|
|
|
/* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */
|
2020-09-30 22:27:10 +08:00
|
|
|
hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */
|
2011-10-15 06:44:11 +08:00
|
|
|
|
2010-08-20 03:55:48 +08:00
|
|
|
/* ``parallel_print'' variables */
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
|
|
|
|
char outBuff[OUTBUFF_SIZE];
|
|
|
|
unsigned outBuffOffset;
|
|
|
|
FILE * overflow_file = NULL;
|
2010-08-20 03:55:48 +08:00
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/* local functions */
|
2020-01-17 05:29:34 +08:00
|
|
|
static void init_table(hid_t fid, table_t **tbl);
|
2005-08-26 04:16:40 +08:00
|
|
|
#ifdef H5DUMP_DEBUG
|
2020-09-30 22:27:10 +08:00
|
|
|
static void dump_table(hid_t fid, char *tablename, table_t *table);
|
|
|
|
#endif /* H5DUMP_DEBUG */
|
2020-01-17 05:29:34 +08:00
|
|
|
static void add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool_t recorded);
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2010-08-20 03:55:48 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: parallel_print
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: wrapper for printf for use in parallel mode.
|
2010-08-20 03:55:48 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2017-10-14 05:34:01 +08:00
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
parallel_print(const char *format, ...)
|
2010-08-20 03:55:48 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
int bytes_written;
|
2012-02-23 05:58:50 +08:00
|
|
|
va_list ap;
|
2010-08-20 03:55:48 +08:00
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
HDva_start(ap, format);
|
2010-08-20 03:55:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!g_Parallel)
|
2012-02-23 05:58:50 +08:00
|
|
|
HDvprintf(format, ap);
|
|
|
|
else {
|
2020-09-30 22:27:10 +08:00
|
|
|
if (overflow_file == NULL) /*no overflow has occurred yet */ {
|
2016-06-29 05:53:48 +08:00
|
|
|
bytes_written = HDvsnprintf(outBuff + outBuffOffset, OUTBUFF_SIZE - outBuffOffset, format, ap);
|
2012-02-23 05:58:50 +08:00
|
|
|
HDva_end(ap);
|
|
|
|
HDva_start(ap, format);
|
2010-08-20 03:55:48 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((bytes_written < 0) || ((unsigned)bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) {
|
2012-02-23 05:58:50 +08:00
|
|
|
/* Terminate the outbuff at the end of the previous output */
|
|
|
|
outBuff[outBuffOffset] = '\0';
|
|
|
|
|
|
|
|
overflow_file = HDtmpfile();
|
2020-09-30 22:27:10 +08:00
|
|
|
if (overflow_file == NULL)
|
|
|
|
HDfprintf(rawerrorstream,
|
|
|
|
"warning: could not create overflow file. Output may be truncated.\n");
|
2012-02-23 05:58:50 +08:00
|
|
|
else
|
|
|
|
bytes_written = HDvfprintf(overflow_file, format, ap);
|
|
|
|
}
|
|
|
|
else
|
2016-06-29 05:53:48 +08:00
|
|
|
outBuffOffset += (unsigned)bytes_written;
|
2012-02-23 05:58:50 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
bytes_written = HDvfprintf(overflow_file, format, ap);
|
|
|
|
}
|
|
|
|
HDva_end(ap);
|
2010-08-20 03:55:48 +08:00
|
|
|
}
|
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-14 05:34:01 +08:00
|
|
|
* Function: error_msg
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Print a nicely formatted error message to stderr flushing the
|
2001-03-09 04:18:42 +08:00
|
|
|
* stdout stream first.
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: Nothing
|
2001-03-09 04:18:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2010-05-12 04:10:25 +08:00
|
|
|
error_msg(const char *fmt, ...)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
HDva_start(ap, fmt);
|
2013-01-23 04:43:12 +08:00
|
|
|
FLUSHSTREAM(rawattrstream);
|
|
|
|
FLUSHSTREAM(rawdatastream);
|
|
|
|
FLUSHSTREAM(rawoutstream);
|
2012-02-25 05:14:47 +08:00
|
|
|
HDfprintf(rawerrorstream, "%s error: ", h5tools_getprogname());
|
|
|
|
HDvfprintf(rawerrorstream, fmt, ap);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
HDva_end(ap);
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-14 05:34:01 +08:00
|
|
|
* Function: warn_msg
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Print a nicely formatted warning message to stderr flushing
|
2001-03-09 04:18:42 +08:00
|
|
|
* the stdout stream first.
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: Nothing
|
2001-03-09 04:18:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2010-05-12 04:10:25 +08:00
|
|
|
warn_msg(const char *fmt, ...)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
HDva_start(ap, fmt);
|
2013-01-23 04:43:12 +08:00
|
|
|
FLUSHSTREAM(rawattrstream);
|
|
|
|
FLUSHSTREAM(rawdatastream);
|
|
|
|
FLUSHSTREAM(rawoutstream);
|
2012-02-25 05:14:47 +08:00
|
|
|
HDfprintf(rawerrorstream, "%s warning: ", h5tools_getprogname());
|
|
|
|
HDvfprintf(rawerrorstream, fmt, ap);
|
2012-02-23 05:58:50 +08:00
|
|
|
HDva_end(ap);
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 04:41:47 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-14 05:34:01 +08:00
|
|
|
* Function: help_ref_msg
|
2011-08-17 04:41:47 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Print a message to refer help page
|
2011-08-17 04:41:47 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: Nothing
|
2011-08-17 04:41:47 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
help_ref_msg(FILE *output)
|
|
|
|
{
|
|
|
|
HDfprintf(output, "Try '-h' or '--help' for more information or ");
|
2020-09-30 22:27:10 +08:00
|
|
|
HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n", h5tools_getprogname());
|
2011-08-17 04:41:47 +08:00
|
|
|
}
|
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-14 05:34:01 +08:00
|
|
|
* Function: get_option
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Determine the command-line options a user specified. We can
|
|
|
|
* accept both short and long type command-lines.
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2006-12-07 05:14:39 +08:00
|
|
|
* Return: Success: The short valued "name" of the command line
|
|
|
|
* parameter or EOF if there are no more
|
|
|
|
* parameters to process.
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Failure: A question mark.
|
2001-03-09 04:18:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
static int sp = 1; /* character index in current token */
|
|
|
|
int opt_opt = '?'; /* option character passed back to user */
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
if (sp == 1) {
|
|
|
|
/* check for more flag-like tokens */
|
|
|
|
if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') {
|
|
|
|
return EOF;
|
2016-02-29 01:58:37 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else if (HDstrcmp(argv[opt_ind], "--") == 0) {
|
2001-03-09 04:18:42 +08:00
|
|
|
opt_ind++;
|
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') {
|
|
|
|
/* long command line option */
|
2021-01-27 21:56:28 +08:00
|
|
|
int i;
|
|
|
|
const char ch = '=';
|
2021-02-23 01:37:12 +08:00
|
|
|
char * arg = HDstrdup(&argv[opt_ind][2]);
|
2021-01-27 21:56:28 +08:00
|
|
|
size_t arg_len = 0;
|
|
|
|
|
|
|
|
opt_arg = strchr(&argv[opt_ind][2], ch);
|
|
|
|
arg_len = HDstrlen(&argv[opt_ind][2]);
|
|
|
|
if (opt_arg) {
|
|
|
|
arg_len -= HDstrlen(opt_arg);
|
|
|
|
opt_arg++; /* skip the equal sign */
|
|
|
|
}
|
|
|
|
arg[arg_len] = 0;
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
for (i = 0; l_opts && l_opts[i].name; i++) {
|
2021-01-27 21:56:28 +08:00
|
|
|
if (HDstrcmp(arg, l_opts[i].name) == 0) {
|
2001-03-09 04:18:42 +08:00
|
|
|
/* we've found a matching long command line flag */
|
|
|
|
opt_opt = l_opts[i].shortval;
|
|
|
|
|
|
|
|
if (l_opts[i].has_arg != no_arg) {
|
2021-01-27 21:56:28 +08:00
|
|
|
if (opt_arg == NULL) {
|
|
|
|
if (l_opts[i].has_arg != optional_arg) {
|
|
|
|
if (opt_ind < (argc - 1))
|
|
|
|
if (argv[opt_ind + 1][0] != '-')
|
|
|
|
opt_arg = argv[++opt_ind];
|
|
|
|
}
|
|
|
|
else if (l_opts[i].has_arg == require_arg) {
|
|
|
|
if (opt_err)
|
|
|
|
HDfprintf(rawerrorstream, "%s: option required for \"--%s\" flag\n", argv[0],
|
|
|
|
arg);
|
|
|
|
|
|
|
|
opt_opt = '?';
|
|
|
|
}
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
2016-02-29 01:58:37 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else {
|
2021-01-27 21:56:28 +08:00
|
|
|
if (opt_arg) {
|
2001-03-09 04:18:42 +08:00
|
|
|
if (opt_err)
|
2020-09-30 22:27:10 +08:00
|
|
|
HDfprintf(rawerrorstream, "%s: no option required for \"%s\" flag\n", argv[0],
|
|
|
|
arg);
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
opt_opt = '?';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l_opts[i].name == NULL) {
|
|
|
|
/* exhausted all of the l_opts we have and still didn't match */
|
|
|
|
if (opt_err)
|
2012-02-25 05:14:47 +08:00
|
|
|
HDfprintf(rawerrorstream, "%s: unknown option \"%s\"\n", argv[0], arg);
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
opt_opt = '?';
|
|
|
|
}
|
|
|
|
|
|
|
|
opt_ind++;
|
|
|
|
sp = 1;
|
2021-02-23 01:37:12 +08:00
|
|
|
|
|
|
|
HDfree(arg);
|
2016-02-29 01:58:37 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else {
|
2020-09-30 22:27:10 +08:00
|
|
|
register char *cp; /* pointer into current token */
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
/* short command line option */
|
|
|
|
opt_opt = argv[opt_ind][sp];
|
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
if (opt_opt == ':' || (cp = HDstrchr(opts, opt_opt)) == 0) {
|
2001-03-09 04:18:42 +08:00
|
|
|
if (opt_err)
|
2020-09-30 22:27:10 +08:00
|
|
|
HDfprintf(rawerrorstream, "%s: unknown option \"%c\"\n", argv[0], opt_opt);
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
/* if no chars left in this token, move to next token */
|
|
|
|
if (argv[opt_ind][++sp] == '\0') {
|
|
|
|
opt_ind++;
|
|
|
|
sp = 1;
|
|
|
|
}
|
|
|
|
return '?';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*++cp == ':') {
|
|
|
|
/* if a value is expected, get it */
|
|
|
|
if (argv[opt_ind][sp + 1] != '\0') {
|
|
|
|
/* flag value is rest of current token */
|
|
|
|
opt_arg = &argv[opt_ind++][sp + 1];
|
2016-02-29 01:58:37 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else if (++opt_ind >= argc) {
|
2001-03-09 04:18:42 +08:00
|
|
|
if (opt_err)
|
2020-09-30 22:27:10 +08:00
|
|
|
HDfprintf(rawerrorstream, "%s: value expected for option \"%c\"\n", argv[0], opt_opt);
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
opt_opt = '?';
|
2016-02-29 01:58:37 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else {
|
2001-03-09 04:18:42 +08:00
|
|
|
/* flag value is next token */
|
|
|
|
opt_arg = argv[opt_ind++];
|
|
|
|
}
|
|
|
|
|
|
|
|
sp = 1;
|
2010-01-30 12:29:13 +08:00
|
|
|
}
|
2008-10-30 04:11:51 +08:00
|
|
|
/* wildcard argument */
|
2012-02-23 05:58:50 +08:00
|
|
|
else if (*cp == '*') {
|
2008-10-30 04:11:51 +08:00
|
|
|
/* check the next argument */
|
|
|
|
opt_ind++;
|
|
|
|
/* we do have an extra argument, check if not last */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((opt_ind + 1) < argc) {
|
|
|
|
if (argv[opt_ind][0] != '-') {
|
2016-02-29 01:58:37 +08:00
|
|
|
opt_arg = argv[opt_ind++];
|
2017-10-20 01:45:17 +08:00
|
|
|
}
|
|
|
|
else {
|
2016-02-29 01:58:37 +08:00
|
|
|
opt_arg = NULL;
|
2017-10-20 01:45:17 +08:00
|
|
|
}
|
2008-10-30 04:11:51 +08:00
|
|
|
}
|
2017-10-20 01:45:17 +08:00
|
|
|
else {
|
2008-10-30 04:11:51 +08:00
|
|
|
opt_arg = NULL;
|
2017-10-20 01:45:17 +08:00
|
|
|
}
|
2008-10-30 04:11:51 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else {
|
2001-03-09 04:18:42 +08:00
|
|
|
/* set up to look at next char in token, next time */
|
|
|
|
if (argv[opt_ind][++sp] == '\0') {
|
|
|
|
/* no more in current token, so setup next token */
|
|
|
|
opt_ind++;
|
|
|
|
sp = 1;
|
|
|
|
}
|
|
|
|
opt_arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the current flag character found */
|
|
|
|
return opt_opt;
|
|
|
|
}
|
|
|
|
|
2019-07-26 00:36:37 +08:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* Function: parse_tuple()
|
|
|
|
*
|
|
|
|
* Purpose:
|
|
|
|
*
|
|
|
|
* Create array of pointers to strings, identified as elements in a tuple
|
|
|
|
* of arbitrary length separated by provided character.
|
|
|
|
* ("tuple" because "nple" looks strange)
|
|
|
|
*
|
|
|
|
* * Receives pointer to start of tuple sequence string, '('.
|
|
|
|
* * Attempts to separate elements by token-character `sep`.
|
|
|
|
* * If the separator character is preceded by a backslash '\',
|
|
|
|
* the backslash is deleted and the separator is included in the
|
|
|
|
* element string as any other character.
|
|
|
|
* * To end an element with a backslash, escape the backslash, e.g.
|
|
|
|
* "(myelem\\,otherelem) -> {"myelem\", "otherelem"}
|
|
|
|
* * In all other cases, a backslash appearing not as part of "\\" or
|
|
|
|
* "\<sep>" digraph will be included berbatim.
|
|
|
|
* * Last two characters in the string MUST be ")\0".
|
|
|
|
*
|
|
|
|
* * Generates a copy of the input string `start`, (src..")\0"), replacing
|
|
|
|
* separators and close-paren with null charaters.
|
|
|
|
* * This string is allocated at runtime and should be freed when done.
|
|
|
|
* * Generates array of char pointers, and directs start of each element
|
|
|
|
* (each pointer) into this copy.
|
|
|
|
* * Each tuple element points to the start of its string (substring)
|
|
|
|
* and ends with a null terminator.
|
|
|
|
* * This array is allocated at runtime and should be freed when done.
|
|
|
|
* * Reallocates and expands elements array during parsing.
|
|
|
|
* * Initially allocated for 2 (plus one null entry), and grows by
|
|
|
|
* powers of 2.
|
|
|
|
* * The final 'slot' in the element array (elements[nelements], e.g.)
|
|
|
|
* always points to NULL.
|
|
|
|
* * The number of elements found and stored are passed out through pointer
|
|
|
|
* to unsigned, `nelems`.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
*
|
|
|
|
* FAIL If malformed--does not look like a tuple "(...)"
|
|
|
|
* or major error was encountered while parsing.
|
|
|
|
* or
|
|
|
|
* SUCCEED String looks properly formed "(...)" and no major errors.
|
|
|
|
*
|
|
|
|
* Stores number of elements through pointer `nelems`.
|
|
|
|
* Stores list of pointers to char (first char in each element
|
|
|
|
* string) through pointer `ptrs_out`.
|
|
|
|
* NOTE: `ptrs_out[nelems] == NULL` should be true.
|
|
|
|
* NOTE: list is malloc'd by function, and should be freed
|
|
|
|
* when done.
|
|
|
|
* Stores "source string" for element pointers through `cpy_out`.
|
|
|
|
* NOTE: Each element substring is null-terminated.
|
|
|
|
* NOTE: There may be extra characters after the last element
|
|
|
|
* (past its null terminator), but is guaranteed to
|
|
|
|
* be null-terminated.
|
|
|
|
* NOTE: `cpy_out` string is malloc'd by function,
|
|
|
|
* and should be freed when done.
|
|
|
|
*
|
|
|
|
* Programmer: Jacob Smith
|
|
|
|
* 2017-11-10
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
|
|
|
*/
|
|
|
|
herr_t
|
2020-09-30 22:27:10 +08:00
|
|
|
parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems, char ***ptrs_out)
|
2019-07-26 00:36:37 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
char * elem_ptr = NULL;
|
|
|
|
char * dest_ptr = NULL;
|
|
|
|
unsigned elems_count = 0;
|
|
|
|
char ** elems = NULL; /* more like *elems[], but complier... */
|
|
|
|
char ** elems_re = NULL; /* temporary pointer, for realloc */
|
|
|
|
char * cpy = NULL;
|
|
|
|
herr_t ret_value = SUCCEED;
|
|
|
|
unsigned init_slots = 2;
|
2019-07-26 00:36:37 +08:00
|
|
|
|
|
|
|
/*****************
|
|
|
|
* SANITY-CHECKS *
|
|
|
|
*****************/
|
|
|
|
|
|
|
|
/* must start with "("
|
|
|
|
*/
|
|
|
|
if (start[0] != '(') {
|
|
|
|
ret_value = FAIL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* must end with ")"
|
|
|
|
*/
|
|
|
|
while (start[elems_count] != '\0') {
|
|
|
|
elems_count++;
|
|
|
|
}
|
|
|
|
if (start[elems_count - 1] != ')') {
|
|
|
|
ret_value = FAIL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
elems_count = 0;
|
|
|
|
|
|
|
|
/***********
|
|
|
|
* PREPARE *
|
|
|
|
***********/
|
|
|
|
|
|
|
|
/* create list
|
|
|
|
*/
|
|
|
|
elems = (char **)HDmalloc(sizeof(char *) * (init_slots + 1));
|
2020-09-30 22:27:10 +08:00
|
|
|
if (elems == NULL) {
|
|
|
|
ret_value = FAIL;
|
|
|
|
goto done;
|
|
|
|
} /* CANTALLOC */
|
2019-07-26 00:36:37 +08:00
|
|
|
|
|
|
|
/* create destination string
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
start++; /* advance past opening paren '(' */
|
2019-07-26 00:36:37 +08:00
|
|
|
cpy = (char *)HDmalloc(sizeof(char) * (HDstrlen(start))); /* no +1; less '(' */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (cpy == NULL) {
|
|
|
|
ret_value = FAIL;
|
|
|
|
goto done;
|
|
|
|
} /* CANTALLOC */
|
2019-07-26 00:36:37 +08:00
|
|
|
|
|
|
|
/* set pointers
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
dest_ptr = cpy; /* start writing copy here */
|
|
|
|
elem_ptr = cpy; /* first element starts here */
|
2019-07-26 00:36:37 +08:00
|
|
|
elems[elems_count++] = elem_ptr; /* set first element pointer into list */
|
|
|
|
|
|
|
|
/*********
|
|
|
|
* PARSE *
|
|
|
|
*********/
|
|
|
|
|
|
|
|
while (*start != '\0') {
|
|
|
|
/* For each character in the source string...
|
|
|
|
*/
|
|
|
|
if (*start == '\\') {
|
|
|
|
/* Possibly an escape digraph.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((*(start + 1) == '\\') || (*(start + 1) == sep)) {
|
2019-07-26 00:36:37 +08:00
|
|
|
/* Valid escape digraph of "\\" or "\<sep>".
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
start++; /* advance past escape char '\' */
|
2019-07-26 00:36:37 +08:00
|
|
|
*(dest_ptr++) = *(start++); /* Copy subsequent char */
|
|
|
|
/* and advance pointers. */
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Not an accepted escape digraph.
|
|
|
|
* Copy backslash character.
|
|
|
|
*/
|
2019-07-26 00:36:37 +08:00
|
|
|
*(dest_ptr++) = *(start++);
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else if (*start == sep) {
|
2019-07-26 00:36:37 +08:00
|
|
|
/* Non-escaped separator.
|
|
|
|
* Terminate elements substring in copy, record element, advance.
|
|
|
|
* Expand elements list if appropriate.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
*(dest_ptr++) = 0; /* Null-terminate elem substring in copy */
|
|
|
|
/* and advance pointer. */
|
|
|
|
start++; /* Advance src pointer past separator. */
|
|
|
|
elem_ptr = dest_ptr; /* Element pointer points to start of first */
|
|
|
|
/* character after null sep in copy. */
|
2019-07-26 00:36:37 +08:00
|
|
|
elems[elems_count++] = elem_ptr; /* Set elem pointer in list */
|
|
|
|
/* and increment count. */
|
|
|
|
|
|
|
|
/* Expand elements list, if necessary.
|
|
|
|
*/
|
|
|
|
if (elems_count == init_slots) {
|
|
|
|
init_slots *= 2;
|
2020-09-30 22:27:10 +08:00
|
|
|
elems_re = (char **)realloc(elems, sizeof(char *) * (init_slots + 1));
|
2019-07-26 00:36:37 +08:00
|
|
|
if (elems_re == NULL) {
|
|
|
|
/* CANTREALLOC */
|
|
|
|
ret_value = FAIL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
elems = elems_re;
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else if (*start == ')' && *(start + 1) == '\0') {
|
2019-07-26 00:36:37 +08:00
|
|
|
/* Found terminal, non-escaped close-paren. Last element.
|
|
|
|
* Write null terminator to copy.
|
|
|
|
* Advance source pointer to gently break from loop.
|
|
|
|
* Requred to prevent ")" from always being added to last element.
|
|
|
|
*/
|
|
|
|
start++;
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else {
|
2019-07-26 00:36:37 +08:00
|
|
|
/* Copy character into destination. Advance pointers.
|
|
|
|
*/
|
|
|
|
*(dest_ptr++) = *(start++);
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
*dest_ptr = '\0'; /* Null-terminate destination string. */
|
2019-07-26 00:36:37 +08:00
|
|
|
elems[elems_count] = NULL; /* Null-terminate elements list. */
|
|
|
|
|
|
|
|
/********************
|
|
|
|
* PASS BACK VALUES *
|
|
|
|
********************/
|
|
|
|
|
|
|
|
*ptrs_out = elems;
|
|
|
|
*nelems = elems_count;
|
|
|
|
*cpy_out = cpy;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (ret_value == FAIL) {
|
|
|
|
/* CLEANUP */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (cpy)
|
|
|
|
free(cpy);
|
|
|
|
if (elems)
|
|
|
|
free(elems);
|
2019-07-26 00:36:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret_value;
|
|
|
|
|
|
|
|
} /* parse_tuple */
|
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-14 05:34:01 +08:00
|
|
|
* Function: indentation
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Print spaces for indentation
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2001-03-09 04:18:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2016-06-29 05:53:48 +08:00
|
|
|
indentation(unsigned x)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
if (x < h5tools_nCols) {
|
2001-03-09 04:18:42 +08:00
|
|
|
while (x-- > 0)
|
2013-01-23 04:43:12 +08:00
|
|
|
PRINTVALSTREAM(rawoutstream, " ");
|
2016-02-29 01:58:37 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else {
|
2012-02-25 05:14:47 +08:00
|
|
|
HDfprintf(rawerrorstream, "error: the indentation exceeds the number of cols.\n");
|
2012-02-24 23:45:54 +08:00
|
|
|
HDexit(1);
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2017-10-14 05:34:01 +08:00
|
|
|
* Function: print_version
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Print the program name and the version information which is
|
|
|
|
* defined the same as the HDF5 library version.
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2001-03-09 04:18:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
print_version(const char *progname)
|
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
PRINTSTREAM(rawoutstream, "%s: Version %u.%u.%u%s%s\n", progname, H5_VERS_MAJOR, H5_VERS_MINOR,
|
|
|
|
H5_VERS_RELEASE, ((const char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE);
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: init_table
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
* Purpose: allocate and initialize tables for shared groups, datasets,
|
2001-03-09 04:18:42 +08:00
|
|
|
* and committed types
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-26 04:16:40 +08:00
|
|
|
static void
|
2020-01-17 05:29:34 +08:00
|
|
|
init_table(hid_t fid, table_t **tbl)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2010-07-30 03:07:26 +08:00
|
|
|
table_t *table = (table_t *)HDmalloc(sizeof(table_t));
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
table->fid = fid;
|
|
|
|
table->size = 20;
|
2001-03-09 04:18:42 +08:00
|
|
|
table->nobjs = 0;
|
2020-09-30 22:27:10 +08:00
|
|
|
table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t));
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
*tbl = table;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-08-26 04:16:40 +08:00
|
|
|
* Function: free_table
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2005-08-26 04:16:40 +08:00
|
|
|
* Purpose: free tables for shared groups, datasets,
|
|
|
|
* and committed types
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2005-08-26 04:16:40 +08:00
|
|
|
free_table(table_t *table)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned u; /* Local index value */
|
2005-08-26 04:16:40 +08:00
|
|
|
|
|
|
|
/* Free the names for the objects in the table */
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < table->nobjs; u++)
|
|
|
|
if (table->objs[u].objname)
|
2005-08-26 04:16:40 +08:00
|
|
|
HDfree(table->objs[u].objname);
|
|
|
|
|
|
|
|
HDfree(table->objs);
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
#ifdef H5DUMP_DEBUG
|
2019-07-26 00:36:37 +08:00
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2005-08-26 04:16:40 +08:00
|
|
|
* Function: dump_table
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2005-08-26 04:16:40 +08:00
|
|
|
* Purpose: display the contents of tables for debugging purposes
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
2005-08-26 04:16:40 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static void
|
2020-09-30 22:27:10 +08:00
|
|
|
dump_table(hid_t fid, char *tablename, table_t *table)
|
2005-08-26 04:16:40 +08:00
|
|
|
{
|
|
|
|
unsigned u;
|
2020-09-30 22:27:10 +08:00
|
|
|
char * obj_tok_str = NULL;
|
2005-08-26 04:16:40 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
PRINTSTREAM(rawoutstream, "%s: # of entries = %d\n", tablename, table->nobjs);
|
2020-01-17 05:29:34 +08:00
|
|
|
for (u = 0; u < table->nobjs; u++) {
|
2020-03-30 16:51:36 +08:00
|
|
|
H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_tok_str);
|
2020-01-17 05:29:34 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
PRINTSTREAM(rawoutstream, "%s %s %d %d\n", obj_tok_str, table->objs[u].objname,
|
|
|
|
table->objs[u].displayed, table->objs[u].recorded);
|
2020-01-17 05:29:34 +08:00
|
|
|
|
2020-03-30 16:51:36 +08:00
|
|
|
H5VLfree_token_str(fid, obj_tok_str);
|
2020-01-17 05:29:34 +08:00
|
|
|
}
|
2005-08-26 04:16:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_tables
|
|
|
|
*
|
|
|
|
* Purpose: display the contents of tables for debugging purposes
|
|
|
|
*
|
|
|
|
* Return: void
|
2001-03-09 04:18:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2005-08-26 04:16:40 +08:00
|
|
|
dump_tables(find_objs_t *info)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2020-01-17 05:29:34 +08:00
|
|
|
dump_table(info->fid, "group_table", info->group_table);
|
|
|
|
dump_table(info->fid, "dset_table", info->dset_table);
|
|
|
|
dump_table(info->fid, "type_table", info->type_table);
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
#endif /* H5DUMP_DEBUG */
|
2019-07-26 00:36:37 +08:00
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: search_obj
|
|
|
|
*
|
|
|
|
* Purpose: search the object specified by objno in the table
|
|
|
|
*
|
|
|
|
* Return: Success: an integer, the location of the object
|
|
|
|
*
|
|
|
|
* Failure: FAIL if object is not found
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE obj_t *
|
2020-09-30 22:27:10 +08:00
|
|
|
search_obj(table_t *table, const H5O_token_t *obj_token)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2005-08-26 04:16:40 +08:00
|
|
|
unsigned u;
|
2020-09-30 22:27:10 +08:00
|
|
|
int token_cmp;
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
for (u = 0; u < table->nobjs; u++) {
|
|
|
|
if (H5Otoken_cmp(table->fid, &table->objs[u].obj_token, obj_token, &token_cmp) < 0)
|
2020-01-17 05:29:34 +08:00
|
|
|
return NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!token_cmp)
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
return &(table->objs[u]);
|
2020-01-17 05:29:34 +08:00
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
return NULL;
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: find_objs_cb
|
|
|
|
*
|
|
|
|
* Purpose: Callback to find objects, committed types and store them in tables
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
*
|
|
|
|
* Failure: FAIL
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-26 04:16:40 +08:00
|
|
|
static herr_t
|
2020-01-17 05:29:34 +08:00
|
|
|
find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_seen, void *op_data)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
find_objs_t *info = (find_objs_t *)op_data;
|
|
|
|
herr_t ret_value = 0;
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
switch (oinfo->type) {
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
case H5O_TYPE_GROUP:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == already_seen)
|
2020-01-17 05:29:34 +08:00
|
|
|
add_obj(info->group_table, &oinfo->token, name, TRUE);
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
break;
|
2005-08-26 04:16:40 +08:00
|
|
|
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
case H5O_TYPE_DATASET:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == already_seen) {
|
2020-01-14 07:09:48 +08:00
|
|
|
hid_t dset = H5I_INVALID_HID;
|
2001-03-09 04:18:42 +08:00
|
|
|
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
/* Add the dataset to the list of objects */
|
2020-01-17 05:29:34 +08:00
|
|
|
add_obj(info->dset_table, &oinfo->token, name, TRUE);
|
2001-03-09 04:18:42 +08:00
|
|
|
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
/* Check for a dataset that uses a named datatype */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) {
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
hid_t type = H5Dget_type(dset);
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Tcommitted(type) > 0) {
|
2020-01-17 05:29:34 +08:00
|
|
|
H5O_info2_t type_oinfo;
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
H5Oget_info3(type, &type_oinfo, H5O_INFO_BASIC);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (search_obj(info->type_table, &type_oinfo.token) == NULL)
|
2020-01-17 05:29:34 +08:00
|
|
|
add_obj(info->type_table, &type_oinfo.token, name, FALSE);
|
2007-09-13 23:44:56 +08:00
|
|
|
} /* end if */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
H5Tclose(type);
|
|
|
|
H5Dclose(dset);
|
|
|
|
} /* end if */
|
|
|
|
else
|
|
|
|
ret_value = FAIL;
|
|
|
|
} /* end if */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5O_TYPE_NAMED_DATATYPE:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL == already_seen) {
|
2008-10-16 11:52:16 +08:00
|
|
|
obj_t *found_obj;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((found_obj = search_obj(info->type_table, &oinfo->token)) == NULL)
|
2020-01-17 05:29:34 +08:00
|
|
|
add_obj(info->type_table, &oinfo->token, name, TRUE);
|
2008-10-16 11:52:16 +08:00
|
|
|
else {
|
|
|
|
/* Use latest version of name */
|
|
|
|
HDfree(found_obj->objname);
|
|
|
|
found_obj->objname = HDstrdup(name);
|
|
|
|
|
|
|
|
/* Mark named datatype as having valid name */
|
|
|
|
found_obj->recorded = TRUE;
|
|
|
|
} /* end else */
|
2020-09-30 22:27:10 +08:00
|
|
|
} /* end if */
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
break;
|
|
|
|
|
2019-08-13 16:36:42 +08:00
|
|
|
case H5O_TYPE_MAP:
|
2015-09-01 03:04:23 +08:00
|
|
|
case H5O_TYPE_UNKNOWN:
|
|
|
|
case H5O_TYPE_NTYPES:
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} /* end switch */
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
return ret_value;
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-08-26 04:16:40 +08:00
|
|
|
* Function: init_objs
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
2005-08-26 04:16:40 +08:00
|
|
|
* Purpose: Initialize tables for groups, datasets & named datatypes
|
2001-03-09 04:18:42 +08:00
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
*
|
2005-08-26 04:16:40 +08:00
|
|
|
* Failure: FAIL
|
2001-03-09 04:18:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-26 04:16:40 +08:00
|
|
|
herr_t
|
2020-09-30 22:27:10 +08:00
|
|
|
init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2019-12-28 16:16:44 +08:00
|
|
|
herr_t ret_value = SUCCEED;
|
2019-01-08 10:36:34 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
/* Initialize the tables */
|
2020-01-17 05:29:34 +08:00
|
|
|
init_table(fid, group_table);
|
|
|
|
init_table(fid, dset_table);
|
|
|
|
init_table(fid, type_table);
|
2005-08-26 04:16:40 +08:00
|
|
|
|
|
|
|
/* Init the find_objs_t */
|
2020-09-30 22:27:10 +08:00
|
|
|
info->fid = fid;
|
2005-08-26 04:16:40 +08:00
|
|
|
info->group_table = *group_table;
|
2020-09-30 22:27:10 +08:00
|
|
|
info->type_table = *type_table;
|
|
|
|
info->dset_table = *dset_table;
|
2005-08-26 04:16:40 +08:00
|
|
|
|
|
|
|
/* Find all shared objects */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((ret_value = h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info, H5O_INFO_BASIC)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "finding shared objects failed");
|
2019-01-08 10:36:34 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
/* Release resources */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (ret_value < 0) {
|
2019-01-08 10:36:34 +08:00
|
|
|
free_table(*group_table);
|
|
|
|
info->group_table = NULL;
|
|
|
|
free_table(*type_table);
|
|
|
|
info->type_table = NULL;
|
|
|
|
free_table(*dset_table);
|
|
|
|
info->dset_table = NULL;
|
|
|
|
}
|
|
|
|
return ret_value;
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: add_obj
|
|
|
|
*
|
|
|
|
* Purpose: add a shared object to the table
|
|
|
|
* realloc the table if necessary
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static void
|
2020-01-17 05:29:34 +08:00
|
|
|
add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool_t record)
|
2001-03-09 04:18:42 +08:00
|
|
|
{
|
2016-06-29 05:53:48 +08:00
|
|
|
size_t u;
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
/* See if we need to make table larger */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (table->nobjs == table->size) {
|
2001-03-09 04:18:42 +08:00
|
|
|
table->size *= 2;
|
2010-08-20 03:55:48 +08:00
|
|
|
table->objs = (struct obj_t *)HDrealloc(table->objs, table->size * sizeof(table->objs[0]));
|
[svn-r14284] Description:
Add H5Lvisit_by_name() API routine to library.
Eliminated all (five!) other group traversal routines and changed them
all to use the new API routine.
Cleaned up output of h5ls & h5stat:
- Issue error when requesting recursive traversal of a file
with the "group info" flag, but no group given
- Print info about root group in all(?) appropriate situations
- Don't print "verbose" information about root group until the
root group is in the list of objects to display
(mostly because h5ls & h5stat had a different twist on traversing the
groups in a file that the other utilities)
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2007-11-25 00:49:36 +08:00
|
|
|
} /* end if */
|
2001-03-09 04:18:42 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
/* Increment number of objects in table */
|
|
|
|
u = table->nobjs++;
|
|
|
|
|
|
|
|
/* Set information about object */
|
2020-01-17 05:29:34 +08:00
|
|
|
HDmemcpy(&table->objs[u].obj_token, obj_token, sizeof(H5O_token_t));
|
2020-09-30 22:27:10 +08:00
|
|
|
table->objs[u].objname = HDstrdup(objname);
|
|
|
|
table->objs[u].recorded = record;
|
2005-08-26 04:16:40 +08:00
|
|
|
table->objs[u].displayed = 0;
|
2001-03-09 04:18:42 +08:00
|
|
|
}
|
2005-02-09 04:55:17 +08:00
|
|
|
|
2005-08-10 00:53:43 +08:00
|
|
|
#ifndef H5_HAVE_TMPFILE
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: tmpfile
|
|
|
|
*
|
|
|
|
* Purpose: provide tmpfile() function when it is not supported by the
|
|
|
|
* system. Always return NULL for now.
|
|
|
|
*
|
|
|
|
* Return: a stream description when succeeds.
|
|
|
|
* NULL if fails.
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
FILE *
|
|
|
|
tmpfile(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2010-09-17 01:48:06 +08:00
|
|
|
* Function: H5tools_get_symlink_info
|
2010-04-23 02:17:35 +08:00
|
|
|
*
|
2016-02-29 01:58:37 +08:00
|
|
|
* Purpose: Get symbolic link (soft, external) info and its target object type
|
2010-04-23 02:17:35 +08:00
|
|
|
(dataset, group, named datatype) and path, if exist
|
|
|
|
*
|
|
|
|
* Patameters:
|
|
|
|
* - [IN] fileid : link file id
|
|
|
|
* - [IN] linkpath : link path
|
|
|
|
* - [OUT] link_info: returning target object info (h5tool_link_info_t)
|
|
|
|
*
|
2016-02-29 01:58:37 +08:00
|
|
|
* Return:
|
|
|
|
* 2 : given pathname is object
|
2017-10-14 05:34:01 +08:00
|
|
|
* 1 : Succeed to get link info.
|
2010-04-23 02:17:35 +08:00
|
|
|
* 0 : Detected as a dangling link
|
|
|
|
* -1 : H5 API failed.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* link_info->trg_path must be freed out of this function
|
|
|
|
*-------------------------------------------------------------------------*/
|
2010-07-30 03:07:26 +08:00
|
|
|
int
|
2020-09-30 22:27:10 +08:00
|
|
|
H5tools_get_symlink_info(hid_t file_id, const char *linkpath, h5tool_link_info_t *link_info,
|
|
|
|
hbool_t get_obj_type)
|
2010-04-23 02:17:35 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
htri_t l_ret;
|
2020-01-17 05:29:34 +08:00
|
|
|
H5O_info2_t trg_oinfo;
|
2020-09-30 22:27:10 +08:00
|
|
|
hid_t fapl = H5P_DEFAULT;
|
|
|
|
hid_t lapl = H5P_DEFAULT;
|
|
|
|
int ret_value = -1; /* init to fail */
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/* init */
|
|
|
|
link_info->trg_type = H5O_TYPE_UNKNOWN;
|
|
|
|
|
2010-09-17 01:48:06 +08:00
|
|
|
/* if path is root, return group type */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!HDstrcmp(linkpath, "/")) {
|
2010-09-17 01:48:06 +08:00
|
|
|
link_info->trg_type = H5O_TYPE_GROUP;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(2);
|
2010-09-17 01:48:06 +08:00
|
|
|
}
|
|
|
|
|
2010-04-23 02:17:35 +08:00
|
|
|
/* check if link itself exist */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) {
|
|
|
|
if (link_info->opt.msg_mode == 1)
|
|
|
|
parallel_print("Warning: link <%s> doesn't exist \n", linkpath);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2010-07-30 03:07:26 +08:00
|
|
|
} /* end if */
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/* get info from link */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Lget_info2(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) {
|
|
|
|
if (link_info->opt.msg_mode == 1)
|
|
|
|
parallel_print("Warning: unable to get link info from <%s>\n", linkpath);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2010-07-30 03:07:26 +08:00
|
|
|
} /* end if */
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/* given path is hard link (object) */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (link_info->linfo.type == H5L_TYPE_HARD)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(2);
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/* trg_path must be freed out of this function when finished using */
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((link_info->trg_path = (char *)HDcalloc(link_info->linfo.u.val_size, sizeof(char))) == NULL) {
|
|
|
|
if (link_info->opt.msg_mode == 1)
|
|
|
|
parallel_print("Warning: unable to allocate buffer for <%s>\n", linkpath);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2017-08-24 05:12:40 +08:00
|
|
|
} /* end if */
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/* get link value */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) <
|
|
|
|
0) {
|
|
|
|
if (link_info->opt.msg_mode == 1)
|
|
|
|
parallel_print("Warning: unable to get link value from <%s>\n", linkpath);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2010-07-30 03:07:26 +08:00
|
|
|
} /* end if */
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/*-----------------------------------------------------
|
2016-02-29 01:58:37 +08:00
|
|
|
* if link type is external link use different lapl to
|
2010-04-23 02:17:35 +08:00
|
|
|
* follow object in other file
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
if (link_info->linfo.type == H5L_TYPE_EXTERNAL) {
|
|
|
|
if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pset_fapl_sec2(fapl) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2020-09-30 22:27:10 +08:00
|
|
|
if ((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Pset_elink_fapl(lapl, fapl) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2010-07-30 03:07:26 +08:00
|
|
|
} /* end if */
|
2010-04-23 02:17:35 +08:00
|
|
|
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
/* Check for retrieving object info */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (get_obj_type) {
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
/*--------------------------------------------------------------
|
|
|
|
* if link's target object exist, get type
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
/* check if target object exist */
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
l_ret = H5Oexists_by_name(file_id, linkpath, lapl);
|
2016-02-29 01:58:37 +08:00
|
|
|
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
/* detect dangling link */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (l_ret == FALSE) {
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(0);
|
2017-10-14 05:34:01 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else if (l_ret < 0) { /* function failed */
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2017-10-14 05:34:01 +08:00
|
|
|
}
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
|
|
|
|
/* get target object info */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (H5Oget_info_by_name3(file_id, linkpath, &trg_oinfo, H5O_INFO_BASIC, lapl) < 0) {
|
|
|
|
if (link_info->opt.msg_mode == 1)
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
/* check unknown type */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >= H5O_TYPE_NTYPES) {
|
|
|
|
if (link_info->opt.msg_mode == 1)
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
parallel_print("Warning: target object of <%s> is unknown type\n", linkpath);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_DONE(FAIL);
|
2020-09-30 22:27:10 +08:00
|
|
|
} /* end if */
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
|
|
|
|
/* set target obj type to return */
|
2020-01-17 05:29:34 +08:00
|
|
|
HDmemcpy(&link_info->obj_token, &trg_oinfo.token, sizeof(H5O_token_t));
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
link_info->trg_type = trg_oinfo.type;
|
2020-09-30 22:27:10 +08:00
|
|
|
link_info->fileno = trg_oinfo.fileno;
|
2010-07-30 03:07:26 +08:00
|
|
|
} /* end if */
|
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk:
r19290:
Correct another error in metadata accumulator dirty region calculations
(this time with a corner case when freeing data in the file).
r19291:
Avoid getting object information for soft/external links if we aren't
going to traverse across the link itself.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, 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-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
2010-08-25 05:03:32 +08:00
|
|
|
else
|
|
|
|
link_info->trg_type = H5O_TYPE_UNKNOWN;
|
2010-04-23 02:17:35 +08:00
|
|
|
|
|
|
|
/* succeed */
|
2017-10-14 05:34:01 +08:00
|
|
|
ret_value = 1;
|
2010-07-30 03:07:26 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
done:
|
2020-09-30 22:27:10 +08:00
|
|
|
if (fapl != H5P_DEFAULT)
|
2010-04-23 02:17:35 +08:00
|
|
|
H5Pclose(fapl);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (lapl != H5P_DEFAULT)
|
2010-04-23 02:17:35 +08:00
|
|
|
H5Pclose(lapl);
|
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
return ret_value;
|
2010-09-17 01:48:06 +08:00
|
|
|
} /* end H5tools_get_symlink_info() */
|
2010-05-15 05:54:59 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
2017-10-14 05:34:01 +08:00
|
|
|
*
|
2010-05-15 05:54:59 +08:00
|
|
|
* Purpose: Initialize the name and operation status of the H5 Tools library
|
2017-10-14 05:34:01 +08:00
|
|
|
*
|
2010-05-15 05:54:59 +08:00
|
|
|
* Description:
|
|
|
|
* These are utility functions to set/get the program name and operation status.
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2017-10-14 05:34:01 +08:00
|
|
|
void
|
|
|
|
h5tools_setprogname(const char *Progname)
|
2010-05-15 05:54:59 +08:00
|
|
|
{
|
|
|
|
h5tools_progname = Progname;
|
|
|
|
}
|
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
void
|
|
|
|
h5tools_setstatus(int D_status)
|
2010-05-15 05:54:59 +08:00
|
|
|
{
|
|
|
|
h5tools_d_status = D_status;
|
|
|
|
}
|
|
|
|
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE const char *
|
|
|
|
h5tools_getprogname(void)
|
2010-05-15 05:54:59 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return h5tools_progname;
|
2010-05-15 05:54:59 +08:00
|
|
|
}
|
|
|
|
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE int
|
|
|
|
h5tools_getstatus(void)
|
2010-05-15 05:54:59 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return h5tools_d_status;
|
2010-05-15 05:54:59 +08:00
|
|
|
}
|
2011-10-15 06:44:11 +08:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------
|
2016-02-29 01:58:37 +08:00
|
|
|
* PURPOSE :
|
|
|
|
* if environment variable H5TOOLS_BUFSIZE is set,
|
2011-10-15 06:44:11 +08:00
|
|
|
* update H5TOOLS_BUFSIZE and H5TOOLS_MALLOCSIZE from the env
|
|
|
|
* This can be called from each tools main() as part of initial act.
|
|
|
|
* Note: this is more of debugging purpose for now.
|
|
|
|
*/
|
2017-10-14 05:34:01 +08:00
|
|
|
int
|
|
|
|
h5tools_getenv_update_hyperslab_bufsize(void)
|
2011-10-15 06:44:11 +08:00
|
|
|
{
|
|
|
|
const char *env_str = NULL;
|
2020-09-30 22:27:10 +08:00
|
|
|
long hyperslab_bufsize_mb;
|
|
|
|
int ret_value = 1;
|
2011-10-15 06:44:11 +08:00
|
|
|
|
|
|
|
/* check if environment variable is set for the hyperslab buffer size */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL != (env_str = HDgetenv("H5TOOLS_BUFSIZE"))) {
|
|
|
|
errno = 0;
|
|
|
|
hyperslab_bufsize_mb = HDstrtol(env_str, (char **)NULL, 10);
|
2011-10-15 06:44:11 +08:00
|
|
|
if (errno != 0 || hyperslab_bufsize_mb <= 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "hyperslab buffer size failed");
|
2011-10-15 06:44:11 +08:00
|
|
|
|
|
|
|
/* convert MB to byte */
|
2016-06-29 05:53:48 +08:00
|
|
|
H5TOOLS_BUFSIZE = (hsize_t)hyperslab_bufsize_mb * 1024 * 1024;
|
2011-10-15 06:44:11 +08:00
|
|
|
|
|
|
|
H5TOOLS_MALLOCSIZE = MAX(H5TOOLS_BUFSIZE, H5TOOLS_MALLOCSIZE);
|
|
|
|
}
|
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
done:
|
|
|
|
return ret_value;
|
2011-10-15 06:44:11 +08:00
|
|
|
}
|
2016-06-29 05:53:48 +08:00
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
#ifdef H5_HAVE_ROS3_VFD
|
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Function: h5tools_parse_ros3_fapl_tuple
|
|
|
|
*
|
|
|
|
* Purpose: A convenience function that parses a string containing a tuple
|
|
|
|
* of S3 VFD credential information and then passes the result to
|
|
|
|
* `h5tools_populate_ros3_fapl()` in order to setup a valid
|
|
|
|
* configuration for the S3 VFD.
|
|
|
|
*
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
*
|
|
|
|
*----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, H5FD_ros3_fapl_t *fapl_config_out)
|
2020-02-12 07:57:19 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
const char *ccred[3];
|
|
|
|
unsigned nelems = 0;
|
|
|
|
char * start = NULL;
|
|
|
|
char * s3cred_src = NULL;
|
|
|
|
char ** s3cred = NULL;
|
|
|
|
herr_t ret_value = SUCCEED;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
|
|
|
/* Attempt to parse S3 credentials tuple */
|
|
|
|
if (parse_tuple(tuple_str, delim, &s3cred_src, &nelems, &s3cred) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "failed to parse S3 VFD info tuple");
|
|
|
|
|
|
|
|
/* Sanity-check tuple count */
|
|
|
|
if (nelems != 3)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "invalid S3 VFD credentials");
|
|
|
|
|
|
|
|
ccred[0] = (const char *)s3cred[0];
|
|
|
|
ccred[1] = (const char *)s3cred[1];
|
|
|
|
ccred[2] = (const char *)s3cred[2];
|
|
|
|
|
|
|
|
if (0 == h5tools_populate_ros3_fapl(fapl_config_out, ccred))
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "failed to populate S3 VFD FAPL config");
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (s3cred)
|
|
|
|
HDfree(s3cred);
|
|
|
|
if (s3cred_src)
|
|
|
|
HDfree(s3cred_src);
|
|
|
|
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
2019-07-26 00:36:37 +08:00
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Function: h5tools_populate_ros3_fapl()
|
|
|
|
*
|
|
|
|
* Purpose:
|
|
|
|
*
|
|
|
|
* Set the values of a ROS3 fapl configuration object.
|
|
|
|
*
|
|
|
|
* If the values pointer is NULL, sets fapl target `fa` to a default
|
|
|
|
* (valid, current-version, non-authenticating) fapl config.
|
|
|
|
*
|
|
|
|
* If `values` pointer is _not_ NULL, expects `values` to contain at least
|
|
|
|
* three non-null pointers to null-terminated strings, corresponding to:
|
|
|
|
* { aws_region,
|
|
|
|
* secret_id,
|
|
|
|
* secret_key,
|
|
|
|
* }
|
|
|
|
* If all three strings are empty (""), the default fapl will be default.
|
|
|
|
* Both aws_region and secret_id values must be both empty or both
|
|
|
|
* populated. If
|
|
|
|
* Only secret_key is allowed to be empty (the empty string, "").
|
|
|
|
* All values are checked against overflow as defined in the ros3 vfd
|
|
|
|
* header file; if a value overruns the permitted space, FAIL is returned
|
|
|
|
* and the function aborts without resetting the fapl to values initially
|
|
|
|
* present.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
*
|
|
|
|
* 0 (failure) if...
|
|
|
|
* * Read-Only S3 VFD is not enabled.
|
|
|
|
* * NULL fapl pointer: (NULL, {...} )
|
|
|
|
* * Warning: In all cases below, fapl will be set as "default"
|
|
|
|
* before error occurs.
|
|
|
|
* * NULL value strings: (&fa, {NULL?, NULL? NULL?, ...})
|
|
|
|
* * Incomplete fapl info:
|
|
|
|
* * empty region, non-empty id, key either way
|
|
|
|
* * (&fa, {"", "...", "?"})
|
|
|
|
* * empty id, non-empty region, key either way
|
|
|
|
* * (&fa, {"...", "", "?"})
|
|
|
|
* * "non-empty key and either id or region empty
|
|
|
|
* * (&fa, {"", "", "...")
|
|
|
|
* * (&fa, {"", "...", "...")
|
|
|
|
* * (&fa, {"...", "", "...")
|
|
|
|
* * Any string would overflow allowed space in fapl definition.
|
|
|
|
* or
|
|
|
|
* 1 (success)
|
|
|
|
* * Sets components in fapl_t pointer, copying strings as appropriate.
|
|
|
|
* * "Default" fapl (valid version, authenticate->False, empty strings)
|
|
|
|
* * `values` pointer is NULL
|
|
|
|
* * (&fa, NULL)
|
|
|
|
* * first three strings in `values` are empty ("")
|
|
|
|
* * (&fa, {"", "", "", ...}
|
|
|
|
* * Authenticating fapl
|
|
|
|
* * region, id, and optional key provided
|
|
|
|
* * (&fa, {"...", "...", ""})
|
|
|
|
* * (&fa, {"...", "...", "..."})
|
|
|
|
*
|
|
|
|
* Programmer: Jacob Smith
|
|
|
|
* 2017-11-13
|
|
|
|
*
|
|
|
|
*----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
|
2019-07-26 00:36:37 +08:00
|
|
|
{
|
|
|
|
int show_progress = 0; /* set to 1 for debugging */
|
|
|
|
int ret_value = 1; /* 1 for success, 0 for failure */
|
|
|
|
/* e.g.? if (!populate()) { then failed } */
|
|
|
|
|
|
|
|
if (show_progress) {
|
|
|
|
HDprintf("called h5tools_populate_ros3_fapl\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fa == NULL) {
|
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" ERROR: null pointer to fapl_t\n");
|
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" preset fapl with default values\n");
|
|
|
|
}
|
2019-08-20 07:35:55 +08:00
|
|
|
fa->version = H5FD_CURR_ROS3_FAPL_T_VERSION;
|
2019-07-26 00:36:37 +08:00
|
|
|
fa->authenticate = FALSE;
|
|
|
|
*(fa->aws_region) = '\0';
|
|
|
|
*(fa->secret_id) = '\0';
|
|
|
|
*(fa->secret_key) = '\0';
|
|
|
|
|
|
|
|
/* sanity-check supplied values
|
|
|
|
*/
|
|
|
|
if (values != NULL) {
|
|
|
|
if (values[0] == NULL) {
|
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" ERROR: aws_region value cannot be NULL\n");
|
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (values[1] == NULL) {
|
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" ERROR: secret_id value cannot be NULL\n");
|
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (values[2] == NULL) {
|
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" ERROR: secret_key value cannot be NULL\n");
|
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if region and ID are supplied (key optional), write to fapl...
|
|
|
|
* fail if value would overflow
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
if (*values[0] != '\0' && *values[1] != '\0') {
|
2019-08-20 07:35:55 +08:00
|
|
|
if (HDstrlen(values[0]) > H5FD_ROS3_MAX_REGION_LEN) {
|
2019-07-26 00:36:37 +08:00
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" ERROR: aws_region value too long\n");
|
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
HDmemcpy(fa->aws_region, values[0], (HDstrlen(values[0]) + 1));
|
2019-07-26 00:36:37 +08:00
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" aws_region set\n");
|
|
|
|
}
|
|
|
|
|
2019-08-20 07:35:55 +08:00
|
|
|
if (HDstrlen(values[1]) > H5FD_ROS3_MAX_SECRET_ID_LEN) {
|
2019-07-26 00:36:37 +08:00
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" ERROR: secret_id value too long\n");
|
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
HDmemcpy(fa->secret_id, values[1], (HDstrlen(values[1]) + 1));
|
2019-07-26 00:36:37 +08:00
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" secret_id set\n");
|
|
|
|
}
|
|
|
|
|
2019-08-20 07:35:55 +08:00
|
|
|
if (HDstrlen(values[2]) > H5FD_ROS3_MAX_SECRET_KEY_LEN) {
|
2019-07-26 00:36:37 +08:00
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" ERROR: secret_key value too long\n");
|
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
HDmemcpy(fa->secret_key, values[2], (HDstrlen(values[2]) + 1));
|
2019-07-26 00:36:37 +08:00
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" secret_key set\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fa->authenticate = TRUE;
|
|
|
|
if (show_progress) {
|
|
|
|
HDprintf(" set to authenticate\n");
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else if (*values[0] != '\0' || *values[1] != '\0' || *values[2] != '\0') {
|
2019-07-26 00:36:37 +08:00
|
|
|
if (show_progress) {
|
2020-09-30 22:27:10 +08:00
|
|
|
HDprintf(" ERROR: invalid assortment of empty/non-empty values\n");
|
2019-07-26 00:36:37 +08:00
|
|
|
}
|
|
|
|
ret_value = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
} /* values != NULL */
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret_value;
|
|
|
|
} /* h5tools_populate_ros3_fapl */
|
2019-08-20 07:35:55 +08:00
|
|
|
#endif /* H5_HAVE_ROS3_VFD */
|
2019-07-26 00:36:37 +08:00
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
#ifdef H5_HAVE_LIBHDFS
|
|
|
|
/*----------------------------------------------------------------------------
|
2019-07-26 00:36:37 +08:00
|
|
|
*
|
2020-02-12 07:57:19 +08:00
|
|
|
* Function: h5tools_parse_hdfs_fapl_tuple
|
2019-07-26 00:36:37 +08:00
|
|
|
*
|
2020-02-12 07:57:19 +08:00
|
|
|
* Purpose: A convenience function that parses a string containing a tuple
|
|
|
|
* of HDFS VFD configuration information.
|
2019-07-26 00:36:37 +08:00
|
|
|
*
|
2020-02-12 07:57:19 +08:00
|
|
|
* Return: SUCCEED/FAIL
|
2019-07-26 00:36:37 +08:00
|
|
|
*
|
2020-02-12 07:57:19 +08:00
|
|
|
*----------------------------------------------------------------------------
|
2019-07-26 00:36:37 +08:00
|
|
|
*/
|
2020-02-12 07:57:19 +08:00
|
|
|
herr_t
|
2020-09-30 22:27:10 +08:00
|
|
|
h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, H5FD_hdfs_fapl_t *fapl_config_out)
|
2019-07-26 00:36:37 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned long k = 0;
|
|
|
|
unsigned nelems = 0;
|
|
|
|
char * props_src = NULL;
|
|
|
|
char ** props = NULL;
|
|
|
|
herr_t ret_value = SUCCEED;
|
2020-02-12 07:57:19 +08:00
|
|
|
|
|
|
|
/* Attempt to parse HDFS configuration tuple */
|
|
|
|
if (parse_tuple(tuple_str, delim, &props_src, &nelems, &props) < 0)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "failed to parse HDFS VFD configuration tuple");
|
|
|
|
|
|
|
|
/* Sanity-check tuple count */
|
|
|
|
if (nelems != 5)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "invalid HDFS VFD configuration");
|
|
|
|
|
|
|
|
/* Populate fapl configuration structure with given properties.
|
|
|
|
* WARNING: No error-checking is done on length of input strings...
|
|
|
|
* Silent overflow is possible, albeit unlikely.
|
|
|
|
*/
|
|
|
|
if (HDstrncmp(props[0], "", 1)) {
|
|
|
|
HDstrncpy(fapl_config_out->namenode_name, (const char *)props[0], HDstrlen(props[0]));
|
2019-07-26 00:36:37 +08:00
|
|
|
}
|
2020-02-12 07:57:19 +08:00
|
|
|
if (HDstrncmp(props[1], "", 1)) {
|
|
|
|
k = strtoul((const char *)props[1], NULL, 0);
|
|
|
|
if (errno == ERANGE)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "supposed port number wasn't");
|
|
|
|
fapl_config_out->namenode_port = (int32_t)k;
|
|
|
|
}
|
|
|
|
if (HDstrncmp(props[2], "", 1)) {
|
|
|
|
HDstrncpy(fapl_config_out->kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
|
|
|
|
}
|
|
|
|
if (HDstrncmp(props[3], "", 1)) {
|
|
|
|
HDstrncpy(fapl_config_out->user_name, (const char *)props[3], HDstrlen(props[3]));
|
|
|
|
}
|
|
|
|
if (HDstrncmp(props[4], "", 1)) {
|
|
|
|
k = HDstrtoul((const char *)props[4], NULL, 0);
|
|
|
|
if (errno == ERANGE)
|
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "supposed buffersize number wasn't");
|
|
|
|
fapl_config_out->stream_buffer_size = (int32_t)k;
|
2019-07-26 00:36:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2020-02-12 07:57:19 +08:00
|
|
|
if (props)
|
|
|
|
HDfree(props);
|
|
|
|
if (props_src)
|
|
|
|
HDfree(props_src);
|
2019-07-26 00:36:37 +08:00
|
|
|
|
2020-02-12 07:57:19 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
#endif /* H5_HAVE_LIBHDFS */
|