]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/config.c
Changed AttributeType.sat_cname from char * to struct berval.
[openldap] / servers / slapd / back-bdb / config.c
1 /* config.c - bdb backend configuration file routine */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11 #include <ac/string.h>
12
13 #include "back-bdb.h"
14
15 int
16 bdb_db_config(
17         BackendDB       *be,
18         const char      *fname,
19         int             lineno,
20         int             argc,
21         char    **argv )
22 {
23         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
24
25         if ( bdb == NULL ) {
26                 fprintf( stderr, "%s: line %d: "
27                         "bdb database info is null!\n",
28                         fname, lineno );
29                 return 1;
30         }
31
32         /* directory is the DB_HOME */
33         if ( strcasecmp( argv[0], "directory" ) == 0 ) {
34                 if ( argc < 2 ) {
35                         fprintf( stderr, "%s: line %d: "
36                                 "missing dir in \"directory <dir>\" line\n",
37                                 fname, lineno );
38                         return 1;
39                 }
40                 if ( bdb->bi_dbenv_home ) {
41                         free( bdb->bi_dbenv_home );
42                 }
43                 bdb->bi_dbenv_home = ch_strdup( argv[1] );
44
45
46         /* transaction checkpoint configuration */
47         } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
48                 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
49
50         /* transaction checkpoint configuration */
51         } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
52                 if ( argc < 3 ) {
53                         fprintf( stderr, "%s: line %d: "
54                                 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
55                                 fname, lineno );
56                         return 1;
57                 }
58                 bdb->bi_txn_cp = 1;
59                 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
60                 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
61
62         /* lock detect configuration */
63         } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
64 #ifndef NO_THREADS
65                 if ( argc < 3 ) {
66                         fprintf( stderr, "%s: line %d: "
67                                 "missing parameters in \"lockDetect <policy> <seconds>\" line\n",
68                                 fname, lineno );
69                         return 1;
70                 }
71
72                 if( strcasecmp( argv[1], "default" ) == 0 ) {
73                         bdb->bi_lock_detect = DB_LOCK_DEFAULT;
74
75                 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
76                         bdb->bi_lock_detect = DB_LOCK_OLDEST;
77
78                 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
79                         bdb->bi_lock_detect = DB_LOCK_RANDOM;
80
81                 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
82                         bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
83
84                 } else {
85                         fprintf( stderr, "%s: line %d: "
86                                 "bad policy (%s) in \"lockDetect <policy> <seconds>\" line\n",
87                                 fname, lineno, argv[1] );
88                         return 1;
89                 }
90
91                 bdb->bi_lock_detect_seconds = strtol( argv[2], NULL, 0 );
92                 if( bdb->bi_lock_detect_seconds < 1 ) {
93                         fprintf( stderr, "%s: line %d: "
94                                 "bad seconds (%s) in \"lockDetect <policy> <seconds>\" line\n",
95                                 fname, lineno, argv[2] );
96                         return 1;
97                 }
98 #else
99                 fprintf( stderr, "%s: line %d: "
100                         "NO THREADS: lockDetect line ignored\n",
101                         fname, lineno );
102 #endif
103
104         /* mode with which to create new database files */
105         } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
106                 if ( argc < 2 ) {
107                         fprintf( stderr, "%s: line %d: "
108                                 "missing mode in \"mode <mode>\" line\n",
109                                 fname, lineno );
110                         return 1;
111                 }
112                 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
113
114 #if BDB_FILTER_INDICES
115         /* attribute to index */
116         } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
117                 int rc;
118                 if ( argc < 2 ) {
119                         fprintf( stderr, "%s: line %d: "
120                                 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
121                                 fname, lineno );
122                         return 1;
123                 } else if ( argc > 3 ) {
124                         fprintf( stderr, "%s: line %d: "
125                                 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
126                                 "line (ignored)\n",
127                                 fname, lineno );
128                 }
129                 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
130
131                 if( rc != LDAP_SUCCESS ) return 1;
132 #endif
133
134         /* anything else */
135         } else {
136                 fprintf( stderr, "%s: line %d: "
137                         "unknown directive \"%s\" in bdb database definition (ignored)\n",
138                         fname, lineno, argv[0] );
139         }
140
141         return 0;
142 }