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