1 /* automatically generated by rust-bindgen */
2 
3 pub const MDB_VERSION_MAJOR: ::libc::c_uint = 0;
4 pub const MDB_VERSION_MINOR: ::libc::c_uint = 9;
5 pub const MDB_VERSION_PATCH: ::libc::c_uint = 24;
6 pub const MDB_VERSION_DATE: &'static [u8; 14usize] = b"July 24, 2019\0";
7 pub const MDB_FIXEDMAP: ::libc::c_uint = 1;
8 pub const MDB_NOSUBDIR: ::libc::c_uint = 16384;
9 pub const MDB_NOSYNC: ::libc::c_uint = 65536;
10 pub const MDB_RDONLY: ::libc::c_uint = 131072;
11 pub const MDB_NOMETASYNC: ::libc::c_uint = 262144;
12 pub const MDB_WRITEMAP: ::libc::c_uint = 524288;
13 pub const MDB_MAPASYNC: ::libc::c_uint = 1048576;
14 pub const MDB_NOTLS: ::libc::c_uint = 2097152;
15 pub const MDB_NOLOCK: ::libc::c_uint = 4194304;
16 pub const MDB_NORDAHEAD: ::libc::c_uint = 8388608;
17 pub const MDB_NOMEMINIT: ::libc::c_uint = 16777216;
18 pub const MDB_REVERSEKEY: ::libc::c_uint = 2;
19 pub const MDB_DUPSORT: ::libc::c_uint = 4;
20 pub const MDB_INTEGERKEY: ::libc::c_uint = 8;
21 pub const MDB_DUPFIXED: ::libc::c_uint = 16;
22 pub const MDB_INTEGERDUP: ::libc::c_uint = 32;
23 pub const MDB_REVERSEDUP: ::libc::c_uint = 64;
24 pub const MDB_CREATE: ::libc::c_uint = 262144;
25 pub const MDB_NOOVERWRITE: ::libc::c_uint = 16;
26 pub const MDB_NODUPDATA: ::libc::c_uint = 32;
27 pub const MDB_CURRENT: ::libc::c_uint = 64;
28 pub const MDB_RESERVE: ::libc::c_uint = 65536;
29 pub const MDB_APPEND: ::libc::c_uint = 131072;
30 pub const MDB_APPENDDUP: ::libc::c_uint = 262144;
31 pub const MDB_MULTIPLE: ::libc::c_uint = 524288;
32 pub const MDB_CP_COMPACT: ::libc::c_uint = 1;
33 pub const MDB_SUCCESS: ::libc::c_int = 0;
34 pub const MDB_KEYEXIST: ::libc::c_int = -30799;
35 pub const MDB_NOTFOUND: ::libc::c_int = -30798;
36 pub const MDB_PAGE_NOTFOUND: ::libc::c_int = -30797;
37 pub const MDB_CORRUPTED: ::libc::c_int = -30796;
38 pub const MDB_PANIC: ::libc::c_int = -30795;
39 pub const MDB_VERSION_MISMATCH: ::libc::c_int = -30794;
40 pub const MDB_INVALID: ::libc::c_int = -30793;
41 pub const MDB_MAP_FULL: ::libc::c_int = -30792;
42 pub const MDB_DBS_FULL: ::libc::c_int = -30791;
43 pub const MDB_READERS_FULL: ::libc::c_int = -30790;
44 pub const MDB_TLS_FULL: ::libc::c_int = -30789;
45 pub const MDB_TXN_FULL: ::libc::c_int = -30788;
46 pub const MDB_CURSOR_FULL: ::libc::c_int = -30787;
47 pub const MDB_PAGE_FULL: ::libc::c_int = -30786;
48 pub const MDB_MAP_RESIZED: ::libc::c_int = -30785;
49 pub const MDB_INCOMPATIBLE: ::libc::c_int = -30784;
50 pub const MDB_BAD_RSLOT: ::libc::c_int = -30783;
51 pub const MDB_BAD_TXN: ::libc::c_int = -30782;
52 pub const MDB_BAD_VALSIZE: ::libc::c_int = -30781;
53 pub const MDB_BAD_DBI: ::libc::c_int = -30780;
54 pub const MDB_LAST_ERRCODE: ::libc::c_int = -30780;
55 #[repr(C)]
56 #[derive(Debug, Copy, Clone)]
57 pub struct MDB_env {
58     _unused: [u8; 0],
59 }
60 #[repr(C)]
61 #[derive(Debug, Copy, Clone)]
62 pub struct MDB_txn {
63     _unused: [u8; 0],
64 }
65 #[doc = " @brief A handle for an individual database in the DB environment."]
66 pub type MDB_dbi = ::libc::c_uint;
67 #[repr(C)]
68 #[derive(Debug, Copy, Clone)]
69 pub struct MDB_cursor {
70     _unused: [u8; 0],
71 }
72 #[doc = " @brief Generic structure used for passing keys and data in and out"]
73 #[doc = " of the database."]
74 #[doc = ""]
75 #[doc = " Values returned from the database are valid only until a subsequent"]
76 #[doc = " update operation, or the end of the transaction. Do not modify or"]
77 #[doc = " free them, they commonly point into the database itself."]
78 #[doc = ""]
79 #[doc = " Key sizes must be between 1 and #mdb_env_get_maxkeysize() inclusive."]
80 #[doc = " The same applies to data sizes in databases with the #MDB_DUPSORT flag."]
81 #[doc = " Other data items can in theory be from 0 to 0xffffffff bytes long."]
82 #[repr(C)]
83 #[derive(Debug, Copy, Clone)]
84 pub struct MDB_val {
85     #[doc = "< size of the data item"]
86     pub mv_size: usize,
87     #[doc = "< address of the data item"]
88     pub mv_data: *mut ::libc::c_void,
89 }
90 #[doc = " @brief A callback function used to compare two keys in a database"]
91 pub type MDB_cmp_func = ::std::option::Option<
92     unsafe extern "C" fn(a: *const MDB_val, b: *const MDB_val) -> ::libc::c_int,
93 >;
94 #[doc = " @brief A callback function used to relocate a position-dependent data item"]
95 #[doc = " in a fixed-address database."]
96 #[doc = ""]
97 #[doc = " The \\b newptr gives the item's desired address in"]
98 #[doc = " the memory map, and \\b oldptr gives its previous address. The item's actual"]
99 #[doc = " data resides at the address in \\b item.  This callback is expected to walk"]
100 #[doc = " through the fields of the record in \\b item and modify any"]
101 #[doc = " values based at the \\b oldptr address to be relative to the \\b newptr address."]
102 #[doc = " @param[in,out] item The item that is to be relocated."]
103 #[doc = " @param[in] oldptr The previous address."]
104 #[doc = " @param[in] newptr The new address to relocate to."]
105 #[doc = " @param[in] relctx An application-provided context, set by #mdb_set_relctx()."]
106 #[doc = " @todo This feature is currently unimplemented."]
107 pub type MDB_rel_func = ::std::option::Option<
108     unsafe extern "C" fn(
109         item: *mut MDB_val,
110         oldptr: *mut ::libc::c_void,
111         newptr: *mut ::libc::c_void,
112         relctx: *mut ::libc::c_void,
113     ),
114 >;
115 #[doc = "< Position at first key/data item"]
116 pub const MDB_FIRST: MDB_cursor_op = 0;
117 #[doc = "< Position at first data item of current key."]
118 #[doc = "Only for #MDB_DUPSORT"]
119 pub const MDB_FIRST_DUP: MDB_cursor_op = 1;
120 #[doc = "< Position at key/data pair. Only for #MDB_DUPSORT"]
121 pub const MDB_GET_BOTH: MDB_cursor_op = 2;
122 #[doc = "< position at key, nearest data. Only for #MDB_DUPSORT"]
123 pub const MDB_GET_BOTH_RANGE: MDB_cursor_op = 3;
124 #[doc = "< Return key/data at current cursor position"]
125 pub const MDB_GET_CURRENT: MDB_cursor_op = 4;
126 #[doc = "< Return up to a page of duplicate data items"]
127 #[doc = "from current cursor position. Move cursor to prepare"]
128 #[doc = "for #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED"]
129 pub const MDB_GET_MULTIPLE: MDB_cursor_op = 5;
130 #[doc = "< Position at last key/data item"]
131 pub const MDB_LAST: MDB_cursor_op = 6;
132 #[doc = "< Position at last data item of current key."]
133 #[doc = "Only for #MDB_DUPSORT"]
134 pub const MDB_LAST_DUP: MDB_cursor_op = 7;
135 #[doc = "< Position at next data item"]
136 pub const MDB_NEXT: MDB_cursor_op = 8;
137 #[doc = "< Position at next data item of current key."]
138 #[doc = "Only for #MDB_DUPSORT"]
139 pub const MDB_NEXT_DUP: MDB_cursor_op = 9;
140 #[doc = "< Return up to a page of duplicate data items"]
141 #[doc = "from next cursor position. Move cursor to prepare"]
142 #[doc = "for #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED"]
143 pub const MDB_NEXT_MULTIPLE: MDB_cursor_op = 10;
144 #[doc = "< Position at first data item of next key"]
145 pub const MDB_NEXT_NODUP: MDB_cursor_op = 11;
146 #[doc = "< Position at previous data item"]
147 pub const MDB_PREV: MDB_cursor_op = 12;
148 #[doc = "< Position at previous data item of current key."]
149 #[doc = "Only for #MDB_DUPSORT"]
150 pub const MDB_PREV_DUP: MDB_cursor_op = 13;
151 #[doc = "< Position at last data item of previous key"]
152 pub const MDB_PREV_NODUP: MDB_cursor_op = 14;
153 #[doc = "< Position at specified key"]
154 pub const MDB_SET: MDB_cursor_op = 15;
155 #[doc = "< Position at specified key, return key + data"]
156 pub const MDB_SET_KEY: MDB_cursor_op = 16;
157 #[doc = "< Position at first key greater than or equal to specified key."]
158 pub const MDB_SET_RANGE: MDB_cursor_op = 17;
159 #[doc = "< Position at previous page and return up to"]
160 #[doc = "a page of duplicate data items. Only for #MDB_DUPFIXED"]
161 pub const MDB_PREV_MULTIPLE: MDB_cursor_op = 18;
162 #[doc = " @brief Cursor Get operations."]
163 #[doc = ""]
164 #[doc = "\tThis is the set of all operations for retrieving data"]
165 #[doc = "\tusing a cursor."]
166 pub type MDB_cursor_op = u32;
167 #[doc = " @brief Statistics for a database in the environment"]
168 #[repr(C)]
169 #[derive(Debug, Copy, Clone)]
170 pub struct MDB_stat {
171     #[doc = "< Size of a database page."]
172     #[doc = "This is currently the same for all databases."]
173     pub ms_psize: ::libc::c_uint,
174     #[doc = "< Depth (height) of the B-tree"]
175     pub ms_depth: ::libc::c_uint,
176     #[doc = "< Number of internal (non-leaf) pages"]
177     pub ms_branch_pages: usize,
178     #[doc = "< Number of leaf pages"]
179     pub ms_leaf_pages: usize,
180     #[doc = "< Number of overflow pages"]
181     pub ms_overflow_pages: usize,
182     #[doc = "< Number of data items"]
183     pub ms_entries: usize,
184 }
185 #[doc = " @brief Information about the environment"]
186 #[repr(C)]
187 #[derive(Debug, Copy, Clone)]
188 pub struct MDB_envinfo {
189     #[doc = "< Address of map, if fixed"]
190     pub me_mapaddr: *mut ::libc::c_void,
191     #[doc = "< Size of the data memory map"]
192     pub me_mapsize: usize,
193     #[doc = "< ID of the last used page"]
194     pub me_last_pgno: usize,
195     #[doc = "< ID of the last committed transaction"]
196     pub me_last_txnid: usize,
197     #[doc = "< max reader slots in the environment"]
198     pub me_maxreaders: ::libc::c_uint,
199     #[doc = "< max reader slots used in the environment"]
200     pub me_numreaders: ::libc::c_uint,
201 }
202 extern "C" {
203     #[doc = " @brief Return the LMDB library version information."]
204     #[doc = ""]
205     #[doc = " @param[out] major if non-NULL, the library major version number is copied here"]
206     #[doc = " @param[out] minor if non-NULL, the library minor version number is copied here"]
207     #[doc = " @param[out] patch if non-NULL, the library patch version number is copied here"]
208     #[doc = " @retval \"version string\" The library version as a string"]
mdb_version( major: *mut ::libc::c_int, minor: *mut ::libc::c_int, patch: *mut ::libc::c_int, ) -> *mut ::libc::c_char209     pub fn mdb_version(
210         major: *mut ::libc::c_int,
211         minor: *mut ::libc::c_int,
212         patch: *mut ::libc::c_int,
213     ) -> *mut ::libc::c_char;
214 }
215 extern "C" {
216     #[doc = " @brief Return a string describing a given error code."]
217     #[doc = ""]
218     #[doc = " This function is a superset of the ANSI C X3.159-1989 (ANSI C) strerror(3)"]
219     #[doc = " function. If the error code is greater than or equal to 0, then the string"]
220     #[doc = " returned by the system function strerror(3) is returned. If the error code"]
221     #[doc = " is less than 0, an error string corresponding to the LMDB library error is"]
222     #[doc = " returned. See @ref errors for a list of LMDB-specific error codes."]
223     #[doc = " @param[in] err The error code"]
224     #[doc = " @retval \"error message\" The description of the error"]
mdb_strerror(err: ::libc::c_int) -> *mut ::libc::c_char225     pub fn mdb_strerror(err: ::libc::c_int) -> *mut ::libc::c_char;
226 }
227 extern "C" {
228     #[doc = " @brief Create an LMDB environment handle."]
229     #[doc = ""]
230     #[doc = " This function allocates memory for a #MDB_env structure. To release"]
231     #[doc = " the allocated memory and discard the handle, call #mdb_env_close()."]
232     #[doc = " Before the handle may be used, it must be opened using #mdb_env_open()."]
233     #[doc = " Various other options may also need to be set before opening the handle,"]
234     #[doc = " e.g. #mdb_env_set_mapsize(), #mdb_env_set_maxreaders(), #mdb_env_set_maxdbs(),"]
235     #[doc = " depending on usage requirements."]
236     #[doc = " @param[out] env The address where the new handle will be stored"]
237     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_env_create(env: *mut *mut MDB_env) -> ::libc::c_int238     pub fn mdb_env_create(env: *mut *mut MDB_env) -> ::libc::c_int;
239 }
240 extern "C" {
241     #[doc = " @brief Open an environment handle."]
242     #[doc = ""]
243     #[doc = " If this function fails, #mdb_env_close() must be called to discard the #MDB_env handle."]
244     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
245     #[doc = " @param[in] path The directory in which the database files reside. This"]
246     #[doc = " directory must already exist and be writable."]
247     #[doc = " @param[in] flags Special options for this environment. This parameter"]
248     #[doc = " must be set to 0 or by bitwise OR'ing together one or more of the"]
249     #[doc = " values described here."]
250     #[doc = " Flags set by mdb_env_set_flags() are also used."]
251     #[doc = " <ul>"]
252     #[doc = "\t<li>#MDB_FIXEDMAP"]
253     #[doc = "      use a fixed address for the mmap region. This flag must be specified"]
254     #[doc = "      when creating the environment, and is stored persistently in the environment."]
255     #[doc = "\t\tIf successful, the memory map will always reside at the same virtual address"]
256     #[doc = "\t\tand pointers used to reference data items in the database will be constant"]
257     #[doc = "\t\tacross multiple invocations. This option may not always work, depending on"]
258     #[doc = "\t\thow the operating system has allocated memory to shared libraries and other uses."]
259     #[doc = "\t\tThe feature is highly experimental."]
260     #[doc = "\t<li>#MDB_NOSUBDIR"]
261     #[doc = "\t\tBy default, LMDB creates its environment in a directory whose"]
262     #[doc = "\t\tpathname is given in \\b path, and creates its data and lock files"]
263     #[doc = "\t\tunder that directory. With this option, \\b path is used as-is for"]
264     #[doc = "\t\tthe database main data file. The database lock file is the \\b path"]
265     #[doc = "\t\twith \"-lock\" appended."]
266     #[doc = "\t<li>#MDB_RDONLY"]
267     #[doc = "\t\tOpen the environment in read-only mode. No write operations will be"]
268     #[doc = "\t\tallowed. LMDB will still modify the lock file - except on read-only"]
269     #[doc = "\t\tfilesystems, where LMDB does not use locks."]
270     #[doc = "\t<li>#MDB_WRITEMAP"]
271     #[doc = "\t\tUse a writeable memory map unless MDB_RDONLY is set. This uses"]
272     #[doc = "\t\tfewer mallocs but loses protection from application bugs"]
273     #[doc = "\t\tlike wild pointer writes and other bad updates into the database."]
274     #[doc = "\t\tThis may be slightly faster for DBs that fit entirely in RAM, but"]
275     #[doc = "\t\tis slower for DBs larger than RAM."]
276     #[doc = "\t\tIncompatible with nested transactions."]
277     #[doc = "\t\tDo not mix processes with and without MDB_WRITEMAP on the same"]
278     #[doc = "\t\tenvironment.  This can defeat durability (#mdb_env_sync etc)."]
279     #[doc = "\t<li>#MDB_NOMETASYNC"]
280     #[doc = "\t\tFlush system buffers to disk only once per transaction, omit the"]
281     #[doc = "\t\tmetadata flush. Defer that until the system flushes files to disk,"]
282     #[doc = "\t\tor next non-MDB_RDONLY commit or #mdb_env_sync(). This optimization"]
283     #[doc = "\t\tmaintains database integrity, but a system crash may undo the last"]
284     #[doc = "\t\tcommitted transaction. I.e. it preserves the ACI (atomicity,"]
285     #[doc = "\t\tconsistency, isolation) but not D (durability) database property."]
286     #[doc = "\t\tThis flag may be changed at any time using #mdb_env_set_flags()."]
287     #[doc = "\t<li>#MDB_NOSYNC"]
288     #[doc = "\t\tDon't flush system buffers to disk when committing a transaction."]
289     #[doc = "\t\tThis optimization means a system crash can corrupt the database or"]
290     #[doc = "\t\tlose the last transactions if buffers are not yet flushed to disk."]
291     #[doc = "\t\tThe risk is governed by how often the system flushes dirty buffers"]
292     #[doc = "\t\tto disk and how often #mdb_env_sync() is called.  However, if the"]
293     #[doc = "\t\tfilesystem preserves write order and the #MDB_WRITEMAP flag is not"]
294     #[doc = "\t\tused, transactions exhibit ACI (atomicity, consistency, isolation)"]
295     #[doc = "\t\tproperties and only lose D (durability).  I.e. database integrity"]
296     #[doc = "\t\tis maintained, but a system crash may undo the final transactions."]
297     #[doc = "\t\tNote that (#MDB_NOSYNC | #MDB_WRITEMAP) leaves the system with no"]
298     #[doc = "\t\thint for when to write transactions to disk, unless #mdb_env_sync()"]
299     #[doc = "\t\tis called. (#MDB_MAPASYNC | #MDB_WRITEMAP) may be preferable."]
300     #[doc = "\t\tThis flag may be changed at any time using #mdb_env_set_flags()."]
301     #[doc = "\t<li>#MDB_MAPASYNC"]
302     #[doc = "\t\tWhen using #MDB_WRITEMAP, use asynchronous flushes to disk."]
303     #[doc = "\t\tAs with #MDB_NOSYNC, a system crash can then corrupt the"]
304     #[doc = "\t\tdatabase or lose the last transactions. Calling #mdb_env_sync()"]
305     #[doc = "\t\tensures on-disk database integrity until next commit."]
306     #[doc = "\t\tThis flag may be changed at any time using #mdb_env_set_flags()."]
307     #[doc = "\t<li>#MDB_NOTLS"]
308     #[doc = "\t\tDon't use Thread-Local Storage. Tie reader locktable slots to"]
309     #[doc = "\t\t#MDB_txn objects instead of to threads. I.e. #mdb_txn_reset() keeps"]
310     #[doc = "\t\tthe slot reseved for the #MDB_txn object. A thread may use parallel"]
311     #[doc = "\t\tread-only transactions. A read-only transaction may span threads if"]
312     #[doc = "\t\tthe user synchronizes its use. Applications that multiplex many"]
313     #[doc = "\t\tuser threads over individual OS threads need this option. Such an"]
314     #[doc = "\t\tapplication must also serialize the write transactions in an OS"]
315     #[doc = "\t\tthread, since LMDB's write locking is unaware of the user threads."]
316     #[doc = "\t<li>#MDB_NOLOCK"]
317     #[doc = "\t\tDon't do any locking. If concurrent access is anticipated, the"]
318     #[doc = "\t\tcaller must manage all concurrency itself. For proper operation"]
319     #[doc = "\t\tthe caller must enforce single-writer semantics, and must ensure"]
320     #[doc = "\t\tthat no readers are using old transactions while a writer is"]
321     #[doc = "\t\tactive. The simplest approach is to use an exclusive lock so that"]
322     #[doc = "\t\tno readers may be active at all when a writer begins."]
323     #[doc = "\t<li>#MDB_NORDAHEAD"]
324     #[doc = "\t\tTurn off readahead. Most operating systems perform readahead on"]
325     #[doc = "\t\tread requests by default. This option turns it off if the OS"]
326     #[doc = "\t\tsupports it. Turning it off may help random read performance"]
327     #[doc = "\t\twhen the DB is larger than RAM and system RAM is full."]
328     #[doc = "\t\tThe option is not implemented on Windows."]
329     #[doc = "\t<li>#MDB_NOMEMINIT"]
330     #[doc = "\t\tDon't initialize malloc'd memory before writing to unused spaces"]
331     #[doc = "\t\tin the data file. By default, memory for pages written to the data"]
332     #[doc = "\t\tfile is obtained using malloc. While these pages may be reused in"]
333     #[doc = "\t\tsubsequent transactions, freshly malloc'd pages will be initialized"]
334     #[doc = "\t\tto zeroes before use. This avoids persisting leftover data from other"]
335     #[doc = "\t\tcode (that used the heap and subsequently freed the memory) into the"]
336     #[doc = "\t\tdata file. Note that many other system libraries may allocate"]
337     #[doc = "\t\tand free memory from the heap for arbitrary uses. E.g., stdio may"]
338     #[doc = "\t\tuse the heap for file I/O buffers. This initialization step has a"]
339     #[doc = "\t\tmodest performance cost so some applications may want to disable"]
340     #[doc = "\t\tit using this flag. This option can be a problem for applications"]
341     #[doc = "\t\twhich handle sensitive data like passwords, and it makes memory"]
342     #[doc = "\t\tcheckers like Valgrind noisy. This flag is not needed with #MDB_WRITEMAP,"]
343     #[doc = "\t\twhich writes directly to the mmap instead of using malloc for pages. The"]
344     #[doc = "\t\tinitialization is also skipped if #MDB_RESERVE is used; the"]
345     #[doc = "\t\tcaller is expected to overwrite all of the memory that was"]
346     #[doc = "\t\treserved in that case."]
347     #[doc = "\t\tThis flag may be changed at any time using #mdb_env_set_flags()."]
348     #[doc = " </ul>"]
349     #[doc = " @param[in] mode The UNIX permissions to set on created files and semaphores."]
350     #[doc = " This parameter is ignored on Windows."]
351     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
352     #[doc = " errors are:"]
353     #[doc = " <ul>"]
354     #[doc = "\t<li>#MDB_VERSION_MISMATCH - the version of the LMDB library doesn't match the"]
355     #[doc = "\tversion that created the database environment."]
356     #[doc = "\t<li>#MDB_INVALID - the environment file headers are corrupted."]
357     #[doc = "\t<li>ENOENT - the directory specified by the path parameter doesn't exist."]
358     #[doc = "\t<li>EACCES - the user didn't have permission to access the environment files."]
359     #[doc = "\t<li>EAGAIN - the environment was locked by another process."]
360     #[doc = " </ul>"]
mdb_env_open( env: *mut MDB_env, path: *const ::libc::c_char, flags: ::libc::c_uint, mode: mdb_mode_t, ) -> ::libc::c_int361     pub fn mdb_env_open(
362         env: *mut MDB_env,
363         path: *const ::libc::c_char,
364         flags: ::libc::c_uint,
365         mode: mdb_mode_t,
366     ) -> ::libc::c_int;
367 }
368 extern "C" {
369     #[doc = " @brief Copy an LMDB environment to the specified path."]
370     #[doc = ""]
371     #[doc = " This function may be used to make a backup of an existing environment."]
372     #[doc = " No lockfile is created, since it gets recreated at need."]
373     #[doc = " @note This call can trigger significant file size growth if run in"]
374     #[doc = " parallel with write transactions, because it employs a read-only"]
375     #[doc = " transaction. See long-lived transactions under @ref caveats_sec."]
376     #[doc = " @param[in] env An environment handle returned by #mdb_env_create(). It"]
377     #[doc = " must have already been opened successfully."]
378     #[doc = " @param[in] path The directory in which the copy will reside. This"]
379     #[doc = " directory must already exist and be writable but must otherwise be"]
380     #[doc = " empty."]
381     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_env_copy(env: *mut MDB_env, path: *const ::libc::c_char) -> ::libc::c_int382     pub fn mdb_env_copy(env: *mut MDB_env, path: *const ::libc::c_char) -> ::libc::c_int;
383 }
384 extern "C" {
385     #[doc = " @brief Copy an LMDB environment to the specified file descriptor."]
386     #[doc = ""]
387     #[doc = " This function may be used to make a backup of an existing environment."]
388     #[doc = " No lockfile is created, since it gets recreated at need."]
389     #[doc = " @note This call can trigger significant file size growth if run in"]
390     #[doc = " parallel with write transactions, because it employs a read-only"]
391     #[doc = " transaction. See long-lived transactions under @ref caveats_sec."]
392     #[doc = " @param[in] env An environment handle returned by #mdb_env_create(). It"]
393     #[doc = " must have already been opened successfully."]
394     #[doc = " @param[in] fd The filedescriptor to write the copy to. It must"]
395     #[doc = " have already been opened for Write access."]
396     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_env_copyfd(env: *mut MDB_env, fd: mdb_filehandle_t) -> ::libc::c_int397     pub fn mdb_env_copyfd(env: *mut MDB_env, fd: mdb_filehandle_t) -> ::libc::c_int;
398 }
399 extern "C" {
400     #[doc = " @brief Copy an LMDB environment to the specified path, with options."]
401     #[doc = ""]
402     #[doc = " This function may be used to make a backup of an existing environment."]
403     #[doc = " No lockfile is created, since it gets recreated at need."]
404     #[doc = " @note This call can trigger significant file size growth if run in"]
405     #[doc = " parallel with write transactions, because it employs a read-only"]
406     #[doc = " transaction. See long-lived transactions under @ref caveats_sec."]
407     #[doc = " @param[in] env An environment handle returned by #mdb_env_create(). It"]
408     #[doc = " must have already been opened successfully."]
409     #[doc = " @param[in] path The directory in which the copy will reside. This"]
410     #[doc = " directory must already exist and be writable but must otherwise be"]
411     #[doc = " empty."]
412     #[doc = " @param[in] flags Special options for this operation. This parameter"]
413     #[doc = " must be set to 0 or by bitwise OR'ing together one or more of the"]
414     #[doc = " values described here."]
415     #[doc = " <ul>"]
416     #[doc = "\t<li>#MDB_CP_COMPACT - Perform compaction while copying: omit free"]
417     #[doc = "\t\tpages and sequentially renumber all pages in output. This option"]
418     #[doc = "\t\tconsumes more CPU and runs more slowly than the default."]
419     #[doc = "\t\tCurrently it fails if the environment has suffered a page leak."]
420     #[doc = " </ul>"]
421     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_env_copy2( env: *mut MDB_env, path: *const ::libc::c_char, flags: ::libc::c_uint, ) -> ::libc::c_int422     pub fn mdb_env_copy2(
423         env: *mut MDB_env,
424         path: *const ::libc::c_char,
425         flags: ::libc::c_uint,
426     ) -> ::libc::c_int;
427 }
428 extern "C" {
429     #[doc = " @brief Copy an LMDB environment to the specified file descriptor,"]
430     #[doc = "\twith options."]
431     #[doc = ""]
432     #[doc = " This function may be used to make a backup of an existing environment."]
433     #[doc = " No lockfile is created, since it gets recreated at need. See"]
434     #[doc = " #mdb_env_copy2() for further details."]
435     #[doc = " @note This call can trigger significant file size growth if run in"]
436     #[doc = " parallel with write transactions, because it employs a read-only"]
437     #[doc = " transaction. See long-lived transactions under @ref caveats_sec."]
438     #[doc = " @param[in] env An environment handle returned by #mdb_env_create(). It"]
439     #[doc = " must have already been opened successfully."]
440     #[doc = " @param[in] fd The filedescriptor to write the copy to. It must"]
441     #[doc = " have already been opened for Write access."]
442     #[doc = " @param[in] flags Special options for this operation."]
443     #[doc = " See #mdb_env_copy2() for options."]
444     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_env_copyfd2( env: *mut MDB_env, fd: mdb_filehandle_t, flags: ::libc::c_uint, ) -> ::libc::c_int445     pub fn mdb_env_copyfd2(
446         env: *mut MDB_env,
447         fd: mdb_filehandle_t,
448         flags: ::libc::c_uint,
449     ) -> ::libc::c_int;
450 }
451 extern "C" {
452     #[doc = " @brief Return statistics about the LMDB environment."]
453     #[doc = ""]
454     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
455     #[doc = " @param[out] stat The address of an #MDB_stat structure"]
456     #[doc = " \twhere the statistics will be copied"]
mdb_env_stat(env: *mut MDB_env, stat: *mut MDB_stat) -> ::libc::c_int457     pub fn mdb_env_stat(env: *mut MDB_env, stat: *mut MDB_stat) -> ::libc::c_int;
458 }
459 extern "C" {
460     #[doc = " @brief Return information about the LMDB environment."]
461     #[doc = ""]
462     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
463     #[doc = " @param[out] stat The address of an #MDB_envinfo structure"]
464     #[doc = " \twhere the information will be copied"]
mdb_env_info(env: *mut MDB_env, stat: *mut MDB_envinfo) -> ::libc::c_int465     pub fn mdb_env_info(env: *mut MDB_env, stat: *mut MDB_envinfo) -> ::libc::c_int;
466 }
467 extern "C" {
468     #[doc = " @brief Flush the data buffers to disk."]
469     #[doc = ""]
470     #[doc = " Data is always written to disk when #mdb_txn_commit() is called,"]
471     #[doc = " but the operating system may keep it buffered. LMDB always flushes"]
472     #[doc = " the OS buffers upon commit as well, unless the environment was"]
473     #[doc = " opened with #MDB_NOSYNC or in part #MDB_NOMETASYNC. This call is"]
474     #[doc = " not valid if the environment was opened with #MDB_RDONLY."]
475     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
476     #[doc = " @param[in] force If non-zero, force a synchronous flush.  Otherwise"]
477     #[doc = "  if the environment has the #MDB_NOSYNC flag set the flushes"]
478     #[doc = "\twill be omitted, and with #MDB_MAPASYNC they will be asynchronous."]
479     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
480     #[doc = " errors are:"]
481     #[doc = " <ul>"]
482     #[doc = "\t<li>EACCES - the environment is read-only."]
483     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
484     #[doc = "\t<li>EIO - an error occurred during synchronization."]
485     #[doc = " </ul>"]
mdb_env_sync(env: *mut MDB_env, force: ::libc::c_int) -> ::libc::c_int486     pub fn mdb_env_sync(env: *mut MDB_env, force: ::libc::c_int) -> ::libc::c_int;
487 }
488 extern "C" {
489     #[doc = " @brief Close the environment and release the memory map."]
490     #[doc = ""]
491     #[doc = " Only a single thread may call this function. All transactions, databases,"]
492     #[doc = " and cursors must already be closed before calling this function. Attempts to"]
493     #[doc = " use any such handles after calling this function will cause a SIGSEGV."]
494     #[doc = " The environment handle will be freed and must not be used again after this call."]
495     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
mdb_env_close(env: *mut MDB_env)496     pub fn mdb_env_close(env: *mut MDB_env);
497 }
498 extern "C" {
499     #[doc = " @brief Set environment flags."]
500     #[doc = ""]
501     #[doc = " This may be used to set some flags in addition to those from"]
502     #[doc = " #mdb_env_open(), or to unset these flags.  If several threads"]
503     #[doc = " change the flags at the same time, the result is undefined."]
504     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
505     #[doc = " @param[in] flags The flags to change, bitwise OR'ed together"]
506     #[doc = " @param[in] onoff A non-zero value sets the flags, zero clears them."]
507     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
508     #[doc = " errors are:"]
509     #[doc = " <ul>"]
510     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
511     #[doc = " </ul>"]
mdb_env_set_flags( env: *mut MDB_env, flags: ::libc::c_uint, onoff: ::libc::c_int, ) -> ::libc::c_int512     pub fn mdb_env_set_flags(
513         env: *mut MDB_env,
514         flags: ::libc::c_uint,
515         onoff: ::libc::c_int,
516     ) -> ::libc::c_int;
517 }
518 extern "C" {
519     #[doc = " @brief Get environment flags."]
520     #[doc = ""]
521     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
522     #[doc = " @param[out] flags The address of an integer to store the flags"]
523     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
524     #[doc = " errors are:"]
525     #[doc = " <ul>"]
526     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
527     #[doc = " </ul>"]
mdb_env_get_flags(env: *mut MDB_env, flags: *mut ::libc::c_uint) -> ::libc::c_int528     pub fn mdb_env_get_flags(env: *mut MDB_env, flags: *mut ::libc::c_uint) -> ::libc::c_int;
529 }
530 extern "C" {
531     #[doc = " @brief Return the path that was used in #mdb_env_open()."]
532     #[doc = ""]
533     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
534     #[doc = " @param[out] path Address of a string pointer to contain the path. This"]
535     #[doc = " is the actual string in the environment, not a copy. It should not be"]
536     #[doc = " altered in any way."]
537     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
538     #[doc = " errors are:"]
539     #[doc = " <ul>"]
540     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
541     #[doc = " </ul>"]
mdb_env_get_path(env: *mut MDB_env, path: *mut *const ::libc::c_char) -> ::libc::c_int542     pub fn mdb_env_get_path(env: *mut MDB_env, path: *mut *const ::libc::c_char) -> ::libc::c_int;
543 }
544 extern "C" {
545     #[doc = " @brief Return the filedescriptor for the given environment."]
546     #[doc = ""]
547     #[doc = " This function may be called after fork(), so the descriptor can be"]
548     #[doc = " closed before exec*().  Other LMDB file descriptors have FD_CLOEXEC."]
549     #[doc = " (Until LMDB 0.9.18, only the lockfile had that.)"]
550     #[doc = ""]
551     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
552     #[doc = " @param[out] fd Address of a mdb_filehandle_t to contain the descriptor."]
553     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
554     #[doc = " errors are:"]
555     #[doc = " <ul>"]
556     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
557     #[doc = " </ul>"]
mdb_env_get_fd(env: *mut MDB_env, fd: *mut mdb_filehandle_t) -> ::libc::c_int558     pub fn mdb_env_get_fd(env: *mut MDB_env, fd: *mut mdb_filehandle_t) -> ::libc::c_int;
559 }
560 extern "C" {
561     #[doc = " @brief Set the size of the memory map to use for this environment."]
562     #[doc = ""]
563     #[doc = " The size should be a multiple of the OS page size. The default is"]
564     #[doc = " 10485760 bytes. The size of the memory map is also the maximum size"]
565     #[doc = " of the database. The value should be chosen as large as possible,"]
566     #[doc = " to accommodate future growth of the database."]
567     #[doc = " This function should be called after #mdb_env_create() and before #mdb_env_open()."]
568     #[doc = " It may be called at later times if no transactions are active in"]
569     #[doc = " this process. Note that the library does not check for this condition,"]
570     #[doc = " the caller must ensure it explicitly."]
571     #[doc = ""]
572     #[doc = " The new size takes effect immediately for the current process but"]
573     #[doc = " will not be persisted to any others until a write transaction has been"]
574     #[doc = " committed by the current process. Also, only mapsize increases are"]
575     #[doc = " persisted into the environment."]
576     #[doc = ""]
577     #[doc = " If the mapsize is increased by another process, and data has grown"]
578     #[doc = " beyond the range of the current mapsize, #mdb_txn_begin() will"]
579     #[doc = " return #MDB_MAP_RESIZED. This function may be called with a size"]
580     #[doc = " of zero to adopt the new size."]
581     #[doc = ""]
582     #[doc = " Any attempt to set a size smaller than the space already consumed"]
583     #[doc = " by the environment will be silently changed to the current size of the used space."]
584     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
585     #[doc = " @param[in] size The size in bytes"]
586     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
587     #[doc = " errors are:"]
588     #[doc = " <ul>"]
589     #[doc = "\t<li>EINVAL - an invalid parameter was specified, or the environment has"]
590     #[doc = "   \tan active write transaction."]
591     #[doc = " </ul>"]
mdb_env_set_mapsize(env: *mut MDB_env, size: usize) -> ::libc::c_int592     pub fn mdb_env_set_mapsize(env: *mut MDB_env, size: usize) -> ::libc::c_int;
593 }
594 extern "C" {
595     #[doc = " @brief Set the maximum number of threads/reader slots for the environment."]
596     #[doc = ""]
597     #[doc = " This defines the number of slots in the lock table that is used to track readers in the"]
598     #[doc = " the environment. The default is 126."]
599     #[doc = " Starting a read-only transaction normally ties a lock table slot to the"]
600     #[doc = " current thread until the environment closes or the thread exits. If"]
601     #[doc = " MDB_NOTLS is in use, #mdb_txn_begin() instead ties the slot to the"]
602     #[doc = " MDB_txn object until it or the #MDB_env object is destroyed."]
603     #[doc = " This function may only be called after #mdb_env_create() and before #mdb_env_open()."]
604     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
605     #[doc = " @param[in] readers The maximum number of reader lock table slots"]
606     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
607     #[doc = " errors are:"]
608     #[doc = " <ul>"]
609     #[doc = "\t<li>EINVAL - an invalid parameter was specified, or the environment is already open."]
610     #[doc = " </ul>"]
mdb_env_set_maxreaders(env: *mut MDB_env, readers: ::libc::c_uint) -> ::libc::c_int611     pub fn mdb_env_set_maxreaders(env: *mut MDB_env, readers: ::libc::c_uint) -> ::libc::c_int;
612 }
613 extern "C" {
614     #[doc = " @brief Get the maximum number of threads/reader slots for the environment."]
615     #[doc = ""]
616     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
617     #[doc = " @param[out] readers Address of an integer to store the number of readers"]
618     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
619     #[doc = " errors are:"]
620     #[doc = " <ul>"]
621     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
622     #[doc = " </ul>"]
mdb_env_get_maxreaders(env: *mut MDB_env, readers: *mut ::libc::c_uint) -> ::libc::c_int623     pub fn mdb_env_get_maxreaders(env: *mut MDB_env, readers: *mut ::libc::c_uint)
624         -> ::libc::c_int;
625 }
626 extern "C" {
627     #[doc = " @brief Set the maximum number of named databases for the environment."]
628     #[doc = ""]
629     #[doc = " This function is only needed if multiple databases will be used in the"]
630     #[doc = " environment. Simpler applications that use the environment as a single"]
631     #[doc = " unnamed database can ignore this option."]
632     #[doc = " This function may only be called after #mdb_env_create() and before #mdb_env_open()."]
633     #[doc = ""]
634     #[doc = " Currently a moderate number of slots are cheap but a huge number gets"]
635     #[doc = " expensive: 7-120 words per transaction, and every #mdb_dbi_open()"]
636     #[doc = " does a linear search of the opened slots."]
637     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
638     #[doc = " @param[in] dbs The maximum number of databases"]
639     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
640     #[doc = " errors are:"]
641     #[doc = " <ul>"]
642     #[doc = "\t<li>EINVAL - an invalid parameter was specified, or the environment is already open."]
643     #[doc = " </ul>"]
mdb_env_set_maxdbs(env: *mut MDB_env, dbs: MDB_dbi) -> ::libc::c_int644     pub fn mdb_env_set_maxdbs(env: *mut MDB_env, dbs: MDB_dbi) -> ::libc::c_int;
645 }
646 extern "C" {
647     #[doc = " @brief Get the maximum size of keys and #MDB_DUPSORT data we can write."]
648     #[doc = ""]
649     #[doc = " Depends on the compile-time constant #MDB_MAXKEYSIZE. Default 511."]
650     #[doc = " See @ref MDB_val."]
651     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
652     #[doc = " @return The maximum size of a key we can write"]
mdb_env_get_maxkeysize(env: *mut MDB_env) -> ::libc::c_int653     pub fn mdb_env_get_maxkeysize(env: *mut MDB_env) -> ::libc::c_int;
654 }
655 extern "C" {
656     #[doc = " @brief Set application information associated with the #MDB_env."]
657     #[doc = ""]
658     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
659     #[doc = " @param[in] ctx An arbitrary pointer for whatever the application needs."]
660     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_env_set_userctx(env: *mut MDB_env, ctx: *mut ::libc::c_void) -> ::libc::c_int661     pub fn mdb_env_set_userctx(env: *mut MDB_env, ctx: *mut ::libc::c_void) -> ::libc::c_int;
662 }
663 extern "C" {
664     #[doc = " @brief Get the application information associated with the #MDB_env."]
665     #[doc = ""]
666     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
667     #[doc = " @return The pointer set by #mdb_env_set_userctx()."]
mdb_env_get_userctx(env: *mut MDB_env) -> *mut ::libc::c_void668     pub fn mdb_env_get_userctx(env: *mut MDB_env) -> *mut ::libc::c_void;
669 }
670 #[doc = " @brief A callback function for most LMDB assert() failures,"]
671 #[doc = " called before printing the message and aborting."]
672 #[doc = ""]
673 #[doc = " @param[in] env An environment handle returned by #mdb_env_create()."]
674 #[doc = " @param[in] msg The assertion message, not including newline."]
675 pub type MDB_assert_func =
676     ::std::option::Option<unsafe extern "C" fn(env: *mut MDB_env, msg: *const ::libc::c_char)>;
677 extern "C" {
678     #[doc = " Set or reset the assert() callback of the environment."]
679     #[doc = " Disabled if liblmdb is buillt with NDEBUG."]
680     #[doc = " @note This hack should become obsolete as lmdb's error handling matures."]
681     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()."]
682     #[doc = " @param[in] func An #MDB_assert_func function, or 0."]
683     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_env_set_assert(env: *mut MDB_env, func: MDB_assert_func) -> ::libc::c_int684     pub fn mdb_env_set_assert(env: *mut MDB_env, func: MDB_assert_func) -> ::libc::c_int;
685 }
686 extern "C" {
687     #[doc = " @brief Create a transaction for use with the environment."]
688     #[doc = ""]
689     #[doc = " The transaction handle may be discarded using #mdb_txn_abort() or #mdb_txn_commit()."]
690     #[doc = " @note A transaction and its cursors must only be used by a single"]
691     #[doc = " thread, and a thread may only have a single transaction at a time."]
692     #[doc = " If #MDB_NOTLS is in use, this does not apply to read-only transactions."]
693     #[doc = " @note Cursors may not span transactions."]
694     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
695     #[doc = " @param[in] parent If this parameter is non-NULL, the new transaction"]
696     #[doc = " will be a nested transaction, with the transaction indicated by \\b parent"]
697     #[doc = " as its parent. Transactions may be nested to any level. A parent"]
698     #[doc = " transaction and its cursors may not issue any other operations than"]
699     #[doc = " mdb_txn_commit and mdb_txn_abort while it has active child transactions."]
700     #[doc = " @param[in] flags Special options for this transaction. This parameter"]
701     #[doc = " must be set to 0 or by bitwise OR'ing together one or more of the"]
702     #[doc = " values described here."]
703     #[doc = " <ul>"]
704     #[doc = "\t<li>#MDB_RDONLY"]
705     #[doc = "\t\tThis transaction will not perform any write operations."]
706     #[doc = " </ul>"]
707     #[doc = " @param[out] txn Address where the new #MDB_txn handle will be stored"]
708     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
709     #[doc = " errors are:"]
710     #[doc = " <ul>"]
711     #[doc = "\t<li>#MDB_PANIC - a fatal error occurred earlier and the environment"]
712     #[doc = "\t\tmust be shut down."]
713     #[doc = "\t<li>#MDB_MAP_RESIZED - another process wrote data beyond this MDB_env's"]
714     #[doc = "\t\tmapsize and this environment's map must be resized as well."]
715     #[doc = "\t\tSee #mdb_env_set_mapsize()."]
716     #[doc = "\t<li>#MDB_READERS_FULL - a read-only transaction was requested and"]
717     #[doc = "\t\tthe reader lock table is full. See #mdb_env_set_maxreaders()."]
718     #[doc = "\t<li>ENOMEM - out of memory."]
719     #[doc = " </ul>"]
mdb_txn_begin( env: *mut MDB_env, parent: *mut MDB_txn, flags: ::libc::c_uint, txn: *mut *mut MDB_txn, ) -> ::libc::c_int720     pub fn mdb_txn_begin(
721         env: *mut MDB_env,
722         parent: *mut MDB_txn,
723         flags: ::libc::c_uint,
724         txn: *mut *mut MDB_txn,
725     ) -> ::libc::c_int;
726 }
727 extern "C" {
728     #[doc = " @brief Returns the transaction's #MDB_env"]
729     #[doc = ""]
730     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
mdb_txn_env(txn: *mut MDB_txn) -> *mut MDB_env731     pub fn mdb_txn_env(txn: *mut MDB_txn) -> *mut MDB_env;
732 }
733 extern "C" {
734     #[doc = " @brief Return the transaction's ID."]
735     #[doc = ""]
736     #[doc = " This returns the identifier associated with this transaction. For a"]
737     #[doc = " read-only transaction, this corresponds to the snapshot being read;"]
738     #[doc = " concurrent readers will frequently have the same transaction ID."]
739     #[doc = ""]
740     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
741     #[doc = " @return A transaction ID, valid if input is an active transaction."]
mdb_txn_id(txn: *mut MDB_txn) -> usize742     pub fn mdb_txn_id(txn: *mut MDB_txn) -> usize;
743 }
744 extern "C" {
745     #[doc = " @brief Commit all the operations of a transaction into the database."]
746     #[doc = ""]
747     #[doc = " The transaction handle is freed. It and its cursors must not be used"]
748     #[doc = " again after this call, except with #mdb_cursor_renew()."]
749     #[doc = " @note Earlier documentation incorrectly said all cursors would be freed."]
750     #[doc = " Only write-transactions free cursors."]
751     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
752     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
753     #[doc = " errors are:"]
754     #[doc = " <ul>"]
755     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
756     #[doc = "\t<li>ENOSPC - no more disk space."]
757     #[doc = "\t<li>EIO - a low-level I/O error occurred while writing."]
758     #[doc = "\t<li>ENOMEM - out of memory."]
759     #[doc = " </ul>"]
mdb_txn_commit(txn: *mut MDB_txn) -> ::libc::c_int760     pub fn mdb_txn_commit(txn: *mut MDB_txn) -> ::libc::c_int;
761 }
762 extern "C" {
763     #[doc = " @brief Abandon all the operations of the transaction instead of saving them."]
764     #[doc = ""]
765     #[doc = " The transaction handle is freed. It and its cursors must not be used"]
766     #[doc = " again after this call, except with #mdb_cursor_renew()."]
767     #[doc = " @note Earlier documentation incorrectly said all cursors would be freed."]
768     #[doc = " Only write-transactions free cursors."]
769     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
mdb_txn_abort(txn: *mut MDB_txn)770     pub fn mdb_txn_abort(txn: *mut MDB_txn);
771 }
772 extern "C" {
773     #[doc = " @brief Reset a read-only transaction."]
774     #[doc = ""]
775     #[doc = " Abort the transaction like #mdb_txn_abort(), but keep the transaction"]
776     #[doc = " handle. #mdb_txn_renew() may reuse the handle. This saves allocation"]
777     #[doc = " overhead if the process will start a new read-only transaction soon,"]
778     #[doc = " and also locking overhead if #MDB_NOTLS is in use. The reader table"]
779     #[doc = " lock is released, but the table slot stays tied to its thread or"]
780     #[doc = " #MDB_txn. Use mdb_txn_abort() to discard a reset handle, and to free"]
781     #[doc = " its lock table slot if MDB_NOTLS is in use."]
782     #[doc = " Cursors opened within the transaction must not be used"]
783     #[doc = " again after this call, except with #mdb_cursor_renew()."]
784     #[doc = " Reader locks generally don't interfere with writers, but they keep old"]
785     #[doc = " versions of database pages allocated. Thus they prevent the old pages"]
786     #[doc = " from being reused when writers commit new data, and so under heavy load"]
787     #[doc = " the database size may grow much more rapidly than otherwise."]
788     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
mdb_txn_reset(txn: *mut MDB_txn)789     pub fn mdb_txn_reset(txn: *mut MDB_txn);
790 }
791 extern "C" {
792     #[doc = " @brief Renew a read-only transaction."]
793     #[doc = ""]
794     #[doc = " This acquires a new reader lock for a transaction handle that had been"]
795     #[doc = " released by #mdb_txn_reset(). It must be called before a reset transaction"]
796     #[doc = " may be used again."]
797     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
798     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
799     #[doc = " errors are:"]
800     #[doc = " <ul>"]
801     #[doc = "\t<li>#MDB_PANIC - a fatal error occurred earlier and the environment"]
802     #[doc = "\t\tmust be shut down."]
803     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
804     #[doc = " </ul>"]
mdb_txn_renew(txn: *mut MDB_txn) -> ::libc::c_int805     pub fn mdb_txn_renew(txn: *mut MDB_txn) -> ::libc::c_int;
806 }
807 extern "C" {
808     #[doc = " @brief Open a database in the environment."]
809     #[doc = ""]
810     #[doc = " A database handle denotes the name and parameters of a database,"]
811     #[doc = " independently of whether such a database exists."]
812     #[doc = " The database handle may be discarded by calling #mdb_dbi_close()."]
813     #[doc = " The old database handle is returned if the database was already open."]
814     #[doc = " The handle may only be closed once."]
815     #[doc = ""]
816     #[doc = " The database handle will be private to the current transaction until"]
817     #[doc = " the transaction is successfully committed. If the transaction is"]
818     #[doc = " aborted the handle will be closed automatically."]
819     #[doc = " After a successful commit the handle will reside in the shared"]
820     #[doc = " environment, and may be used by other transactions."]
821     #[doc = ""]
822     #[doc = " This function must not be called from multiple concurrent"]
823     #[doc = " transactions in the same process. A transaction that uses"]
824     #[doc = " this function must finish (either commit or abort) before"]
825     #[doc = " any other transaction in the process may use this function."]
826     #[doc = ""]
827     #[doc = " To use named databases (with name != NULL), #mdb_env_set_maxdbs()"]
828     #[doc = " must be called before opening the environment.  Database names are"]
829     #[doc = " keys in the unnamed database, and may be read but not written."]
830     #[doc = ""]
831     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
832     #[doc = " @param[in] name The name of the database to open. If only a single"]
833     #[doc = " \tdatabase is needed in the environment, this value may be NULL."]
834     #[doc = " @param[in] flags Special options for this database. This parameter"]
835     #[doc = " must be set to 0 or by bitwise OR'ing together one or more of the"]
836     #[doc = " values described here."]
837     #[doc = " <ul>"]
838     #[doc = "\t<li>#MDB_REVERSEKEY"]
839     #[doc = "\t\tKeys are strings to be compared in reverse order, from the end"]
840     #[doc = "\t\tof the strings to the beginning. By default, Keys are treated as strings and"]
841     #[doc = "\t\tcompared from beginning to end."]
842     #[doc = "\t<li>#MDB_DUPSORT"]
843     #[doc = "\t\tDuplicate keys may be used in the database. (Or, from another perspective,"]
844     #[doc = "\t\tkeys may have multiple data items, stored in sorted order.) By default"]
845     #[doc = "\t\tkeys must be unique and may have only a single data item."]
846     #[doc = "\t<li>#MDB_INTEGERKEY"]
847     #[doc = "\t\tKeys are binary integers in native byte order, either unsigned int"]
848     #[doc = "\t\tor size_t, and will be sorted as such."]
849     #[doc = "\t\tThe keys must all be of the same size."]
850     #[doc = "\t<li>#MDB_DUPFIXED"]
851     #[doc = "\t\tThis flag may only be used in combination with #MDB_DUPSORT. This option"]
852     #[doc = "\t\ttells the library that the data items for this database are all the same"]
853     #[doc = "\t\tsize, which allows further optimizations in storage and retrieval. When"]
854     #[doc = "\t\tall data items are the same size, the #MDB_GET_MULTIPLE, #MDB_NEXT_MULTIPLE"]
855     #[doc = "\t\tand #MDB_PREV_MULTIPLE cursor operations may be used to retrieve multiple"]
856     #[doc = "\t\titems at once."]
857     #[doc = "\t<li>#MDB_INTEGERDUP"]
858     #[doc = "\t\tThis option specifies that duplicate data items are binary integers,"]
859     #[doc = "\t\tsimilar to #MDB_INTEGERKEY keys."]
860     #[doc = "\t<li>#MDB_REVERSEDUP"]
861     #[doc = "\t\tThis option specifies that duplicate data items should be compared as"]
862     #[doc = "\t\tstrings in reverse order."]
863     #[doc = "\t<li>#MDB_CREATE"]
864     #[doc = "\t\tCreate the named database if it doesn't exist. This option is not"]
865     #[doc = "\t\tallowed in a read-only transaction or a read-only environment."]
866     #[doc = " </ul>"]
867     #[doc = " @param[out] dbi Address where the new #MDB_dbi handle will be stored"]
868     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
869     #[doc = " errors are:"]
870     #[doc = " <ul>"]
871     #[doc = "\t<li>#MDB_NOTFOUND - the specified database doesn't exist in the environment"]
872     #[doc = "\t\tand #MDB_CREATE was not specified."]
873     #[doc = "\t<li>#MDB_DBS_FULL - too many databases have been opened. See #mdb_env_set_maxdbs()."]
874     #[doc = " </ul>"]
mdb_dbi_open( txn: *mut MDB_txn, name: *const ::libc::c_char, flags: ::libc::c_uint, dbi: *mut MDB_dbi, ) -> ::libc::c_int875     pub fn mdb_dbi_open(
876         txn: *mut MDB_txn,
877         name: *const ::libc::c_char,
878         flags: ::libc::c_uint,
879         dbi: *mut MDB_dbi,
880     ) -> ::libc::c_int;
881 }
882 extern "C" {
883     #[doc = " @brief Retrieve statistics for a database."]
884     #[doc = ""]
885     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
886     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
887     #[doc = " @param[out] stat The address of an #MDB_stat structure"]
888     #[doc = " \twhere the statistics will be copied"]
889     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
890     #[doc = " errors are:"]
891     #[doc = " <ul>"]
892     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
893     #[doc = " </ul>"]
mdb_stat(txn: *mut MDB_txn, dbi: MDB_dbi, stat: *mut MDB_stat) -> ::libc::c_int894     pub fn mdb_stat(txn: *mut MDB_txn, dbi: MDB_dbi, stat: *mut MDB_stat) -> ::libc::c_int;
895 }
896 extern "C" {
897     #[doc = " @brief Retrieve the DB flags for a database handle."]
898     #[doc = ""]
899     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
900     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
901     #[doc = " @param[out] flags Address where the flags will be returned."]
902     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_dbi_flags( txn: *mut MDB_txn, dbi: MDB_dbi, flags: *mut ::libc::c_uint, ) -> ::libc::c_int903     pub fn mdb_dbi_flags(
904         txn: *mut MDB_txn,
905         dbi: MDB_dbi,
906         flags: *mut ::libc::c_uint,
907     ) -> ::libc::c_int;
908 }
909 extern "C" {
910     #[doc = " @brief Close a database handle. Normally unnecessary. Use with care:"]
911     #[doc = ""]
912     #[doc = " This call is not mutex protected. Handles should only be closed by"]
913     #[doc = " a single thread, and only if no other threads are going to reference"]
914     #[doc = " the database handle or one of its cursors any further. Do not close"]
915     #[doc = " a handle if an existing transaction has modified its database."]
916     #[doc = " Doing so can cause misbehavior from database corruption to errors"]
917     #[doc = " like MDB_BAD_VALSIZE (since the DB name is gone)."]
918     #[doc = ""]
919     #[doc = " Closing a database handle is not necessary, but lets #mdb_dbi_open()"]
920     #[doc = " reuse the handle value.  Usually it's better to set a bigger"]
921     #[doc = " #mdb_env_set_maxdbs(), unless that value would be large."]
922     #[doc = ""]
923     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
924     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
mdb_dbi_close(env: *mut MDB_env, dbi: MDB_dbi)925     pub fn mdb_dbi_close(env: *mut MDB_env, dbi: MDB_dbi);
926 }
927 extern "C" {
928     #[doc = " @brief Empty or delete+close a database."]
929     #[doc = ""]
930     #[doc = " See #mdb_dbi_close() for restrictions about closing the DB handle."]
931     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
932     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
933     #[doc = " @param[in] del 0 to empty the DB, 1 to delete it from the"]
934     #[doc = " environment and close the DB handle."]
935     #[doc = " @return A non-zero error value on failure and 0 on success."]
mdb_drop(txn: *mut MDB_txn, dbi: MDB_dbi, del: ::libc::c_int) -> ::libc::c_int936     pub fn mdb_drop(txn: *mut MDB_txn, dbi: MDB_dbi, del: ::libc::c_int) -> ::libc::c_int;
937 }
938 extern "C" {
939     #[doc = " @brief Set a custom key comparison function for a database."]
940     #[doc = ""]
941     #[doc = " The comparison function is called whenever it is necessary to compare a"]
942     #[doc = " key specified by the application with a key currently stored in the database."]
943     #[doc = " If no comparison function is specified, and no special key flags were specified"]
944     #[doc = " with #mdb_dbi_open(), the keys are compared lexically, with shorter keys collating"]
945     #[doc = " before longer keys."]
946     #[doc = " @warning This function must be called before any data access functions are used,"]
947     #[doc = " otherwise data corruption may occur. The same comparison function must be used by every"]
948     #[doc = " program accessing the database, every time the database is used."]
949     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
950     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
951     #[doc = " @param[in] cmp A #MDB_cmp_func function"]
952     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
953     #[doc = " errors are:"]
954     #[doc = " <ul>"]
955     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
956     #[doc = " </ul>"]
mdb_set_compare(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: MDB_cmp_func) -> ::libc::c_int957     pub fn mdb_set_compare(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: MDB_cmp_func) -> ::libc::c_int;
958 }
959 extern "C" {
960     #[doc = " @brief Set a custom data comparison function for a #MDB_DUPSORT database."]
961     #[doc = ""]
962     #[doc = " This comparison function is called whenever it is necessary to compare a data"]
963     #[doc = " item specified by the application with a data item currently stored in the database."]
964     #[doc = " This function only takes effect if the database was opened with the #MDB_DUPSORT"]
965     #[doc = " flag."]
966     #[doc = " If no comparison function is specified, and no special key flags were specified"]
967     #[doc = " with #mdb_dbi_open(), the data items are compared lexically, with shorter items collating"]
968     #[doc = " before longer items."]
969     #[doc = " @warning This function must be called before any data access functions are used,"]
970     #[doc = " otherwise data corruption may occur. The same comparison function must be used by every"]
971     #[doc = " program accessing the database, every time the database is used."]
972     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
973     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
974     #[doc = " @param[in] cmp A #MDB_cmp_func function"]
975     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
976     #[doc = " errors are:"]
977     #[doc = " <ul>"]
978     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
979     #[doc = " </ul>"]
mdb_set_dupsort(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: MDB_cmp_func) -> ::libc::c_int980     pub fn mdb_set_dupsort(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: MDB_cmp_func) -> ::libc::c_int;
981 }
982 extern "C" {
983     #[doc = " @brief Set a relocation function for a #MDB_FIXEDMAP database."]
984     #[doc = ""]
985     #[doc = " @todo The relocation function is called whenever it is necessary to move the data"]
986     #[doc = " of an item to a different position in the database (e.g. through tree"]
987     #[doc = " balancing operations, shifts as a result of adds or deletes, etc.). It is"]
988     #[doc = " intended to allow address/position-dependent data items to be stored in"]
989     #[doc = " a database in an environment opened with the #MDB_FIXEDMAP option."]
990     #[doc = " Currently the relocation feature is unimplemented and setting"]
991     #[doc = " this function has no effect."]
992     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
993     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
994     #[doc = " @param[in] rel A #MDB_rel_func function"]
995     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
996     #[doc = " errors are:"]
997     #[doc = " <ul>"]
998     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
999     #[doc = " </ul>"]
mdb_set_relfunc(txn: *mut MDB_txn, dbi: MDB_dbi, rel: MDB_rel_func) -> ::libc::c_int1000     pub fn mdb_set_relfunc(txn: *mut MDB_txn, dbi: MDB_dbi, rel: MDB_rel_func) -> ::libc::c_int;
1001 }
1002 extern "C" {
1003     #[doc = " @brief Set a context pointer for a #MDB_FIXEDMAP database's relocation function."]
1004     #[doc = ""]
1005     #[doc = " See #mdb_set_relfunc and #MDB_rel_func for more details."]
1006     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1007     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
1008     #[doc = " @param[in] ctx An arbitrary pointer for whatever the application needs."]
1009     #[doc = " It will be passed to the callback function set by #mdb_set_relfunc"]
1010     #[doc = " as its \\b relctx parameter whenever the callback is invoked."]
1011     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1012     #[doc = " errors are:"]
1013     #[doc = " <ul>"]
1014     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1015     #[doc = " </ul>"]
mdb_set_relctx( txn: *mut MDB_txn, dbi: MDB_dbi, ctx: *mut ::libc::c_void, ) -> ::libc::c_int1016     pub fn mdb_set_relctx(
1017         txn: *mut MDB_txn,
1018         dbi: MDB_dbi,
1019         ctx: *mut ::libc::c_void,
1020     ) -> ::libc::c_int;
1021 }
1022 extern "C" {
1023     #[doc = " @brief Get items from a database."]
1024     #[doc = ""]
1025     #[doc = " This function retrieves key/data pairs from the database. The address"]
1026     #[doc = " and length of the data associated with the specified \\b key are returned"]
1027     #[doc = " in the structure to which \\b data refers."]
1028     #[doc = " If the database supports duplicate keys (#MDB_DUPSORT) then the"]
1029     #[doc = " first data item for the key will be returned. Retrieval of other"]
1030     #[doc = " items requires the use of #mdb_cursor_get()."]
1031     #[doc = ""]
1032     #[doc = " @note The memory pointed to by the returned values is owned by the"]
1033     #[doc = " database. The caller need not dispose of the memory, and may not"]
1034     #[doc = " modify it in any way. For values returned in a read-only transaction"]
1035     #[doc = " any modification attempts will cause a SIGSEGV."]
1036     #[doc = " @note Values returned from the database are valid only until a"]
1037     #[doc = " subsequent update operation, or the end of the transaction."]
1038     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1039     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
1040     #[doc = " @param[in] key The key to search for in the database"]
1041     #[doc = " @param[out] data The data corresponding to the key"]
1042     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1043     #[doc = " errors are:"]
1044     #[doc = " <ul>"]
1045     #[doc = "\t<li>#MDB_NOTFOUND - the key was not in the database."]
1046     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1047     #[doc = " </ul>"]
mdb_get( txn: *mut MDB_txn, dbi: MDB_dbi, key: *mut MDB_val, data: *mut MDB_val, ) -> ::libc::c_int1048     pub fn mdb_get(
1049         txn: *mut MDB_txn,
1050         dbi: MDB_dbi,
1051         key: *mut MDB_val,
1052         data: *mut MDB_val,
1053     ) -> ::libc::c_int;
1054 }
1055 extern "C" {
1056     #[doc = " @brief Store items into a database."]
1057     #[doc = ""]
1058     #[doc = " This function stores key/data pairs in the database. The default behavior"]
1059     #[doc = " is to enter the new key/data pair, replacing any previously existing key"]
1060     #[doc = " if duplicates are disallowed, or adding a duplicate data item if"]
1061     #[doc = " duplicates are allowed (#MDB_DUPSORT)."]
1062     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1063     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
1064     #[doc = " @param[in] key The key to store in the database"]
1065     #[doc = " @param[in,out] data The data to store"]
1066     #[doc = " @param[in] flags Special options for this operation. This parameter"]
1067     #[doc = " must be set to 0 or by bitwise OR'ing together one or more of the"]
1068     #[doc = " values described here."]
1069     #[doc = " <ul>"]
1070     #[doc = "\t<li>#MDB_NODUPDATA - enter the new key/data pair only if it does not"]
1071     #[doc = "\t\talready appear in the database. This flag may only be specified"]
1072     #[doc = "\t\tif the database was opened with #MDB_DUPSORT. The function will"]
1073     #[doc = "\t\treturn #MDB_KEYEXIST if the key/data pair already appears in the"]
1074     #[doc = "\t\tdatabase."]
1075     #[doc = "\t<li>#MDB_NOOVERWRITE - enter the new key/data pair only if the key"]
1076     #[doc = "\t\tdoes not already appear in the database. The function will return"]
1077     #[doc = "\t\t#MDB_KEYEXIST if the key already appears in the database, even if"]
1078     #[doc = "\t\tthe database supports duplicates (#MDB_DUPSORT). The \\b data"]
1079     #[doc = "\t\tparameter will be set to point to the existing item."]
1080     #[doc = "\t<li>#MDB_RESERVE - reserve space for data of the given size, but"]
1081     #[doc = "\t\tdon't copy the given data. Instead, return a pointer to the"]
1082     #[doc = "\t\treserved space, which the caller can fill in later - before"]
1083     #[doc = "\t\tthe next update operation or the transaction ends. This saves"]
1084     #[doc = "\t\tan extra memcpy if the data is being generated later."]
1085     #[doc = "\t\tLMDB does nothing else with this memory, the caller is expected"]
1086     #[doc = "\t\tto modify all of the space requested. This flag must not be"]
1087     #[doc = "\t\tspecified if the database was opened with #MDB_DUPSORT."]
1088     #[doc = "\t<li>#MDB_APPEND - append the given key/data pair to the end of the"]
1089     #[doc = "\t\tdatabase. This option allows fast bulk loading when keys are"]
1090     #[doc = "\t\talready known to be in the correct order. Loading unsorted keys"]
1091     #[doc = "\t\twith this flag will cause a #MDB_KEYEXIST error."]
1092     #[doc = "\t<li>#MDB_APPENDDUP - as above, but for sorted dup data."]
1093     #[doc = " </ul>"]
1094     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1095     #[doc = " errors are:"]
1096     #[doc = " <ul>"]
1097     #[doc = "\t<li>#MDB_MAP_FULL - the database is full, see #mdb_env_set_mapsize()."]
1098     #[doc = "\t<li>#MDB_TXN_FULL - the transaction has too many dirty pages."]
1099     #[doc = "\t<li>EACCES - an attempt was made to write in a read-only transaction."]
1100     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1101     #[doc = " </ul>"]
mdb_put( txn: *mut MDB_txn, dbi: MDB_dbi, key: *mut MDB_val, data: *mut MDB_val, flags: ::libc::c_uint, ) -> ::libc::c_int1102     pub fn mdb_put(
1103         txn: *mut MDB_txn,
1104         dbi: MDB_dbi,
1105         key: *mut MDB_val,
1106         data: *mut MDB_val,
1107         flags: ::libc::c_uint,
1108     ) -> ::libc::c_int;
1109 }
1110 extern "C" {
1111     #[doc = " @brief Delete items from a database."]
1112     #[doc = ""]
1113     #[doc = " This function removes key/data pairs from the database."]
1114     #[doc = " If the database does not support sorted duplicate data items"]
1115     #[doc = " (#MDB_DUPSORT) the data parameter is ignored."]
1116     #[doc = " If the database supports sorted duplicates and the data parameter"]
1117     #[doc = " is NULL, all of the duplicate data items for the key will be"]
1118     #[doc = " deleted. Otherwise, if the data parameter is non-NULL"]
1119     #[doc = " only the matching data item will be deleted."]
1120     #[doc = " This function will return #MDB_NOTFOUND if the specified key/data"]
1121     #[doc = " pair is not in the database."]
1122     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1123     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
1124     #[doc = " @param[in] key The key to delete from the database"]
1125     #[doc = " @param[in] data The data to delete"]
1126     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1127     #[doc = " errors are:"]
1128     #[doc = " <ul>"]
1129     #[doc = "\t<li>EACCES - an attempt was made to write in a read-only transaction."]
1130     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1131     #[doc = " </ul>"]
mdb_del( txn: *mut MDB_txn, dbi: MDB_dbi, key: *mut MDB_val, data: *mut MDB_val, ) -> ::libc::c_int1132     pub fn mdb_del(
1133         txn: *mut MDB_txn,
1134         dbi: MDB_dbi,
1135         key: *mut MDB_val,
1136         data: *mut MDB_val,
1137     ) -> ::libc::c_int;
1138 }
1139 extern "C" {
1140     #[doc = " @brief Create a cursor handle."]
1141     #[doc = ""]
1142     #[doc = " A cursor is associated with a specific transaction and database."]
1143     #[doc = " A cursor cannot be used when its database handle is closed.  Nor"]
1144     #[doc = " when its transaction has ended, except with #mdb_cursor_renew()."]
1145     #[doc = " It can be discarded with #mdb_cursor_close()."]
1146     #[doc = " A cursor in a write-transaction can be closed before its transaction"]
1147     #[doc = " ends, and will otherwise be closed when its transaction ends."]
1148     #[doc = " A cursor in a read-only transaction must be closed explicitly, before"]
1149     #[doc = " or after its transaction ends. It can be reused with"]
1150     #[doc = " #mdb_cursor_renew() before finally closing it."]
1151     #[doc = " @note Earlier documentation said that cursors in every transaction"]
1152     #[doc = " were closed when the transaction committed or aborted."]
1153     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1154     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
1155     #[doc = " @param[out] cursor Address where the new #MDB_cursor handle will be stored"]
1156     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1157     #[doc = " errors are:"]
1158     #[doc = " <ul>"]
1159     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1160     #[doc = " </ul>"]
mdb_cursor_open( txn: *mut MDB_txn, dbi: MDB_dbi, cursor: *mut *mut MDB_cursor, ) -> ::libc::c_int1161     pub fn mdb_cursor_open(
1162         txn: *mut MDB_txn,
1163         dbi: MDB_dbi,
1164         cursor: *mut *mut MDB_cursor,
1165     ) -> ::libc::c_int;
1166 }
1167 extern "C" {
1168     #[doc = " @brief Close a cursor handle."]
1169     #[doc = ""]
1170     #[doc = " The cursor handle will be freed and must not be used again after this call."]
1171     #[doc = " Its transaction must still be live if it is a write-transaction."]
1172     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
mdb_cursor_close(cursor: *mut MDB_cursor)1173     pub fn mdb_cursor_close(cursor: *mut MDB_cursor);
1174 }
1175 extern "C" {
1176     #[doc = " @brief Renew a cursor handle."]
1177     #[doc = ""]
1178     #[doc = " A cursor is associated with a specific transaction and database."]
1179     #[doc = " Cursors that are only used in read-only"]
1180     #[doc = " transactions may be re-used, to avoid unnecessary malloc/free overhead."]
1181     #[doc = " The cursor may be associated with a new read-only transaction, and"]
1182     #[doc = " referencing the same database handle as it was created with."]
1183     #[doc = " This may be done whether the previous transaction is live or dead."]
1184     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1185     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
1186     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1187     #[doc = " errors are:"]
1188     #[doc = " <ul>"]
1189     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1190     #[doc = " </ul>"]
mdb_cursor_renew(txn: *mut MDB_txn, cursor: *mut MDB_cursor) -> ::libc::c_int1191     pub fn mdb_cursor_renew(txn: *mut MDB_txn, cursor: *mut MDB_cursor) -> ::libc::c_int;
1192 }
1193 extern "C" {
1194     #[doc = " @brief Return the cursor's transaction handle."]
1195     #[doc = ""]
1196     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
mdb_cursor_txn(cursor: *mut MDB_cursor) -> *mut MDB_txn1197     pub fn mdb_cursor_txn(cursor: *mut MDB_cursor) -> *mut MDB_txn;
1198 }
1199 extern "C" {
1200     #[doc = " @brief Return the cursor's database handle."]
1201     #[doc = ""]
1202     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
mdb_cursor_dbi(cursor: *mut MDB_cursor) -> MDB_dbi1203     pub fn mdb_cursor_dbi(cursor: *mut MDB_cursor) -> MDB_dbi;
1204 }
1205 extern "C" {
1206     #[doc = " @brief Retrieve by cursor."]
1207     #[doc = ""]
1208     #[doc = " This function retrieves key/data pairs from the database. The address and length"]
1209     #[doc = " of the key are returned in the object to which \\b key refers (except for the"]
1210     #[doc = " case of the #MDB_SET option, in which the \\b key object is unchanged), and"]
1211     #[doc = " the address and length of the data are returned in the object to which \\b data"]
1212     #[doc = " refers."]
1213     #[doc = " See #mdb_get() for restrictions on using the output values."]
1214     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
1215     #[doc = " @param[in,out] key The key for a retrieved item"]
1216     #[doc = " @param[in,out] data The data of a retrieved item"]
1217     #[doc = " @param[in] op A cursor operation #MDB_cursor_op"]
1218     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1219     #[doc = " errors are:"]
1220     #[doc = " <ul>"]
1221     #[doc = "\t<li>#MDB_NOTFOUND - no matching key found."]
1222     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1223     #[doc = " </ul>"]
mdb_cursor_get( cursor: *mut MDB_cursor, key: *mut MDB_val, data: *mut MDB_val, op: MDB_cursor_op, ) -> ::libc::c_int1224     pub fn mdb_cursor_get(
1225         cursor: *mut MDB_cursor,
1226         key: *mut MDB_val,
1227         data: *mut MDB_val,
1228         op: MDB_cursor_op,
1229     ) -> ::libc::c_int;
1230 }
1231 extern "C" {
1232     #[doc = " @brief Store by cursor."]
1233     #[doc = ""]
1234     #[doc = " This function stores key/data pairs into the database."]
1235     #[doc = " The cursor is positioned at the new item, or on failure usually near it."]
1236     #[doc = " @note Earlier documentation incorrectly said errors would leave the"]
1237     #[doc = " state of the cursor unchanged."]
1238     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
1239     #[doc = " @param[in] key The key operated on."]
1240     #[doc = " @param[in] data The data operated on."]
1241     #[doc = " @param[in] flags Options for this operation. This parameter"]
1242     #[doc = " must be set to 0 or one of the values described here."]
1243     #[doc = " <ul>"]
1244     #[doc = "\t<li>#MDB_CURRENT - replace the item at the current cursor position."]
1245     #[doc = "\t\tThe \\b key parameter must still be provided, and must match it."]
1246     #[doc = "\t\tIf using sorted duplicates (#MDB_DUPSORT) the data item must still"]
1247     #[doc = "\t\tsort into the same place. This is intended to be used when the"]
1248     #[doc = "\t\tnew data is the same size as the old. Otherwise it will simply"]
1249     #[doc = "\t\tperform a delete of the old record followed by an insert."]
1250     #[doc = "\t<li>#MDB_NODUPDATA - enter the new key/data pair only if it does not"]
1251     #[doc = "\t\talready appear in the database. This flag may only be specified"]
1252     #[doc = "\t\tif the database was opened with #MDB_DUPSORT. The function will"]
1253     #[doc = "\t\treturn #MDB_KEYEXIST if the key/data pair already appears in the"]
1254     #[doc = "\t\tdatabase."]
1255     #[doc = "\t<li>#MDB_NOOVERWRITE - enter the new key/data pair only if the key"]
1256     #[doc = "\t\tdoes not already appear in the database. The function will return"]
1257     #[doc = "\t\t#MDB_KEYEXIST if the key already appears in the database, even if"]
1258     #[doc = "\t\tthe database supports duplicates (#MDB_DUPSORT)."]
1259     #[doc = "\t<li>#MDB_RESERVE - reserve space for data of the given size, but"]
1260     #[doc = "\t\tdon't copy the given data. Instead, return a pointer to the"]
1261     #[doc = "\t\treserved space, which the caller can fill in later - before"]
1262     #[doc = "\t\tthe next update operation or the transaction ends. This saves"]
1263     #[doc = "\t\tan extra memcpy if the data is being generated later. This flag"]
1264     #[doc = "\t\tmust not be specified if the database was opened with #MDB_DUPSORT."]
1265     #[doc = "\t<li>#MDB_APPEND - append the given key/data pair to the end of the"]
1266     #[doc = "\t\tdatabase. No key comparisons are performed. This option allows"]
1267     #[doc = "\t\tfast bulk loading when keys are already known to be in the"]
1268     #[doc = "\t\tcorrect order. Loading unsorted keys with this flag will cause"]
1269     #[doc = "\t\ta #MDB_KEYEXIST error."]
1270     #[doc = "\t<li>#MDB_APPENDDUP - as above, but for sorted dup data."]
1271     #[doc = "\t<li>#MDB_MULTIPLE - store multiple contiguous data elements in a"]
1272     #[doc = "\t\tsingle request. This flag may only be specified if the database"]
1273     #[doc = "\t\twas opened with #MDB_DUPFIXED. The \\b data argument must be an"]
1274     #[doc = "\t\tarray of two MDB_vals. The mv_size of the first MDB_val must be"]
1275     #[doc = "\t\tthe size of a single data element. The mv_data of the first MDB_val"]
1276     #[doc = "\t\tmust point to the beginning of the array of contiguous data elements."]
1277     #[doc = "\t\tThe mv_size of the second MDB_val must be the count of the number"]
1278     #[doc = "\t\tof data elements to store. On return this field will be set to"]
1279     #[doc = "\t\tthe count of the number of elements actually written. The mv_data"]
1280     #[doc = "\t\tof the second MDB_val is unused."]
1281     #[doc = " </ul>"]
1282     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1283     #[doc = " errors are:"]
1284     #[doc = " <ul>"]
1285     #[doc = "\t<li>#MDB_MAP_FULL - the database is full, see #mdb_env_set_mapsize()."]
1286     #[doc = "\t<li>#MDB_TXN_FULL - the transaction has too many dirty pages."]
1287     #[doc = "\t<li>EACCES - an attempt was made to write in a read-only transaction."]
1288     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1289     #[doc = " </ul>"]
mdb_cursor_put( cursor: *mut MDB_cursor, key: *mut MDB_val, data: *mut MDB_val, flags: ::libc::c_uint, ) -> ::libc::c_int1290     pub fn mdb_cursor_put(
1291         cursor: *mut MDB_cursor,
1292         key: *mut MDB_val,
1293         data: *mut MDB_val,
1294         flags: ::libc::c_uint,
1295     ) -> ::libc::c_int;
1296 }
1297 extern "C" {
1298     #[doc = " @brief Delete current key/data pair"]
1299     #[doc = ""]
1300     #[doc = " This function deletes the key/data pair to which the cursor refers."]
1301     #[doc = " This does not invalidate the cursor, so operations such as MDB_NEXT"]
1302     #[doc = " can still be used on it."]
1303     #[doc = " Both MDB_NEXT and MDB_GET_CURRENT will return the same record after"]
1304     #[doc = " this operation."]
1305     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
1306     #[doc = " @param[in] flags Options for this operation. This parameter"]
1307     #[doc = " must be set to 0 or one of the values described here."]
1308     #[doc = " <ul>"]
1309     #[doc = "\t<li>#MDB_NODUPDATA - delete all of the data items for the current key."]
1310     #[doc = "\t\tThis flag may only be specified if the database was opened with #MDB_DUPSORT."]
1311     #[doc = " </ul>"]
1312     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1313     #[doc = " errors are:"]
1314     #[doc = " <ul>"]
1315     #[doc = "\t<li>EACCES - an attempt was made to write in a read-only transaction."]
1316     #[doc = "\t<li>EINVAL - an invalid parameter was specified."]
1317     #[doc = " </ul>"]
mdb_cursor_del(cursor: *mut MDB_cursor, flags: ::libc::c_uint) -> ::libc::c_int1318     pub fn mdb_cursor_del(cursor: *mut MDB_cursor, flags: ::libc::c_uint) -> ::libc::c_int;
1319 }
1320 extern "C" {
1321     #[doc = " @brief Return count of duplicates for current key."]
1322     #[doc = ""]
1323     #[doc = " This call is only valid on databases that support sorted duplicate"]
1324     #[doc = " data items #MDB_DUPSORT."]
1325     #[doc = " @param[in] cursor A cursor handle returned by #mdb_cursor_open()"]
1326     #[doc = " @param[out] countp Address where the count will be stored"]
1327     #[doc = " @return A non-zero error value on failure and 0 on success. Some possible"]
1328     #[doc = " errors are:"]
1329     #[doc = " <ul>"]
1330     #[doc = "\t<li>EINVAL - cursor is not initialized, or an invalid parameter was specified."]
1331     #[doc = " </ul>"]
mdb_cursor_count(cursor: *mut MDB_cursor, countp: *mut usize) -> ::libc::c_int1332     pub fn mdb_cursor_count(cursor: *mut MDB_cursor, countp: *mut usize) -> ::libc::c_int;
1333 }
1334 extern "C" {
1335     #[doc = " @brief Compare two data items according to a particular database."]
1336     #[doc = ""]
1337     #[doc = " This returns a comparison as if the two data items were keys in the"]
1338     #[doc = " specified database."]
1339     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1340     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
1341     #[doc = " @param[in] a The first item to compare"]
1342     #[doc = " @param[in] b The second item to compare"]
1343     #[doc = " @return < 0 if a < b, 0 if a == b, > 0 if a > b"]
mdb_cmp( txn: *mut MDB_txn, dbi: MDB_dbi, a: *const MDB_val, b: *const MDB_val, ) -> ::libc::c_int1344     pub fn mdb_cmp(
1345         txn: *mut MDB_txn,
1346         dbi: MDB_dbi,
1347         a: *const MDB_val,
1348         b: *const MDB_val,
1349     ) -> ::libc::c_int;
1350 }
1351 extern "C" {
1352     #[doc = " @brief Compare two data items according to a particular database."]
1353     #[doc = ""]
1354     #[doc = " This returns a comparison as if the two items were data items of"]
1355     #[doc = " the specified database. The database must have the #MDB_DUPSORT flag."]
1356     #[doc = " @param[in] txn A transaction handle returned by #mdb_txn_begin()"]
1357     #[doc = " @param[in] dbi A database handle returned by #mdb_dbi_open()"]
1358     #[doc = " @param[in] a The first item to compare"]
1359     #[doc = " @param[in] b The second item to compare"]
1360     #[doc = " @return < 0 if a < b, 0 if a == b, > 0 if a > b"]
mdb_dcmp( txn: *mut MDB_txn, dbi: MDB_dbi, a: *const MDB_val, b: *const MDB_val, ) -> ::libc::c_int1361     pub fn mdb_dcmp(
1362         txn: *mut MDB_txn,
1363         dbi: MDB_dbi,
1364         a: *const MDB_val,
1365         b: *const MDB_val,
1366     ) -> ::libc::c_int;
1367 }
1368 #[doc = " @brief A callback function used to print a message from the library."]
1369 #[doc = ""]
1370 #[doc = " @param[in] msg The string to be printed."]
1371 #[doc = " @param[in] ctx An arbitrary context pointer for the callback."]
1372 #[doc = " @return < 0 on failure, >= 0 on success."]
1373 pub type MDB_msg_func = ::std::option::Option<
1374     unsafe extern "C" fn(msg: *const ::libc::c_char, ctx: *mut ::libc::c_void) -> ::libc::c_int,
1375 >;
1376 extern "C" {
1377     #[doc = " @brief Dump the entries in the reader lock table."]
1378     #[doc = ""]
1379     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
1380     #[doc = " @param[in] func A #MDB_msg_func function"]
1381     #[doc = " @param[in] ctx Anything the message function needs"]
1382     #[doc = " @return < 0 on failure, >= 0 on success."]
mdb_reader_list( env: *mut MDB_env, func: MDB_msg_func, ctx: *mut ::libc::c_void, ) -> ::libc::c_int1383     pub fn mdb_reader_list(
1384         env: *mut MDB_env,
1385         func: MDB_msg_func,
1386         ctx: *mut ::libc::c_void,
1387     ) -> ::libc::c_int;
1388 }
1389 extern "C" {
1390     #[doc = " @brief Check for stale entries in the reader lock table."]
1391     #[doc = ""]
1392     #[doc = " @param[in] env An environment handle returned by #mdb_env_create()"]
1393     #[doc = " @param[out] dead Number of stale slots that were cleared"]
1394     #[doc = " @return 0 on success, non-zero on failure."]
mdb_reader_check(env: *mut MDB_env, dead: *mut ::libc::c_int) -> ::libc::c_int1395     pub fn mdb_reader_check(env: *mut MDB_env, dead: *mut ::libc::c_int) -> ::libc::c_int;
1396 }
1397