]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/config.c
99a7c7794ef0da8fc96e3bbb56d144ab1c7057b1
[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         /* mode with which to create new database files */
41         } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
42                 if ( argc < 2 ) {
43                         fprintf( stderr,
44                         "%s: line %d: missing mode in \"mode <mode>\" line\n",
45                             fname, lineno );
46                         exit( 1 );
47                 }
48                 li->li_mode = strtol( argv[1], NULL, 0 );
49
50         /* attribute to index */
51         } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
52                 if ( argc < 2 ) {
53                         fprintf( stderr,
54 "%s: line %d: missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
55                             fname, lineno );
56                         exit( 1 );
57                 } else if ( argc > 3 ) {
58                         fprintf( stderr,
59 "%s: line %d: extra junk after \"index <attr> [pres,eq,approx,sub]\" line (ignored)\n",
60                             fname, lineno );
61                 }
62                 attr_index_config( li, fname, lineno, argc - 1, &argv[1], 0 );
63
64         /* size of the cache in entries */
65         } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
66                 if ( argc < 2 ) {
67                         fprintf( stderr,
68                 "%s: line %d: missing size in \"cachesize <size>\" line\n",
69                             fname, lineno );
70                         exit( 1 );
71                 }
72                 li->li_cache.c_maxsize = atoi( argv[1] );
73
74         /* size of each dbcache in bytes */
75         } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) {
76                 if ( argc < 2 ) {
77                         fprintf( stderr,
78                 "%s: line %d: missing size in \"dbcachesize <size>\" line\n",
79                             fname, lineno );
80                         exit( 1 );
81                 }
82                 li->li_dbcachesize = atoi( argv[1] );
83
84         /* no write sync */
85         } else if ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) {
86                 li->li_dbcachewsync = 0;
87
88         /* anything else */
89         } else {
90                 fprintf( stderr,
91 "%s: line %d: unknown directive \"%s\" in ldbm database definition (ignored)\n",
92                     fname, lineno, argv[0] );
93         }
94 }