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