Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / common / db.h
blob14c751c196bc7e31d46a82904657c47be8997120
1 /* $NetBSD: db.h,v 1.2 2008/05/20 17:53:18 aymeric Exp $ */
3 #include <db.h>
5 #ifndef DB_BUFFER_SMALL
6 #define DB_BUFFER_SMALL ENOMEM
7 #endif
9 #if USE_DB1 || (DB_VERSION_MAJOR >= 3 && DB_VERSION_MINOR >= 1)
10 #define db_env_open(env,path,flags,mode) \
11 (env)->open(env, path, flags, mode)
12 #define db_env_remove(env,path,flags) \
13 (env)->remove(env, path, flags)
14 #else
15 #define db_env_open(env,path,flags,mode) \
16 (env)->open(env, path, NULL, flags, mode)
17 #define db_env_remove(env,path,flags) \
18 (env)->remove(env, path, NULL, flags)
19 #endif
21 #if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1
22 #define db_open(db,file,type,flags,mode) \
23 (db)->open(db, NULL, file, NULL, type, flags, mode)
24 #else
25 #define db_open(db,file,type,flags,mode) \
26 (db)->open(db, file, NULL, type, flags, mode)
27 #endif
29 #ifdef USE_DYNAMIC_LOADING
30 #define db_create nvi_db_create
31 #define db_env_create nvi_db_env_create
32 #define db_strerror nvi_db_strerror
34 extern int (*nvi_db_create) __P((DB **, DB_ENV *, u_int32_t));
35 extern int (*nvi_db_env_create) __P((DB_ENV **, u_int32_t));
36 extern char *(*nvi_db_strerror) __P((int));
37 #endif
39 #ifdef USE_DB1
41 #define DB_AFTER 1
42 #define DB_APPEND 2
43 #define DB_BEFORE 3
44 #define DB_FIRST 7
45 #define DB_LAST 15
46 #define DB_SET 25
48 #define DB_NOTFOUND (-30989)
50 /* DBT emulation */
51 typedef DBT DBT_v1;
52 #undef DBT
53 #define DBT DBT_new
55 typedef struct {
56 void *data;
57 size_t size;
59 u_int32_t ulen;
61 #define DB_DBT_USERMEM 0x040
62 u_int32_t flags;
63 } DBT;
65 /* DB_ENV emulation */
66 struct __db_env_new;
67 typedef struct __db_env_new DB_ENV;
69 struct __db_env_new {
70 int (*close)(DB_ENV *, u_int32_t);
71 int (*open)(DB_ENV *, char *, u_int32_t, int);
72 #define DB_INIT_MPOOL 0x004000
73 #define DB_PRIVATE 0x200000
74 int (*remove)(DB_ENV *, char *, u_int32_t);
76 char *base_path;
77 int mode;
80 /* DBC emulation */
82 struct __dbc_new;
83 typedef struct __dbc_new DBC;
85 typedef recno_t db_recno_t;
86 #define DB_MAX_RECORDS MAX_REC_NUMBER
88 #define DB_UNKNOWN (-1)
90 /* DB emulation */
91 typedef DB DB_old;
92 #undef DB
93 #define DB DB_new
94 typedef struct __db_new DB;
96 #undef DB_TXN
97 typedef void DB_TXN;
99 #undef DB_LSN
100 typedef struct {
101 int dummy;
102 } DB_LSN;
104 struct __db_new {
105 DB_old *actual_db;
107 int type;
109 int (*close)(DB *, u_int32_t);
110 #define DB_NOSYNC 26 /* close() */
112 int (*open)(DB *, const char *, const char *, DBTYPE, u_int32_t, int);
113 #define DB_CREATE 0x000001 /* Create file as necessary. */
114 #define DB_TRUNCATE 0x004000 /* Discard existing DB (O_TRUNC) */
116 int (*sync)(DB *, u_int32_t);
117 int (*get)(DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
118 int (*put)(DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
119 int (*del)(DB *, DB_TXN *, DBT *, u_int32_t);
121 int (*cursor)(DB *, DB_TXN *, DBC **, u_int32_t);
123 int (*set_flags)(DB *, u_int32_t);
124 #define DB_RENUMBER 0x0008 /* Recno: renumber on insert/delete. */
125 #define DB_SNAPSHOT 0x0020 /* Recno: snapshot the input. */
127 int (*set_pagesize)(DB *, u_int32_t);
129 int (*set_re_delim)(DB *, int);
130 int (*set_re_source)(DB *, const char *);
132 RECNOINFO _recno_info;
133 u_int32_t _pagesize;
134 u_int32_t _flags;
137 struct __dbc_new {
138 DB *db;
139 db_recno_t pos;
140 DBT_v1 pos_key;
141 int (*c_close)(DBC *);
142 int (*c_get)(DBC *, DBT *, DBT *, u_int32_t);
143 int (*c_put)(DBC *, DBT *, DBT *, u_int32_t);
146 #endif /* USE_DB1 */