]> git.sur5r.net Git - openldap/commitdiff
New dn2id format with base/one/subtree indices (ldbm/bdb2)
authorKurt Zeilenga <kurt@openldap.org>
Tue, 17 Aug 1999 19:00:59 +0000 (19:00 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 17 Aug 1999 19:00:59 +0000 (19:00 +0000)
New id2entry (id-less) format (ldbm/bdb2)
Removed id2children (ldbm/bdb2)
Added nextid database (ldbm)
Broke ldbmtest
Removed ldif2* tools (ldbm/bdb2)
Added slap tools (slapadd, slapcat, slapindex)

111 files changed:
build/main.dsw
include/ldbm.h
include/ldif.h
include/lutil.h
libraries/libldbm/ldbm.c
libraries/libldif/line64.c
libraries/liblutil/Makefile.in
libraries/liblutil/base64.c
libraries/liblutil/debug.c
libraries/liblutil/getopt.c
libraries/liblutil/getpass.c
libraries/liblutil/liblutil.dsp
libraries/liblutil/md5.c
libraries/liblutil/ntservice.c
libraries/liblutil/passwd.c
libraries/liblutil/sha1.c
libraries/liblutil/utils.c [new file with mode: 0644]
servers/slapd/back-bdb2/Makefile.in
servers/slapd/back-bdb2/add.c
servers/slapd/back-bdb2/back-bdb2.h
servers/slapd/back-bdb2/close.c
servers/slapd/back-bdb2/dbcache.c
servers/slapd/back-bdb2/delete.c
servers/slapd/back-bdb2/dn2id.c
servers/slapd/back-bdb2/external.h
servers/slapd/back-bdb2/filterindex.c
servers/slapd/back-bdb2/id2children.c
servers/slapd/back-bdb2/id2entry.c
servers/slapd/back-bdb2/idl.c
servers/slapd/back-bdb2/index.c
servers/slapd/back-bdb2/init.c
servers/slapd/back-bdb2/modify.c
servers/slapd/back-bdb2/nextid.c
servers/slapd/back-bdb2/porter.c
servers/slapd/back-bdb2/proto-back-bdb2.h
servers/slapd/back-bdb2/search.c
servers/slapd/back-bdb2/tools.c [new file with mode: 0644]
servers/slapd/back-bdb2/txn.c
servers/slapd/back-bdb2/txn.h
servers/slapd/back-ldbm/Makefile.in
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/backldbm.dsp
servers/slapd/back-ldbm/close.c
servers/slapd/back-ldbm/config.c
servers/slapd/back-ldbm/dbcache.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/external.h
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/id2children.c
servers/slapd/back-ldbm/id2entry.c
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/index.c
servers/slapd/back-ldbm/init.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/nextid.c
servers/slapd/back-ldbm/proto-back-ldbm.h
servers/slapd/back-ldbm/search.c
servers/slapd/back-ldbm/tools.c [new file with mode: 0644]
servers/slapd/back-perl/add.c
servers/slapd/back-shell/add.c
servers/slapd/back-tcl/tcl_util.c
servers/slapd/backend.c
servers/slapd/entry.c
servers/slapd/init.c
servers/slapd/main.c
servers/slapd/proto-slap.h
servers/slapd/repl.c
servers/slapd/slap.h
servers/slapd/tools/Makefile.in
servers/slapd/tools/centipede.c
servers/slapd/tools/ldbmcat.c [deleted file]
servers/slapd/tools/ldbmcat.dsp [deleted file]
servers/slapd/tools/ldbmcat.dsw [deleted file]
servers/slapd/tools/ldbmtest.c
servers/slapd/tools/ldbmtest.dsp
servers/slapd/tools/ldif2common.c [deleted file]
servers/slapd/tools/ldif2common.h [deleted file]
servers/slapd/tools/ldif2id2children-bdb2.c [deleted file]
servers/slapd/tools/ldif2id2children.c [deleted file]
servers/slapd/tools/ldif2id2children.dsp [deleted file]
servers/slapd/tools/ldif2id2entry-bdb2.c [deleted file]
servers/slapd/tools/ldif2id2entry.c [deleted file]
servers/slapd/tools/ldif2id2entry.dsp [deleted file]
servers/slapd/tools/ldif2index-bdb2.c [deleted file]
servers/slapd/tools/ldif2index.c [deleted file]
servers/slapd/tools/ldif2index.dsp [deleted file]
servers/slapd/tools/ldif2ldbm-bdb2.c [deleted file]
servers/slapd/tools/ldif2ldbm.c [deleted file]
servers/slapd/tools/ldif2ldbm.dsp [deleted file]
servers/slapd/tools/sizecount.c
servers/slapd/tools/slapadd.c [new file with mode: 0644]
servers/slapd/tools/slapadd.dsp [new file with mode: 0644]
servers/slapd/tools/slapcat.c [new file with mode: 0644]
servers/slapd/tools/slapcat.dsp [new file with mode: 0644]
servers/slapd/tools/slapcommon.c [new file with mode: 0644]
servers/slapd/tools/slapcommon.h [new file with mode: 0644]
servers/slapd/tools/slapindex.c [new file with mode: 0644]
servers/slapd/tools/slapindex.dsp [new file with mode: 0644]
tests/scripts/defines.sh
tests/scripts/makeldbm.sh
tests/scripts/startup_nis_ldap_server.sh
tests/scripts/test001-ldif2ldbm
tests/scripts/test001-slapadd
tests/scripts/test003-search
tests/scripts/test004-modify
tests/scripts/test005-modrdn
tests/scripts/test006-acls
tests/scripts/test008-concurrency
tests/scripts/test009-referral

index 2b8c9582c28f20fb80bebb9a6fc896f6c9284721..bfe89b0ef0116bcc15c61a0b8d4b9ec3d5878c2e 100644 (file)
@@ -87,34 +87,46 @@ Package=<4>
     Project_Dep_Name ldapsearch
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name ldbmcat
-    End Project Dependency
-    Begin Project Dependency
     Project_Dep_Name ldbmtest
     End Project Dependency
     Begin Project Dependency
     Project_Dep_Name ldif
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name ldif2id2children
+    Project_Dep_Name testavl
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name ldif2id2entry
+    Project_Dep_Name ud
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name ldif2index
+    Project_Dep_Name slapcat
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name ldif2ldbm
+    Project_Dep_Name slapadd
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name slapindex
     End Project Dependency
     Begin Project Dependency
     Project_Dep_Name slapd
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name testavl
+    Project_Dep_Name ldbmcat
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name ud
+    Project_Dep_Name ldif2ldbm
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name ldbmindex
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name ldbmentry
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name ltest
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name ltest_r
     End Project Dependency
 }}}
 
@@ -291,7 +303,7 @@ Package=<4>
 
 ###############################################################################
 
-Project: "ldbmtest"=..\servers\slapd\tools\ldbmtest.dsp - Package Owner=<4>
+Project: "ldbmentry"=..\servers\slapd\tools\ldbmentry.dsp - Package Owner=<4>
 
 Package=<5>
 {{{
@@ -303,6 +315,9 @@ Package=<4>
     Project_Dep_Name backldbm
     End Project Dependency
     Begin Project Dependency
+    Project_Dep_Name libavl
+    End Project Dependency
+    Begin Project Dependency
     Project_Dep_Name liblber
     End Project Dependency
     Begin Project Dependency
@@ -312,46 +327,19 @@ Package=<4>
     Project_Dep_Name libldbm
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name liblutil
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libslapd
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libavl
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libldif
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "ldif"=..\servers\slapd\tools\ldif.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name liblber
-    End Project Dependency
-    Begin Project Dependency
     Project_Dep_Name libldif
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libldap
+    Project_Dep_Name liblutil
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name liblutil
+    Project_Dep_Name libslapd
     End Project Dependency
 }}}
 
 ###############################################################################
 
-Project: "ldif2id2children"=..\servers\slapd\tools\ldif2id2children.dsp - Package Owner=<4>
+Project: "ldbmindex"=..\servers\slapd\tools\ldbmindex.dsp - Package Owner=<4>
 
 Package=<5>
 {{{
@@ -363,22 +351,22 @@ Package=<4>
     Project_Dep_Name backldbm
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libldap_r
+    Project_Dep_Name libavl
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libldif
+    Project_Dep_Name liblber
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libavl
+    Project_Dep_Name libldap_r
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name liblutil
+    Project_Dep_Name libldbm
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name liblber
+    Project_Dep_Name libldif
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libldbm
+    Project_Dep_Name liblutil
     End Project Dependency
     Begin Project Dependency
     Project_Dep_Name libslapd
@@ -387,7 +375,7 @@ Package=<4>
 
 ###############################################################################
 
-Project: "ldif2id2entry"=..\servers\slapd\tools\ldif2id2entry.dsp - Package Owner=<4>
+Project: "ldbmtest"=..\servers\slapd\tools\ldbmtest.dsp - Package Owner=<4>
 
 Package=<5>
 {{{
@@ -399,31 +387,31 @@ Package=<4>
     Project_Dep_Name backldbm
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libavl
+    Project_Dep_Name liblber
     End Project Dependency
     Begin Project Dependency
     Project_Dep_Name libldap_r
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libldif
+    Project_Dep_Name libldbm
     End Project Dependency
     Begin Project Dependency
     Project_Dep_Name liblutil
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name liblber
+    Project_Dep_Name libslapd
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libldbm
+    Project_Dep_Name libavl
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libslapd
+    Project_Dep_Name libldif
     End Project Dependency
 }}}
 
 ###############################################################################
 
-Project: "ldif2index"=..\servers\slapd\tools\ldif2index.dsp - Package Owner=<4>
+Project: "ldif"=..\servers\slapd\tools\ldif.dsp - Package Owner=<4>
 
 Package=<5>
 {{{
@@ -432,28 +420,16 @@ Package=<5>
 Package=<4>
 {{{
     Begin Project Dependency
-    Project_Dep_Name backldbm
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libldap_r
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libavl
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name liblutil
+    Project_Dep_Name liblber
     End Project Dependency
     Begin Project Dependency
     Project_Dep_Name libldif
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name liblber
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libldbm
+    Project_Dep_Name libldap
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name libslapd
+    Project_Dep_Name liblutil
     End Project Dependency
 }}}
 
@@ -645,6 +621,78 @@ Package=<4>
 
 ###############################################################################
 
+Project: "slapadd"=..\servers\slapd\tools\slapadd.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name backldbm
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libavl
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblber
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldap_r
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldbm
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldif
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblutil
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libslapd
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "slapcat"=..\servers\slapd\tools\slapcat.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name libavl
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblber
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldap_r
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldbm
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldif
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblutil
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libslapd
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name backldbm
+    End Project Dependency
+}}}
+
+###############################################################################
+
 Project: "slapd"=..\servers\slapd\slapd.dsp - Package Owner=<4>
 
 Package=<5>
@@ -684,6 +732,42 @@ Package=<4>
 
 ###############################################################################
 
+Project: "slapindex"=..\servers\slapd\tools\slapindex.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name backldbm
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libavl
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblber
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldap_r
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldbm
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldif
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblutil
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libslapd
+    End Project Dependency
+}}}
+
+###############################################################################
+
 Project: "testavl"=..\libraries\libavl\testavl.dsp - Package Owner=<4>
 
 Package=<5>
index 876b7c60efada58494843c28d64489f496f76064..10f9b3b44de3723da8b7c363558cf80fb4a4b8a6 100644 (file)
@@ -49,23 +49,26 @@ typedef DBT Datum;
 
 typedef DB     *LDBM;
 
-LDAP_END_DECL
 
 #define DB_TYPE                DB_BTREE
 
 /* for ldbm_open */
 #ifdef HAVE_BERKELEY_DB2
+typedef DBC    LDBMCursor;
 #      define LDBM_READER      DB_RDONLY
 #      define LDBM_WRITER      0x00000      /* hopefully */
 #      define LDBM_WRCREAT     (DB_NOMMAP|DB_CREATE|DB_THREAD)
 #      define LDBM_NEWDB       (DB_TRUNCATE|DB_CREATE|DB_THREAD)
 #else
+typedef int LDBMCursor;
 #      define LDBM_READER      O_RDONLY
 #      define LDBM_WRITER      O_RDWR
 #      define LDBM_WRCREAT     (O_RDWR|O_CREAT)
 #      define LDBM_NEWDB       (O_RDWR|O_TRUNC|O_CREAT)
 #endif
 
+LDAP_END_DECL
+
 #  define LDBM_FAST    0
 
 #define LDBM_SUFFIX    ".dbb"
@@ -110,17 +113,17 @@ typedef DBT       Datum;
 
 typedef DB     *LDBM;
 
-LDAP_END_DECL
-
 #define DB_TYPE                DB_HASH
 
 /* for ldbm_open */
 #ifdef LDBM_USE_DB2
+typedef DBC    LDBMCursor;
 #      define LDBM_READER      DB_RDONLY
 #      define LDBM_WRITER      0x00000      /* hopefully */
 #      define LDBM_WRCREAT     (DB_NOMMAP|DB_CREATE|DB_THREAD)
 #      define LDBM_NEWDB       (DB_TRUNCATE|DB_CREATE|DB_THREAD)
 #else
+typedef int LDBMCursor;
 #      define LDBM_READER      O_RDONLY
 #      define LDBM_WRITER      O_RDWR
 #      define LDBM_WRCREAT     (O_RDWR|O_CREAT)
@@ -128,6 +131,8 @@ LDAP_END_DECL
 #      define LDBM_FAST        0
 #endif
 
+LDAP_END_DECL
+
 #define LDBM_SUFFIX    ".dbh"
 
 /* for ldbm_insert */
@@ -148,7 +153,7 @@ LDAP_END_DECL
 LDAP_BEGIN_DECL
 
 typedef datum          Datum;
-
+typedef int LDBMCursor;
 typedef GDBM_FILE      LDBM;
 
 extern gdbm_error      gdbm_errno;
@@ -182,6 +187,7 @@ LDAP_END_DECL
 LDAP_BEGIN_DECL
 
 typedef datum          Datum;
+typedef int LDBMCursor;
 typedef MDBM           *LDBM;
 
 LDAP_END_DECL
@@ -222,7 +228,7 @@ LDAP_END_DECL
 LDAP_BEGIN_DECL
 
 typedef datum  Datum;
-
+typedef int LDBMCursor;
 typedef DBM    *LDBM;
 
 LDAP_END_DECL
@@ -258,18 +264,12 @@ Datum     ldbm_fetch( LDBM ldbm, Datum key );
 int    ldbm_store( LDBM ldbm, Datum key, Datum data, int flags );
 int    ldbm_delete( LDBM ldbm, Datum key );
 
-#if HAVE_BERKELEY_DB2
-       void   *ldbm_malloc( size_t size );
-       Datum   ldbm_firstkey( LDBM ldbm, DBC **dbch );
-       Datum   ldbm_nextkey( LDBM ldbm, Datum key, DBC *dbcp );
-#else
-       Datum   ldbm_firstkey( LDBM ldbm );
-       Datum   ldbm_nextkey( LDBM ldbm, Datum key );
-#endif
-
+Datum  ldbm_firstkey( LDBM ldbm, LDBMCursor **cursor );
+Datum  ldbm_nextkey( LDBM ldbm, Datum key, LDBMCursor *cursor );
 
 /* initialization of Datum structures */
 #ifdef HAVE_BERKELEY_DB2
+       void   *ldbm_malloc( size_t size );
 #   define ldbm_datum_init(d) ((void)memset(&(d), 0, sizeof(Datum)))
 #else
 #   define ldbm_datum_init(d) ((void)0)
index a28dd3044fe635abe657ada6cb6e48297a6d2f29..901fb58e7083a39adfbc0a612078e25c0d933f9b 100644 (file)
@@ -64,6 +64,14 @@ ldif_fetch_url LDAP_P((
 LDAP_F( char * )
 ldif_getline LDAP_P(( char **next ));
 
+LDAP_F( int )
+ldif_read_record LDAP_P((
+       FILE *fp,
+       int *lineno,
+       char **bufp,
+       int *buflen ));
+
+
 #define LDIF_PUT_NOVALUE       0x0000  /* no value */
 #define LDIF_PUT_VALUE         0x0001  /* value w/ auto detection */
 #define LDIF_PUT_TEXT          0x0002  /* assume text */
index 7a607b11ba0ce4023fe1ba2a42397a3fa3fa1e0b..d7eb530fcd3e91dfb1db7343649e72f527b7c796 100644 (file)
@@ -47,6 +47,14 @@ lutil_passwd LDAP_P((
        const char *passwd,
        const char **methods ));
 
+/* utils.c */
+LDAP_F( char* )
+lutil_progname LDAP_P((
+       const char* name,
+       int argc,
+       char *argv[] ));
+
+
 LDAP_END_DECL
 
 #endif /* _LUTIL_H */
index 3cfebe7912409f99d68b4d58cdd4aa969a5d4b52..e9091a9a106af873a9a8b3eb210336f27897b164 100644 (file)
@@ -314,16 +314,12 @@ ldbm_delete( LDBM ldbm, Datum key )
 }
 
 Datum
-#ifdef HAVE_BERKELEY_DB2
-ldbm_firstkey( LDBM ldbm, DBC **dbch )
-#else
-ldbm_firstkey( LDBM ldbm )
-#endif
+ldbm_firstkey( LDBM ldbm, LDBMCursor **dbch )
 {
        Datum   key, data;
 
 #ifdef HAVE_BERKELEY_DB2
-       DBC  *dbci;
+       LDBMCursor  *dbci;
 
        ldbm_datum_init( key );
        ldbm_datum_init( data );
@@ -375,11 +371,7 @@ ldbm_firstkey( LDBM ldbm )
 }
 
 Datum
-#ifdef HAVE_BERKELEY_DB2
-ldbm_nextkey( LDBM ldbm, Datum key, DBC *dbcp )
-#else
-ldbm_nextkey( LDBM ldbm, Datum key )
-#endif
+ldbm_nextkey( LDBM ldbm, Datum key, LDBMCursor *dbcp )
 {
        Datum   data;
 
@@ -518,7 +510,7 @@ ldbm_delete( LDBM ldbm, Datum key )
 }
 
 Datum
-ldbm_firstkey( LDBM ldbm )
+ldbm_firstkey( LDBM ldbm, LDBMCursor **dbcp )
 {
        Datum d;
 
@@ -530,7 +522,7 @@ ldbm_firstkey( LDBM ldbm )
 }
 
 Datum
-ldbm_nextkey( LDBM ldbm, Datum key )
+ldbm_nextkey( LDBM ldbm, Datum key, LDBMCursor *dbcp )
 {
        Datum d;
 
@@ -629,7 +621,7 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
 
        return( db );
 
-}/* LDBM ldbm_open() */
+}
 
 
 
@@ -655,7 +647,7 @@ ldbm_close( LDBM ldbm )
        fflush( stdout );
 #endif
 
-}/* void ldbm_close() */
+}
 
 
 
@@ -672,7 +664,7 @@ ldbm_sync( LDBM ldbm )
        mdbm_sync( ldbm );
         LDBM_UNLOCK;
 
-}/* void ldbm_sync() */
+}
 
 
 #define MAX_MDBM_RETRY 5
@@ -739,7 +731,7 @@ ldbm_fetch( LDBM ldbm, Datum key )
 
        return d;
 
-}/* Datum ldbm_fetch() */
+}
 
 
 
@@ -786,8 +778,7 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags )
 
        return( rc );
 
-}/* int ldbm_store() */
-
+}
 
 
 
@@ -817,7 +808,7 @@ ldbm_delete( LDBM ldbm, Datum key )
 
        return( rc );
 
-}/* int ldbm_delete() */
+}
 
 
 
@@ -872,24 +863,24 @@ ldbm_get_next( LDBM ldbm, kvpair (*fptr)(MDBM *, kvpair) )
 
        return ret;
 
-}/* static Datum ldbm_get_next() */
+}
 
 
 
 
 Datum
-ldbm_firstkey( LDBM ldbm )
+ldbm_firstkey( LDBM ldbm, LDBMCursor **dbcp )
 {
 
        return ldbm_get_next( ldbm, mdbm_first );
 
-}/* Datum ldbm_firstkey() */
+}
 
 
 
 
 Datum
-ldbm_nextkey( LDBM ldbm, Datum key )
+ldbm_nextkey( LDBM ldbm, Datum key, LDBMCursor *dbcp )
 {
 
        /* XXX:
@@ -899,7 +890,7 @@ ldbm_nextkey( LDBM ldbm, Datum key )
 
        return ldbm_get_next( ldbm, mdbm_next );
 
-}/* Datum ldbm_nextkey() */
+}
 
 int
 ldbm_errno( LDBM ldbm )
@@ -907,7 +898,7 @@ ldbm_errno( LDBM ldbm )
        /* XXX: best we can do with current  mdbm interface */
        return( errno );
 
-}/* int ldbm_errno() */
+}
 
 
 
@@ -985,7 +976,7 @@ ldbm_delete( LDBM ldbm, Datum key )
 }
 
 Datum
-ldbm_firstkey( LDBM ldbm )
+ldbm_firstkey( LDBM ldbm, LDBMCursor **dbcp )
 {
        Datum d;
 
@@ -997,7 +988,7 @@ ldbm_firstkey( LDBM ldbm )
 }
 
 Datum
