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