]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/config.c
Implement NEXTID chunking. Obtain IDs in chunks of size
[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 void
14 ldbm_back_config(
15     Backend     *be,
16     char        *fname,
17     int         lineno,
18     int         argc,
19     char        **argv
20 )
21 {
22         struct ldbminfo *li = (struct ldbminfo *) be->be_private;
23
24         if ( li == NULL ) {
25                 fprintf( stderr, "%s: line %d: ldbm backend info is null!\n",
26                     fname, lineno );
27                 exit( 1 );
28         }
29
30         /* directory where database files live */
31         if ( strcasecmp( argv[0], "directory" ) == 0 ) {
32                 if ( argc < 2 ) {
33                         fprintf( stderr,
34                 "%s: line %d: missing dir in \"directory <dir>\" line\n",
35                             fname, lineno );
36                         exit( 1 );
37                 }
38                 li->li_directory = ch_strdup( argv[1] );
39
40                 li->li_nextid_file =
41                         ch_malloc( strlen(li->li_directory) + sizeof("/NEXTID") );
42
43                 strcpy(li->li_nextid_file, li->li_directory);
44                 strcat(li->li_nextid_file, "/NEXTID");
45
46         /* mode with which to create new database files */
47         } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
48                 if ( argc < 2 ) {
49                         fprintf( stderr,
50                         "%s: line %d: missing mode in \"mode <mode>\" line\n",
51                             fname, lineno );
52                         exit( 1 );
53                 }
54                 li->li_mode = strtol( argv[1], NULL, 0 );
55
56         /* attribute to index */
57         } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
58                 if ( argc < 2 ) {
59                         fprintf( stderr,
60 "%s: line %d: missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
61                             fname, lineno );
62                         exit( 1 );
63                 } else if ( argc > 3 ) {
64                         fprintf( stderr,
65 "%s: line %d: extra junk after \"index <attr> [pres,eq,approx,sub]\" line (ignored)\n",
66                             fname, lineno );
67                 }
68                 attr_index_config( li, fname, lineno, argc - 1, &argv[1], 0 );
69
70         /* size of the cache in entries */
71         } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
72                 if ( argc < 2 ) {
73                         fprintf( stderr,
74                 "%s: line %d: missing size in \"cachesize <size>\" line\n",
75                             fname, lineno );
76                         exit( 1 );
77                 }
78                 li->li_cache.c_maxsize = atoi( argv[1] );
79
80         /* size of each dbcache in bytes */
81         } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) {
82                 if ( argc < 2 ) {
83                         fprintf( stderr,
84                 "%s: line %d: missing size in \"dbcachesize <size>\" line\n",
85                             fname, lineno );
86                         exit( 1 );
87                 }
88                 li->li_dbcachesize = atoi( argv[1] );
89
90         /* no write sync */
91         } else if ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) {
92                 li->li_dbcachewsync = 0;
93
94         /* anything else */
95         } else {
96                 fprintf( stderr,
97 "%s: line %d: unknown directive \"%s\" in ldbm database definition (ignored)\n",
98                     fname, lineno, argv[0] );
99         }
100 }