1 /* config.c - ldbm backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2006 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 ) {
81 fprintf( stderr, "%s: line %d: extra junk "
82 "after \"index <attr> [pres,eq,approx,sub]\" line.\n",
86 rc = attr_index_config( li, fname, lineno, argc - 1, &argv[1] );
88 if( rc != LDAP_SUCCESS ) return 1;
90 /* size of the cache in entries */
91 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
94 "%s: line %d: missing size in \"cachesize <size>\" line\n",
98 if ( lutil_atoi( &li->li_cache.c_maxsize, argv[1] ) != 0 ) {
100 "%s: line %d: unable to parse cachesize \"%s\"\n",
101 fname, lineno, argv[1] );
105 /* size of each dbcache in bytes */
106 } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) {
109 "%s: line %d: missing size in \"dbcachesize <size>\" line\n",
113 if ( lutil_atoi( &li->li_dbcachesize, argv[1] ) ) {
115 "%s: line %d: unable to parse dbcachesize \"%s\"\n",
116 fname, lineno, argv[1] );
120 /* no locking (not safe) */
121 } else if ( strcasecmp( argv[0], "dbnolocking" ) == 0 ) {
122 li->li_dblocking = 0;
124 /* no write sync (not safe) */
125 } else if ( ( strcasecmp( argv[0], "dbnosync" ) == 0 )
126 || ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) )
128 li->li_dbwritesync = 0;
130 /* run sync thread */
131 } else if ( strcasecmp( argv[0], "dbsync" ) == 0 ) {
135 Debug( LDAP_DEBUG_ANY,
136 "%s: line %d: missing frquency value in \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
141 if ( lutil_atoi( &i, argv[1] ) != 0 || i < 0 ) {
142 Debug( LDAP_DEBUG_ANY,
143 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
148 li->li_dbsyncfreq = i;
151 if ( lutil_atoi( &i, argv[2] ) != 0 || i < 0 ) {
152 Debug( LDAP_DEBUG_ANY,
153 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
157 li ->li_dbsyncwaitn = i;
161 if ( lutil_atoi( &i, argv[3] ) != 0 || i <= 0 ) {
162 Debug( LDAP_DEBUG_ANY,
163 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
167 li ->li_dbsyncwaitinterval = i;
170 /* turn off writesync when sync policy is in place */
171 li->li_dbwritesync = 0;
174 Debug( LDAP_DEBUG_ANY,
175 "\"dbsync\" policies not supported in non-threaded environments\n", 0, 0, 0);
182 return SLAP_CONF_UNKNOWN;