chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / nss / nss_db / dummy-db.h
1 /* Constants and structures from the various Berkeley DB releases.
2    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #include <stdint.h>
21
22 #include "nss_db.h"
23
24 /* This file contains dummy definitions for various constants and
25    structures from the Berkeley release.  We only provide those
26    definitions that are actually needed.  In case of the structures,
27    we're only interested in the function pointers, since that's the
28    interface to the database.  Unfortunately the structures have been
29    changed several times.  */
30
31 /* The value for the btree database type has not been changed (yet?).  */
32 #define DB_BTREE        (1)
33
34 /* Permission flags for all 2.x releases.  */
35 #define DB2x_RDONLY     0x010000
36
37 /* The error values for all 2.x releases.  */
38 #define DB2x_KEYEXIST   ( -3)
39 #define DB2x_NOTFOUND   ( -7)
40
41 /* For all 2.x releases up to 2.6.3 we can use the same definitions.
42    We'll refer to them as 2.4 since that's the version distributed
43    with glibc 2.1.  */
44
45 /* Access methods from version 2.4.  */
46 #define DB24_FIRST              0x000020
47 #define DB24_NEXT               0x000800
48 #define DB24_NOOVERWRITE        0x001000
49
50 /* Permission flags from version 2.4.  */
51 #define DB24_TRUNCATE   0x080000
52
53 /* The DB structure from version 2.4.  */
54 struct db24
55 {
56   void  *mutexp;
57   enum { dummy24 } type;
58   void *dbenv;
59   void *mp_dbenv;
60   void *master;
61   void *internal;
62   void *mp;
63   void *mpf;
64   struct
65   {
66     void *tqh_first;
67     void **tqh_last;
68   } curs_queue;
69   struct {
70     void *lh_first;
71   } handleq;
72   struct {
73     void *le_next;
74     void **le_prev;
75   } links;
76   uint32_t log_fileid;
77   void *txn;
78   uint32_t locker;
79   struct db24_dbt {
80     void *data;
81     uint32_t size;
82     uint32_t ulen;
83     uint32_t dlen;
84     uint32_t doff;
85     uint32_t flags;
86   } lock_dbt;
87   struct{
88     uint32_t pgno;
89     uint8_t fileid[20];
90   } lock;
91   size_t pgsize;
92   void *db_malloc;
93   /* Functions. */
94   int (*close) (void *, uint32_t);
95   int (*cursor) (void *, void *, void **);
96   int (*del) (void *, void *, DBT *, uint32_t);
97   int (*fd) (void *, int *);
98   int (*get) (void *, void *, DBT *, DBT *, uint32_t);
99   int (*put) (void *, void *, DBT *, DBT *, uint32_t);
100   int (*stat) (void *, void *, void *(*)(size_t), uint32_t);
101   int (*sync) (void *, uint32_t);
102   uint32_t flags;
103 };
104
105 /* The DBC structure for the 2.4 release.  */
106 struct dbc24
107 {
108   void *dbp;
109   void *txn;
110   struct
111   {
112     void *tqe_next;
113     void **tqe_prev;
114   } links;
115   void *internal;
116   void *c_close;
117   void *c_del;
118   int (*c_get) (void *, DBT *, DBT *, uint32_t);
119   void *c_put;
120 };
121
122 /* The 2.7 release is slighty different.  */
123
124 /* Access methods from version 2.7.  */
125 #define DB27_FIRST              7
126 #define DB27_NEXT               15
127 #define DB27_NOOVERWRITE        17
128
129 /* Permission flags from version 2.7.  */
130 #define DB27_TRUNCATE   0x020000
131
132 /* The DB structure from version 2.7.  */
133 struct db27
134 {
135   void  *mutexp;
136   enum { dummy27 } type;
137   int byteswapped;
138   int saved_open_fd;
139   void *dbenv;
140   void *mp_dbenv;
141   void *internal;
142   void *mp;
143   void *mpf;
144   struct
145   {
146     void *tqh_first;
147     void **tqh_last;
148   } free_queue;
149   struct
150   {
151     void *tqh_first;
152     void **tqh_last;
153   } active_queue;
154   uint8_t fileid[20];
155   uint32_t log_fileid;
156   size_t pgsize;
157   void *db_malloc;
158   void *dup_compare;
159   void *h_hash;
160   /* Functions. */
161   int (*am_close) (void *);
162   int (*close) (void *, uint32_t);
163   int (*cursor) (void *, void *, void **, uint32_t);
164   int (*del) (void *, void *, DBT *, uint32_t);
165   int (*fd) (void *, int *);
166   int (*get) (void *, void *, DBT *, DBT *, uint32_t);
167   int (*join) (void *, void **, uint32_t, void **);
168   int (*put) (void *, void *, DBT *, DBT *, uint32_t);
169   int (*stat) (void *, void *, void *(*)(size_t), uint32_t);
170   int (*sync) (void *, uint32_t);
171   uint32_t flags;
172 };
173
174 /* The DBC structure for version 2.7.  */
175 struct dbc27
176 {
177   void *dbp;
178   void *txn;
179   struct
180   {
181     void *tqe_next;
182     void **tqe_prev;
183   } links;
184   uint32_t lid;
185   uint32_t locker;
186   DBT lock_dbt;
187   struct{
188     uint32_t pgno;
189     uint8_t fileid[20];
190   } lock;
191   size_t mylock;
192   DBT rkey;
193   DBT rdata;
194   void *c_am_close;
195   void *c_am_destroy;
196   void *c_close;
197   void *c_del;
198   int (*c_get) (void *, DBT *, DBT *, uint32_t);
199   void *c_put;
200   void *internal;
201   uint32_t flags;
202 };
203
204 /* Version 3.0 is mostly incompatible with 2.x.  */
205
206 /* Access methods from version 3.0.  */
207 #define DB30_FIRST              9
208 #define DB30_NEXT               17
209 #define DB30_NOOVERWRITE        20
210
211 /* Error values from version 3.0.  */
212 #define DB30_KEYEXIST   (-30997)
213 #define DB30_NOTFOUND   (-30994)
214
215 /* Permission flags from version 3.0.  */
216 #define DB30_RDONLY     0x000010
217 #define DB30_TRUNCATE   0x020000
218
219 /* The DB structure from version 3.0.  */
220 struct db30
221 {
222   size_t pgsize;
223   void (*db_feedback) (void *, int, int);
224   void *(*db_malloc) (size_t);
225   void *(*db_realloc) (void *, size_t);
226   int (*dup_compare) (const DBT *, const DBT *);
227   void *dbenv;
228   enum { dummy30 } type;
229   void *mpf;
230   void  *mutexp;
231   u_int8_t fileid[20];
232   int32_t log_fileid;
233   void *open_txn;
234   void *saved_open_fhp;
235   struct
236   {
237     void *tqh_first;
238     void **tqh_last;
239   } free_queue;
240   struct
241   {
242     void *tqh_first;
243     void **tqh_last;
244   } active_queue;
245   void  *bt_internal;
246   void  *cj_internal;
247   void  *h_internal;
248   void  *q_internal;
249   void  *xa_internal;
250   /* Functions.  */
251   int  (*close) (void *, uint32_t);
252   int  (*cursor) (void *, void *, void **, uint32_t);
253   int  (*del) (void *, void *, DBT *, uint32_t);
254   void (*err) (void *, int, const char *, ...);
255   void (*errx) (void *, const char *, ...);
256   int  (*fd) (void *, int *);
257   int  (*get) (void *, void *, DBT *, DBT *, uint32_t);
258   int  (*get_byteswapped) (void *);
259   int (*get_type) (void *);
260   int  (*join) (void *, void **, void **, uint32_t);
261   int  (*open) (void *, const char *, const char *, int, uint32_t, int);
262   int  (*put) (void *, void *, DBT *, DBT *, uint32_t);
263   int  (*remove) (void *, const char *, const char *, uint32_t);
264   int  (*set_cachesize) (void *, uint32_t, uint32_t, int);
265   int  (*set_dup_compare) (void *, int (*)(const DBT *, const DBT *));
266   void (*set_errcall) (void *, void (*)(const char *, char *));
267   void (*set_errfile) (void *, void *);
268   void (*set_errpfx) (void *, const char *);
269   void (*set_feedback) (void *, void (*)(void *, int, int));
270   int  (*set_flags) (void *, uint32_t);
271   int  (*set_lorder) (void *, int);
272   int  (*set_malloc) (void *, void *(*)(size_t));
273   int  (*set_pagesize) (void *, uint32_t);
274   void (*set_paniccall) (void *, void (*)(void *, int));
275   int  (*set_realloc) (void *, void *(*)(void *, size_t));
276   int  (*stat) (void *, void *, void *(*)(size_t), uint32_t);
277   int  (*sync) (void *, uint32_t);
278   int  (*upgrade) (void *, const char *, uint32_t);
279
280   int  (*set_bt_compare) (void *, int (*)(const DBT *, const DBT *));
281   int  (*set_bt_maxkey) (void *, uint32_t);
282   int  (*set_bt_minkey) (void *, uint32_t);
283   int  (*set_bt_prefix) (void *, size_t (*)(const DBT *, const DBT *));
284
285   int  (*set_h_ffactor) (void *, uint32_t);
286   int  (*set_h_hash) (void *, uint32_t (*)(const void *, uint32_t));
287   int  (*set_h_nelem) (void *, uint32_t);
288
289   int  (*set_re_delim) (void *, int);
290   int  (*set_re_len) (void *, uint32_t);
291   int  (*set_re_pad) (void *, int);
292   int  (*set_re_source) (void *, const char *);
293
294   uint32_t am_ok;
295   uint32_t flags;
296 };
297
298 /* The DBC structure from version 3.0.  */
299 struct dbc30
300 {
301   void *dbp;
302   void *txn;
303   struct
304   {
305     void *tqe_next;
306     void **tqe_prev;
307   } links;
308   uint32_t lid;                 /* Default process' locker id. */
309   uint32_t locker;              /* Locker for this operation. */
310   DBT lock_dbt;         /* DBT referencing lock. */
311   struct
312   {
313     uint32_t pgno;
314     uint8_t fileid[20];
315   } lock;
316   struct
317   {
318     size_t off;
319     uint32_t ndx;
320     uint32_t gen;
321   } mylock;
322   DBT rkey;
323   DBT rdata;
324   int (*c_close) (void *);
325   int (*c_del) (void *, uint32_t);
326   int (*c_dup) (void *, void **, uint32_t);
327   int (*c_get) (void *, DBT *, DBT *, uint32_t);
328   int (*c_put) (void *, DBT *, DBT *, uint32_t);
329   int (*c_am_close) (void *);
330   int (*c_am_destroy) (void *);
331   void *internal;
332   uint32_t flags;
333 };