1 /* init.c - initialize ldbm backend */
3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
12 #include <ac/socket.h>
15 #include "back-ldbm.h"
17 #ifdef SLAPD_LDBM_DYNAMIC
19 int back_ldbm_LTX_init_module(int argc, char *argv[]) {
22 memset( &bi, 0, sizeof(bi) );
24 bi.bi_init = ldbm_back_initialize;
30 #endif /* SLAPD_LDBM_DYNAMIC */
37 bi->bi_open = ldbm_back_open;
39 bi->bi_close = ldbm_back_close;
40 bi->bi_destroy = ldbm_back_destroy;
42 bi->bi_db_init = ldbm_back_db_init;
43 bi->bi_db_config = ldbm_back_db_config;
44 bi->bi_db_open = ldbm_back_db_open;
45 bi->bi_db_close = ldbm_back_db_close;
46 bi->bi_db_destroy = ldbm_back_db_destroy;
48 bi->bi_op_bind = ldbm_back_bind;
49 bi->bi_op_unbind = ldbm_back_unbind;
50 bi->bi_op_search = ldbm_back_search;
51 bi->bi_op_compare = ldbm_back_compare;
52 bi->bi_op_modify = ldbm_back_modify;
53 bi->bi_op_modrdn = ldbm_back_modrdn;
54 bi->bi_op_add = ldbm_back_add;
55 bi->bi_op_delete = ldbm_back_delete;
56 bi->bi_op_abandon = ldbm_back_abandon;
58 bi->bi_entry_release_rw = ldbm_back_entry_release_rw;
59 bi->bi_acl_group = ldbm_back_group;
62 * hooks for slap tools
64 bi->bi_tool_entry_open = ldbm_tool_entry_open;
65 bi->bi_tool_entry_close = ldbm_tool_entry_close;
66 bi->bi_tool_entry_first = ldbm_tool_entry_first;
67 bi->bi_tool_entry_next = ldbm_tool_entry_next;
68 bi->bi_tool_entry_get = ldbm_tool_entry_get;
69 bi->bi_tool_entry_put = ldbm_tool_entry_put;
70 bi->bi_tool_index_attr = ldbm_tool_index_attr;
71 bi->bi_tool_index_change = ldbm_tool_index_change;
72 bi->bi_tool_sync = ldbm_tool_sync;
74 bi->bi_connection_init = 0;
75 bi->bi_connection_destroy = 0;
95 /* initialize the underlying database system */
96 rc = ldbm_initialize();
106 /* terminate the underlying database system */
120 /* allocate backend-database-specific stuff */
121 li = (struct ldbminfo *) ch_calloc( 1, sizeof(struct ldbminfo) );
123 /* arrange to read nextid later (on first request for it) */
124 li->li_nextid = NOID;
126 /* default cache size */
127 li->li_cache.c_maxsize = DEFAULT_CACHE_SIZE;
129 /* default database cache size */
130 li->li_dbcachesize = DEFAULT_DBCACHE_SIZE;
132 /* default cache mode is sync on write */
133 li->li_dbcachewsync = 1;
135 /* default file creation mode */
136 li->li_mode = DEFAULT_MODE;
138 /* default database directory */
139 li->li_directory = ch_strdup( DEFAULT_DB_DIRECTORY );
141 argv[ 0 ] = "objectclass";
142 argv[ 1 ] = "pres,eq";
144 attr_index_config( li, "ldbm objectclass initialization",
147 /* initialize various mutex locks & condition variables */
148 ldap_pvt_thread_mutex_init( &li->li_root_mutex );
149 ldap_pvt_thread_mutex_init( &li->li_add_mutex );
150 ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex );
151 ldap_pvt_thread_mutex_init( &li->li_nextid_mutex );
152 ldap_pvt_thread_mutex_init( &li->li_dbcache_mutex );
153 ldap_pvt_thread_cond_init( &li->li_dbcache_cv );
169 ldbm_back_db_destroy(
173 /* should free/destroy every in be_private */
175 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
176 free( li->li_nextid_file );
177 free( li->li_directory );
178 attr_index_destroy( li->li_attrs );
180 ldap_pvt_thread_mutex_destroy( &li->li_root_mutex );
181 ldap_pvt_thread_mutex_destroy( &li->li_add_mutex );
182 ldap_pvt_thread_mutex_destroy( &li->li_cache.c_mutex );
183 ldap_pvt_thread_mutex_destroy( &li->li_nextid_mutex );
184 ldap_pvt_thread_mutex_destroy( &li->li_dbcache_mutex );
185 ldap_pvt_thread_cond_destroy( &li->li_dbcache_cv );
186 #endif /* SLAP_CLEANUP */
187 free( be->be_private );
188 be->be_private = NULL;