2003-04-01 02:10:51 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2001-03-09 04:18:42 +08:00
|
|
|
/*
|
|
|
|
* Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
|
|
|
|
* Tuesday, 6. March 2001
|
|
|
|
*
|
|
|
|
* Purpose: Support functions for the various tools.
|
|
|
|
*/
|
|
|
|
#ifndef H5TOOLS_UTILS_H__
|
|
|
|
#define H5TOOLS_UTILS_H__
|
|
|
|
|
|
|
|
#include "hdf5.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* begin get_option section
|
|
|
|
*/
|
|
|
|
extern int opt_err; /* getoption prints errors if this is on */
|
|
|
|
extern int opt_ind; /* token pointer */
|
|
|
|
extern const char *opt_arg; /* flag argument (or value) */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
no_arg = 0, /* doesn't take an argument */
|
|
|
|
require_arg, /* requires an argument */
|
|
|
|
optional_arg /* argument is optional */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get_option determines which options are specified on the command line and
|
|
|
|
* returns a pointer to any arguments possibly associated with the option in
|
|
|
|
* the ``opt_arg'' variable. get_option returns the shortname equivalent of
|
|
|
|
* the option. The long options are specified in the following way:
|
|
|
|
*
|
|
|
|
* struct long_options foo[] = {
|
|
|
|
* { "filename", require_arg, 'f' },
|
|
|
|
* { "append", no_arg, 'a' },
|
|
|
|
* { "width", require_arg, 'w' },
|
|
|
|
* { NULL, 0, 0 }
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* Long named options can have arguments specified as either:
|
|
|
|
*
|
|
|
|
* ``--param=arg'' or ``--param arg''
|
|
|
|
*
|
|
|
|
* Short named options can have arguments specified as either:
|
|
|
|
*
|
|
|
|
* ``-w80'' or ``-w 80''
|
|
|
|
*
|
|
|
|
* and can have more than one short named option specified at one time:
|
|
|
|
*
|
|
|
|
* -aw80
|
2005-08-14 04:53:35 +08:00
|
|
|
*
|
2001-03-09 04:18:42 +08:00
|
|
|
* in which case those options which expect an argument need to come at the
|
|
|
|
* end.
|
|
|
|
*/
|
|
|
|
typedef struct long_options {
|
|
|
|
const char *name; /* name of the long option */
|
|
|
|
int has_arg; /* whether we should look for an arg */
|
|
|
|
char shortval; /* the shortname equivalent of long arg
|
|
|
|
* this gets returned from get_option */
|
|
|
|
} long_options;
|
|
|
|
|
|
|
|
extern int get_option(int argc, const char **argv, const char *opt,
|
|
|
|
const struct long_options *l_opt);
|
|
|
|
/*
|
|
|
|
* end get_option section
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*struct taken from the dumper. needed in table struct*/
|
|
|
|
typedef struct obj_t {
|
2003-08-09 03:39:10 +08:00
|
|
|
haddr_t objno;
|
2002-02-28 05:52:19 +08:00
|
|
|
char *objname;
|
2005-08-26 04:16:40 +08:00
|
|
|
hbool_t displayed; /* Flag to indicate that the object has been displayed */
|
|
|
|
hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */
|
2001-03-09 04:18:42 +08:00
|
|
|
} obj_t;
|
|
|
|
|
|
|
|
/*struct for the tables that the find_objs function uses*/
|
|
|
|
typedef struct table_t {
|
2005-08-26 04:16:40 +08:00
|
|
|
size_t size;
|
|
|
|
size_t nobjs;
|
2001-03-09 04:18:42 +08:00
|
|
|
obj_t *objs;
|
|
|
|
} table_t;
|
|
|
|
|
|
|
|
/*this struct stores the information that is passed to the find_objs function*/
|
|
|
|
typedef struct find_objs_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
|
|
|
hid_t fid;
|
2001-03-09 04:18:42 +08:00
|
|
|
table_t *group_table;
|
|
|
|
table_t *type_table;
|
|
|
|
table_t *dset_table;
|
|
|
|
} find_objs_t;
|
|
|
|
|
|
|
|
extern int nCols; /*max number of columns for outputting */
|
|
|
|
|
|
|
|
/* Definitions of useful routines */
|
|
|
|
extern void indentation(int);
|
|
|
|
extern void print_version(const char *progname);
|
|
|
|
extern void error_msg(const char *progname, const char *fmt, ...);
|
|
|
|
extern void warn_msg(const char *progname, const char *fmt, ...);
|
2005-08-26 04:16:40 +08:00
|
|
|
extern void free_table(table_t *table);
|
|
|
|
#ifdef H5DUMP_DEBUG
|
|
|
|
extern void dump_tables(find_objs_t *info)
|
|
|
|
#endif /* H5DUMP_DEBUG */
|
|
|
|
extern herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
|
|
|
|
table_t **dset_table, table_t **type_table);
|
|
|
|
extern obj_t *search_obj(table_t *temp, haddr_t objno);
|
2005-08-18 03:21:36 +08:00
|
|
|
#ifndef H5_HAVE_TMPFILE
|
|
|
|
extern FILE * tmpfile(void);
|
|
|
|
#endif
|
2001-03-09 04:18:42 +08:00
|
|
|
|
|
|
|
#endif /* H5TOOLS_UTILS_H__ */
|