]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/config.c
f56b8cc2a8a55a79ad9efd480fc94026a4f03a48
[openldap] / servers / slapd / back-bdb / config.c
1 /* config.c - ldbm 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         /* mode with which to create new database files */
47         } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
48                 if ( argc < 3 ) {
49                         fprintf( stderr, "%s: line %d: "
50                                 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
51                                 fname, lineno );
52                         return 1;
53                 }
54                 bdb->bi_txn_cp = 1;
55                 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
56                 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
57
58         /* mode with which to create new database files */
59         } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
60                 if ( argc < 2 ) {
61                         fprintf( stderr, "%s: line %d: "
62                                 "missing mode in \"mode <mode>\" line\n",
63                                 fname, lineno );
64                         return 1;
65                 }
66                 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
67
68 #if 0
69         /* attribute to index */
70         } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
71                 int rc;
72                 if ( argc < 2 ) {
73                         fprintf( stderr, "%s: line %d: "
74                                 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
75                                 fname, lineno );
76                         return 1;
77                 } else if ( argc > 3 ) {
78                         fprintf( stderr, "%s: line %d: "
79                                 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
80                                 "line (ignored)\n",
81                                 fname, lineno );
82                 }
83                 rc = attr_index_config( li, fname, lineno, argc - 1, &argv[1] );
84
85                 if( rc != LDAP_SUCCESS ) return 1;
86 #endif
87
88         /* anything else */
89         } else {
90                 fprintf( stderr, "%s: line %d: "
91                         "unknown directive \"%s\" in bdb database definition (ignored)\n",
92                         fname, lineno, argv[0] );
93         }
94
95         return 0;
96 }