-ldbm_nextkey( LDBM ldbm, Datum key )
+ldbm_nextkey( LDBM ldbm, Datum key, LDBMCursor *dbcp )
 {
        Datum d;
 
index aef935b755c5c9f76c14d5e68da9203607dcebb5..fa39ce6ae5051c9e91d500849b295ce943d7abf7 100644 (file)
@@ -534,3 +534,62 @@ int ldif_is_not_printable(
 
        return 1;
 }
+
+/*
+ * slap_read_ldif - read an ldif record.  Return 1 for success, 0 for EOF.
+ */
+int
+ldif_read_record(
+       FILE        *fp,
+       int         *lno,               /* ptr to line number counter              */
+       char        **bufp,     /* ptr to malloced output buffer           */
+       int         *buflenp )  /* ptr to length of *bufp                  */
+{
+       char        linebuf[BUFSIZ], *line;
+       ber_len_t   lcur = 0, len, linesize;
+       int         last_ch = '\n', found_entry = 0, stop;
+
+       line     = linebuf;
+       linesize = sizeof( linebuf );
+
+       for ( stop = feof( fp );  !stop;  last_ch = line[len-1] ) {
+               if ( fgets( line, linesize, fp ) == NULL ) {
+                       stop = 1;
+                       /* Add \n in case the file does not end with newline */
+                       line = "\n";
+               }
+               len = strlen( line );
+
+               if ( last_ch == '\n' ) {
+                       (*lno)++;
+
+                       if ( line[0] == '\n' ) {
+                               if ( !found_entry )
+                                       continue;
+                               break;
+                       }
+
+                       if ( !found_entry ) {
+                               /* Found a new entry */
+                               found_entry = 1;
+
+                               if ( isdigit( (unsigned char) line[0] ) ) {
+                                       /* skip index */
+                                       continue;
+                               }
+                       }                       
+               }
+
+               if ( *buflenp - lcur <= len ) {
+                       char *nbufp = ber_memrealloc( *bufp, *buflenp += len + BUFSIZ );
+                       if( nbufp == NULL ) {
+                               return 0;
+                       }
+                       *bufp = nbufp;
+               }
+               strcpy( *bufp + lcur, line );
+               lcur += len;
+       }
+
+       return( found_entry );
+}
\ No newline at end of file
index b5932cc985e25417c7272b811d68c2d7736f4ea7..189f2f66236215fd377ecee626d12f9688ebcd20 100644 (file)
@@ -3,8 +3,10 @@
 ##
 
 LIBRARY        = liblutil.a
-SRCS   = base64.c debug.c detach.c md5.c passwd.c sha1.c getpass.c lockf.c
-OBJS   = base64.o debug.o detach.o md5.o passwd.o sha1.o getpass.o lockf.o \
+SRCS   = base64.c debug.c detach.c \
+       md5.c passwd.c sha1.c getpass.c lockf.c utils.c
+OBJS   = base64.o debug.o detach.o \
+       md5.o passwd.o sha1.o getpass.o lockf.o utils.o \
        @LIBOBJS@
 
 LDAP_INCDIR= ../../include       
index 2a29a1dea0498cbaaaf9427c84d0b15a9ac22c83..e837088347682ce3af7926b9497bc5ed3c7b1f34 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * Modified by Kurt D. Zeilenga for inclusion into OpenLDAP
  */
index d6bb4f836f33f0cda7350fce4e5494e29b06f32f..f6b9979060b6de9572387ede8446075400c6018c 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * Copyright (c) 1996, 1998 by Internet Software Consortium.
  *
index c69bd17aa194c6fdcfd29d1a9abfa02e693a1681..2294dcf519dfc69cbf7ab741ddfb8c002de82b45 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
        getopt.c
 
index 30c632d56249d32fb0022aab52c35f61b7c00297..6efd3f00d4068917e9476740c7b452511c3d0b5d 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * Copyright (c) 1992, 1993  Regents of the University of Michigan.
  * All rights reserved.
index 4ccd716d13ea52f6a828d0680086af062d917fe5..539fc479c09a2dd37bda42c8de9a040a572aed88 100644 (file)
@@ -252,6 +252,10 @@ InputPath=.\slapdmsg.mc
 
 !ENDIF 
 
+# End Source File
+# Begin Source File
+
+SOURCE=.\utils.c
 # End Source File
 # End Target
 # End Project
index 9fbf7e2755962ff04d6f2d2f18a5e47eed845874..0109b1c652e35f981dc41108ebccff0133134618 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * Modified by Kurt D. Zeilenga for inclusion into OpenLDAP
  * I hereby disclaim copyright in any changes I have made; this
index bf6d114b05d80dbbd3a2fd2ce257d2e5ea8bd0da..57ab8c89f950c0ea75af7710be17b037c5ed6fef 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /* ntservice.c */
 #include "portable.h"
 
index cbe5e6fb132dd3ebc8a29058d2068e6f926adc09..8fc16c2a01abcfe77be69fd3dcdb458f9a9dbfb5 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * lutil_password(credentials, password)
  *
index 7b0d9c4aa6f8fca64d634d52992afab6f4206f6e..bdaafda16288b7f88288595ce57709f3f7692562 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*     Acquired from:
  *     $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $       */
 
diff --git a/libraries/liblutil/utils.c b/libraries/liblutil/utils.c
new file mode 100644 (file)
index 0000000..8bd298f
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+
+#include <lutil.h>
+#include <ldap_defaults.h>
+
+char* lutil_progname( const char* name, int argc, char *argv[] )
+{
+       char *progname;
+
+       if(argc == 0) {
+               return strdup( name );
+       }
+
+       progname = strrchr ( argv[0], *LDAP_DIRSEP );
+       progname = strdup( progname ? &progname[1] : argv[0] );
+
+       return progname;
+}
index 97ce09b7ae8706798eac9ba0baad35f8b08a8412..08e30bea3458aa2eedd49126fb03be14351edda4 100644 (file)
@@ -2,12 +2,12 @@ SRCS  = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \
                index.c id2children.c nextid.c abandon.c compare.c group.c \
                modify.c modrdn.c delete.c init.c config.c bind.c attr.c \
                filterindex.c unbind.c kerberos.c close.c alias.c startup.c \
-               timing.c porter.c txn.c
+               timing.c porter.c txn.c tools.c
 OBJS   = idl.lo add.lo search.lo cache.lo dbcache.lo dn2id.lo entry.lo id2entry.lo \
                index.lo id2children.lo nextid.lo abandon.lo compare.lo group.lo \
                modify.lo modrdn.lo delete.lo init.lo config.lo bind.lo attr.lo \
                filterindex.lo unbind.lo kerberos.lo close.lo alias.lo startup.lo \
-               timing.lo porter.lo txn.lo
+               timing.lo porter.lo txn.lo tools.lo
 
 LDAP_INCDIR= ../../../include       
 LDAP_LIBDIR= ../../../libraries
index bb495be727c48cd1d50c0b9c71d80c409c8fd1ae..7324cc2e137b25ce3428b848d72093d9f5f7bde7 100644 (file)
@@ -188,9 +188,6 @@ bdb2i_back_add_internal(
                Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
                    0 );
 
-               /* return the id */
-               bdb2i_next_id_return( be, e->e_id );
-                
                /* free the entry */
                entry_free( e );
 
@@ -203,28 +200,9 @@ bdb2i_back_add_internal(
 
        rc = -1;
 
-       /*
-        * add it to the id2children index for the parent
-        */
-
-       bdb2i_start_timing( be->bd_info, &time1 );
-
-       if ( bdb2i_id2children_add( be, p, e ) != 0 ) {
-               Debug( LDAP_DEBUG_TRACE, "bdb2i_id2children_add failed\n", 0,
-                   0, 0 );
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
-
-               bdb2i_stop_timing( be->bd_info, time1, "ADD-ID2CHILDREN", conn, op );
-
-               goto return_results;
-       }
-
-       bdb2i_stop_timing( be->bd_info, time1, "ADD-ID2CHILDREN", conn, op );
-
        /*
         * Add the entry to the attribute indexes, then add it to
-        * the id2children index, dn2id index, and the id2entry index.
+        * the id2entry and dn2id index.
         */
 
        bdb2i_start_timing( be->bd_info, &time1 );
@@ -317,11 +295,9 @@ bdb2_back_add(
 
        /*  check, if a new default attribute index will be created,
                in which case we have to open the index file BEFORE TP  */
-       switch ( slapMode ) {
+       switch ( slapMode & SLAP_MODE ) {
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        bdb2i_check_default_attr_index_add( li, e );
                        break;
        }
index cfcc4924254406d8b220bb0626d5fa016e0c2404..758318c080772049cc7474f35f362f03a8184034 100644 (file)
@@ -20,11 +20,19 @@ LDAP_BEGIN_DECL
 
 #define SUBLEN                 3
 
+#define DN_BASE_PREFIX         '='
+#define DN_ONE_PREFIX          '@'
+#define DN_SUBTREE_PREFIX      '?'
+    
+#define SLAPD_FILTER_DN_ONE                    ((ber_tag_t) -2)
+#define SLAPD_FILTER_DN_SUBTREE                ((ber_tag_t) -3)
+
+
 #define BDB2_SUFFIX     ".bdb2"
 
 
 /*
- * there is a single index for each attribute.  these prefixes insure
+ * there is a single index for each attribute.  these prefixes ensure
  * that there is no collision among keys.
  */
 #define EQ_PREFIX      '='     /* prefix for equality keys     */
@@ -32,6 +40,10 @@ LDAP_BEGIN_DECL
 #define SUB_PREFIX     '*'     /* prefix for substring keys    */
 #define CONT_PREFIX    '\\'    /* prefix for continuation keys */
 
+/* allow 3 characters per byte + PREFIX + EOS */
+#define CONT_SIZE      ( sizeof(long)*3 + 1 + 1 )
+
+
 #define UNKNOWN_PREFIX '?'     /* prefix for unknown keys    */
 
 #define DEFAULT_BLOCKSIZE      8192
@@ -98,18 +110,19 @@ struct dbcache {
 };
 
 typedef  struct dbcache  BDB2_TXN_FILES;
+typedef  struct dbcache DBCache;
 
 
 /* for the cache of attribute information (which are indexed, etc.) */
 struct attrinfo {
        char    *ai_type;       /* type name (cn, sn, ...)      */
        int     ai_indexmask;   /* how the attr is indexed      */
-#define INDEX_PRESENCE 0x01
-#define INDEX_EQUALITY 0x02
-#define INDEX_APPROX   0x04
-#define INDEX_SUB      0x08
-#define INDEX_UNKNOWN  0x10
-#define INDEX_FROMINIT 0x20
+#define INDEX_PRESENCE 0x0001
+#define INDEX_EQUALITY 0x0002
+#define INDEX_APPROX   0x0004
+#define INDEX_SUB              0x0008
+#define INDEX_UNKNOWN  0x0010
+#define INDEX_FROMINIT 0x1000
        int     ai_syntaxmask;  /* what kind of syntax          */
 /* ...from slap.h...
 #define SYNTAX_CIS      0x01
@@ -119,12 +132,6 @@ struct attrinfo {
 */
 };
 
-/* this could be made an option */
-#ifndef SLAPD_NEXTID_CHUNK
-#define SLAPD_NEXTID_CHUNK     32
-#endif
-
-
 /*  TP stuff  */
 
 typedef  struct _bdb2_txn_head {
@@ -178,9 +185,6 @@ extern DB_ENV       bdb2i_dbEnv;
 /*  the private description of a database  */
 struct ldbminfo {
        ID                      li_nextid;
-#if SLAPD_NEXTID_CHUNK > 1
-       ID                      li_nextid_wrote;
-#endif
        char            *li_nextid_file;
        int                     li_mode;
        char                    *li_directory;
index eafdf164f4b91fc7b01d46378b613fd6b5085975..894e4dfadca9158c88768c6b94363b3c6ad9af9a 100644 (file)
@@ -12,6 +12,7 @@
 static int
 bdb2i_back_db_close_internal( BackendDB *be )
 {
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        DB_LOCK         lock;
 
        /*  since close will probably write the NEXTID file,
@@ -20,8 +21,7 @@ bdb2i_back_db_close_internal( BackendDB *be )
                return( -1 );
        }
 
-       if ( slapMode != SLAP_TOOL_MODE ) {
-
+       if ( li->li_nextid != NOID ) {
                Debug( LDAP_DEBUG_TRACE, "bdb2 backend saving nextid\n", 0, 0, 0 );
                if ( bdb2i_next_id_save( be ) < 0 ) {
                        Debug( LDAP_DEBUG_ANY, "bdb2 backend nextid save failed!\n",
index e220c91dad4c524e16309904aee1dcd532820736..d77e1e772e78e0fe044ae238d5feec61e42e089a 100644 (file)
@@ -28,12 +28,10 @@ bdb2i_cache_open(
 )
 {
        /*  all files are open, so return handle from file cache  */
-       switch ( slapMode ) {
+       switch ( slapMode & SLAP_MODE ) {
 
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        {
                                struct  ldbminfo        *li = (struct ldbminfo *) be->be_private;
                                char    buf[MAXPATHLEN];
@@ -60,12 +58,9 @@ void
 bdb2i_cache_close( BackendDB *be, struct dbcache *db )
 {
        /*  all files stay open until SERVER or TOOL shut down  */
-       switch ( slapMode ) {
-
+       switch ( slapMode & SLAP_MODE ) {
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        return;
 
                default:
@@ -81,12 +76,9 @@ void
 bdb2i_cache_really_close( BackendDB *be, struct dbcache *db )
 {
        /*  all files stay open until SERVER or TOOL shut down  */
-       switch ( slapMode ) {
-
+       switch ( slapMode & SLAP_MODE ) {
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        return;
 
                default:
@@ -102,12 +94,10 @@ void
 bdb2i_cache_flush_all( BackendDB *be )
 {
        /*  if SERVER or TOOL, syncing is done by TP, or during shutdown  */
-       switch ( slapMode ) {
+       switch ( slapMode & SLAP_MODE ) {
 
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        return;
 
                default:
@@ -163,12 +153,12 @@ bdb2i_cache_store(
                flags, 0, 0, 0, 0 );
 #endif /* LDBM_DEBUG */
 
-       if ( slapMode == SLAP_TIMEDSERVER_MODE )
+       if ( slapMode & SLAP_TIMED_MODE )
                bdb2i_uncond_start_timing( &time1 );
 
        rc = bdb2i_db_store( db->dbc_db, key, data, flags );
 
-       if ( slapMode == SLAP_TIMEDSERVER_MODE ) {
+       if ( slapMode & SLAP_TIMED_MODE ) {
                char buf[BUFSIZ];
                char buf2[BUFSIZ];
 
index ca36c2bacff0501616aa555c0be664263ef8c533..d80d2dceb2bf1482ccd7624b873d22289e20a690 100644 (file)
@@ -93,7 +93,7 @@ bdb2i_back_delete_internal(
        }
 #endif
 
-       /* delete from parent's id2children entry */
+       /* find parent's entry */
        if( (pdn = dn_parent( be, e->e_ndn )) != NULL ) {
                if( (p = bdb2i_dn2entry_w( be, pdn, &matched )) == NULL) {
                        Debug( LDAP_DEBUG_TRACE,
@@ -125,15 +125,6 @@ bdb2i_back_delete_internal(
                }
        }
 
-       if ( bdb2i_id2children_remove( be, p, e ) != 0 ) {
-               Debug(LDAP_DEBUG_ARGS,
-                       "<=- bdb2i_back_delete: operations error %s\n",
-                       dn, 0, 0);
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                               NULL, NULL, NULL, NULL );
-               goto return_results;
-       }
-
        /* delete from dn2id mapping */
        if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 0 ) {
                Debug(LDAP_DEBUG_ARGS,
index 35b1081d2bd3862238377c5cca73c56d8f7d4236..b4c17be8fb280a384d17fc8a1954a9766ff55221 100644 (file)
@@ -23,9 +23,6 @@ bdb2i_dn2id_add(
        Datum           key, data;
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
-       ldbm_datum_init( key );
-       ldbm_datum_init( data );
-
        Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_add( \"%s\", %ld )\n", dn, id, 0 );
 
        if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT ))
@@ -35,11 +32,12 @@ bdb2i_dn2id_add(
                return( -1 );
        }
 
-       dn = ch_strdup( dn );
-       (void) dn_normalize_case( dn );
+       ldbm_datum_init( key );
+       key.dsize = strlen( dn ) + 2;
+       key.dptr = ch_malloc( key.dsize );
+       sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn );
 
-       key.dptr = dn;
-       key.dsize = strlen( dn ) + 1;
+       ldbm_datum_init( data );
        data.dptr = (char *) &id;
        data.dsize = sizeof(ID);
 
@@ -48,7 +46,41 @@ bdb2i_dn2id_add(
 
        rc = bdb2i_cache_store( db, key, data, flags );
 
-       free( dn );
+       free( key.dptr );
+
+       if ( rc != -1 ) {
+               char *pdn = dn_parent( NULL, dn );
+
+               if( pdn != NULL ) {
+                       ldbm_datum_init( key );
+                       key.dsize = strlen( pdn ) + 2;
+                       key.dptr = ch_malloc( key.dsize );
+                       sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
+                       rc = bdb2i_idl_insert_key( be, db, key, id );
+                       free( key.dptr );
+               }
+       }
+
+       if ( rc != -1 ) {
+               char **subtree = dn_subtree( NULL, dn );
+
+               if( subtree != NULL ) {
+                       int i;
+                       for( i=0; subtree[i] != NULL; i++ ) {
+                               ldbm_datum_init( key );
+                               key.dsize = strlen( subtree[i] ) + 2;
+                               key.dptr = ch_malloc( key.dsize );
+                               sprintf( key.dptr, "%c%s", DN_SUBTREE_PREFIX, subtree[i] );
+
+                               rc = bdb2i_idl_insert_key( be, db, key, id );
+
+                               free( key.dptr );
+                       }
+
+                       charray_free( subtree );
+               }
+       }
+
        bdb2i_cache_close( be, db );
 
        Debug( LDAP_DEBUG_TRACE, "<= bdb2i_dn2id_add %d\n", rc, 0, 0 );
@@ -66,16 +98,10 @@ bdb2i_dn2id(
        ID              id;
        Datum           key, data;
 
-       ldbm_datum_init( key );
-       ldbm_datum_init( data );
-
-       dn = ch_strdup( dn );
        Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id( \"%s\" )\n", dn, 0, 0 );
-       (void) dn_normalize_case( dn );
 
        /* first check the cache */
        if ( (id = bdb2i_cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) {
-               free( dn );
                Debug( LDAP_DEBUG_TRACE, "<= bdb2i_dn2id %ld (in cache)\n", id,
                        0, 0 );
                return( id );
@@ -83,19 +109,22 @@ bdb2i_dn2id(
 
        if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT ))
                == NULL ) {
-               free( dn );
                Debug( LDAP_DEBUG_ANY, "<= bdb2i_dn2id could not open dn2id%s\n",
                        BDB2_SUFFIX, 0, 0 );
                return( NOID );
        }
 
-       key.dptr = dn;
-       key.dsize = strlen( dn ) + 1;
+       ldbm_datum_init( key );
+
+       key.dsize = strlen( dn ) + 2;
+       key.dptr = ch_malloc( key.dsize );
+       sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn );
 
        data = bdb2i_cache_fetch( db, key );
 
        bdb2i_cache_close( be, db );
-       free( dn );
+
+       free( key.dptr );
 
        if ( data.dptr == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "<= bdb2i_dn2id NOID\n", 0, 0, 0 );
@@ -110,6 +139,41 @@ bdb2i_dn2id(
        return( id );
 }
 
+ID_BLOCK *
+bdb2i_dn2idl(
+    BackendDB  *be,
+    char       *dn,
+       int     prefix )
+{
+       struct dbcache  *db;
+       Datum key;
+       ID_BLOCK *idl;
+
+       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2idl( \"%c%s\" )\n", prefix, dn, 0 );
+
+       if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT ))
+           == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                   "<= bdb2i_dn2idl could not open dn2id%s\n", BDB2_SUFFIX,
+                   0, 0 );
+               return( NULL );
+       }
+
+       ldbm_datum_init( key );
+
+       key.dsize = strlen( dn ) + 2;
+       key.dptr = ch_malloc( key.dsize );
+       sprintf( key.dptr, "%c%s", prefix, dn );
+
+       idl = bdb2i_idl_fetch( be, db, key );
+
+       free( key.dptr );
+
+       bdb2i_cache_close( be, db );
+
+       return( idl );
+}
+
 int
 bdb2i_dn2id_delete(
     BackendDB  *be,
@@ -120,8 +184,6 @@ bdb2i_dn2id_delete(
        Datum           key;
        int             rc;
 
-       ldbm_datum_init( key );
-
        Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\" )\n", dn, 0, 0 );
 
        if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT ))
@@ -132,14 +194,15 @@ bdb2i_dn2id_delete(
                return( -1 );
        }
 
-       dn = ch_strdup( dn );
-       (void) dn_normalize_case( dn );
-       key.dptr = dn;
-       key.dsize = strlen( dn ) + 1;
+       ldbm_datum_init( key );
+
+       key.dsize = strlen( dn ) + 2;
+       key.dptr = ch_malloc( key.dsize );
+       sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn );
 
        rc = bdb2i_cache_delete( db, key );
 
-       free( dn );
+       free( key.dptr );
 
        bdb2i_cache_close( be, db );
 
index 31d22796017043ee61b4e4e6f4b8ac397ccede38..58da13d2248f7f126720b73013d0e5a56709321d 100644 (file)
@@ -58,6 +58,18 @@ extern int   bdb2_back_group LDAP_P(( BackendDB *bd,
        Entry *target, char* gr_ndn, char* op_ndn,
        char* objectclassValue, char* groupattrName));
 
+/* hooks for slap tools */
+extern int bdb2_tool_entry_open LDAP_P(( BackendDB *be, int mode ));
+extern int bdb2_tool_entry_close LDAP_P(( BackendDB *be ));
+extern ID bdb2_tool_entry_first LDAP_P(( BackendDB *be ));
+extern ID bdb2_tool_entry_next LDAP_P(( BackendDB *be ));
+extern Entry* bdb2_tool_entry_get LDAP_P(( BackendDB *be, ID id ));
+extern ID bdb2_tool_entry_put LDAP_P(( BackendDB *be, Entry *e ));
+extern int bdb2_tool_index_attr LDAP_P(( BackendDB *be, char* type ));
+extern int bdb2_tool_index_change LDAP_P(( BackendDB *be, char* type,
+       struct berval **bv, ID id, int op ));
+extern int bdb2_tool_sync LDAP_P(( BackendDB *be ));
+
 LDAP_END_DECL
 
 #endif /* _BDB2_EXTERNAL_H */
index 32da1d85e7935f0d24e30b9948a4f5569ada0268..ad546caa485f21125a11cc7e01ab9bd2c5861061 100644 (file)
@@ -36,6 +36,16 @@ bdb2i_filter_candidates(
 
        result = NULL;
        switch ( f->f_choice ) {
+       case SLAPD_FILTER_DN_ONE:
+               Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
+               result = bdb2i_dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX );
+               break;
+
+       case SLAPD_FILTER_DN_SUBTREE:
+               Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
+               result = bdb2i_dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX );
+               break;
+
        case LDAP_FILTER_EQUALITY:
                Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
                result = ava_candidates( be, &f->f_ava, LDAP_FILTER_EQUALITY );
index d4784d5bd8a42a9bbe8927ae8ecc195f842b7991..903418daa6be04b03adfb04a992983357cfe060d 100644 (file)
 #include "slap.h"
 #include "back-bdb2.h"
 
-int
-bdb2i_id2children_add(
-    BackendDB  *be,
-    Entry      *p,
-    Entry      *e
-)
-{
-       struct dbcache  *db;
-       Datum           key;
-       char            buf[20];
-
-       ldbm_datum_init( key );
-
-       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_id2children_add( %ld, %ld )\n",
-              p ? p->e_id : 0, e->e_id, 0 );
-
-       if ( (db = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
-           LDBM_WRCREAT )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "<= bdb2i_id2children_add -1 could not open \"id2children%s\"\n",
-                   BDB2_SUFFIX, 0, 0 );
-               return( -1 );
-       }
-
-       sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
-       key.dptr = buf;
-       key.dsize = strlen( buf ) + 1;
-
-       if ( bdb2i_idl_insert_key( be, db, key, e->e_id ) != 0 ) {
-               Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_add -1 (idl_insert)\n",
-                   0, 0, 0 );
-               bdb2i_cache_close( be, db );
-               return( -1 );
-       }
-
-       bdb2i_cache_close( be, db );
-
-       Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_add 0\n", 0, 0, 0 );
-       return( 0 );
-}
-
-
-int
-bdb2i_id2children_remove(
-    BackendDB  *be,
-    Entry      *p,
-    Entry      *e
-)
-{
-       struct dbcache  *db;
-       Datum           key;
-       char            buf[20];
-
-       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_id2children_remove( %ld, %ld )\n",
-               p ? p->e_id : 0, e->e_id, 0 );
-
-       if ( (db = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
-           LDBM_WRCREAT )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "<= bdb2i_id2children_remove -1 could not open \"id2children%s\"\n",
-                   BDB2_SUFFIX, 0, 0 );
-               return( -1 );
-       }
-
-       ldbm_datum_init( key );
-       sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
-       key.dptr = buf;
-       key.dsize = strlen( buf ) + 1;
-
-       if ( bdb2i_idl_delete_key( be, db, key, e->e_id ) != 0 ) {
-               Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_remove -1 (idl_delete)\n",
-                   0, 0, 0 );
-               bdb2i_cache_close( be, db );
-               return( -1 );
-       }
-
-       bdb2i_cache_close( be, db );
-
-       Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_remove 0\n", 0, 0, 0 );
-       return( 0 );
-}
-
 int
 bdb2i_has_children(
     BackendDB  *be,
@@ -102,26 +20,27 @@ bdb2i_has_children(
        Datum           key;
        int             rc = 0;
        ID_BLOCK                *idl;
-       char            buf[20];
 
        ldbm_datum_init( key );
 
        Debug( LDAP_DEBUG_TRACE, "=> bdb2i_has_children( %ld )\n", p->e_id , 0, 0 );
 
-       if ( (db = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
+       if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX,
            LDBM_WRCREAT )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
-                   "<= bdb2i_has_children -1 could not open \"id2children%s\"\n",
-                   BDB2_SUFFIX, 0, 0 );
+                   "<= bdb2i_has_children: could not open \"dn2id" BDB2_SUFFIX "\"\n",
+                   0, 0, 0 );
                return( 0 );
        }
 
-       sprintf( buf, "%c%ld", EQ_PREFIX, p->e_id );
-       key.dptr = buf;
-       key.dsize = strlen( buf ) + 1;
+       key.dsize = strlen( p->e_ndn ) + 2;
+       key.dptr = ch_malloc( key.dsize );
+       sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, p->e_ndn );
 
        idl = bdb2i_idl_fetch( be, db, key );
 
+       free( key.dptr );
+
        bdb2i_cache_close( be, db );
 
        if( idl != NULL ) {
index a2cc63690c8396426932c13f37cfcd06a0d60262..c7bf18e5c02f773a4569251af1b9290afb52e1c2 100644 (file)
@@ -39,7 +39,7 @@ bdb2i_id2entry_add( BackendDB *be, Entry *e )
        key.dsize = sizeof(ID);
 
        ldap_pvt_thread_mutex_lock( &entry2str_mutex );
-       data.dptr = entry2str( e, &len, 1 );
+       data.dptr = entry2str( e, &len );
        data.dsize = len + 1;
 
        /* store it */
@@ -150,13 +150,7 @@ bdb2i_id2entry_rw( BackendDB *be, ID id, int rw )
                return( NULL );
        }
 
-       if ( e->e_id != id ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "<= bdb2i_id2entry_%s( %ld ) (wrong id %ld on disk)\n",
-                       rw ? "w" : "r", id, e->e_id );
-               entry_free( e );
-               return( NULL );
-       }
+       e->e_id = id; 
 
        if ( bdb2i_cache_add_entry_rw( &li->li_cache, e, rw ) != 0 ) {
                entry_free( e );
index 5b000f308e1ae49adf1d402ed69496668846ee1d..f6718dc4b438c90976ed64ed0b51f676031086fc 100644 (file)
@@ -139,12 +139,13 @@ bdb2i_idl_fetch(
        tmp = (ID_BLOCK **) ch_malloc( (i + 1) * sizeof(ID_BLOCK *) );
 
        /* read in all the blocks */
-       kstr = (char *) ch_malloc( key.dsize + 20 );
+       kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
        nids = 0;
        for ( i = 0; !ID_BLOCK_NOID(idl, i); i++ ) {
                ldbm_datum_init( data );
 
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, i) );
+               sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+                       ID_BLOCK_ID(idl, i), key.dptr );
                data.dptr = kstr;
                data.dsize = strlen( kstr ) + 1;
 
@@ -298,7 +299,8 @@ idl_change_first(
        }
 
        /* write block with new key */
-       sprintf( bkey.dptr, "%c%s%ld", CONT_PREFIX, hkey.dptr, ID_BLOCK_ID(b, 0) );
+       sprintf( bkey.dptr, "%c%ld%s", CONT_PREFIX,
+                       ID_BLOCK_ID(b, 0), hkey.dptr );
        bkey.dsize = strlen( bkey.dptr ) + 1;
        if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
                Debug( LDAP_DEBUG_ANY,
@@ -389,16 +391,16 @@ bdb2i_idl_insert_key(
                        rc = idl_store( be, db, key, idl );
 
                        /* store the first id block */
-                       kstr = (char *) ch_malloc( key.dsize + 20 );
-                       sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                           ID_BLOCK_ID(tmp, 0) );
+                       kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
+                       sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+                           ID_BLOCK_ID(tmp, 0), key.dptr );
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        rc = idl_store( be, db, k2, tmp );
 
                        /* store the second id block */
-                       sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                           ID_BLOCK_ID(tmp2, 0) );
+                       sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+                           ID_BLOCK_ID(tmp2, 0), key.dptr );
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        rc = idl_store( be, db, k2, tmp2 );
@@ -432,8 +434,9 @@ bdb2i_idl_insert_key(
        }
 
        /* get the block */
-       kstr = (char *) ch_malloc( key.dsize + 20 );
-       sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, i) );
+       kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
+       sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+               ID_BLOCK_ID(idl, i), key.dptr );
        k2.dptr = kstr;
        k2.dsize = strlen( kstr ) + 1;
        if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
@@ -477,8 +480,8 @@ bdb2i_idl_insert_key(
                /* is there a next block? */
                if ( !first && !ID_BLOCK_NOID(idl, i + 1) ) {
                        /* read it in */
-                       sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                           ID_BLOCK_ID(idl, i + 1) );
+                       sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+                           ID_BLOCK_ID(idl, i + 1), key.dptr );
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) {
@@ -535,8 +538,8 @@ bdb2i_idl_insert_key(
 
                        /* delete all indirect blocks */
                        for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) {
-                               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                                   ID_BLOCK_ID(idl, j) );
+                               sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+                                   ID_BLOCK_ID(idl, j), key.dptr );
                                k2.dptr = kstr;
                                k2.dsize = strlen( kstr ) + 1;
 
@@ -578,15 +581,15 @@ bdb2i_idl_insert_key(
                rc = idl_store( be, db, key, tmp );
 
                /* store the first id block */
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                   ID_BLOCK_ID(tmp2, 0) );
+               sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+                   ID_BLOCK_ID(tmp2, 0), key.dptr );
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
                rc = idl_store( be, db, k2, tmp2 );
 
                /* store the second id block */
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                   ID_BLOCK_ID(tmp3, 0) );
+               sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+                   ID_BLOCK_ID(tmp3, 0), key.dptr );
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
                rc = idl_store( be, db, k2, tmp3 );
@@ -715,11 +718,11 @@ bdb2i_idl_delete_key (
           */
        for ( nids = 0; !ID_BLOCK_NOID(idl, nids); nids++ )
                ;       /* NULL */
-       kstr = (char *) ch_malloc( key.dsize + 20 );
+       kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
        for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ )
        {
                ldbm_datum_init( data );
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, j) );
+               sprintf( kstr, "%c%ld%s", CONT_PREFIX, ID_BLOCK_ID(idl, j), key.dptr );
                data.dptr = kstr;
                data.dsize = strlen( kstr ) + 1;
 
