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