]> git.sur5r.net Git - openldap/blob - servers/slapd/back-mdb/proto-mdb.h
5228d26a82eb43166e800f0e56f22204d969771e
[openldap] / servers / slapd / back-mdb / proto-mdb.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2000-2013 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15
16 #ifndef _PROTO_MDB_H
17 #define _PROTO_MDB_H
18
19 LDAP_BEGIN_DECL
20
21 #define MDB_UCTYPE      "MDB"
22
23 /*
24  * attr.c
25  */
26
27 AttrInfo *mdb_attr_mask( struct mdb_info *mdb,
28         AttributeDescription *desc );
29
30 void mdb_attr_flush( struct mdb_info *mdb );
31
32 int mdb_attr_slot( struct mdb_info *mdb,
33         AttributeDescription *desc, int *insert );
34
35 int mdb_attr_dbs_open( BackendDB *be, MDB_txn *txn, struct config_reply_s *cr );
36 void mdb_attr_dbs_close( struct mdb_info *mdb );
37
38 int mdb_attr_index_config LDAP_P(( struct mdb_info *mdb,
39         const char *fname, int lineno,
40         int argc, char **argv, struct config_reply_s *cr ));
41
42 void mdb_attr_index_unparse LDAP_P(( struct mdb_info *mdb, BerVarray *bva ));
43 void mdb_attr_index_destroy LDAP_P(( struct mdb_info *mdb ));
44 void mdb_attr_index_free LDAP_P(( struct mdb_info *mdb,
45         AttributeDescription *ad ));
46
47 void mdb_attr_info_free( AttrInfo *ai );
48
49 int mdb_ad_read( struct mdb_info *mdb, MDB_txn *txn );
50 int mdb_ad_get( struct mdb_info *mdb, MDB_txn *txn, AttributeDescription *ad );
51
52 /*
53  * config.c
54  */
55
56 int mdb_back_init_cf( BackendInfo *bi );
57
58 /*
59  * dn2entry.c
60  */
61
62 int mdb_dn2entry LDAP_P(( Operation *op, MDB_txn *tid, MDB_cursor *mc,
63         struct berval *dn, Entry **e, ID *nsubs, int matched ));
64
65 /*
66  * dn2id.c
67  */
68
69 int mdb_dn2id(
70         Operation *op,
71         MDB_txn *txn,
72         MDB_cursor *mc,
73         struct berval *ndn,
74         ID *id,
75         ID *nsubs,
76         struct berval *matched,
77         struct berval *nmatched );
78
79 int mdb_dn2id_add(
80         Operation *op,
81         MDB_cursor *mcp,
82         MDB_cursor *mcd,
83         ID pid,
84         ID nsubs,
85         int upsub,
86         Entry *e );
87
88 int mdb_dn2id_delete(
89         Operation *op,
90         MDB_cursor *mc,
91         ID id,
92         ID nsubs );
93
94 int mdb_dn2id_children(
95         Operation *op,
96         MDB_txn *tid,
97         Entry *e );
98
99 int mdb_dn2sups (
100         Operation *op,
101         MDB_txn *tid,
102         struct berval *dn,
103         ID *sups
104         );
105
106 int mdb_dn2idl(
107         Operation *op,
108         MDB_txn *txn,
109         struct berval *ndn,
110         ID eid,
111         ID *ids,
112         ID *stack );
113
114 int mdb_dn2id_parent(
115         Operation *op,
116         MDB_txn *txn,
117         ID eid,
118         ID *idp );
119
120 int mdb_id2name(
121         Operation *op,
122         MDB_txn *txn,
123         MDB_cursor **cursp,
124         ID eid,
125         struct berval *name,
126         struct berval *nname);
127
128 int mdb_idscope(
129         Operation *op,
130         MDB_txn *txn,
131         ID base,
132         ID *ids,
133         ID *res );
134
135 struct IdScopes;
136
137 int mdb_idscopes(
138         Operation *op,
139         struct IdScopes *isc );
140
141 int mdb_dn2id_walk(
142         Operation *op,
143         struct IdScopes *isc );
144
145 MDB_cmp_func mdb_dup_compare;
146
147 /*
148  * filterentry.c
149  */
150
151 int mdb_filter_candidates(
152         Operation *op,
153         MDB_txn *txn,
154         Filter  *f,
155         ID *ids,
156         ID *tmp,
157         ID *stack );
158
159 /*
160  * id2entry.c
161  */
162
163 int mdb_id2entry_add(
164         Operation *op,
165         MDB_txn *tid,
166         MDB_cursor *mc,
167         Entry *e );
168
169 int mdb_id2entry_update(
170         Operation *op,
171         MDB_txn *tid,
172         MDB_cursor *mc,
173         Entry *e );
174
175 int mdb_id2entry_delete(
176         BackendDB *be,
177         MDB_txn *tid,
178         Entry *e);
179
180 int mdb_id2entry(
181         Operation *op,
182         MDB_cursor *mc,
183         ID id,
184         Entry **e);
185
186 int mdb_id2edata(
187         Operation *op,
188         MDB_cursor *mc,
189         ID id,
190         MDB_val *data);
191
192 int mdb_entry_return( Operation *op, Entry *e );
193 BI_entry_release_rw mdb_entry_release;
194 BI_entry_get_rw mdb_entry_get;
195
196 int mdb_entry_decode( Operation *op, MDB_val *data, Entry **e );
197
198 void mdb_reader_flush( MDB_env *env );
199 int mdb_opinfo_get( Operation *op, struct mdb_info *mdb, int rdonly, mdb_op_info **moi );
200
201 /*
202  * idl.c
203  */
204
205 unsigned mdb_idl_search( ID *ids, ID id );
206
207 int mdb_idl_fetch_key(
208         BackendDB       *be,
209         MDB_txn         *txn,
210         MDB_dbi         dbi,
211         MDB_val         *key,
212         ID                      *ids,
213         MDB_cursor      **saved_cursor,
214         int                     get_flag );
215
216 int mdb_idl_insert( ID *ids, ID id );
217
218 typedef int (mdb_idl_keyfunc)(
219         BackendDB *be,
220         MDB_cursor *mc,
221         struct berval *key,
222         ID id );
223
224 mdb_idl_keyfunc mdb_idl_insert_keys;
225 mdb_idl_keyfunc mdb_idl_delete_keys;
226
227 int
228 mdb_idl_intersection(
229         ID *a,
230         ID *b );
231
232 int
233 mdb_idl_union(
234         ID *a,
235         ID *b );
236
237 ID mdb_idl_first( ID *ids, ID *cursor );
238 ID mdb_idl_next( ID *ids, ID *cursor );
239
240 void mdb_idl_sort( ID *ids, ID *tmp );
241 int mdb_idl_append( ID *a, ID *b );
242 int mdb_idl_append_one( ID *ids, ID id );
243
244
245 /*
246  * index.c
247  */
248
249 extern AttrInfo *
250 mdb_index_mask LDAP_P((
251         Backend *be,
252         AttributeDescription *desc,
253         struct berval *name ));
254
255 extern int
256 mdb_index_param LDAP_P((
257         Backend *be,
258         AttributeDescription *desc,
259         int ftype,
260         MDB_dbi *dbi,
261         slap_mask_t *mask,
262         struct berval *prefix ));
263
264 extern int
265 mdb_index_values LDAP_P((
266         Operation *op,
267         MDB_txn *txn,
268         AttributeDescription *desc,
269         BerVarray vals,
270         ID id,
271         int opid ));
272
273 extern int
274 mdb_index_recset LDAP_P((
275         struct mdb_info *mdb,
276         Attribute *a,
277         AttributeType *type,
278         struct berval *tags,
279         IndexRec *ir ));
280
281 extern int
282 mdb_index_recrun LDAP_P((
283         Operation *op,
284         MDB_txn *txn,
285         struct mdb_info *mdb,
286         IndexRec *ir,
287         ID id,
288         int base ));
289
290 int mdb_index_entry LDAP_P(( Operation *op, MDB_txn *t, int r, Entry *e ));
291
292 #define mdb_index_entry_add(op,t,e) \
293         mdb_index_entry((op),(t),SLAP_INDEX_ADD_OP,(e))
294 #define mdb_index_entry_del(op,t,e) \
295         mdb_index_entry((op),(t),SLAP_INDEX_DELETE_OP,(e))
296
297 /*
298  * key.c
299  */
300
301 extern int
302 mdb_key_read(
303     Backend     *be,
304         MDB_txn *txn,
305         MDB_dbi dbi,
306     struct berval *k,
307         ID *ids,
308     MDB_cursor **saved_cursor,
309         int get_flags );
310
311 /*
312  * nextid.c
313  */
314
315 int mdb_next_id( BackendDB *be, MDB_cursor *mc, ID *id );
316
317 /*
318  * modify.c
319  */
320
321 int mdb_modify_internal(
322         Operation *op,
323         MDB_txn *tid,
324         Modifications *modlist,
325         Entry *e,
326         const char **text,
327         char *textbuf,
328         size_t textlen );
329
330 /*
331  * monitor.c
332  */
333
334 int mdb_monitor_db_init( BackendDB *be );
335 int mdb_monitor_db_open( BackendDB *be );
336 int mdb_monitor_db_close( BackendDB *be );
337 int mdb_monitor_db_destroy( BackendDB *be );
338
339 #ifdef MDB_MONITOR_IDX
340 int
341 mdb_monitor_idx_add(
342         struct mdb_info         *mdb,
343         AttributeDescription    *desc,
344         slap_mask_t             type );
345 #endif /* MDB_MONITOR_IDX */
346
347 /*
348  * former external.h
349  */
350
351 extern BI_init                          mdb_back_initialize;
352
353 extern BI_db_config                     mdb_db_config;
354
355 extern BI_op_add                        mdb_add;
356 extern BI_op_bind                       mdb_bind;
357 extern BI_op_compare                    mdb_compare;
358 extern BI_op_delete                     mdb_delete;
359 extern BI_op_modify                     mdb_modify;
360 extern BI_op_modrdn                     mdb_modrdn;
361 extern BI_op_search                     mdb_search;
362 extern BI_op_extended                   mdb_extended;
363
364 extern BI_chk_referrals                 mdb_referrals;
365
366 extern BI_operational                   mdb_operational;
367
368 extern BI_has_subordinates              mdb_hasSubordinates;
369
370 /* tools.c */
371 extern BI_tool_entry_open               mdb_tool_entry_open;
372 extern BI_tool_entry_close              mdb_tool_entry_close;
373 extern BI_tool_entry_first_x            mdb_tool_entry_first_x;
374 extern BI_tool_entry_next               mdb_tool_entry_next;
375 extern BI_tool_entry_get                mdb_tool_entry_get;
376 extern BI_tool_entry_put                mdb_tool_entry_put;
377 extern BI_tool_entry_reindex            mdb_tool_entry_reindex;
378 extern BI_tool_dn2id_get                mdb_tool_dn2id_get;
379 extern BI_tool_entry_modify             mdb_tool_entry_modify;
380
381 extern mdb_idl_keyfunc mdb_tool_idl_add;
382
383 LDAP_END_DECL
384
385 #endif /* _PROTO_MDB_H */