1 /* config.c - bdb backend configuration file routine */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
15 #define SLAP_BDB_ALLOW_DBNOTXN
16 #define SLAP_BDB_ALLOW_DIRTY_READ
26 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
29 fprintf( stderr, "%s: line %d: "
30 "bdb database info is null!\n",
35 /* directory is the DB_HOME */
36 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
38 fprintf( stderr, "%s: line %d: "
39 "missing dir in \"directory <dir>\" line\n",
43 if ( bdb->bi_dbenv_home ) {
44 free( bdb->bi_dbenv_home );
46 bdb->bi_dbenv_home = ch_strdup( argv[1] );
48 #ifdef SLAP_BDB_ALLOW_DBNOTXN
49 /* turn off transactions, use CDB mode instead */
50 } else if ( strcasecmp( argv[0], "dbnotxn" ) == 0 ) {
53 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
54 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
55 bdb->bi_db_opflags |= DB_DIRTY_READ;
57 /* transaction checkpoint configuration */
58 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
59 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
61 /* transaction checkpoint configuration */
62 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
64 fprintf( stderr, "%s: line %d: "
65 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
70 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
71 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
73 /* lock detect configuration */
74 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
77 fprintf( stderr, "%s: line %d: "
78 "missing parameters in \"lockDetect <policy> <seconds>\" line\n",
83 if( strcasecmp( argv[1], "default" ) == 0 ) {
84 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
86 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
87 bdb->bi_lock_detect = DB_LOCK_OLDEST;
89 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
90 bdb->bi_lock_detect = DB_LOCK_RANDOM;
92 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
93 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
96 fprintf( stderr, "%s: line %d: "
97 "bad policy (%s) in \"lockDetect <policy> <seconds>\" line\n",
98 fname, lineno, argv[1] );
102 bdb->bi_lock_detect_seconds = strtol( argv[2], NULL, 0 );
103 if( bdb->bi_lock_detect_seconds < 1 ) {
104 fprintf( stderr, "%s: line %d: "
105 "bad seconds (%s) in \"lockDetect <policy> <seconds>\" line\n",
106 fname, lineno, argv[2] );
110 fprintf( stderr, "%s: line %d: "
111 "NO THREADS: lockDetect line ignored\n",
115 /* mode with which to create new database files */
116 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
118 fprintf( stderr, "%s: line %d: "
119 "missing mode in \"mode <mode>\" line\n",
123 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
125 #if BDB_FILTER_INDICES
126 /* attribute to index */
127 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
130 fprintf( stderr, "%s: line %d: "
131 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
134 } else if ( argc > 3 ) {
135 fprintf( stderr, "%s: line %d: "
136 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
140 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
142 if( rc != LDAP_SUCCESS ) return 1;
147 fprintf( stderr, "%s: line %d: "
148 "unknown directive \"%s\" in bdb database definition (ignored)\n",
149 fname, lineno, argv[0] );