]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/back-ldbm.h
Change compiled in LDBM default directory
[openldap] / servers / slapd / back-ldbm / back-ldbm.h
1 /* back-ldbm.h - ldap ldbm back-end header file */
2
3 #ifndef _BACK_LDBM_H_
4 #define _BACK_LDBM_H_
5
6 #include "ldbm.h"
7 #include "ldapconfig.h"
8
9 LDAP_BEGIN_DECL
10
11 #define DEFAULT_CACHE_SIZE      1000
12
13 #ifdef HAVE_BERKELEY_DB2
14 #       define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE)
15 #else
16 #       define DEFAULT_DBCACHE_SIZE 100000
17 #endif
18
19 #define DEFAULT_DB_DIRECTORY    DEFAULT_RUNDIR DEFAULT_DIRSEP "openldap-ldbm"
20 #define DEFAULT_MODE            0600
21
22 #define SUBLEN                  3
23
24 /*
25  * there is a single index for each attribute.  these prefixes insure
26  * that there is no collision among keys.
27  */
28 #define EQ_PREFIX       '='     /* prefix for equality keys     */
29 #define APPROX_PREFIX   '~'     /* prefix for approx keys       */
30 #define SUB_PREFIX      '*'     /* prefix for substring keys    */
31 #define CONT_PREFIX     '\\'    /* prefix for continuation keys */
32
33 #define UNKNOWN_PREFIX  '?'     /* prefix for unknown keys    */
34
35 #define DEFAULT_BLOCKSIZE       8192
36
37 /*
38  * This structure represents an id block on disk and an id list
39  * in core.
40  *
41  * The fields have the following meanings:
42  *
43  *      b_nmax  maximum number of ids in this block. if this is == ALLIDSBLOCK,
44  *              then this block represents all ids.
45  *      b_nids  current number of ids in use in this block.  if this
46  *              is == INDBLOCK, then this block is an indirect block
47  *              containing a list of other blocks containing actual ids.
48  *              the list is terminated by an id of NOID.
49  *      b_ids   a list of the actual ids themselves
50  */
51
52 typedef ID ID_BLOCK;
53
54 #define ID_BLOCK_NMAX_OFFSET    0
55 #define ID_BLOCK_NIDS_OFFSET    1
56 #define ID_BLOCK_IDS_OFFSET             2
57
58 /* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */
59
60 #define ID_BLOCK_NMAX(b)                ((b)[ID_BLOCK_NMAX_OFFSET])
61 #define ID_BLOCK_NIDS(b)                ((b)[ID_BLOCK_NIDS_OFFSET])
62 #define ID_BLOCK_ID(b, n)               ((b)[ID_BLOCK_IDS_OFFSET+(n)])
63
64 #define ID_BLOCK_NOID(b, n)             (ID_BLOCK_ID((b),(n)) == NOID)
65
66 #define ID_BLOCK_ALLIDS_VALUE   0
67 #define ID_BLOCK_ALLIDS(b)              (ID_BLOCK_NMAX(b) == ID_BLOCK_ALLIDS_VALUE)
68
69 #define ID_BLOCK_INDIRECT_VALUE 0
70 #define ID_BLOCK_INDIRECT(b)    (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
71
72 /* for the in-core cache of entries */
73 struct cache {
74         int             c_maxsize;
75         int             c_cursize;
76         Avlnode         *c_dntree;
77         Avlnode         *c_idtree;
78         Entry           *c_lruhead;     /* lru - add accessed entries here */
79         Entry           *c_lrutail;     /* lru - rem lru entries from here */
80         ldap_pvt_thread_mutex_t c_mutex;
81 };
82
83 /* for the cache of open index files */
84 struct dbcache {
85         int             dbc_refcnt;
86         int             dbc_maxids;
87         int             dbc_maxindirect;
88         time_t  dbc_lastref;
89         long    dbc_blksize;
90         char    *dbc_name;
91         LDBM    dbc_db;
92 };
93
94 /* for the cache of attribute information (which are indexed, etc.) */
95 struct attrinfo {
96         char    *ai_type;       /* type name (cn, sn, ...)      */
97         int     ai_indexmask;   /* how the attr is indexed      */
98 #define INDEX_PRESENCE  0x01
99 #define INDEX_EQUALITY  0x02
100 #define INDEX_APPROX    0x04
101 #define INDEX_SUB       0x08
102 #define INDEX_UNKNOWN   0x10
103 #define INDEX_FROMINIT  0x20
104         int     ai_syntaxmask;  /* what kind of syntax          */
105 /* ...from slap.h...
106 #define SYNTAX_CIS      0x01
107 #define SYNTAX_CES      0x02
108 #define SYNTAX_BIN      0x04
109    ... etc. ...
110 */
111 };
112
113 #define MAXDBCACHE      10
114
115 /* this could be made an option */
116 #ifndef SLAPD_NEXTID_CHUNK
117 #define SLAPD_NEXTID_CHUNK      32
118 #endif
119
120 struct ldbminfo {
121         ID                      li_nextid;
122 #if SLAPD_NEXTID_CHUNK > 1
123         ID                      li_nextid_wrote;
124 #endif
125         char            *li_nextid_file;
126         ldap_pvt_thread_mutex_t         li_root_mutex;
127         ldap_pvt_thread_mutex_t         li_add_mutex;
128         ldap_pvt_thread_mutex_t         li_nextid_mutex;
129         int                     li_mode;
130         char                    *li_directory;
131         struct cache            li_cache;
132         Avlnode                 *li_attrs;
133         int                     li_dbcachesize;
134         int                     li_dbcachewsync;
135         struct dbcache          li_dbcache[MAXDBCACHE];
136         ldap_pvt_thread_mutex_t         li_dbcache_mutex;
137         ldap_pvt_thread_cond_t          li_dbcache_cv;
138 };
139
140 #include "proto-back-ldbm.h"
141
142 LDAP_END_DECL
143
144 #endif /* _back_ldbm_h_ */