]> git.sur5r.net Git - openldap/blob - servers/slapd/back-mdb/proto-mdb.h
Merge branch 'mdb.master' of /home/hyc/OD/mdb
[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-2011 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, MDB_txn *txn );
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,
63         struct berval *dn, Entry **e, int matched ));
64
65 /*
66  * dn2id.c
67  */
68
69 int mdb_dn2id(
70         Operation *op,
71         MDB_txn *txn,
72         struct berval *ndn,
73         ID *id,
74         struct berval *matched,
75         struct berval *nmatched );
76
77 int mdb_dn2id_add(
78         Operation *op,
79         MDB_txn *tid,
80         ID pid,
81         Entry *e );
82
83 int mdb_dn2id_delete(
84         Operation *op,
85         MDB_txn *tid,
86         ID pid,
87         Entry *e );
88
89 int mdb_dn2id_children(
90         Operation *op,
91         MDB_txn *tid,
92         Entry *e );
93
94 int mdb_dn2sups (
95         Operation *op,
96         MDB_txn *tid,
97         struct berval *dn,
98         ID *sups
99         );
100
101 int mdb_dn2idl(
102         Operation *op,
103         MDB_txn *txn,
104         struct berval *ndn,
105         ID eid,
106         ID *ids,
107         ID *stack );
108
109 int mdb_dn2id_parent(
110         Operation *op,
111         MDB_txn *txn,
112         ID eid,
113         ID *idp );
114
115 int mdb_id2name(
116         Operation *op,
117         MDB_txn *txn,
118         MDB_cursor **cursp,
119         ID eid,
120         struct berval *name,
121         struct berval *nname);
122
123 int mdb_idscope(
124         Operation *op,
125         MDB_txn *txn,
126         ID base,
127         ID *ids,
128         ID *res );
129
130 int mdb_idscopes(
131         Operation *op,
132         IdScopes *isc );
133
134 MDB_cmp_func mdb_dup_compare;
135
136 /*
137  * filterentry.c
138  */
139
140 int mdb_filter_candidates(
141         Operation *op,
142         MDB_txn *txn,
143         Filter  *f,
144         ID *ids,
145         ID *tmp,
146         ID *stack );
147
148 /*
149  * id2entry.c
150  */
151
152 int mdb_id2entry_add(
153         Operation *op,
154         MDB_txn *tid,
155         Entry *e );
156
157 int mdb_id2entry_update(
158         Operation *op,
159         MDB_txn *tid,
160         Entry *e );
161
162 int mdb_id2entry_delete(
163         BackendDB *be,
164         MDB_txn *tid,
165         Entry *e);
166
167 int mdb_id2entry(
168         Operation *op,
169         MDB_txn *tid,
170         ID id,
171         Entry **e);
172
173 void mdb_entry_free ( Entry *e );
174 int mdb_entry_return( Entry *e );
175 BI_entry_release_rw mdb_entry_release;
176 BI_entry_get_rw mdb_entry_get;
177
178 int mdb_entry_decode( Operation *op, MDB_val *data, Entry **e );
179
180 void mdb_reader_flush( MDB_env *env );
181 int mdb_opinfo_get( Operation *op, struct mdb_info *mdb, int rdonly, mdb_op_info **moi );
182
183 /*
184  * idl.c
185  */
186
187 unsigned mdb_idl_search( ID *ids, ID id );
188
189 int mdb_idl_fetch_key(
190         BackendDB       *be,
191         MDB_txn         *txn,
192         MDB_dbi         dbi,
193         MDB_val         *key,
194         ID                      *ids,
195         MDB_cursor      **saved_cursor,
196         int                     get_flag );
197
198 int mdb_idl_insert( ID *ids, ID id );
199
200 typedef int (mdb_idl_keyfunc)(
201         MDB_cursor *mc,
202         MDB_val *key,
203         ID id );
204
205 mdb_idl_keyfunc mdb_idl_insert_keys;
206 mdb_idl_keyfunc mdb_idl_delete_keys;
207
208 int
209 mdb_idl_intersection(
210         ID *a,
211         ID *b );
212
213 int
214 mdb_idl_union(
215         ID *a,
216         ID *b );
217
218 ID mdb_idl_first( ID *ids, ID *cursor );
219 ID mdb_idl_next( ID *ids, ID *cursor );
220
221 void mdb_idl_sort( ID *ids, ID *tmp );
222 int mdb_idl_append( ID *a, ID *b );
223 int mdb_idl_append_one( ID *ids, ID id );
224
225
226 /*
227  * index.c
228  */
229
230 extern AttrInfo *
231 mdb_index_mask LDAP_P((
232         Backend *be,
233         AttributeDescription *desc,
234         struct berval *name ));
235
236 extern int
237 mdb_index_param LDAP_P((
238         Backend *be,
239         AttributeDescription *desc,
240         int ftype,
241         MDB_dbi *dbi,
242         slap_mask_t *mask,
243         struct berval *prefix ));
244
245 extern int
246 mdb_index_values LDAP_P((
247         Operation *op,
248         MDB_txn *txn,
249         AttributeDescription *desc,
250         BerVarray vals,
251         ID id,
252         int opid ));
253
254 extern int
255 mdb_index_recset LDAP_P((
256         struct mdb_info *mdb,
257         Attribute *a,
258         AttributeType *type,
259         struct berval *tags,
260         IndexRec *ir ));
261
262 extern int
263 mdb_index_recrun LDAP_P((
264         Operation *op,
265         struct mdb_info *mdb,
266         IndexRec *ir,
267         ID id,
268         int base ));
269
270 int mdb_index_entry LDAP_P(( Operation *op, MDB_txn *t, int r, Entry *e ));
271
272 #define mdb_index_entry_add(op,t,e) \
273         mdb_index_entry((op),(t),SLAP_INDEX_ADD_OP,(e))
274 #define mdb_index_entry_del(op,t,e) \
275         mdb_index_entry((op),(t),SLAP_INDEX_DELETE_OP,(e))
276
277 /*
278  * key.c
279  */
280
281 extern int
282 mdb_key_read(
283     Backend     *be,
284         MDB_txn *txn,
285         MDB_dbi dbi,
286     struct berval *k,
287         ID *ids,
288     MDB_cursor **saved_cursor,
289         int get_flags );
290
291 /*
292  * nextid.c
293  */
294
295 int mdb_next_id( BackendDB *be, MDB_txn *tid, ID *id );
296
297 /*
298  * modify.c
299  */
300
301 int mdb_modify_internal(
302         Operation *op,
303         MDB_txn *tid,
304         Modifications *modlist,
305         Entry *e,
306         const char **text,
307         char *textbuf,
308         size_t textlen );
309
310 /*
311  * monitor.c
312  */
313
314 int mdb_monitor_db_init( BackendDB *be );
315 int mdb_monitor_db_open( BackendDB *be );
316 int mdb_monitor_db_close( BackendDB *be );
317 int mdb_monitor_db_destroy( BackendDB *be );
318
319 #ifdef MDB_MONITOR_IDX
320 int
321 mdb_monitor_idx_add(
322         struct mdb_info         *mdb,
323         AttributeDescription    *desc,
324         slap_mask_t             type );
325 #endif /* MDB_MONITOR_IDX */
326
327 /*
328  * former external.h
329  */
330
331 extern BI_init                          mdb_back_initialize;
332
333 extern BI_db_config                     mdb_db_config;
334
335 extern BI_op_add                        mdb_add;
336 extern BI_op_bind                       mdb_bind;
337 extern BI_op_compare                    mdb_compare;
338 extern BI_op_delete                     mdb_delete;
339 extern BI_op_modify                     mdb_modify;
340 extern BI_op_modrdn                     mdb_modrdn;
341 extern BI_op_search                     mdb_search;
342 extern BI_op_extended                   mdb_extended;
343
344 extern BI_chk_referrals                 mdb_referrals;
345
346 extern BI_operational                   mdb_operational;
347
348 extern BI_has_subordinates              mdb_hasSubordinates;
349
350 /* tools.c */
351 extern BI_tool_entry_open               mdb_tool_entry_open;
352 extern BI_tool_entry_close              mdb_tool_entry_close;
353 extern BI_tool_entry_first_x            mdb_tool_entry_first_x;
354 extern BI_tool_entry_next               mdb_tool_entry_next;
355 extern BI_tool_entry_get                mdb_tool_entry_get;
356 extern BI_tool_entry_put                mdb_tool_entry_put;
357 extern BI_tool_entry_reindex            mdb_tool_entry_reindex;
358 extern BI_tool_dn2id_get                mdb_tool_dn2id_get;
359 extern BI_tool_entry_modify             mdb_tool_entry_modify;
360
361 LDAP_END_DECL
362
363 #endif /* _PROTO_MDB_H */