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>
15 #define SLAP_BDB_ALLOW_DBNOTXN
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_DBNOTXN
51 /* turn off transactions, use CDB mode instead */
52 } else if ( strcasecmp( argv[0], "dbnotxn" ) == 0 ) {
55 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
56 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
57 bdb->bi_db_opflags |= DB_DIRTY_READ;
59 /* transaction checkpoint configuration */
60 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
61 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
63 /* transaction checkpoint configuration */
64 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
66 fprintf( stderr, "%s: line %d: "
67 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
72 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
73 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
75 /* lock detect configuration */
76 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
79 fprintf( stderr, "%s: line %d: "
80 "missing parameters in \"lockDetect <policy> <seconds>\" line\n",
85 if( strcasecmp( argv[1], "default" ) == 0 ) {
86 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
88 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
89 bdb->bi_lock_detect = DB_LOCK_OLDEST;
91 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
92 bdb->bi_lock_detect = DB_LOCK_RANDOM;
94 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
95 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
97 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
98 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
101 fprintf( stderr, "%s: line %d: "
102 "bad policy (%s) in \"lockDetect <policy> <seconds>\" line\n",
103 fname, lineno, argv[1] );
107 bdb->bi_lock_detect_seconds = strtol( argv[2], NULL, 0 );
108 if( bdb->bi_lock_detect_seconds < 1 ) {
109 fprintf( stderr, "%s: line %d: "
110 "bad seconds (%s) in \"lockDetect <policy> <seconds>\" line\n",
111 fname, lineno, argv[2] );
115 fprintf( stderr, "%s: line %d: "
116 "NO THREADS: lockDetect line ignored\n",
120 /* mode with which to create new database files */
121 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
123 fprintf( stderr, "%s: line %d: "
124 "missing mode in \"mode <mode>\" line\n",
128 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
130 #if BDB_FILTER_INDICES
131 /* attribute to index */
132 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
135 fprintf( stderr, "%s: line %d: "
136 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
139 } else if ( argc > 3 ) {
140 fprintf( stderr, "%s: line %d: "
141 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
145 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
147 if( rc != LDAP_SUCCESS ) return 1;
152 fprintf( stderr, "%s: line %d: "
153 "unknown directive \"%s\" in bdb database definition (ignored)\n",
154 fname, lineno, argv[0] );