index 5e2a97ad3232d75cab8a0698097e8dabc0b40a0b..0338712c704323d6a4d1525648677a50d7fe31b1 100644 (file)
@@ -108,8 +108,8 @@ bdb2i_index_read(
        ldbm_datum_init( key );
 
        prefix = index2prefix( indextype );
-       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_index_read( \"%s\" \"%c\" \"%s\" )\n",
-           type, prefix, val );
+       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_index_read( \"%c%s\" -> \"%s\" )\n",
+           prefix, type, val );
 
        bdb2i_attr_masks( be->be_private, type, &indexmask, &syntax );
        if ( ! (indextype & indexmask) ) {
@@ -143,6 +143,7 @@ bdb2i_index_read(
                        tmpval = (char *) ch_malloc( len + 2 );
                        realval = tmpval;
                }
+
         realval[0] = prefix;
         strcpy( &realval[1], val );
        }
@@ -238,8 +239,8 @@ bdb2i_index_add_values(
                return 0;
        }
 
-       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_index_add_values( \"%s\", %ld )\n", type,
-           id, 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> bdb2i_index_add_values( \"%s\", %ld )\n",
+               type, id, 0 );
        attr_normalize( type );
        bdb2i_attr_masks( be->be_private, type, &indexmask, &syntax );
        if ( indexmask == 0 ) {
index 231994a595c17c917df8e33a89feaf85ed44fa40..3977fc5e20bf8349dd48b1cf1a96e45a4f65a7d9 100644 (file)
@@ -38,7 +38,7 @@ bdb2i_back_init_private(
        bt->lty_dbhome = DEFAULT_DB_HOME;
        bt->lty_mpsize = DEFAULT_DBCACHE_SIZE;
 
-       if ( slapMode == SLAP_TIMEDSERVER_MODE )
+       if ( slapMode & SLAP_TIMED_MODE )
                bt->lty_betiming = 1;
 
        bi->bi_private = bt;
@@ -78,6 +78,19 @@ bdb2_back_initialize(
        bi->bi_entry_release_rw = bdb2_back_entry_release_rw;
        bi->bi_acl_group = bdb2_back_group;
 
+       /*
+        * hooks for slap tools
+        */
+       bi->bi_tool_entry_open = bdb2_tool_entry_open;
+       bi->bi_tool_entry_close = bdb2_tool_entry_close;
+       bi->bi_tool_entry_first = bdb2_tool_entry_first;
+       bi->bi_tool_entry_next = bdb2_tool_entry_next;
+       bi->bi_tool_entry_get = bdb2_tool_entry_get;
+       bi->bi_tool_entry_put = bdb2_tool_entry_put;
+       bi->bi_tool_index_attr = bdb2_tool_index_attr;
+       bi->bi_tool_index_change = bdb2_tool_index_change;
+       bi->bi_tool_sync = bdb2_tool_sync;
+
        bi->bi_connection_init = 0;
        bi->bi_connection_destroy = 0;
 
@@ -164,27 +177,11 @@ bdb2i_back_db_init_internal(
        /* default database directory */
        li->li_directory = DEFAULT_DB_DIRECTORY;
 
-       /* always index dn, id2children, objectclass (used in some searches) */
-       if ( !at_find( "dn" ) ) {
-               argv[ 0 ] = "dn";
-               argv[ 1 ] = "dn";
-               argv[ 2 ] = NULL;
-               attr_syntax_config( "ldbm dn initialization", 0, 2, argv );
-       }
-       argv[ 0 ] = "dn";
-       argv[ 1 ] = "eq,sub";
-       argv[ 2 ] = NULL;
-       bdb2i_attr_index_config( li, "ldbm dn initialization", 0, 2, argv, 1 );
-       argv[ 0 ] = "id2children";
-       argv[ 1 ] = "eq";
-       argv[ 2 ] = NULL;
-       bdb2i_attr_index_config( li, "ldbm id2children initialization", 0, 2, argv,
-           1 );
        argv[ 0 ] = "objectclass";
        argv[ 1 ] = "pres,eq";
        argv[ 2 ] = NULL;
-       bdb2i_attr_index_config( li, "ldbm objectclass initialization", 0, 2, argv,
-           1 );
+       bdb2i_attr_index_config( li, "ldbm objectclass initialization",
+               0, 2, argv, 1 );
 
        /*  initialize the cache mutex */
        ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex );
index ef263e7ed660104fcbebb1e1608a94e0baa8819c..1e4a62d9a363f5ed596ec35cd2c0d93d8036c6cc 100644 (file)
@@ -145,11 +145,9 @@ bdb2_back_modify(
 
        /*  check, if a new default attribute index will be created,
                in which case we have to open the index file BEFORE TP  */
-       switch ( slapMode ) {
+       switch ( slapMode & SLAP_MODE ) {
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        bdb2i_check_default_attr_index_mod( li, modlist );
                        break;
        }
@@ -314,7 +312,7 @@ bdb2i_replace_values(
 {
        (void) attr_delete( &e->e_attrs, mod->mod_type );
 
-       if ( mod->bvalues != NULL &&
+       if ( mod->mod_bvalues != NULL &&
                attr_merge( e, mod->mod_type, mod->mod_bvalues ) != 0 )
        {
                return( LDAP_CONSTRAINT_VIOLATION );
index 0218cfd7842acc13d6305cb526162004600442ce..91cb5e360aace0b902a0edb5feaf1b0a2716365b 100644 (file)
@@ -26,9 +26,6 @@ bdb2i_next_id_save( BackendDB *be )
        int rc;
 
        rc = next_id_write( be, id );
-       if (rc == 0) {
-               li->li_nextid_wrote = id;
-       }
 
        return rc;
 }
@@ -46,44 +43,15 @@ bdb2i_next_id( BackendDB *be )
                if ( li->li_nextid == NOID ) {
                        li->li_nextid = 1;
                }
-
-#if SLAPD_NEXTID_CHUNK > 1
-               li->li_nextid_wrote = li->li_nextid;
-#endif
        }
 
        id = li->li_nextid++;
 
-#if SLAPD_NEXTID_CHUNK > 1
-       if ( li->li_nextid > li->li_nextid_wrote ) {
-               li->li_nextid_wrote += SLAPD_NEXTID_CHUNK;
-               (void) next_id_write( be, li->li_nextid_wrote );
-       }
-#else
        (void) next_id_write( be, li->li_nextid );
-#endif
 
        return( id );
 }
 
-void
-bdb2i_next_id_return( BackendDB *be, ID id )
-{
-#ifdef SLAPD_NEXTID_RETURN
-       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-
-       if ( id != li->li_nextid - 1 ) {
-               return;
-       }
-
-       li->li_nextid--;
-
-#if !( SLAPD_NEXTID_CHUNK > 1 )
-       (void) next_id_write( be, li->li_nextid );
-#endif
-#endif
-}
-
 ID
 bdb2i_next_id_get( BackendDB *be )
 {
@@ -97,10 +65,6 @@ bdb2i_next_id_get( BackendDB *be )
                if ( li->li_nextid == NOID ) {
                        li->li_nextid = 1;
                }
-
-#if SLAPD_NEXTID_CHUNK > 1
-               li->li_nextid_wrote = li->li_nextid;
-#endif
        }
 
        id = li->li_nextid;
index 26e36107730912ae4a10bae3266ddbfe3005505d..8dba543e7cad77f71a1618c1e69aea42e1b97694 100644 (file)
@@ -21,12 +21,10 @@ bdb2i_enter_backend_rw( DB_LOCK *lock, int writer )
        DBT            lock_dbt;
        int            ret = 0;
 
-       switch ( slapMode ) {
+       switch ( slapMode & SLAP_MODE ) {
 
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        if ( ( ret = lock_id( bdb2i_dbEnv.lk_info, &locker )) != 0 ) {
 
                                Debug( LDAP_DEBUG_ANY,
@@ -103,12 +101,10 @@ bdb2i_leave_backend_rw( DB_LOCK lock, int writer )
        ret_transaction |= bdb2i_set_txn_checkpoint( bdb2i_dbEnv.tx_info, 0 );
 
        /*  now release the lock  */
-       switch ( slapMode ) {
+       switch ( slapMode & SLAP_MODE ) {
 
                case SLAP_SERVER_MODE:
-               case SLAP_TIMEDSERVER_MODE:
                case SLAP_TOOL_MODE:
-               case SLAP_TOOLID_MODE:
                        switch( ( ret_lock = lock_put( bdb2i_dbEnv.lk_info, lock ))) {
 
                                case 0:
index f0583e1f14cfc694562a5977021fce477c95b02f..7f1042202d171b52b09dd5de786ef7a42fc2f3b9 100644 (file)
@@ -77,6 +77,12 @@ int bdb2i_dn2id_add LDAP_P(( BackendDB *be, char *dn, ID id ));
 ID bdb2i_dn2id LDAP_P(( BackendDB *be, char *dn ));
 int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, char *dn ));
 
+ID_BLOCK *
+bdb2i_dn2idl LDAP_P((
+    BackendDB  *be,
+    char       *dn,
+       int     prefix ));
+
 Entry * bdb2i_dn2entry_rw LDAP_P((
        BackendDB *be,
        char *dn,
@@ -101,8 +107,6 @@ ID_BLOCK * bdb2i_filter_candidates LDAP_P(( BackendDB *be, Filter *f ));
  * id2children.c
  */
 
-int bdb2i_id2children_add LDAP_P(( BackendDB *be, Entry *p, Entry *e ));
-int bdb2i_id2children_remove LDAP_P(( BackendDB *be, Entry *p, Entry *e ));
 int bdb2i_has_children LDAP_P(( BackendDB *be, Entry *p ));
 
 /*
index 9117aeafb9918f667c004d92dc1d24602f9e98ae..9b5dc6d3de2adcb7cb74e3a55169482e432c254d 100644 (file)
@@ -437,28 +437,20 @@ search_candidates(
                lf->f_choice = LDAP_FILTER_AND;
                lf->f_and = (Filter *) ch_malloc( sizeof(Filter) );
 
-               lf->f_and->f_choice = LDAP_FILTER_SUBSTRINGS;
-               lf->f_and->f_sub_type = ch_strdup( "dn" );
-               lf->f_and->f_sub_initial = NULL;
-               lf->f_and->f_sub_any = NULL;
-               lf->f_and->f_sub_final = ch_strdup( e->e_ndn );
+               lf->f_and->f_choice = SLAPD_FILTER_DN_SUBTREE;
+               lf->f_and->f_dn = e->e_ndn;
 
                lf->f_and->f_next = f;
                f = lf;
 
        } else if ( scope == LDAP_SCOPE_ONELEVEL ) {
-               char buf[16];
-
                lf = (Filter *) ch_malloc( sizeof(Filter) );
                lf->f_next = NULL;
                lf->f_choice = LDAP_FILTER_AND;
                lf->f_and = (Filter *) ch_malloc( sizeof(Filter) );
 
-               lf->f_and->f_choice = LDAP_FILTER_EQUALITY;
-               lf->f_and->f_ava.ava_type = ch_strdup( "id2children" );
-               sprintf( buf, "%ld", e != NULL ? e->e_id : 0 );
-               lf->f_and->f_ava.ava_value.bv_val = ch_strdup( buf );
-               lf->f_and->f_ava.ava_value.bv_len = strlen( buf );
+               lf->f_and->f_choice = SLAPD_FILTER_DN_ONE;
+               lf->f_and->f_dn = e->e_ndn;
 
                lf->f_and->f_next = f;
                f = lf;
@@ -471,8 +463,8 @@ search_candidates(
 
        /* free up filter additions we allocated above */
        if( lf != NULL ) {
-               lf->f_and->f_next = NULL;
-               filter_free( lf );
+               free( lf->f_and );
+               free( lf );
        }
 
        if( af != NULL ) {
diff --git a/servers/slapd/back-bdb2/tools.c b/servers/slapd/back-bdb2/tools.c
new file mode 100644 (file)
index 0000000..5d92b1a
--- /dev/null
@@ -0,0 +1,248 @@
+/* tools.c - tools for slap tools */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-bdb2.h"
+
+static LDBMCursor *cursorp = NULL;
+static DBCache *id2entry = NULL;
+
+int bdb2_tool_entry_open(
+       BackendDB *be, int mode )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       int flags;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry == NULL );
+
+       switch( mode ) {
+       case 1:
+               flags = LDBM_WRCREAT;
+               break;
+       case 2:
+#ifdef TRUNCATE_MODE
+               flags = LDBM_NEWDB;
+#else
+               flags = LDBM_WRCREAT;
+#endif
+               break;
+       default:
+               flags = LDBM_READER;
+       }
+
+       li->li_dbcachewsync = 0;
+
+       if ( (id2entry = bdb2i_cache_open( be, "id2entry", BDB2_SUFFIX, flags ))
+           == NULL ) {
+               Debug( LDAP_DEBUG_ANY, "Could not open/create id2entry" BDB2_SUFFIX "\n",
+                   0, 0, 0 );
+               return( -1 );
+       }
+
+       return 0;
+}
+
+int bdb2_tool_entry_close(
+       BackendDB *be )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       bdb2i_cache_close( be, id2entry );
+       li->li_dbcachewsync = 1;
+       id2entry = NULL;
+
+       return 0;
+}
+
+ID bdb2_tool_entry_first(
+       BackendDB *be )
+{
+       Datum key;
+       ID id;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       key = ldbm_firstkey( id2entry->dbc_db, &cursorp );
+
+       if( key.dptr == NULL ) {
+               return NOID;
+       }
+
+       memcpy( &id, key.dptr, key.dsize );
+
+       ldbm_datum_free( id2entry->dbc_db, key );
+
+       return id;
+}
+
+ID bdb2_tool_entry_next(
+       BackendDB *be )
+{
+       Datum key;
+       ID id;
+       int count;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       /* allow for NEXTID */
+       ldbm_datum_init( key );
+
+       key = ldbm_nextkey( id2entry->dbc_db, key, cursorp );
+
+       if( key.dptr == NULL ) {
+               return NOID;
+       }
+
+       memcpy( &id, key.dptr, key.dsize );
+
+       ldbm_datum_free( id2entry->dbc_db, key );
+
+       return id;
+}
+
+Entry* bdb2_tool_entry_get( BackendDB *be, ID id )
+{
+       Entry *e;
+       Datum key, data;
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       ldbm_datum_init( key );
+
+       key.dptr = (char *) &id;
+       key.dsize = sizeof(ID);
+
+       data = bdb2i_cache_fetch( id2entry, key );
+
+       if ( data.dptr == NULL ) {
+               return NULL;
+       }
+
+       e = str2entry( data.dptr );
+       ldbm_datum_free( id2entry->dbc_db, data );
+
+       return e;
+}
+
+ID bdb2_tool_entry_put(
+       BackendDB *be,
+       Entry *e )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       Datum key, data;
+       int rc, len;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       if( bdb2i_next_id_get( be ) == NOID ) {
+               return NOID;
+       }
+
+       e->e_id = li->li_nextid++;
+
+       Debug( LDAP_DEBUG_TRACE, "=> bdb2_tool_entry_put( %ld, \"%s\" )\n",
+               e->e_id, e->e_dn, 0 );
+
+       rc = bdb2i_index_add_entry( be, e );
+
+       if( rc != 0 ) {
+               return NOID;
+       }
+
+       rc = bdb2i_dn2id_add( be, e->e_ndn, e->e_id );
+
+       if( rc != 0 ) {
+               return NOID;
+       }
+
+       ldbm_datum_init( key );
+       ldbm_datum_init( data );
+
+       key.dptr = (char *) &e->e_id;
+       key.dsize = sizeof(ID);
+
+       data.dptr = entry2str( e, &len );
+       data.dsize = len + 1;
+
+       /* store it */
+       rc = bdb2i_cache_store( id2entry, key, data, LDBM_REPLACE );
+
+       if( rc != 0 ) {
+               (void) bdb2i_dn2id_delete( be, e->e_ndn );
+               return NOID;
+       }
+
+       return e->e_id;
+}
+
+int bdb2_tool_index_attr(
+       BackendDB *be,
+       char* type )
+{
+       static DBCache *db = NULL;
+       int indexmask, syntaxmask;
+       char * at_cn;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+
+       bdb2i_attr_masks( be->be_private, type, &indexmask, &syntaxmask );
+
+       attr_normalize( type );
+       at_cn = at_canonical_name( type );
+
+       if ( (db = bdb2i_cache_open( be, at_cn, LDBM_SUFFIX, LDBM_NEWDB ))
+           == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                   "<= index_read NULL (could not open %s%s)\n", at_cn,
+                   BDB2_SUFFIX, 0 );
+               return( NULL );
+       }
+
+       bdb2i_cache_close( be, db );
+
+       return indexmask != 0;
+}
+
+int bdb2_tool_index_change(
+       BackendDB *be,
+       char* type,
+       struct berval **bv,
+       ID id,
+       int op )
+{
+       assert( slapMode & SLAP_TOOL_MODE );
+
+       bdb2i_index_add_values( be,
+               type, bv, id );
+
+       return 0;
+}
+
+int bdb2_tool_sync( BackendDB *be )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+
+       if ( li->li_nextid != NOID ) {
+               bdb2i_next_id_save( be );
+       }
+
+       return 0;
+}
index 4cf75de346d511e4c6f22be0e1f480837cb57fbb..747a754ccef2c08000e3a97497bb1c3f9d7e9181 100644 (file)
@@ -7,6 +7,14 @@
 #endif
 #include "txn.h"
 
+/*  default DB files  */
+char  *bdb2i_fixed_filenames[] = {
+       "id2entry",
+       "dn2id",
+       "objectclass",
+       NULL
+};
+
 
 int
 bdb2i_txn_head_init( BDB2_TXN_HEAD *head )
@@ -17,20 +25,19 @@ bdb2i_txn_head_init( BDB2_TXN_HEAD *head )
        /*  for each fixed DB file allocate a file descriptor node and
         initialize the file's name  */
        fileNodeH = &head->dbFiles;
-       for ( dbFile = BDB2_DB_DN_FILE; dbFile <= BDB2_DB_OC_IDX_FILE; dbFile++ ) {
 
+       for ( dbFile = 0; bdb2i_fixed_filenames[dbFile] != NULL; dbFile++ ) {
                char fileName[MAXPATHLEN];
 
                *fileNodeH = (BDB2_TXN_FILES *) ch_calloc( 1, sizeof( BDB2_TXN_FILES ));
-               if ( *fileNodeH == NULL ) {
 
+               if ( *fileNodeH == NULL ) {
                        Debug( LDAP_DEBUG_ANY, "bdb2i_txn_head_init(): out of memory!\n",
                                        0, 0, 0 );
                        return( 1 );
-
                }
 
-               sprintf( fileName, "%s%s", bdb2i_fixed_filenames[dbFile], BDB2_SUFFIX );
+               sprintf( fileName, "%s" BDB2_SUFFIX, bdb2i_fixed_filenames[dbFile] );
                (*fileNodeH)->dbc_name = ch_strdup( fileName );
 
                fileNodeH = &(*fileNodeH)->next;
index b8ebc3aa7b479a529548546457243f522cc97771..93a43ebc2116874978a13c3a8110f1cf64df67c1 100644 (file)
@@ -46,13 +46,6 @@ ldap_pvt_thread_mutex_t   txn_dirty_mutex;
 #define NEXTID_RECNO   (db_recno_t) 1
 
 
-/*  default DB files  */
-char  *bdb2i_fixed_filenames[] = {
-
-               "dn", "dn2id", "id2entry", "id2children", "objectclass"
-
-       };
-
 
 #endif  /*  _BDB2_TXN_H_  */
 
index 80c2fad6f8beb200e3efbb8d132a6ca7f5283e63..3a88ae1c3bc90543431ed4d7fde51e4d50b7fe73 100644 (file)
@@ -1,11 +1,11 @@
-SRCS   = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \
+SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \
                index.c id2children.c nextid.c abandon.c compare.c group.c \
                modify.c modrdn.c delete.c init.c config.c bind.c attr.c \
-               filterindex.c unbind.c kerberos.c close.c alias.c
-OBJS   = idl.lo add.lo search.lo cache.lo dbcache.lo dn2id.lo entry.lo id2entry.lo \
+               filterindex.c unbind.c kerberos.c close.c alias.c tools.c
+OBJS = idl.lo add.lo search.lo cache.lo dbcache.lo dn2id.lo entry.lo id2entry.lo \
                index.lo id2children.lo nextid.lo abandon.lo compare.lo group.lo \
                modify.lo modrdn.lo delete.lo init.lo config.lo bind.lo attr.lo \
-               filterindex.lo unbind.lo kerberos.lo close.lo alias.lo
+               filterindex.lo unbind.lo kerberos.lo close.lo alias.lo tools.lo
 
 LDAP_INCDIR= ../../../include       
 LDAP_LIBDIR= ../../../libraries
index a3ff1feca577abeb3a621f3cd8dc670a1e0f1c6a..8775e2951454d8f1f3791526e10ec4a356835c88 100644 (file)
@@ -211,9 +211,6 @@ ldbm_back_add(
                Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
                    0 );
 
-               /* return the id */
-               next_id_return( be, e->e_id );
-
                /* free the entry */
                entry_free( e );
 
@@ -226,20 +223,6 @@ ldbm_back_add(
 
        rc = -1;
 
-#ifndef DN_INDICES
-       /*
-        * add it to the id2children index for the parent
-        */
-       if ( id2children_add( be, p, e ) != 0 ) {
-               Debug( LDAP_DEBUG_TRACE, "id2children_add failed\n", 0,
-                   0, 0 );
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
-
-               goto return_results;
-       }
-#endif
-
        /*
         * Add the entry to the attribute indexes, then add it to
         * the id2children index, dn2id index, and the id2entry index.
index 2b699eba9f54e4e4e81f8e12f6fa23e6ca6dba51..9a68e0e2d180c0c2c3300f7603ba47190d558b73 100644 (file)
@@ -24,7 +24,6 @@ LDAP_BEGIN_DECL
 
 #define SUBLEN                 3
 
-/* #undef DN_INDICES *//* generate dn eq, subtree, and parent indices */
 #define DN_BASE_PREFIX         '='
 #define DN_ONE_PREFIX          '@'
 #define DN_SUBTREE_PREFIX      '?'
@@ -44,8 +43,6 @@ LDAP_BEGIN_DECL
 /* allow 3 characters per byte + PREFIX + EOS */
 #define CONT_SIZE ( sizeof(long)*3 + 1 + 1 )
 
-/* #undef CONT_POSTFIX *//* postfix original key */
-
 #define UNKNOWN_PREFIX '?'     /* prefix for unknown keys    */
 
 #define DEFAULT_BLOCKSIZE      8192
@@ -131,20 +128,11 @@ typedef struct ldbm_attrinfo {
 
 #define MAXDBCACHE     16
 
-/* this could be made an option */
-#ifndef SLAPD_NEXTID_CHUNK
-#define SLAPD_NEXTID_CHUNK     32
-#endif
-
 struct ldbminfo {
        ID                      li_nextid;
-#if SLAPD_NEXTID_CHUNK > 1
-       ID                      li_nextid_wrote;
-#endif
-       char            *li_nextid_file;
+       ldap_pvt_thread_mutex_t         li_nextid_mutex;
        ldap_pvt_thread_mutex_t         li_root_mutex;
        ldap_pvt_thread_mutex_t         li_add_mutex;
-       ldap_pvt_thread_mutex_t         li_nextid_mutex;
        int                     li_mode;
        char                    *li_directory;
        Cache           li_cache;
index c9d2a5faf7884d31ba03a1ab581a2f5c9984e4da..377cc8ad3c9c3fda8921fb1f6e6d6fa7d099da19 100644 (file)
@@ -240,6 +240,10 @@ SOURCE=.\startup.c
 # End Source File
 # Begin Source File
 
+SOURCE=.\tools.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\unbind.c
 # End Source File
 # End Target
index f5e5442aa52ea9e9bbe88dce2a1f04f9afbe4ad1..fe03f78404ee140eb7d27d1c55e7326f3498b442 100644 (file)
 int
 ldbm_back_db_close( Backend *be )
 {
-       Debug( LDAP_DEBUG_TRACE, "ldbm backend saving nextid\n", 0, 0, 0 );
-       if ( next_id_save( be ) < 0 ) {
-               Debug( LDAP_DEBUG_ANY, "ldbm backend nextid save failed!\n", 0, 0, 0 );
-       }
-
        Debug( LDAP_DEBUG_TRACE, "ldbm backend syncing\n", 0, 0, 0 );
        ldbm_cache_flush_all( be );
        Debug( LDAP_DEBUG_TRACE, "ldbm backend done syncing\n", 0, 0, 0 );
index 8df6e46fa1ce8af82043dd9e08908399adb91095..80cabd6a477c7c71e541a6cbca4910516677e1bb 100644 (file)
@@ -44,14 +44,6 @@ ldbm_back_db_config(
                        free( li->li_directory );
                li->li_directory = ch_strdup( argv[1] );
 
-               if ( li->li_nextid_file )
-                       free( li->li_nextid_file );
-               li->li_nextid_file =
-                       ch_malloc( strlen(li->li_directory) + sizeof("/NEXTID") + 1 );
-
-               strcpy(li->li_nextid_file, li->li_directory);
-               strcat(li->li_nextid_file, "/NEXTID");
-
        /* mode with which to create new database files */
        } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
                if ( argc < 2 ) {
index 1163605314893f3baee2bc5f94300e2069b18adb..3a0287122e1c68f1ea5e02f92e0e7d10695b8d53 100644 (file)
@@ -121,11 +121,6 @@ ldbm_cache_open(
        li->li_dbcache[i].dbc_maxindirect = (SLAPD_LDBM_MIN_MAXIDS /
            li->li_dbcache[i].dbc_maxids) + 1;
 
-#ifndef CONT_POSTFIX
-       /* don't let maxindirect exceed 9 */
-       li->li_dbcache[i].dbc_maxindirect %= 10;
-#endif
-
        Debug( LDAP_DEBUG_ARGS,
            "ldbm_cache_open (blksize %ld) (maxids %d) (maxindirect %d)\n",
            li->li_dbcache[i].dbc_blksize, li->li_dbcache[i].dbc_maxids,
@@ -203,9 +198,7 @@ ldbm_cache_fetch(
 {
        Datum   data;
 
-       ldbm_datum_init( data );
-
-       data = ldbm_fetch( db->dbc_db, key );
+       return ldbm_fetch( db->dbc_db, key );
 
        return( data );
 }
index ac6b7d6343e1d089c1d524f880f52ad6f0ec1d70..7db49948bb07c7f90472e70b7158d5ca4cf6b6ef 100644 (file)
@@ -140,17 +140,6 @@ ldbm_back_delete(
                rootlock = 1;
        }
 
-#ifndef DN_INDICES
-       if ( id2children_remove( be, p, e ) != 0 ) {
-               Debug(LDAP_DEBUG_ARGS,
-                       "<=- ldbm_back_delete: operations error %s\n",
-                       dn, 0, 0);
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
-               goto return_results;
-       }
-#endif
-
        /* delete from dn2id mapping */
        if ( dn2id_delete( be, e->e_ndn ) != 0 ) {
                Debug(LDAP_DEBUG_ARGS,
index 1353146f4a21055ca29a121cba681e761989b764..0b3dbece3691cffa805497a5735a259e751e61e2 100644 (file)
@@ -27,9 +27,6 @@ dn2id_add(
        Datum           key, data;
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
-       ldbm_datum_init( key );
-       ldbm_datum_init( data );
-
        Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn, id, 0 );
 
        if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
@@ -39,15 +36,12 @@ dn2id_add(
                return( -1 );
        }
 
-#ifndef DN_INDICES
-       key.dptr = dn;
-       key.dsize = strlen( key.dptr ) + 1;
-#else
+       ldbm_datum_init( key );
        key.dsize = strlen( dn ) + 2;
        key.dptr = ch_malloc( key.dsize );
        sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn );
-#endif
 
+       ldbm_datum_init( data );
        data.dptr = (char *) &id;
        data.dsize = sizeof(ID);
 
@@ -56,13 +50,13 @@ dn2id_add(
 
        rc = ldbm_cache_store( db, key, data, flags );
 
-#ifdef DN_INDICES
        free( key.dptr );
 
        if ( rc != -1 ) {
                char *pdn = dn_parent( NULL, dn );
 
                if( pdn != NULL ) {
+                       ldbm_datum_init( key );
                        key.dsize = strlen( pdn ) + 2;
                        key.dptr = ch_malloc( key.dsize );
                        sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
@@ -77,6 +71,7 @@ dn2id_add(
                if( subtree != NULL ) {
                        int i;
                        for( i=0; subtree[i] != NULL; i++ ) {
+                               ldbm_datum_init( key );
                                key.dsize = strlen( subtree[i] ) + 2;
                                key.dptr = ch_malloc( key.dsize );
                                sprintf( key.dptr, "%c%s",
@@ -93,7 +88,6 @@ dn2id_add(
                }
 
        }
-#endif
 
        ldbm_cache_close( be, db );
 
@@ -112,9 +106,6 @@ dn2id(
        ID              id;
        Datum           key, data;
 
-       ldbm_datum_init( key );
-       ldbm_datum_init( data );
-
        Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn, 0, 0 );
 
        /* first check the cache */
@@ -131,22 +122,17 @@ dn2id(
                return( NOID );
        }
 
-#ifndef DN_INDICES
-       key.dptr = dn;
-       key.dsize = strlen( key.dptr ) + 1;
-#else
+       ldbm_datum_init( key );
+
        key.dsize = strlen( dn ) + 2;
        key.dptr = ch_malloc( key.dsize );
        sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn );
-#endif
 
        data = ldbm_cache_fetch( db, key );
 
        ldbm_cache_close( be, db );
 
-#ifdef DN_INDICES
        free( key.dptr );
-#endif
 
        if ( data.dptr == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "<= dn2id NOID\n", 0, 0, 0 );
@@ -161,7 +147,6 @@ dn2id(
        return( id );
 }
 
-#ifdef DN_INDICES
 ID_BLOCK *
 dn2idl(
     Backend    *be,
@@ -173,8 +158,6 @@ dn2idl(
        Datum           key;
        ID_BLOCK        *idl;
 
-       ldbm_datum_init( key );
-
        Debug( LDAP_DEBUG_TRACE, "=> dn2idl( \"%c%s\" )\n", prefix, dn, 0 );
 
        if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
@@ -184,6 +167,8 @@ dn2idl(
                return NULL;
        }
 
+       ldbm_datum_init( key );
+
        key.dsize = strlen( dn ) + 2;
        key.dptr = ch_malloc( key.dsize );
        sprintf( key.dptr, "%c%s", prefix, dn );
@@ -196,7 +181,7 @@ dn2idl(
 
        return( idl );
 }
-#endif
+
 
 int
 dn2id_delete(
@@ -208,8 +193,6 @@ dn2id_delete(
        Datum           key;
        int             rc;
 
-       ldbm_datum_init( key );
-
        Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\" )\n", dn, 0, 0 );
 
        if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
@@ -220,20 +203,15 @@ dn2id_delete(
                return( -1 );
        }
 
-#ifndef DN_INDICES
-       key.dptr = dn;
-       key.dsize = strlen( key.dptr ) + 1;
-#else
+       ldbm_datum_init( key );
+
        key.dsize = strlen( dn ) + 2;
        key.dptr = ch_malloc( key.dsize );
        sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn );
-#endif
 
        rc = ldbm_cache_delete( db, key );
 
-#ifdef DN_INDICES
        free( key.dptr );
-#endif
 
        ldbm_cache_close( be, db );
 
index e48f588623411320c52fc10058ed8832fb0e2215..c35e612d116e84af563a055df1f2b985a638fe3a 100644 (file)
@@ -60,6 +60,20 @@ extern int   ldbm_back_group LDAP_P(( BackendDB *bd,
        Entry *target, char* gr_ndn, char* op_ndn,
        char* objectclassValue, char* groupattrName));
 
+
+/* hooks for slap tools */
+extern int ldbm_tool_entry_open LDAP_P(( BackendDB *be, int mode ));
+extern int ldbm_tool_entry_close LDAP_P(( BackendDB *be ));
+extern ID ldbm_tool_entry_first LDAP_P(( BackendDB *be ));
+extern ID ldbm_tool_entry_next LDAP_P(( BackendDB *be ));
+extern Entry* ldbm_tool_entry_get LDAP_P(( BackendDB *be, ID id ));
+extern ID ldbm_tool_entry_put LDAP_P(( BackendDB *be, Entry *e ));
+extern int ldbm_tool_index_attr LDAP_P(( BackendDB *be, char* type ));
+extern int ldbm_tool_index_change LDAP_P(( BackendDB *be, char* type,
+       struct berval **bv, ID id, int op ));
+extern int ldbm_tool_sync LDAP_P(( BackendDB *be ));
+
+       
 LDAP_END_DECL
 
 #endif /* _LDBM_EXTERNAL_H */
index 370dc230ab32217497366c770413fcf0e8c658df..1db64e44806de6f1efd5b66fea62e9393f3208e4 100644 (file)
@@ -40,7 +40,6 @@ filter_candidates(
 
        result = NULL;
        switch ( f->f_choice ) {
-#ifdef DN_INDICES
        case SLAPD_FILTER_DN_ONE:
                Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
                result = dn2idl( be, f->f_dn, DN_ONE_PREFIX );
@@ -50,7 +49,7 @@ filter_candidates(
                Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
                result = dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX );
                break;
-#endif
+
        case LDAP_FILTER_EQUALITY:
                Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
                result = ava_candidates( be, &f->f_ava, LDAP_FILTER_EQUALITY );
index c5bc3f052402b2c4a30d44773c8548f1f5b57038..00d5bf6988e2227ff443cad15282b90783016477 100644 (file)
 #include "slap.h"
 #include "back-ldbm.h"
 
-#ifndef DN_INDICES
-int
-id2children_add(
-    Backend    *be,
-    Entry      *p,
-    Entry      *e
-)
-{
-       DBCache *db;
-       Datum           key;
-       char            buf[20];
-
-       ldbm_datum_init( key );
-
-       Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %ld, %ld )\n",
-              p ? p->e_id : 0, e->e_id, 0 );
-
-       if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
-           LDBM_WRCREAT )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "<= id2children_add -1 could not open \"id2children%s\"\n",
-                   LDBM_SUFFIX, 0, 0 );
-               return( -1 );
-       }
-
-       sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
-       key.dptr = buf;
-       key.dsize = strlen( buf ) + 1;
-
-       if ( idl_insert_key( be, db, key, e->e_id ) != 0 ) {
-               Debug( LDAP_DEBUG_TRACE, "<= id2children_add -1 (idl_insert)\n",
-                   0, 0, 0 );
-               ldbm_cache_close( be, db );
-               return( -1 );
-       }
-
-       ldbm_cache_close( be, db );
-
-       Debug( LDAP_DEBUG_TRACE, "<= id2children_add 0\n", 0, 0, 0 );
-       return( 0 );
-}
-
-
-int
-id2children_remove(
-    Backend    *be,
-    Entry      *p,
-    Entry      *e
-)
-{
-       DBCache *db;
-       Datum           key;
-       char            buf[20];
-
-       Debug( LDAP_DEBUG_TRACE, "=> id2children_remove( %ld, %ld )\n", p ? p->e_id
-           : 0, e->e_id, 0 );
-
-       if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
-           LDBM_WRCREAT )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "<= id2children_remove -1 could not open \"id2children%s\"\n",
-                   LDBM_SUFFIX, 0, 0 );
-               return( -1 );
-       }
-
-       ldbm_datum_init( key );
-       sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
-       key.dptr = buf;
-       key.dsize = strlen( buf ) + 1;
-
-       if ( idl_delete_key( be, db, key, e->e_id ) != 0 ) {
-#if 0
-               Debug( LDAP_DEBUG_ANY,
-                       "<= id2children_remove: idl_delete_key failure\n",
-                   0, 0, 0 );
-               ldbm_cache_close( be, db );
-               return( -1 );
-#else
-               Debug( LDAP_DEBUG_ANY,
-                       "<= id2children_remove: ignoring idl_delete_key failure\n",
-                   0, 0, 0 );
-#endif
-       }
-
-       ldbm_cache_close( be, db );
-
-       Debug( LDAP_DEBUG_TRACE, "<= id2children_remove 0\n", 0, 0, 0 );
-       return( 0 );
-}
-#endif
 
 int
 has_children(
@@ -115,28 +25,11 @@ has_children(
        Datum           key;
        int             rc = 0;
        ID_BLOCK                *idl;
-#ifndef DN_INDICES
-       char            buf[20];
-#endif
 
        ldbm_datum_init( key );
 
        Debug( LDAP_DEBUG_TRACE, "=> has_children( %ld )\n", p->e_id , 0, 0 );
 
-#ifndef DN_INDICES
-       if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
-           LDBM_WRCREAT )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "<= has_children -1 could not open \"id2children%s\"\n",
-                   LDBM_SUFFIX, 0, 0 );
-               return( 0 );
-       }
-
-       sprintf( buf, "%c%ld", EQ_PREFIX, p->e_id );
-       key.dptr = buf;
-       key.dsize = strlen( buf ) + 1;
-
-#else
        if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX,
            LDBM_WRCREAT )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
@@ -148,10 +41,11 @@ has_children(
        key.dsize = strlen( p->e_ndn ) + 2;
        key.dptr = ch_malloc( key.dsize );
        sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, p->e_ndn );
-#endif
 
        idl = idl_fetch( be, db, key );
 
+       free( key.dptr );
+
        ldbm_cache_close( be, db );
 
        if( idl != NULL ) {
index f33630e9cd16253a260ba2d222d9cde74ad6fce0..982e816d6b57a8aec8fa9a59bf20cc9660d419f3 100644 (file)
@@ -43,7 +43,7 @@ id2entry_add( Backend *be, Entry *e )
        key.dsize = sizeof(ID);
 
        ldap_pvt_thread_mutex_lock( &entry2str_mutex );
-       data.dptr = entry2str( e, &len, 1 );
+       data.dptr = entry2str( e, &len );
        data.dsize = len + 1;
 
        /* store it */
@@ -144,7 +144,6 @@ id2entry_rw( Backend *be, ID id, int rw )
        }
 
        e = str2entry( data.dptr );
-
        ldbm_datum_free( db->dbc_db, data );
        ldbm_cache_close( be, db );
 
@@ -154,12 +153,7 @@ id2entry_rw( Backend *be, ID id, int rw )
                return( NULL );
        }
 
-       if ( e->e_id != id ) {
-               Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (wrong id %ld on disk)\n",
-                       rw ? "w" : "r", id, e->e_id );
-               entry_free( e );
-               return( NULL );
-       }
+       e->e_id = id;
 
        if( cache_add_entry_rw( &li->li_cache, e, rw ) != 0 ) {
                entry_free( e );
index eb68a95c7f2933c327018f0a6e157cb0a1712b9e..47c8a305cc6fa5399c6142f1ee6f4989eb555e6e 100644 (file)
@@ -45,7 +45,6 @@ idl_allids( Backend *be )
        return( idl );
 }
 
-
 /* Free an ID_BLOCK */
 void
 idl_free( ID_BLOCK *idl )
@@ -72,8 +71,6 @@ idl_fetch_one(
        Datum   data;
        ID_BLOCK        *idl;
 
-       ldbm_datum_init( data );
-
        /* Debug( LDAP_DEBUG_TRACE, "=> idl_fetch_one\n", 0, 0, 0 ); */
 
        data = ldbm_cache_fetch( db, key );
@@ -148,13 +145,9 @@ idl_fetch(
        for ( i = 0; !ID_BLOCK_NOID(idl, i); i++ ) {
                ldbm_datum_init( data );
 
-#ifndef CONT_POSTFIX
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                       key.dptr, ID_BLOCK_ID(idl, i) );
-#else
                sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                        ID_BLOCK_ID(idl, i), key.dptr );
-#endif
+
                data.dptr = kstr;
                data.dsize = strlen( kstr ) + 1;
 
@@ -307,13 +300,9 @@ idl_change_first(
        }
 
        /* write block with new key */
-#ifdef CONT_POSTFIX
-       sprintf( bkey.dptr, "%c%s%ld", CONT_PREFIX,
-               hkey.dptr, ID_BLOCK_ID(b, 0) );
-#else
        sprintf( bkey.dptr, "%c%ld%s", CONT_PREFIX,
                ID_BLOCK_ID(b, 0), hkey.dptr );
-#endif
+
        bkey.dsize = strlen( bkey.dptr ) + 1;
        if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
                Debug( LDAP_DEBUG_ANY,
@@ -405,25 +394,16 @@ idl_insert_key(
 
                        /* store the first id block */
                        kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
-#ifdef CONT_POSTFIX
-                       sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                               key.dptr, ID_BLOCK_ID(tmp, 0) );
-#else
                        sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                                ID_BLOCK_ID(tmp, 0), key.dptr );
-#endif
+
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        rc = idl_store( be, db, k2, tmp );
 
                        /* store the second id block */
-#ifdef CONT_POSTFIX
-                       sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                               key.dptr, ID_BLOCK_ID(tmp2, 0) );
-#else
                        sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                                ID_BLOCK_ID(tmp2, 0), key.dptr );
-#endif
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        rc = idl_store( be, db, k2, tmp2 );
@@ -458,13 +438,8 @@ idl_insert_key(
 
        /* get the block */
        kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
-#ifdef CONT_POSTFIX
-       sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-               key.dptr, ID_BLOCK_ID(idl, i) );
-#else
        sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                ID_BLOCK_ID(idl, i), key.dptr );
-#endif
        k2.dptr = kstr;
        k2.dsize = strlen( kstr ) + 1;
        if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
@@ -508,13 +483,8 @@ idl_insert_key(
                /* is there a next block? */
                if ( !first && !ID_BLOCK_NOID(idl, i + 1) ) {
                        /* read it in */
-#ifdef CONT_POSTFIX
-                       sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                               key.dptr, ID_BLOCK_ID(idl, i + 1) );
-#else
                        sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                                ID_BLOCK_ID(idl, i + 1), key.dptr );
-#endif
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) {
@@ -571,13 +541,8 @@ idl_insert_key(
 
                        /* delete all indirect blocks */
                        for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) {
-#ifdef CONT_POSTFIX
-                               sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                                       key.dptr, ID_BLOCK_ID(idl, j) );
-#else
                                sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                                        ID_BLOCK_ID(idl, j), key.dptr );
-#endif
                                k2.dptr = kstr;
                                k2.dsize = strlen( kstr ) + 1;
 
@@ -619,25 +584,15 @@ idl_insert_key(
                rc = idl_store( be, db, key, tmp );
 
                /* store the first id block */
-#ifdef CONT_POSTFIX
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                       key.dptr, ID_BLOCK_ID(tmp2, 0) );
-#else
                sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                        ID_BLOCK_ID(tmp2, 0), key.dptr );
-#endif
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
                rc = idl_store( be, db, k2, tmp2 );
 
                /* store the second id block */
-#ifdef CONT_POSTFIX
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                       key.dptr, ID_BLOCK_ID(tmp3, 0) );
-#else
                sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                        ID_BLOCK_ID(tmp3, 0), key.dptr );
-#endif
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
                rc = idl_store( be, db, k2, tmp3 );
@@ -771,13 +726,8 @@ idl_delete_key (
        for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) 
        {
                ldbm_datum_init( data );
-#ifdef CONT_POSTFIX
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX,
-                       key.dptr, ID_BLOCK_ID(idl, j) );
-#else
                sprintf( kstr, "%c%ld%s", CONT_PREFIX,
                        ID_BLOCK_ID(idl, j), key.dptr );
-#endif
                data.dptr = kstr;
                data.dsize = strlen( kstr ) + 1;
 
index f10a5906fd98637689c67dc3efbd7e11e7dcce4b..b44ffab75650d0102ee2963d628e7ce10360762a 100644 (file)
@@ -50,7 +50,7 @@ index_add_entry(
        /* add the dn to the indexes */
        {
                char *dn = ch_strdup("dn");
-               index_change_values( be, dn, bvals, e->e_id, __INDEX_ADD_OP );
+               index_change_values( be, dn, bvals, e->e_id, SLAP_INDEX_ADD_OP );
                free( dn );
        }
 
@@ -58,9 +58,8 @@ index_add_entry(
 
        /* add each attribute to the indexes */
        for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) {
-
                index_change_values( be, ap->a_type, ap->a_vals, e->e_id,
-                                    __INDEX_ADD_OP );
+                                    SLAP_INDEX_ADD_OP );
        }
 
        Debug( LDAP_DEBUG_TRACE, "<= index_add( %ld, \"%s\" ) 0\n", e->e_id,
@@ -90,14 +89,14 @@ index_add_mods(
                                               mod->mod_type,
                                               mod->mod_bvalues,
                                               id,
-                                              __INDEX_ADD_OP);
+                                              SLAP_INDEX_ADD_OP );
                        break;
                case LDAP_MOD_DELETE:
                        rc =  index_change_values( be,
                                                   mod->mod_type,
                                                   mod->mod_bvalues,
                                                   id,
-                                                  __INDEX_DELETE_OP );
+                                                  SLAP_INDEX_DELETE_OP );
                        break;
                case LDAP_MOD_SOFTADD:  /* SOFTADD means index was there */
                        rc = 0;
@@ -159,17 +158,18 @@ index_read(
        realval = val;
        tmpval = NULL;
        if ( prefix != UNKNOWN_PREFIX ) {
-              unsigned int     len = strlen( val );
+               unsigned int    len = strlen( val );
 
-              if ( (len + 2) < sizeof(buf) ) {
+               if ( (len + 2) < sizeof(buf) ) {
                        realval = buf;
                } else {
                        /* value + prefix + null */
                        tmpval = (char *) ch_malloc( len + 2 );
                        realval = tmpval;
                }
-              realval[0] = prefix;
-              strcpy( &realval[1], val );
+
+               realval[0] = prefix;
+               strcpy( &realval[1], val );
        }
 
        key.dptr = realval;
@@ -272,16 +272,16 @@ index_change_values(
        if( vals == NULL ) {
                Debug( LDAP_DEBUG_TRACE,
                        "=> index_change_values( %s, NULL, %ld, op=%s )\n", 
-                       type, id, ((op == __INDEX_ADD_OP) ? "ADD" : "DELETE" ) );
+                       type, id, ((op == SLAP_INDEX_ADD_OP) ? "ADD" : "DELETE" ) );
                return 0;
        }
 
        Debug( LDAP_DEBUG_TRACE,
               "=> index_change_values( \"%s\", %ld, op=%s )\n", 
-              type, id, ((op == __INDEX_ADD_OP) ? "ADD" : "DELETE" ) );
+              type, id, ((op == SLAP_INDEX_ADD_OP) ? "ADD" : "DELETE" ) );
 
        
-       if (op == __INDEX_ADD_OP) {
+       if (op == SLAP_INDEX_ADD_OP) {
 
            /* Add values */
 
@@ -433,7 +433,7 @@ index_change_values(
 
        return( 0 );
 
-}/* int index_change_values() */
+}
 
 static int
 index2prefix( int indextype )
index abfc3ec5cb16a411863137c82ea2d7741cd36de8..770f5883ed22cac6103ea4db2295aab1b90814aa 100644 (file)
@@ -58,6 +58,19 @@ ldbm_back_initialize(
        bi->bi_entry_release_rw = ldbm_back_entry_release_rw;
        bi->bi_acl_group = ldbm_back_group;
 
+       /*
+        * hooks for slap tools
+        */
+       bi->bi_tool_entry_open = ldbm_tool_entry_open;
+       bi->bi_tool_entry_close = ldbm_tool_entry_close;
+       bi->bi_tool_entry_first = ldbm_tool_entry_first;
+       bi->bi_tool_entry_next = ldbm_tool_entry_next;
+       bi->bi_tool_entry_get = ldbm_tool_entry_get;
+       bi->bi_tool_entry_put = ldbm_tool_entry_put;
+       bi->bi_tool_index_attr = ldbm_tool_index_attr;
+       bi->bi_tool_index_change = ldbm_tool_index_change;
+       bi->bi_tool_sync = ldbm_tool_sync;
+
        bi->bi_connection_init = 0;
        bi->bi_connection_destroy = 0;
 
@@ -110,10 +123,6 @@ ldbm_back_db_init(
        /* arrange to read nextid later (on first request for it) */
        li->li_nextid = NOID;
 
-#if SLAPD_NEXTID_CHUNK > 1
-       li->li_nextid_wrote = NOID;
-#endif
-
        /* default cache size */
        li->li_cache.c_maxsize = DEFAULT_CACHE_SIZE;
 
@@ -129,29 +138,11 @@ ldbm_back_db_init(
        /* default database directory */
        li->li_directory = ch_strdup( DEFAULT_DB_DIRECTORY );
 
-#ifndef DN_INDICES
-       /* always index dn, id2children, objectclass (used in some searches) */
-       if ( !at_find( "dn" ) ) {
-               argv[ 0 ] = "dn";
-               argv[ 1 ] = "dn";
-               argv[ 2 ] = NULL;
-               attr_syntax_config( "ldbm dn initialization", 0, 2, argv );
-       }
-       argv[ 0 ] = "dn";
-       argv[ 1 ] = "eq,sub";
-       argv[ 2 ] = NULL;
-       attr_index_config( li, "ldbm dn initialization", 0, 2, argv, 1 );
-       argv[ 0 ] = "id2children";
-       argv[ 1 ] = "eq";
-       argv[ 2 ] = NULL;
-       attr_index_config( li, "ldbm id2children initialization", 0, 2, argv,
-           1 );
-#endif
        argv[ 0 ] = "objectclass";
        argv[ 1 ] = "pres,eq";
        argv[ 2 ] = NULL;
-       attr_index_config( li, "ldbm objectclass initialization", 0, 2, argv,
-           1 );
+       attr_index_config( li, "ldbm objectclass initialization",
+               0, 2, argv, 1 );
 
        /* initialize various mutex locks & condition variables */
        ldap_pvt_thread_mutex_init( &li->li_root_mutex );
index 6f58b94767eff27f6fca1ca4828107300eeff678..267222b01c50b243e49cf1174fae634e70e40381 100644 (file)
@@ -134,7 +134,7 @@ int ldbm_modify_internal(
                                                mod->mod_type,
                                                a->a_vals,
                                                e->e_id,
-                                               __INDEX_DELETE_OP);
+                                               SLAP_INDEX_DELETE_OP);
                                }
                        }
                }
index 0e45fced41691d42fe1ac8e822475b65827346d5..af718a10dc979f7fddb5fc5467d8349ca773ba19 100644 (file)
@@ -1,4 +1,4 @@
-/* id.c - keep track of the next id to be given out */
+/* nextid.c - keep track of the next id to be given out */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 #include "slap.h"
 #include "back-ldbm.h"
 
-/* All functions except put_nextid() obey slapMode == SLAP_TOOL_MODE. */
-
-static ID  next_id_read( Backend *be );
-static ID  next_id_get_save( Backend *be, int do_save );
-
-#define    next_id_write( be, id ) \
-       (slapMode == SLAP_TOOL_MODE ? (be, id, 0) : put_nextid( be, id ))
-
 static ID
 next_id_read( Backend *be )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       ID      id;
-       char    buf[20];
-       char*   file = li->li_nextid_file; 
-       FILE*   fp;
-
-       if ( slapMode == SLAP_TOOL_MODE )
-               return NOID;
-
-       if ( (fp = fopen( file, "r" )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "next_id_read: could not open \"%s\"\n",
-                   file, 0, 0 );
-               return NOID;
+       ID id = NOID;
+       Datum key, data;
+       DBCache *db;
+
+       if ( (db = ldbm_cache_open( be, "nextid", LDBM_SUFFIX, LDBM_WRCREAT ))
+           == NULL ) {
+               Debug( LDAP_DEBUG_ANY, "Could not open/create nextid" LDBM_SUFFIX "\n",
+                       0, 0, 0 );
+               return( NOID );
        }
 
-       if ( fgets( buf, sizeof(buf), fp ) == NULL ) {
-               Debug( LDAP_DEBUG_ANY,
-                  "next_id_read: could not fgets nextid from \"%s\"\n",
-                   file, 0, 0 );
-               fclose( fp );
-               return NOID;
-       }
+       ldbm_datum_init( key );
+       key.dptr = (char *) &id;
+       key.dsize = sizeof(ID);
+
+       data = ldbm_cache_fetch( db, key );
 
-       id = atol( buf );
-       fclose( fp );
+       if( data.dptr != NULL ) {
+               memcpy( &id, data.dptr, sizeof( ID ) );
+               ldbm_datum_free( db->dbc_db, data );
 
-       if(id < 1) {
-               Debug( LDAP_DEBUG_ANY,
-                       "next_id_read %ld: atol(%s) return non-positive integer\n",
-                       id, buf, 0 );
-               return NOID;
+       } else {
+               id = 1;
        }
 
+       ldbm_cache_close( be, db );
        return id;
 }
 
-int
-put_nextid( Backend *be, ID id )
+ID
+next_id_write( Backend *be, ID id )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       char*   file = li->li_nextid_file; 
-       FILE*   fp;
-       int             rc;
-
-       if ( (fp = fopen( file, "w" )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "put_nextid(%ld): could not open \"%s\"\n",
-                   id, file, 0 );
-               return -1;
-       } 
-
-       rc = 0;
-
-       if ( fprintf( fp, "%ld\n", id ) == EOF ) {
-               Debug( LDAP_DEBUG_ANY, "put_nextid(%ld): cannot fprintf\n",
-                   id, 0, 0 );
-               rc = -1;
+       Datum key, data;
+       DBCache *db;
+       ID noid = NOID;
+       int flags;
+
+       if ( (db = ldbm_cache_open( be, "nextid", LDBM_SUFFIX, LDBM_WRCREAT ))
+           == NULL ) {
+               Debug( LDAP_DEBUG_ANY, "Could not open/create nextid" LDBM_SUFFIX "\n",
+                   0, 0, 0 );
+               return( NOID );
        }
 
-       if( fclose( fp ) != 0 ) {
-               Debug( LDAP_DEBUG_ANY, "put_nextid %ld: cannot fclose\n",
-                   id, 0, 0 );
-               rc = -1;
-       }
-
-       return rc;
-}
-
-int
-next_id_save( Backend *be )
-{
-       return( next_id_get_save( be, 1 ) == NOID ? -1 : 0 );
-}
-
-ID
-next_id( Backend *be )
-{
-       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       ID              id;
+       ldbm_datum_init( key );
+       ldbm_datum_init( data );
 
-       ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex );
+       key.dptr = (char *) &noid;
+       key.dsize = sizeof(ID);
 
-       /* first time in here since startup - try to read the nexid */
-       if ( li->li_nextid == NOID ) {
-               li->li_nextid = next_id_read( be );
+       data.dptr = (char *) &id;
+       data.dsize = sizeof(ID);
 
-               if ( li->li_nextid == NOID ) {
-                       li->li_nextid = 1;
-               }
+       flags = LDBM_REPLACE;
+       if( li->li_dbcachewsync ) flags |= LDBM_SYNC;
 
-#if SLAPD_NEXTID_CHUNK > 1
-               li->li_nextid_wrote = li->li_nextid;
-#endif
+       if ( ldbm_cache_store( db, key, data, flags ) != 0 ) {
+               id = NOID;
        }
 
-       id = li->li_nextid++;
-
-#if SLAPD_NEXTID_CHUNK > 1
-       if ( li->li_nextid > li->li_nextid_wrote ) {
-               li->li_nextid_wrote += SLAPD_NEXTID_CHUNK;
-               (void) next_id_write( be, li->li_nextid_wrote );
-       }
-#else
-       (void) next_id_write( be, li->li_nextid );
-#endif
-
-       ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
-       return( id );
+       ldbm_cache_close( be, db );
+       return id;
 }
 
-void
-next_id_return( Backend *be, ID id )
+ID
+next_id_get( Backend *be )
 {
-#ifdef SLAPD_NEXTID_RETURN
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       ID id = NOID;
 
        ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex );
 
-       if ( id != li->li_nextid - 1 ) {
-               ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
-               return;
+       if ( li->li_nextid == NOID ) {
+               li->li_nextid = next_id_read( be );
        }
 
-       li->li_nextid--;
-
-#if !( SLAPD_NEXTID_CHUNK > 1 )
-       (void) next_id_write( be, li->li_nextid );
-#endif
+       id = li->li_nextid;
 
        ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
-#endif
+       return id;
 }
 
 ID
-next_id_get( Backend *be )
-{
-       return next_id_get_save( be, 0 );
-}
-
-static ID
-next_id_get_save( Backend *be, int do_save )
+next_id( Backend *be )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       ID              id;
+       ID id = NOID;
 
        ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex );
 
-       /* first time in here since startup - try to read the nexid */
        if ( li->li_nextid == NOID ) {
                li->li_nextid = next_id_read( be );
-
-               if ( li->li_nextid == NOID ) {
-                       li->li_nextid = 1;
-               }
-
-#if SLAPD_NEXTID_CHUNK > 1
-               li->li_nextid_wrote = li->li_nextid;
-#endif
        }
 
-       id = li->li_nextid;
+       if ( li->li_nextid != NOID ) {
+               id = li->li_nextid++;
 
-       if ( do_save ) {
-               if ( next_id_write( be, id ) == 0 ) {
-                       li->li_nextid_wrote = id;
-               } else {
-                       id = NOID;
-               }
+               (void) next_id_write( be, li->li_nextid );
        }
 
        ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
+       return id;
 
-       return( id );
 }
index 341a09ead25f8264d61e46fd7e1debf57b3f1ab2..9e14f239d11bc8bb28a96a539f3def839afe9997 100644 (file)
@@ -139,15 +139,12 @@ int index_add_mods LDAP_P(( Backend *be, LDAPModList *ml, ID id ));
 ID_BLOCK * index_read LDAP_P(( Backend *be,
        char *type, int indextype, char *val ));
 /* Possible operations supported (op) by index_change_values() */
-#define __INDEX_ADD_OP         0x0001
-#define __INDEX_DELETE_OP      0x0002
 int index_change_values LDAP_P(( Backend *be,
                                 char *type,
                                 struct berval **vals,
                                 ID  id,
                                 unsigned int op ));
 
-
 /*
  * kerberos.c
  */
@@ -179,11 +176,9 @@ int ldbm_modify_internal LDAP_P((Backend *be,
  * nextid.c
  */
 
-int put_nextid LDAP_P(( Backend *be, ID id ));
 ID next_id LDAP_P(( Backend *be ));
-void next_id_return LDAP_P(( Backend *be, ID id ));
 ID next_id_get LDAP_P(( Backend *be ));
-int next_id_save LDAP_P(( Backend *be ));
+ID next_id_write LDAP_P(( Backend *be, ID id ));
 
 LDAP_END_DECL
 #endif
index 6c2cc6169c708967c434b0b251b9774a51eed92e..32028a6544532332576a8554b654736351a32431 100644 (file)
@@ -400,40 +400,20 @@ search_candidates(
                lf->f_choice = LDAP_FILTER_AND;
                lf->f_and = (Filter *) ch_malloc( sizeof(Filter) );
 
-#ifndef DN_INDICES
-               lf->f_and->f_choice = LDAP_FILTER_SUBSTRINGS;
-               lf->f_and->f_sub_type = ch_strdup( "dn" );
-               lf->f_and->f_sub_initial = NULL;
-               lf->f_and->f_sub_any = NULL;
-               lf->f_and->f_sub_final = ch_strdup( e->e_ndn );
-#else
                lf->f_and->f_choice = SLAPD_FILTER_DN_SUBTREE;
                lf->f_and->f_dn = e->e_ndn;
-#endif
 
                lf->f_and->f_next = f;
                f = lf;
 
        } else if ( scope == LDAP_SCOPE_ONELEVEL ) {
-#ifndef DN_INDICES
-               char buf[16];
-#endif
-
                lf = (Filter *) ch_malloc( sizeof(Filter) );
                lf->f_next = NULL;
                lf->f_choice = LDAP_FILTER_AND;
                lf->f_and = (Filter *) ch_malloc( sizeof(Filter) );
 
-#ifndef DN_INDICES
-               lf->f_and->f_choice = LDAP_FILTER_EQUALITY;
-               lf->f_and->f_ava.ava_type = ch_strdup( "id2children" );
-               sprintf( buf, "%ld", e != NULL ? e->e_id : 0 );
-               lf->f_and->f_ava.ava_value.bv_val = ch_strdup( buf );
-               lf->f_and->f_ava.ava_value.bv_len = strlen( buf );
-#else
                lf->f_and->f_choice = SLAPD_FILTER_DN_ONE;
                lf->f_and->f_dn = e->e_ndn;
-#endif
 
                lf->f_and->f_next = f;
                f = lf;
@@ -446,13 +426,8 @@ search_candidates(
 
        /* free up filter additions we allocated above */
        if( lf != NULL ) {
-#ifndef DN_INDICES
-               lf->f_and->f_next = NULL;
-               filter_free( lf );
-#else
                free( lf->f_and );
                free( lf );
-#endif
        }
 
        if( af != NULL ) {
diff --git a/servers/slapd/back-ldbm/tools.c b/servers/slapd/back-ldbm/tools.c
new file mode 100644 (file)
index 0000000..fe593c7
--- /dev/null
@@ -0,0 +1,248 @@
+/* tools.c - tools for slap tools */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldbm.h"
+
+static LDBMCursor *cursorp = NULL;
+static DBCache *id2entry = NULL;
+
+int ldbm_tool_entry_open(
+       BackendDB *be, int mode )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       int flags;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry == NULL );
+
+       switch( mode ) {
+       case 1:
+               flags = LDBM_WRCREAT;
+               break;
+       case 2:
+#ifdef TRUNCATE_MODE
+               flags = LDBM_NEWDB;
+#else
+               flags = LDBM_WRCREAT;
+#endif
+               break;
+       default:
+               flags = LDBM_READER;
+       }
+
+       li->li_dbcachewsync = 0;
+
+       if ( (id2entry = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, flags ))
+           == NULL ) {
+               Debug( LDAP_DEBUG_ANY, "Could not open/create id2entry" LDBM_SUFFIX "\n",
+                   0, 0, 0 );
+               return( -1 );
+       }
+
+       return 0;
+}
+
+int ldbm_tool_entry_close(
+       BackendDB *be )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       ldbm_cache_close( be, id2entry );
+       li->li_dbcachewsync = 1;
+       id2entry = NULL;
+
+       return 0;
+}
+
+ID ldbm_tool_entry_first(
+       BackendDB *be )
+{
+       Datum key;
+       ID id;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       key = ldbm_firstkey( id2entry->dbc_db, &cursorp );
+
+       if( key.dptr == NULL ) {
+               return NOID;
+       }
+
+       memcpy( &id, key.dptr, key.dsize );
+
+       ldbm_datum_free( id2entry->dbc_db, key );
+
+       return id;
+}
+
+ID ldbm_tool_entry_next(
+       BackendDB *be )
+{
+       Datum key;
+       ID id;
+       int count;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       /* allow for NEXTID */
+       ldbm_datum_init( key );
+
+       key = ldbm_nextkey( id2entry->dbc_db, key, cursorp );
+
+       if( key.dptr == NULL ) {
+               return NOID;
+       }
+
+       memcpy( &id, key.dptr, key.dsize );
+
+       ldbm_datum_free( id2entry->dbc_db, key );
+
+       return id;
+}
+
+Entry* ldbm_tool_entry_get( BackendDB *be, ID id )
+{
+       Entry *e;
+       Datum key, data;
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       ldbm_datum_init( key );
+
+       key.dptr = (char *) &id;
+       key.dsize = sizeof(ID);
+
+       data = ldbm_cache_fetch( id2entry, key );
+
+       if ( data.dptr == NULL ) {
+               return NULL;
+       }
+
+       e = str2entry( data.dptr );
+       ldbm_datum_free( id2entry->dbc_db, data );
+
+       return e;
+}
+
+ID ldbm_tool_entry_put(
+       BackendDB *be,
+       Entry *e )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+       Datum key, data;
+       int rc, len;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+       assert( id2entry != NULL );
+
+       if( next_id_get( be ) == NOID ) {
+               return NOID;
+       }
+
+       e->e_id = li->li_nextid++;
+
+       Debug( LDAP_DEBUG_TRACE, "=> ldbm_tool_entry_put( %ld, \"%s\" )\n",
+               e->e_id, e->e_dn, 0 );
+
+       rc = index_add_entry( be, e );
+
+       if( rc != 0 ) {
+               return NOID;
+       }
+
+       rc = dn2id_add( be, e->e_ndn, e->e_id );
+
+       if( rc != 0 ) {
+               return NOID;
+       }
+
+       ldbm_datum_init( key );
+       ldbm_datum_init( data );
+
+       key.dptr = (char *) &e->e_id;
+       key.dsize = sizeof(ID);
+
+       data.dptr = entry2str( e, &len );
+       data.dsize = len + 1;
+
+       /* store it */
+       rc = ldbm_cache_store( id2entry, key, data, LDBM_REPLACE );
+
+       if( rc != 0 ) {
+               (void) dn2id_delete( be, e->e_ndn );
+               return NOID;
+       }
+
+       return e->e_id;
+}
+
+int ldbm_tool_index_attr(
+       BackendDB *be,
+       char* type )
+{
+       static DBCache *db = NULL;
+       int indexmask, syntaxmask;
+       char * at_cn;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+
+       attr_masks( be->be_private, type, &indexmask, &syntaxmask );
+
+       attr_normalize( type );
+       at_cn = at_canonical_name( type );
+
+       if ( (db = ldbm_cache_open( be, at_cn, LDBM_SUFFIX, LDBM_NEWDB ))
+           == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                   "<= index_read NULL (could not open %s%s)\n", at_cn,
+                   LDBM_SUFFIX, 0 );
+               return( NULL );
+       }
+
+       ldbm_cache_close( be, db );
+
+       return indexmask != 0;
+}
+
+int ldbm_tool_index_change(
+       BackendDB *be,
+       char* type,
+       struct berval **bv,
+       ID id,
+       int op )
+{
+       assert( slapMode & SLAP_TOOL_MODE );
+
+       index_change_values( be,
+               type, bv, id, op );
+
+       return 0;
+}
+
+int ldbm_tool_sync( BackendDB *be )
+{
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+
+       assert( slapMode & SLAP_TOOL_MODE );
+
+       if ( li->li_nextid != NOID ) {
+               next_id_write( be, li->li_nextid );
+       }
+
+       return 0;
+}
index 89193b499a4c9ee833fddb2dc91e7098e76f3120..ed30475ac9fa2eab7b87dc68beb104246fcef774 100644 (file)
@@ -34,14 +34,15 @@ perl_back_add(
 
        PerlBackend *perl_back = (PerlBackend *) be->be_private;
 
-       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
+       ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
+       ldap_pvt_thread_mutex_lock( &entry2str_mutex );
 
        {
                dSP; ENTER; SAVETMPS;
 
                PUSHMARK(sp);
                XPUSHs( perl_back->pb_obj_ref );
-               XPUSHs(sv_2mortal(newSVpv( entry2str( e, &len, 0 ), 0 )));
+               XPUSHs(sv_2mortal(newSVpv( entry2str( e, &len ), 0 )));
 
                PUTBACK;
 
@@ -58,6 +59,7 @@ perl_back_add(
                PUTBACK; FREETMPS; LEAVE;
        }
 
+       ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
        ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
 
        if( return_code != 0 ) {
index 9c033e7be853b8d73811bd3a0f7332b703db0bff..1c189a96d4b63f4dbbb1fce95a9137b881b3a256 100644 (file)
@@ -39,7 +39,7 @@ shell_back_add(
        fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        ldap_pvt_thread_mutex_lock( &entry2str_mutex );
-       fprintf( wfp, "%s", entry2str( e, &len, 0 ) );
+       fprintf( wfp, "%s", entry2str( e, &len ) );
        ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
        fclose( wfp );
 
index 879c9c34f80ca2279b2badca4cdab5101cd5d0ae..b1c64b5ac7e20ceb58a2ba505fc0c9f906c0fc9f 100644 (file)
@@ -1,6 +1,6 @@
 /* result.c - tcl backend utility functions
  *
- * $Id: tcl_util.c,v 1.7 1999/07/16 00:45:52 kdz Exp $
+ * $Id: tcl_util.c,v 1.8 1999/08/02 23:38:43 hallvard Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
@@ -110,9 +110,8 @@ tcl_clean_entry (
        char *entrystr, *mark1, *mark2, *buf, *bp, *dup;
        int len, bsize;
 
-       pthread_mutex_lock (&entry2str_mutex);
-       entrystr = entry2str (e, &len, 0);
-       pthread_mutex_unlock (&entry2str_mutex);
+       ldap_pvt_thread_mutex_lock(&entry2str_mutex);
+       entrystr = entry2str (e, &len);
 
        buf = (char *) ch_malloc (BUFSIZ);
        buf[0] = '\0';
@@ -147,6 +146,8 @@ tcl_clean_entry (
                }
                free (dup);
        } while ((mark1 = (char *) strchr (mark1, '\n')) != NULL);
+
+       ldap_pvt_thread_mutex_unlock (&entry2str_mutex);
        return buf;
 }
 
index 0c07a87a9bba3b0526c340a9fd96c1cb1216a67d..7e8a1cf327caebe660b2169e5130432310e776b7 100644 (file)
@@ -84,11 +84,10 @@ int backend_init(void)
        }
 
        for( ;
-               binfo[nBackendInfo].bi_type !=  NULL;
+               binfo[nBackendInfo].bi_type != NULL;
                nBackendInfo++ )
        {
-               rc = binfo[nBackendInfo].bi_init(
-                       &binfo[nBackendInfo] );
+               rc = binfo[nBackendInfo].bi_init( &binfo[nBackendInfo] );
 
                if(rc != 0) {
                        Debug( LDAP_DEBUG_ANY,
@@ -158,7 +157,7 @@ int backend_add(BackendInfo *aBackendInfo)
    }       
 }
 
-int backend_startup(int n)
+int backend_startup(Backend *be)
 {
        int i;
        int rc = 0;
@@ -171,24 +170,14 @@ int backend_startup(int n)
                return 1;
        }
 
-       if(n >= 0) {
+       if(be != NULL) {
                /* startup a specific backend database */
                Debug( LDAP_DEBUG_TRACE,
-                       "backend_startup: starting database %d\n",
-                       n, 0, 0 );
+                       "backend_startup: starting database\n",
+                       0, 0, 0 );
 
-               /* make sure, n does not exceed the number of backend databases */
-               if ( n >= nbackends ) {
-
-                       Debug( LDAP_DEBUG_ANY,
-                               "backend_startup: database number %d exceeding maximum (%d)\n",
-                               n, nbackends, 0 );
-                       return 1;
-               }
-
-               if ( backendDB[n].bd_info->bi_open ) {
-                       rc = backendDB[n].bd_info->bi_open(
-                               backendDB[n].bd_info );
+               if ( be->bd_info->bi_open ) {
+                       rc = be->bd_info->bi_open( be->bd_info );
                }
 
                if(rc != 0) {
@@ -198,9 +187,8 @@ int backend_startup(int n)
                        return rc;
                }
 
-               if ( backendDB[n].bd_info->bi_db_open ) {
-                       rc = backendDB[n].bd_info->bi_db_open(
-                               &backendDB[n] );
+               if ( be->bd_info->bi_db_open ) {
+                       rc = be->bd_info->bi_db_open( be );
                }
 
                if(rc != 0) {
@@ -251,36 +239,37 @@ int backend_startup(int n)
        return rc;
 }
 
-int backend_shutdown(int n)
+int backend_num( Backend *be )
 {
        int i;
-       int rc = 0;
 
-       if(n >= 0) {
-               /* shutdown a specific backend database */
+       if( be == NULL ) return -1;
+
+       for( i = 0; i < nBackendDB; i++ ) {
+               if( be == &backendDB[i] ) return i;
+       }
+       return -1;
+}
 
-               /* make sure, n does not exceed the number of backend databases */
-               if ( n >= nbackends ) {
+int backend_shutdown( Backend *be )
+{
+       int i;
+       int rc = 0;
 
-                       Debug( LDAP_DEBUG_ANY,
-                               "backend_startup: database number %d exceeding maximum (%d)\n",
-                               n, nbackends, 0 );
-                       return 1;
-               }
+       if( be != NULL ) {
+               /* shutdown a specific backend database */
 
-               if ( backendDB[n].bd_info->bi_nDB == 0 ) {
+               if ( be->bd_info->bi_nDB == 0 ) {
                        /* no database of this type, we never opened it */
                        return 0;
                }
 
-               if ( backendDB[n].bd_info->bi_db_close ) {
-                       backendDB[n].bd_info->bi_db_close(
-                               &backendDB[n] );
+               if ( be->bd_info->bi_db_close ) {
+                       be->bd_info->bi_db_close( be );
                }
 
-               if( backendDB[n].bd_info->bi_close ) {
-                       backendDB[n].bd_info->bi_close(
-                               backendDB[n].bd_info );
+               if( be->bd_info->bi_close ) {
+                       be->bd_info->bi_close( be->bd_info );
                }
 
                return 0;
index d58b4a70931b07a894b68c9b70bbcccda51eed8a..370864ba77a232f4807d5f0a8db761fe84b832c5 100644 (file)
@@ -20,9 +20,8 @@ static unsigned char  *ecur;  /* pointer to end of currently used ebuf */
 static int             emaxsize;/* max size of ebuf                     */
 
 Entry *
-str2entry( char        *s )
+str2entry( char *s )
 {
-       int                     id = 0;
        Entry           *e;
        Attribute       **a;
        char            *type;
@@ -35,9 +34,9 @@ str2entry( char       *s )
        char            ptype[64];
 
        /*
-        * In string format, an entry looks like this:
+        * LDIF is used as the string format.
+        * An entry looks like this:
         *
-        *      <id>\n
         *      dn: <dn>\n
         *      [<attr>:[:] <value>\n]
         *      [<tab><continuedvalue>\n]*
@@ -52,17 +51,7 @@ str2entry( char      *s )
        Debug( LDAP_DEBUG_TRACE, "=> str2entry\n",
                s ? s : "NULL", 0, 0 );
 
-       /* check to see if there's an id included */
        next = s;
-       if ( isdigit( (unsigned char) *s ) ) {
-               id = atoi( s );
-               if ( (s = ldif_getline( &next )) == NULL ) {
-                       Debug( LDAP_DEBUG_TRACE,
-                           "<= str2entry NULL (missing newline after id)\n",
-                           0, 0, 0 );
-                       return( NULL );
-               }
-       }
 
        /* initialize reader/writer lock */
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
@@ -74,7 +63,7 @@ str2entry( char       *s )
                return( NULL );
        }
 
-       e->e_id = id;
+       e->e_id = NOID;
        e->e_private = NULL;
 
        /* dn + attributes */
@@ -172,9 +161,7 @@ str2entry( char     *s )
 char *
 entry2str(
     Entry      *e,
-    int                *len,
-    int                printid
-)
+    int                *len )
 {
        Attribute       *a;
        struct berval   *bv;
@@ -189,13 +176,6 @@ entry2str(
 
        ecur = ebuf;
 
-       if ( printid ) {
-               /* id + newline */
-               MAKE_SPACE( 10 );
-               sprintf( (char *) ecur, "%ld\n", e->e_id );
-               ecur = (unsigned char *) strchr( (char *) ecur, '\0' );
-       }
-
        /* put the dn */
        if ( e->e_dn != NULL ) {
                /* put "dn: <dn>" */
index f11af8f24aa21c614e94c7448ea1acee8c14d02c..5e0fcb3e381bf06063f3d86c47c4f036f8950407 100644 (file)
@@ -70,6 +70,8 @@ slap_init( int mode, char *name )
 {
        int rc;
 
+       assert( mode );
+
        if( slapMode != SLAP_UNDEFINED_MODE ) {
                Debug( LDAP_DEBUG_ANY,
                 "%s init: init called twice (old=%d, new=%d)\n",
@@ -79,18 +81,12 @@ slap_init( int mode, char *name )
 
        slapMode = mode;
 
-       switch ( slapMode ) {
-
+       switch ( slapMode & SLAP_MODE ) {
                case SLAP_SERVER_MODE:
                case SLAP_TOOL_MODE:
-#ifdef SLAP_TIMEDSERVER_MODE
-               case SLAP_TIMEDSERVER_MODE:
-#endif
-               case SLAP_TOOLID_MODE:
-
                        Debug( LDAP_DEBUG_TRACE,
                                "%s init: initiated %s.\n",
-                               name, (mode == SLAP_TOOL_MODE || mode == SLAP_TOOLID_MODE) ? "tool" : "server", 0 );
+                               name, ( mode & SLAP_TOOL_MODE ) ? "tool" : "server", 0 );
 
                        slap_name = name;
        
@@ -110,7 +106,7 @@ slap_init( int mode, char *name )
                        ldap_pvt_thread_mutex_init( &crypt_mutex );
 #endif
 
-                       rc = backend_init();
+                       rc = backend_init( );
                        break;
 
                default:
@@ -123,7 +119,7 @@ slap_init( int mode, char *name )
        return rc;
 }
 
-int slap_startup(int dbnum)
+int slap_startup( Backend *be )
 {
        int rc;
 
@@ -131,7 +127,7 @@ int slap_startup(int dbnum)
                "%s startup: initiated.\n",
                slap_name, 0, 0 );
 
-       rc = backend_startup(dbnum);
+       rc = backend_startup( be );
 
        if( rc == 0 ) {
                rc = sasl_init();
@@ -140,7 +136,7 @@ int slap_startup(int dbnum)
        return rc;
 }
 
-int slap_shutdown(int dbnum)
+int slap_shutdown( Backend *be )
 {
        int rc;
 
@@ -151,7 +147,7 @@ int slap_shutdown(int dbnum)
        sasl_destroy();
 
        /* let backends do whatever cleanup they need to do */
-       rc = backend_shutdown(dbnum); 
+       rc = backend_shutdown( be ); 
 
        return rc;
 }
index 8386f6eeb98ebe4f0a1185a438a9a016d47a8bc7..9d0544573b667f45682eaf9b2c40c355421019ab 100644 (file)
@@ -282,7 +282,7 @@ int main( int argc, char **argv )
 
 #ifdef SLAPD_BDB2
                case 't':  /* timed server */
-                       serverMode = SLAP_TIMEDSERVER_MODE;
+                       serverMode |= SLAP_TIMED_MODE;
                        break;
 #endif
 
@@ -384,7 +384,7 @@ int main( int argc, char **argv )
 #endif
 #endif /* HAVE_WINSOCK */
 
-       if ( slap_startup(-1)  != 0 ) {
+       if ( slap_startup( NULL )  != 0 ) {
                rc = 1;
                SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
                goto shutdown;
@@ -427,7 +427,7 @@ int main( int argc, char **argv )
 
 shutdown:
        /* remember an error during shutdown */
-       rc |= slap_shutdown(-1);
+       rc |= slap_shutdown( NULL );
 destroy:
        /* remember an error during destroy */
        rc |= slap_destroy();
index 801dbd2afcc0c5c30637a69798ce49fb68f3445f..5c29a9cf75a0ec1e03e35e4c18328fdd1da0747d 100644 (file)
@@ -79,8 +79,9 @@ void ava_free LDAP_P(( Ava *ava, int freeit ));
 
 int backend_init LDAP_P((void));
 int backend_add LDAP_P((BackendInfo *aBackendInfo));
-int backend_startup LDAP_P((int dbnum));
-int backend_shutdown LDAP_P((int dbnum));
+int backend_num LDAP_P((Backend *be));
+int backend_startup LDAP_P((Backend *be));
+int backend_shutdown LDAP_P((Backend *be));
 int backend_destroy LDAP_P((void));
 
 BackendInfo * backend_info LDAP_P(( char *type ));
@@ -206,7 +207,7 @@ void build_new_dn LDAP_P(( char ** new_dn, char *e_dn, char * p_dn,
  */
 
 Entry * str2entry LDAP_P(( char        *s ));
-char * entry2str LDAP_P(( Entry *e, int *len, int printid ));
+char * entry2str LDAP_P(( Entry *e, int *len ));
 void entry_free LDAP_P(( Entry *e ));
 
 int entry_cmp LDAP_P(( Entry *a, Entry *b ));
@@ -441,8 +442,8 @@ extern ldap_pvt_thread_mutex_t      gmtime_mutex;
 extern AccessControl *global_acl;
 
 int    slap_init LDAP_P((int mode, char* name));
-int    slap_startup LDAP_P((int dbnum));
-int    slap_shutdown LDAP_P((int dbnum));
+int    slap_startup LDAP_P(( Backend *be ));
+int    slap_shutdown LDAP_P(( Backend *be ));
 int    slap_destroy LDAP_P((void));
 
 struct sockaddr_in;
index 8f8b6439221e8c499a3e2e655c588532176c4082..39e4e7121843c750f05ed2169ce7d5dab5459a3d 100644 (file)
@@ -99,7 +99,7 @@ replog(
                e = change;
                fprintf( fp, "changetype: add\n" );
                ldap_pvt_thread_mutex_lock( &entry2str_mutex );
-               tmp = entry2str( e, &len, 0 );
+               tmp = entry2str( e, &len );
                while ( (tmp = strchr( tmp, '\n' )) != NULL ) {
                        tmp++;
                        if ( ! isspace( (unsigned char) *tmp ) )
index a9a21d14673e52f413a5a70760d41ffc3c219698..bc67e28b85d554ddd3cb1e4a682fcae1c44bb09f 100644 (file)
@@ -390,12 +390,15 @@ extern int nBackendDB;
 extern BackendInfo     *backendInfo;
 extern BackendDB       *backendDB;
 
-extern int                     slapMode;       
-#define SLAP_UNDEFINED_MODE    0
-#define SLAP_SERVER_MODE       1
-#define SLAP_TOOL_MODE         2
+extern int slapMode;   
+#define SLAP_UNDEFINED_MODE    0x0000
+#define SLAP_SERVER_MODE       0x0001
+#define SLAP_TOOL_MODE         0x0002
+#define SLAP_MODE                      0x0003
+
+#define SLAP_TRUNCATE_MODE     0x0100
 #ifdef SLAPD_BDB2
-#  define SLAP_TIMEDSERVER_MODE  3
+#define SLAP_TIMED_MODE                0x1000
 #endif
 #define SLAP_TOOLID_MODE    4
 
@@ -426,6 +429,17 @@ struct slap_backend_db {
 #define                be_connection_init      bd_info->bi_connection_init
 #define                be_connection_destroy   bd_info->bi_connection_destroy
 
+#ifdef SLAPD_TOOLS
+#define                be_entry_open bd_info->bi_tool_entry_open
+#define                be_entry_close bd_info->bi_tool_entry_close
+#define                be_entry_first bd_info->bi_tool_entry_first
+#define                be_entry_next bd_info->bi_tool_entry_next
+#define                be_entry_get bd_info->bi_tool_entry_get
+#define                be_entry_put bd_info->bi_tool_entry_put
+#define                be_index_attr bd_info->bi_tool_index_attr
+#define                be_index_change bd_info->bi_tool_index_change
+#define                be_sync bd_info->bi_tool_sync
+#endif
 
        /* these should be renamed from be_ to bd_ */
        char    **be_suffix;    /* the DN suffixes of data in this backend */
@@ -554,6 +568,20 @@ struct slap_backend_info {
        int     (*bi_connection_destroy) LDAP_P((BackendDB *bd,
                struct slap_conn *c));
 
+       /* hooks for slap tools */
+       int (*bi_tool_entry_open) LDAP_P(( BackendDB *be, int mode ));
+       int (*bi_tool_entry_close) LDAP_P(( BackendDB *be ));
+       ID (*bi_tool_entry_first) LDAP_P(( BackendDB *be ));
+       ID (*bi_tool_entry_next) LDAP_P(( BackendDB *be ));
+       Entry* (*bi_tool_entry_get) LDAP_P(( BackendDB *be, ID id ));
+       ID (*bi_tool_entry_put) LDAP_P(( BackendDB *be, Entry *e ));
+       int (*bi_tool_index_attr) LDAP_P(( BackendDB *be, char* type ));
+       int (*bi_tool_index_change) LDAP_P(( BackendDB *be, char* type,
+               struct berval **bv, ID id, int op ));
+       int (*bi_tool_sync) LDAP_P(( BackendDB *be ));
+
+#define SLAP_INDEX_ADD_OP              0x0001
+#define SLAP_INDEX_DELETE_OP   0x0002
 
        unsigned int bi_nDB;    /* number of databases of this type */
        void    *bi_private;    /* anything the backend type needs */
index 731d6fbaf6e102d89c62dfb633aa8c71ae785f4d..4e04a7391e0a7372c7e8db4fbddf3fcf3e1029ab 100644 (file)
@@ -12,9 +12,9 @@
 #       Stand alone LDAP server tools makefile
 #
 #-----------------------------------------------------------------------------
-HAVE_QUIPU = @BUILD_QUIPU@
 BUILD_LDBM = @BUILD_LDBM@
 BUILD_BDB2 = @BUILD_BDB2@
+BUILD_QUIPU = @BUILD_QUIPU@
 
 LDAP_INCDIR= ../../../include       
 LDAP_LIBDIR= ../../../libraries
@@ -30,133 +30,110 @@ XXLIBS = $(LDAPD_LIBS) $(SLAPD_LIBS) \
        $(LDIF_LIBS) $(LUTIL_LIBS)
 XXXLIBS = $(LTHREAD_LIBS) $(MODULES_LIBS)
 
-PROGRAMS=ldif2index ldif2ldbm ldbmcat ldif2id2entry ldif2id2children \
-       centipede ldbmtest ldif
+PROGRAMS=ldif slapadd slapcat slapindex
+LDBMPROGRAMS=centipede sizecount
+BDB2PROGRAMS=
+QUIPUPROGRAMS=chlog2replog edb2ldif
 
-PROGRAMS2=ldif2index-bdb2 ldif2ldbm-bdb2 \
-       ldif2id2entry-bdb2 ldif2id2children-bdb2
-
-SRCS = centipede.c ldbmcat.c ldbmtest.c sizecount.c \
-       ldif.c ldif2id2children.c ldif2id2entry.c ldif2index.c ldif2ldbm.c \
-       mimic.c ldif2common.c
-
-SRCS2 = ldif2id2children-bdb2.c ldif2id2entry-bdb2.c \
-       ldif2index-bdb2.c ldif2ldbm-bdb2.c
+SRCS = ldif.c mimic.c slapcommon.c
 
 XSRCS = edb2-vers.c
 
-EDB2LDIFSRCS   = edb2ldif.c ldapsyntax.c
-EDB2LDIFOBJS   = edb2ldif.o ldapsyntax.o
+LDBMSRCS = centipede.c sizecount.c
+
+BDB2SRCS =
 
-OBJS1  = mimic.o \
-               ../config.o ../ch_malloc.o ../backend.o ../charray.o \
+QUIPUSRCS      = edb2ldif.c ldapsyntax.c chlog2replog.c
+SLAPD_OBJS = ../config.o ../ch_malloc.o ../backend.o ../charray.o \
                ../module.o ../aclparse.o ../schema.o ../filterentry.o \
                ../acl.o ../phonetic.o ../attr.o ../value.o ../entry.o \
                ../dn.o ../filter.o ../str2filter.o ../ava.o ../init.o \
                ../controls.o ../schemaparse.o
-OBJS2  = $(OBJS1) ldif2common.o
+SLAPOBJS = $(SLAPD_OBJS) slapcommon.o mimic.o 
 
-all-local: build-ldbm build-bdb2 build-edb2ldif build-chlog2replog
+EDB2LDIFSRCS    = edb2ldif.c ldapsyntax.c
+EDB2LDIFOBJS    = edb2ldif.o ldapsyntax.o
+
+all-local: build-progs build-ldbm build-bdb2 build-quipu
+
+build-progs: $(PROGRAMS)
 
 build-ldbm: ldbm-tools-$(BUILD_LDBM)
 ldbm-tools-no:
        @echo "run configure with --enable-ldbm to build LDBM tools"
 
+ldbm-tools-yes ldbm-tools-mod: $(LDBMPROGRAMS)
+
 build-bdb2: bdb2-tools-$(BUILD_BDB2)
 bdb2-tools-no:
        @echo "run configure with --enable-bdb2 to build BDB2 tools"
 
-ldbm-tools-yes ldbm-tools-mod: $(PROGRAMS)
-
-bdb2-tools-yes bdb2-tools-mod: $(PROGRAMS2)
-
-build-edb2ldif:        edb-$(HAVE_QUIPU)
-edb-no:
-       @echo "run configure with --enable-quipu to build edb2ldif"
-edb-yes: edb2ldif
-
-edb2ldif:      edb2-vers.o
-       $(CC) $(LDFLAGS) -o $@ $(EDB2LDIFOBJS) edb2-vers.o $(LIBS)
-
-edb2-vers.c: $(EDB2LDIFOBJS)
-       @-$(RM) $@
-       $(MKVERSION) ebd2ldif > $@
-
-build-chlog2replog: chlog-$(HAVE_QUIPU)
-chlog-no:
-       @echo "run configure with --enable-quipu to build chlog2replog"
-chlog-yes: chlog2replog
-
-chlog2replog: chlog2replog.o ../lock.o ../ch_malloc.o $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ chlog2replog.o ../lock.o ../ch_malloc.o $(LIBS)
-
-ldif2index:    ldif2index.o ../libbackends.a $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2index.o $(OBJS2) ../libbackends.a $(LIBS)
-
-ldif2index-bdb2:       ldif2index-bdb2.o ../libbackends.a \
-               $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2index-bdb2.o $(OBJS2) ../libbackends.a $(LIBS)
+bdb2-tools-yes bdb2-tools-mod: $(BDB2PROGRAMS)
 
-ldif2ldbm:     ldif2ldbm.o ../libbackends.a $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2ldbm.o $(OBJS2) ../libbackends.a $(LIBS)
+build-quipu: quipu-tools-$(BUILD_QUIPU)
+quipu-tools-no:
+       @echo "run configure with --enable-quipu to build QUIPU tools"
 
-ldif2ldbm-bdb2:        ldif2ldbm-bdb2.o ../libbackends.a $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2ldbm-bdb2.o $(OBJS2) ../libbackends.a $(LIBS)
+quipu-tools-yes quipu-tools-mod: $(QUIPUPROGRAMS)
 
-ldif2id2entry: ldif2id2entry.o ../libbackends.a $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2id2entry.o $(OBJS2) ../libbackends.a $(LIBS)
-
-ldif2id2entry-bdb2:    ldif2id2entry-bdb2.o ../libbackends.a \
-               $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2id2entry-bdb2.o $(OBJS2) ../libbackends.a $(LIBS)
-
-ldif2id2children:      ldif2id2children.o ../libbackends.a \
-               $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2id2children.o $(OBJS2) ../libbackends.a $(LIBS)
+#
+# SLAP Tools
+#
+slapadd:       slapadd.o ../libbackends.a $(SLAPOBJS) $(SLAPD_LIBDEPEND) 
+       $(LTLINK) -o $@ slapadd.o $(SLAPOBJS) ../libbackends.a $(LIBS)
 
-ldif2id2children-bdb2: ldif2id2children-bdb2.o ../libbackends.a \
-               $(OBJS2) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldif2id2children-bdb2.o $(OBJS2) ../libbackends.a $(LIBS)
+slapcat:       slapcat.o ../libbackends.a $(SLAPOBJS) $(SLAPD_LIBDEPEND) 
+       $(LTLINK) -o $@ slapcat.o $(SLAPOBJS) ../libbackends.a $(LIBS)
 
-ldbmcat:       ldbmcat.o $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o $@ ldbmcat.o $(LIBS)
+slapindex:     slapindex.o ../libbackends.a $(SLAPOBJS) $(SLAPD_LIBDEPEND) 
+       $(LTLINK) -o $@ slapindex.o $(SLAPOBJS) ../libbackends.a $(LIBS)
 
 ldif:          ldif.o $(SLAPD_LIBDEPEND) 
        $(LTLINK) -o $@ ldif.o $(LIBS)
 
+#
+# LDBM Specific Tools
+#
 centipede:     centipede.o $(SLAPD_LIBDEPEND) 
        $(LTLINK) -o $@ centipede.o $(LIBS)
 
 sizecount:     sizecount.o ../phonetic.o ../ch_malloc.o $(SLAPD_LIBDEPEND) 
        $(LTLINK) -o $@ sizecount.o ../phonetic.o ../ch_malloc.o $(LIBS)
 
-ldbmtest:      ldbmtest.o ../libbackends.a $(OBJS1) $(SLAPD_LIBDEPEND) 
-       $(LTLINK) -o ldbmtest ldbmtest.o $(OBJS1) ../libbackends.a $(LIBS)
+#
+# BDBM Specific Tools
+#
+
+#
+# QUIPU Specific Tools
+#
+edb2ldif:      edb2-vers.o
+       $(CC) $(LDFLAGS) -o $@ $(EDB2LDIFOBJS) edb2-vers.o $(LIBS)
+
+edb2-vers.c: $(EDB2LDIFOBJS)
+       @-$(RM) $@
+       $(MKVERSION) ebd2ldif > $@
+
+chlog2replog: chlog2replog.o ../lock.o ../ch_malloc.o $(SLAPD_LIBDEPEND) 
+       $(LTLINK) -o $@ chlog2replog.o ../lock.o ../ch_malloc.o $(LIBS)
 
 clean-local: FORCE
-       $(RM) $(PROGRAMS) $(PROGRAMS2) $(XPROGRAMS) $(XSRCS) edb2-vers.c \
-               *.o core .libs/*
+       $(RM) $(PROGRAMS) $(LDBMPROGRAMS2) $(BDB2PROGRAMS) $(QUIPUPROGRAM) \
+               $(XPROGRAMS) $(XSRCS) *.o core .libs/*
 
 depend-local: FORCE
-       @DEPEND=no ; DEPEND_LDBM= ; DEPEND_BDB2= ; DEPEND_QUIPU= ; \
+       @DEPEND_LDBM= ; DEPEND_BDB2= ; DEPEND_QUIPU= ; \
        if [ "$(BUILD_LDBM)" != "no" ]; then \
-               DEPEND_LDBM="$(SRCS)"; \
-               DEPEND=yes ; \
+               DEPEND_LDBM="$(LDBMSRCS)"; \
        fi; \
        if [ "$(BUILD_BDB2)" != "no" ]; then \
-               DEPEND_BDB2="$(SRCS2)"; \
-               DEPEND=yes ; \
+               DEPEND_BDB2="$(BDBMSRCS)"; \
        fi; \
-       if [ "$(HAVE_QUIPU)" != "no" ]; then \
-               DEPEND_QUIPU="$(QUIPUINCLUDEFLAG) chlog2replog.c $(EDB2LDIFSRCS)"; \
-               DEPEND=yes ; \
+       if [ "$(BUILD_QUIPU)" != "no" ]; then \
+               DEPEND_QUIPU="$(QUIPUINCLUDEFLAG) $(QUIPUSRCS)"; \
        fi; \
-       if [ "$$DEPEND" = "yes" ]; then \
-       $(MKDEP) $(DEFS) $(DEFINES) $$DEPEND_QUIPU \
-                       $$DEPEND_LDBM $$DEPEND_BDB2; \
-       else \
-               echo "slapd-tools: no dependencies to make"; \
-       fi
+       $(MKDEP) $(DEFS) $(DEFINES) $(SRCS) $$DEPEND_QUIPU \
+                       $$DEPEND_LDBM $$DEPEND_BDB2
 
 install-local: install-ldbm-$(BUILD_LDBM) install-bdb2-$(BUILD_BDB2) \
         install-quipu-$(HAVE_QUIPU)
@@ -165,24 +142,16 @@ install-ldbm-no install-bdb2-no install-quipu-no:
 
 install-ldbm-yes install-ldbm-mod: FORCE
        @-$(MKDIR) $(sbindir) 
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2ldbm $(sbindir)        ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2index $(sbindir)       ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2id2entry $(sbindir)    ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2id2children $(sbindir) ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldbmcat $(sbindir)  ; \
+       $(LTINSTALL) $(INSTALLFLAGS) -m 755 slapcat $(sbindir)  ; \
+       $(LTINSTALL) $(INSTALLFLAGS) -m 755 slapentry $(sbindir)        ; \
+       $(LTINSTALL) $(INSTALLFLAGS) -m 755 slapindex $(sbindir)        ; \
        $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif $(sbindir)     ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 centipede $(sbindir)        ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldbmtest $(sbindir)
+       $(LTINSTALL) $(INSTALLFLAGS) -m 755 centipede $(sbindir)
 
 install-bdb2-yes install-bdb2-mod: FORCE
        @-$(MKDIR) $(sbindir) 
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2ldbm-bdb2 $(sbindir)   ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2index-bdb2 $(sbindir)  ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2id2entry-bdb2 $(sbindir) ; \
-       $(LTINSTALL) $(INSTALLFLAGS) -m 755 ldif2id2children-bdb2 $(sbindir)
 
 install-quipu-yes: FORCE
        @-$(MKDIR) $(sbindir)
        $(LTINSTALL) $(INSTALLFLAGS) -m 755 edb2ldif $(sbindir); \
        $(LTINSTALL) $(INSTALLFLAGS) -m 755 chlog2replog $(sbindir)
-
index e0927ccc1a9d42d435f1a876abc8f52101ca2d85..be3f03baabd4bf40443b91c1927f262ade1dfe55 100644 (file)
 #include <ac/time.h>
 #include <ac/unistd.h>         /* get link(), unlink() */
 
-#include <lber.h>
 #include <ldap.h>
-
 #include <ldbm.h>
 
+int    slap_debug;
+
 #define DEFAULT_LDAPFILTER     "(objectclass=*)"
 
 #define CENTROID_VALUE 1
@@ -565,10 +565,8 @@ diff_centroids(
        int             amax, acur, dmax, dcur;
        char    **vals;
 
-#ifdef HAVE_BERKELEY_DB2
-       DBC     *ocursorp;
-       DBC     *ncursorp;
-#endif /* HAVE_BERKELEY_DB2 */
+       LDBMCursor      *ocursorp;
+       LDBMCursor      *ncursorp;
 
        if ( verbose ) {
                printf( "Generating mods for differential %s centroid...", attr );
@@ -622,14 +620,10 @@ diff_centroids(
 
        olast.dptr = NULL;
        nlast.dptr = NULL;
-#ifdef HAVE_BERKELEY_DB2
+
        for ( okey = ldbm_firstkey( oldbm, &ocursorp ),
                        nkey = ldbm_firstkey( nldbm, &ncursorp );
              okey.dptr != NULL && nkey.dptr != NULL; )
-#else
-       for ( okey = ldbm_firstkey( oldbm ), nkey = ldbm_firstkey( nldbm );
-             okey.dptr != NULL && nkey.dptr != NULL; )
-#endif
        {
                int     rc = strcmp( okey.dptr, nkey.dptr );
 
@@ -644,13 +638,9 @@ diff_centroids(
                        }
                        nlast = nkey;
 
-#ifdef HAVE_BERKELEY_DB2
                        okey = ldbm_nextkey( oldbm, olast, ocursorp );
                        nkey = ldbm_nextkey( nldbm, nlast, ncursorp );
-#else
-                       okey = ldbm_nextkey( oldbm, olast );
-                       nkey = ldbm_nextkey( nldbm, nlast );
-#endif
+
                } else if ( rc > 0 ) {
                        /* new value is not in old centroid - add it */
                        if ( charray_add_dup( &avals, &acur, &amax, nkey.dptr ) == NULL ) {
@@ -663,11 +653,8 @@ diff_centroids(
                        }
                        nlast = nkey;
 
-#ifdef HAVE_BERKELEY_DB2
                        nkey = ldbm_nextkey( nldbm, nlast, ncursorp );
-#else
-                       nkey = ldbm_nextkey( nldbm, nlast );
-#endif
+
                } else {
                        /* old value is not in new centroid - delete it */
                        if ( charray_add_dup( &dvals, &dcur, &dmax, okey.dptr ) == NULL ) {
@@ -680,11 +667,7 @@ diff_centroids(
                        }
                        olast = okey;
 
-#ifdef HAVE_BERKELEY_DB2
                        okey = ldbm_nextkey( oldbm, olast, ocursorp );
-#else
-                       okey = ldbm_nextkey( oldbm, olast );
-#endif
                }
        }
 
@@ -694,11 +677,7 @@ diff_centroids(
                        return( NULL );
                }
 
-#ifdef HAVE_BERKELEY_DB2
                okey = ldbm_nextkey( oldbm, olast, ocursorp );
-#else
-               okey = ldbm_nextkey( oldbm, olast );
-#endif
                if ( olast.dptr != NULL ) {
                        ldbm_datum_free( oldbm, olast );
                }
@@ -713,11 +692,7 @@ diff_centroids(
                        return( NULL );
                }
 
-#ifdef HAVE_BERKELEY_DB2
                nkey = ldbm_nextkey( nldbm, nlast, ncursorp );
-#else
-               nkey = ldbm_nextkey( nldbm, nlast );
-#endif
                if ( nlast.dptr != NULL ) {
                        ldbm_datum_free( nldbm, nlast );
                }
@@ -738,13 +713,8 @@ diff_centroids(
 
        /* generate list of values to add */
        lastkey.dptr = NULL;
-#ifdef HAVE_BERKELEY_DB2
        for ( key = ldbm_firstkey( nldbm, &ncursorp ); key.dptr != NULL;
          key = ldbm_nextkey( nldbm, lastkey, ncursorp ) )
-#else
-       for ( key = ldbm_firstkey( nldbm ); key.dptr != NULL;
-         key = ldbm_nextkey( nldbm, lastkey ) )
-#endif
        {
                /* see if it's in the old one */
                data = ldbm_fetch( oldbm, key );
@@ -769,13 +739,8 @@ diff_centroids(
 
        /* generate list of values to delete */
        lastkey.dptr = NULL;
-#ifdef HAVE_BERKELEY_DB2
        for ( key = ldbm_firstkey( oldbm, &ocursorp ); key.dptr != NULL;
          key = ldbm_nextkey( oldbm, lastkey, ocursorp ) )
-#else
-       for ( key = ldbm_firstkey( oldbm ); key.dptr != NULL;
-         key = ldbm_nextkey( oldbm, lastkey ) )
-#endif
        {
                /* see if it's in the new one */
                data = ldbm_fetch( nldbm, key );
@@ -836,9 +801,7 @@ full_centroid(
        char    **vals;
        int             vcur, vmax;
 
-#ifdef HAVE_BERKELEY_DB2
-       DBC *cursorp;
-#endif
+       LDBMCursor *cursorp;
 
        if ( verbose ) {
                printf( "Generating mods for full %s centroid...", attr );
@@ -870,13 +833,9 @@ full_centroid(
        lastkey.dptr = NULL;
        vals = NULL;
        vcur = vmax = 0;
-#ifdef HAVE_BERKELEY_DB2
+
        for ( key = ldbm_firstkey( ldbm, &cursorp ); key.dptr != NULL;
          key = ldbm_nextkey( ldbm, lastkey, cursorp ) )
-#else
-       for ( key = ldbm_firstkey( ldbm ); key.dptr != NULL;
-         key = ldbm_nextkey( ldbm, lastkey ) )
-#endif
        {
                if ( charray_add_dup( &vals, &vcur, &vmax, key.dptr ) == NULL ) {
                        ldap_mods_free( mods, 1 );
diff --git a/servers/slapd/tools/ldbmcat.c b/servers/slapd/tools/ldbmcat.c
deleted file mode 100644 (file)
index 7580c2e..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-#include <ac/ctype.h>
-#include <ac/socket.h>
-#include <ac/string.h>
-
-#include "ldbm.h"
-#include "../slap.h"
-
-static void
-usage( char *name )
-{
-        fprintf( stderr, "usage: %s [-n] <filename>\n", name );
-}
-
-int
-main( int argc, char **argv )
-{
-        Datum               key, data;
-        LDBM                dbp;
-        char                *file, *s;
-        int                printid = 1;
-
-#ifdef HAVE_BERKELEY_DB2
-        DBC        *cursorp;
-#endif
-
-        ldbm_datum_init( key );
-        ldbm_datum_init( data );
-
-        if ( argc < 2 || argc > 3 || ( argc == 3 && strcmp( argv[1], "-n" )
-            != 0 )) {
-                usage( argv[0] );
-                               return EXIT_FAILURE;
-        }
-        if ( argc == 3 && strcmp( argv[1], "-n" ) == 0 ) {
-                printid = 0;
-                file = argv[2];
-        } else {
-                file = argv[1];
-        }
-
-        if ( (dbp = ldbm_open( file, LDBM_READER, 0, 0 )) == NULL ) {
-                perror( file );
-                               return EXIT_FAILURE;
-        }
-
-#ifdef HAVE_BERKELEY_DB2
-        for ( key = ldbm_firstkey( dbp, &cursorp ); key.dptr != NULL;
-            key = ldbm_nextkey( dbp, key, cursorp ) )
-#else
-        for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
-            key = ldbm_nextkey( dbp, key ) )
-#endif
-        {
-                data = ldbm_fetch( dbp, key );
-
-                if (( s = data.dptr ) != NULL ) {
-
-                    if ( !printid && isdigit( (unsigned char) *s )) {
-                        if (( s = strchr( s, '\n' )) != NULL ) {
-                                ++s;
-                        }
-                    }
-                    if ( s != NULL ) {
-                        puts( s );
-                    }
-
-                    ldbm_datum_free( dbp, data );
-                               }
-        }
-
-        ldbm_close( dbp );
-
-               return EXIT_SUCCESS;
-}
diff --git a/servers/slapd/tools/ldbmcat.dsp b/servers/slapd/tools/ldbmcat.dsp
deleted file mode 100644 (file)
index e74b773..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ldbmcat" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=ldbmcat - Win32 Single Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "ldbmcat.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "ldbmcat.mak" CFG="ldbmcat - Win32 Single Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "ldbmcat - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "ldbmcat - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "ldbmcat - Win32 Single Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldbmcat - Win32 Single Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "ldbmcat - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\Release"
-# PROP Intermediate_Dir "..\Release\ldbmcat"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 libdb.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
-
-!ELSEIF  "$(CFG)" == "ldbmcat - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldbmcat_"
-# PROP BASE Intermediate_Dir "ldbmcat_"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\Debug"
-# PROP Intermediate_Dir "..\Debug\ldbmcat"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 libdb.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
-
-!ELSEIF  "$(CFG)" == "ldbmcat - Win32 Single Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldbmcat_"
-# PROP BASE Intermediate_Dir "ldbmcat_"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\Sdebug"
-# PROP Intermediate_Dir "..\SDebug\ldbmcat"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 oldbm32.lib libdb.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
-# ADD LINK32 libdb.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
-
-!ELSEIF  "$(CFG)" == "ldbmcat - Win32 Single Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ldbmcat0"
-# PROP BASE Intermediate_Dir "ldbmcat0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\SRelease"
-# PROP Intermediate_Dir "..\SRelease\ldbmcat"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libdb.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
-# ADD LINK32 libdbs.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
-
-!ENDIF 
-
-# Begin Target
-
-# Name "ldbmcat - Win32 Release"
-# Name "ldbmcat - Win32 Debug"
-# Name "ldbmcat - Win32 Single Debug"
-# Name "ldbmcat - Win32 Single Release"
-# Begin Source File
-
-SOURCE=.\ldbmcat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mimic.c
-# End Source File
-# End Target
-# End Project
diff --git a/servers/slapd/tools/ldbmcat.dsw b/servers/slapd/tools/ldbmcat.dsw
deleted file mode 100644 (file)
index 61f9a1b..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 5.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "ldbmcat"=.\ldbmcat.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name libldbm
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "libldbm"=..\..\..\libraries\libldbm\libldbm.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
index fb058df05bdcf2be67e8707604b0e74cbbab4d9b..b0a6766b2cff955360923b34a623c6295cb35008 100644 (file)
@@ -57,9 +57,12 @@ main( int argc, char **argv )
        int             i;
        char            *tailorfile;
 
-#ifdef HAVE_BERKELEY_DB2
-       DBC     *cursorp;
-#endif
+       LDBMCursor      *cursorp;
+
+       fprintf(stderr,
+               "ldbmtest not updated to support new index formats!\n" );
+       exit( EXIT_FAILURE );
+
 
        ldbm_datum_init( savekey );
        ldbm_datum_init( key );
@@ -91,7 +94,7 @@ main( int argc, char **argv )
 
        slap_init(SLAP_TOOL_MODE, "ldbmtest");
        read_config( tailorfile );
-       slap_startup(-1);
+       slap_startup( NULL );
 
        while ( 1 ) {
                printf( "dbtest: " );
@@ -114,7 +117,7 @@ main( int argc, char **argv )
                        }
                        break;
 
-               case 'l':       /* lookup somethig in an index */
+               case 'l':       /* lookup something in an index */
                        if ( (dbc = openchoice( buf[1], LDBM_READER, 1, NULL ))
                            == NULL ) {
                                continue;
@@ -153,15 +156,9 @@ main( int argc, char **argv )
                        }
 
                        savekey.dptr = NULL;
-#ifdef HAVE_BERKELEY_DB2
                        for ( key = ldbm_firstkey( dbc->dbc_db, &cursorp );
                            key.dptr != NULL;
                            key = ldbm_nextkey( dbc->dbc_db, key, cursorp ) )
-#else
-                       for ( key = ldbm_firstkey( dbc->dbc_db );
-                           key.dptr != NULL;
-                           key = ldbm_nextkey( dbc->dbc_db, key ) )
-#endif
                        {
                                if ( savekey.dptr != NULL )
                                        ldbm_datum_free( dbc->dbc_db, savekey );
@@ -327,14 +324,9 @@ main( int argc, char **argv )
 
                        last.dptr = NULL;
 
-#ifdef HAVE_BERKELEY_DB2
                        for ( key = ldbm_firstkey( dbp, &cursorp );
                                key.dptr != NULL;
                                key = ldbm_nextkey( dbp, last, cursorp ) )
-#else
-                       for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
-                           key = ldbm_nextkey( dbp, last ) )
-#endif
                        {
                                if ( last.dptr != NULL ) {
                                        ldbm_datum_free( dbp, last );
@@ -360,7 +352,6 @@ main( int argc, char **argv )
                        printf( "          b    => change default backend\n" );
                        printf( "          B    => print default backend\n" );
                        printf( "where <c> is a char selecting the index:\n" );
-                       printf( "          c => id2children\n" );
                        printf( "          d => dn2id\n" );
                        printf( "          e => id2entry\n" );
                        printf( "          f => arbitrary file\n" );
@@ -369,7 +360,7 @@ main( int argc, char **argv )
                }
        }
 
-       slap_shutdown(-1);
+       slap_shutdown( NULL );
        slap_destroy();
 
        return( EXIT_SUCCESS );
@@ -608,9 +599,6 @@ openchoice( char c, int mode, int verbose, char **fname )
        static char     name[MAXPATHLEN];
 
        switch ( c ) {
-       case 'c':       /* id2children */
-               sprintf( name, "id2children" );
-               break;
        case 'd':       /* dn2id */
                sprintf( name, "dn2id" );
                break;
@@ -626,7 +614,7 @@ openchoice( char c, int mode, int verbose, char **fname )
                }
                break;
        default:
-               printf( "specify one of [fdeci] to select file\n" );
+               printf( "specify one of [fdei] to select file\n" );
                return( NULL );
                break;
        }
@@ -689,7 +677,6 @@ print_entry(
                }
                break;
 
-       case 'c':
        case 'i':       /* index - key is string, data is dnid[] */
                if ( key != NULL )
                        fprintf( fp, "%s%s (len %d)\n", klabel, key->dptr,
@@ -706,8 +693,7 @@ print_entry(
                                        fprintf( fp, "\t%ld\n", ID_BLOCK_ID(idl, i) );
                                }
                        } else if ( ID_BLOCK_ALLIDS( idl ) ) {
-                               fprintf( fp, "\tALLIDS (1..%ld)\n",
-                                   ID_BLOCK_NIDS(idl) - 1 );
+                               fprintf( fp, "\tALLIDS\n" );
                        } else {
                                for ( i = 0; i < ID_BLOCK_NIDS(idl); i++ ) {
                                        fprintf( fp, "\t%ld\n", ID_BLOCK_ID(idl,i) );
@@ -726,7 +712,7 @@ print_entry(
                break;
 
        default:
-               fprintf( stderr, "specify [deci] to select a file\n" );
+               fprintf( stderr, "specify [dei] to select a file\n" );
                break;
        }
 }
@@ -785,7 +771,6 @@ get_keydata( FILE *fp, char c, Datum *key, Datum *data )
                }
                break;
 
-       case 'c':       /* id2children - key is string dnid, data is dnid[] */
        case 'i':       /* index - key is string, data is dnid[] */
                if ( key != NULL ) {
                        if ( tty )
@@ -804,7 +789,7 @@ get_keydata( FILE *fp, char c, Datum *key, Datum *data )
                break;
 
        default:
-               fprintf(stderr, "specify [deci] to select file type\n");
+               fprintf(stderr, "specify [dei] to select file type\n");
                break;
        }
 }
index 6bd91f19b970ed4f0f89e298284bf0774c819248..b7202b6af54f9ac16650b32f1dfb035820d988cb 100644 (file)
@@ -70,7 +70,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
diff --git a/servers/slapd/tools/ldif2common.c b/servers/slapd/tools/ldif2common.c
deleted file mode 100644 (file)
index 3bc52e0..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-/* ldif2common.c - common definitions for the ldif2* tools */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include "ldif2common.h"
-
-
-char   *progname;
-char   *tailorfile = SLAPD_DEFAULT_CONFIGFILE;
-char   *inputfile      = NULL;
-char   *sbindir    = LDAP_SBINDIR;             /* used by ldif2ldbm */
-int    cmdkids     = 1;                        /* used by ldif2ldbm */
-int    dbnum;
-
-
-static void
-usage( int tool )
-{
-       fprintf( stderr, "usage: %s %s\n\t%s%s\n",
-                        progname, "-i inputfile [-d debuglevel] [-f configfile]",
-                        "[-n databasenumber]",
-                        ((tool == LDIF2LDBM)  ? " [-j #jobs] [-s sbindir]" :
-                         (tool == LDIF2INDEX) ? " attr" :
-                         "") );
-       exit( EXIT_FAILURE );
-}
-
-
-/*
- * slap_ldif_init - initialize ldif utility, handle program options.
- * args: tool - which ldif2* program is running.
- *       argc, argv - from main.
- *       dbtype - "ldbm"/"bdb2".
- *       options - to getopt.
- */
-
-void
-slap_ldif_init( int argc, char **argv, int tool, const char *dbtype, int mode )
-{
-       char *options = (tool == LDIF2LDBM ? "e:s:j:d:f:i:n:" : "d:f:i:n:");
-       int rc, i;
-
-       progname = strrchr ( argv[0], '/' );
-       progname = ch_strdup( progname ? progname + 1 : argv[0] );
-
-       inputfile = NULL;
-       tailorfile = SLAPD_DEFAULT_CONFIGFILE;
-       dbnum = -1;
-       while ( (i = getopt( argc, argv, options )) != EOF ) {
-               switch ( i ) {
-               case 'd':       /* turn on debugging */
-                       ldap_debug = atoi( optarg );
-                       break;
-
-               case 's':       /* alternate sbindir (index cmd location) */
-               case 'e':       /* accept -e for backwards compatibility */
-                       /* only used by ldif2ldbm and ldif2ldbm-bdb2 */
-                       sbindir = strdup( optarg );
-                       break;
-
-               case 'f':       /* specify a tailor file */
-                       tailorfile = strdup( optarg );
-                       break;
-
-               case 'i':       /* input file */
-                       inputfile = strdup( optarg );
-                       break;
-
-               case 'j':       /* number of parallel index procs */
-                       /* only in ldif2ldbm and ldif2ldbm-bdb2 */
-                       cmdkids = atoi( optarg );
-                       break;
-
-               case 'n':       /* which config file db to index */
-                       dbnum = atoi( optarg ) - 1;
-                       break;
-
-               default:
-                       usage( tool );
-                       break;
-               }
-       }
-       if ( inputfile == NULL || (argc != optind + (tool == LDIF2INDEX)) )
-               usage( tool );
-
-       if ( freopen( inputfile, "r", stdin ) == NULL ) {
-               perror( inputfile );
-               exit( EXIT_FAILURE );
-       }
-
-       /*
-        * initialize stuff and figure out which backend we're dealing with
-        */
-
-       rc = slap_init( mode, progname );
-       if (rc != 0 ) {
-               fprintf( stderr, "%s: slap_init failed!\n", progname );
-               exit( EXIT_FAILURE );
-       }
-
-       read_config( tailorfile );
-
-       if ( dbnum == -1 ) {
-               for ( dbnum = 0; dbnum < nbackends; dbnum++ ) {
-                       if ( strcasecmp( backends[dbnum].be_type, dbtype )
-                           == 0 ) {
-                               break;
-                       }
-               }
-               if ( dbnum == nbackends ) {
-                       fprintf( stderr, "No %s database found in config file\n", dbtype );
-                       exit( EXIT_FAILURE );
-               }
-       } else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
-               fprintf( stderr, "Database number selected via -n is out of range\n" );
-               fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-               exit( EXIT_FAILURE );
-       } else if ( strcasecmp( backends[dbnum].be_type, dbtype ) != 0 ) {
-               fprintf( stderr, "Database number %d selected via -n is not an %s database\n", dbnum, dbtype );
-               exit( EXIT_FAILURE );
-       }
-}
-
-
-#define IDBUFSIZ 100                   /* enough to hold <decimal ID>\n\0 */
-
-/*
- * slap_read_ldif - read an ldif record.  Return 1 for success, 0 for EOF.
- */
-int
-slap_read_ldif(
-       int         *lno,               /* ptr to line number counter              */
-       char        **bufp,     /* ptr to malloced output buffer           */
-       int         *buflenp,   /* ptr to length of *bufp                  */
-       ID          *idp,       /* ptr to ID number to be read/incremented */
-       int         idout )     /* flag to begin *buf with ID number       */
-{
-       char        linebuf[IDBUFSIZ + BUFSIZ], *line;
-       ber_len_t   lcur = 0, idlen, len, linesize;
-       int         last_ch = '\n', found_entry = 0, stop;
-
-       line     = linebuf + IDBUFSIZ;
-       linesize = sizeof( linebuf ) - IDBUFSIZ;
-
-       for ( stop = feof( stdin );  !stop;  last_ch = line[len-1] ) {
-               if ( fgets( line, linesize, stdin ) == NULL ) {
-                       stop = 1;
-                       /* Add \n in case the file does not end with newline */
-                       line = "\n";
-               }
-               len = strlen( line );
-
-               if ( last_ch == '\n' ) {
-                       (*lno)++;
-
-                       if ( line[0] == '\n' ) {
-                               if ( !found_entry )
-                                       continue;
-                               break;
-                       }
-
-                       if ( !found_entry ) {
-                               /* Found a new entry */
-                               found_entry = 1;
-
-                               if ( isdigit( (unsigned char) line[0] ) ) {
-                                       *idp = atol( line );
-                                       if ( !idout )
-                                               continue;
-                               } else {
-                                       ++(*idp);
-                                       if ( idout ) {
-                                               sprintf( linebuf, "%ld\n", (long) *idp );
-                                               idlen = strlen( linebuf );
-                                               line -= idlen;
-                                               linesize += idlen;
-                                               len += idlen;
-                                               SAFEMEMCPY( line, linebuf, idlen );
-                                       }
-                               }
-                       }                       
-               }
-
-               if ( *buflenp - lcur <= len )
-                       *bufp = ch_realloc( *bufp, *buflenp += len + BUFSIZ );
-               strcpy( *bufp + lcur, line );
-               lcur += len;
-       }
-
-       return( found_entry );
-}
diff --git a/servers/slapd/tools/ldif2common.h b/servers/slapd/tools/ldif2common.h
deleted file mode 100644 (file)
index 0d63a8b..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-/* ldif2common.h - common definitions for the ldif2* tools */
-
-#ifndef LDIF2COMMON_H_
-#define LDIF2COMMON_H_
-
-#include "ldap_defaults.h"
-#include "../slap.h"
-
-enum ldiftool {
-       LDIF2LDBM = 1, LDIF2INDEX, LDIF2ID2ENTRY, LDIF2ID2CHILDREN
-};
-
-
-extern char    *progname;
-extern char    *tailorfile;
-extern char    *inputfile;
-extern char    *sbindir;
-extern int     cmdkids;
-extern int     dbnum;
-
-
-void slap_ldif_init LDAP_P(( int, char **, int, const char *, int ));
-int  slap_read_ldif LDAP_P(( int *, char **, int *, ID *, int ));
-
-
-#endif /* LDIF2COMMON_H_ */
diff --git a/servers/slapd/tools/ldif2id2children-bdb2.c b/servers/slapd/tools/ldif2id2children-bdb2.c
deleted file mode 100644 (file)
index caa49a8..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include "ldif2common.h"
-#include "../back-bdb2/back-bdb2.h"
-#include "ldif.h"
-
-int
-main( int argc, char **argv )
-{
-       int             i, stop;
-       char            *linep, *buf;
-       char            line[BUFSIZ];
-       int             lineno, elineno;
-       int             lmax, lcur;
-       ID              id;
-       struct dbcache  *db, *db2;
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-
-       slap_ldif_init( argc, argv, LDIF2ID2CHILDREN, "bdb2", SLAP_TOOL_MODE );
-
-       slap_startup(dbnum);
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       /*
-        * first, make the dn2id index
-        */
-
-       if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_NEWDB ))
-           == NULL ) {
-               perror( "dn2id file" );
-               exit( EXIT_FAILURE );
-       }
-
-       id = 0;
-       stop = 0;
-       lineno = 0;
-       buf = NULL;
-       lcur = lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( ! stop ) {
-               char            *type, *val, *s;
-               ber_len_t               vlen;
-               Datum           key, data;
-
-               ldbm_datum_init( key );
-               ldbm_datum_init( data );
-
-               if ( fgets( line, sizeof(line), stdin ) != NULL ) {
-                       int     len;
-
-                       lineno++;
-                       len = strlen( line );
-                       while ( lcur + len + 1 > lmax ) {
-                               lmax += BUFSIZ;
-                               buf = (char *) ch_realloc( buf, lmax );
-                       }
-                       strcpy( buf + lcur, line );
-                       lcur += len;
-               } else {
-                       stop = 1;
-               }
-               if ( line[0] == '\n' || stop && buf && *buf ) {
-                       if ( *buf != '\n' ) {
-                               if (isdigit((unsigned char) *buf)) {
-                                       id = atol(buf);
-                               } else {
-                                       id++;
-                               }
-                               s = buf;
-                               elineno = 0;
-                               while ( (linep = ldif_getline( &s )) != NULL ) {
-                                       elineno++;
-                                       if ( ldif_parse_line( linep, &type, &val,
-                                           &vlen ) != 0 ) {
-                                               Debug( LDAP_DEBUG_PARSE,
-                           "bad line %d in entry ending at line %d ignored\n",
-                                                   elineno, lineno, 0 );
-                                               continue;
-                                       }
-
-                                       if ( strcmp( type, "dn" ) == 0 )
-                                               break;
-                               }
-
-                               if ( linep == NULL ) {
-                                       fprintf( stderr, "entry %ld has no dn\n",
-                                           id );
-                               } else {
-                                       if( val != NULL ) {
-                                               (void) dn_normalize_case( val );
-                                       }
-                                       key.dptr = val;
-                                       key.dsize = strlen( val != NULL ? val : "" ) + 1;
-                                       data.dptr = (char *) &id;
-                                       data.dsize = sizeof(ID);
-                                       if ( ldbm_store( db->dbc_db, key, data,
-                                           LDBM_REPLACE ) != 0 ) {
-                                               perror( "dn2id ldbm_store..." );
-                                               exit( EXIT_FAILURE );
-                                       }
-                               }
-                       }
-                       *buf = '\0';
-                       lcur = 0;
-                       line[0] = '\0';
-               }
-       }
-       if ( buf )
-               free( buf );
-
-       /*
-        * next, make the id2children index
-        */
-
-       if ( (db2 = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
-           LDBM_NEWDB )) == NULL ) {
-               perror( "id2children file" );
-               exit( EXIT_FAILURE );
-       }
-
-       rewind( stdin );
-       id = 0;
-       stop = 0;
-       buf = NULL;
-       lineno = 0;
-       lcur = lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( ! stop ) {
-               char    *type, *val, *s, *dn;
-               ber_len_t       vlen;
-               ID      pid;
-               char    buf2[20];
-               Datum   key, data;
-
-               ldbm_datum_init( key );
-               ldbm_datum_init( data );
-
-               if ( fgets( line, sizeof(line), stdin ) != NULL ) {
-                       int     len;
-
-                       len = strlen( line );
-                       while ( lcur + len + 1 > lmax ) {
-                               lmax += BUFSIZ;
-                               buf = (char *) ch_realloc( buf, lmax );
-                       }
-                       strcpy( buf + lcur, line );
-                       lcur += len;
-               } else {
-                       stop = 1;
-               }
-               if ( line[0] == '\n' || stop && buf && *buf ) {
-                       if ( * buf != '\n' ) {
-                               if (isdigit((unsigned char) *buf)) {
-                                       id = atol(buf);
-                               } else {
-                                       id++;
-                               }
-                               s = buf;
-                               while ( (linep = ldif_getline( &s )) != NULL ) {
-                                       if ( ldif_parse_line( linep, &type, &val,
-                                           &vlen ) != 0 ) {
-                                               Debug( LDAP_DEBUG_PARSE,
-                                                   "bad line %d ignored\n",
-                                                   lineno, 0, 0 );
-                                               continue;
-                                       }
-
-                                       if ( strcmp( type, "dn" ) == 0 )
-                                               break;
-                               }
-
-                               if ( linep == NULL ) {
-                                       fprintf( stderr, "entry %ld has no dn\n",
-                                           id );
-                               } else {
-                                       if ( (dn = dn_parent( be, val ))
-                                           == NULL ) {
-                                               pid = 0;
-                                       } else {
-                                               (void) dn_normalize_case( dn );
-                                               key.dptr = dn;
-                                               key.dsize = strlen( dn ) + 1;
-
-                                               data = ldbm_fetch( db->dbc_db,
-                                                   key );
-                                               free( dn );
-                                               if ( data.dptr == NULL ) {
-                                                       (void) dn_normalize_case( val );
-                                                       if ( ! be_issuffix( be,
-                                                           val ) ) {
-       Debug( LDAP_DEBUG_PARSE, "no parent \"%s\" of \"%s\"\n", dn, val, 0 );
-                                                       }
-                                                       *buf = '\0';
-                                                       lcur = 0;
-                                                       line[0] = '\0';
-                                                       continue;
-                                               }
-                                               (void) memcpy( (char *) &pid,
-                                                   data.dptr, sizeof(ID) );
-
-                                               ldbm_datum_free( db->dbc_db, data);
-                                       }
-
-                                       sprintf( buf2, "%c%ld", EQ_PREFIX, pid );
-                                       key.dptr = buf2;
-                                       key.dsize = strlen( buf2 ) + 1;
-                                       if ( bdb2i_idl_insert_key( be, db2, key, id )
-                                           != 0 ) {
-                                               perror( "bdb2i_idl_insert_key" );
-                                               exit( EXIT_FAILURE );
-                                       }
-                               }
-                       }
-                       *buf = '\0';
-                       lcur = 0;
-                       line[0] = '\0';
-               }
-       }
-
-#ifdef SLAP_CLEANUP
-       bdb2i_cache_close( be, db2 );
-       bdb2i_cache_close( be, db );
-#endif
-
-       slap_shutdown(dbnum);
-       slap_destroy();
-
-       exit( EXIT_SUCCESS );
-}
diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c
deleted file mode 100644 (file)
index 37d8190..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include "ldif2common.h"
-#include "../back-ldbm/back-ldbm.h"
-#include "ldif.h"
-
-int
-main( int argc, char **argv )
-{
-       char            *linep, *buf;
-       int             lineno, elineno;
-       int         lmax;
-       ID              id;
-       DBCache *db;
-#ifndef DN_INDICES
-       DBCache *db2;
-#endif
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-
-       slap_ldif_init( argc, argv, LDIF2ID2CHILDREN, "ldbm", SLAP_TOOL_MODE );
-
-       slap_startup(dbnum);
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       /*
-        * first, make the dn2id index
-        */
-
-       if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_NEWDB ))
-           == NULL ) {
-               perror( "dn2id file" );
-               exit( EXIT_FAILURE );
-       }
-
-       id = 0;
-       lineno = 0;
-       buf = NULL;
-       lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( slap_read_ldif( &lineno, &buf, &lmax, &id, 0 ) ) {
-               char            *type, *val, *s;
-               ber_len_t               vlen;
-               Datum           key, data;
-
-               ldbm_datum_init( key );
-               ldbm_datum_init( data );
-
-                               s = buf;
-                               elineno = 0;
-                               while ( (linep = ldif_getline( &s )) != NULL ) {
-                                       elineno++;
-                                       if ( ldif_parse_line( linep, &type, &val,
-                                           &vlen ) != 0 ) {
-                                               Debug( LDAP_DEBUG_PARSE,
-                           "bad line %d in entry ending at line %d ignored\n",
-                                                   elineno, lineno, 0 );
-                                               continue;
-                                       }
-
-                                       if ( strcmp( type, "dn" ) == 0 )
-                                               break;
-                               }
-
-                               if ( linep == NULL ) {
-                                       fprintf( stderr, "entry %ld has no dn\n",
-                                           id );
-                               } else {
-                                       if( val != NULL ) {
-                                               (void) dn_normalize_case( val );
-                                       }
-#ifndef DN_INDICES
-                                       key.dptr = val;
-                                       key.dsize = strlen( val != NULL ? val : "" ) + 1;
-#else
-                                       key.dsize = strlen( val != NULL ? val : "" ) + 2;
-                                       key.dptr = ch_malloc( key.dsize );
-                                       sprintf( key.dptr, "%c%s", DN_BASE_PREFIX,
-                                               val != NULL ? val : "" );
-#endif
-                                       data.dptr = (char *) &id;
-                                       data.dsize = sizeof(ID);
-                                       if ( ldbm_store( db->dbc_db, key, data,
-                                           LDBM_REPLACE ) != 0 ) {
-                                               perror( "dn2id ldbm_store" );
-                                               exit( EXIT_FAILURE );
-                                       }
-#ifdef DN_INDICES
-                                       free( key.dptr );
-
-                                       {
-                                               int rc = 0;
-                                               char *pdn = dn_parent( NULL, val );
-
-                                               if( pdn != NULL ) {
-                                                       key.dsize = strlen( pdn ) + 2;
-                                                       key.dptr = ch_malloc( key.dsize );
-                                                       sprintf( key.dptr, "%c%s",
-                                                               DN_ONE_PREFIX, pdn );
-                                                       rc = idl_insert_key( be, db, key, id );
-                                                       free( key.dptr );
-                                               }
-
-                                               if( rc == -1 ) {
-                                                       perror( "dn2id dn_parent insert" );
-                                                       exit( EXIT_FAILURE );
-                                               }
-                                       }
-
-                                       {
-                                               int rc = 0;
-                                               char **subtree = dn_subtree( NULL, val );
-
-                                               if( subtree != NULL ) {
-                                                       int i;
-                                                       for( i=0; subtree[i] != NULL; i++ ) {
-                                                               key.dsize = strlen( subtree[i] ) + 2;
-                                                               key.dptr = ch_malloc( key.dsize );
-                                                               sprintf( key.dptr, "%c%s",
-                                                                       DN_SUBTREE_PREFIX, subtree[i] );
-
-                                                               rc = idl_insert_key( be, db, key, id );
-
-                                                               free( key.dptr );
-
-                                                               if( rc == -1 ) {
-                                                                       perror( "dn2id dn_subtree insert" );
-                                                                       exit( EXIT_FAILURE );
-                                                               }
-                                                       }
-
-                                                       charray_free( subtree );
-                                               }
-
-                                       }
-#endif
-                               }
-       }
-       if ( buf )
-               free( buf );
-
-
-#ifndef DN_INDICES
-       /*
-        * next, make the id2children index
-        */
-
-       if ( (db2 = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
-           LDBM_NEWDB )) == NULL ) {
-               perror( "id2children file" );
-               exit( EXIT_FAILURE );
-       }
-
-       rewind( stdin );
-       id = 0;
-       buf = NULL;
-       lineno = 0;
-       lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( slap_read_ldif( &lineno, &buf, &lmax, &id, 0 ) ) {
-               char    *type, *val, *s, *dn;
-               ber_len_t       vlen;
-               ID      pid;
-               char    buf2[20];
-               Datum   key, data;
-
-               ldbm_datum_init( key );
-               ldbm_datum_init( data );
-
-                               s = buf;
-                               while ( (linep = ldif_getline( &s )) != NULL ) {
-                                       if ( ldif_parse_line( linep, &type, &val,
-                                           &vlen ) != 0 ) {
-                                               Debug( LDAP_DEBUG_PARSE,
-                                                   "bad line %d ignored\n",
-                                                   lineno, 0, 0 );
-                                               continue;
-                                       }
-
-                                       if ( strcmp( type, "dn" ) == 0 )
-                                               break;
-                               }
-
-                               if ( linep == NULL ) {
-                                       fprintf( stderr, "entry %ld has no dn\n",
-                                           id );
-                               } else {
-                                       if ( (dn = dn_parent( be, val ))
-                                           == NULL ) {
-                                               pid = 0;
-                                       } else {
-                                               (void) dn_normalize_case( dn );
-                                               key.dptr = dn;
-                                               key.dsize = strlen( dn ) + 1;
-
-                                               data = ldbm_fetch( db->dbc_db,
-                                                   key );
-                                               free( dn );
-                                               if ( data.dptr == NULL ) {
-                                                       (void) dn_normalize_case( val );
-                                                       if ( ! be_issuffix( be,
-                                                           val ) ) {
-       Debug( LDAP_DEBUG_PARSE, "no parent \"%s\" of \"%s\"\n", dn, val, 0 );
-                                                       }
-                                                       continue;
-                                               }
-                                               (void) memcpy( (char *) &pid,
-                                                   data.dptr, sizeof(ID) );
-
-                                               ldbm_datum_free( db->dbc_db, data);
-                                       }
-
-                                       sprintf( buf2, "%c%ld", EQ_PREFIX, pid );
-                                       key.dptr = buf2;
-                                       key.dsize = strlen( buf2 ) + 1;
-                                       if ( idl_insert_key( be, db2, key, id )
-                                           != 0 ) {
-                                               perror( "idl_insert_key" );
-                                               exit( EXIT_FAILURE );
-                                       }
-                               }
-       }
-
-#ifdef SLAP_CLEANUP
-       ldbm_cache_close( be, db2 );
-       ldbm_cache_close( be, db );
-#endif
-#else
-#ifdef SLAP_CLEANUP
-       ldbm_cache_close( be, db );
-#endif
-#endif
-
-
-       slap_shutdown(dbnum);
-       slap_destroy();
-
-       return( EXIT_SUCCESS );
-}
diff --git a/servers/slapd/tools/ldif2id2children.dsp b/servers/slapd/tools/ldif2id2children.dsp
deleted file mode 100644 (file)
index c165ee3..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ldif2id2children" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=ldif2id2children - Win32 Single Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2id2children.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2id2children.mak"\
- CFG="ldif2id2children - Win32 Single Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "ldif2id2children - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2id2children - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2id2children - Win32 Single Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2id2children - Win32 Single Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "ldif2id2children - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\Release"
-# PROP Intermediate_Dir "..\Release\ldif2id2children"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "ldif2id2children - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\Debug"
-# PROP Intermediate_Dir "..\Debug\ldif2id2children"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2id2children - Win32 Single Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldif2id2"
-# PROP BASE Intermediate_Dir "ldif2id2"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\SDebug"
-# PROP Intermediate_Dir "..\SDebug\ldif2id2children"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2id2children - Win32 Single Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ldif2id0"
-# PROP BASE Intermediate_Dir "ldif2id0"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\SRelease"
-# PROP Intermediate_Dir "..\SRelease\ldif2id2children"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ENDIF 
-
-# Begin Target
-
-# Name "ldif2id2children - Win32 Release"
-# Name "ldif2id2children - Win32 Debug"
-# Name "ldif2id2children - Win32 Single Debug"
-# Name "ldif2id2children - Win32 Single Release"
-# Begin Source File
-
-SOURCE=.\ldif2common.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ldif2common.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ldif2id2children.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mimic.c
-# End Source File
-# End Target
-# End Project
diff --git a/servers/slapd/tools/ldif2id2entry-bdb2.c b/servers/slapd/tools/ldif2id2entry-bdb2.c
deleted file mode 100644 (file)
index b51c2c4..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include "ldif2common.h"
-#include "../back-bdb2/back-bdb2.h"
-
-int
-main( int argc, char **argv )
-{
-       int             i, stop;
-       char            *buf;
-       char            line[BUFSIZ], idbuf[BUFSIZ];
-       int             lmax, lcur;
-       ID              id;
-       ID              maxid;
-       struct dbcache  *db;
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-       FILE            *fp;
-
-       slap_ldif_init( argc, argv, LDIF2ID2ENTRY, "bdb2", SLAP_TOOLID_MODE );
-
-       slap_startup(dbnum);
-
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       if ( (db = bdb2i_cache_open( be, "id2entry", BDB2_SUFFIX, LDBM_NEWDB ))
-           == NULL ) {
-               perror( "id2entry file" );
-               exit( EXIT_FAILURE );
-       }
-
-       id = 0;
-       maxid = 0;
-       stop = 0;
-       buf = NULL;
-       lcur = lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( ! stop ) {
-               Datum           key, data;
-
-               ldbm_datum_init( key );
-               ldbm_datum_init( data );
-
-               if ( fgets( line, sizeof(line), stdin ) != NULL ) {
-                       int     len, idlen;
-
-                       len = strlen( line );
-                       if ( buf == NULL || *buf == '\0' ) {
-                               if (!isdigit((unsigned char) line[0])) {
-                                       sprintf( idbuf, "%ld\n", id + 1 );
-                                       idlen = strlen( idbuf );
-                               } else {
-                                       id = atol(line) - 1;
-                                       idlen = 0;
-                               }
-                       } else {
-                               idlen = 0;
-                       }
-
-                       while ( lcur + len + idlen + 1 > lmax ) {
-                               lmax += BUFSIZ;
-                               buf = (char *) ch_realloc( buf, lmax );
-                       }
-
-                       if ( idlen > 0 ) {
-                               strcpy( buf + lcur, idbuf );
-                               lcur += idlen;
-                       }
-                       strcpy( buf + lcur, line );
-                       lcur += len;
-               } else {
-                       stop = 1;
-               }
-               if ( line[0] == '\n' || stop && buf && *buf ) {
-                       if ( *buf != '\n' ) {
-                               int len;
-
-                               id++;
-                               if ( id > maxid )
-                                       maxid = id;
-                               key.dptr = (char *) &id;
-                               key.dsize = sizeof(ID);
-                               data.dptr = buf;
-                               len = strlen(buf);
-                               if (buf[len - 1] == '\n')
-                                       buf[--len] = '\0';
-                               data.dsize = len + 1;
-                               if ( ldbm_store( db->dbc_db, key, data,
-                                   LDBM_INSERT ) != 0 ) {
-                                       fputs("id2entry ldbm_store failed\n",
-                                             stderr);
-                                       exit( EXIT_FAILURE );
-                               }
-                       }
-                       *buf = '\0';
-                       lcur = 0;
-                       line[0] = '\0';
-               }
-       }
-
-       maxid++;
-       bdb2i_put_nextid( be, maxid );
-
-#ifdef SLAP_CLEANUP
-       bdb2i_cache_close( be, db );
-#endif
-
-       slap_shutdown(dbnum);
-
-       slap_destroy();
-
-       exit( EXIT_SUCCESS );
-}
diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c
deleted file mode 100644 (file)
index 9d279bd..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include "ldif2common.h"
-#include "../back-ldbm/back-ldbm.h"
-
-int
-main( int argc, char **argv )
-{
-       char            *buf;
-       int         lineno;
-       int         lmax;
-       ID              id;
-       ID              maxid;
-       DBCache *db;
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-
-       slap_ldif_init( argc, argv, LDIF2ID2ENTRY, "ldbm", SLAP_TOOLID_MODE );
-
-       slap_startup(dbnum);
-
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_NEWDB ))
-           == NULL ) {
-               perror( "id2entry file" );
-               exit( EXIT_FAILURE );
-       }
-
-       id = 0;
-       maxid = 0;
-       buf = NULL;
-       lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( slap_read_ldif( &lineno, &buf, &lmax, &id, 1 ) ) {
-               Datum           key, data;
-
-               ldbm_datum_init( key );
-               ldbm_datum_init( data );
-
-                               if ( id > maxid )
-                                       maxid = id;
-                               key.dptr = (char *) &id;
-                               key.dsize = sizeof(ID);
-                               data.dptr = buf;
-                               data.dsize = strlen( buf ) + 1;
-                               if ( ldbm_store( db->dbc_db, key, data,
-                                   LDBM_INSERT ) != 0 ) {
-                                       fputs("id2entry ldbm_store failed\n",
-                                             stderr);
-                                       exit( EXIT_FAILURE );
-                               }
-       }
-
-       maxid++;
-       put_nextid( be, maxid );
-
-#ifdef SLAP_CLEANUP
-       ldbm_cache_close( be, db );
-#endif
-
-       slap_shutdown(dbnum);
-
-       slap_destroy();
-
-       return( EXIT_SUCCESS );
-}
diff --git a/servers/slapd/tools/ldif2id2entry.dsp b/servers/slapd/tools/ldif2id2entry.dsp
deleted file mode 100644 (file)
index 64457eb..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ldif2id2entry" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=ldif2id2entry - Win32 Single Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2id2entry.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2id2entry.mak" CFG="ldif2id2entry - Win32 Single Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "ldif2id2entry - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2id2entry - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2id2entry - Win32 Single Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2id2entry - Win32 Single Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "ldif2id2entry - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\Release"
-# PROP Intermediate_Dir "..\Release\ldif2id2entry"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "ldif2id2entry - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldif2id2"
-# PROP BASE Intermediate_Dir "ldif2id2"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\Debug"
-# PROP Intermediate_Dir "..\Debug\ldif2id2entry"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2id2entry - Win32 Single Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldif2id2"
-# PROP BASE Intermediate_Dir "ldif2id2"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\SDebug"
-# PROP Intermediate_Dir "..\SDebug\ldif2id2entry"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2id2entry - Win32 Single Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ldif2id0"
-# PROP BASE Intermediate_Dir "ldif2id0"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\SRelease"
-# PROP Intermediate_Dir "..\SRelease\ldif2id2entry"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ENDIF 
-
-# Begin Target
-
-# Name "ldif2id2entry - Win32 Release"
-# Name "ldif2id2entry - Win32 Debug"
-# Name "ldif2id2entry - Win32 Single Debug"
-# Name "ldif2id2entry - Win32 Single Release"
-# Begin Source File
-
-SOURCE=.\ldif2common.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ldif2common.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ldif2id2entry.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mimic.c
-# End Source File
-# End Target
-# End Project
diff --git a/servers/slapd/tools/ldif2index-bdb2.c b/servers/slapd/tools/ldif2index-bdb2.c
deleted file mode 100644 (file)
index 4a4374f..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include "ldif2common.h"
-#include "../back-bdb2/back-bdb2.h"
-#include "ldif.h"
-
-int
-main( int argc, char **argv )
-{
-       int             i, stop;
-       char            *linep, *buf, *attr;
-       char            line[BUFSIZ];
-       int             lineno, elineno;
-       int             lmax, lcur, indexmask, syntaxmask;
-       unsigned long   id;
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-
-       slap_ldif_init( argc, argv, LDIF2INDEX, "bdb2", SLAP_TOOL_MODE );
-       attr = attr_normalize( argv[argc - 1] );
-
-       slap_startup(dbnum);
-
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       bdb2i_attr_masks( be->be_private, attr, &indexmask, &syntaxmask );
-       if ( indexmask == 0 ) {
-               exit( EXIT_SUCCESS );
-       }
-
-       id = 0;
-       stop = 0;
-       lineno = 0;
-       buf = NULL;
-       lcur = lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( ! stop ) {
-               char            *type, *val, *s;
-               ber_len_t       vlen;
-
-               if ( fgets( line, sizeof(line), stdin ) != NULL ) {
-                       int     len;
-
-                       lineno++;
-                       len = strlen( line );
-                       while ( lcur + len + 1 > lmax ) {
-                               lmax += BUFSIZ;
-                               buf = (char *) ch_realloc( buf, lmax );
-                       }
-                       strcpy( buf + lcur, line );
-                       lcur += len;
-               } else {
-                       stop = 1;
-               }
-               if ( line[0] == '\n' || stop && buf && *buf ) {
-                       if ( *buf != '\n' ) {
-                               if (isdigit((unsigned char) *buf)) {
-                                       id = atol(buf);
-                               } else {
-                                       id++;
-                               }
-                               s = buf;
-                               elineno = 0;
-                               while ( (linep = ldif_getline( &s )) != NULL ) {
-                                       elineno++;
-                                       if ( ldif_parse_line( linep, &type, &val,
-                                           &vlen ) != 0 ) {
-                                               Debug( LDAP_DEBUG_PARSE,
-                           "bad line %d in entry ending at line %d ignored\n",
-                                                   elineno, lineno, 0 );
-                                               continue;
-                                       }
-
-                                       if ( strcasecmp( type, attr ) == 0 ) {
-                                               bv.bv_val = val;
-                                               bv.bv_len = vlen;
-                                               bdb2i_index_add_values( be, attr,
-                                                   vals, id );
-                                       }
-                               }
-                       }
-                       *buf = '\0';
-                       lcur = 0;
-               }
-       }
-
-       slap_shutdown(dbnum);
-       slap_destroy();
-
-       exit( EXIT_SUCCESS );
-}
diff --git a/servers/slapd/tools/ldif2index.c b/servers/slapd/tools/ldif2index.c
deleted file mode 100644 (file)
index d6a38ed..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-
-#include <ac/ctype.h>
-#include <ac/string.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-
-#include "ldif2common.h"
-#include "../back-ldbm/back-ldbm.h"
-#include "ldif.h"
-
-int
-main( int argc, char **argv )
-{
-       char            *linep, *buf, *attr;
-       int             lineno, elineno;
-       int         lmax;
-       int         indexmask, syntaxmask;
-       ID              id;
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-
-       slap_ldif_init( argc, argv, LDIF2INDEX, "ldbm", SLAP_TOOL_MODE );
-       attr = attr_normalize( argv[argc - 1] );
-
-       slap_startup(dbnum);
-
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       attr_masks( be->be_private, attr, &indexmask, &syntaxmask );
-       if ( indexmask == 0 ) {
-               exit( EXIT_SUCCESS );
-       }
-
-       id = 0;
-       lineno = 0;
-       buf = NULL;
-       lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( slap_read_ldif( &lineno, &buf, &lmax, &id, 0 ) ) {
-               char            *type, *val, *s;
-               ber_len_t               vlen;
-
-                               s = buf;
-                               elineno = 0;
-                               while ( (linep = ldif_getline( &s )) != NULL ) {
-                                       elineno++;
-                                       if ( ldif_parse_line( linep, &type, &val,
-                                           &vlen ) != 0 ) {
-                                               Debug( LDAP_DEBUG_PARSE,
-                           "bad line %d in entry ending at line %d ignored\n",
-                                                   elineno, lineno, 0 );
-                                               continue;
-                                       }
-
-                                       if ( strcasecmp( type, attr ) == 0 ) {
-                                               bv.bv_val = val;
-                                               bv.bv_len = vlen;
-                                               index_change_values( be,
-                                                                    attr,
-                                                                    vals,
-                                                                    id,
-                                                              __INDEX_ADD_OP);
-                                       }
-                               }
-       }
-
-       slap_shutdown(dbnum);
-       slap_destroy();
-
-       return( EXIT_SUCCESS );
-}
diff --git a/servers/slapd/tools/ldif2index.dsp b/servers/slapd/tools/ldif2index.dsp
deleted file mode 100644 (file)
index 65b8cdd..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ldif2index" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=ldif2index - Win32 Single Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2index.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2index.mak" CFG="ldif2index - Win32 Single Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "ldif2index - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2index - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2index - Win32 Single Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2index - Win32 Single Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "ldif2index - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\Release"
-# PROP Intermediate_Dir "..\Release\ldif2index"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "ldif2index - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldif2ind"
-# PROP BASE Intermediate_Dir "ldif2ind"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\Debug"
-# PROP Intermediate_Dir "..\Debug\ldif2index"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2index - Win32 Single Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldif2ind"
-# PROP BASE Intermediate_Dir "ldif2ind"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\SDebug"
-# PROP Intermediate_Dir "..\SDebug\ldif2index"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib shell32.lib hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2index - Win32 Single Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ldif2in0"
-# PROP BASE Intermediate_Dir "ldif2in0"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\SRelease"
-# PROP Intermediate_Dir "..\SRelease\ldif2index"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ENDIF 
-
-# Begin Target
-
-# Name "ldif2index - Win32 Release"
-# Name "ldif2index - Win32 Debug"
-# Name "ldif2index - Win32 Single Debug"
-# Name "ldif2index - Win32 Single Release"
-# Begin Source File
-
-SOURCE=.\ldif2common.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ldif2common.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ldif2index.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mimic.c
-# End Source File
-# End Target
-# End Project
diff --git a/servers/slapd/tools/ldif2ldbm-bdb2.c b/servers/slapd/tools/ldif2ldbm-bdb2.c
deleted file mode 100644 (file)
index 46fabe6..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-#include <ac/string.h>
-#include <ac/ctype.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-#include <ac/wait.h>
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#include "ldif2common.h"
-#include "../back-bdb2/back-bdb2.h"
-#include "ldif.h"
-
-#define INDEXCMD               "ldif2index-bdb2"
-#define ID2ENTRYCMD            "ldif2id2entry-bdb2"
-#define ID2CHILDRENCMD         "ldif2id2children-bdb2"
-#define MAXARGS                100
-
-static void fork_child( char *prog, char *args[] );
-static void    wait4kids( int nkidval );
-
-static int      maxkids = 1;
-static int      nkids;
-
-int
-main( int argc, char **argv )
-{
-       int             i, stop;
-       char            *linep, *buf;
-       char            *args[MAXARGS];
-       char            buf2[20], buf3[20];
-       char            line[BUFSIZ];
-       char            cmd[MAXPATHLEN];
-       int             lineno, elineno;
-       int             lmax, lcur;
-       ID              id;
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-       Avlnode         *avltypes = NULL;
-
-       slap_ldif_init( argc, argv, LDIF2LDBM, "bdb2", SLAP_TOOL_MODE );
-
-       slap_startup(dbnum);
-
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       /*
-        * generate the id2entry index
-        */
-
-       i = 0;
-       sprintf( cmd, "%s/%s", sbindir, ID2ENTRYCMD );
-       args[i++] = cmd;
-       args[i++] = "-i";
-       args[i++] = inputfile;
-       args[i++] = "-f";
-       args[i++] = tailorfile;
-       args[i++] = "-n";
-       sprintf( buf2, "%d", dbnum+1 );
-       args[i++] = buf2;
-       if ( ldap_debug ) {
-               sprintf( buf3, "%d", ldap_debug );
-               args[i++] = "-d";
-               args[i++] = buf3;
-       }
-       args[i++] = NULL;
-       fork_child( cmd, args );
-
-       /*
-        * generate the dn2id and id2children indexes
-        */
-
-       i = 0;
-       sprintf( cmd, "%s/%s", sbindir, ID2CHILDRENCMD );
-       args[i++] = cmd;
-       args[i++] = "-i";
-       args[i++] = inputfile;
-       args[i++] = "-f";
-       args[i++] = tailorfile;
-       args[i++] = "-n";
-       sprintf( buf2, "%d", dbnum+1 );
-       args[i++] = buf2;
-       if ( ldap_debug ) {
-               sprintf( buf3, "%d", ldap_debug );
-               args[i++] = "-d";
-               args[i++] = buf3;
-       }
-       args[i++] = NULL;
-       fork_child( cmd, args );
-
-       maxkids = cmdkids;
-
-       /*
-        * generate the attribute indexes
-        */
-
-       i = 0;
-       sprintf( cmd, "%s/%s", sbindir, INDEXCMD );
-       args[i++] = cmd;
-       args[i++] = "-i";
-       args[i++] = inputfile;
-       args[i++] = "-f";
-       args[i++] = tailorfile;
-       args[i++] = "-n";
-       sprintf( buf2, "%d", dbnum+1 );
-       args[i++] = buf2;
-       if ( ldap_debug ) {
-               sprintf( buf3, "%d", ldap_debug );
-               args[i++] = "-d";
-               args[i++] = buf3;
-       }
-       args[i++] = NULL;               /* will hold the attribute name */
-       args[i++] = NULL;
-
-       id = 0;
-       stop = 0;
-       buf = NULL;
-       lineno = 0;
-       lcur = lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( ! stop ) {
-               char            *type, *val, *s;
-               ber_len_t               vlen;
-               int indexmask, syntaxmask;
-
-               if ( fgets( line, sizeof(line), stdin ) != NULL ) {
-                       int     len;
-
-                       lineno++;
-                       len = strlen( line );
-                       while ( lcur + len + 1 > lmax ) {
-                               lmax += BUFSIZ;
-                               buf = (char *) ch_realloc( buf, lmax );
-                       }
-                       strcpy( buf + lcur, line );
-                       lcur += len;
-               } else {
-                       stop = 1;
-               }
-               if ( line[0] == '\n' || stop && buf && *buf ) {
-                       id++;
-                       s = buf;
-                       elineno = 0;
-                       while ( (linep = ldif_getline( &s )) != NULL ) {
-                               elineno++;
-                               if ( ldif_parse_line( linep, &type, &val, &vlen )
-                                   != 0 ) {
-                                       Debug( LDAP_DEBUG_PARSE,
-                           "bad line %d in entry ending at line %d ignored\n",
-                                           elineno, lineno, 0 );
-                                       continue;
-                               }
-
-                               if ( !isascii( *type ) || isdigit( *type ) )
-                                       continue;
-
-                               type = strdup( type );
-                               if ( avl_insert( &avltypes, type, (AVL_CMP) strcasecmp,
-                                   avl_dup_error ) != 0 ) {
-                                       free( type );
-                               } else {
-                                       bdb2i_attr_masks( be->be_private, type,
-                                           &indexmask, &syntaxmask );
-                                       if ( indexmask ) {
-                                               args[i - 2] = type;
-                                               fork_child( cmd, args );
-                                       }
-                               }
-                       }
-                       *buf = '\0';
-                       lcur = 0;
-               }
-       }
-
-       slap_shutdown(dbnum);
-
-       wait4kids( -1 );
-
-       slap_destroy();
-
-       exit( EXIT_SUCCESS );
-}
-
-static void
-fork_child( char *prog, char *args[] )
-{
-       int     pid;
-
-       wait4kids( maxkids );
-
-       switch ( pid = fork() ) {
-       case 0:         /* child */
-               execvp( prog, args );
-               fprintf( stderr, "%s: ", prog );
-               perror( "execv" );
-               exit( EXIT_FAILURE );
-               break;
-
-       case -1:        /* trouble */
-               fprintf( stderr, "Could not fork to run %s\n", prog );
-               perror( "fork" );
-               break;
-
-       default:        /* parent */
-               nkids++;
-               break;
-       }
-}
-
-static void
-wait4kids( int nkidval )
-{
-       int             status;
-       unsigned char   *p;
-
-       while ( nkids >= nkidval ) {
-               wait( &status );
-               p = (unsigned char *) &status;
-               if ( p[sizeof(int) - 1] == 0177 ) {
-                       fprintf( stderr,
-                           "stopping: child stopped with signal %d\n",
-                           p[sizeof(int) - 2] );
-               } else if ( p[sizeof(int) - 1] != 0 ) {
-                       fprintf( stderr, 
-                           "stopping: child terminated with signal %d\n",
-                           p[sizeof(int) - 1] );
-                       exit( p[sizeof(int) - 1] );
-               } else if ( p[sizeof(int) - 2] != 0 ) {
-                       fprintf( stderr, 
-                           "stopping: child exited with status %d\n",
-                           p[sizeof(int) - 2] );
-                       exit( p[sizeof(int) - 2] );
-               } else {
-                       nkids--;
-               }
-       }
-}
diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c
deleted file mode 100644 (file)
index cc89840..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/stdlib.h>
-#include <ac/string.h>
-#include <ac/ctype.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-#include <ac/wait.h>
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#include "ldif2common.h"
-#include "../back-ldbm/back-ldbm.h"
-#include "ldif.h"
-
-#define INDEXCMD               "ldif2index" EXEEXT
-#define ID2ENTRYCMD            "ldif2id2entry" EXEEXT
-#define ID2CHILDRENCMD         "ldif2id2children" EXEEXT
-
-#define MAXARGS                100
-
-static void fork_child( char *prog, char *args[] );
-static void    wait4kids( int nkidval );
-
-static int      maxkids = 1;
-static int      nkids;
-
-int
-main( int argc, char **argv )
-{
-       int             i;
-       char            *linep, *buf;
-       char            *args[MAXARGS];
-       char            buf2[20], buf3[20];
-       char            cmd[MAXPATHLEN];
-       int             lineno, elineno;
-       int             lmax;
-       ID              id;
-       Backend         *be = NULL;
-       struct ldbminfo *li;
-       struct berval   bv;
-       struct berval   *vals[2];
-       Avlnode         *avltypes = NULL;
-
-       slap_ldif_init( argc, argv, LDIF2LDBM, "ldbm", SLAP_TOOL_MODE );
-
-       slap_startup(dbnum);
-
-       be = &backends[dbnum];
-
-       /* disable write sync'ing */
-       li = (struct ldbminfo *) be->be_private;
-       li->li_dbcachewsync = 0;
-
-       /*
-        * generate the id2entry index
-        */
-
-       i = 0;
-       sprintf( cmd, "%s/%s", sbindir, ID2ENTRYCMD );
-       args[i++] = cmd;
-       args[i++] = "-i";
-       args[i++] = inputfile;
-       args[i++] = "-f";
-       args[i++] = tailorfile;
-       args[i++] = "-n";
-       sprintf( buf2, "%d", dbnum+1 );
-       args[i++] = buf2;
-       if ( ldap_debug ) {
-               sprintf( buf3, "%d", ldap_debug );
-               args[i++] = "-d";
-               args[i++] = buf3;
-       }
-       args[i++] = NULL;
-       fork_child( cmd, args );
-
-       /*
-        * generate the dn2id and id2children indexes
-        */
-
-       i = 0;
-       sprintf( cmd, "%s/%s", sbindir, ID2CHILDRENCMD );
-       args[i++] = cmd;
-       args[i++] = "-i";
-       args[i++] = inputfile;
-       args[i++] = "-f";
-       args[i++] = tailorfile;
-       args[i++] = "-n";
-       sprintf( buf2, "%d", dbnum+1 );
-       args[i++] = buf2;
-       if ( ldap_debug ) {
-               sprintf( buf3, "%d", ldap_debug );
-               args[i++] = "-d";
-               args[i++] = buf3;
-       }
-       args[i++] = NULL;
-       fork_child( cmd, args );
-
-    maxkids = cmdkids;
-
-       /*
-        * generate the attribute indexes
-        */
-
-       i = 0;
-       sprintf( cmd, "%s/%s", sbindir, INDEXCMD );
-       args[i++] = cmd;
-       args[i++] = "-i";
-       args[i++] = inputfile;
-       args[i++] = "-f";
-       args[i++] = tailorfile;
-       args[i++] = "-n";
-       sprintf( buf2, "%d", dbnum+1 );
-       args[i++] = buf2;
-       if ( ldap_debug ) {
-               sprintf( buf3, "%d", ldap_debug );
-               args[i++] = "-d";
-               args[i++] = buf3;
-       }
-       args[i++] = NULL;               /* will hold the attribute name */
-       args[i++] = NULL;
-
-       id = 0;
-       buf = NULL;
-       lineno = 0;
-       lmax = 0;
-       vals[0] = &bv;
-       vals[1] = NULL;
-       while ( slap_read_ldif( &lineno, &buf, &lmax, &id, 0 ) ) {
-               char            *type, *val, *s;
-               ber_len_t       vlen;
-               int                     indexmask, syntaxmask;
-
-                       s = buf;
-                       elineno = 0;
-                       while ( (linep = ldif_getline( &s )) != NULL ) {
-                               elineno++;
-                               if ( ldif_parse_line( linep, &type, &val, &vlen )
-                                   != 0 ) {
-                                       Debug( LDAP_DEBUG_PARSE,
-                           "bad line %d in entry ending at line %d ignored\n",
-                                           elineno, lineno, 0 );
-                                       continue;
-                               }
-
-                               if ( !isascii( *type ) || isdigit( *type ) )
-                                       continue;
-
-                               type = strdup( type );
-                               if ( avl_insert( &avltypes, type, (AVL_CMP) strcasecmp,
-                                   avl_dup_error ) != 0 ) {
-                                       free( type );
-                               } else {
-                                       attr_masks( be->be_private, type,
-                                           &indexmask, &syntaxmask );
-                                       if ( indexmask ) {
-                                               args[i - 2] = type;
-                                               fork_child( cmd, args );
-                                       }
-                               }
-                       }
-       }
-
-       wait4kids( -1 );
-
-       slap_shutdown(dbnum);
-
-       slap_destroy();
-
-       return( EXIT_SUCCESS );
-}
-
-#ifdef WIN32
-
-static HANDLE processes[MAXIMUM_WAIT_OBJECTS];
-
-static void
-fork_child( char *prog, char *args[] )
-{
-    PROCESS_INFORMATION proc_info;
-    PROCESS_INFORMATION *pinfo = &proc_info;
-    STARTUPINFO  start_info;
-    int i;
-    char cmdLine[2048];
-
-    wait4kids( maxkids );
-
-    i = 1;
-    memset( &start_info, 0, sizeof(STARTUPINFO) );
-    memset( cmdLine, 0, sizeof(cmdLine) );
-    strcpy( cmdLine, prog );
-    while ( args[i] != NULL )
-    {
-        strcat( cmdLine, " " );
-        strcat( cmdLine, args[i] );
-        i++;
-    }
-
-    if ( !CreateProcess( NULL, cmdLine, NULL, NULL,
-                         TRUE, CREATE_NEW_CONSOLE,
-                         NULL, NULL, &start_info, pinfo ) )
-    {
-        fprintf( stderr, "Could not create %s: ", prog );
-        perror( "CreateProcess" );
-        exit (EXIT_FAILURE);
-    }
-
-    processes[nkids] = proc_info.hProcess;
-    nkids++;
-
-}
-
-static void
-wait4kids( int nkidval )
-{
-    DWORD  wait_index;
-    while( nkids >= nkidval )
-    {
-        wait_index = WaitForMultipleObjects( nkids, processes, FALSE, INFINITE );
-        /*
-        *  processes[wait_index] completed.  Move any remaining indexes into its
-        *  place in the array so it stays filled.
-        */
-        if ( nkids > 1 )
-        {
-            memcpy ( &processes[wait_index], &processes[wait_index+1], sizeof(HANDLE)*(nkids-1) );
-            processes[nkids] = 0;
-        }
-        nkids--;
-    }
-}
-
-#else
-
-static void
-fork_child( char *prog, char *args[] )
-{
-       int     pid;
-
-       wait4kids( maxkids );
-
-       switch ( pid = fork() ) {
-       case 0:         /* child */
-               execvp( prog, args );
-               fprintf( stderr, "%s: ", prog );
-               perror( "execv" );
-               exit( EXIT_FAILURE );
-               break;
-
-       case -1:        /* trouble */
-               fprintf( stderr, "Could not fork to run %s\n", prog );
-               perror( "fork" );
-               break;
-
-       default:        /* parent */
-               nkids++;
-               break;
-       }
-}
-
-static void
-wait4kids( int nkidval )
-{
-       int             status;
-       unsigned char   *p;
-
-       while ( nkids >= nkidval ) {
-               wait( &status );
-               p = (unsigned char *) &status;
-               if ( p[sizeof(int) - 1] == 0177 ) {
-                       fprintf( stderr,
-                           "stopping: child stopped with signal %d\n",
-                           p[sizeof(int) - 2] );
-               } else if ( p[sizeof(int) - 1] != 0 ) {
-                       fprintf( stderr, 
-                           "stopping: child terminated with signal %d\n",
-                           p[sizeof(int) - 1] );
-                       exit( p[sizeof(int) - 1] );
-               } else if ( p[sizeof(int) - 2] != 0 ) {
-                       fprintf( stderr, 
-                           "stopping: child exited with status %d\n",
-                           p[sizeof(int) - 2] );
-                       exit( p[sizeof(int) - 2] );
-               } else {
-                       nkids--;
-               }
-       }
-}
-
-#endif
diff --git a/servers/slapd/tools/ldif2ldbm.dsp b/servers/slapd/tools/ldif2ldbm.dsp
deleted file mode 100644 (file)
index 964d2a4..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ldif2ldbm" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=ldif2ldbm - Win32 Single Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2ldbm.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "ldif2ldbm.mak" CFG="ldif2ldbm - Win32 Single Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "ldif2ldbm - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2ldbm - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "ldif2ldbm - Win32 Single Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "ldif2ldbm - Win32 Single Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "ldif2ldbm - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\Release"
-# PROP Intermediate_Dir "..\Release\ldif2ldbm"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "ldif2ldbm - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\Debug"
-# PROP Intermediate_Dir "..\Debug\ldif2dlbm"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2ldbm - Win32 Single Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ldif2ldb"
-# PROP BASE Intermediate_Dir "ldif2ldb"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\SDebug"
-# PROP Intermediate_Dir "..\SDebug\ldif2dlbm"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib shell32.lib hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ELSEIF  "$(CFG)" == "ldif2ldbm - Win32 Single Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "ldif2ld0"
-# PROP BASE Intermediate_Dir "ldif2ld0"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\SRelease"
-# PROP Intermediate_Dir "..\SRelease\ldif2dlbm"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ENDIF 
-
-# Begin Target
-
-# Name "ldif2ldbm - Win32 Release"
-# Name "ldif2ldbm - Win32 Debug"
-# Name "ldif2ldbm - Win32 Single Debug"
-# Name "ldif2ldbm - Win32 Single Release"
-# Begin Source File
-
-SOURCE=.\ldif2common.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ldif2common.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\tools\ldif2ldbm.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mimic.c
-# End Source File
-# End Target
-# End Project
index 74e96fc4a1b8f117258f4ae86ec8ce8ddba9a373..52f19d20eb91201ae1cdf1daddab1697c65a7f35 100644 (file)
@@ -6,10 +6,8 @@
 #include <ac/string.h>
 #include <ac/unistd.h>
 
-#include <ldbm.h>
-#include <lber.h>
 #include <ldap.h>
-#include "portable.h"
+#include <ldbm.h>
 
 #define CACHE_SIZE     1000000
 #define MODE           0600
@@ -23,6 +21,7 @@ extern char   *phonetic(char *);
 
 extern int ldap_debug;
 
+int slap_debug;
 int    ldap_syslog;
 int    ldap_syslog_level;
 
diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c
new file mode 100644 (file)
index 0000000..99a7932
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#include "slapcommon.h"
+
+int
+main( int argc, char **argv )
+{
+       char            *buf;
+       int         lineno;
+       int         lmax;
+       int                     rc = EXIT_SUCCESS;
+
+       slap_tool_init( "slapadd", SLAPADD, argc, argv );
+       slap_startup( be );
+
+       if( !be->be_entry_open &&
+               !be->be_entry_close &&
+               !be->be_entry_put )
+       {
+               fprintf( stderr, "%s: database doesn't support necessary operations.\n",
+                       progname );
+               exit( EXIT_FAILURE );
+       }
+
+       buf = NULL;
+       lmax = 0;
+
+       if( be->be_entry_open( be, 1 ) != 0 ) {
+               fprintf( stderr, "%s: could not open database.\n",
+                       progname );
+               exit( EXIT_FAILURE );
+       }
+
+       while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
+               ID id;
+               Entry *e = str2entry( buf );
+
+               if( e == NULL ) {
+                       fprintf( stderr, "%s: could not parse entry at line %d\n",
+                               progname, lineno );
+                       rc = EXIT_FAILURE;
+                       continue;
+               }
+
+               id = be->be_entry_put( be, e );
+
+               if( id == NOID ) {
+                       fprintf( stderr, "%s: could not add entry (%s) at line %d\n",
+                               progname, e->e_dn, lineno );
+                       rc = EXIT_FAILURE;
+
+               } else if ( verbose ) {
+                       fprintf( stderr, "added: \"%s\" (%08ld)\n",
+                               e->e_dn, (long) id );
+               }
+
+               entry_free( e );
+       }
+
+       be->be_entry_close( be );
+
+       if( be->be_sync ) {
+               be->be_sync( be );
+       }
+
+       slap_shutdown( be );
+       slap_destroy();
+
+       return rc;
+}
diff --git a/servers/slapd/tools/slapadd.dsp b/servers/slapd/tools/slapadd.dsp
new file mode 100644 (file)
index 0000000..d269441
--- /dev/null
@@ -0,0 +1,157 @@
+# Microsoft Developer Studio Project File - Name="slapadd" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=slapadd - Win32 Single Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "slapadd.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "slapadd.mak" CFG="slapadd - Win32 Single Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "slapadd - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "slapadd - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "slapadd - Win32 Single Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "slapadd - Win32 Single Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "slapadd - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\Release"
+# PROP Intermediate_Dir "..\Release\slapadd"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "slapadd - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ldif2"
+# PROP BASE Intermediate_Dir "ldif2"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\Debug"
+# PROP Intermediate_Dir "..\Debug\slapadd"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF  "$(CFG)" == "slapadd - Win32 Single Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ldif2"
+# PROP BASE Intermediate_Dir "ldif2"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\SDebug"
+# PROP Intermediate_Dir "..\SDebug\slapadd"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF  "$(CFG)" == "slapadd - Win32 Single Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ldif2id0"
+# PROP BASE Intermediate_Dir "ldif2id0"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\SRelease"
+# PROP Intermediate_Dir "..\SRelease\slapadd"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386
+
+!ENDIF 
+
+# Begin Target
+
+# Name "slapadd - Win32 Release"
+# Name "slapadd - Win32 Debug"
+# Name "slapadd - Win32 Single Debug"
+# Name "slapadd - Win32 Single Release"
+# Begin Source File
+
+SOURCE=.\mimic.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapadd.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapcommon.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapcommon.h
+# End Source File
+# End Target
+# End Project
diff --git a/servers/slapd/tools/slapcat.c b/servers/slapd/tools/slapcat.c
new file mode 100644 (file)
index 0000000..f5d035e
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+
+#include "slapcommon.h"
+
+int
+main( int argc, char **argv )
+{
+       ID id;
+       int rc = EXIT_SUCCESS;
+
+       slap_tool_init( "slapcat", SLAPCAT, argc, argv );
+
+       slap_startup( be );
+
+       if( !be->be_entry_open &&
+               !be->be_entry_close &&
+               !be->be_entry_first &&
+               !be->be_entry_next &&
+               !be->be_entry_get )
+       {
+               fprintf( stderr, "%s: database doesn't support necessary operations.\n",
+                       progname );
+               exit( EXIT_FAILURE );
+       }
+
+       if( be->be_entry_open( be, 0 ) != 0 ) {
+               fprintf( stderr, "%s: could not open database.\n",
+                       progname );
+               exit( EXIT_FAILURE );
+       }
+
+       for ( id = be->be_entry_first( be );
+               id != NOID;
+               id = be->be_entry_next( be ) )
+       {
+               char *data;
+               int len;
+               Entry* e = be->be_entry_get( be, id );
+
+               if( verbose ) {
+                       printf( "# id=%08lx\n", (long) id );
+               }
+
+               if ( e == NULL ) {
+                       printf("# no data for entry id=%08lx\n\n", (long) id );
+                       rc = EXIT_FAILURE;
+                       continue;
+               }
+
+               data = entry2str( e, &len );
+
+               fputs( data, ldiffp );
+               fputs( "\n", ldiffp );
+       }
+
+       be->be_entry_close( be );
+
+       slap_shutdown( be );
+       slap_destroy();
+
+       return rc;
+}
diff --git a/servers/slapd/tools/slapcat.dsp b/servers/slapd/tools/slapcat.dsp
new file mode 100644 (file)
index 0000000..8a73d66
--- /dev/null
@@ -0,0 +1,156 @@
+# Microsoft Developer Studio Project File - Name="slapcat" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=slapcat - Win32 Single Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "slapcat.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "slapcat.mak" CFG="slapcat - Win32 Single Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "slapcat - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "slapcat - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "slapcat - Win32 Single Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "slapcat - Win32 Single Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "slapcat - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\Release"
+# PROP Intermediate_Dir "..\Release\slapcat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
+
+!ELSEIF  "$(CFG)" == "slapcat - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "slapcat"
+# PROP BASE Intermediate_Dir "slapcat"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\Debug"
+# PROP Intermediate_Dir "..\Debug\slapcat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
+
+!ELSEIF  "$(CFG)" == "slapcat - Win32 Single Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "slapcat"
+# PROP BASE Intermediate_Dir "slapcat"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\Sdebug"
+# PROP Intermediate_Dir "..\SDebug\slapcat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 oldbm32.lib libdb.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
+# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
+
+!ELSEIF  "$(CFG)" == "slapcat - Win32 Single Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "slapcat"
+# PROP BASE Intermediate_Dir "slapcat"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\SRelease"
+# PROP Intermediate_Dir "..\SRelease\slapcat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libdb.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
+# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "slapcat - Win32 Release"
+# Name "slapcat - Win32 Debug"
+# Name "slapcat - Win32 Single Debug"
+# Name "slapcat - Win32 Single Release"
+# Begin Source File
+
+SOURCE=.\mimic.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapcat.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapcommon.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapcommon.h
+# End Source File
+# End Target
+# End Project
diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c
new file mode 100644 (file)
index 0000000..f2791a6
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* slapcommon.c - common routine for the slap tools */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#include "slapcommon.h"
+#include "lutil.h"
+
+
+char   *progname       = NULL;
+char   *conffile       = SLAPD_DEFAULT_CONFIGFILE;
+int            truncatemode = 0;
+int            verbose         = 0;
+
+char   *ldiffile       = NULL;
+FILE   *ldiffp         = NULL;
+
+Backend *be = NULL;
+
+static void
+usage( int tool )
+{
+       char *options = NULL;
+       fprintf( stderr,
+               "usage: %s [-v] [-d debuglevel] [-f configfile]\n"
+                        "\t[-n databasenumber | -b suffix]", progname );
+
+       switch( tool ) {
+       case SLAPADD:
+               options = "\t[-l ldiffile]\n";
+               break;
+
+       case SLAPCAT:
+               options = "\t[-l ldiffile]\n";
+               break;
+
+       case SLAPINDEX:
+               options = "\tattributetype\n";
+               break;
+       }
+
+       if( options != NULL ) {
+               fputs( options, stderr );
+       }
+       exit( EXIT_FAILURE );
+}
+
+
+/*
+ * slap_tool_init - initialize slap utility, handle program options.
+ * arguments:
+ *     name            program name
+ *     tool            tool code
+ *     argc, argv      command line arguments
+ */
+
+void
+slap_tool_init(
+       const char* name,
+       int tool,
+       int argc, char **argv )
+{
+       char *options;
+       char *base = NULL;
+       int rc, i, dbnum;
+       int mode = SLAP_TOOL_MODE;
+
+       progname = lutil_progname( name, argc, argv );
+
+       switch( tool ) {
+       case SLAPADD:
+               options = "b:d:f:l:n:tv";
+               break;
+
+       case SLAPINDEX:
+               options = "b:d:f:n:v";
+               break;
+
+       case SLAPCAT:
+               options = "b:d:f:l:n:v";
+               break;
+
+       default:
+               fprintf( stderr, "%s: unknown tool mode (%d)\n", tool );
+               exit( EXIT_FAILURE );
+       }
+
+       ldiffile = NULL;
+       conffile = SLAPD_DEFAULT_CONFIGFILE;
+       dbnum = -1;
+       while ( (i = getopt( argc, argv, options )) != EOF ) {
+               switch ( i ) {
+               case 'b':
+                       base = strdup( optarg );
+
+               case 'd':       /* turn on debugging */
+                       ldap_debug = atoi( optarg );
+                       break;
+
+               case 'f':       /* specify a conf file */
+                       conffile = strdup( optarg );
+                       break;
+
+               case 'l':       /* LDIF file */
+                       ldiffile = strdup( optarg );
+                       break;
+
+               case 'n':       /* which config file db to index */
+                       dbnum = atoi( optarg ) - 1;
+                       break;
+
+               case 't':       /* turn on truncate */
+                       truncatemode++;
+                       mode |= SLAP_TRUNCATE_MODE;
+                       break;
+
+               case 'v':       /* turn on verbose */
+                       verbose++;
+                       break;
+
+               default:
+                       usage( tool );
+                       break;
+               }
+       }
+
+       if ( ( argc != optind + (tool == SLAPINDEX ? 1 : 0) )
+               || (dbnum >= 0 && base != NULL ) )
+       {
+               usage( tool );
+       }
+
+       if ( ldiffile == NULL ) {
+               ldiffp = tool == SLAPCAT ? stdout : stdin;
+
+       } else if( (ldiffp = fopen( ldiffile, tool == SLAPCAT ? "w" : "r" ))
+               == NULL )
+       {
+               perror( ldiffile );
+               exit( EXIT_FAILURE );
+       }
+
+       /*
+        * initialize stuff and figure out which backend we're dealing with
+        */
+
+       rc = slap_init( mode, progname );
+
+       if (rc != 0 ) {
+               fprintf( stderr, "%s: slap_init failed!\n", progname );
+               exit( EXIT_FAILURE );
+       }
+
+       read_config( conffile );
+
+       if ( !nbackends ) {
+               fprintf( stderr, "No databases found in config file\n" );
+               exit( EXIT_FAILURE );
+       }
+
+       if( base != NULL ) {
+               char *tbase = ch_strdup( base );
+
+               if( dn_normalize_case( tbase ) == NULL ) {
+                       fprintf( stderr, "%s: slap_init invalid suffix (\"%s\")\n",
+                               progname, base );
+                       exit( EXIT_FAILURE );
+               }
+
+               be = select_backend( tbase );
+               free( tbase );
+
+               if( be == NULL ) {
+                       fprintf( stderr, "%s: slap_init no backend for \"%s\"\n",
+                               progname, base );
+                       exit( EXIT_FAILURE );
+               }
+
+       } else if ( dbnum == -1 ) {
+               be = &backends[dbnum=0];
+
+       } else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
+               fprintf( stderr,
+                       "Database number selected via -n is out of range\n"
+                       "Must be in the range 1 to %d (number of databases in the config file)\n",
+                       nbackends );
+               exit( EXIT_FAILURE );
+
+       } else {
+               be = &backends[dbnum];
+       }
+}
diff --git a/servers/slapd/tools/slapcommon.h b/servers/slapd/tools/slapcommon.h
new file mode 100644 (file)
index 0000000..a5b62b4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* slapcommon.h - common definitions for the slap tools */
+
+#ifndef SLAPCOMMON_H_
+#define SLAPCOMMON_H_ 1
+
+#define SLAPD_TOOLS 1
+#include "ldap_defaults.h"
+#include "../slap.h"
+
+enum slaptool {
+       SLAPCAT=1,      /* database -> LDIF tool */
+       SLAPADD,        /* LDIF -> database tool */
+       SLAPINDEX,      /* database index tool */
+       SLAPTEST        /* database testing tool */
+};
+
+
+extern char    *progname;
+extern char    *conffile;
+extern Backend *be;
+extern int             appendmode;
+extern int             verbose;
+
+extern char    *ldiffile;
+extern FILE    *ldiffp;
+
+void slap_tool_init LDAP_P((
+       const char* name,
+       int tool,
+       int argc, char **argv ));
+
+#endif /* SLAPCOMMON_H_ */
diff --git a/servers/slapd/tools/slapindex.c b/servers/slapd/tools/slapindex.c
new file mode 100644 (file)
index 0000000..8de92b9
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#include "slapcommon.h"
+
+int
+main( int argc, char **argv )
+{
+       char            *type;
+       ID id;
+       int rc = EXIT_SUCCESS;
+
+       slap_tool_init( "slapindex", SLAPINDEX, argc, argv );
+
+       slap_startup( be );
+
+       if( !be->be_entry_open &&
+               !be->be_entry_close &&
+               !be->be_entry_first &&
+               !be->be_entry_next &&
+               !be->be_entry_get &&
+               !be->be_index_attr &&
+               !be->be_index_change )
+       {
+               fprintf( stderr, "%s: database doesn't support necessary operations.\n",
+                       progname );
+               exit( EXIT_FAILURE );
+       }
+
+       type = attr_normalize( argv[argc - 1] );
+
+       if ( !be->be_index_attr( be, type ) ) {
+               fprintf( stderr, "attribute type \"%s\": no indices to generate\n",
+                       type );
+               exit( EXIT_FAILURE );
+       }
+
+       if( be->be_entry_open( be, 0 ) != 0 ) {
+               fprintf( stderr, "%s: could not open database.\n",
+                       progname );
+               exit( EXIT_FAILURE );
+       }
+
+       for ( id = be->be_entry_first( be );
+               id != NOID;
+               id = be->be_entry_next( be ) )
+       {
+               Attribute *attr;
+               struct berval **values;
+               Entry* e = be->be_entry_get( be, id );
+               struct berval bv;
+               struct berval *bvals[2];
+
+               if ( e == NULL ) {
+                       fprintf( stderr,
+                               "entry id=%08lx: no data\n", (long) id );
+                       rc = EXIT_FAILURE;
+                       continue;
+               }
+
+               if( verbose ) {
+                       printf("indexing id=%08lx dn=\"%s\"\n",
+                               id, e->e_dn );
+               }
+
+               if( strcasecmp( type, "dn" ) == 0 ) {
+                       attr = attr_find( e->e_attrs, type );
+
+                       if( attr == NULL ) continue;
+
+                       values = attr->a_vals;
+
+               } else {
+                       bv.bv_val = e->e_ndn;
+                       bv.bv_len = strlen( bv.bv_val );
+                       bvals[0] = &bv;
+                       bvals[1] = NULL;
+
+                       values = bvals;
+               }
+
+               if ( be->be_index_change( be,
+                       type, attr->a_vals, id, SLAP_INDEX_ADD_OP ) )
+               {
+                       rc = EXIT_FAILURE;
+               }
+
+               entry_free( e );
+       }
+
+       (void) be->be_entry_close( be );
+
+       slap_shutdown( be );
+       slap_destroy();
+
+       return( rc );
+}
diff --git a/servers/slapd/tools/slapindex.dsp b/servers/slapd/tools/slapindex.dsp
new file mode 100644 (file)
index 0000000..7c935bf
--- /dev/null
@@ -0,0 +1,158 @@
+# Microsoft Developer Studio Project File - Name="slapindex" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=slapindex - Win32 Single Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "slapindex.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "slapindex.mak" CFG="slapindex - Win32 Single Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "slapindex - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "slapindex - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "slapindex - Win32 Single Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "slapindex - Win32 Single Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "slapindex - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\Release"
+# PROP Intermediate_Dir "..\Release\slapindex"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "slapindex - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ldif2ind"
+# PROP BASE Intermediate_Dir "ldif2ind"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\Debug"
+# PROP Intermediate_Dir "..\Debug\slapindex"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF  "$(CFG)" == "slapindex - Win32 Single Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ldif2ind"
+# PROP BASE Intermediate_Dir "ldif2ind"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\SDebug"
+# PROP Intermediate_Dir "..\SDebug\slapindex"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib shell32.lib hs_regexd.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ELSEIF  "$(CFG)" == "slapindex - Win32 Single Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ldif2in0"
+# PROP BASE Intermediate_Dir "ldif2in0"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\SRelease"
+# PROP Intermediate_Dir "..\SRelease\slapindex"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386
+
+!ENDIF 
+
+# Begin Target
+
+# Name "slapindex - Win32 Release"
+# Name "slapindex - Win32 Debug"
+# Name "slapindex - Win32 Single Debug"
+# Name "slapindex - Win32 Single Release"
+# Begin Source File
+
+SOURCE=.\mimic.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapcommon.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapcommon.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\slapindex.c
+# End Source File
+# End Target
+# End Project
index f13800d21e3d7457cecf78c33056d1b755f4fce5..8e3f6b1ed3f29440e09015db0e3def652e2dd6ee 100755 (executable)
@@ -3,7 +3,6 @@ DATADIR=$SRCDIR/data
 PROGDIR=./progs
 
 if test "$BACKEND" = "bdb2" ; then
-       LDIF2LDBM=../servers/slapd/tools/ldif2ldbm-bdb2
        CONF=$DATADIR/slapd-bdb2-master.conf
        ACLCONF=$DATADIR/slapd-bdb2-acl.conf
        MASTERCONF=$DATADIR/slapd-bdb2-repl-master.conf
@@ -11,7 +10,6 @@ if test "$BACKEND" = "bdb2" ; then
        REFSLAVECONF=$DATADIR/slapd-bdb2-ref-slave.conf
        TIMING="-t"
 else
-       LDIF2LDBM=../servers/slapd/tools/ldif2ldbm
        CONF=$DATADIR/slapd-master.conf
        ACLCONF=$DATADIR/slapd-acl.conf
        MASTERCONF=$DATADIR/slapd-repl-master.conf
@@ -28,6 +26,8 @@ PASSWDCONF=$DATADIR/slapd-passwd.conf
 CLIENTDIR=../clients/tools
 #CLIENTDIR=/usr/local/bin
 
+LDIF2LDBM="../servers/slapd/tools/slapadd $LDAP_VERBOSE"
+
 SLAPD=../servers/slapd/slapd
 SLURPD=../servers/slurpd/slurpd
 LDAPSEARCH="$CLIENTDIR/ldapsearch $PROTO -LLL"
index 72cdb3053db05a84318304d2c377e3d41f4388d0..4107012e97a7f3c99de5a619faa4bfa566773844 100755 (executable)
@@ -7,7 +7,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index 2c71f4f2e769062b642d5799781b2be64704cd44..06391bb48cecb55b5d3ed21bc70f0a0ff7ffa823 100755 (executable)
@@ -27,7 +27,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $NIS_CONF -i $NIS_LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $NIS_CONF -l $NIS_LDIF
 RC=$?
 if [ $RC != 0 ]; then
        echo "ldif2ldbm failed!"
index 42123ec417e88003857f7c9d6d2abaea5657cacd..8fde6c413103cfa405cc627550dfc9afdf7f6d91 100755 (executable)
@@ -20,7 +20,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index 42123ec417e88003857f7c9d6d2abaea5657cacd..8fde6c413103cfa405cc627550dfc9afdf7f6d91 100755 (executable)
@@ -20,7 +20,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index 2999b01117c19fa301e88eb5735758ea9b2e7140..de58905d9e252425b5229ac32cd68e918bf3d030 100755 (executable)
@@ -17,7 +17,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index acd91b58c1681aedbeccb3ea42db90f018363ef7..c9fbd0902911656b562b31eb14f43a093f519613 100755 (executable)
@@ -17,7 +17,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index d7f63a84822349cbc258cb56cf9a0c61689d5b25..caf0df4f8a57380dfd6b91fb357c22e869b13484 100755 (executable)
@@ -17,7 +17,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index 8ea70246610771c45ce592ea5711812ccd5f4879..ad866b7f1aa5f4b4ed3d8aa9e28a9a590927efd4 100755 (executable)
@@ -17,7 +17,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index 2ba50426d8631208eb534aff3b3d5e8dbd9bd4ac..9644566ee760fa761a6032d39985c8228a0c4e23 100755 (executable)
@@ -20,7 +20,7 @@ echo "Cleaning up in $DBDIR..."
 rm -f $DBDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"
index c4c5bbf83f562e663958f143ee71746e9d699dfc..3bc69ea74fd76e13306f8f4edc561fc0a3bf9e30 100755 (executable)
@@ -22,7 +22,7 @@ rm -f $DBDIR/[!C]*
 rm -f $REPLDIR/[!C]*
 
 echo "Running ldif2ldbm to build slapd database..."
-$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
+$LDIF2LDBM -f $CONF -l $LDIF
 RC=$?
 if test $RC != 0 ; then
        echo "ldif2ldbm failed!"