00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00002 * Copyright by The HDF Group. * 00003 * Copyright by the Board of Trustees of the University of Illinois. * 00004 * All rights reserved. * 00005 * * 00006 * This file is part of HDF5. The full HDF5 copyright notice, including * 00007 * terms governing use, modification, and redistribution, is contained in * 00008 * the files COPYING and Copyright.html. COPYING can be found at the root * 00009 * of the source code distribution tree; Copyright.html can be found at the * 00010 * root level of an installed copy of the electronic HDF5 document set and * 00011 * is linked from the top-level documents page. It can also be found at * 00012 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 00013 * access to either file, you may request a copy from help@hdfgroup.org. * 00014 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00015 00016 #ifndef H5TRAV_H__ 00017 #define H5TRAV_H__ 00018 00019 #include "hdf5.h" 00020 00021 /* Typedefs for visiting objects */ 00022 typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info_t *oinfo, 00023 const char *first_seen, void *udata); 00024 typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *linfo, 00025 void *udata); 00026 00027 /*------------------------------------------------------------------------- 00028 * public enum to specify type of an object 00029 * the TYPE can be: 00030 * H5TRAV_TYPE_UNKNOWN = -1, 00031 * H5TRAV_TYPE_GROUP, Object is a group 00032 * H5TRAV_TYPE_DATASET, Object is a dataset 00033 * H5TRAV_TYPE_TYPE, Object is a named datatype 00034 * H5TRAV_TYPE_LINK, Object is a symbolic link 00035 * H5TRAV_TYPE_UDLINK, Object is a user-defined link 00036 *------------------------------------------------------------------------- 00037 */ 00038 typedef enum { 00039 H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */ 00040 H5TRAV_TYPE_GROUP, /* Object is a group */ 00041 H5TRAV_TYPE_DATASET, /* Object is a dataset */ 00042 H5TRAV_TYPE_NAMED_DATATYPE, /* Object is a named datatype */ 00043 H5TRAV_TYPE_LINK, /* Object is a symbolic link */ 00044 H5TRAV_TYPE_UDLINK /* Object is a user-defined link */ 00045 } h5trav_type_t; 00046 00047 /*------------------------------------------------------------------------- 00048 * public struct to store name and type of an object 00049 *------------------------------------------------------------------------- 00050 */ 00051 typedef struct trav_path_t { 00052 char *path; 00053 h5trav_type_t type; 00054 } trav_path_t; 00055 00056 typedef struct trav_info_t { 00057 size_t nalloc; 00058 size_t nused; 00059 trav_path_t *paths; 00060 } trav_info_t; 00061 00062 00063 /*------------------------------------------------------------------------- 00064 * keep record of hard link information 00065 *------------------------------------------------------------------------- 00066 */ 00067 typedef struct trav_link_t { 00068 char *new_name; 00069 } trav_link_t; 00070 00071 00072 /*------------------------------------------------------------------------- 00073 * struct to store basic info needed for the h5trav table traversal algorythm 00074 *------------------------------------------------------------------------- 00075 */ 00076 00077 typedef struct trav_obj_t { 00078 haddr_t objno; /* object address */ 00079 unsigned flags[2]; /* h5diff.object is present or not in both files*/ 00080 char *name; /* name */ 00081 h5trav_type_t type; /* type of object */ 00082 trav_link_t *links; /* array of possible link names */ 00083 size_t sizelinks; /* size of links array */ 00084 size_t nlinks; /* number of links */ 00085 } trav_obj_t; 00086 00087 00088 /*------------------------------------------------------------------------- 00089 * private struct that stores all objects 00090 *------------------------------------------------------------------------- 00091 */ 00092 00093 typedef struct trav_table_t { 00094 size_t size; 00095 size_t nobjs; 00096 trav_obj_t *objs; 00097 } trav_table_t; 00098 00099 00100 /*------------------------------------------------------------------------- 00101 * public functions 00102 *------------------------------------------------------------------------- 00103 */ 00104 00105 #ifdef __cplusplus 00106 extern "C" { 00107 #endif 00108 00109 /*------------------------------------------------------------------------- 00110 * "h5trav general" public functions 00111 *------------------------------------------------------------------------- 00112 */ 00113 int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, 00114 hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, 00115 void *udata); 00116 00117 /*------------------------------------------------------------------------- 00118 * "h5trav info" public functions 00119 *------------------------------------------------------------------------- 00120 */ 00121 int h5trav_getinfo(hid_t file_id, trav_info_t *info); 00122 ssize_t h5trav_getindex(const trav_info_t *info, const char *obj); 00123 00124 /*------------------------------------------------------------------------- 00125 * "h5trav table" public functions 00126 *------------------------------------------------------------------------- 00127 */ 00128 00129 int h5trav_gettable(hid_t fid, trav_table_t *travt); 00130 int h5trav_getindext(const char *obj, const trav_table_t *travt); 00131 00132 /*------------------------------------------------------------------------- 00133 * "h5trav print" public functions 00134 *------------------------------------------------------------------------- 00135 */ 00136 int h5trav_print(hid_t fid); 00137 00138 #ifdef __cplusplus 00139 } 00140 #endif 00141 00142 /*------------------------------------------------------------------------- 00143 * info private functions 00144 *------------------------------------------------------------------------- 00145 */ 00146 00147 void trav_info_init(trav_info_t **info); 00148 00149 void trav_info_free(trav_info_t *info); 00150 00151 /*------------------------------------------------------------------------- 00152 * table private functions 00153 *------------------------------------------------------------------------- 00154 */ 00155 00156 void trav_table_init(trav_table_t **table); 00157 00158 void trav_table_free(trav_table_t *table); 00159 00160 void trav_table_addflags(unsigned *flags, 00161 char *objname, 00162 h5trav_type_t type, 00163 trav_table_t *table); 00164 00165 #endif /* H5TRAV_H__ */ 00166