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