summaryrefslogtreecommitdiffstats
path: root/servers/slapd/back-mdb/proto-mdb.h
blob: 5b20e47c98a09f7d0bd279f51e7d6fddf9b5aca1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 *
 * Copyright 2000-2021 The OpenLDAP Foundation.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only as authorized by the OpenLDAP
 * Public License.
 *
 * A copy of this license is available in the file LICENSE in the
 * top-level directory of the distribution or, alternatively, at
 * <http://www.OpenLDAP.org/license.html>.
 */

#ifndef _PROTO_MDB_H
#define _PROTO_MDB_H

LDAP_BEGIN_DECL

#define MDB_UCTYPE	"MDB"

/*
 * attr.c
 */

AttrInfo *mdb_attr_mask( struct mdb_info *mdb,
	AttributeDescription *desc );

void mdb_attr_flush( struct mdb_info *mdb );

int mdb_attr_slot( struct mdb_info *mdb,
	AttributeDescription *desc, int *insert );

int mdb_attr_dbs_open( BackendDB *be, MDB_txn *txn, struct config_reply_s *cr );
void mdb_attr_dbs_close( struct mdb_info *mdb );

int mdb_attr_index_config LDAP_P(( struct mdb_info *mdb,
	const char *fname, int lineno,
	int argc, char **argv, struct config_reply_s *cr ));

void mdb_attr_index_unparse LDAP_P(( struct mdb_info *mdb, BerVarray *bva ));
void mdb_attr_index_destroy LDAP_P(( struct mdb_info *mdb ));
void mdb_attr_index_free LDAP_P(( struct mdb_info *mdb,
	AttributeDescription *ad ));

void mdb_attr_info_free( AttrInfo *ai );

int mdb_ad_read( struct mdb_info *mdb, MDB_txn *txn );
int mdb_ad_get( struct mdb_info *mdb, MDB_txn *txn, AttributeDescription *ad );
void mdb_ad_unwind( struct mdb_info *mdb, int prev_ads );

/*
 * config.c
 */

int mdb_back_init_cf( BackendInfo *bi );

/*
 * dn2entry.c
 */

int mdb_dn2entry LDAP_P(( Operation *op, MDB_txn *tid, MDB_cursor *mc,
	struct berval *dn, Entry **e, ID *nsubs, int matched ));

/*
 * dn2id.c
 */

int mdb_dn2id(
	Operation *op,
	MDB_txn *txn,
	MDB_cursor *mc,
	struct berval *ndn,
	ID *id,
	ID *nsubs,
	struct berval *matched,
	struct berval *nmatched );

int mdb_dn2id_add(
	Operation *op,
	MDB_cursor *mcp,
	MDB_cursor *mcd,
	ID pid,
	ID nsubs,
	int upsub,
	Entry *e );

int mdb_dn2id_delete(
	Operation *op,
	MDB_cursor *mc,
	ID id,
	ID nsubs );

int mdb_dn2id_children(
	Operation *op,
	MDB_txn *tid,
	Entry *e );

int mdb_dn2sups (
	Operation *op,
	MDB_txn *tid,
	struct berval *dn,
	ID *sups
	);

int mdb_dn2idl(
	Operation *op,
	MDB_txn *txn,
	struct berval *ndn,
	ID eid,
	ID *ids,
	ID *stack );

int mdb_dn2id_parent(
	Operation *op,
	MDB_txn *txn,
	ID eid,
	ID *idp );

int mdb_id2name(
	Operation *op,
	MDB_txn *txn,
	MDB_cursor **cursp,
	ID eid,
	struct berval *name,
	struct berval *nname);

int mdb_idscope(
	Operation *op,
	MDB_txn *txn,
	ID base,
	ID *ids,
	ID *res );

struct IdScopes;

int mdb_idscopes(
	Operation *op,
	struct IdScopes *isc );

int mdb_idscopechk(
	Operation *op,
	struct IdScopes *isc );

int mdb_dn2id_walk(
	Operation *op,
	struct IdScopes *isc );

void mdb_dn2id_wrestore(
	Operation *op,
	struct IdScopes *isc );

MDB_cmp_func mdb_dup_compare;

/*
 * filterentry.c
 */

int mdb_filter_candidates(
	Operation *op,
	MDB_txn *txn,
	Filter	*f,
	ID *ids,
	ID *tmp,
	ID *stack );

/*
 * id2entry.c
 */

int mdb_id2entry_add(
	Operation *op,
	MDB_txn *tid,
	MDB_cursor *mc,
	Entry *e );

int mdb_id2entry_update(
	Operation *op,
	MDB_txn *tid,
	MDB_cursor *mc,
	Entry *e );

int mdb_id2entry_delete(
	BackendDB *be,
	MDB_txn *tid,
	Entry *e);

int mdb_id2entry(
	Operation *op,
	MDB_cursor *mc,
	ID id,
	Entry **e);

int mdb_id2edata(
	Operation *op,
	MDB_cursor *mc,
	ID id,
	MDB_val *data);

int mdb_entry_return( Operation *op, Entry *e );
BI_entry_release_rw mdb_entry_release;
BI_entry_get_rw mdb_entry_get;

int mdb_entry_decode( Operation *op, MDB_txn *txn, MDB_val *data, Entry **e );

