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>
16 # define SLAP_BDB_ALLOW_DIRTY_READ
27 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
30 fprintf( stderr, "%s: line %d: "
31 "bdb database info is null!\n",
36 /* directory is the DB_HOME */
37 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
39 fprintf( stderr, "%s: line %d: "
40 "missing dir in \"directory <dir>\" line\n",
44 if ( bdb->bi_dbenv_home ) {
45 free( bdb->bi_dbenv_home );
47 bdb->bi_dbenv_home = ch_strdup( argv[1] );
49 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
50 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
51 bdb->bi_db_opflags |= DB_DIRTY_READ;
53 /* transaction checkpoint configuration */
54 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
55 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
57 /* transaction checkpoint configuration */
58 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
60 fprintf( stderr, "%s: line %d: "
61 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
66 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
67 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
69 /* lock detect configuration */
70 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
72 fprintf( stderr, "%s: line %d: "
73 "missing parameters in \"lockDetect <policy>\" line\n",
78 if( strcasecmp( argv[1], "default" ) == 0 ) {
79 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
81 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
82 bdb->bi_lock_detect = DB_LOCK_OLDEST;
84 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
85 bdb->bi_lock_detect = DB_LOCK_RANDOM;
87 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
88 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
90 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
91 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
94 fprintf( stderr, "%s: line %d: "
95 "bad policy (%s) in \"lockDetect <policy>\" line\n",
96 fname, lineno, argv[1] );
100 /* mode with which to create new database files */
101 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
103 fprintf( stderr, "%s: line %d: "
104 "missing mode in \"mode <mode>\" line\n",
108 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
110 /* attribute to index */
111 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
114 fprintf( stderr, "%s: line %d: "
115 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
118 } else if ( argc > 3 ) {
119 fprintf( stderr, "%s: line %d: "
120 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
124 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
126 if( rc != LDAP_SUCCESS ) return 1;
128 /* size of the cache in entries */
129 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
132 "%s: line %d: missing size in \"cachesize <size>\" line\n",
136 bdb->bi_cache.c_maxsize = atoi( argv[1] );
138 /* depth of search stack cache in units of (IDL)s */
139 } else if ( strcasecmp( argv[0], "searchstack" ) == 0 ) {
142 "%s: line %d: missing depth in \"searchstack <depth>\" line\n",
146 bdb->bi_search_stack_depth = atoi( argv[1] );
147 if ( bdb->bi_search_stack_depth < MINIMUM_SEARCH_STACK_DEPTH ) {
149 "%s: line %d: depth %d too small, using %d\n",
150 fname, lineno, bdb->bi_search_stack_depth,
151 MINIMUM_SEARCH_STACK_DEPTH );
152 bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH;
155 #ifdef SLAP_IDL_CACHE
156 /* size of the IDL cache in entries */
157 } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) {
160 "%s: line %d: missing size in \"idlcachesize <size>\" line\n",
164 if ( !( slapMode & SLAP_TOOL_MODE ) )
165 bdb->bi_idl_cache_max_size = atoi( argv[1] );
170 fprintf( stderr, "%s: line %d: "
171 "unknown directive \"%s\" in bdb database definition (ignored)\n",
172 fname, lineno, argv[0] );