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