]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/back-ldbm.h
Import add/delete/modify fixes from devel.
[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
8 LDAP_BEGIN_DECL
9
10 #define DEFAULT_CACHE_SIZE      1000
11
12 /* SHOULD BE REMOVED IN NEXT RELEASE */
13 #define SLAPD_CHILD_MODIFICATION_WITH_ENTRY_ACL 1
14
15 #ifdef HAVE_BERKELEY_DB2
16 #       define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE)
17 #else
18 #       define DEFAULT_DBCACHE_SIZE 100000
19 #endif
20
21 #define DEFAULT_DB_DIRECTORY    "/usr/tmp"
22 #define DEFAULT_MODE            0600
23
24 #define SUBLEN                  3
25
26 /*
27  * there is a single index for each attribute.  these prefixes insure
28  * that there is no collision among keys.
29  */
30 #define EQ_PREFIX       '='     /* prefix for equality keys     */
31 #define APPROX_PREFIX   '~'     /* prefix for approx keys       */
32 #define SUB_PREFIX      '*'     /* prefix for substring keys    */
33 #define CONT_PREFIX     '\\'    /* prefix for continuation keys */
34
35 #define UNKNOWN_PREFIX  '?'     /* prefix for unknown keys    */
36
37 #define DEFAULT_BLOCKSIZE       8192
38
39 /*
40  * This structure represents an id block on disk and an id list
41  * in core.
42  *
43  * The fields have the following meanings:
44  *
45  *      b_nmax  maximum number of ids in this block. if this is == ALLIDSBLOCK,
46  *              then this block represents all ids.
47  *      b_nids  current number of ids in use in this block.  if this
48  *              is == INDBLOCK, then this block is an indirect block
49  *              containing a list of other blocks containing actual ids.
50  *              the list is terminated by an id of NOID.
51  *      b_ids   a list of the actual ids themselves
52  */
53 typedef struct block {
54         ID              b_nmax;         /* max number of ids in this list  */
55 #define ALLIDSBLOCK     0               /* == 0 => this is an allid block  */
56         ID              b_nids;         /* current number of ids used      */
57 #define INDBLOCK        0               /* == 0 => this is an indirect blk */
58         ID              b_ids[1];       /* the ids - actually bigger       */
59 } Block, IDList;
60
61 #define ALLIDS( idl )           ((idl)->b_nmax == ALLIDSBLOCK)
62 #define INDIRECT_BLOCK( idl )   ((idl)->b_nids == INDBLOCK)
63
64 /* for the in-core cache of entries */
65 struct cache {
66         int             c_maxsize;
67         int             c_cursize;
68         Avlnode         *c_dntree;
69         Avlnode         *c_idtree;
70         Entry           *c_lruhead;     /* lru - add accessed entries here */
71         Entry           *c_lrutail;     /* lru - rem lru entries from here */
72         pthread_mutex_t c_mutex;
73 };
74
75 /* for the cache of open index files */
76 struct dbcache {
77         char            *dbc_name;
78         int             dbc_refcnt;
79         time_t          dbc_lastref;
80         pthread_mutex_t dbc_mutex;
81         pthread_cond_t  dbc_cv;
82         int             dbc_readers;
83         long            dbc_blksize;
84         int             dbc_maxids;
85         int             dbc_maxindirect;
86         LDBM            dbc_db;
87 };
88
89 /* for the cache of attribute information (which are indexed, etc.) */
90 struct attrinfo {
91         char    *ai_type;       /* type name (cn, sn, ...)      */
92         int     ai_indexmask;   /* how the attr is indexed      */
93 #define INDEX_PRESENCE  0x01
94 #define INDEX_EQUALITY  0x02
95 #define INDEX_APPROX    0x04
96 #define INDEX_SUB       0x08
97 #define INDEX_UNKNOWN   0x10
98 #define INDEX_FROMINIT  0x20
99         int     ai_syntaxmask;  /* what kind of syntax          */
100 /* ...from slap.h...
101 #define SYNTAX_CIS      0x01
102 #define SYNTAX_CES      0x02
103 #define SYNTAX_BIN      0x04
104    ... etc. ...
105 */
106 };
107
108 #define MAXDBCACHE      10
109
110 struct ldbminfo {
111         ID                      li_nextid;
112         pthread_mutex_t         li_root_mutex;
113         pthread_mutex_t         li_add_mutex;
114         pthread_mutex_t         li_nextid_mutex;
115         int                     li_mode;
116         char                    *li_directory;
117         struct cache            li_cache;
118         Avlnode                 *li_attrs;
119         int                     li_dbcachesize;
120         int                     li_dbcachewsync;
121         struct dbcache          li_dbcache[MAXDBCACHE];
122         pthread_mutex_t         li_dbcache_mutex;
123         pthread_cond_t          li_dbcache_cv;
124 };
125
126 #include "proto-back-ldbm.h"
127
128 LDAP_END_DECL
129
130 #endif /* _back_ldbm_h_ */