Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / common / vi_db.h
blob9184fc546b62c5aa208195bc16d3cc7e5c70748f
1 /* $NetBSD: vi_db.h,v 1.3 2013/11/29 22:56:19 christos Exp $ */
3 #include <db.h>
5 #ifndef DB_BUFFER_SMALL
6 #define DB_BUFFER_SMALL ENOMEM
7 #endif
9 #ifdef USE_BUNDLED_DB
11 typedef void DB_ENV;
13 typedef recno_t db_recno_t;
14 #define DB_MAX_RECORDS MAX_REC_NUMBER
16 #define db_env_close(env,flags)
17 #define db_env_create(env,flags) \
18 (((void)env), 1)
19 #define db_env_remove(env,path,flags) \
21 #define db_open(db,file,type,flags,mode) \
22 (db)->open(db, file, NULL, type, flags, mode)
23 #define db_get_low(db,key,data,flags) \
24 (db)->get(db, key, data, flags)
25 #define db_close(db) \
26 (db)->close(db)
28 #else
30 #if USE_DB1 || (DB_VERSION_MAJOR >= 3 && DB_VERSION_MINOR >= 1)
31 #define db_env_open(env,path,flags,mode) \
32 (env)->open(env, path, flags, mode)
33 #define db_env_remove(env,path,flags) \
34 (env)->remove(env, path, flags)
35 #else
36 #define db_env_open(env,path,flags,mode) \
37 (env)->open(env, path, NULL, flags, mode)
38 #define db_env_remove(env,path,flags) \
39 (env)->remove(env, path, NULL, flags)
40 #endif
42 #define db_env_close(env,flags) \
43 (env)->close(env, flags)
45 #if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1
46 #define db_open(db,file,type,flags,mode) \
47 (db)->open(db, NULL, file, NULL, type, flags, mode)
48 #else
49 #define db_open(db,file,type,flags,mode) \
50 (db)->open(db, file, NULL, type, flags, mode)
51 #endif
52 #define db_get_low(db,key,data,flags) \
53 (db)->get(db, NULL, key, data, flags)
54 #define db_close(db) \
55 (db)->close(db, DB_NOSYNC)
57 #endif
59 #ifdef USE_DYNAMIC_LOADING
60 #define db_create nvi_db_create
61 #define db_env_create nvi_db_env_create
62 #define db_strerror nvi_db_strerror
64 extern int (*nvi_db_create) __P((DB **, DB_ENV *, u_int32_t));
65 extern int (*nvi_db_env_create) __P((DB_ENV **, u_int32_t));
66 extern char *(*nvi_db_strerror) __P((int));
67 #endif
69 #ifdef USE_DB1
71 #define DB_AFTER 1
72 #define DB_APPEND 2
73 #define DB_BEFORE 3
74 #define DB_FIRST 7
75 #define DB_LAST 15
76 #define DB_SET 25
78 #define DB_NOTFOUND (-30989)
80 /* DBT emulation */
81 typedef DBT DBT_v1;
82 #undef DBT
83 #define DBT DBT_new
85 typedef struct {
86 void *data;
87 size_t size;
89 u_int32_t ulen;
91 #define DB_DBT_USERMEM 0x040
92 u_int32_t flags;
93 } DBT;
95 /* DB_ENV emulation */
96 struct __db_env_new;
97 typedef struct __db_env_new DB_ENV;
99 struct __db_env_new {
100 int (*close)(DB_ENV *, u_int32_t);
101 int (*open)(DB_ENV *, char *, u_int32_t, int);
102 #define DB_INIT_MPOOL 0x004000
103 #define DB_PRIVATE 0x200000
104 int (*remove)(DB_ENV *, char *, u_int32_t);
106 char *base_path;
107 int mode;
110 /* DBC emulation */
112 struct __dbc_new;
113 typedef struct __dbc_new DBC;
115 typedef recno_t db_recno_t;
116 #define DB_MAX_RECORDS MAX_REC_NUMBER
118 #define DB_UNKNOWN (-1)
120 /* DB emulation */
121 typedef DB DB_old;
122 #undef DB
123 #define DB DB_new
124 typedef struct __db_new DB;
126 #undef DB_TXN
127 typedef void DB_TXN;
129 #undef DB_LSN
130 typedef struct {
131 int dummy;
132 } DB_LSN;
134 struct __db_new {
135 DB_old *actual_db;
137 int type;
139 int (*close)(DB *, u_int32_t);
140 #define DB_NOSYNC 26 /* close() */
142 int (*open)(DB *, const char *, const char *, DBTYPE, u_int32_t, int);
143 #define DB_CREATE 0x000001 /* Create file as necessary. */
144 #define DB_TRUNCATE 0x004000 /* Discard existing DB (O_TRUNC) */
146 int (*sync)(DB *, u_int32_t);
147 int (*get)(DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
148 int (*put)(DB *, DB_TXN *, DBT *, DBT *, u_int32_t);
149 int (*del)(DB *, DB_TXN *, DBT *, u_int32_t);
151 int (*cursor)(DB *, DB_TXN *, DBC **, u_int32_t);
153 int (*set_flags)(DB *, u_int32_t);
154 #define DB_RENUMBER 0x0008 /* Recno: renumber on insert/delete. */
155 #define DB_SNAPSHOT 0x0020 /* Recno: snapshot the input. */
157 int (*set_pagesize)(DB *, u_int32_t);
159 int (*set_re_delim)(DB *, int);
160 int (*set_re_source)(DB *, const char *);
162 RECNOINFO _recno_info;
163 u_int32_t _pagesize;
164 u_int32_t _flags;
167 struct __dbc_new {
168 DB *db;
169 db_recno_t pos;
170 DBT_v1 pos_key;
171 int (*c_close)(DBC *);
172 int (*c_get)(DBC *, DBT *, DBT *, u_int32_t);
173 int (*c_put)(DBC *, DBT *, DBT *, u_int32_t);
176 #endif /* USE_DB1 */