1 /* config.c - ldbm backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2005 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
21 #include <ac/socket.h>
22 #include <ac/string.h>
25 #include "back-ldbm.h"
38 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
41 fprintf( stderr, "%s: line %d: ldbm database info is null!\n",
46 /* directory where database files live */
47 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
50 "%s: line %d: missing dir in \"directory <dir>\" line\n",
54 if ( li->li_directory )
55 free( li->li_directory );
56 li->li_directory = ch_strdup( argv[1] );
58 /* mode with which to create new database files */
59 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
62 "%s: line %d: missing mode in \"mode <mode>\" line\n",
66 if ( lutil_atoix( &li->li_mode, argv[1], 0 ) != 0 ) {
68 "%s: line %d: unable to parse mode=\"%s\" in \"mode <mode>\" line\n",
69 fname, lineno, argv[1] );
73 /* attribute to index */
74 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
77 "%s: line %d: missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
80 } else if ( argc > 3 ) {
82 "%s: line %d: extra junk after \"index <attr> [pres,eq,approx,sub]\" line" SLAPD_CONF_UNKNOWN_IGNORED ".\n",
84 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
86 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
88 rc = attr_index_config( li, fname, lineno, argc - 1, &argv[1] );
90 if( rc != LDAP_SUCCESS ) return 1;
92 /* size of the cache in entries */
93 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
96 "%s: line %d: missing size in \"cachesize <size>\" line\n",
100 if ( lutil_atoi( &li->li_cache.c_maxsize, argv[1] ) != 0 ) {
102 "%s: line %d: unable to parse cachesize \"%s\"\n",
103 fname, lineno, argv[1] );
107 /* size of each dbcache in bytes */
108 } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) {
111 "%s: line %d: missing size in \"dbcachesize <size>\" line\n",
115 if ( lutil_atoi( &li->li_dbcachesize, argv[1] ) ) {
117 "%s: line %d: unable to parse dbcachesize \"%s\"\n",
118 fname, lineno, argv[1] );
122 /* no locking (not safe) */
123 } else if ( strcasecmp( argv[0], "dbnolocking" ) == 0 ) {
124 li->li_dblocking = 0;
126 /* no write sync (not safe) */
127 } else if ( ( strcasecmp( argv[0], "dbnosync" ) == 0 )
128 || ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) )
130 li->li_dbwritesync = 0;
132 /* run sync thread */
133 } else if ( strcasecmp( argv[0], "dbsync" ) == 0 ) {
137 Debug( LDAP_DEBUG_ANY,
138 "%s: line %d: missing frquency value in \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
143 if ( lutil_atoi( &i, argv[1] ) != 0 || i < 0 ) {
144 Debug( LDAP_DEBUG_ANY,
145 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
150 li->li_dbsyncfreq = i;
153 if ( lutil_atoi( &i, argv[2] ) != 0 || i < 0 ) {
154 Debug( LDAP_DEBUG_ANY,
155 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
159 li ->li_dbsyncwaitn = i;
163 if ( lutil_atoi( &i, argv[3] ) != 0 || i <= 0 ) {
164 Debug( LDAP_DEBUG_ANY,
165 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
169 li ->li_dbsyncwaitinterval = i;
172 /* turn off writesync when sync policy is in place */
173 li->li_dbwritesync = 0;
176 Debug( LDAP_DEBUG_ANY,
177 "\"dbsync\" policies not supported in non-threaded environments\n", 0, 0, 0);
184 return SLAP_CONF_UNKNOWN;