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