/* ldbm.c - ldap dbm compatibility routines */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2003 The OpenLDAP Foundation.
+ * Portions Copyright 1998-2003 Kurt D. Zeilenga.
+ * Portions Copyright 1998-2001 Net Boolean Incorporated.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
*/
-
-/* Patched for Berkeley DB version 2.0; /KSp; 98/02/23
- * - DB version 2.6.4b ; 1998/12/28, /KSp
- * - DB_DBT_MALLOC ; 1998/03/22, /KSp
- * - basic implementation; 1998/02/23, /KSp
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP). Additional significant contributors
+ * include:
+ * Gary Williams
+ * Howard Chu
+ * Juan Gomez
+ * Kurt D. Zeilenga
+ * Kurt Spanier
+ * Mark Whitehouse
+ * Randy Kundee
*/
#include "portable.h"
DB_ENV *ldbm_Env = NULL; /* real or fake, depending on db and version */
#endif
+/* Let's make the version comparisons a little easier... */
+#undef DB_VERSION_X
+#ifdef HAVE_BERKELEY_DB
+#define DB_VERSION_X ((DB_VERSION_MAJOR<<16)|(DB_VERSION_MINOR<<8)|DB_VERSION_PATCH)
+#endif
+
/*******************************************************************
* *
* Create some special functions to initialize Berkeley DB for *
DB_ENV *env = NULL;
int err;
u_int32_t envFlags;
+#ifdef HAVE_EBCDIC
+ char n2[2048];
+#endif
err = db_env_create( &env, 0 );
return NULL;
}
-#if DB_VERSION_MAJOR > 3 || DB_VERSION_MINOR >= 3
+#if DB_VERSION_X >= 0x030300
/* This interface appeared in 3.3 */
env->set_alloc( env, ldbm_malloc, NULL, NULL );
#endif
envFlags |= DB_THREAD;
#endif
-#if DB_VERSION_MAJOR > 3 || DB_VERSION_MINOR > 0
+#ifdef HAVE_EBCDIC
+ strncpy(n2, home, sizeof(n2)-1);
+ n2[sizeof(n2)-1] = '\0';
+ __atoe(n2);
+ home = n2;
+#endif
+#if DB_VERSION_X >= 0x030100
err = env->open( env, home, envFlags, 0 );
#else
/* 3.0.x requires an extra argument */
return NULL;
}
-#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR < 3
+#if DB_VERSION_X < 0x030300
ret->set_malloc( ret, ldbm_malloc );
#endif
__atoe(n2);
name = n2;
#endif
-#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR > 0 && DB_VERSION_PATCH >= 17
+#if DB_VERSION_X >= 0x040111
err = ret->open( ret, NULL, name, NULL, DB_TYPE, rw, mode);
#else
err = ret->open( ret, name, NULL, DB_TYPE, rw, mode);
LDBM_RLOCK;
/* acquire a cursor for the DB */
-# if DB_VERSION_MAJOR >= 3 || (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR > 5)
+# if DB_VERSION_X >= 0x020600
rc = ldbm->cursor( ldbm, NULL, &dbci, 0 );
# else
rc = ldbm->cursor( ldbm, NULL, &dbci );