]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/back-ldbm.h
remove a componentCertificate attribute from the organizationalPerson objectclass
[openldap] / servers / slapd / back-ldbm / back-ldbm.h
1 /* back-ldbm.h - ldap ldbm back-end header file */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2004 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #ifndef _BACK_LDBM_H_
18 #define _BACK_LDBM_H_
19
20 #include "ldbm.h"
21
22 LDAP_BEGIN_DECL
23
24 #define LDBM_SUBENTRIES 1
25
26 #define DEFAULT_CACHE_SIZE      1000
27
28 #if defined(HAVE_BERKELEY_DB) && DB_VERSION_MAJOR >= 2
29 #       define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE)
30 #else
31 #       define DEFAULT_DBCACHE_SIZE 100000
32 #endif
33
34 #define DN_BASE_PREFIX          SLAP_INDEX_EQUALITY_PREFIX
35 #define DN_ONE_PREFIX           '%'
36 #define DN_SUBTREE_PREFIX       '@'
37
38 /*
39  * there is a single index for each attribute.  these prefixes ensure
40  * that there is no collision among keys.
41  */
42
43 /* allow PREFIX + byte for continuate number */
44 #define SLAP_INDEX_CONT_SIZE ( sizeof(SLAP_INDEX_CONT_PREFIX) + sizeof(unsigned char) )
45
46 #define DEFAULT_BLOCKSIZE       8192
47
48 /*
49  * This structure represents an id block on disk and an id list
50  * in core.
51  *
52  * The fields have the following meanings:
53  *
54  *      b_nmax  maximum number of ids in this block. if this is == ALLIDSBLOCK,
55  *              then this block represents all ids.
56  *      b_nids  current number of ids in use in this block.  if this
57  *              is == INDBLOCK, then this block is an indirect block
58  *              containing a list of other blocks containing actual ids.
59  *              the list is terminated by an id of NOID.
60  *      b_ids   a list of the actual ids themselves
61  */
62
63 typedef ID ID_BLOCK;
64
65 #define ID_BLOCK_NMAX_OFFSET    0
66 #define ID_BLOCK_NIDS_OFFSET    1
67 #define ID_BLOCK_IDS_OFFSET             2
68
69 /* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */
70
71 #define ID_BLOCK_NMAX(b)                ((b)[ID_BLOCK_NMAX_OFFSET])
72
73 /* Use this macro to get the value, but not to set it.
74  * By default this is identical to above.
75  */
76 #define ID_BLOCK_NMAXN(b)               ID_BLOCK_NMAX(b)
77 #define ID_BLOCK_NIDS(b)                ((b)[ID_BLOCK_NIDS_OFFSET])
78 #define ID_BLOCK_ID(b, n)               ((b)[ID_BLOCK_IDS_OFFSET+(n)])
79
80 #define ID_BLOCK_NOID(b, n)             (ID_BLOCK_ID((b),(n)) == NOID)
81
82 #define ID_BLOCK_ALLIDS_VALUE   0
83 #define ID_BLOCK_ALLIDS(b)              (ID_BLOCK_NMAX(b) == ID_BLOCK_ALLIDS_VALUE)
84
85 #define ID_BLOCK_INDIRECT_VALUE 0
86 #define ID_BLOCK_INDIRECT(b)    (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
87
88 #define USE_INDIRECT_NIDS       1
89
90 #ifdef USE_INDIRECT_NIDS
91 /*
92  * Use the high bit of ID_BLOCK_NMAX to indicate an INDIRECT block, thus
93  * freeing up the ID_BLOCK_NIDS to store an actual count. This allows us
94  * to use binary search on INDIRECT blocks.
95  */
96 #undef  ID_BLOCK_NMAXN
97 #define ID_BLOCK_NMAXN(b)               ((b)[ID_BLOCK_NMAX_OFFSET]&0x7fffffff)
98 #undef  ID_BLOCK_INDIRECT_VALUE
99 #define ID_BLOCK_INDIRECT_VALUE 0x80000000
100 #undef  ID_BLOCK_INDIRECT
101 #define ID_BLOCK_INDIRECT(b)    (ID_BLOCK_NMAX(b) & ID_BLOCK_INDIRECT_VALUE)
102
103 #endif  /* USE_INDIRECT_NIDS */
104
105 /* for the in-core cache of entries */
106 typedef struct ldbm_cache {
107         int             c_maxsize;
108         int             c_cursize;
109         Avlnode         *c_dntree;
110         Avlnode         *c_idtree;
111         Entry           *c_lruhead;     /* lru - add accessed entries here */
112         Entry           *c_lrutail;     /* lru - rem lru entries from here */
113         ldap_pvt_thread_mutex_t c_mutex;
114 } Cache;
115
116 #define CACHE_READ_LOCK         0
117 #define CACHE_WRITE_LOCK        1
118
119 /* for the cache of open index files */
120 typedef struct ldbm_dbcache {
121         int             dbc_refcnt;
122         int             dbc_maxids;
123         int             dbc_maxindirect;
124         int             dbc_dirty;
125         int             dbc_flags;
126         time_t  dbc_lastref;
127         long    dbc_blksize;
128         char    *dbc_name;
129         LDBM    dbc_db;
130         ldap_pvt_thread_mutex_t dbc_write_mutex;
131 } DBCache;
132
133 #define MAXDBCACHE      128
134
135 struct ldbminfo {
136         ldap_pvt_thread_rdwr_t          li_giant_rwlock;
137         ID                      li_nextid;
138         int                     li_mode;
139         slap_mask_t     li_defaultmask;
140         char                    *li_directory;
141         Cache           li_cache;
142         Avlnode                 *li_attrs;
143         int                     li_dblocking;   /* lock databases */
144         int                     li_dbwritesync; /* write sync */
145         int                     li_dbcachesize;
146         DBCache         li_dbcache[MAXDBCACHE];
147         ldap_pvt_thread_mutex_t         li_dbcache_mutex;
148         ldap_pvt_thread_cond_t          li_dbcache_cv;
149         DB_ENV                  *li_dbenv;
150         int                     li_envdirok;
151         int                     li_dbsyncfreq;
152         int                     li_dbsyncwaitn;
153         int                     li_dbsyncwaitinterval;
154         ldap_pvt_thread_t       li_dbsynctid;
155         int                     li_dbshutdown;
156 };
157
158 LDAP_END_DECL
159
160 #include "proto-back-ldbm.h"
161
162 #endif /* _back_ldbm_h_ */