Back to index

glibc  2.9
dummy-db.h
Go to the documentation of this file.
00001 /* Constants and structures from the various Berkeley DB releases.
00002    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <stdint.h>
00021 
00022 #include "nss_db.h"
00023 
00024 /* This file contains dummy definitions for various constants and
00025    structures from the Berkeley release.  We only provide those
00026    definitions that are actually needed.  In case of the structures,
00027    we're only interested in the function pointers, since that's the
00028    interface to the database.  Unfortunately the structures have been
00029    changed several times.  */
00030 
00031 /* The value for the btree database type has not been changed (yet?).  */
00032 #define DB_BTREE     (1)
00033 
00034 /* Permission flags for all 2.x releases.  */
00035 #define DB2x_RDONLY  0x010000
00036 
00037 /* The error values for all 2.x releases.  */
00038 #define DB2x_KEYEXIST       ( -3)
00039 #define DB2x_NOTFOUND       ( -7)
00040 
00041 /* For all 2.x releases up to 2.6.3 we can use the same definitions.
00042    We'll refer to them as 2.4 since that's the version distributed
00043    with glibc 2.1.  */
00044 
00045 /* Access methods from version 2.4.  */
00046 #define DB24_FIRST          0x000020
00047 #define DB24_NEXT           0x000800
00048 #define DB24_NOOVERWRITE    0x001000
00049 
00050 /* Permission flags from version 2.4.  */
00051 #define DB24_TRUNCATE       0x080000
00052 
00053 /* The DB structure from version 2.4.  */
00054 struct db24
00055 {
00056   void *mutexp;
00057   enum { dummy24 } type;
00058   void *dbenv;
00059   void *mp_dbenv;
00060   void *master;
00061   void *internal;
00062   void *mp;
00063   void *mpf;
00064   struct
00065   {
00066     void *tqh_first;
00067     void **tqh_last;
00068   } curs_queue;
00069   struct {
00070     void *lh_first;
00071   } handleq;
00072   struct {
00073     void *le_next;
00074     void **le_prev;
00075   } links;
00076   uint32_t log_fileid;
00077   void *txn;
00078   uint32_t locker;
00079   struct db24_dbt {
00080     void *data;
00081     uint32_t size;
00082     uint32_t ulen;
00083     uint32_t dlen;
00084     uint32_t doff;
00085     uint32_t flags;
00086   } lock_dbt;
00087   struct{
00088     uint32_t pgno;
00089     uint8_t fileid[20];
00090   } lock;
00091   size_t pgsize;
00092   void *db_malloc;
00093   /* Functions. */
00094   int (*close) (void *, uint32_t);
00095   int (*cursor) (void *, void *, void **);
00096   int (*del) (void *, void *, DBT *, uint32_t);
00097   int (*fd) (void *, int *);
00098   int (*get) (void *, void *, DBT *, DBT *, uint32_t);
00099   int (*put) (void *, void *, DBT *, DBT *, uint32_t);
00100   int (*stat) (void *, void *, void *(*)(size_t), uint32_t);
00101   int (*sync) (void *, uint32_t);
00102   uint32_t flags;
00103 };
00104 
00105 /* The DBC structure for the 2.4 release.  */
00106 struct dbc24
00107 {
00108   void *dbp;
00109   void *txn;
00110   struct
00111   {
00112     void *tqe_next;
00113     void **tqe_prev;
00114   } links;
00115   void *internal;
00116   void *c_close;
00117   void *c_del;
00118   int (*c_get) (void *, DBT *, DBT *, uint32_t);
00119   void *c_put;
00120 };
00121 
00122 /* The 2.7 release is slighty different.  */
00123 
00124 /* Access methods from version 2.7.  */
00125 #define DB27_FIRST          7
00126 #define DB27_NEXT           15
00127 #define DB27_NOOVERWRITE    17
00128 
00129 /* Permission flags from version 2.7.  */
00130 #define DB27_TRUNCATE       0x020000
00131 
00132 /* The DB structure from version 2.7.  */
00133 struct db27
00134 {
00135   void *mutexp;
00136   enum { dummy27 } type;
00137   int byteswapped;
00138   int saved_open_fd;
00139   void *dbenv;
00140   void *mp_dbenv;
00141   void *internal;
00142   void *mp;
00143   void *mpf;
00144   struct
00145   {
00146     void *tqh_first;
00147     void **tqh_last;
00148   } free_queue;
00149   struct
00150   {
00151     void *tqh_first;
00152     void **tqh_last;
00153   } active_queue;
00154   uint8_t fileid[20];
00155   uint32_t log_fileid;
00156   size_t pgsize;
00157   void *db_malloc;
00158   void *dup_compare;
00159   void *h_hash;
00160   /* Functions. */
00161   int (*am_close) (void *);
00162   int (*close) (void *, uint32_t);
00163   int (*cursor) (void *, void *, void **, uint32_t);
00164   int (*del) (void *, void *, DBT *, uint32_t);
00165   int (*fd) (void *, int *);
00166   int (*get) (void *, void *, DBT *, DBT *, uint32_t);
00167   int (*join) (void *, void **, uint32_t, void **);
00168   int (*put) (void *, void *, DBT *, DBT *, uint32_t);
00169   int (*stat) (void *, void *, void *(*)(size_t), uint32_t);
00170   int (*sync) (void *, uint32_t);
00171   uint32_t flags;
00172 };
00173 
00174 /* The DBC structure for version 2.7.  */
00175 struct dbc27
00176 {
00177   void *dbp;
00178   void *txn;
00179   struct
00180   {
00181     void *tqe_next;
00182     void **tqe_prev;
00183   } links;
00184   uint32_t lid;
00185   uint32_t locker;
00186   DBT lock_dbt;
00187   struct{
00188     uint32_t pgno;
00189     uint8_t fileid[20];
00190   } lock;
00191   size_t mylock;
00192   DBT rkey;
00193   DBT rdata;
00194   void *c_am_close;
00195   void *c_am_destroy;
00196   void *c_close;
00197   void *c_del;
00198   int (*c_get) (void *, DBT *, DBT *, uint32_t);
00199   void *c_put;
00200   void *internal;
00201   uint32_t flags;
00202 };
00203 
00204 /* Version 3.0 is mostly incompatible with 2.x.  */
00205 
00206 /* Access methods from version 3.0.  */
00207 #define DB30_FIRST          9
00208 #define DB30_NEXT           17
00209 #define DB30_NOOVERWRITE    20
00210 
00211 /* Error values from version 3.0.  */
00212 #define DB30_KEYEXIST       (-30997)
00213 #define DB30_NOTFOUND       (-30994)
00214 
00215 /* Permission flags from version 3.0.  */
00216 #define DB30_RDONLY  0x000010
00217 #define DB30_TRUNCATE       0x020000
00218 
00219 /* The DB structure from version 3.0.  */
00220 struct db30
00221 {
00222   size_t pgsize;
00223   void (*db_feedback) (void *, int, int);
00224   void *(*db_malloc) (size_t);
00225   void *(*db_realloc) (void *, size_t);
00226   int (*dup_compare) (const DBT *, const DBT *);
00227   void *dbenv;
00228   enum { dummy30 } type;
00229   void *mpf;
00230   void *mutexp;
00231   u_int8_t fileid[20];
00232   int32_t log_fileid;
00233   void *open_txn;
00234   void *saved_open_fhp;
00235   struct
00236   {
00237     void *tqh_first;
00238     void **tqh_last;
00239   } free_queue;
00240   struct
00241   {
00242     void *tqh_first;
00243     void **tqh_last;
00244   } active_queue;
00245   void *bt_internal;
00246   void *cj_internal;
00247   void *h_internal;
00248   void *q_internal;
00249   void *xa_internal;
00250   /* Functions.  */
00251   int  (*close) (void *, uint32_t);
00252   int  (*cursor) (void *, void *, void **, uint32_t);
00253   int  (*del) (void *, void *, DBT *, uint32_t);
00254   void (*err) (void *, int, const char *, ...);
00255   void (*errx) (void *, const char *, ...);
00256   int  (*fd) (void *, int *);
00257   int  (*get) (void *, void *, DBT *, DBT *, uint32_t);
00258   int  (*get_byteswapped) (void *);
00259   int (*get_type) (void *);
00260   int  (*join) (void *, void **, void **, uint32_t);
00261   int  (*open) (void *,     const char *, const char *, int, uint32_t, int);
00262   int  (*put) (void *, void *, DBT *, DBT *, uint32_t);
00263   int  (*remove) (void *, const char *, const char *, uint32_t);
00264   int  (*set_cachesize) (void *, uint32_t, uint32_t, int);
00265   int  (*set_dup_compare) (void *, int (*)(const DBT *, const DBT *));
00266   void (*set_errcall) (void *, void (*)(const char *, char *));
00267   void (*set_errfile) (void *, void *);
00268   void (*set_errpfx) (void *, const char *);
00269   void (*set_feedback) (void *, void (*)(void *, int, int));
00270   int  (*set_flags) (void *, uint32_t);
00271   int  (*set_lorder) (void *, int);
00272   int  (*set_malloc) (void *, void *(*)(size_t));
00273   int  (*set_pagesize) (void *, uint32_t);
00274   void (*set_paniccall) (void *, void (*)(void *, int));
00275   int  (*set_realloc) (void *, void *(*)(void *, size_t));
00276   int  (*stat) (void *, void *, void *(*)(size_t), uint32_t);
00277   int  (*sync) (void *, uint32_t);
00278   int  (*upgrade) (void *, const char *, uint32_t);
00279 
00280   int  (*set_bt_compare) (void *, int (*)(const DBT *, const DBT *));
00281   int  (*set_bt_maxkey) (void *, uint32_t);
00282   int  (*set_bt_minkey) (void *, uint32_t);
00283   int  (*set_bt_prefix) (void *, size_t (*)(const DBT *, const DBT *));
00284 
00285   int  (*set_h_ffactor) (void *, uint32_t);
00286   int  (*set_h_hash) (void *, uint32_t (*)(const void *, uint32_t));
00287   int  (*set_h_nelem) (void *, uint32_t);
00288 
00289   int  (*set_re_delim) (void *, int);
00290   int  (*set_re_len) (void *, uint32_t);
00291   int  (*set_re_pad) (void *, int);
00292   int  (*set_re_source) (void *, const char *);
00293 
00294   uint32_t am_ok;
00295   uint32_t flags;
00296 };
00297 
00298 /* The DBC structure from version 3.0.  */
00299 struct dbc30
00300 {
00301   void *dbp;
00302   void *txn;
00303   struct
00304   {
00305     void *tqe_next;
00306     void **tqe_prev;
00307   } links;
00308   uint32_t lid;                    /* Default process' locker id. */
00309   uint32_t locker;          /* Locker for this operation. */
00310   DBT lock_dbt;             /* DBT referencing lock. */
00311   struct
00312   {
00313     uint32_t pgno;
00314     uint8_t fileid[20];
00315   } lock;
00316   struct
00317   {
00318     size_t off;
00319     uint32_t ndx;
00320     uint32_t gen;
00321   } mylock;
00322   DBT rkey;
00323   DBT rdata;
00324   int (*c_close) (void *);
00325   int (*c_del) (void *, uint32_t);
00326   int (*c_dup) (void *, void **, uint32_t);
00327   int (*c_get) (void *, DBT *, DBT *, uint32_t);
00328   int (*c_put) (void *, DBT *, DBT *, uint32_t);
00329   int (*c_am_close) (void *);
00330   int (*c_am_destroy) (void *);
00331   void *internal;
00332   uint32_t flags;
00333 };