1998-12-29 03:51:35 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted only
|
|
|
|
* as authorized by the OpenLDAP Public License. A copy of this
|
|
|
|
* license is available at http://www.OpenLDAP.org/license.html or
|
|
|
|
* in file LICENSE in the top-level directory of the distribution.
|
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
/* ldbm.h - ldap dbm compatibility routine header file */
|
|
|
|
|
|
|
|
#ifndef _LDBM_H_
|
|
|
|
#define _LDBM_H_
|
|
|
|
|
1999-01-27 04:55:54 +08:00
|
|
|
#include <ldap_cdefs.h>
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#ifdef LDBM_USE_DBBTREE
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* *
|
1998-10-25 09:41:42 +08:00
|
|
|
* use berkeley db btree package *
|
1998-08-09 08:43:13 +08:00
|
|
|
* *
|
|
|
|
*****************************************************************/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <fcntl.h>
|
1998-08-20 08:05:08 +08:00
|
|
|
|
1999-01-27 04:55:54 +08:00
|
|
|
#ifdef HAVE_DB_185_H
|
1998-08-20 08:05:08 +08:00
|
|
|
# include <db_185.h>
|
|
|
|
#else
|
|
|
|
# include <db.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
# ifdef HAVE_BERKELEY_DB2
|
1998-09-03 08:50:13 +08:00
|
|
|
# define R_NOOVERWRITE DB_NOOVERWRITE
|
|
|
|
# define DEFAULT_DB_PAGE_SIZE 1024
|
|
|
|
# endif
|
1998-08-20 08:05:08 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_BEGIN_DECL
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
typedef DBT Datum;
|
|
|
|
#define dsize size
|
|
|
|
#define dptr data
|
|
|
|
|
|
|
|
typedef DB *LDBM;
|
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_END_DECL
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#define DB_TYPE DB_BTREE
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* for ldbm_open */
|
1998-10-25 09:41:42 +08:00
|
|
|
#ifdef HAVE_BERKELEY_DB2
|
1998-09-03 08:50:13 +08:00
|
|
|
# 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
|
|
|
|
# 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
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
# define LDBM_FAST 0
|
|
|
|
|
|
|
|
#define LDBM_SUFFIX ".dbb"
|
|
|
|
#define LDBM_ORDERED 1
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* for ldbm_insert */
|
|
|
|
#define LDBM_INSERT R_NOOVERWRITE
|
|
|
|
#define LDBM_REPLACE 0
|
|
|
|
#define LDBM_SYNC 0x80000000
|
|
|
|
|
1998-11-17 12:07:31 +08:00
|
|
|
#elif defined( LDBM_USE_DBHASH )
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* *
|
1998-10-25 09:41:42 +08:00
|
|
|
* use berkeley db hash package *
|
1998-08-09 08:43:13 +08:00
|
|
|
* *
|
|
|
|
*****************************************************************/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <fcntl.h>
|
1998-09-03 08:50:13 +08:00
|
|
|
|
1999-01-27 04:55:54 +08:00
|
|
|
#ifdef HAVE_DB_185_H
|
1998-08-20 08:05:08 +08:00
|
|
|
# include <db_185.h>
|
|
|
|
#else
|
|
|
|
# include <db.h>
|
1998-09-03 08:50:13 +08:00
|
|
|
# ifdef LDBM_USE_DB2
|
|
|
|
# define R_NOOVERWRITE DB_NOOVERWRITE
|
|
|
|
# define DEFAULT_DB_PAGE_SIZE 1024
|
|
|
|
# endif
|
1998-08-20 08:05:08 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_BEGIN_DECL
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
typedef DBT Datum;
|
|
|
|
#define dsize size
|
|
|
|
#define dptr data
|
|
|
|
|
|
|
|
typedef DB *LDBM;
|
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_END_DECL
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#define DB_TYPE DB_HASH
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* for ldbm_open */
|
1998-09-03 08:50:13 +08:00
|
|
|
#ifdef LDBM_USE_DB2
|
|
|
|
# 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
|
|
|
|
# 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)
|
1998-10-25 09:41:42 +08:00
|
|
|
# define LDBM_FAST 0
|
1998-09-03 08:50:13 +08:00
|
|
|
#endif
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#define LDBM_SUFFIX ".dbh"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* for ldbm_insert */
|
|
|
|
#define LDBM_INSERT R_NOOVERWRITE
|
|
|
|
#define LDBM_REPLACE 0
|
|
|
|
#define LDBM_SYNC 0x80000000
|
|
|
|
|
1998-11-17 12:07:31 +08:00
|
|
|
#elif defined( HAVE_GDBM )
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* *
|
|
|
|
* use gdbm if possible *
|
|
|
|
* *
|
|
|
|
*****************************************************************/
|
|
|
|
|
|
|
|
#include <gdbm.h>
|
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_BEGIN_DECL
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
typedef datum Datum;
|
|
|
|
|
|
|
|
typedef GDBM_FILE LDBM;
|
|
|
|
|
|
|
|
extern gdbm_error gdbm_errno;
|
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_END_DECL
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
/* for ldbm_open */
|
|
|
|
#define LDBM_READER GDBM_READER
|
|
|
|
#define LDBM_WRITER GDBM_WRITER
|
|
|
|
#define LDBM_WRCREAT GDBM_WRCREAT
|
|
|
|
#define LDBM_NEWDB GDBM_NEWDB
|
|
|
|
#define LDBM_FAST GDBM_FAST
|
|
|
|
|
|
|
|
#define LDBM_SUFFIX ".gdbm"
|
|
|
|
|
|
|
|
/* for ldbm_insert */
|
|
|
|
#define LDBM_INSERT GDBM_INSERT
|
|
|
|
#define LDBM_REPLACE GDBM_REPLACE
|
|
|
|
#define LDBM_SYNC 0x80000000
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
|
1998-11-17 12:07:31 +08:00
|
|
|
#elif defined( HAVE_NDBM )
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* *
|
|
|
|
* if none of the above use ndbm, the standard unix thing *
|
|
|
|
* *
|
|
|
|
*****************************************************************/
|
|
|
|
|
|
|
|
#include <ndbm.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_FCNTL_H
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_BEGIN_DECL
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
typedef datum Datum;
|
|
|
|
|
|
|
|
typedef DBM *LDBM;
|
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
LDAP_END_DECL
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/* for ldbm_open */
|
|
|
|
#define LDBM_READER O_RDONLY
|
|
|
|
#define LDBM_WRITER O_WRONLY
|
|
|
|
#define LDBM_WRCREAT (O_RDWR|O_CREAT)
|
|
|
|
#define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT)
|
|
|
|
#define LDBM_FAST 0
|
|
|
|
|
|
|
|
#define LDBM_SUFFIX ".ndbm"
|
|
|
|
|
|
|
|
/* for ldbm_insert */
|
|
|
|
#define LDBM_INSERT DBM_INSERT
|
|
|
|
#define LDBM_REPLACE DBM_REPLACE
|
|
|
|
#define LDBM_SYNC 0
|
|
|
|
|
1998-11-17 12:07:31 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-01-27 04:55:54 +08:00
|
|
|
LDAP_BEGIN_DECL
|
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
int ldbm_initialize( void );
|
|
|
|
int ldbm_shutdown( void );
|
1999-02-08 19:42:14 +08:00
|
|
|
#if HAVE_BERKELEY_DB2
|
|
|
|
extern DB_ENV ldbm_Env;
|
|
|
|
#endif
|
1999-02-05 17:03:47 +08:00
|
|
|
|
1999-02-05 01:36:06 +08:00
|
|
|
int ldbm_errno( LDBM ldbm );
|
1998-08-09 08:43:13 +08:00
|
|
|
LDBM ldbm_open( char *name, int rw, int mode, int dbcachesize );
|
|
|
|
void ldbm_close( LDBM ldbm );
|
|
|
|
void ldbm_sync( LDBM ldbm );
|
|
|
|
void ldbm_datum_free( LDBM ldbm, Datum data );
|
|
|
|
Datum ldbm_datum_dup( LDBM ldbm, Datum data );
|
|
|
|
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 );
|
1998-09-03 08:50:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#if HAVE_BERKELEY_DB2
|
1998-09-03 08:50:13 +08:00
|
|
|
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
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-12-30 01:28:45 +08:00
|
|
|
|
|
|
|
/* initialization of Datum structures */
|
|
|
|
#ifdef HAVE_BERKELEY_DB2
|
|
|
|
# define ldbm_datum_init(d) ((void)memset(&(d), 0, sizeof(Datum)))
|
|
|
|
#else
|
|
|
|
# define ldbm_datum_init(d) ((void)0)
|
|
|
|
#endif /* HAVE_BERKELEY_DB2 */
|
|
|
|
|
1999-01-27 04:55:54 +08:00
|
|
|
LDAP_END_DECL
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#endif /* _ldbm_h_ */
|