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