Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / openldap / dist / servers / slapd / back-bdb / proto-bdb.h
blobad3d03588c9208e5935a0579d35f2971e2cdf3c7
1 /* $OpenLDAP: pkg/ldap/servers/slapd/back-bdb/proto-bdb.h,v 1.137.2.9 2008/02/12 00:34:58 quanah Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2000-2008 The OpenLDAP Foundation.
5 * All rights reserved.
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.
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>.
16 #ifndef _PROTO_BDB_H
17 #define _PROTO_BDB_H
19 LDAP_BEGIN_DECL
21 #ifdef BDB_HIER
22 #define BDB_SYMBOL(x) LDAP_CONCAT(hdb_,x)
23 #define BDB_UCTYPE "HDB"
24 #else
25 #define BDB_SYMBOL(x) LDAP_CONCAT(bdb_,x)
26 #define BDB_UCTYPE "BDB"
27 #endif
30 * attr.c
33 #define bdb_attr_mask BDB_SYMBOL(attr_mask)
34 #define bdb_attr_flush BDB_SYMBOL(attr_flush)
35 #define bdb_attr_slot BDB_SYMBOL(attr_slot)
36 #define bdb_attr_index_config BDB_SYMBOL(attr_index_config)
37 #define bdb_attr_index_destroy BDB_SYMBOL(attr_index_destroy)
38 #define bdb_attr_index_free BDB_SYMBOL(attr_index_free)
39 #define bdb_attr_index_unparse BDB_SYMBOL(attr_index_unparse)
40 #define bdb_attr_info_free BDB_SYMBOL(attr_info_free)
42 AttrInfo *bdb_attr_mask( struct bdb_info *bdb,
43 AttributeDescription *desc );
45 void bdb_attr_flush( struct bdb_info *bdb );
47 int bdb_attr_slot( struct bdb_info *bdb,
48 AttributeDescription *desc, unsigned *insert );
50 int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb,
51 const char *fname, int lineno,
52 int argc, char **argv ));
54 void bdb_attr_index_unparse LDAP_P(( struct bdb_info *bdb, BerVarray *bva ));
55 void bdb_attr_index_destroy LDAP_P(( struct bdb_info *bdb ));
56 void bdb_attr_index_free LDAP_P(( struct bdb_info *bdb,
57 AttributeDescription *ad ));
59 void bdb_attr_info_free( AttrInfo *ai );
62 * config.c
65 #define bdb_back_init_cf BDB_SYMBOL(back_init_cf)
67 int bdb_back_init_cf( BackendInfo *bi );
70 * dbcache.c
72 #define bdb_db_cache BDB_SYMBOL(db_cache)
74 int
75 bdb_db_cache(
76 Backend *be,
77 struct berval *name,
78 DB **db );
81 * dn2entry.c
83 #define bdb_dn2entry BDB_SYMBOL(dn2entry)
85 int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
86 struct berval *dn, EntryInfo **e, int matched,
87 BDB_LOCKER locker, DB_LOCK *lock ));
90 * dn2id.c
92 #define bdb_dn2id BDB_SYMBOL(dn2id)
93 #define bdb_dn2id_add BDB_SYMBOL(dn2id_add)
94 #define bdb_dn2id_delete BDB_SYMBOL(dn2id_delete)
95 #define bdb_dn2id_children BDB_SYMBOL(dn2id_children)
96 #define bdb_dn2idl BDB_SYMBOL(dn2idl)
98 int bdb_dn2id(
99 Operation *op,
100 struct berval *dn,
101 EntryInfo *ei,
102 BDB_LOCKER locker,
103 DB_LOCK *lock );
105 int bdb_dn2id_add(
106 Operation *op,
107 DB_TXN *tid,
108 EntryInfo *eip,
109 Entry *e );
111 int bdb_dn2id_delete(
112 Operation *op,
113 DB_TXN *tid,
114 EntryInfo *eip,
115 Entry *e );
117 int bdb_dn2id_children(
118 Operation *op,
119 DB_TXN *tid,
120 Entry *e );
122 int bdb_dn2idl(
123 Operation *op,
124 BDB_LOCKER locker,
125 struct berval *ndn,
126 EntryInfo *ei,
127 ID *ids,
128 ID *stack );
130 #ifdef BDB_HIER
131 #define bdb_dn2id_parent BDB_SYMBOL(dn2id_parent)
132 #define bdb_dup_compare BDB_SYMBOL(dup_compare)
133 #define bdb_fix_dn BDB_SYMBOL(fix_dn)
135 int bdb_dn2id_parent(
136 Operation *op,
137 BDB_LOCKER locker,
138 EntryInfo *ei,
139 ID *idp );
141 int bdb_dup_compare(
142 DB *db,
143 const DBT *usrkey,
144 const DBT *curkey );
146 int bdb_fix_dn( Entry *e, int checkit );
147 #endif
151 * error.c
153 #define bdb_errcall BDB_SYMBOL(errcall)
155 #if DB_VERSION_FULL < 0x04030000
156 void bdb_errcall( const char *pfx, char * msg );
157 #else
158 #define bdb_msgcall BDB_SYMBOL(msgcall)
159 void bdb_errcall( const DB_ENV *env, const char *pfx, const char * msg );
160 void bdb_msgcall( const DB_ENV *env, const char * msg );
161 #endif
163 #ifdef HAVE_EBCDIC
164 #define ebcdic_dberror BDB_SYMBOL(ebcdic_dberror)
166 char *ebcdic_dberror( int rc );
167 #define db_strerror(x) ebcdic_dberror(x)
168 #endif
171 * filterentry.c
173 #define bdb_filter_candidates BDB_SYMBOL(filter_candidates)
175 int bdb_filter_candidates(
176 Operation *op,
177 BDB_LOCKER locker,
178 Filter *f,
179 ID *ids,
180 ID *tmp,
181 ID *stack );
184 * id2entry.c
186 #define bdb_id2entry BDB_SYMBOL(id2entry)
187 #define bdb_id2entry_add BDB_SYMBOL(id2entry_add)
188 #define bdb_id2entry_update BDB_SYMBOL(id2entry_update)
189 #define bdb_id2entry_delete BDB_SYMBOL(id2entry_delete)
191 int bdb_id2entry_add(
192 BackendDB *be,
193 DB_TXN *tid,
194 Entry *e );
196 int bdb_id2entry_update(
197 BackendDB *be,
198 DB_TXN *tid,
199 Entry *e );
201 int bdb_id2entry_delete(
202 BackendDB *be,
203 DB_TXN *tid,
204 Entry *e);
206 #ifdef SLAP_ZONE_ALLOC
207 #else
208 int bdb_id2entry(
209 BackendDB *be,
210 DB_TXN *tid,
211 BDB_LOCKER locker,
212 ID id,
213 Entry **e);
214 #endif
216 #define bdb_entry_free BDB_SYMBOL(entry_free)
217 #define bdb_entry_return BDB_SYMBOL(entry_return)
218 #define bdb_entry_release BDB_SYMBOL(entry_release)
219 #define bdb_entry_get BDB_SYMBOL(entry_get)
221 void bdb_entry_free ( Entry *e );
222 #ifdef SLAP_ZONE_ALLOC
223 int bdb_entry_return( struct bdb_info *bdb, Entry *e, int seqno );
224 #else
225 int bdb_entry_return( Entry *e );
226 #endif
227 BI_entry_release_rw bdb_entry_release;
228 BI_entry_get_rw bdb_entry_get;
232 * idl.c
235 #define bdb_idl_cache_get BDB_SYMBOL(idl_cache_get)
236 #define bdb_idl_cache_put BDB_SYMBOL(idl_cache_put)
237 #define bdb_idl_cache_del BDB_SYMBOL(idl_cache_del)
238 #define bdb_idl_cache_add_id BDB_SYMBOL(idl_cache_add_id)
239 #define bdb_idl_cache_del_id BDB_SYMBOL(idl_cache_del_id)
241 int bdb_idl_cache_get(
242 struct bdb_info *bdb,
243 DB *db,
244 DBT *key,
245 ID *ids );
247 void
248 bdb_idl_cache_put(
249 struct bdb_info *bdb,
250 DB *db,
251 DBT *key,
252 ID *ids,
253 int rc );
255 void
256 bdb_idl_cache_del(
257 struct bdb_info *bdb,
258 DB *db,
259 DBT *key );
261 void
262 bdb_idl_cache_add_id(
263 struct bdb_info *bdb,
264 DB *db,
265 DBT *key,
266 ID id );
268 void
269 bdb_idl_cache_del_id(
270 struct bdb_info *bdb,
271 DB *db,
272 DBT *key,
273 ID id );
275 #define bdb_idl_first BDB_SYMBOL(idl_first)
276 #define bdb_idl_next BDB_SYMBOL(idl_next)
277 #define bdb_idl_search BDB_SYMBOL(idl_search)
278 #define bdb_idl_insert BDB_SYMBOL(idl_insert)
279 #define bdb_idl_intersection BDB_SYMBOL(idl_intersection)
280 #define bdb_idl_union BDB_SYMBOL(idl_union)
281 #define bdb_idl_sort BDB_SYMBOL(idl_sort)
282 #define bdb_idl_append BDB_SYMBOL(idl_append)
283 #define bdb_idl_append_one BDB_SYMBOL(idl_append_one)
285 #define bdb_idl_fetch_key BDB_SYMBOL(idl_fetch_key)
286 #define bdb_idl_insert_key BDB_SYMBOL(idl_insert_key)
287 #define bdb_idl_delete_key BDB_SYMBOL(idl_delete_key)
289 unsigned bdb_idl_search( ID *ids, ID id );
291 int bdb_idl_fetch_key(
292 BackendDB *be,
293 DB *db,
294 BDB_LOCKER locker,
295 DBT *key,
296 ID *ids,
297 DBC **saved_cursor,
298 int get_flag );
300 int bdb_idl_insert( ID *ids, ID id );
302 int bdb_idl_insert_key(
303 BackendDB *be,
304 DB *db,
305 DB_TXN *txn,
306 DBT *key,
307 ID id );
309 int bdb_idl_delete_key(
310 BackendDB *be,
311 DB *db,
312 DB_TXN *txn,
313 DBT *key,
314 ID id );
317 bdb_idl_intersection(
318 ID *a,
319 ID *b );
322 bdb_idl_union(
323 ID *a,
324 ID *b );
326 ID bdb_idl_first( ID *ids, ID *cursor );
327 ID bdb_idl_next( ID *ids, ID *cursor );
329 void bdb_idl_sort( ID *ids, ID *tmp );
330 int bdb_idl_append( ID *a, ID *b );
331 int bdb_idl_append_one( ID *ids, ID id );
335 * index.c
337 #define bdb_index_mask BDB_SYMBOL(index_mask)
338 #define bdb_index_param BDB_SYMBOL(index_param)
339 #define bdb_index_values BDB_SYMBOL(index_values)
340 #define bdb_index_entry BDB_SYMBOL(index_entry)
341 #define bdb_index_recset BDB_SYMBOL(index_recset)
342 #define bdb_index_recrun BDB_SYMBOL(index_recrun)
344 extern AttrInfo *
345 bdb_index_mask LDAP_P((
346 Backend *be,
347 AttributeDescription *desc,
348 struct berval *name ));
350 extern int
351 bdb_index_param LDAP_P((
352 Backend *be,
353 AttributeDescription *desc,
354 int ftype,
355 DB **db,
356 slap_mask_t *mask,
357 struct berval *prefix ));
359 extern int
360 bdb_index_values LDAP_P((
361 Operation *op,
362 DB_TXN *txn,
363 AttributeDescription *desc,
364 BerVarray vals,
365 ID id,
366 int opid ));
368 extern int
369 bdb_index_recset LDAP_P((
370 struct bdb_info *bdb,
371 Attribute *a,
372 AttributeType *type,
373 struct berval *tags,
374 IndexRec *ir ));
376 extern int
377 bdb_index_recrun LDAP_P((
378 Operation *op,
379 struct bdb_info *bdb,
380 IndexRec *ir,
381 ID id,
382 int base ));
384 int bdb_index_entry LDAP_P(( Operation *op, DB_TXN *t, int r, Entry *e ));
386 #define bdb_index_entry_add(op,t,e) \
387 bdb_index_entry((op),(t),SLAP_INDEX_ADD_OP,(e))
388 #define bdb_index_entry_del(op,t,e) \
389 bdb_index_entry((op),(t),SLAP_INDEX_DELETE_OP,(e))
392 * key.c
394 #define bdb_key_read BDB_SYMBOL(key_read)
395 #define bdb_key_change BDB_SYMBOL(key_change)
397 extern int
398 bdb_key_read(
399 Backend *be,
400 DB *db,
401 BDB_LOCKER locker,
402 struct berval *k,
403 ID *ids,
404 DBC **saved_cursor,
405 int get_flags );
407 extern int
408 bdb_key_change(
409 Backend *be,
410 DB *db,
411 DB_TXN *txn,
412 struct berval *k,
413 ID id,
414 int op );
417 * nextid.c
419 #define bdb_next_id BDB_SYMBOL(next_id)
420 #define bdb_last_id BDB_SYMBOL(last_id)
422 int bdb_next_id( BackendDB *be, ID *id );
423 int bdb_last_id( BackendDB *be, DB_TXN *tid );
426 * modify.c
428 #define bdb_modify_internal BDB_SYMBOL(modify_internal)
430 int bdb_modify_internal(
431 Operation *op,
432 DB_TXN *tid,
433 Modifications *modlist,
434 Entry *e,
435 const char **text,
436 char *textbuf,
437 size_t textlen );
440 * monitor.c
443 #define bdb_monitor_db_init BDB_SYMBOL(monitor_db_init)
444 #define bdb_monitor_db_open BDB_SYMBOL(monitor_db_open)
445 #define bdb_monitor_db_close BDB_SYMBOL(monitor_db_close)
446 #define bdb_monitor_db_destroy BDB_SYMBOL(monitor_db_destroy)
448 int bdb_monitor_db_init( BackendDB *be );
449 int bdb_monitor_db_open( BackendDB *be );
450 int bdb_monitor_db_close( BackendDB *be );
451 int bdb_monitor_db_destroy( BackendDB *be );
453 #ifdef BDB_MONITOR_IDX
454 #define bdb_monitor_idx_add BDB_SYMBOL(monitor_idx_add)
456 bdb_monitor_idx_add(
457 struct bdb_info *bdb,
458 AttributeDescription *desc,
459 slap_mask_t type );
460 #endif /* BDB_MONITOR_IDX */
463 * cache.c
465 #define bdb_cache_entry_db_unlock BDB_SYMBOL(cache_entry_db_unlock)
466 #define bdb_cache_return_entry_rw BDB_SYMBOL(cache_return_entry_rw)
468 #define bdb_cache_entryinfo_lock(e) \
469 ldap_pvt_thread_mutex_lock( &(e)->bei_kids_mutex )
470 #define bdb_cache_entryinfo_unlock(e) \
471 ldap_pvt_thread_mutex_unlock( &(e)->bei_kids_mutex )
472 #define bdb_cache_entryinfo_trylock(e) \
473 ldap_pvt_thread_mutex_trylock( &(e)->bei_kids_mutex )
475 /* What a mess. Hopefully the current cache scheme will stabilize
476 * and we can trim out all of this stuff.
478 void bdb_cache_return_entry_rw( struct bdb_info *bdb, Entry *e,
479 int rw, DB_LOCK *lock );
480 #define bdb_cache_return_entry_r(bdb, e, l) \
481 bdb_cache_return_entry_rw((bdb), (e), 0, (l))
482 #define bdb_cache_return_entry_w(bdb, e, l) \
483 bdb_cache_return_entry_rw((bdb), (e), 1, (l))
484 #if 0
485 void bdb_unlocked_cache_return_entry_rw( struct bdb_info *bdb, Entry *e, int rw );
486 #else
487 #define bdb_unlocked_cache_return_entry_rw( a, b, c ) ((void)0)
488 #endif
489 #define bdb_unlocked_cache_return_entry_r( c, e ) \
490 bdb_unlocked_cache_return_entry_rw((c), (e), 0)
491 #define bdb_unlocked_cache_return_entry_w( c, e ) \
492 bdb_unlocked_cache_return_entry_rw((c), (e), 1)
494 #define bdb_cache_add BDB_SYMBOL(cache_add)
495 #define bdb_cache_children BDB_SYMBOL(cache_children)
496 #define bdb_cache_delete BDB_SYMBOL(cache_delete)
497 #define bdb_cache_delete_cleanup BDB_SYMBOL(cache_delete_cleanup)
498 #define bdb_cache_find_id BDB_SYMBOL(cache_find_id)
499 #define bdb_cache_find_info BDB_SYMBOL(cache_find_info)
500 #define bdb_cache_find_ndn BDB_SYMBOL(cache_find_ndn)
501 #define bdb_cache_find_parent BDB_SYMBOL(cache_find_parent)
502 #define bdb_cache_modify BDB_SYMBOL(cache_modify)
503 #define bdb_cache_modrdn BDB_SYMBOL(cache_modrdn)
504 #define bdb_cache_release_all BDB_SYMBOL(cache_release_all)
505 #define bdb_cache_delete_entry BDB_SYMBOL(cache_delete_entry)
507 int bdb_cache_children(
508 Operation *op,
509 DB_TXN *txn,
510 Entry *e
512 int bdb_cache_add(
513 struct bdb_info *bdb,
514 EntryInfo *pei,
515 Entry *e,
516 struct berval *nrdn,
517 BDB_LOCKER locker,
518 DB_LOCK *lock
520 int bdb_cache_modrdn(
521 struct bdb_info *bdb,
522 Entry *e,
523 struct berval *nrdn,
524 Entry *new,
525 EntryInfo *ein,
526 BDB_LOCKER locker,
527 DB_LOCK *lock
529 int bdb_cache_modify(
530 struct bdb_info *bdb,
531 Entry *e,
532 Attribute *newAttrs,
533 BDB_LOCKER locker,
534 DB_LOCK *lock
536 int bdb_cache_find_ndn(
537 Operation *op,
538 BDB_LOCKER locker,
539 struct berval *ndn,
540 EntryInfo **res
542 EntryInfo * bdb_cache_find_info(
543 struct bdb_info *bdb,
544 ID id
547 #define ID_LOCKED 1
548 #define ID_NOCACHE 2
549 int bdb_cache_find_id(
550 Operation *op,
551 DB_TXN *tid,
552 ID id,
553 EntryInfo **eip,
554 int flag,
555 BDB_LOCKER locker,
556 DB_LOCK *lock
559 bdb_cache_find_parent(
560 Operation *op,
561 BDB_LOCKER locker,
562 ID id,
563 EntryInfo **res
565 int bdb_cache_delete(
566 struct bdb_info *bdb,
567 Entry *e,
568 BDB_LOCKER locker,
569 DB_LOCK *lock
571 void bdb_cache_delete_cleanup(
572 Cache *cache,
573 EntryInfo *ei
575 void bdb_cache_release_all( Cache *cache );
577 #ifdef BDB_HIER
578 int hdb_cache_load(
579 struct bdb_info *bdb,
580 EntryInfo *ei,
581 EntryInfo **res
583 #endif
585 #define bdb_cache_entry_db_relock BDB_SYMBOL(cache_entry_db_relock)
586 int bdb_cache_entry_db_relock(
587 struct bdb_info *bdb,
588 BDB_LOCKER locker,
589 EntryInfo *ei,
590 int rw,
591 int tryOnly,
592 DB_LOCK *lock );
594 int bdb_cache_entry_db_unlock(
595 struct bdb_info *bdb,
596 DB_LOCK *lock );
598 #ifdef BDB_REUSE_LOCKERS
600 #define bdb_locker_id BDB_SYMBOL(locker_id)
601 #define bdb_locker_flush BDB_SYMBOL(locker_flush)
602 int bdb_locker_id( Operation *op, DB_ENV *env, BDB_LOCKER *locker );
603 void bdb_locker_flush( DB_ENV *env );
605 #define LOCK_ID_FREE(env, locker) ((void)0)
606 #define LOCK_ID(env, locker) bdb_locker_id(op, env, locker)
608 #else
610 #define LOCK_ID_FREE(env, locker) XLOCK_ID_FREE(env, locker)
611 #define LOCK_ID(env, locker) XLOCK_ID(env, locker)
613 #endif
616 * trans.c
618 #define bdb_trans_backoff BDB_SYMBOL(trans_backoff)
620 void
621 bdb_trans_backoff( int num_retries );
624 * former external.h
627 #define bdb_back_initialize BDB_SYMBOL(back_initialize)
628 #define bdb_db_config BDB_SYMBOL(db_config)
629 #define bdb_add BDB_SYMBOL(add)
630 #define bdb_bind BDB_SYMBOL(bind)
631 #define bdb_compare BDB_SYMBOL(compare)
632 #define bdb_delete BDB_SYMBOL(delete)
633 #define bdb_modify BDB_SYMBOL(modify)
634 #define bdb_modrdn BDB_SYMBOL(modrdn)
635 #define bdb_search BDB_SYMBOL(search)
636 #define bdb_extended BDB_SYMBOL(extended)
637 #define bdb_referrals BDB_SYMBOL(referrals)
638 #define bdb_operational BDB_SYMBOL(operational)
639 #define bdb_hasSubordinates BDB_SYMBOL(hasSubordinates)
640 #define bdb_tool_entry_open BDB_SYMBOL(tool_entry_open)
641 #define bdb_tool_entry_close BDB_SYMBOL(tool_entry_close)
642 #define bdb_tool_entry_next BDB_SYMBOL(tool_entry_next)
643 #define bdb_tool_entry_get BDB_SYMBOL(tool_entry_get)
644 #define bdb_tool_entry_put BDB_SYMBOL(tool_entry_put)
645 #define bdb_tool_entry_reindex BDB_SYMBOL(tool_entry_reindex)
646 #define bdb_tool_dn2id_get BDB_SYMBOL(tool_dn2id_get)
647 #define bdb_tool_entry_modify BDB_SYMBOL(tool_entry_modify)
648 #define bdb_tool_idl_add BDB_SYMBOL(tool_idl_add)
650 extern BI_init bdb_back_initialize;
652 extern BI_db_config bdb_db_config;
654 extern BI_op_add bdb_add;
655 extern BI_op_bind bdb_bind;
656 extern BI_op_compare bdb_compare;
657 extern BI_op_delete bdb_delete;
658 extern BI_op_modify bdb_modify;
659 extern BI_op_modrdn bdb_modrdn;
660 extern BI_op_search bdb_search;
661 extern BI_op_extended bdb_extended;
663 extern BI_chk_referrals bdb_referrals;
665 extern BI_operational bdb_operational;
667 extern BI_has_subordinates bdb_hasSubordinates;
669 /* tools.c */
670 extern BI_tool_entry_open bdb_tool_entry_open;
671 extern BI_tool_entry_close bdb_tool_entry_close;
672 extern BI_tool_entry_next bdb_tool_entry_next;
673 extern BI_tool_entry_get bdb_tool_entry_get;
674 extern BI_tool_entry_put bdb_tool_entry_put;
675 extern BI_tool_entry_reindex bdb_tool_entry_reindex;
676 extern BI_tool_dn2id_get bdb_tool_dn2id_get;
677 extern BI_tool_entry_modify bdb_tool_entry_modify;
679 int bdb_tool_idl_add( BackendDB *be, DB *db, DB_TXN *txn, DBT *key, ID id );
681 LDAP_END_DECL
683 #endif /* _PROTO_BDB_H */