2003-04-03 02:44:12 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-04-03 02:44:12 +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 *
|
|
|
|
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
|
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2003-04-03 02:44:12 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2003-01-24 06:08:51 +08:00
|
|
|
|
|
|
|
#include "h5trav.h"
|
2017-10-14 05:34:01 +08:00
|
|
|
#include "h5tools.h"
|
2005-08-14 04:53:35 +08:00
|
|
|
#include "H5private.h"
|
2003-04-09 04:27:27 +08:00
|
|
|
|
2006-11-21 05:31:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* local typedefs
|
2006-11-21 05:31:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2014-03-16 12:44:13 +08:00
|
|
|
typedef struct trav_addr_path_t {
|
2020-01-17 05:29:34 +08:00
|
|
|
H5O_token_t token;
|
2014-03-16 12:44:13 +08:00
|
|
|
char *path;
|
|
|
|
} trav_addr_path_t;
|
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
typedef struct trav_addr_t {
|
|
|
|
size_t nalloc;
|
|
|
|
size_t nused;
|
2014-03-16 12:44:13 +08:00
|
|
|
trav_addr_path_t *objs;
|
2007-09-06 23:54:22 +08:00
|
|
|
} trav_addr_t;
|
|
|
|
|
|
|
|
typedef struct {
|
[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
|
|
|
h5trav_obj_func_t visit_obj; /* Callback for visiting objects */
|
|
|
|
h5trav_lnk_func_t visit_lnk; /* Callback for visiting links */
|
2007-09-06 23:54:22 +08:00
|
|
|
void *udata; /* User data to pass to callbacks */
|
|
|
|
} trav_visitor_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
trav_addr_t *seen; /* List of addresses seen already */
|
|
|
|
const trav_visitor_t *visitor; /* Information for visiting each link/object */
|
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
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.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-06-04 08:17:27 +08:00
|
|
|
hbool_t is_absolute; /* Whether the traversal has absolute paths */
|
2008-09-22 02:35:43 +08:00
|
|
|
const char *base_grp_name; /* Name of the group that serves as the base
|
|
|
|
* for iteration */
|
2020-01-17 05:29:34 +08:00
|
|
|
unsigned fields; /* Fields needed in H5O_info2_t struct */
|
2007-09-06 23:54:22 +08:00
|
|
|
} trav_ud_traverse_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
hid_t fid; /* File ID being traversed */
|
|
|
|
} trav_print_udata_t;
|
2003-10-29 01:40:05 +08:00
|
|
|
|
2015-03-07 03:53:23 +08:00
|
|
|
typedef struct trav_path_op_data_t {
|
|
|
|
const char *path;
|
|
|
|
} trav_path_op_data_t;
|
|
|
|
|
2012-07-13 04:30:30 +08:00
|
|
|
/* format for hsize_t */
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-21 05:29:26 +08:00
|
|
|
#ifdef H5TRAV_PRINT_SPACE
|
2013-10-01 00:52:03 +08:00
|
|
|
#define HSIZE_T_FORMAT "%" H5_PRINTF_LL_WIDTH "u"
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-21 05:29:26 +08:00
|
|
|
#endif /* H5TRAV_PRINT_SPACE */
|
2012-07-13 04:30:30 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* local functions
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static void trav_table_add(trav_table_t *table,
|
|
|
|
const char *objname,
|
2020-01-17 05:29:34 +08:00
|
|
|
const H5O_info2_t *oinfo);
|
2003-10-29 01:40:05 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
static void trav_table_addlink(trav_table_t *table,
|
2020-01-17 05:29:34 +08:00
|
|
|
const H5O_token_t *obj_token,
|
2007-09-06 23:54:22 +08:00
|
|
|
const char *path);
|
2006-11-21 05:31:06 +08:00
|
|
|
|
2012-07-10 03:41:17 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* local variables
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static H5_index_t trav_index_by = H5_INDEX_NAME;
|
|
|
|
static H5_iter_order_t trav_index_order = H5_ITER_INC;
|
|
|
|
|
2012-07-13 04:30:30 +08:00
|
|
|
static int trav_verbosity = 0;
|
2012-07-12 23:38:44 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5trav_set_index
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Set indexing properties for the objects & links in the file
|
2012-07-12 23:38:44 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: none
|
2012-07-12 23:38:44 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order)
|
|
|
|
{
|
|
|
|
trav_index_by = print_index_by;
|
|
|
|
trav_index_order = print_index_order;
|
|
|
|
}
|
|
|
|
|
2012-07-13 04:30:30 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5trav_set_verbose
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Set verbosity of file contents 1=>attributes
|
2012-07-13 04:30:30 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: none
|
2012-07-13 04:30:30 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5trav_set_verbose(int print_verbose)
|
|
|
|
{
|
|
|
|
trav_verbosity = print_verbose;
|
|
|
|
}
|
|
|
|
|
2006-11-21 05:31:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* "h5trav info" public functions. used in h5diff
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2003-01-24 06:08:51 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2020-01-17 05:29:34 +08:00
|
|
|
* Function: trav_token_add
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2020-01-17 05:29:34 +08:00
|
|
|
* Purpose: Add an object token to visited data structure
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2003-01-24 06:08:51 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
static void
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_token_add(trav_addr_t *visited, H5O_token_t *token, const char *path)
|
2003-01-24 06:08:51 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
size_t idx; /* Index of address to use */
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Allocate space if necessary */
|
|
|
|
if(visited->nused == visited->nalloc) {
|
|
|
|
visited->nalloc = MAX(1, visited->nalloc * 2);;
|
2014-03-16 12:44:13 +08:00
|
|
|
visited->objs = (trav_addr_path_t *)HDrealloc(visited->objs, visited->nalloc * sizeof(trav_addr_path_t));
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end if */
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Append it */
|
|
|
|
idx = visited->nused++;
|
2020-01-17 05:29:34 +08:00
|
|
|
HDmemcpy(&visited->objs[idx].token, token, sizeof(H5O_token_t));
|
[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
|
|
|
visited->objs[idx].path = HDstrdup(path);
|
2020-01-17 05:29:34 +08:00
|
|
|
} /* end trav_token_add() */
|
2003-12-19 00:18:09 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2020-01-17 05:29:34 +08:00
|
|
|
* Function: trav_token_visited
|
2003-10-23 05:30:19 +08:00
|
|
|
*
|
2020-01-17 05:29:34 +08:00
|
|
|
* Purpose: Check if an object token has already been seen
|
2003-10-23 05:30:19 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: TRUE/FALSE
|
2003-10-23 05:30:19 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE static const char *
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_token_visited(hid_t loc_id, trav_addr_t *visited, H5O_token_t *token)
|
2003-10-23 05:30:19 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
size_t u; /* Local index variable */
|
2020-01-17 05:29:34 +08:00
|
|
|
int token_cmp;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
|
|
|
/* Look for address */
|
2020-01-17 05:29:34 +08:00
|
|
|
for(u = 0; u < visited->nused; u++) {
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Check for address already in array */
|
2020-01-17 05:29:34 +08:00
|
|
|
if(H5Otoken_cmp(loc_id, &visited->objs[u].token, token, &token_cmp) < 0)
|
|
|
|
return NULL;
|
|
|
|
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(visited->objs[u].path);
|
2020-01-17 05:29:34 +08:00
|
|
|
}
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
/* Didn't find object token */
|
[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(NULL);
|
2020-01-17 05:29:34 +08:00
|
|
|
} /* end trav_token_visited() */
|
2003-10-23 05:30:19 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: traverse_cb
|
2003-10-23 05:30:19 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Iterator callback for traversing objects in file
|
2003-10-23 05:30:19 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
static herr_t
|
2020-01-17 05:29:34 +08:00
|
|
|
traverse_cb(hid_t loc_id, const char *path, const H5L_info2_t *linfo,
|
2007-09-06 23:54:22 +08:00
|
|
|
void *_udata)
|
|
|
|
{
|
|
|
|
trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */
|
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
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.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-06-04 08:17:27 +08:00
|
|
|
char *new_name = NULL;
|
|
|
|
const char *full_name;
|
[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
|
|
|
const char *already_visited = NULL; /* Whether the link/object was already visited */
|
2007-09-06 23:54:22 +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
|
|
|
/* Create the full path name for the link */
|
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
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.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-06-04 08:17:27 +08:00
|
|
|
if(udata->is_absolute) {
|
2008-09-22 02:35:43 +08:00
|
|
|
size_t base_len = HDstrlen(udata->base_grp_name);
|
2014-03-16 12:44:13 +08:00
|
|
|
size_t add_slash = base_len ? ((udata->base_grp_name)[base_len - 1] != '/') : 1;
|
2019-07-10 11:15:36 +08:00
|
|
|
size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1 + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2014-03-16 12:44:13 +08:00
|
|
|
if(NULL == (new_name = (char*)HDmalloc(new_name_len)))
|
2008-09-22 02:35:43 +08:00
|
|
|
return(H5_ITER_ERROR);
|
2014-03-16 12:44:13 +08:00
|
|
|
if(add_slash)
|
|
|
|
HDsnprintf(new_name, new_name_len, "%s/%s", udata->base_grp_name, path);
|
|
|
|
else
|
|
|
|
HDsnprintf(new_name, new_name_len, "%s%s", udata->base_grp_name, path);
|
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
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.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-06-04 08:17:27 +08:00
|
|
|
full_name = new_name;
|
|
|
|
} /* end if */
|
|
|
|
else
|
|
|
|
full_name = path;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
|
|
|
/* Perform the correct action for different types of links */
|
|
|
|
if(linfo->type == H5L_TYPE_HARD) {
|
2020-01-17 05:29:34 +08:00
|
|
|
H5O_info2_t oinfo;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
|
|
|
/* Get information about the object */
|
2020-01-17 05:29:34 +08:00
|
|
|
if(H5Oget_info_by_name3(loc_id, path, &oinfo, udata->fields, H5P_DEFAULT) < 0) {
|
2008-08-11 23:16:34 +08:00
|
|
|
if(new_name)
|
|
|
|
HDfree(new_name);
|
2007-09-06 23:54:22 +08:00
|
|
|
return(H5_ITER_ERROR);
|
2014-03-16 12:44:13 +08:00
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
|
|
|
|
/* If the object has multiple links, add it to the list of addresses
|
|
|
|
* already visited, if it isn't there already
|
|
|
|
*/
|
[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
|
|
|
if(oinfo.rc > 1)
|
2020-01-17 05:29:34 +08:00
|
|
|
if(NULL == (already_visited = trav_token_visited(loc_id, udata->seen, &oinfo.token)))
|
|
|
|
trav_token_add(udata->seen, &oinfo.token, full_name);
|
2007-09-06 23:54:22 +08:00
|
|
|
|
|
|
|
/* Make 'visit object' callback */
|
2007-09-13 23:44:56 +08:00
|
|
|
if(udata->visitor->visit_obj)
|
2008-08-11 23:16:34 +08:00
|
|
|
if((*udata->visitor->visit_obj)(full_name, &oinfo, already_visited, udata->visitor->udata) < 0) {
|
|
|
|
if(new_name)
|
|
|
|
HDfree(new_name);
|
|
|
|
return(H5_ITER_ERROR);
|
2014-03-16 12:44:13 +08:00
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end if */
|
|
|
|
else {
|
|
|
|
/* Make 'visit link' callback */
|
2007-09-13 23:44:56 +08:00
|
|
|
if(udata->visitor->visit_lnk)
|
2008-08-11 23:16:34 +08:00
|
|
|
if((*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata) < 0) {
|
|
|
|
if(new_name)
|
|
|
|
HDfree(new_name);
|
|
|
|
return(H5_ITER_ERROR);
|
2014-03-16 12:44:13 +08:00
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end else */
|
|
|
|
|
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
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.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-06-04 08:17:27 +08:00
|
|
|
if(new_name)
|
|
|
|
HDfree(new_name);
|
2007-09-06 23:54:22 +08:00
|
|
|
|
|
|
|
return(H5_ITER_CONT);
|
|
|
|
} /* end traverse_cb() */
|
2003-10-23 05:30:19 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: traverse
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Iterate over all the objects/links in a file. Conforms to the
|
|
|
|
* "visitor" pattern.
|
2007-09-06 23:54:22 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2007-09-06 23:54:22 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
[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
|
|
|
traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
|
2018-04-25 04:10:13 +08:00
|
|
|
hbool_t recurse, const trav_visitor_t *visitor, unsigned fields)
|
2003-10-23 05:30:19 +08:00
|
|
|
{
|
2020-01-17 05:29:34 +08:00
|
|
|
H5O_info2_t oinfo; /* Object info for starting group */
|
2019-12-28 16:16:44 +08:00
|
|
|
int ret_value = 0;
|
2007-09-06 23:54:22 +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
|
|
|
/* Get info for starting object */
|
2020-01-17 05:29:34 +08:00
|
|
|
if(H5Oget_info_by_name3(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Oget_info_by_name failed");
|
2007-09-06 23:54:22 +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
|
|
|
/* Visit the starting object */
|
|
|
|
if(visit_start && visitor->visit_obj)
|
|
|
|
(*visitor->visit_obj)(grp_name, &oinfo, NULL, visitor->udata);
|
2007-09-06 23:54:22 +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
|
|
|
/* Go visiting, if the object is a group */
|
|
|
|
if(oinfo.type == H5O_TYPE_GROUP) {
|
|
|
|
trav_addr_t seen; /* List of addresses seen */
|
|
|
|
trav_ud_traverse_t udata; /* User data for iteration callback */
|
2007-09-06 23:54:22 +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
|
|
|
/* Init addresses seen */
|
|
|
|
seen.nused = seen.nalloc = 0;
|
|
|
|
seen.objs = NULL;
|
2007-09-06 23:54:22 +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 multiple links to top group */
|
|
|
|
if(oinfo.rc > 1)
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_token_add(&seen, &oinfo.token, grp_name);
|
2007-09-06 23:54:22 +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
|
|
|
/* Set up user data structure */
|
|
|
|
udata.seen = &seen;
|
|
|
|
udata.visitor = visitor;
|
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
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.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
2008-06-04 08:17:27 +08:00
|
|
|
udata.is_absolute = (*grp_name == '/');
|
2008-09-22 02:35:43 +08:00
|
|
|
udata.base_grp_name = grp_name;
|
2018-04-25 04:10:13 +08:00
|
|
|
udata.fields = fields;
|
2007-09-06 23:54:22 +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 iteration of links vs. visiting all links recursively */
|
|
|
|
if(recurse) {
|
|
|
|
/* Visit all links in group, recursively */
|
2020-01-17 05:29:34 +08:00
|
|
|
if(H5Lvisit_by_name2(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Lvisit_by_name failed");
|
[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 */
|
|
|
|
else {
|
|
|
|
/* Iterate over links in group */
|
2020-01-17 05:29:34 +08:00
|
|
|
if(H5Literate_by_name2(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "H5Literate_by_name failed");
|
[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 else */
|
|
|
|
|
|
|
|
/* Free visited addresses table */
|
|
|
|
if(seen.objs) {
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
|
|
|
|
/* Free paths to objects */
|
|
|
|
for(u = 0; u < seen.nused; u++)
|
|
|
|
HDfree(seen.objs[u].path);
|
|
|
|
HDfree(seen.objs);
|
|
|
|
} /* end if */
|
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
done:
|
|
|
|
return ret_value;
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2006-11-21 05:31:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: trav_info_add
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Add a link path & type to info struct
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2006-11-21 05:31:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-09-17 01:48:06 +08:00
|
|
|
void
|
2007-09-13 23:44:56 +08:00
|
|
|
trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
|
2006-11-21 05:31:06 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
size_t idx; /* Index of address to use */
|
2006-11-21 05:31:06 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
if (info) {
|
|
|
|
/* Allocate space if necessary */
|
|
|
|
if(info->nused == info->nalloc) {
|
|
|
|
info->nalloc = MAX(1, info->nalloc * 2);;
|
|
|
|
info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t));
|
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
/* Append it */
|
|
|
|
idx = info->nused++;
|
|
|
|
info->paths[idx].path = HDstrdup(path);
|
|
|
|
info->paths[idx].type = obj_type;
|
|
|
|
info->paths[idx].fileno = 0;
|
2020-01-17 05:29:34 +08:00
|
|
|
|
|
|
|
/* Set token to 'undefined' values */
|
|
|
|
info->paths[idx].obj_token = H5O_TOKEN_UNDEF;
|
2017-10-14 05:34:01 +08:00
|
|
|
}
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end trav_info_add() */
|
|
|
|
|
2012-08-04 04:11:36 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_fileinfo_add
|
|
|
|
*
|
|
|
|
* Purpose: Add a file addr & fileno to info struct
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
|
|
|
|
{
|
2020-01-17 05:29:34 +08:00
|
|
|
H5O_info2_t oinfo;
|
2012-08-04 04:11:36 +08:00
|
|
|
size_t idx = info->nused - 1;
|
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
if(info->paths[idx].path && HDstrcmp(info->paths[idx].path, "."))
|
|
|
|
H5Oget_info_by_name3(loc_id, info->paths[idx].path, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
|
2012-08-04 04:11:36 +08:00
|
|
|
else
|
2020-01-17 05:29:34 +08:00
|
|
|
H5Oget_info3(loc_id, &oinfo, H5O_INFO_BASIC);
|
2012-08-04 04:11:36 +08:00
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
HDmemcpy(&info->paths[idx].obj_token, &oinfo.token, sizeof(H5O_token_t));
|
2012-08-04 04:11:36 +08:00
|
|
|
info->paths[idx].fileno = oinfo.fileno;
|
|
|
|
} /* end trav_fileinfo_add() */
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2006-11-21 05:31:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: trav_info_visit_obj
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Callback for visiting object, with 'info' structure
|
2007-09-06 23:54:22 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2006-11-21 05:31:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-09-17 01:48:06 +08:00
|
|
|
int
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo,
|
2017-10-14 05:34:01 +08:00
|
|
|
const char H5_ATTR_UNUSED *already_visited, void *udata)
|
2007-09-06 23:54:22 +08:00
|
|
|
{
|
2011-05-07 06:02:24 +08:00
|
|
|
size_t idx;
|
|
|
|
trav_info_t *info_p;
|
2017-10-14 05:34:01 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Add the object to the 'info' struct */
|
2007-09-13 23:44:56 +08:00
|
|
|
/* (object types map directly to "traversal" types) */
|
|
|
|
trav_info_add((trav_info_t *)udata, path, (h5trav_type_t)oinfo->type);
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2011-05-07 06:02:24 +08:00
|
|
|
/* set object addr and fileno. These are for checking same object */
|
|
|
|
info_p = (trav_info_t *) udata;
|
|
|
|
idx = info_p->nused - 1;
|
2020-01-17 05:29:34 +08:00
|
|
|
HDmemcpy(&info_p->paths[idx].obj_token, &oinfo->token, sizeof(H5O_token_t));
|
2011-05-07 06:02:24 +08:00
|
|
|
info_p->paths[idx].fileno = oinfo->fileno;
|
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
return(0);
|
|
|
|
} /* end trav_info_visit_obj() */
|
2006-11-21 05:31:06 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2006-11-21 05:31:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: trav_info_visit_lnk
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Callback for visiting link, with 'info' structure
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2006-11-21 05:31:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-09-17 01:48:06 +08:00
|
|
|
int
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata)
|
2006-11-21 05:31:06 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Add the link to the 'info' struct */
|
2007-09-13 23:44:56 +08:00
|
|
|
trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK));
|
2006-11-21 05:31:06 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
return(0);
|
|
|
|
} /* end trav_info_visit_lnk() */
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2006-11-21 05:31:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: h5trav_getinfo
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: get an array of "trav_info_t" , containing the name and type of
|
|
|
|
* objects in the file
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2006-11-21 05:31:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
int
|
|
|
|
h5trav_getinfo(hid_t file_id, trav_info_t *info)
|
2006-11-21 05:31:06 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */
|
2019-12-28 16:16:44 +08:00
|
|
|
int ret_value = 0;
|
2006-11-21 05:31:06 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Init visitor structure */
|
|
|
|
info_visitor.visit_obj = trav_info_visit_obj;
|
|
|
|
info_visitor.visit_lnk = trav_info_visit_lnk;
|
|
|
|
info_visitor.udata = info;
|
|
|
|
|
|
|
|
/* Traverse all objects in the file, visiting each object & link */
|
2018-05-15 01:26:48 +08:00
|
|
|
if(traverse(file_id, "/", TRUE, TRUE, &info_visitor, H5O_INFO_BASIC) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "traverse failed");
|
2006-11-21 05:31:06 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
done:
|
|
|
|
return ret_value;
|
2006-11-21 05:31:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: h5trav_getindex
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: get index of OBJ in list
|
2006-11-21 05:31:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: index on success,
|
|
|
|
* -1 if not found
|
2006-11-21 05:31:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE ssize_t
|
2007-09-06 23:54:22 +08:00
|
|
|
h5trav_getindex(const trav_info_t *info, const char *obj)
|
2006-11-21 05:31:06 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
size_t u; /* Local index variable */
|
|
|
|
|
|
|
|
/* Loop over all paths in 'info' struct, looking for object */
|
|
|
|
for(u = 0; u < info->nused; u++) {
|
|
|
|
/* Check for object name having full path (with leading '/') */
|
|
|
|
if(HDstrcmp(obj, info->paths[u].path) == 0)
|
|
|
|
return((ssize_t)u);
|
|
|
|
|
|
|
|
/* Check for object name without leading '/' */
|
|
|
|
if(HDstrcmp(obj, (info->paths[u].path + 1)) == 0)
|
|
|
|
return((ssize_t)u);
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
return((ssize_t)-1);
|
|
|
|
} /* end h5trav_getindex() */
|
2006-11-21 05:31:06 +08:00
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
|
2003-01-24 06:08:51 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: trav_info_init
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Initialize the info
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2003-01-24 06:08:51 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
void
|
2010-09-17 01:48:06 +08:00
|
|
|
trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info)
|
2003-01-24 06:08:51 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
trav_info_t *info = (trav_info_t *)HDmalloc(sizeof(trav_info_t));
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Init info structure */
|
|
|
|
info->nused = info->nalloc = 0;
|
|
|
|
info->paths = NULL;
|
2010-09-17 01:48:06 +08:00
|
|
|
info->fname = filename;
|
|
|
|
info->fid = fileid;
|
|
|
|
|
|
|
|
/* Initialize list of visited symbolic links */
|
|
|
|
info->symlink_visited.nused = 0;
|
|
|
|
info->symlink_visited.nalloc = 0;
|
|
|
|
info->symlink_visited.objs = NULL;
|
|
|
|
info->symlink_visited.dangle_link = FALSE;
|
2007-09-06 23:54:22 +08:00
|
|
|
*_info = info;
|
|
|
|
} /* end trav_info_init() */
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_info_free
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: free info memory
|
2007-09-06 23:54:22 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
trav_info_free(trav_info_t *info)
|
|
|
|
{
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
|
|
|
|
if(info) {
|
2010-09-17 01:48:06 +08:00
|
|
|
/* Free visited symbolic links path and file (if alloc) */
|
2017-10-14 05:34:01 +08:00
|
|
|
for(u = 0; u < info->symlink_visited.nused; u++) {
|
2010-09-17 01:48:06 +08:00
|
|
|
if (info->symlink_visited.objs[u].file)
|
|
|
|
HDfree(info->symlink_visited.objs[u].file);
|
|
|
|
HDfree(info->symlink_visited.objs[u].path);
|
|
|
|
}
|
|
|
|
HDfree(info->symlink_visited.objs);
|
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Free path names */
|
|
|
|
for(u = 0; u < info->nused; u++)
|
|
|
|
HDfree(info->paths[u].path);
|
|
|
|
HDfree(info->paths);
|
|
|
|
HDfree(info);
|
|
|
|
} /* end if */
|
|
|
|
} /* end trav_info_free() */
|
2003-01-24 06:08:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* "h5trav table" public functions. used in h5repack
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_table_visit_obj
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2007-09-06 23:54:22 +08:00
|
|
|
* Purpose: Callback for visiting object, with 'table' sructure
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2003-01-24 06:08:51 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
static int
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_table_visit_obj(const char *path, const H5O_info2_t *oinfo,
|
[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
|
|
|
const char *already_visited, void *udata)
|
2003-01-24 06:08:51 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
trav_table_t *table = (trav_table_t *)udata;
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Check if we've already seen this object */
|
[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
|
|
|
if(NULL == already_visited)
|
2007-09-06 23:54:22 +08:00
|
|
|
/* add object to table */
|
|
|
|
trav_table_add(table, path, oinfo);
|
[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
|
|
|
else
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Add alias for object to table */
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_table_addlink(table, &oinfo->token, path);
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
return 0;
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end trav_table_visit_obj() */
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2003-01-24 06:08:51 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: trav_table_visit_lnk
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Callback for visiting link, with 'table' sructure
|
2007-09-06 23:54:22 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2007-09-06 23:54:22 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_table_visit_lnk(const char *path, const H5L_info2_t H5_ATTR_UNUSED *linfo, void *udata)
|
2007-09-06 23:54:22 +08:00
|
|
|
{
|
|
|
|
/* Add the link to the 'table' struct */
|
|
|
|
trav_table_add((trav_table_t *)udata, path, NULL);
|
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
return 0;
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end trav_table_visit_lnk() */
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5trav_gettable
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: get the trav_table_t struct
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2003-01-24 06:08:51 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
int
|
|
|
|
h5trav_gettable(hid_t fid, trav_table_t *table)
|
2003-01-24 06:08:51 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */
|
2019-12-28 16:16:44 +08:00
|
|
|
int ret_value = 0;
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Init visitor structure */
|
|
|
|
table_visitor.visit_obj = trav_table_visit_obj;
|
|
|
|
table_visitor.visit_lnk = trav_table_visit_lnk;
|
|
|
|
table_visitor.udata = table;
|
2003-01-24 06:08:51 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Traverse all objects in the file, visiting each object & link */
|
2018-05-15 01:26:48 +08:00
|
|
|
if(traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "traverse failed");
|
2017-10-14 05:34:01 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
return ret_value;
|
2003-01-24 06:08:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: h5trav_getindext
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: get index of NAME in list
|
2003-01-24 06:08:51 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: index on success,
|
|
|
|
* -1 if not found
|
2003-01-24 06:08:51 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE int
|
2007-09-06 23:54:22 +08:00
|
|
|
h5trav_getindext(const char *name, const trav_table_t *table)
|
2003-01-24 06:08:51 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
unsigned int i;
|
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
if(table) {
|
|
|
|
for(i = 0; i < table->nobjs; i++) {
|
|
|
|
/* Check for object name having full path (with leading '/') */
|
|
|
|
if(HDstrcmp(name, table->objs[i].name) == 0)
|
|
|
|
return((int)i);
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
/* Check for object name without leading '/' */
|
|
|
|
if(HDstrcmp(name, table->objs[i].name + 1) == 0)
|
|
|
|
return((int)i);
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
/* search also in the list of links */
|
|
|
|
if(table->objs[i].nlinks) {
|
|
|
|
unsigned int j;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
for ( j=0; j<table->objs[i].nlinks; j++) {
|
|
|
|
/* Check for object name having full path (with leading '/') */
|
|
|
|
if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0)
|
|
|
|
return((int)i);
|
2007-08-31 04:34:13 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
/* Check for object name without leading '/' */
|
|
|
|
if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0)
|
|
|
|
return((int)i);
|
|
|
|
} /* end for */
|
|
|
|
} /* end if */
|
|
|
|
} /* end for */
|
|
|
|
}
|
2007-09-06 23:54:22 +08:00
|
|
|
return -1;
|
2003-01-24 06:08:51 +08:00
|
|
|
}
|
|
|
|
|
2007-04-05 04:25:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_table_add
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Add OBJNO, NAME and TYPE of object to table
|
2007-04-05 04:25:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2007-04-05 04:25:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
static void
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_table_add(trav_table_t *table, const char *path, const H5O_info2_t *oinfo)
|
2007-04-05 04:25:42 +08:00
|
|
|
{
|
2013-08-20 06:13:15 +08:00
|
|
|
size_t new_obj;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
if(table) {
|
|
|
|
if(table->nobjs == table->size) {
|
|
|
|
table->size = MAX(1, table->size * 2);
|
|
|
|
table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
|
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
new_obj = table->nobjs++;
|
2020-01-17 05:29:34 +08:00
|
|
|
if(oinfo)
|
|
|
|
HDmemcpy(&table->objs[new_obj].obj_token, &oinfo->token, sizeof(H5O_token_t));
|
|
|
|
else
|
|
|
|
/* Set token to 'undefined' values */
|
|
|
|
table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF;
|
2017-10-14 05:34:01 +08:00
|
|
|
table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0;
|
|
|
|
table->objs[new_obj].is_same_trgobj = 0;
|
|
|
|
table->objs[new_obj].name = (char *)HDstrdup(path);
|
|
|
|
table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK;
|
|
|
|
table->objs[new_obj].nlinks = 0;
|
|
|
|
table->objs[new_obj].sizelinks = 0;
|
|
|
|
table->objs[new_obj].links = NULL;
|
|
|
|
}
|
2007-09-06 23:54:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_table_addlink
|
|
|
|
*
|
|
|
|
* Purpose: Add a hardlink name to the object
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static void
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_table_addlink(trav_table_t *table, const H5O_token_t *obj_token, const char *path)
|
2007-09-06 23:54:22 +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
|
|
|
size_t i; /* Local index variable */
|
2020-01-17 05:29:34 +08:00
|
|
|
int token_cmp;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
if(table) {
|
|
|
|
for(i = 0; i < table->nobjs; i++) {
|
2020-01-17 05:29:34 +08:00
|
|
|
if(H5Otoken_cmp(table->fid, &table->objs[i].obj_token, obj_token, &token_cmp) < 0)
|
|
|
|
return;
|
|
|
|
if(!token_cmp) {
|
2017-10-14 05:34:01 +08:00
|
|
|
size_t n;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
/* already inserted? */
|
|
|
|
if(HDstrcmp(table->objs[i].name, path) == 0)
|
|
|
|
return;
|
[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
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
/* allocate space if necessary */
|
|
|
|
if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {
|
|
|
|
table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);
|
|
|
|
table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
|
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
/* insert it */
|
|
|
|
n = table->objs[i].nlinks++;
|
|
|
|
table->objs[i].links[n].new_name = (char *)HDstrdup(path);
|
[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
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
return;
|
2020-01-17 05:29:34 +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
|
|
|
} /* end for */
|
2020-01-17 05:29:34 +08:00
|
|
|
} /* end if */
|
2007-04-05 04:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_table_addflags
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Add FLAGS, NAME and TYPE of object to table
|
2007-04-05 04:25:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2007-04-05 04:25:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void trav_table_addflags(unsigned *flags,
|
|
|
|
char *name,
|
2007-09-13 23:44:56 +08:00
|
|
|
h5trav_type_t type,
|
2007-04-05 04:25:42 +08:00
|
|
|
trav_table_t *table)
|
|
|
|
{
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-21 05:29:26 +08:00
|
|
|
size_t new_obj;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
if(table) {
|
|
|
|
if(table->nobjs == table->size) {
|
|
|
|
table->size = MAX(1, table->size * 2);
|
|
|
|
table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
|
|
|
|
} /* end if */
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
new_obj = table->nobjs++;
|
2020-01-17 05:29:34 +08:00
|
|
|
|
|
|
|
/* Set token to 'undefined' values */
|
|
|
|
table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF;
|
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
table->objs[new_obj].flags[0] = flags[0];
|
|
|
|
table->objs[new_obj].flags[1] = flags[1];
|
|
|
|
table->objs[new_obj].is_same_trgobj = 0;
|
|
|
|
table->objs[new_obj].name = (char *)HDstrdup(name);
|
|
|
|
table->objs[new_obj].type = type;
|
|
|
|
table->objs[new_obj].nlinks = 0;
|
|
|
|
table->objs[new_obj].sizelinks = 0;
|
|
|
|
table->objs[new_obj].links = NULL;
|
|
|
|
}
|
2007-04-05 04:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_table_init
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Initialize the table
|
2007-04-05 04:25:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2007-04-05 04:25:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2020-01-17 05:29:34 +08:00
|
|
|
void trav_table_init(hid_t fid, trav_table_t **tbl)
|
2007-04-05 04:25:42 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t));
|
2017-10-14 05:34:01 +08:00
|
|
|
if(table) {
|
2020-01-17 05:29:34 +08:00
|
|
|
table->fid = fid;
|
2017-10-14 05:34:01 +08:00
|
|
|
table->size = 0;
|
|
|
|
table->nobjs = 0;
|
|
|
|
table->objs = NULL;
|
|
|
|
}
|
2007-09-06 23:54:22 +08:00
|
|
|
*tbl = table;
|
2007-04-05 04:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_table_free
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: free table memory
|
2007-04-05 04:25:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: void
|
2007-04-05 04:25:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2017-10-14 05:34:01 +08:00
|
|
|
void trav_table_free(trav_table_t *table)
|
2007-04-05 04:25:42 +08:00
|
|
|
{
|
2017-10-14 05:34:01 +08:00
|
|
|
if(table) {
|
|
|
|
if(table->objs) {
|
|
|
|
unsigned int i;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
for(i = 0; i < table->nobjs; i++) {
|
|
|
|
HDfree(table->objs[i].name );
|
|
|
|
if(table->objs[i].nlinks) {
|
|
|
|
unsigned int j;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
for(j = 0; j < table->objs[i].nlinks; j++)
|
|
|
|
HDfree(table->objs[i].links[j].new_name);
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
HDfree(table->objs[i].links);
|
|
|
|
} /* end if */
|
|
|
|
} /* end for */
|
|
|
|
HDfree(table->objs);
|
|
|
|
} /* end if */
|
|
|
|
HDfree(table);
|
|
|
|
}
|
2007-04-05 04:25:42 +08:00
|
|
|
}
|
|
|
|
|
2012-07-13 04:30:30 +08:00
|
|
|
static herr_t
|
2013-08-20 06:13:15 +08:00
|
|
|
trav_attr(hid_t
|
|
|
|
#ifndef H5TRAV_PRINT_SPACE
|
2017-10-14 05:34:01 +08:00
|
|
|
H5_ATTR_UNUSED
|
2013-08-20 06:13:15 +08:00
|
|
|
#endif /* H5TRAV_PRINT_SPACE */
|
2017-10-14 05:34:01 +08:00
|
|
|
obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data)
|
2012-07-13 04:30:30 +08:00
|
|
|
{
|
2015-03-07 03:53:23 +08:00
|
|
|
trav_path_op_data_t *op_data = (trav_path_op_data_t *)_op_data;
|
|
|
|
const char *buf = op_data->path;
|
2012-07-13 04:30:30 +08:00
|
|
|
|
|
|
|
if((strlen(buf)==1) && (*buf=='/'))
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s%s", "attribute", buf, attr_name);
|
2012-07-13 04:30:30 +08:00
|
|
|
else
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s/%s", "attribute", buf, attr_name);
|
2012-07-13 04:30:30 +08:00
|
|
|
|
|
|
|
#ifdef H5TRAV_PRINT_SPACE
|
|
|
|
if(trav_verbosity < 2) {
|
|
|
|
#endif
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf("\n");
|
2012-07-13 04:30:30 +08:00
|
|
|
#ifdef H5TRAV_PRINT_SPACE
|
|
|
|
}
|
|
|
|
else {
|
2020-01-14 07:09:48 +08:00
|
|
|
hid_t attr = H5I_INVALID_HID;
|
|
|
|
hid_t space = H5I_INVALID_HID;
|
2012-07-13 04:30:30 +08:00
|
|
|
hsize_t size[H5S_MAX_RANK];
|
|
|
|
int ndims;
|
|
|
|
int i;
|
|
|
|
H5S_class_t space_type;
|
|
|
|
|
|
|
|
if((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) {
|
|
|
|
space = H5Aget_space(attr);
|
|
|
|
|
|
|
|
/* Data space */
|
|
|
|
ndims = H5Sget_simple_extent_dims(space, size, NULL);
|
|
|
|
space_type = H5Sget_simple_extent_type(space);
|
|
|
|
switch(space_type) {
|
|
|
|
case H5S_SCALAR:
|
|
|
|
/* scalar dataspace */
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" scalar\n");
|
2012-07-13 04:30:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5S_SIMPLE:
|
|
|
|
/* simple dataspace */
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" {");
|
2017-10-14 05:34:01 +08:00
|
|
|
for (i = 0; i < ndims; i++) {
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf("%s" HSIZE_T_FORMAT, i?", ":"", size[i]);
|
2012-07-13 04:30:30 +08:00
|
|
|
}
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf("}\n");
|
2012-07-13 04:30:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5S_NULL:
|
|
|
|
/* null dataspace */
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" null\n");
|
2012-07-13 04:30:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Unknown dataspace type */
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" unknown\n");
|
2012-07-13 04:30:30 +08:00
|
|
|
break;
|
|
|
|
} /* end switch */
|
|
|
|
|
|
|
|
H5Sclose(space);
|
|
|
|
H5Aclose(attr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: trav_print_visit_obj
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Callback for visiting object, when printing info
|
2007-09-06 23:54:22 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2007-09-06 23:54:22 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_print_visit_obj(const char *path, const H5O_info2_t *oinfo,
|
|
|
|
const char *already_visited, void *udata)
|
2007-09-06 23:54:22 +08:00
|
|
|
{
|
2012-07-13 04:30:30 +08:00
|
|
|
trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Print the name of the object */
|
|
|
|
/* (no new-line, so that objects that we've encountered before can print
|
|
|
|
* the name of the original object)
|
|
|
|
*/
|
|
|
|
switch(oinfo->type) {
|
|
|
|
case H5O_TYPE_GROUP:
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s", "group", path);
|
2007-09-06 23:54:22 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5O_TYPE_DATASET:
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s", "dataset", path);
|
2007-09-06 23:54:22 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5O_TYPE_NAMED_DATATYPE:
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s", "datatype", path);
|
2007-09-06 23:54:22 +08:00
|
|
|
break;
|
|
|
|
|
2019-08-13 16:36:42 +08:00
|
|
|
case H5O_TYPE_MAP:
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-21 05:29:26 +08:00
|
|
|
case H5O_TYPE_UNKNOWN:
|
|
|
|
case H5O_TYPE_NTYPES:
|
2007-09-06 23:54:22 +08:00
|
|
|
default:
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s", "unknown object type", path);
|
2007-09-06 23:54:22 +08:00
|
|
|
break;
|
|
|
|
} /* end switch */
|
|
|
|
|
|
|
|
/* Check if we've already seen this object */
|
2012-07-13 04:30:30 +08:00
|
|
|
if(NULL == already_visited) {
|
2015-03-07 03:53:23 +08:00
|
|
|
trav_path_op_data_t op_data;
|
|
|
|
|
|
|
|
op_data.path = path;
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Finish printing line about object */
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf("\n");
|
2012-07-13 04:30:30 +08:00
|
|
|
if(trav_verbosity > 0)
|
2017-08-24 05:12:40 +08:00
|
|
|
H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order,
|
2015-03-07 03:53:23 +08:00
|
|
|
NULL, trav_attr, &op_data, H5P_DEFAULT);
|
2012-07-13 04:30:30 +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
|
|
|
else
|
|
|
|
/* Print the link's original name */
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" -> %s\n", already_visited);
|
2007-04-05 04:25:42 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
return(0);
|
|
|
|
} /* end trav_print_visit_obj() */
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2007-04-05 04:25:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-09-06 23:54:22 +08:00
|
|
|
* Function: trav_print_visit_lnk
|
2007-04-05 04:25:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Callback for visiting link, when printing info
|
2007-09-06 23:54:22 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2007-09-06 23:54:22 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
2020-01-17 05:29:34 +08:00
|
|
|
trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata)
|
2007-09-06 23:54:22 +08:00
|
|
|
{
|
|
|
|
trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
|
|
|
|
|
|
|
|
/* Print appropriate information for the type of link */
|
|
|
|
switch(linfo->type) {
|
|
|
|
case H5L_TYPE_SOFT:
|
|
|
|
if(linfo->u.val_size > 0) {
|
2012-03-03 05:30:30 +08:00
|
|
|
char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
|
2017-08-24 05:12:40 +08:00
|
|
|
if(targbuf) {
|
|
|
|
if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
|
|
|
|
targbuf[0] = 0;
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s -> %s\n", "link", path, targbuf);
|
2017-08-24 05:12:40 +08:00
|
|
|
HDfree(targbuf);
|
|
|
|
}
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end if */
|
|
|
|
else
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s ->\n", "link", path);
|
2007-09-06 23:54:22 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case H5L_TYPE_EXTERNAL:
|
|
|
|
if(linfo->u.val_size > 0) {
|
2017-10-14 05:34:01 +08:00
|
|
|
char *targbuf = NULL;
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-21 05:29:26 +08:00
|
|
|
const char *filename = NULL;
|
|
|
|
const char *objname = NULL;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2012-03-03 05:30:30 +08:00
|
|
|
targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
|
2017-08-24 05:12:40 +08:00
|
|
|
if(targbuf) {
|
|
|
|
if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
|
|
|
|
targbuf[0] = 0;
|
|
|
|
if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0)
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
|
2017-08-24 05:12:40 +08:00
|
|
|
HDfree(targbuf);
|
|
|
|
}
|
2007-09-06 23:54:22 +08:00
|
|
|
} /* end if */
|
|
|
|
else
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s ->\n", "ext link", path);
|
2007-09-06 23:54:22 +08:00
|
|
|
break;
|
|
|
|
|
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect.
Bring Coverity changes from branch back to trunk:
r20821:
Use HDstrncpy. --gh
(Fixed already, with strdup)
r20822:
(Not merged, incorrect use of HDstrncpy())
r20823:
(Not merged, incorrect use of HDstrncpy())
r20824:
Maintenance: Bug fix: addressed CID 666.
Value stored at *expression_len should be used in the call to
HD5packFstring to avoid overflow (and unnecessary arithmetic
calculation and casting)
r20825:
Issue 642: Added check for error and handler with print to stderr and exit.
r20826:
Undo revision 20818, as that issue has already been fixed in the 1.8 branch
and trunk (but not coverity branch)
r20827:
(Not merged, incorrect use of HDstrncpy())
r20828:
Use HDstrncpy. --gh
(Corrected use of strncpy())
r20829:
Check return of H5Lget_val(print_udata->fid, path, targbuf,
linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0.
Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL,
&filename, &objname) was successful and allow print. Otherwise filename
and objname are not created. (init those to NULL)
r20830:
resolved coverity issues 939, 940, 941, 944, and 947.
all were complaints about use of sprintf, and in all cases, the
buffers used were large enough for all eventualities.
Resolved issue by replacing calls to sprintf with calls
to snprintf.
r20831:
Maintenance: Addressed CID 852
Replaced sprintf with snprintf
r20832:
Purpose: Fix valgrind issues with hl/examples/ex_image2
Description:
Modified hl/examples/ex_image2 to free global "gbuf" before exit.
Tested on:
Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety
(too minor to require h5committest)
2014-02-21 05:29:26 +08:00
|
|
|
case H5L_TYPE_HARD:
|
|
|
|
/* Should be handled elsewhere */
|
|
|
|
return(-1);
|
|
|
|
|
|
|
|
case H5L_TYPE_ERROR:
|
|
|
|
case H5L_TYPE_MAX:
|
2007-09-06 23:54:22 +08:00
|
|
|
default:
|
2019-08-16 05:46:00 +08:00
|
|
|
HDprintf(" %-10s %s -> ???\n", "unknown type of UD link", path);
|
2007-09-06 23:54:22 +08:00
|
|
|
break;
|
|
|
|
} /* end switch() */
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
} /* end trav_print_visit_lnk() */
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5trav_print
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Print information about the objects & links in the file
|
2007-04-05 04:25:42 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2007-04-05 04:25:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2007-09-06 23:54:22 +08:00
|
|
|
int
|
2012-07-12 23:38:44 +08:00
|
|
|
h5trav_print(hid_t fid)
|
2007-04-05 04:25:42 +08:00
|
|
|
{
|
2007-09-06 23:54:22 +08:00
|
|
|
trav_print_udata_t print_udata; /* User data for traversal */
|
|
|
|
trav_visitor_t print_visitor; /* Visitor structure for printing objects */
|
2019-12-28 16:16:44 +08:00
|
|
|
int ret_value = 0;
|
2007-09-06 23:54:22 +08:00
|
|
|
|
|
|
|
/* Init user data for printing */
|
|
|
|
print_udata.fid = fid;
|
|
|
|
|
|
|
|
/* Init visitor structure */
|
|
|
|
print_visitor.visit_obj = trav_print_visit_obj;
|
|
|
|
print_visitor.visit_lnk = trav_print_visit_lnk;
|
|
|
|
print_visitor.udata = &print_udata;
|
2007-04-05 04:25:42 +08:00
|
|
|
|
2007-09-06 23:54:22 +08:00
|
|
|
/* Traverse all objects in the file, visiting each object & link */
|
2018-05-15 01:26:48 +08:00
|
|
|
if(traverse(fid, "/", TRUE, TRUE, &print_visitor, H5O_INFO_BASIC) < 0)
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "traverse failed");
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
done:
|
|
|
|
return ret_value;
|
[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
|
|
|
}
|
|
|
|
|
2019-12-20 06:29: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
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5trav_visit
|
|
|
|
*
|
|
|
|
* Purpose: Generic traversal routine for visiting objects and links
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
[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
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
|
|
|
|
hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk,
|
2018-04-25 04:10:13 +08:00
|
|
|
void *udata, unsigned fields)
|
[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
|
|
|
{
|
|
|
|
trav_visitor_t visitor; /* Visitor structure for objects */
|
2019-12-28 16:16:44 +08:00
|
|
|
int ret_value = 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
|
|
|
|
|
|
|
/* Init visitor structure */
|
|
|
|
visitor.visit_obj = visit_obj;
|
|
|
|
visitor.visit_lnk = visit_lnk;
|
|
|
|
visitor.udata = udata;
|
|
|
|
|
|
|
|
/* Traverse all objects in the file, visiting each object & link */
|
2018-04-25 04:10:13 +08:00
|
|
|
if(traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0)
|
2019-12-28 16:16:44 +08:00
|
|
|
H5TOOLS_GOTO_ERROR((-1), "traverse failed");
|
2007-09-06 23:54:22 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
done:
|
|
|
|
return ret_value;
|
2007-09-06 23:54:22 +08:00
|
|
|
}
|
2007-04-05 04:25:42 +08:00
|
|
|
|
2010-09-17 01:48:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: symlink_visit_add
|
|
|
|
*
|
|
|
|
* Purpose: Add an symbolic link to visited data structure
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: 0 on success,
|
|
|
|
* -1 on failure
|
2010-09-17 01:48:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
herr_t
|
|
|
|
symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
|
|
|
|
{
|
2019-12-28 16:16:44 +08:00
|
|
|
size_t idx; /* Index of address to use */
|
|
|
|
herr_t ret_value = SUCCEED;
|
2010-09-17 01:48:06 +08:00
|
|
|
|
|
|
|
/* Allocate space if necessary */
|
2014-03-16 12:44:13 +08:00
|
|
|
if(visited->nused == visited->nalloc) {
|
|
|
|
void *tmp_ptr;
|
|
|
|
|
2010-09-17 01:48:06 +08:00
|
|
|
visited->nalloc = MAX(1, visited->nalloc * 2);
|
2014-03-16 12:44:13 +08:00
|
|
|
if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t))))
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "visited data structure realloc failed");
|
2014-03-16 12:44:13 +08:00
|
|
|
visited->objs = (symlink_trav_path_t *)tmp_ptr;
|
2010-09-17 01:48:06 +08:00
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
/* Append it */
|
|
|
|
idx = visited->nused++;
|
|
|
|
|
|
|
|
visited->objs[idx].type = type;
|
|
|
|
visited->objs[idx].file = NULL;
|
|
|
|
visited->objs[idx].path = NULL;
|
|
|
|
|
2014-03-16 12:44:13 +08:00
|
|
|
if(type == H5L_TYPE_EXTERNAL) {
|
|
|
|
if(NULL == (visited->objs[idx].file = HDstrdup(file))) {
|
2010-09-17 01:48:06 +08:00
|
|
|
visited->nused--;
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "visited data structure name allocation failed");
|
2014-03-16 12:44:13 +08:00
|
|
|
} /* end if */
|
|
|
|
} /* end if */
|
2010-09-17 01:48:06 +08:00
|
|
|
|
2014-03-16 12:44:13 +08:00
|
|
|
if(NULL == (visited->objs[idx].path = HDstrdup(path))) {
|
2010-09-17 01:48:06 +08:00
|
|
|
visited->nused--;
|
2014-03-16 12:44:13 +08:00
|
|
|
if(visited->objs[idx].file)
|
2010-09-17 01:48:06 +08:00
|
|
|
HDfree (visited->objs[idx].file);
|
2019-12-28 13:02:26 +08:00
|
|
|
H5TOOLS_GOTO_ERROR(FAIL, "visited data structure path allocation failed");
|
2014-03-16 12:44:13 +08:00
|
|
|
} /* end if */
|
2010-09-17 01:48:06 +08:00
|
|
|
|
2017-10-14 05:34:01 +08:00
|
|
|
done:
|
|
|
|
return ret_value;
|
2010-09-17 01:48:06 +08:00
|
|
|
} /* end symlink_visit_add() */
|
|
|
|
|
2019-12-20 06:29:35 +08:00
|
|
|
|
2010-09-17 01:48:06 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: symlink_is_visited
|
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Purpose: Check if an symbolic link has already been visited
|
2010-09-17 01:48:06 +08:00
|
|
|
*
|
2017-10-14 05:34:01 +08:00
|
|
|
* Return: TRUE/FALSE
|
2010-09-17 01:48:06 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_PURE hbool_t
|
2010-09-17 01:48:06 +08:00
|
|
|
symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
|
|
|
|
{
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
|
|
|
|
/* Look for symlink */
|
2014-03-16 12:44:13 +08:00
|
|
|
for(u = 0; u < visited->nused; u++) {
|
2010-09-17 01:48:06 +08:00
|
|
|
/* Check for symlink values already in array */
|
|
|
|
/* check type and path pair to distingush between symbolic links */
|
2014-03-16 12:44:13 +08:00
|
|
|
if((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path)) {
|
2010-09-17 01:48:06 +08:00
|
|
|
/* if external link, file need to be matched as well */
|
2014-03-16 12:44:13 +08:00
|
|
|
if(visited->objs[u].type == H5L_TYPE_EXTERNAL)
|
|
|
|
if(!HDstrcmp(visited->objs[u].file, file))
|
|
|
|
return(TRUE);
|
|
|
|
|
2010-09-17 01:48:06 +08:00
|
|
|
return (TRUE);
|
2014-03-16 12:44:13 +08:00
|
|
|
} /* end if */
|
|
|
|
} /* end for */
|
|
|
|
|
2010-09-17 01:48:06 +08:00
|
|
|
/* Didn't find symlink */
|
|
|
|
return(FALSE);
|
|
|
|
} /* end symlink_is_visited() */
|
|
|
|
|