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 files COPYING and Copyright.html.  COPYING can be found at the root   *
9  * of the source code distribution tree; Copyright.html can be found at the  *
10  * root level of an installed copy of the electronic HDF5 document set and   *
11  * is linked from the top-level documents page.  It can also be found at     *
12  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
13  * access to either file, you may request a copy from help@hdfgroup.org.     *
14  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 module hdf5.H5Lpublic;
17 
18 /*-------------------------------------------------------------------------
19  *
20  * Created:             H5Lpublic.h
21  *                      Dec 1 2005
22  *                      James Laird
23  *
24  * Purpose:             Public declarations for the H5L package (links)
25  *
26  *-------------------------------------------------------------------------
27  */
28 
29 /* Public headers needed by this file */
30 public import core.stdc.time;
31 
32 import hdf5.H5public;
33 import hdf5.H5Ipublic;
34 import hdf5.H5Tpublic;
35 
36 extern(C):
37 
38 /*****************/
39 /* Public Macros */
40 /*****************/
41 
42 /* Maximum length of a link's name */
43 /* (encoded in a 32-bit unsigned integer) */
44 enum H5L_MAX_LINK_NAME_LEN  = (cast(uint32_t)(-1));  /* (4GB - 1) */
45 
46 /* Macro to indicate operation occurs on same location */
47 enum H5L_SAME_LOC = 0;
48 
49 /* Current version of the H5L_class_t struct */
50 enum H5L_LINK_CLASS_T_VERS = 0;
51 
52 /*******************/
53 /* Public Typedefs */
54 /*******************/
55 
56 /* Link class types.
57  * Values less than 64 are reserved for the HDF5 library's internal use.
58  * Values 64 to 255 are for "user-defined" link class types; these types are
59  * defined by HDF5 but their behavior can be overridden by users.
60  * Users who want to create new classes of links should contact the HDF5
61  * development team at hdfhelp@ncsa.uiuc.edu .
62  * These values can never change because they appear in HDF5 files.
63  */
64 enum H5L_type_t {
65     H5L_TYPE_ERROR = (-1),      /* Invalid link type id         */
66     H5L_TYPE_HARD = 0,          /* Hard link id                 */
67     H5L_TYPE_SOFT = 1,          /* Soft link id                 */
68     H5L_TYPE_EXTERNAL = 64,     /* External link id             */
69     H5L_TYPE_MAX = 255	        /* Maximum link type id         */
70 };
71 enum H5L_TYPE_BUILTIN_MAX = H5L_type_t.H5L_TYPE_SOFT;      /* Maximum value link value for "built-in" link types */
72 enum H5L_TYPE_UD_MIN = H5L_type_t.H5L_TYPE_EXTERNAL;  /* Link ids at or above this value are "user-defined" link types. */
73 
74 /* Information struct for link (for H5Lget_info/H5Lget_info_by_idx) */
75 struct H5L_info_t {
76     H5L_type_t          type;           /* Type of link                   */
77     hbool_t             corder_valid;   /* Indicate if creation order is valid */
78     int64_t             corder;         /* Creation order                 */
79     H5T_cset_t          cset;           /* Character set of link name     */
80     union u {
81         haddr_t         address;        /* Address hard link points to    */
82         size_t          val_size;       /* Size of a soft link or UD link value */
83     };
84 }
85 
86 /* The H5L_class_t struct can be used to override the behavior of a
87  * "user-defined" link class. Users should populate the struct with callback
88  * functions defined below.
89  */
90 /* Callback prototypes for user-defined links */
91 /* Link creation callback */
92 alias H5L_create_func_t = herr_t function(const char *link_name, hid_t loc_group,
93     const void *lnkdata, size_t lnkdata_size, hid_t lcpl_id);
94 
95 /* Callback for when the link is moved */
96 alias H5L_move_func_t = herr_t function(const char *new_name, hid_t new_loc,
97     const void *lnkdata, size_t lnkdata_size);
98 
99 /* Callback for when the link is copied */
100 alias H5L_copy_func_t = herr_t function(const char *new_name, hid_t new_loc,
101     const void *lnkdata, size_t lnkdata_size);
102 
103 /* Callback during link traversal */
104 alias H5L_traverse_func_t = herr_t function(const char *link_name, hid_t cur_group,
105     const void *lnkdata, size_t lnkdata_size, hid_t lapl_id);
106 
107 /* Callback for when the link is deleted */
108 alias H5L_delete_func_t = herr_t function(const char *link_name, hid_t file,
109     const void *lnkdata, size_t lnkdata_size);
110 
111 /* Callback for querying the link */
112 /* Returns the size of the buffer needed */
113 alias H5L_query_func_t = ssize_t function(const char *link_name, const void *lnkdata,
114     size_t lnkdata_size, void *buf /*out*/, size_t buf_size);
115 
116 /* User-defined link types */
117 struct H5L_class_t {
118     int _version;                    /* Version number of this struct        */
119     H5L_type_t id;                  /* Link type ID                         */
120     const char *comment;            /* Comment for debugging                */
121     H5L_create_func_t create_func;  /* Callback during link creation        */
122     H5L_move_func_t move_func;      /* Callback after moving link           */
123     H5L_copy_func_t copy_func;      /* Callback after copying link          */
124     H5L_traverse_func_t trav_func;  /* Callback during link traversal       */
125     H5L_delete_func_t del_func;     /* Callback for link deletion           */
126     H5L_query_func_t query_func;    /* Callback for queries                 */
127 }
128 
129 /* Prototype for H5Literate/H5Literate_by_name() operator */
130 alias H5L_iterate_t = herr_t function(hid_t group, const char *name, const H5L_info_t *info,
131     void *op_data);
132 
133 /* Callback for external link traversal */
134 alias H5L_elink_traverse_t = herr_t function(const char *parent_file_name,
135     const char *parent_group_name, const char *child_file_name,
136     const char *child_object_name, uint *acc_flags, hid_t fapl_id,
137     void *op_data);
138 
139 
140 /********************/
141 /* Public Variables */
142 /********************/
143 
144 version(Posix) {
145 
146 /*********************/
147 /* Public Prototypes */
148 /*********************/
149 herr_t H5Lmove(hid_t src_loc, const char *src_name, hid_t dst_loc,
150     const char *dst_name, hid_t lcpl_id, hid_t lapl_id);
151 herr_t H5Lcopy(hid_t src_loc, const char *src_name, hid_t dst_loc,
152     const char *dst_name, hid_t lcpl_id, hid_t lapl_id);
153 herr_t H5Lcreate_hard(hid_t cur_loc, const char *cur_name,
154     hid_t dst_loc, const char *dst_name, hid_t lcpl_id, hid_t lapl_id);
155 herr_t H5Lcreate_soft(const char *link_target, hid_t link_loc_id,
156     const char *link_name, hid_t lcpl_id, hid_t lapl_id);
157 herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id);
158 herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name,
159     H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id);
160 herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/,
161     size_t size, hid_t lapl_id);
162 herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name,
163     H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
164     void *buf/*out*/, size_t size, hid_t lapl_id);
165 htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id);
166 herr_t H5Lget_info(hid_t loc_id, const char *name,
167     H5L_info_t *linfo /*out*/, hid_t lapl_id);
168 herr_t H5Lget_info_by_idx(hid_t loc_id, const char *group_name,
169     H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
170     H5L_info_t *linfo /*out*/, hid_t lapl_id);
171 ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name,
172     H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
173     char *name /*out*/, size_t size, hid_t lapl_id);
174 herr_t H5Literate(hid_t grp_id, H5_index_t idx_type,
175     H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data);
176 herr_t H5Literate_by_name(hid_t loc_id, const char *group_name,
177     H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
178     H5L_iterate_t op, void *op_data, hid_t lapl_id);
179 herr_t H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
180     H5L_iterate_t op, void *op_data);
181 herr_t H5Lvisit_by_name(hid_t loc_id, const char *group_name,
182     H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op,
183     void *op_data, hid_t lapl_id);
184 
185 /* UD link functions */
186 herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name,
187     H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id,
188     hid_t lapl_id);
189 herr_t H5Lregister(const H5L_class_t *cls);
190 herr_t H5Lunregister(H5L_type_t id);
191 htri_t H5Lis_registered(H5L_type_t id);
192 
193 /* External link functions */
194 herr_t H5Lunpack_elink_val(const void *ext_linkval/*in*/, size_t link_size,
195    uint *flags, const char **filename/*out*/, const char **obj_path /*out*/);
196 herr_t H5Lcreate_external(const char *file_name, const char *obj_name,
197     hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id);
198 }
199