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  * This file contains private information about the H5L module
16  * for dealing with links in an HDF5 file.
17  */
18 #ifndef _H5Lprivate_H
19 #define _H5Lprivate_H
20 
21 /* Include package's public header */
22 #include "H5Lpublic.h"
23 
24 /* Private headers needed by this file */
25 #include "H5Gprivate.h"		/* Groups				*/
26 #include "H5Oprivate.h"		/* Object headers			*/
27 
28 
29 /**************************/
30 /* Library Private Macros */
31 /**************************/
32 
33 /* Default number of soft links to traverse */
34 #define H5L_NUM_LINKS   16
35 
36 /* ========  Link creation property names ======== */
37 #define H5L_CRT_INTERMEDIATE_GROUP_NAME         "intermediate_group" /* Create intermediate groups flag */
38 
39 /* ========  Link access property names ======== */
40 #define H5L_ACS_NLINKS_NAME        "max soft links"         /* Number of soft links to traverse */
41 #define H5L_ACS_ELINK_PREFIX_NAME  "external link prefix"   /* External link prefix */
42 #define H5L_ACS_ELINK_FAPL_NAME    "external link fapl"     /* file access property list for external link access */
43 #define H5L_ACS_ELINK_FLAGS_NAME   "external link flags"    /* file access flags for external link traversal */
44 #define H5L_ACS_ELINK_CB_NAME      "external link callback" /*  callback function for external link traversal */
45 
46 
47 /****************************/
48 /* Library Private Typedefs */
49 /****************************/
50 
51 /* User data for path traversal routine for getting link value by index */
52 typedef struct {
53     /* In */
54     H5_index_t idx_type;               /* Index to use */
55     H5_iter_order_t order;              /* Order to iterate in index */
56     hsize_t n;                          /* Offset of link within index */
57     size_t size;                        /* Size of user buffer */
58 
59     /* Out */
60     void *buf;                          /* User buffer */
61 } H5L_trav_gvbi_t;
62 
63 /* User data for path traversal routine for getting link info by index */
64 typedef struct {
65     /* In */
66     H5_index_t idx_type;               /* Index to use */
67     H5_iter_order_t order;              /* Order to iterate in index */
68     hsize_t n;                          /* Offset of link within index */
69 
70     /* Out */
71     H5L_info_t      *linfo;             /* Buffer to return to user */
72 } H5L_trav_gibi_t;
73 
74 /* User data for path traversal routine for getting name by index */
75 typedef struct {
76     /* In */
77     H5_index_t idx_type;                /* Index to use */
78     H5_iter_order_t order;              /* Order to iterate in index */
79     hsize_t n;                          /* Offset of link within index */
80     size_t size;                        /* Size of name buffer */
81 
82     /* Out */
83     char *name;                         /* Buffer to return name to user */
84     ssize_t name_len;                   /* Length of full name */
85 } H5L_trav_gnbi_t;
86 
87 /* User data for path traversal routine for removing link by index */
88 typedef struct {
89     /* In */
90     H5_index_t idx_type;               /* Index to use */
91     H5_iter_order_t order;              /* Order to iterate in index */
92     hsize_t n;                          /* Offset of link within index */
93 } H5L_trav_rmbi_t;
94 
95 /* Structure for external link traversal callback property */
96 typedef struct H5L_elink_cb_t {
97     H5L_elink_traverse_t      func;
98     void                      *user_data;
99 } H5L_elink_cb_t;
100 
101 
102 /*****************************/
103 /* Library Private Variables */
104 /*****************************/
105 
106 
107 /******************************/
108 /* Library Private Prototypes */
109 /******************************/
110 
111 /* General operations on links */
112 H5_DLL herr_t H5L_init(void);
113 H5_DLL herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name,
114     H5G_loc_t *obj_loc, hid_t lcpl_id);
115 H5_DLL herr_t H5L_link_object(const H5G_loc_t *new_loc, const char *new_name,
116     H5O_obj_create_t *ocrt_info, hid_t lcpl_id);
117 H5_DLL herr_t H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name,
118     const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id);
119 H5_DLL herr_t H5L_create_soft(const char *target_path, const H5G_loc_t *cur_loc,
120     const char *cur_name, hid_t lcpl_id);
121 H5_DLL herr_t H5L_move(const H5G_loc_t *src_loc, const char *src_name,
122     const H5G_loc_t *dst_loc, const char *dst_name, hbool_t copy_flag,
123     hid_t lcpl_id);
124 H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name);
125 H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name,
126     H5L_info_t *linkbuf/*out*/);
127 H5_DLL herr_t H5L_delete(const H5G_loc_t *loc, const char *name);
128 H5_DLL herr_t H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf/*out*/,
129     size_t size);
130 H5_DLL herr_t H5L_register_external(void);
131 
132 /* User-defined link functions */
133 H5_DLL herr_t H5L_register(const H5L_class_t *cls);
134 H5_DLL herr_t H5L_unregister(H5L_type_t id);
135 H5_DLL const H5L_class_t *H5L_find_class(H5L_type_t id);
136 
137 #endif /* _H5Lprivate_H */
138 
139