Commit e4f6d548 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

New dn2id format with base/one/subtree indices (ldbm/bdb2)

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)
parent 375995be
......@@ -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>
......
......@@ -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)
......
......@@ -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 */
......
......@@ -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 */
......@@ -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;
......
......@@ -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 */