MISR Toolkit  1.5.1
h5trav.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 #ifndef H5TRAV_H__
15 #define H5TRAV_H__
16 
17 #include "hdf5.h"
18 
19 /* Typedefs for visiting objects */
20 typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info_t *oinfo,
21  const char *first_seen, void *udata);
22 typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *linfo,
23  void *udata);
24 
25 /*-------------------------------------------------------------------------
26  * public enum to specify type of an object
27  * the TYPE can be:
28  * H5TRAV_TYPE_UNKNOWN = -1,
29  * H5TRAV_TYPE_GROUP, Object is a group
30  * H5TRAV_TYPE_DATASET, Object is a dataset
31  * H5TRAV_TYPE_TYPE, Object is a named datatype
32  * H5TRAV_TYPE_LINK, Object is a symbolic link
33  * H5TRAV_TYPE_UDLINK, Object is a user-defined link
34  *-------------------------------------------------------------------------
35  */
36 typedef enum {
37  H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */
38  H5TRAV_TYPE_GROUP, /* Object is a group */
39  H5TRAV_TYPE_DATASET, /* Object is a dataset */
40  H5TRAV_TYPE_NAMED_DATATYPE, /* Object is a named datatype */
41  H5TRAV_TYPE_LINK, /* Object is a symbolic link */
42  H5TRAV_TYPE_UDLINK /* Object is a user-defined link */
44 
45 /*-------------------------------------------------------------------------
46  * public struct to store name and type of an object
47  *-------------------------------------------------------------------------
48  */
49 /* Struct to keep track of symbolic link targets visited.
50  * Functions: symlink_visit_add() and symlink_is_visited()
51  */
52 typedef struct symlink_trav_path_t {
54  char *file;
55  char *path;
57 
58 typedef struct symlink_trav_t {
59  size_t nalloc;
60  size_t nused;
64 
65 typedef struct trav_path_t {
66  char *path;
68  haddr_t objno; /* object address */
69  unsigned long fileno; /* File number that object is located in */
70 } trav_path_t;
71 
72 typedef struct trav_info_t {
73  size_t nalloc;
74  size_t nused;
75  const char *fname;
76  hid_t fid; /* File ID */
78  symlink_trav_t symlink_visited; /* already visited symbolic links */
79  void * opts; /* optional data passing */
80 } trav_info_t;
81 
82 
83 /*-------------------------------------------------------------------------
84  * keep record of hard link information
85  *-------------------------------------------------------------------------
86  */
87 typedef struct trav_link_t {
88  char *new_name;
89 } trav_link_t;
90 
91 
92 /*-------------------------------------------------------------------------
93  * struct to store basic info needed for the h5trav table traversal algorythm
94  *-------------------------------------------------------------------------
95  */
96 
97 typedef struct trav_obj_t {
98  haddr_t objno; /* object address */
99  unsigned flags[2]; /* h5diff.object is present or not in both files*/
100  hbool_t is_same_trgobj; /* same target object? no need to compare */
101  char *name; /* name */
102  h5trav_type_t type; /* type of object */
103  trav_link_t *links; /* array of possible link names */
104  size_t sizelinks; /* size of links array */
105  size_t nlinks; /* number of links */
106 } trav_obj_t;
107 
108 
109 /*-------------------------------------------------------------------------
110  * private struct that stores all objects
111  *-------------------------------------------------------------------------
112  */
113 
114 typedef struct trav_table_t {
115  size_t size;
116  size_t nobjs;
118 } trav_table_t;
119 
120 
121 /*-------------------------------------------------------------------------
122  * public functions
123  *-------------------------------------------------------------------------
124  */
125 
126 #ifdef __cplusplus
127 extern "C" {
128 #endif
129 
130 /*-------------------------------------------------------------------------
131  * "h5trav general" public functions
132  *-------------------------------------------------------------------------
133  */
134 H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order);
135 H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name,
136  hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj,
137  h5trav_lnk_func_t visit_lnk, void *udata);
138 H5TOOLS_DLL herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path);
139 H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path);
140 
141 /*-------------------------------------------------------------------------
142  * "h5trav info" public functions
143  *-------------------------------------------------------------------------
144  */
146 H5TOOLS_DLL ssize_t h5trav_getindex(const trav_info_t *info, const char *obj);
147 H5TOOLS_DLL int trav_info_visit_obj (const char *path, const H5O_info_t *oinfo, const char *already_visited, void *udata);
148 H5TOOLS_DLL int trav_info_visit_lnk (const char *path, const H5L_info_t *linfo, void *udata);
149 
150 /*-------------------------------------------------------------------------
151  * "h5trav table" public functions
152  *-------------------------------------------------------------------------
153  */
154 
156 H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt);
157 
158 /*-------------------------------------------------------------------------
159  * "h5trav print" public functions
160  *-------------------------------------------------------------------------
161  */
163 H5TOOLS_DLL void h5trav_set_verbose(int print_verbose);
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 /*-------------------------------------------------------------------------
170  * info private functions
171  *-------------------------------------------------------------------------
172  */
173 
174 H5TOOLS_DLL void trav_info_init(const char *filename, hid_t fileid, trav_info_t **info);
175 
177 
178 H5TOOLS_DLL void trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type);
179 
180 H5TOOLS_DLL void trav_fileinfo_add(trav_info_t *info, hid_t loc_id);
181 
182 /*-------------------------------------------------------------------------
183  * table private functions
184  *-------------------------------------------------------------------------
185  */
186 
188 
190 
191 H5TOOLS_DLL void trav_table_addflags(unsigned *flags,
192  char *objname,
194  trav_table_t *table);
195 
196 #endif /* H5TRAV_H__ */
197 
H5TOOLS_DLL ssize_t h5trav_getindex(const trav_info_t *info, const char *obj)
HDFFCLIBAPI intf * info
unsigned int hbool_t
Definition: H5public.h:142
H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt)
herr_t(* h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *linfo, void *udata)
Definition: h5trav.h:22
H5TOOLS_DLL void trav_info_init(const char *filename, hid_t fileid, trav_info_t **info)
char * filename
Definition: cdjpeg.h:133
#define H5TOOLS_DLL
Definition: H5api_adpt.h:260
H5TOOLS_DLL void h5trav_set_verbose(int print_verbose)
H5_index_t
Definition: H5public.h:305
long long ssize_t
Definition: H5public.h:156
size_t size
Definition: h5trav.h:115
char * path
Definition: h5trav.h:66
int herr_t
Definition: H5public.h:124
void * opts
Definition: h5trav.h:79
H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata)
unsigned long fileno
Definition: h5trav.h:69
size_t nobjs
Definition: h5trav.h:116
haddr_t objno
Definition: h5trav.h:98
H5TOOLS_DLL void trav_table_free(trav_table_t *table)
char * name
Definition: h5trav.h:101
const char * fname
Definition: h5trav.h:75
H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order)
H5TOOLS_DLL void trav_info_free(trav_info_t *info)
H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info)
H5TOOLS_DLL void trav_table_addflags(unsigned *flags, char *objname, h5trav_type_t type, trav_table_t *table)
h5trav_type_t
Definition: h5trav.h:36
H5TOOLS_DLL int h5trav_print(hid_t fid)
size_t nused
Definition: h5trav.h:74
struct trav_obj_t trav_obj_t
symlink_trav_t symlink_visited
Definition: h5trav.h:78
size_t sizelinks
Definition: h5trav.h:104
h5trav_type_t type
Definition: h5trav.h:67
uint64_t haddr_t
Definition: H5public.h:182
trav_obj_t * objs
Definition: h5trav.h:117
struct trav_table_t trav_table_t
struct symlink_trav_t symlink_trav_t
struct symlink_trav_path_t symlink_trav_path_t
h5trav_type_t type
Definition: h5trav.h:102
H5TOOLS_DLL int h5trav_gettable(hid_t fid, trav_table_t *travt)
herr_t(* h5trav_obj_func_t)(const char *path_name, const H5O_info_t *oinfo, const char *first_seen, void *udata)
Definition: h5trav.h:20
H5_iter_order_t
Definition: H5public.h:284
struct trav_path_t trav_path_t
H5TOOLS_DLL void trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
haddr_t objno
Definition: h5trav.h:68
int hid_t
Definition: H5Ipublic.h:54
H5TOOLS_DLL void trav_table_init(trav_table_t **table)
H5TOOLS_DLL int trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
size_t nalloc
Definition: h5trav.h:73
trav_path_t * paths
Definition: h5trav.h:77
trav_link_t * links
Definition: h5trav.h:103
size_t nlinks
Definition: h5trav.h:105
hid_t fid
Definition: h5trav.h:76
H5TOOLS_DLL void trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
H5L_type_t
Definition: H5Lpublic.h:62
HDFFCLIBAPI intf intf * flags
H5TOOLS_DLL int trav_info_visit_obj(const char *path, const H5O_info_t *oinfo, const char *already_visited, void *udata)
hbool_t is_same_trgobj
Definition: h5trav.h:100
H5TOOLS_DLL herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
struct trav_info_t trav_info_t
struct trav_link_t trav_link_t

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