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