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