]> git.sur5r.net Git - openldap/commitdiff
Add minimal config support
authorKurt Zeilenga <kurt@openldap.org>
Mon, 25 Sep 2000 21:10:21 +0000 (21:10 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 25 Sep 2000 21:10:21 +0000 (21:10 +0000)
servers/slapd/back-bdb/Makefile.in
servers/slapd/back-bdb/backbdb.dsp
servers/slapd/back-bdb/config.c [new file with mode: 0644]
servers/slapd/back-bdb/external.h
servers/slapd/back-bdb/init.c

index 646183ec6c9ef1ae58d037807b72111190fe085e..cbcd68b5be437089fb59233857b03ffee5d75f10 100644 (file)
@@ -1,9 +1,9 @@
 # $OpenLDAP$
 
-SRCS = init.c tools.c \
+SRCS = init.c tools.c config.c \
        add.c compare.c delete.c search.c \
        dn2entry.lo dn2id.c error.c id2entry.c idl.c nextid.c
-OBJS = init.lo tools.lo \
+OBJS = init.lo tools.lo config.lo \
        add.lo compare.lo delete.lo search.lo \
        dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo
 
index 3543e5e5a5b09f1ae0c03232fa089525daa2511a..b07b71385b257666bc27bd276e7bb166249986e4 100644 (file)
@@ -139,6 +139,10 @@ SOURCE=.\compare.c
 # End Source File
 # Begin Source File
 
+SOURCE=.\config.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\delete.c
 # End Source File
 # Begin Source File
diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c
new file mode 100644 (file)
index 0000000..7ac348c
--- /dev/null
@@ -0,0 +1,83 @@
+/* config.c - ldbm backend configuration file routine */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/string.h>
+
+#include "back-bdb.h"
+
+int
+bdb_db_config(
+    Backend    *be,
+    const char *fname,
+    int                lineno,
+    int                argc,
+    char       **argv )
+{
+       struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+
+       if ( bdb == NULL ) {
+               fprintf( stderr, "%s: line %d: "
+                       "bdb database info is null!\n",
+                   fname, lineno );
+               return 1;
+       }
+
+       /* directory is the DB_HOME */
+       if ( strcasecmp( argv[0], "directory" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr, "%s: line %d: "
+                               "missing dir in \"directory <dir>\" line\n",
+                           fname, lineno );
+                       return 1;
+               }
+               if ( bdb->bi_dbenv_home ) {
+                       free( bdb->bi_dbenv_home );
+               }
+               bdb->bi_dbenv_home = ch_strdup( argv[1] );
+
+       /* mode with which to create new database files */
+       } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
+               if ( argc < 2 ) {
+                       fprintf( stderr, "%s: line %d: "
+                               "missing mode in \"mode <mode>\" line\n",
+                           fname, lineno );
+                       return 1;
+               }
+               bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
+
+#if 0
+       /* attribute to index */
+       } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
+               int rc;
+               if ( argc < 2 ) {
+                       fprintf( stderr, "%s: line %d: "
+                               "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
+                           fname, lineno );
+                       return 1;
+               } else if ( argc > 3 ) {
+                       fprintf( stderr, "%s: line %d: "
+                               "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
+                               "line (ignored)\n",
+                           fname, lineno );
+               }
+               rc = attr_index_config( li, fname, lineno, argc - 1, &argv[1] );
+
+               if( rc != LDAP_SUCCESS ) return 1;
+#endif
+
+       /* anything else */
+       } else {
+               fprintf( stderr, "%s: line %d: "
+                       "unknown directive \"%s\" in bdb database definition (ignored)\n",
+                   fname, lineno, argv[0] );
+       }
+
+       return 0;
+}
index 1adee5d1a55c1097365f59f362362aa505f7807c..6b721685de1e6ebfbe08972fb8c6677157bfeb57 100644 (file)
@@ -11,6 +11,10 @@ LDAP_BEGIN_DECL
 
 extern int     bdb_initialize LDAP_P(( BackendInfo *bi ));
 
+extern int     bdb_db_config LDAP_P(( BackendDB *bd,
+       const char *fname, int lineno,
+       int argc, char **argv ));
+
 extern int     bdb_add LDAP_P(( BackendDB *bd,
        Connection *conn, Operation *op, Entry *e ));
 
index 32c44b06b5ed5e232d9a7ecef93e4c16a52347f1..046a060900d238cec3ebfefa43702e024bc73290 100644 (file)
@@ -269,7 +269,7 @@ bdb_initialize(
        bi->bi_destroy = bdb_destroy;
 
        bi->bi_db_init = bdb_db_init;
-       bi->bi_db_config = 0;
+       bi->bi_db_config = bdb_db_config;
        bi->bi_db_open = bdb_db_open;
        bi->bi_db_close = bdb_db_close;
        bi->bi_db_destroy = bdb_db_destroy;