1 /* config.c - bdb backend configuration file routine */
4 * Copyright 1998-2002 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 ) {
73 fprintf( stderr, "%s: line %d: "
74 "missing parameters in \"lockDetect <policy> <seconds>\" 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> <seconds>\" line\n",
97 fname, lineno, argv[1] );
101 bdb->bi_lock_detect_seconds = strtol( argv[2], NULL, 0 );
102 if( bdb->bi_lock_detect_seconds < 1 ) {
103 fprintf( stderr, "%s: line %d: "
104 "bad seconds (%s) in \"lockDetect <policy> <seconds>\" line\n",
105 fname, lineno, argv[2] );
109 fprintf( stderr, "%s: line %d: "
110 "NO THREADS: lockDetect line ignored\n",
114 /* mode with which to create new database files */
115 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
117 fprintf( stderr, "%s: line %d: "
118 "missing mode in \"mode <mode>\" line\n",
122 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
124 /* attribute to index */
125 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
128 fprintf( stderr, "%s: line %d: "
129 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
132 } else if ( argc > 3 ) {
133 fprintf( stderr, "%s: line %d: "
134 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
138 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
140 if( rc != LDAP_SUCCESS ) return 1;
142 /* size of the cache in entries */
143 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
146 "%s: line %d: missing size in \"cachesize <size>\" line\n",
150 bdb->bi_cache.c_maxsize = atoi( argv[1] );
154 fprintf( stderr, "%s: line %d: "
155 "unknown directive \"%s\" in bdb database definition (ignored)\n",
156 fname, lineno, argv[0] );