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
25 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
28 fprintf( stderr, "%s: line %d: "
29 "bdb database info is null!\n",
34 /* directory is the DB_HOME */
35 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
37 fprintf( stderr, "%s: line %d: "
38 "missing dir in \"directory <dir>\" line\n",
42 if ( bdb->bi_dbenv_home ) {
43 free( bdb->bi_dbenv_home );
45 bdb->bi_dbenv_home = ch_strdup( argv[1] );
47 #ifdef SLAP_BDB_ALLOW_DBNOTXN
48 /* turn off transactions, use CDB mode instead */
49 } else if ( strcasecmp( argv[0], "dbnotxn" ) == 0 ) {
52 /* transaction checkpoint configuration */
53 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
54 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
56 /* transaction checkpoint configuration */
57 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
59 fprintf( stderr, "%s: line %d: "
60 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
65 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
66 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
68 /* lock detect configuration */
69 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
72 fprintf( stderr, "%s: line %d: "
73 "missing parameters in \"lockDetect <policy> <seconds>\" 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;
91 fprintf( stderr, "%s: line %d: "
92 "bad policy (%s) in \"lockDetect <policy> <seconds>\" line\n",
93 fname, lineno, argv[1] );
97 bdb->bi_lock_detect_seconds = strtol( argv[2], NULL, 0 );
98 if( bdb->bi_lock_detect_seconds < 1 ) {
99 fprintf( stderr, "%s: line %d: "
100 "bad seconds (%s) in \"lockDetect <policy> <seconds>\" line\n",
101 fname, lineno, argv[2] );
105 fprintf( stderr, "%s: line %d: "
106 "NO THREADS: lockDetect line ignored\n",
110 /* mode with which to create new database files */
111 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
113 fprintf( stderr, "%s: line %d: "
114 "missing mode in \"mode <mode>\" line\n",
118 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
120 #if BDB_FILTER_INDICES
121 /* attribute to index */
122 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
125 fprintf( stderr, "%s: line %d: "
126 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
129 } else if ( argc > 3 ) {
130 fprintf( stderr, "%s: line %d: "
131 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
135 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
137 if( rc != LDAP_SUCCESS ) return 1;
142 fprintf( stderr, "%s: line %d: "
143 "unknown directive \"%s\" in bdb database definition (ignored)\n",
144 fname, lineno, argv[0] );