back-bdb.h 1.78 KB
Newer Older
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1
2
3
4
5
6
7
8
9
10
11
12
13
/* back-bdb.h - ldap ldbm back-end header file */
/* $OpenLDAP$ */
/*
 * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#ifndef _BACK_BDB_H_
#define _BACK_BDB_H_

#include <portable.h>
#include <db.h>

14
15
#include "slap.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
16
17
LDAP_BEGIN_DECL

Kurt Zeilenga's avatar
Kurt Zeilenga committed
18

Kurt Zeilenga's avatar
Kurt Zeilenga committed
19
20
21
22
#define DN_BASE_PREFIX		SLAP_INDEX_EQUALITY_PREFIX
#define DN_ONE_PREFIX	 	'%'
#define DN_SUBTREE_PREFIX 	'@'

23
24
25
26
27
28
#define DBTzero(t)			(memset((t), 0, sizeof(DBT)))
#define DBT2bv(t,bv)		((bv)->bv_val = (t)->data, \
								(bv)->bv_len = (t)->size)
#define bv2DBT(bv,t)		((t)->data = (bv)->bv_val, \
								(t)->size = (bv)->bv_len )

Kurt Zeilenga's avatar
Kurt Zeilenga committed
29
#define DEFAULT_MODE		0600
Kurt Zeilenga's avatar
Kurt Zeilenga committed
30

Kurt Zeilenga's avatar
Kurt Zeilenga committed
31
32
#define BDB_TXN_RETRIES	16

33
#define BDB_DBENV_HOME	LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
34

35
#ifdef BDB_SUBDIRS
36
37
38
#define BDB_TMP_SUBDIR	LDAP_DIRSEP "tmp"
#define BDB_LG_SUBDIR	LDAP_DIRSEP "log"
#define BDB_DATA_SUBDIR	LDAP_DIRSEP "data"
39
#endif
Kurt Zeilenga's avatar
Kurt Zeilenga committed
40

41
#define BDB_SUFFIX		".bdb"
42
43
44
45
#define BDB_NEXTID		0
#define BDB_DN2ID		1
#define BDB_ID2ENTRY	2
#define BDB_INDICES		3
46
47
48
49
50
51
52
53

struct bdb_db_info {
	DB			*bdi_db;
};

struct bdb_info {
	DB_ENV		*bi_dbenv;

54
55
	/* DB_ENV parameters */
	/* The DB_ENV can be tuned via DB_CONFIG */
56
57
58
59
60
	char		*bi_dbenv_home;
	u_int32_t	bi_dbenv_xflags; /* extra flags */
	int			bi_dbenv_mode;

	int			bi_ndatabases;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
61
	struct bdb_db_info **bi_databases;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
62
63
64
65

	int			bi_txn_cp;
	u_int32_t	bi_txn_cp_min;
	u_int32_t	bi_txn_cp_kbyte;
66
67
68
69
70
71

#ifndef NO_THREADS
	int			bi_lock_detect;
	int			bi_lock_detect_seconds;
	ldap_pvt_thread_t	bi_lock_detect_tid;
#endif
72
73

	ID			bi_lastid;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
74
};
75

Kurt Zeilenga's avatar
Kurt Zeilenga committed
76
#define bi_nextid	bi_databases[BDB_NEXTID]
77
#define bi_id2entry	bi_databases[BDB_ID2ENTRY]
Kurt Zeilenga's avatar
Kurt Zeilenga committed
78
#define bi_dn2id	bi_databases[BDB_DN2ID]
Kurt Zeilenga's avatar
Kurt Zeilenga committed
79

80
81
82
83
84
85
struct bdb_op_info {
	BackendDB*	boi_bdb;
	DB_TXN*		boi_txn;
	int			boi_err;
};

Kurt Zeilenga's avatar
Kurt Zeilenga committed
86
87
LDAP_END_DECL

Kurt Zeilenga's avatar
Kurt Zeilenga committed
88
89
#include "proto-bdb.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
90
#endif /* _BACK_BDB_H_ */