]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/config.c
add new ber dump routine (behind NEW_LOGGING)
[openldap] / servers / slapd / back-ldbm / 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
12 #include <ac/socket.h>
13 #include <ac/string.h>
14
15 #include "slap.h"
16 #include "back-ldbm.h"
17
18
19 int
20 ldbm_back_db_config(
21     Backend     *be,
22     const char  *fname,
23     int         lineno,
24     int         argc,
25     char        **argv
26 )
27 {
28         int rc;
29         struct ldbminfo *li = (struct ldbminfo *) be->be_private;
30
31         if ( li == NULL ) {
32                 fprintf( stderr, "%s: line %d: ldbm database info is null!\n",
33                     fname, lineno );
34                 return( 1 );
35         }
36
37         /* directory where database files live */
38         if ( strcasecmp( argv[0], "directory" ) == 0 ) {
39                 if ( argc < 2 ) {
40                         fprintf( stderr,
41                 "%s: line %d: missing dir in \"directory <dir>\" line\n",
42                             fname, lineno );
43                         return( 1 );
44                 }
45                 if ( li->li_directory )
46                         free( li->li_directory );
47                 li->li_directory = ch_strdup( argv[1] );
48
49         /* mode with which to create new database files */
50         } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
51                 if ( argc < 2 ) {
52                         fprintf( stderr,
53                         "%s: line %d: missing mode in \"mode <mode>\" line\n",
54                             fname, lineno );
55                         return( 1 );
56                 }
57                 li->li_mode = strtol( argv[1], NULL, 0 );
58
59         /* attribute to index */
60         } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
61                 if ( argc < 2 ) {
62                         fprintf( stderr,
63 "%s: line %d: missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
64                             fname, lineno );
65                         return( 1 );
66                 } else if ( argc > 3 ) {
67                         fprintf( stderr,
68 "%s: line %d: extra junk after \"index <attr> [pres,eq,approx,sub]\" line (ignored)\n",
69                             fname, lineno );
70                 }
71                 rc = attr_index_config( li, fname, lineno, argc - 1, &argv[1] );
72
73                 if( rc != LDAP_SUCCESS ) return 1;
74
75         /* size of the cache in entries */
76         } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
77                 if ( argc < 2 ) {
78                         fprintf( stderr,
79                 "%s: line %d: missing size in \"cachesize <size>\" line\n",
80                             fname, lineno );
81                         return( 1 );
82                 }
83                 li->li_cache.c_maxsize = atoi( argv[1] );
84
85         /* size of each dbcache in bytes */
86         } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) {
87                 if ( argc < 2 ) {
88                         fprintf( stderr,
89                 "%s: line %d: missing size in \"dbcachesize <size>\" line\n",
90                             fname, lineno );
91                         return( 1 );
92                 }
93                 li->li_dbcachesize = atoi( argv[1] );
94
95         /* no locking (not safe) */
96         } else if ( strcasecmp( argv[0], "dbnolocking" ) == 0 ) {
97                 li->li_dblocking = 0;
98
99         /* no write sync (not safe) */
100         } else if ( ( strcasecmp( argv[0], "dbnosync" ) == 0 )
101                 || ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) )
102         {
103                 li->li_dbwritesync = 0;
104
105         /* anything else */
106         } else {
107                 fprintf( stderr,
108 "%s: line %d: unknown directive \"%s\" in ldbm database definition (ignored)\n",
109                     fname, lineno, argv[0] );
110         }
111
112         return 0;
113 }