1 /* config.c - ldbm backend configuration file routine */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
16 #include "back-ldbm.h"
28 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
31 fprintf( stderr, "%s: line %d: ldbm database info is null!\n",
36 /* directory where database files live */
37 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
40 "%s: line %d: missing dir in \"directory <dir>\" line\n",
44 if ( li->li_directory )
45 free( li->li_directory );
46 li->li_directory = ch_strdup( argv[1] );
48 /* mode with which to create new database files */
49 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
52 "%s: line %d: missing mode in \"mode <mode>\" line\n",
56 li->li_mode = strtol( argv[1], NULL, 0 );
58 /* attribute to index */
59 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
62 "%s: line %d: missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
65 } else if ( argc > 3 ) {
67 "%s: line %d: extra junk after \"index <attr> [pres,eq,approx,sub]\" line (ignored)\n",
70 rc = attr_index_config( li, fname, lineno, argc - 1, &argv[1] );
72 if( rc != LDAP_SUCCESS ) return 1;
74 /* size of the cache in entries */
75 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
78 "%s: line %d: missing size in \"cachesize <size>\" line\n",
82 li->li_cache.c_maxsize = atoi( argv[1] );
84 /* size of each dbcache in bytes */
85 } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) {
88 "%s: line %d: missing size in \"dbcachesize <size>\" line\n",
92 li->li_dbcachesize = atoi( argv[1] );
94 /* no locking (not safe) */
95 } else if ( strcasecmp( argv[0], "dbnolocking" ) == 0 ) {
98 /* no write sync (not safe) */
99 } else if ( ( strcasecmp( argv[0], "dbnosync" ) == 0 )
100 || ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) )
102 li->li_dbwritesync = 0;
104 /* run sync thread */
105 } else if ( strcasecmp( argv[0], "dbsync" ) == 0 ) {
110 LDAP_LOG ( CONFIG, ERR, "ldbm_back_db_config: %s: "
111 "line %d: missing frequency value in \"dbsync <frequency> "
112 "[<wait-times> [wait-interval]]\" line\n", fname, lineno, 0 );
114 Debug( LDAP_DEBUG_ANY,
115 "%s: line %d: missing frquency value in \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
125 LDAP_LOG ( CONFIG, ERR,
126 "ldbm_back_db_config: %s: "
127 "line %d: frequency value (%d) invalid \"dbsync "
128 "<frequency> [<wait-times> [wait-interval]]\" line\n",
131 Debug( LDAP_DEBUG_ANY,
132 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
138 li->li_dbsyncfreq = i;
144 LDAP_LOG ( CONFIG,ERR, "ldbm_back_db_config: %s: "
145 "line %d: frequency value (%d) invalid \"dbsync "
146 "<frequency> [<wait-times> [wait-interval]]\" line\n",
149 Debug( LDAP_DEBUG_ANY,
150 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
155 li ->li_dbsyncwaitn = i;
162 LDAP_LOG ( CONFIG,ERR, "ldbm_back_db_config: %s: "
163 "line %d: frequency value (%d) invalid \"dbsync "
164 "<frequency> [<wait-times> [wait-interval]]\" line\n",
167 Debug( LDAP_DEBUG_ANY,
168 "%s: line %d: frquency value (%d) invalid \"dbsync <frequency> [<wait-times> [wait-interval]]\" line\n",
173 li ->li_dbsyncwaitinterval = i;
176 /* turn off writesync when sync policy is in place */
177 li->li_dbwritesync = 0;
181 LDAP_LOG ( CONFIG, ERR, "ldbm_back_db_config: \"dbsync\""
182 " policies not supported in non-threaded environments\n", 0, 0, 0 );
184 Debug( LDAP_DEBUG_ANY,
185 "\"dbsync\" policies not supported in non-threaded environments\n", 0, 0, 0);
194 "%s: line %d: unknown directive \"%s\" in ldbm database definition (ignored)\n",
195 fname, lineno, argv[0] );