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