void mdb_reader_flush( MDB_env *env );
int mdb_opinfo_get( Operation *op, struct mdb_info *mdb, int rdonly, mdb_op_info **moi );

/*
 * idl.c
 */

unsigned mdb_idl_search( ID *ids, ID id );

int mdb_idl_fetch_key(
	BackendDB	*be,
	MDB_txn		*txn,
	MDB_dbi		dbi,
	MDB_val		*key,
	ID			*ids,
	MDB_cursor	**saved_cursor,
	int                     get_flag );

int mdb_idl_insert( ID *ids, ID id );

typedef int (mdb_idl_keyfunc)(
	BackendDB *be,
	MDB_cursor *mc,
	struct berval *key,
	ID id );

mdb_idl_keyfunc mdb_idl_insert_keys;
mdb_idl_keyfunc mdb_idl_delete_keys;

int
mdb_idl_intersection(
	ID *a,
	ID *b );

int
mdb_idl_union(
	ID *a,
	ID *b );

ID mdb_idl_first( ID *ids, ID *cursor );
ID mdb_idl_next( ID *ids, ID *cursor );

void mdb_idl_sort( ID *ids, ID *tmp );
int mdb_idl_append( ID *a, ID *b );
int mdb_idl_append_one( ID *ids, ID id );


/*
 * index.c
 */

extern AttrInfo *
mdb_index_mask LDAP_P((
	Backend *be,
	AttributeDescription *desc,
	struct berval *name ));

extern int
mdb_index_param LDAP_P((
	Backend *be,
	AttributeDescription *desc,
	int ftype,
	MDB_dbi *dbi,
	slap_mask_t *mask,
	struct berval *prefix ));

extern int
mdb_index_values LDAP_P((
	Operation *op,
	MDB_txn *txn,
	AttributeDescription *desc,
	BerVarray vals,
	ID id,
	int opid ));

extern int
mdb_index_recset LDAP_P((
	struct mdb_info *mdb,
	Attribute *a,
	AttributeType *type,
	struct berval *tags,
	IndexRec *ir ));

extern int
mdb_index_recrun LDAP_P((
	Operation *op,
	MDB_txn *txn,
	struct mdb_info *mdb,
	IndexRec *ir,
	ID id,
	int base ));

int mdb_index_entry LDAP_P(( Operation *op, MDB_txn *t, int r, Entry *e ));

#define mdb_index_entry_add(op,t,e) \
	mdb_index_entry((op),(t),SLAP_INDEX_ADD_OP,(e))
#define mdb_index_entry_del(op,t,e) \
	mdb_index_entry((op),(t),SLAP_INDEX_DELETE_OP,(e))

/*
 * key.c
 */

extern int
mdb_key_read(
    Backend	*be,
	MDB_txn *txn,
	MDB_dbi dbi,
    struct berval *k,
	ID *ids,
    MDB_cursor **saved_cursor,
        int get_flags );

/*
 * nextid.c
 */

int mdb_next_id( BackendDB *be, MDB_cursor *mc, ID *id );

/*
 * modify.c
 */

int mdb_modify_internal(
	Operation *op,
	MDB_txn *tid,
	Modifications *modlist,
	Entry *e,
	const char **text,
	char *textbuf,
	size_t textlen );

/*
 * monitor.c
 */

int mdb_monitor_db_init( BackendDB *be );
int mdb_monitor_db_open( BackendDB *be );
int mdb_monitor_db_close( BackendDB *be );
int mdb_monitor_db_destroy( BackendDB *be );

#ifdef MDB_MONITOR_IDX
int
mdb_monitor_idx_add(
	struct mdb_info		*mdb,
	AttributeDescription	*desc,
	slap_mask_t		type );
#endif /* MDB_MONITOR_IDX */

/*
 * former external.h
 */

extern BI_init				mdb_back_initialize;

extern BI_db_config			mdb_db_config;

extern BI_op_add			mdb_add;
extern BI_op_bind			mdb_bind;
extern BI_op_compare			mdb_compare;
extern BI_op_delete			mdb_delete;
extern BI_op_modify			mdb_modify;
extern BI_op_modrdn			mdb_modrdn;
extern BI_op_search			mdb_search;
extern BI_op_extended			mdb_extended;

extern BI_chk_referrals			mdb_referrals;

extern BI_operational			mdb_operational;

extern BI_has_subordinates 		mdb_hasSubordinates;

/* tools.c */
extern BI_tool_entry_open		mdb_tool_entry_open;
extern BI_tool_entry_close		mdb_tool_entry_close;
extern BI_tool_entry_first_x		mdb_tool_entry_first_x;
extern BI_tool_entry_next		mdb_tool_entry_next;
extern BI_tool_entry_get		mdb_tool_entry_get;
extern BI_tool_entry_put		mdb_tool_entry_put;
extern BI_tool_entry_reindex		mdb_tool_entry_reindex;
extern BI_tool_dn2id_get		mdb_tool_dn2id_get;
extern BI_tool_entry_modify		mdb_tool_entry_modify;

extern mdb_idl_keyfunc mdb_tool_idl_add;

LDAP_END_DECL

#endif /* _PROTO_MDB_H */