MISR Toolkit  1.5.1
h5tools_utils.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
16  * Tuesday, 6. March 2001
17  *
18  * Purpose: Support functions for the various tools.
19  */
20 #ifndef H5TOOLS_UTILS_H__
21 #define H5TOOLS_UTILS_H__
22 
23 #include "hdf5.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* ``parallel_print'' information */
30 #define PRINT_DATA_MAX_SIZE 512
31 #define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
32 
34 H5TOOLS_DLLVAR unsigned char g_Parallel;
38 
39 /* Maximum size used in a call to malloc for a dataset */
41 /* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */
43 /*
44  * begin get_option section
45  */
46 H5TOOLS_DLLVAR int opt_err; /* getoption prints errors if this is on */
47 H5TOOLS_DLLVAR int opt_ind; /* token pointer */
48 H5TOOLS_DLLVAR const char *opt_arg; /* flag argument (or value) */
49 
50 enum {
51  no_arg = 0, /* doesn't take an argument */
52  require_arg, /* requires an argument */
53  optional_arg /* argument is optional */
54 };
55 
56 /*
57  * get_option determines which options are specified on the command line and
58  * returns a pointer to any arguments possibly associated with the option in
59  * the ``opt_arg'' variable. get_option returns the shortname equivalent of
60  * the option. The long options are specified in the following way:
61  *
62  * struct long_options foo[] = {
63  * { "filename", require_arg, 'f' },
64  * { "append", no_arg, 'a' },
65  * { "width", require_arg, 'w' },
66  * { NULL, 0, 0 }
67  * };
68  *
69  * Long named options can have arguments specified as either:
70  *
71  * ``--param=arg'' or ``--param arg''
72  *
73  * Short named options can have arguments specified as either:
74  *
75  * ``-w80'' or ``-w 80''
76  *
77  * and can have more than one short named option specified at one time:
78  *
79  * -aw80
80  *
81  * in which case those options which expect an argument need to come at the
82  * end.
83  */
84 typedef struct long_options {
85  const char *name; /* name of the long option */
86  int has_arg; /* whether we should look for an arg */
87  char shortval; /* the shortname equivalent of long arg
88  * this gets returned from get_option */
89 } long_options;
90 
91 H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt,
92  const struct long_options *l_opt);
93 /*
94  * end get_option section
95  */
96 
97 /*struct taken from the dumper. needed in table struct*/
98 typedef struct obj_t {
100  char *objname;
101  hbool_t displayed; /* Flag to indicate that the object has been displayed */
102  hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */
103 } obj_t;
104 
105 /*struct for the tables that the find_objs function uses*/
106 typedef struct table_t {
107  size_t size;
108  size_t nobjs;
110 } table_t;
111 
112 /*this struct stores the information that is passed to the find_objs function*/
113 typedef struct find_objs_t {
118 } find_objs_t;
119 
120 H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */
121 
122 /* Definitions of useful routines */
123 H5TOOLS_DLL void indentation(unsigned);
124 H5TOOLS_DLL void print_version(const char *progname);
125 H5TOOLS_DLL void parallel_print(const char* format, ... );
126 H5TOOLS_DLL void error_msg(const char *fmt, ...);
127 H5TOOLS_DLL void warn_msg(const char *fmt, ...);
128 H5TOOLS_DLL void help_ref_msg(FILE *output);
129 H5TOOLS_DLL void free_table(table_t *table);
130 #ifdef H5DUMP_DEBUG
131 H5TOOLS_DLL void dump_tables(find_objs_t *info)
132 #endif /* H5DUMP_DEBUG */
133 H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
134  table_t **dset_table, table_t **type_table);
136 #ifndef H5_HAVE_TMPFILE
137 H5TOOLS_DLL FILE * tmpfile(void);
138 #endif
139 
140 /*************************************************************
141  *
142  * candidate functions to be public
143  *
144  *************************************************************/
145 
146 /* This code is layout for common code among tools */
147 typedef enum toolname_t {
148  TOOL_H5DIFF, TOOL_H5LS, TOOL__H5DUMP /* add as necessary */
150 
151 /* this struct can be used to differntiate among tools */
152 typedef struct {
153  h5tool_toolname_t toolname;
154  int msg_mode;
155 } h5tool_opt_t;
156 
157 /* obtain link info from H5tools_get_symlink_info() */
158 typedef struct {
159  H5O_type_t trg_type; /* OUT: target type */
160  char *trg_path; /* OUT: target obj path. This must be freed
161  * when used with H5tools_get_symlink_info() */
162  haddr_t objno; /* OUT: target object address */
163  unsigned long fileno; /* OUT: File number that target object is located in */
164  H5L_info_t linfo; /* OUT: link info */
165  h5tool_opt_t opt; /* IN: options */
167 
168 
169 /* Definitions of routines */
170 H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char * linkpath,
171  h5tool_link_info_t *link_info, hbool_t get_obj_type);
172 H5TOOLS_DLL const char *h5tools_getprogname(void);
173 H5TOOLS_DLL void h5tools_setprogname(const char*progname);
175 H5TOOLS_DLL void h5tools_setstatus(int d_status);
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* H5TOOLS_UTILS_H__ */
toolname_t
H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt, const struct long_options *l_opt)
H5TOOLS_DLLVAR hsize_t H5TOOLS_BUFSIZE
Definition: h5tools_utils.h:42
#define H5TOOLS_DLLVAR
Definition: H5api_adpt.h:261
H5TOOLS_DLLVAR int opt_err
Definition: h5tools_utils.h:46
char * objname
enum toolname_t h5tool_toolname_t
HDFFCLIBAPI intf * info
unsigned int hbool_t
Definition: H5public.h:142
H5TOOLS_DLLVAR char outBuff[]
Definition: h5tools_utils.h:35
#define H5TOOLS_DLL
Definition: H5api_adpt.h:260
struct find_objs_t find_objs_t
H5TOOLS_DLLVAR int g_nTasks
Definition: h5tools_utils.h:33
H5TOOLS_DLL const char * h5tools_getprogname(void)
struct obj_t obj_t
H5TOOLS_DLL void warn_msg(const char *fmt,...)
int herr_t
Definition: H5public.h:124
size_t size
H5TOOLS_DLL int h5tools_getstatus(void)
struct table_t table_t
unsigned long long hsize_t
Definition: H5public.h:169
H5O_type_t
Definition: H5Opublic.h:81
size_t nobjs
H5TOOLS_DLLVAR const char * opt_arg
Definition: h5tools_utils.h:48
H5TOOLS_DLL void print_version(const char *progname)
H5TOOLS_DLL void free_table(table_t *table)
H5TOOLS_DLL void parallel_print(const char *format,...)
table_t * dset_table
struct long_options long_options
H5TOOLS_DLL void h5tools_setstatus(int d_status)
obj_t * objs
hbool_t recorded
haddr_t objno
Definition: h5tools_utils.h:99
uint64_t haddr_t
Definition: H5public.h:182
table_t * group_table
table_t * type_table
H5TOOLS_DLLVAR int opt_ind
Definition: h5tools_utils.h:47
int hid_t
Definition: H5Ipublic.h:54
H5TOOLS_DLL void indentation(unsigned)
H5TOOLS_DLLVAR unsigned outBuffOffset
Definition: h5tools_utils.h:36
H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char *linkpath, h5tool_link_info_t *link_info, hbool_t get_obj_type)
H5TOOLS_DLL obj_t * search_obj(table_t *temp, haddr_t objno)
H5TOOLS_DLLVAR unsigned h5tools_nCols
H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void)
H5TOOLS_DLL void help_ref_msg(FILE *output)
const char * name
Definition: h5tools_utils.h:85
H5TOOLS_DLLVAR FILE * overflow_file
Definition: h5tools_utils.h:37
H5TOOLS_DLL void h5tools_setprogname(const char *progname)
H5TOOLS_DLL void error_msg(const char *fmt,...)
H5TOOLS_DLLVAR unsigned char g_Parallel
Definition: h5tools_utils.h:34
h5tool_toolname_t toolname
hbool_t displayed
H5TOOLS_DLLVAR hsize_t H5TOOLS_MALLOCSIZE
Definition: h5tools_utils.h:40
HDFFCLIBAPI _fcd _fcd format
#define output(c)
Definition: lexan.c:10
H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table)

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:53