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