1 /* config.c - bdb backend configuration file routine */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
17 # define SLAP_BDB_ALLOW_DIRTY_READ
28 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
31 fprintf( stderr, "%s: line %d: "
32 "bdb database info is null!\n",
37 /* directory is the DB_HOME */
38 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
40 fprintf( stderr, "%s: line %d: "
41 "missing dir in \"directory <dir>\" line\n",
45 if ( bdb->bi_dbenv_home ) {
46 free( bdb->bi_dbenv_home );
48 bdb->bi_dbenv_home = ch_strdup( argv[1] );
50 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
51 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
52 bdb->bi_db_opflags |= DB_DIRTY_READ;
54 /* transaction logging configuration */
55 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
56 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
58 /* transaction checkpoint configuration */
59 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
61 fprintf( stderr, "%s: line %d: "
62 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
67 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
68 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
70 /* lock detect configuration */
71 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
73 fprintf( stderr, "%s: line %d: "
74 "missing parameters in \"lockDetect <policy>\" line\n",
79 if( strcasecmp( argv[1], "default" ) == 0 ) {
80 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
82 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
83 bdb->bi_lock_detect = DB_LOCK_OLDEST;
85 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
86 bdb->bi_lock_detect = DB_LOCK_RANDOM;
88 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
89 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
91 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
92 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
95 fprintf( stderr, "%s: line %d: "
96 "bad policy (%s) in \"lockDetect <policy>\" line\n",
97 fname, lineno, argv[1] );
101 /* mode with which to create new database files */
102 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
104 fprintf( stderr, "%s: line %d: "
105 "missing mode in \"mode <mode>\" line\n",
109 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
111 /* attribute to index */
112 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
115 fprintf( stderr, "%s: line %d: "
116 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
119 } else if ( argc > 3 ) {
120 fprintf( stderr, "%s: line %d: "
121 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
125 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
127 if( rc != LDAP_SUCCESS ) return 1;
129 /* unique key for shared memory regions */
130 } else if ( strcasecmp( argv[0], "shm_key" ) == 0 ) {
133 "%s: line %d: missing key in \"shm_key <key>\" line\n",
137 bdb->bi_shm_key = atoi( argv[1] );
139 /* size of the cache in entries */
140 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
143 "%s: line %d: missing size in \"cachesize <size>\" line\n",
147 bdb->bi_cache.c_maxsize = atoi( argv[1] );
149 /* depth of search stack cache in units of (IDL)s */
150 } else if ( strcasecmp( argv[0], "searchstack" ) == 0 ) {
153 "%s: line %d: missing depth in \"searchstack <depth>\" line\n",
157 bdb->bi_search_stack_depth = atoi( argv[1] );
158 if ( bdb->bi_search_stack_depth < MINIMUM_SEARCH_STACK_DEPTH ) {
160 "%s: line %d: depth %d too small, using %d\n",
161 fname, lineno, bdb->bi_search_stack_depth,
162 MINIMUM_SEARCH_STACK_DEPTH );
163 bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH;
166 #ifdef SLAP_IDL_CACHE
167 /* size of the IDL cache in entries */
168 } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) {
171 "%s: line %d: missing size in \"idlcachesize <size>\" line\n",
175 if ( !( slapMode & SLAP_TOOL_MODE ) )
176 bdb->bi_idl_cache_max_size = atoi( argv[1] );
181 fprintf( stderr, "%s: line %d: "
182 "unknown directive \"%s\" in bdb database definition (ignored)\n",
183 fname, lineno, argv[0] );