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