]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/proto-bdb.h
Cleanup verb/mask processing
[openldap] / servers / slapd / back-bdb / proto-bdb.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2000-2005 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_BDB_H
17 #define _PROTO_BDB_H
18
19 LDAP_BEGIN_DECL
20
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
28
29 /*
30  * attr.c
31  */
32
33 #define bdb_attr_mask                           BDB_SYMBOL(attr_mask)
34 #define bdb_attr_index_config           BDB_SYMBOL(attr_index_config)
35 #define bdb_attr_index_destroy          BDB_SYMBOL(attr_index_destroy)
36
37 #ifdef LDAP_COMP_MATCH
38 #define bdb_attr_comp_ref                       BDB_SYMBOL(attr_comp_ref)
39 #define bdb_attr_mask_cr                        BDB_SYMBOL(attr_mask_cr)
40 void bdb_attr_comp_ref( struct bdb_info *bdb,
41         AttributeDescription *desc,
42         ComponentReference **cr );
43 void bdb_attr_mask_cr( struct bdb_info *bdb,
44         AttributeDescription *desc,
45         slap_mask_t *indexmask,
46         ComponentReference **cr );
47 #endif
48
49 void bdb_attr_mask( struct bdb_info *bdb,
50         AttributeDescription *desc,
51         slap_mask_t *indexmask );
52
53 int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb,
54         const char *fname, int lineno,
55         int argc, char **argv ));
56
57 void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
58
59 /*
60  * config.c
61  */
62
63 #define bdb_back_init_cf                                BDB_SYMBOL(back_init_cf)
64
65 int bdb_back_init_cf( BackendInfo *bi );
66
67 /*
68  * dbcache.c
69  */
70 #define bdb_db_cache                            BDB_SYMBOL(db_cache)
71
72 int
73 bdb_db_cache(
74     Backend     *be,
75     const char *name,
76         DB **db );
77
78 /*
79  * dn2entry.c
80  */
81 #define bdb_dn2entry                            BDB_SYMBOL(dn2entry)
82
83 int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
84         struct berval *dn, EntryInfo **e, int matched,
85         u_int32_t locker, DB_LOCK *lock ));
86
87 /*
88  * dn2id.c
89  */
90 #define bdb_dn2id                                       BDB_SYMBOL(dn2id)
91 #define bdb_dn2id_add                           BDB_SYMBOL(dn2id_add)
92 #define bdb_dn2id_delete                        BDB_SYMBOL(dn2id_delete)
93 #define bdb_dn2id_children                      BDB_SYMBOL(dn2id_children)
94 #define bdb_dn2idl                                      BDB_SYMBOL(dn2idl)
95
96 int bdb_dn2id(
97         Operation *op,
98         DB_TXN *tid,
99         struct berval *dn,
100         EntryInfo *ei );
101
102 int bdb_dn2id_add(
103         Operation *op,
104         DB_TXN *tid,
105         EntryInfo *eip,
106         Entry *e );
107
108 int bdb_dn2id_delete(
109         Operation *op,
110         DB_TXN *tid,
111         EntryInfo *eip,
112         Entry *e );
113
114 int bdb_dn2id_children(
115         Operation *op,
116         DB_TXN *tid,
117         Entry *e );
118
119 int bdb_dn2idl(
120         Operation *op,
121         Entry *e,
122         ID *ids,
123         ID *stack );
124
125 #ifdef BDB_HIER
126 #define bdb_dn2id_parent                        BDB_SYMBOL(dn2id_parent)
127 #define bdb_fix_dn                                      BDB_SYMBOL(fix_dn)
128
129 int bdb_dn2id_parent(
130         Operation *op,
131         DB_TXN *txn,
132         EntryInfo *ei,
133         ID *idp );
134
135 int bdb_fix_dn( Entry *e, int checkit );
136 #endif
137
138
139 /*
140  * error.c
141  */
142 #define bdb_errcall                                     BDB_SYMBOL(errcall)
143
144 #if DB_VERSION_FULL < 0x04030000
145 void bdb_errcall( const char *pfx, char * msg );
146 #else
147 void bdb_errcall( const DB_ENV *env, const char *pfx, const char * msg );
148 #endif
149
150 #ifdef HAVE_EBCDIC
151 #define ebcdic_dberror                          BDB_SYMBOL(ebcdic_dberror)
152
153 char *ebcdic_dberror( int rc );
154 #define db_strerror(x)  ebcdic_dberror(x)
155 #endif
156
157 /*
158  * filterentry.c
159  */
160 #define bdb_filter_candidates           BDB_SYMBOL(filter_candidates)
161
162 int bdb_filter_candidates(
163         Operation *op,
164         Filter  *f,
165         ID *ids,
166         ID *tmp,
167         ID *stack );
168
169 /*
170  * id2entry.c
171  */
172 #define bdb_id2entry                            BDB_SYMBOL(id2entry)
173 #define bdb_id2entry_add                        BDB_SYMBOL(id2entry_add)
174 #define bdb_id2entry_update                     BDB_SYMBOL(id2entry_update)
175 #define bdb_id2entry_delete                     BDB_SYMBOL(id2entry_delete)
176
177 int bdb_id2entry_add(
178         BackendDB *be,
179         DB_TXN *tid,
180         Entry *e );
181
182 int bdb_id2entry_update(
183         BackendDB *be,
184         DB_TXN *tid,
185         Entry *e );
186
187 int bdb_id2entry_delete(
188         BackendDB *be,
189         DB_TXN *tid,
190         Entry *e);
191
192 #ifdef SLAP_ZONE_ALLOC
193 #else
194 int bdb_id2entry(
195         BackendDB *be,
196         DB_TXN *tid,
197         ID id,
198         Entry **e);
199 #endif
200
201 #define bdb_entry_free                          BDB_SYMBOL(entry_free)
202 #define bdb_entry_return                        BDB_SYMBOL(entry_return)
203 #define bdb_entry_release                       BDB_SYMBOL(entry_release)
204 #define bdb_entry_get                           BDB_SYMBOL(entry_get)
205
206 void bdb_entry_free ( Entry *e );
207 #ifdef SLAP_ZONE_ALLOC
208 int bdb_entry_return( struct bdb_info *bdb, Entry *e, int seqno );
209 #else
210 int bdb_entry_return( Entry *e );
211 #endif
212 BI_entry_release_rw bdb_entry_release;
213 BI_entry_get_rw bdb_entry_get;
214
215
216 /*
217  * idl.c
218  */
219
220 #define bdb_idl_cache_get                       BDB_SYMBOL(idl_cache_get)
221 #define bdb_idl_cache_put                       BDB_SYMBOL(idl_cache_put)
222 #define bdb_idl_cache_del                       BDB_SYMBOL(idl_cache_del)
223
224 int bdb_idl_cache_get(
225         struct bdb_info *bdb,
226         DB *db,
227         DBT *key,
228         ID *ids );
229
230 void
231 bdb_idl_cache_put(
232         struct bdb_info *bdb,
233         DB              *db,
234         DBT             *key,
235         ID              *ids,
236         int             rc );
237
238 void
239 bdb_idl_cache_del(
240         struct bdb_info *bdb,
241         DB              *db,
242         DBT             *key );
243
244 #define bdb_idl_first                           BDB_SYMBOL(idl_first)
245 #define bdb_idl_next                            BDB_SYMBOL(idl_next)
246 #define bdb_idl_search                          BDB_SYMBOL(idl_search)
247 #define bdb_idl_insert                          BDB_SYMBOL(idl_insert)
248 #define bdb_idl_intersection            BDB_SYMBOL(idl_intersection)
249 #define bdb_idl_union                           BDB_SYMBOL(idl_union)
250
251 #define bdb_idl_fetch_key                       BDB_SYMBOL(idl_fetch_key)
252 #define bdb_idl_insert_key                      BDB_SYMBOL(idl_insert_key)
253 #define bdb_idl_delete_key                      BDB_SYMBOL(idl_delete_key)
254
255 unsigned bdb_idl_search( ID *ids, ID id );
256
257 int bdb_idl_fetch_key(
258         BackendDB       *be,
259         DB                      *db,
260         DB_TXN          *tid,
261         DBT                     *key,
262         ID                      *ids,
263         DBC                     **saved_cursor,
264         int                     get_flag );
265
266 int bdb_idl_insert( ID *ids, ID id );
267
268 int bdb_idl_insert_key(
269         BackendDB *be,
270         DB *db,
271         DB_TXN *txn,
272         DBT *key,
273         ID id );
274
275 int bdb_idl_delete_key(
276         BackendDB *be,
277         DB *db,
278         DB_TXN *txn,
279         DBT *key,
280         ID id );
281
282 int
283 bdb_idl_intersection(
284         ID *a,
285         ID *b );
286
287 int
288 bdb_idl_union(
289         ID *a,
290         ID *b );
291
292 ID bdb_idl_first( ID *ids, ID *cursor );
293 ID bdb_idl_next( ID *ids, ID *cursor );
294
295
296
297 /*
298  * index.c
299  */
300 #define bdb_index_is_indexed            BDB_SYMBOL(index_is_indexed)
301 #define bdb_index_param                         BDB_SYMBOL(index_param)
302 #define bdb_index_values                        BDB_SYMBOL(index_values)
303 #define bdb_index_entry                         BDB_SYMBOL(index_entry)
304
305 extern int
306 bdb_index_is_indexed LDAP_P((
307         Backend *be,
308         AttributeDescription *desc ));
309
310 extern int
311 bdb_index_param LDAP_P((
312         Backend *be,
313         AttributeDescription *desc,
314         int ftype,
315         DB **db,
316         slap_mask_t *mask,
317         struct berval *prefix ));
318
319 extern int
320 bdb_index_values LDAP_P((
321         Operation *op,
322         DB_TXN *txn,
323         AttributeDescription *desc,
324         BerVarray vals,
325         ID id,
326         int opid ));
327
328 int bdb_index_entry LDAP_P(( Operation *op, DB_TXN *t, int r, Entry *e ));
329
330 #define bdb_index_entry_add(op,t,e) \
331         bdb_index_entry((op),(t),SLAP_INDEX_ADD_OP,(e))
332 #define bdb_index_entry_del(op,t,e) \
333         bdb_index_entry((op),(t),SLAP_INDEX_DELETE_OP,(e))
334
335 /*
336  * key.c
337  */
338 #define bdb_key_read                            BDB_SYMBOL(key_read)
339 #define bdb_key_change                          BDB_SYMBOL(key_change)
340
341 extern int
342 bdb_key_read(
343     Backend     *be,
344         DB *db,
345         DB_TXN *txn,
346     struct berval *k,
347         ID *ids,
348     DBC **saved_cursor,
349         int get_flags );
350
351 extern int
352 bdb_key_change(
353     Backend      *be,
354     DB *db,
355         DB_TXN *txn,
356     struct berval *k,
357     ID id,
358     int op );
359         
360 /*
361  * nextid.c
362  */
363 #define bdb_next_id                                     BDB_SYMBOL(next_id)
364 #define bdb_last_id                                     BDB_SYMBOL(last_id)
365
366 int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *id );
367 int bdb_last_id( BackendDB *be, DB_TXN *tid );
368
369 /*
370  * modify.c
371  */
372 #define bdb_modify_internal                     BDB_SYMBOL(modify_internal)
373
374 int bdb_modify_internal(
375         Operation *op,
376         DB_TXN *tid,
377         Modifications *modlist,
378         Entry *e,
379         const char **text,
380         char *textbuf,
381         size_t textlen );
382
383
384 /*
385  * cache.c
386  */
387 #define bdb_cache_entry_db_unlock       BDB_SYMBOL(cache_entry_db_unlock)
388
389 #define bdb_cache_entryinfo_lock(e) \
390         ldap_pvt_thread_mutex_lock( &(e)->bei_kids_mutex )
391 #define bdb_cache_entryinfo_unlock(e) \
392         ldap_pvt_thread_mutex_unlock( &(e)->bei_kids_mutex )
393
394 /* What a mess. Hopefully the current cache scheme will stabilize
395  * and we can trim out all of this stuff.
396  */
397 #if 0
398 void bdb_cache_return_entry_rw( DB_ENV *env, Cache *cache, Entry *e,
399         int rw, DB_LOCK *lock );
400 #else
401 #define bdb_cache_return_entry_rw( env, cache, e, rw, lock ) \
402         bdb_cache_entry_db_unlock( env, lock )
403 #define bdb_cache_return_entry( env, lock ) \
404         bdb_cache_entry_db_unlock( env, lock )
405 #endif
406 #define bdb_cache_return_entry_r(env, c, e, l) \
407         bdb_cache_return_entry_rw((env), (c), (e), 0, (l))
408 #define bdb_cache_return_entry_w(env, c, e, l) \
409         bdb_cache_return_entry_rw((env), (c), (e), 1, (l))
410 #if 0
411 void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw );
412 #else
413 #define bdb_unlocked_cache_return_entry_rw( a, b, c )
414 #endif
415 #define bdb_unlocked_cache_return_entry_r( c, e ) \
416         bdb_unlocked_cache_return_entry_rw((c), (e), 0)
417 #define bdb_unlocked_cache_return_entry_w( c, e ) \
418         bdb_unlocked_cache_return_entry_rw((c), (e), 1)
419
420 #define bdb_cache_add                           BDB_SYMBOL(cache_add)
421 #define bdb_cache_children                      BDB_SYMBOL(cache_children)
422 #define bdb_cache_delete                        BDB_SYMBOL(cache_delete)
423 #define bdb_cache_delete_cleanup        BDB_SYMBOL(cache_delete_cleanup)
424 #define bdb_cache_find_id                       BDB_SYMBOL(cache_find_id)
425 #define bdb_cache_find_info                     BDB_SYMBOL(cache_find_info)
426 #define bdb_cache_find_ndn                      BDB_SYMBOL(cache_find_ndn)
427 #define bdb_cache_modify                        BDB_SYMBOL(cache_modify)
428 #define bdb_cache_modrdn                        BDB_SYMBOL(cache_modrdn)
429 #define bdb_cache_release_all           BDB_SYMBOL(cache_release_all)
430 #define bdb_cache_delete_entry          BDB_SYMBOL(cache_delete_entry)
431
432 int bdb_cache_children(
433         Operation *op,
434         DB_TXN *txn,
435         Entry *e
436 );
437 int bdb_cache_add(
438         struct bdb_info *bdb,
439         EntryInfo *pei,
440         Entry   *e,
441         struct berval *nrdn,
442         u_int32_t locker
443 );
444 int bdb_cache_modrdn(
445         Entry   *e,
446         struct berval *nrdn,
447         Entry   *new,
448         EntryInfo *ein,
449         DB_ENV *env,
450         u_int32_t locker,
451         DB_LOCK *lock
452 );
453 int bdb_cache_modify(
454         Entry *e,
455         Attribute *newAttrs,
456         DB_ENV *env,
457         u_int32_t locker,
458         DB_LOCK *lock
459 );
460 int bdb_cache_find_ndn(
461         Operation *op,
462         DB_TXN  *txn,
463         struct berval   *ndn,
464         EntryInfo       **res
465 );
466 EntryInfo * bdb_cache_find_info(
467         struct bdb_info *bdb,
468         ID id
469 );
470 int bdb_cache_find_id(
471         Operation *op,
472         DB_TXN  *tid,
473         ID              id,
474         EntryInfo **eip,
475         int     islocked,
476         u_int32_t       locker,
477         DB_LOCK         *lock
478 );
479 int bdb_cache_delete(
480         Cache   *cache,
481         Entry   *e,
482         DB_ENV  *env,
483         u_int32_t locker,
484         DB_LOCK *lock
485 );
486 void bdb_cache_delete_cleanup(
487         Cache   *cache,
488         EntryInfo *ei
489 );
490 void bdb_cache_release_all( Cache *cache );
491 void bdb_cache_delete_entry(
492         struct bdb_info *bdb,
493         EntryInfo *ei,
494         u_int32_t locker,
495         DB_LOCK *lock
496 );
497
498 #ifdef BDB_HIER
499 int hdb_cache_load(
500         struct bdb_info *bdb,
501         EntryInfo *ei,
502         EntryInfo **res
503 );
504 #endif
505
506 #define bdb_cache_entry_db_relock               BDB_SYMBOL(cache_entry_db_relock)
507 int bdb_cache_entry_db_relock(
508         DB_ENV *env,
509         u_int32_t locker,
510         EntryInfo *ei,
511         int rw,
512         int tryOnly,
513         DB_LOCK *lock );
514
515 int bdb_cache_entry_db_unlock(
516         DB_ENV *env,
517         DB_LOCK *lock );
518
519 #ifdef BDB_REUSE_LOCKERS
520
521 #define bdb_locker_id                           BDB_SYMBOL(locker_id)
522 int bdb_locker_id( Operation *op, DB_ENV *env, int *locker );
523
524 #define LOCK_ID_FREE(env, locker)
525 #define LOCK_ID(env, locker)    bdb_locker_id(op, env, locker)
526
527 #else
528
529 #define LOCK_ID_FREE(env, locker)       XLOCK_ID_FREE(env, locker)
530 #define LOCK_ID(env, locker)            XLOCK_ID(env, locker)
531
532 #endif
533
534 /*
535  * trans.c
536  */
537 #define bdb_trans_backoff                       BDB_SYMBOL(trans_backoff)
538
539 void
540 bdb_trans_backoff( int num_retries );
541
542 /*
543  * former external.h
544  */
545
546 #define bdb_back_initialize             BDB_SYMBOL(back_initialize)
547 #define bdb_db_config                   BDB_SYMBOL(db_config)
548 #define bdb_add                         BDB_SYMBOL(add)
549 #define bdb_bind                        BDB_SYMBOL(bind)
550 #define bdb_compare                     BDB_SYMBOL(compare)
551 #define bdb_delete                      BDB_SYMBOL(delete)
552 #define bdb_modify                      BDB_SYMBOL(modify)
553 #define bdb_modrdn                      BDB_SYMBOL(modrdn)
554 #define bdb_search                      BDB_SYMBOL(search)
555 #define bdb_extended                    BDB_SYMBOL(extended)
556 #define bdb_referrals                   BDB_SYMBOL(referrals)
557 #define bdb_operational                 BDB_SYMBOL(operational)
558 #define bdb_hasSubordinates             BDB_SYMBOL(hasSubordinates)
559 #define bdb_tool_entry_open             BDB_SYMBOL(tool_entry_open)
560 #define bdb_tool_entry_close            BDB_SYMBOL(tool_entry_close)
561 #define bdb_tool_entry_next             BDB_SYMBOL(tool_entry_next)
562 #define bdb_tool_entry_get              BDB_SYMBOL(tool_entry_get)
563 #define bdb_tool_entry_put              BDB_SYMBOL(tool_entry_put)
564 #define bdb_tool_entry_reindex          BDB_SYMBOL(tool_entry_reindex)
565 #define bdb_tool_dn2id_get              BDB_SYMBOL(tool_dn2id_get)
566 #define bdb_tool_id2entry_get           BDB_SYMBOL(tool_id2entry_get)
567 #define bdb_tool_entry_modify           BDB_SYMBOL(tool_entry_modify)
568
569 extern BI_init                          bdb_back_initialize;
570
571 extern BI_db_config                     bdb_db_config;
572
573 extern BI_op_add                        bdb_add;
574 extern BI_op_bind                       bdb_bind;
575 extern BI_op_compare                    bdb_compare;
576 extern BI_op_delete                     bdb_delete;
577 extern BI_op_modify                     bdb_modify;
578 extern BI_op_modrdn                     bdb_modrdn;
579 extern BI_op_search                     bdb_search;
580 extern BI_op_extended                   bdb_extended;
581
582 extern BI_chk_referrals                 bdb_referrals;
583
584 extern BI_operational                   bdb_operational;
585
586 extern BI_has_subordinates              bdb_hasSubordinates;
587
588 /* tools.c */
589 extern BI_tool_entry_open               bdb_tool_entry_open;
590 extern BI_tool_entry_close              bdb_tool_entry_close;
591 extern BI_tool_entry_next               bdb_tool_entry_next;
592 extern BI_tool_entry_get                bdb_tool_entry_get;
593 extern BI_tool_entry_put                bdb_tool_entry_put;
594 extern BI_tool_entry_reindex            bdb_tool_entry_reindex;
595 extern BI_tool_dn2id_get                bdb_tool_dn2id_get;
596 extern BI_tool_id2entry_get             bdb_tool_id2entry_get;
597 extern BI_tool_entry_modify             bdb_tool_entry_modify;
598
599 LDAP_END_DECL
600
601 #endif /* _PROTO_BDB_H */