1 /* back-ldbm.h - ldap ldbm back-end header file */
3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
14 #define DEFAULT_CACHE_SIZE 1000
16 #ifdef HAVE_BERKELEY_DB2
17 # define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE)
19 # define DEFAULT_DBCACHE_SIZE 100000
22 #define DEFAULT_DB_DIRECTORY "/usr/tmp"
23 #define DEFAULT_MODE 0600
28 /* #define DN_INDICES 1 *//* generate dn eq, subtree, and parent indices */
29 #define DN_ENTRY_PREFIX '='
30 #define DN_SUBTREE_PREFIX '+'
31 #define DN_PARENT_PREFIX '-'
34 * there is a single index for each attribute. these prefixes ensure
35 * that there is no collision among keys.
37 #define EQ_PREFIX '=' /* prefix for equality keys */
38 #define APPROX_PREFIX '~' /* prefix for approx keys */
39 #define SUB_PREFIX '*' /* prefix for substring keys */
40 #define CONT_PREFIX '\\' /* prefix for continuation keys */
42 /* allow 3 characters per byte + PREFIX + EOS */
43 #define CONT_SIZE ( sizeof(long)*3 + 1 + 1 )
45 #undef CONT_POSTFIX /* postfix original key */
47 #define UNKNOWN_PREFIX '?' /* prefix for unknown keys */
49 #define DEFAULT_BLOCKSIZE 8192
52 * This structure represents an id block on disk and an id list
55 * The fields have the following meanings:
57 * b_nmax maximum number of ids in this block. if this is == ALLIDSBLOCK,
58 * then this block represents all ids.
59 * b_nids current number of ids in use in this block. if this
60 * is == INDBLOCK, then this block is an indirect block
61 * containing a list of other blocks containing actual ids.
62 * the list is terminated by an id of NOID.
63 * b_ids a list of the actual ids themselves
68 #define ID_BLOCK_NMAX_OFFSET 0
69 #define ID_BLOCK_NIDS_OFFSET 1
70 #define ID_BLOCK_IDS_OFFSET 2
72 /* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */
74 #define ID_BLOCK_NMAX(b) ((b)[ID_BLOCK_NMAX_OFFSET])
75 #define ID_BLOCK_NIDS(b) ((b)[ID_BLOCK_NIDS_OFFSET])
76 #define ID_BLOCK_ID(b, n) ((b)[ID_BLOCK_IDS_OFFSET+(n)])
78 #define ID_BLOCK_NOID(b, n) (ID_BLOCK_ID((b),(n)) == NOID)
80 #define ID_BLOCK_ALLIDS_VALUE 0
81 #define ID_BLOCK_ALLIDS(b) (ID_BLOCK_NMAX(b) == ID_BLOCK_ALLIDS_VALUE)
83 #define ID_BLOCK_INDIRECT_VALUE 0
84 #define ID_BLOCK_INDIRECT(b) (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
86 /* for the in-core cache of entries */
87 typedef struct ldbm_cache {
92 Entry *c_lruhead; /* lru - add accessed entries here */
93 Entry *c_lrutail; /* lru - rem lru entries from here */
94 ldap_pvt_thread_mutex_t c_mutex;
97 #define CACHE_READ_LOCK 0
98 #define CACHE_WRITE_LOCK 1
100 /* for the cache of open index files */
101 typedef struct ldbm_dbcache {
111 /* for the cache of attribute information (which are indexed, etc.) */
112 typedef struct ldbm_attrinfo {
113 char *ai_type; /* type name (cn, sn, ...) */
114 int ai_indexmask; /* how the attr is indexed */
115 #define INDEX_PRESENCE 0x01
116 #define INDEX_EQUALITY 0x02
117 #define INDEX_APPROX 0x04
118 #define INDEX_SUB 0x08
119 #define INDEX_UNKNOWN 0x10
120 #define INDEX_FROMINIT 0x20
121 int ai_syntaxmask; /* what kind of syntax */
123 #define SYNTAX_CIS 0x01
124 #define SYNTAX_CES 0x02
125 #define SYNTAX_BIN 0x04
130 #define MAXDBCACHE 16
132 /* this could be made an option */
133 #ifndef SLAPD_NEXTID_CHUNK
134 #define SLAPD_NEXTID_CHUNK 32
139 #if SLAPD_NEXTID_CHUNK > 1
142 char *li_nextid_file;
143 ldap_pvt_thread_mutex_t li_root_mutex;
144 ldap_pvt_thread_mutex_t li_add_mutex;
145 ldap_pvt_thread_mutex_t li_nextid_mutex;
152 DBCache li_dbcache[MAXDBCACHE];
153 ldap_pvt_thread_mutex_t li_dbcache_mutex;
154 ldap_pvt_thread_cond_t li_dbcache_cv;
155 #ifdef HAVE_BERKELEY_DB2
160 extern int ldbm_ignore_nextid_file;
164 #include "proto-back-ldbm.h"
166 #endif /* _back_ldbm_h_ */