]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/proto-bdb.h
ITS#2449, broken NOT filters
[openldap] / servers / slapd / back-bdb / proto-bdb.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 2000-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #ifndef _PROTO_BDB_H
8 #define _PROTO_BDB_H
9
10 LDAP_BEGIN_DECL
11
12 /*
13  * alias.c
14  */
15 Entry *bdb_deref_internal_r LDAP_P((
16         BackendDB *be,
17         Entry *e,
18         struct berval *dn,
19         int *err,
20         Entry **matched,
21         const char **text ));
22
23 #define deref_entry_r( be, e, err, matched, text ) \
24         bdb_deref_internal_r( be, e, NULL, err, matched, text )
25 #define deref_dn_r( be, dn, err, matched, text ) \
26         bdb_deref_internal_r( be, NULL, dn, err, matched, text)
27
28 /*
29  * attr.c
30  */
31
32 void bdb_attr_mask( struct bdb_info *bdb,
33         AttributeDescription *desc,
34         slap_mask_t *indexmask );
35
36 int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb,
37         const char *fname, int lineno,
38         int argc, char **argv ));
39
40 void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
41
42 /*
43  * dbcache.c
44  */
45 int
46 bdb_db_cache(
47     Backend     *be,
48     DB_TXN *tid,
49     const char *name,
50         DB **db );
51
52 /*
53  * dn2entry.c
54  */
55 int bdb_dn2entry LDAP_P(( BackendDB *be, DB_TXN *tid,
56         struct berval *dn, EntryInfo **e, int matched,
57         u_int32_t locker, DB_LOCK *lock, void *ctx));
58
59 /*
60  * dn2id.c
61  */
62 int bdb_dn2id(
63         BackendDB *be,
64         DB_TXN *tid,
65         struct berval *dn,
66         ID *id,
67         void *ctx );
68
69 int bdb_dn2id_add(
70         BackendDB *be,
71         DB_TXN *tid,
72         struct berval *pdn,
73         Entry *e );
74
75 int bdb_dn2id_delete(
76         BackendDB *be,
77         DB_TXN *tid,
78         char *pdn,
79         Entry *e );
80
81 int bdb_dn2id_children(
82         Operation *op,
83         DB_TXN *tid,
84         Entry *e );
85
86 int
87 bdb_dn2idl(
88         BackendDB       *be,
89         struct berval   *dn,
90         int prefix,
91         ID *ids );
92
93 /*
94  * entry.c
95  */
96 int bdb_entry_return( Entry *e );
97 BI_entry_release_rw bdb_entry_release;
98 BI_entry_get_rw bdb_entry_get;
99
100 /*
101  * error.c
102  */
103 void bdb_errcall( const char *pfx, char * msg );
104
105 /*
106  * filterentry.c
107  */
108 int bdb_filter_candidates(
109         Operation *op,
110         Filter  *f,
111         ID *ids,
112         ID *tmp,
113         ID *stack );
114
115 /*
116  * id2entry.c
117  */
118 int bdb_id2entry_add(
119         BackendDB *be,
120         DB_TXN *tid,
121         Entry *e );
122
123 int bdb_id2entry_update(
124         BackendDB *be,
125         DB_TXN *tid,
126         Entry *e );
127
128 int bdb_id2entry_delete(
129         BackendDB *be,
130         DB_TXN *tid,
131         Entry *e);
132
133 int bdb_id2entry(
134         BackendDB *be,
135         DB_TXN *tid,
136         ID id,
137         Entry **e);
138
139 void bdb_entry_free ( Entry *e );
140
141 /*
142  * idl.c
143  */
144 #ifdef SLAP_IDL_CACHE
145 int bdb_idl_entry_cmp( const void*, const void* );
146 #endif
147
148 unsigned bdb_idl_search( ID *ids, ID id );
149
150 int bdb_bt_compare(
151         DB *db,
152         const DBT *a,
153         const DBT *b );
154
155 int bdb_idl_fetch_key(
156         BackendDB *be,
157         DB *db,
158         DB_TXN *txn,
159         DBT *key,
160         ID *ids );
161
162 int bdb_idl_insert( ID *ids, ID id );
163
164 int bdb_idl_insert_key(
165         BackendDB *be,
166         DB *db,
167         DB_TXN *txn,
168         DBT *key,
169         ID id );
170
171 int bdb_idl_delete_key(
172         BackendDB *be,
173         DB *db,
174         DB_TXN *txn,
175         DBT *key,
176         ID id );
177
178 #if 0
179 int
180 bdb_idl_notin(
181     ID  *a,
182     ID  *b,
183         ID      *ids );
184 #endif
185
186 int
187 bdb_idl_intersection(
188         ID *a,
189         ID *b );
190
191 int
192 bdb_idl_union(
193         ID *a,
194         ID *b );
195
196 ID bdb_idl_first( ID *ids, ID *cursor );
197 ID bdb_idl_next( ID *ids, ID *cursor );
198
199
200 /*
201  * index.c
202  */
203 extern int
204 bdb_index_is_indexed LDAP_P((
205         Backend *be,
206         AttributeDescription *desc ));
207
208 extern int
209 bdb_index_param LDAP_P((
210         Backend *be,
211         AttributeDescription *desc,
212         int ftype,
213         DB **db,
214         slap_mask_t *mask,
215         struct berval *prefix ));
216
217 extern int
218 bdb_index_values LDAP_P((
219         Operation *op,
220         DB_TXN *txn,
221         AttributeDescription *desc,
222         BerVarray vals,
223         ID id,
224         int opid ));
225
226 int bdb_index_entry LDAP_P(( Operation *op, DB_TXN *t, int r, Entry *e ));
227
228 #define bdb_index_entry_add(be,t,e) \
229         bdb_index_entry((be),(t),SLAP_INDEX_ADD_OP,(e))
230 #define bdb_index_entry_del(be,t,e) \
231         bdb_index_entry((be),(t),SLAP_INDEX_DELETE_OP,(e))
232
233 /*
234  * init.c
235  */
236 extern struct berval bdb_uuid;
237
238 /*
239  * key.c
240  */
241 extern int
242 bdb_key_read(
243     Backend     *be,
244         DB *db,
245         DB_TXN *txn,
246     struct berval *k,
247         ID *ids );
248
249 extern int
250 bdb_key_change(
251     Backend      *be,
252     DB *db,
253         DB_TXN *txn,
254     struct berval *k,
255     ID id,
256     int op );
257         
258 /*
259  * nextid.c
260  */
261 int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *id );
262 int bdb_last_id( BackendDB *be, DB_TXN *tid );
263
264 /*
265  * modify.c
266  */
267 int bdb_modify_internal(
268         Operation *op,
269         DB_TXN *tid,
270         Modifications *modlist,
271         Entry *e,
272         const char **text,
273         char *textbuf,
274         size_t textlen );
275
276 /*
277  * passwd.c
278  */
279 BI_op_extended bdb_exop_passwd;
280
281
282 /*
283  * cache.c
284  */
285
286 #define bdb_cache_entryinfo_lock(e) \
287         ldap_pvt_thread_mutex_lock( &(e)->bei_kids_mutex )
288 #define bdb_cache_entryinfo_unlock(e) \
289         ldap_pvt_thread_mutex_unlock( &(e)->bei_kids_mutex )
290
291 #if 0
292 void bdb_cache_return_entry_rw( DB_ENV *env, Cache *cache, Entry *e,
293         int rw, DB_LOCK *lock );
294 #else
295 #define bdb_cache_return_entry_rw( env, cache, e, rw, lock ) \
296         bdb_cache_entry_db_unlock( env, lock )
297 #define bdb_cache_return_entry( env, lock ) \
298         bdb_cache_entry_db_unlock( env, lock )
299 #endif
300 #define bdb_cache_return_entry_r(env, c, e, l) \
301         bdb_cache_return_entry_rw((env), (c), (e), 0, (l))
302 #define bdb_cache_return_entry_w(env, c, e, l) \
303         bdb_cache_return_entry_rw((env), (c), (e), 1, (l))
304 #if 0
305 void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw );
306 #else
307 #define bdb_unlocked_cache_return_entry_rw( a, b, c )
308 #endif
309 #define bdb_unlocked_cache_return_entry_r( c, e ) \
310         bdb_unlocked_cache_return_entry_rw((c), (e), 0)
311 #define bdb_unlocked_cache_return_entry_w( c, e ) \
312         bdb_unlocked_cache_return_entry_rw((c), (e), 1)
313 int bdb_cache_add(
314         struct bdb_info *bdb,
315         EntryInfo *pei,
316         Entry   *e,
317         struct berval *nrdn,
318         u_int32_t locker
319 );
320 int bdb_cache_modrdn(
321         Entry   *e,
322         struct berval *nrdn,
323         Entry   *new,
324         EntryInfo *ein,
325         DB_ENV *env,
326         u_int32_t locker,
327         DB_LOCK *lock
328 );
329 int bdb_cache_modify(
330         Entry *e,
331         Attribute *newAttrs,
332         DB_ENV *env,
333         u_int32_t locker,
334         DB_LOCK *lock
335 );
336 int bdb_cache_update_entry(
337        Cache   *cache,
338        Entry   *e
339 );
340 int bdb_cache_find_entry_ndn2id(
341         Backend *be,
342         DB_TXN  *txn,
343         struct berval   *ndn,
344         EntryInfo       **res,
345         u_int32_t       locker,
346         void    *ctx
347 );
348 int bdb_cache_find_entry_id(
349         Backend *be,
350         DB_TXN  *tid,
351         ID              id,
352         EntryInfo **eip,
353         int     islocked,
354         u_int32_t       locker,
355         DB_LOCK         *lock,
356         void    *ctx
357 );
358 int bdb_cache_delete_entry(
359         Cache   *cache,
360         Entry   *e,
361         DB_ENV  *env,
362         u_int32_t locker,
363         DB_LOCK *lock
364 );
365 void bdb_cache_release_all( Cache *cache );
366
367 /*
368  * lcup.c
369  */
370
371 BI_op_abandon bdb_abandon;
372
373 BI_op_cancel bdb_cancel;
374
375 #if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
376 int bdb_do_search(
377         Operation       *op,
378         SlapReply       *rs,
379         Operation       *ps_op,
380         Entry           *entry,
381         int             psearch_type
382 );
383 #define bdb_psearch(op, rs, sop, e, ps_type)    bdb_do_search(op, rs, sop, e, ps_type)
384 #endif
385
386 /*
387  * search.c
388  */
389
390 #ifdef LDAP_CLIENT_UPDATE
391 int
392 bdb_build_lcup_update_ctrl(
393         Operation       *op,
394         SlapReply       *rs,
395         Entry           *e,
396         int             entry_count,
397         LDAPControl     **ctrls,
398         int             num_ctrls,
399         struct berval   *latest_entrycsn_bv,
400         int             isdeleted       );
401
402 int
403 bdb_build_lcup_done_ctrl(
404         Operation       *op,
405         SlapReply       *rs,
406         LDAPControl     **ctrls,
407         int             num_ctrls,
408         struct berval   *latest_entrycsn_bv     );
409 #endif
410
411 #ifdef LDAP_SYNC
412 int
413 bdb_build_sync_state_ctrl(
414         Operation       *op,
415         SlapReply       *rs,
416         Entry           *e,
417         int             entry_sync_state,
418         LDAPControl     **ctrls,
419         int             num_ctrls,
420         int             send_cookie,
421         struct berval   *latest_entrycsn_bv     );
422
423 int
424 bdb_build_sync_done_ctrl(
425         Operation       *op,
426         SlapReply       *rs,
427         LDAPControl     **ctrls,
428         int             num_ctrls,
429         int             send_cookie,
430         struct berval   *latest_entrycsn_bv     );
431
432 int
433 bdb_send_ldap_intermediate(
434         Operation   *op,
435         SlapReply       *rs,
436         int         state,
437         struct berval *cookie );
438 #endif
439
440 #ifdef BDB_REUSE_LOCKERS
441
442 int bdb_locker_id( Operation *op, DB_ENV *env, int *locker );
443
444 #endif
445
446 #ifdef HAVE_EBCDIC
447 char *ebcdic_dberror( int rc );
448
449 #define db_strerror(x)  ebcdic_dberror(x)
450 #endif
451
452 LDAP_END_DECL
453
454 #endif /* _PROTO_BDB_H */