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