1pub const MDB_FMT_Z: &[u8; 2] = b"z\0";
4pub const MDB_SIZE_MAX: u64 = 18446744073709551615;
5pub const MDB_VERSION_MAJOR: ::libc::c_uint = 0;
6pub const MDB_VERSION_MINOR: ::libc::c_uint = 9;
7pub const MDB_VERSION_PATCH: ::libc::c_uint = 70;
8pub const MDB_VERSION_DATE: &[u8; 18] = b"December 19, 2015\0";
9pub const MDB_FIXEDMAP: ::libc::c_uint = 1;
10pub const MDB_NOSUBDIR: ::libc::c_uint = 16384;
11pub const MDB_NOSYNC: ::libc::c_uint = 65536;
12pub const MDB_RDONLY: ::libc::c_uint = 131072;
13pub const MDB_NOMETASYNC: ::libc::c_uint = 262144;
14pub const MDB_WRITEMAP: ::libc::c_uint = 524288;
15pub const MDB_MAPASYNC: ::libc::c_uint = 1048576;
16pub const MDB_NOTLS: ::libc::c_uint = 2097152;
17pub const MDB_NOLOCK: ::libc::c_uint = 4194304;
18pub const MDB_NORDAHEAD: ::libc::c_uint = 8388608;
19pub const MDB_NOMEMINIT: ::libc::c_uint = 16777216;
20pub const MDB_PREVSNAPSHOT: ::libc::c_uint = 33554432;
21pub const MDB_REVERSEKEY: ::libc::c_uint = 2;
22pub const MDB_DUPSORT: ::libc::c_uint = 4;
23pub const MDB_INTEGERKEY: ::libc::c_uint = 8;
24pub const MDB_DUPFIXED: ::libc::c_uint = 16;
25pub const MDB_INTEGERDUP: ::libc::c_uint = 32;
26pub const MDB_REVERSEDUP: ::libc::c_uint = 64;
27pub const MDB_CREATE: ::libc::c_uint = 262144;
28pub const MDB_NOOVERWRITE: ::libc::c_uint = 16;
29pub const MDB_NODUPDATA: ::libc::c_uint = 32;
30pub const MDB_CURRENT: ::libc::c_uint = 64;
31pub const MDB_RESERVE: ::libc::c_uint = 65536;
32pub const MDB_APPEND: ::libc::c_uint = 131072;
33pub const MDB_APPENDDUP: ::libc::c_uint = 262144;
34pub const MDB_MULTIPLE: ::libc::c_uint = 524288;
35pub const MDB_CP_COMPACT: ::libc::c_uint = 1;
36pub const MDB_SUCCESS: ::libc::c_int = 0;
37pub const MDB_KEYEXIST: ::libc::c_int = -30799;
38pub const MDB_NOTFOUND: ::libc::c_int = -30798;
39pub const MDB_PAGE_NOTFOUND: ::libc::c_int = -30797;
40pub const MDB_CORRUPTED: ::libc::c_int = -30796;
41pub const MDB_PANIC: ::libc::c_int = -30795;
42pub const MDB_VERSION_MISMATCH: ::libc::c_int = -30794;
43pub const MDB_INVALID: ::libc::c_int = -30793;
44pub const MDB_MAP_FULL: ::libc::c_int = -30792;
45pub const MDB_DBS_FULL: ::libc::c_int = -30791;
46pub const MDB_READERS_FULL: ::libc::c_int = -30790;
47pub const MDB_TLS_FULL: ::libc::c_int = -30789;
48pub const MDB_TXN_FULL: ::libc::c_int = -30788;
49pub const MDB_CURSOR_FULL: ::libc::c_int = -30787;
50pub const MDB_PAGE_FULL: ::libc::c_int = -30786;
51pub const MDB_MAP_RESIZED: ::libc::c_int = -30785;
52pub const MDB_INCOMPATIBLE: ::libc::c_int = -30784;
53pub const MDB_BAD_RSLOT: ::libc::c_int = -30783;
54pub const MDB_BAD_TXN: ::libc::c_int = -30782;
55pub const MDB_BAD_VALSIZE: ::libc::c_int = -30781;
56pub const MDB_BAD_DBI: ::libc::c_int = -30780;
57pub const MDB_PROBLEM: ::libc::c_int = -30779;
58pub const MDB_LAST_ERRCODE: ::libc::c_int = -30779;
59#[doc = "Unsigned type used for mapsize, entry counts and page/transaction IDs.\n\n\tIt is normally size_t, hence the name. Defining MDB_VL32 makes it\n\tuint64_t, but do not try this unless you know what you are doing."]
60pub type mdb_size_t = usize;
61#[repr(C)]
62#[derive(Debug, Copy, Clone)]
63pub struct MDB_env {
64 _unused: [u8; 0],
65}
66#[repr(C)]
67#[derive(Debug, Copy, Clone)]
68pub struct MDB_txn {
69 _unused: [u8; 0],
70}
71#[doc = "A handle for an individual database in the DB environment."]
72pub type MDB_dbi = ::libc::c_uint;
73#[repr(C)]
74#[derive(Debug, Copy, Clone)]
75pub struct MDB_cursor {
76 _unused: [u8; 0],
77}
78#[doc = "Generic structure used for passing keys and data in and out\n of the database.\n\n Values returned from the database are valid only until a subsequent\n update operation, or the end of the transaction. Do not modify or\n free them, they commonly point into the database itself.\n\n Key sizes must be between 1 and #mdb_env_get_maxkeysize() inclusive.\n The same applies to data sizes in databases with the #MDB_DUPSORT flag.\n Other data items can in theory be from 0 to 0xffffffff bytes long."]
79#[repr(C)]
80#[derive(Debug, Copy, Clone)]
81pub struct MDB_val {
82 #[doc = "< size of the data item"]
83 pub mv_size: usize,
84 #[doc = "< address of the data item"]
85 pub mv_data: *mut ::libc::c_void,
86}
87#[doc = "A callback function used to compare two keys in a database"]
88pub type MDB_cmp_func = ::std::option::Option<
89 unsafe extern "C" fn(a: *const MDB_val, b: *const MDB_val) -> ::libc::c_int,
90>;
91#[doc = "A callback function used to relocate a position-dependent data item\n in a fixed-address database.\n\n The **newptr** gives the item's desired address in\n the memory map, and **oldptr** gives its previous address. The item's actual\n data resides at the address in **item.** This callback is expected to walk\n through the fields of the record in **item** and modify any\n values based at the **oldptr** address to be relative to the **newptr** address.\n # Arguments\n\n* `item` (direction in, out) - The item that is to be relocated.\n * `oldptr` (direction in) - The previous address.\n * `newptr` (direction in) - The new address to relocate to.\n * `relctx` (direction in) - An application-provided context, set by #mdb_set_relctx().\n This feature is currently unimplemented."]
92pub type MDB_rel_func = ::std::option::Option<
93 unsafe extern "C" fn(
94 item: *mut MDB_val,
95 oldptr: *mut ::libc::c_void,
96 newptr: *mut ::libc::c_void,
97 relctx: *mut ::libc::c_void,
98 ),
99>;
100#[doc = "< Position at first key/data item"]
101pub const MDB_FIRST: MDB_cursor_op = 0;
102#[doc = "< Position at first data item of current key.\nOnly for #MDB_DUPSORT"]
103pub const MDB_FIRST_DUP: MDB_cursor_op = 1;
104#[doc = "< Position at key/data pair. Only for #MDB_DUPSORT"]
105pub const MDB_GET_BOTH: MDB_cursor_op = 2;
106#[doc = "< position at key, nearest data. Only for #MDB_DUPSORT"]
107pub const MDB_GET_BOTH_RANGE: MDB_cursor_op = 3;
108#[doc = "< Return key/data at current cursor position"]
109pub const MDB_GET_CURRENT: MDB_cursor_op = 4;
110#[doc = "< Return up to a page of duplicate data items\nfrom current cursor position. Move cursor to prepare\nfor #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED"]
111pub const MDB_GET_MULTIPLE: MDB_cursor_op = 5;
112#[doc = "< Position at last key/data item"]
113pub const MDB_LAST: MDB_cursor_op = 6;
114#[doc = "< Position at last data item of current key.\nOnly for #MDB_DUPSORT"]
115pub const MDB_LAST_DUP: MDB_cursor_op = 7;
116#[doc = "< Position at next data item"]
117pub const MDB_NEXT: MDB_cursor_op = 8;
118#[doc = "< Position at next data item of current key.\nOnly for #MDB_DUPSORT"]
119pub const MDB_NEXT_DUP: MDB_cursor_op = 9;
120#[doc = "< Return up to a page of duplicate data items\nfrom next cursor position. Move cursor to prepare\nfor #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED"]
121pub const MDB_NEXT_MULTIPLE: MDB_cursor_op = 10;
122#[doc = "< Position at first data item of next key"]
123pub const MDB_NEXT_NODUP: MDB_cursor_op = 11;
124#[doc = "< Position at previous data item"]
125pub const MDB_PREV: MDB_cursor_op = 12;
126#[doc = "< Position at previous data item of current key.\nOnly for #MDB_DUPSORT"]
127pub const MDB_PREV_DUP: MDB_cursor_op = 13;
128#[doc = "< Position at last data item of previous key"]
129pub const MDB_PREV_NODUP: MDB_cursor_op = 14;
130#[doc = "< Position at specified key"]
131pub const MDB_SET: MDB_cursor_op = 15;
132#[doc = "< Position at specified key, return key + data"]
133pub const MDB_SET_KEY: MDB_cursor_op = 16;
134#[doc = "< Position at first key greater than or equal to specified key."]
135pub const MDB_SET_RANGE: MDB_cursor_op = 17;
136#[doc = "< Position at previous page and return up to\na page of duplicate data items. Only for #MDB_DUPFIXED"]
137pub const MDB_PREV_MULTIPLE: MDB_cursor_op = 18;
138#[doc = "Cursor Get operations.\n\n\tThis is the set of all operations for retrieving data\n\tusing a cursor."]
139pub type MDB_cursor_op = ::libc::c_uint;
140#[doc = "Statistics for a database in the environment"]
141#[repr(C)]
142#[derive(Debug, Copy, Clone)]
143pub struct MDB_stat {
144 #[doc = "< Size of a database page.\nThis is currently the same for all databases."]
145 pub ms_psize: ::libc::c_uint,
146 #[doc = "< Depth (height) of the B-tree"]
147 pub ms_depth: ::libc::c_uint,
148 #[doc = "< Number of internal (non-leaf) pages"]
149 pub ms_branch_pages: mdb_size_t,
150 #[doc = "< Number of leaf pages"]
151 pub ms_leaf_pages: mdb_size_t,
152 #[doc = "< Number of overflow pages"]
153 pub ms_overflow_pages: mdb_size_t,
154 #[doc = "< Number of data items"]
155 pub ms_entries: mdb_size_t,
156}
157#[doc = "Information about the environment"]
158#[repr(C)]
159#[derive(Debug, Copy, Clone)]
160pub struct MDB_envinfo {
161 #[doc = "< Address of map, if fixed"]
162 pub me_mapaddr: *mut ::libc::c_void,
163 #[doc = "< Size of the data memory map"]
164 pub me_mapsize: mdb_size_t,
165 #[doc = "< ID of the last used page"]
166 pub me_last_pgno: mdb_size_t,
167 #[doc = "< ID of the last committed transaction"]
168 pub me_last_txnid: mdb_size_t,
169 #[doc = "< max reader slots in the environment"]
170 pub me_maxreaders: ::libc::c_uint,
171 #[doc = "< max reader slots used in the environment"]
172 pub me_numreaders: ::libc::c_uint,
173}
174extern "C" {
175 #[doc = "Return the LMDB library version information.\n\n # Arguments\n\n* `major` (direction out) - if non-NULL, the library major version number is copied here\n * `minor` (direction out) - if non-NULL, the library minor version number is copied here\n * `patch` (direction out) - if non-NULL, the library patch version number is copied here\n # Returns\n\n* `\"version` - string\" The library version as a string"]
176 pub fn mdb_version(
177 major: *mut ::libc::c_int,
178 minor: *mut ::libc::c_int,
179 patch: *mut ::libc::c_int,
180 ) -> *mut ::libc::c_char;
181}
182extern "C" {
183 #[doc = "Return a string describing a given error code.\n\n This function is a superset of the ANSI C X3.159-1989 (ANSI C) strerror(3)\n function. If the error code is greater than or equal to 0, then the string\n returned by the system function strerror(3) is returned. If the error code\n is less than 0, an error string corresponding to the LMDB library error is\n returned. See errors for a list of LMDB-specific error codes.\n # Arguments\n\n* `err` (direction in) - The error code\n # Returns\n\n* `\"error` - message\" The description of the error"]
184 pub fn mdb_strerror(err: ::libc::c_int) -> *mut ::libc::c_char;
185}
186extern "C" {
187 #[doc = "Create an LMDB environment handle.\n\n This function allocates memory for a #MDB_env structure. To release\n the allocated memory and discard the handle, call #mdb_env_close().\n Before the handle may be used, it must be opened using #mdb_env_open().\n Various other options may also need to be set before opening the handle,\n e.g. #mdb_env_set_mapsize(), #mdb_env_set_maxreaders(), #mdb_env_set_maxdbs(),\n depending on usage requirements.\n # Arguments\n\n* `env` (direction out) - The address where the new handle will be stored\n # Returns\n\nA non-zero error value on failure and 0 on success."]
188 pub fn mdb_env_create(env: *mut *mut MDB_env) -> ::libc::c_int;
189}
190extern "C" {
191 #[doc = "Open an environment handle.\n\n If this function fails, #mdb_env_close() must be called to discard the #MDB_env handle.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `path` (direction in) - The directory in which the database files reside. This\n directory must already exist and be writable.\n * `flags` (direction in) - Special options for this environment. This parameter\n must be set to 0 or by bitwise OR'ing together one or more of the\n values described here.\n Flags set by mdb_env_set_flags() are also used.\n <ul>\n\t<li>#MDB_FIXEDMAP\n use a fixed address for the mmap region. This flag must be specified\n when creating the environment, and is stored persistently in the environment.\n\t\tIf successful, the memory map will always reside at the same virtual address\n\t\tand pointers used to reference data items in the database will be constant\n\t\tacross multiple invocations. This option may not always work, depending on\n\t\thow the operating system has allocated memory to shared libraries and other uses.\n\t\tThe feature is highly experimental.\n\t<li>#MDB_NOSUBDIR\n\t\tBy default, LMDB creates its environment in a directory whose\n\t\tpathname is given in **path,** and creates its data and lock files\n\t\tunder that directory. With this option, **path** is used as-is for\n\t\tthe database main data file. The database lock file is the **path**\n\t\twith \"-lock\" appended.\n\t<li>#MDB_RDONLY\n\t\tOpen the environment in read-only mode. No write operations will be\n\t\tallowed. LMDB will still modify the lock file - except on read-only\n\t\tfilesystems, where LMDB does not use locks.\n\t<li>#MDB_WRITEMAP\n\t\tUse a writeable memory map unless MDB_RDONLY is set. This uses\n\t\tfewer mallocs but loses protection from application bugs\n\t\tlike wild pointer writes and other bad updates into the database.\n\t\tThis may be slightly faster for DBs that fit entirely in RAM, but\n\t\tis slower for DBs larger than RAM.\n\t\tIncompatible with nested transactions.\n\t\tDo not mix processes with and without MDB_WRITEMAP on the same\n\t\tenvironment. This can defeat durability (#mdb_env_sync etc).\n\t<li>#MDB_NOMETASYNC\n\t\tFlush system buffers to disk only once per transaction, omit the\n\t\tmetadata flush. Defer that until the system flushes files to disk,\n\t\tor next non-MDB_RDONLY commit or #mdb_env_sync(). This optimization\n\t\tmaintains database integrity, but a system crash may undo the last\n\t\tcommitted transaction. I.e. it preserves the ACI (atomicity,\n\t\tconsistency, isolation) but not D (durability) database property.\n\t\tThis flag may be changed at any time using #mdb_env_set_flags().\n\t<li>#MDB_NOSYNC\n\t\tDon't flush system buffers to disk when committing a transaction.\n\t\tThis optimization means a system crash can corrupt the database or\n\t\tlose the last transactions if buffers are not yet flushed to disk.\n\t\tThe risk is governed by how often the system flushes dirty buffers\n\t\tto disk and how often #mdb_env_sync() is called. However, if the\n\t\tfilesystem preserves write order and the #MDB_WRITEMAP flag is not\n\t\tused, transactions exhibit ACI (atomicity, consistency, isolation)\n\t\tproperties and only lose D (durability). I.e. database integrity\n\t\tis maintained, but a system crash may undo the final transactions.\n\t\tNote that (#MDB_NOSYNC | #MDB_WRITEMAP) leaves the system with no\n\t\thint for when to write transactions to disk, unless #mdb_env_sync()\n\t\tis called. (#MDB_MAPASYNC | #MDB_WRITEMAP) may be preferable.\n\t\tThis flag may be changed at any time using #mdb_env_set_flags().\n\t<li>#MDB_MAPASYNC\n\t\tWhen using #MDB_WRITEMAP, use asynchronous flushes to disk.\n\t\tAs with #MDB_NOSYNC, a system crash can then corrupt the\n\t\tdatabase or lose the last transactions. Calling #mdb_env_sync()\n\t\tensures on-disk database integrity until next commit.\n\t\tThis flag may be changed at any time using #mdb_env_set_flags().\n\t<li>#MDB_NOTLS\n\t\tDon't use Thread-Local Storage. Tie reader locktable slots to\n\t\t#MDB_txn objects instead of to threads. I.e. #mdb_txn_reset() keeps\n\t\tthe slot reserved for the #MDB_txn object. A thread may use parallel\n\t\tread-only transactions. A read-only transaction may span threads if\n\t\tthe user synchronizes its use. Applications that multiplex many\n\t\tuser threads over individual OS threads need this option. Such an\n\t\tapplication must also serialize the write transactions in an OS\n\t\tthread, since LMDB's write locking is unaware of the user threads.\n\t<li>#MDB_NOLOCK\n\t\tDon't do any locking. If concurrent access is anticipated, the\n\t\tcaller must manage all concurrency itself. For proper operation\n\t\tthe caller must enforce single-writer semantics, and must ensure\n\t\tthat no readers are using old transactions while a writer is\n\t\tactive. The simplest approach is to use an exclusive lock so that\n\t\tno readers may be active at all when a writer begins.\n\t<li>#MDB_NORDAHEAD\n\t\tTurn off readahead. Most operating systems perform readahead on\n\t\tread requests by default. This option turns it off if the OS\n\t\tsupports it. Turning it off may help random read performance\n\t\twhen the DB is larger than RAM and system RAM is full.\n\t\tThe option is not implemented on Windows.\n\t<li>#MDB_NOMEMINIT\n\t\tDon't initialize malloc'd memory before writing to unused spaces\n\t\tin the data file. By default, memory for pages written to the data\n\t\tfile is obtained using malloc. While these pages may be reused in\n\t\tsubsequent transactions, freshly malloc'd pages will be initialized\n\t\tto zeroes before use. This avoids persisting leftover data from other\n\t\tcode (that used the heap and subsequently freed the memory) into the\n\t\tdata file. Note that many other system libraries may allocate\n\t\tand free memory from the heap for arbitrary uses. E.g., stdio may\n\t\tuse the heap for file I/O buffers. This initialization step has a\n\t\tmodest performance cost so some applications may want to disable\n\t\tit using this flag. This option can be a problem for applications\n\t\twhich handle sensitive data like passwords, and it makes memory\n\t\tcheckers like Valgrind noisy. This flag is not needed with #MDB_WRITEMAP,\n\t\twhich writes directly to the mmap instead of using malloc for pages. The\n\t\tinitialization is also skipped if #MDB_RESERVE is used; the\n\t\tcaller is expected to overwrite all of the memory that was\n\t\treserved in that case.\n\t\tThis flag may be changed at any time using #mdb_env_set_flags().\n\t<li>#MDB_PREVSNAPSHOT\n\t\tOpen the environment with the previous snapshot rather than the latest\n\t\tone. This loses the latest transaction, but may help work around some\n\t\ttypes of corruption. If opened with write access, this must be the\n\t\tonly process using the environment. This flag is automatically reset\n\t\tafter a write transaction is successfully committed.\n </ul>\n * `mode` (direction in) - The UNIX permissions to set on created files and semaphores.\n This parameter is ignored on Windows.\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_VERSION_MISMATCH - the version of the LMDB library doesn't match the\n\tversion that created the database environment.\n\t<li>#MDB_INVALID - the environment file headers are corrupted.\n\t<li>ENOENT - the directory specified by the path parameter doesn't exist.\n\t<li>EACCES - the user didn't have permission to access the environment files.\n\t<li>EAGAIN - the environment was locked by another process.\n </ul>"]
192 pub fn mdb_env_open(
193 env: *mut MDB_env,
194 path: *const ::libc::c_char,
195 flags: ::libc::c_uint,
196 mode: mdb_mode_t,
197 ) -> ::libc::c_int;
198}
199extern "C" {
200 #[doc = "Copy an LMDB environment to the specified path.\n\n This function may be used to make a backup of an existing environment.\n No lockfile is created, since it gets recreated at need.\n > **Note:** This call can trigger significant file size growth if run in\n parallel with write transactions, because it employs a read-only\n transaction. See long-lived transactions under caveats_sec.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create(). It\n must have already been opened successfully.\n * `path` (direction in) - The directory in which the copy will reside. This\n directory must already exist and be writable but must otherwise be\n empty.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
201 pub fn mdb_env_copy(env: *mut MDB_env, path: *const ::libc::c_char) -> ::libc::c_int;
202}
203extern "C" {
204 #[doc = "Copy an LMDB environment to the specified file descriptor.\n\n This function may be used to make a backup of an existing environment.\n No lockfile is created, since it gets recreated at need.\n > **Note:** This call can trigger significant file size growth if run in\n parallel with write transactions, because it employs a read-only\n transaction. See long-lived transactions under caveats_sec.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create(). It\n must have already been opened successfully.\n * `fd` (direction in) - The filedescriptor to write the copy to. It must\n have already been opened for Write access.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
205 pub fn mdb_env_copyfd(env: *mut MDB_env, fd: mdb_filehandle_t) -> ::libc::c_int;
206}
207extern "C" {
208 #[doc = "Copy an LMDB environment to the specified path, with options.\n\n This function may be used to make a backup of an existing environment.\n No lockfile is created, since it gets recreated at need.\n > **Note:** This call can trigger significant file size growth if run in\n parallel with write transactions, because it employs a read-only\n transaction. See long-lived transactions under caveats_sec.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create(). It\n must have already been opened successfully.\n * `path` (direction in) - The directory in which the copy will reside. This\n directory must already exist and be writable but must otherwise be\n empty.\n * `flags` (direction in) - Special options for this operation. This parameter\n must be set to 0 or by bitwise OR'ing together one or more of the\n values described here.\n <ul>\n\t<li>#MDB_CP_COMPACT - Perform compaction while copying: omit free\n\t\tpages and sequentially renumber all pages in output. This option\n\t\tconsumes more CPU and runs more slowly than the default.\n\t\tCurrently it fails if the environment has suffered a page leak.\n </ul>\n # Returns\n\nA non-zero error value on failure and 0 on success."]
209 pub fn mdb_env_copy2(
210 env: *mut MDB_env,
211 path: *const ::libc::c_char,
212 flags: ::libc::c_uint,
213 ) -> ::libc::c_int;
214}
215extern "C" {
216 #[doc = "Copy an LMDB environment to the specified file descriptor,\n\twith options.\n\n This function may be used to make a backup of an existing environment.\n No lockfile is created, since it gets recreated at need. See\n #mdb_env_copy2() for further details.\n > **Note:** This call can trigger significant file size growth if run in\n parallel with write transactions, because it employs a read-only\n transaction. See long-lived transactions under caveats_sec.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create(). It\n must have already been opened successfully.\n * `fd` (direction in) - The filedescriptor to write the copy to. It must\n have already been opened for Write access.\n * `flags` (direction in) - Special options for this operation.\n See #mdb_env_copy2() for options.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
217 pub fn mdb_env_copyfd2(
218 env: *mut MDB_env,
219 fd: mdb_filehandle_t,
220 flags: ::libc::c_uint,
221 ) -> ::libc::c_int;
222}
223extern "C" {
224 #[doc = "Return statistics about the LMDB environment.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `stat` (direction out) - The address of an #MDB_stat structure\n \twhere the statistics will be copied"]
225 pub fn mdb_env_stat(env: *mut MDB_env, stat: *mut MDB_stat) -> ::libc::c_int;
226}
227extern "C" {
228 #[doc = "Return information about the LMDB environment.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `stat` (direction out) - The address of an #MDB_envinfo structure\n \twhere the information will be copied"]
229 pub fn mdb_env_info(env: *mut MDB_env, stat: *mut MDB_envinfo) -> ::libc::c_int;
230}
231extern "C" {
232 #[doc = "Flush the data buffers to disk.\n\n Data is always written to disk when #mdb_txn_commit() is called,\n but the operating system may keep it buffered. LMDB always flushes\n the OS buffers upon commit as well, unless the environment was\n opened with #MDB_NOSYNC or in part #MDB_NOMETASYNC. This call is\n not valid if the environment was opened with #MDB_RDONLY.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `force` (direction in) - If non-zero, force a synchronous flush. Otherwise\n if the environment has the #MDB_NOSYNC flag set the flushes\n\twill be omitted, and with #MDB_MAPASYNC they will be asynchronous.\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EACCES - the environment is read-only.\n\t<li>EINVAL - an invalid parameter was specified.\n\t<li>EIO - an error occurred during synchronization.\n </ul>"]
233 pub fn mdb_env_sync(env: *mut MDB_env, force: ::libc::c_int) -> ::libc::c_int;
234}
235extern "C" {
236 #[doc = "Close the environment and release the memory map.\n\n Only a single thread may call this function. All transactions, databases,\n and cursors must already be closed before calling this function. Attempts to\n use any such handles after calling this function will cause a SIGSEGV.\n The environment handle will be freed and must not be used again after this call.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()"]
237 pub fn mdb_env_close(env: *mut MDB_env);
238}
239extern "C" {
240 #[doc = "Set environment flags.\n\n This may be used to set some flags in addition to those from\n #mdb_env_open(), or to unset these flags. If several threads\n change the flags at the same time, the result is undefined.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `flags` (direction in) - The flags to change, bitwise OR'ed together\n * `onoff` (direction in) - A non-zero value sets the flags, zero clears them.\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
241 pub fn mdb_env_set_flags(
242 env: *mut MDB_env,
243 flags: ::libc::c_uint,
244 onoff: ::libc::c_int,
245 ) -> ::libc::c_int;
246}
247extern "C" {
248 #[doc = "Get environment flags.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `flags` (direction out) - The address of an integer to store the flags\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
249 pub fn mdb_env_get_flags(env: *mut MDB_env, flags: *mut ::libc::c_uint) -> ::libc::c_int;
250}
251extern "C" {
252 #[doc = "Return the path that was used in #mdb_env_open().\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `path` (direction out) - Address of a string pointer to contain the path. This\n is the actual string in the environment, not a copy. It should not be\n altered in any way.\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
253 pub fn mdb_env_get_path(env: *mut MDB_env, path: *mut *const ::libc::c_char) -> ::libc::c_int;
254}
255extern "C" {
256 #[doc = "Return the filedescriptor for the given environment.\n\n This function may be called after fork(), so the descriptor can be\n closed before exec*(). Other LMDB file descriptors have FD_CLOEXEC.\n (Until LMDB 0.9.18, only the lockfile had that.)\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `fd` (direction out) - Address of a mdb_filehandle_t to contain the descriptor.\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
257 pub fn mdb_env_get_fd(env: *mut MDB_env, fd: *mut mdb_filehandle_t) -> ::libc::c_int;
258}
259extern "C" {
260 #[doc = "Set the size of the memory map to use for this environment.\n\n The size should be a multiple of the OS page size. The default is\n 10485760 bytes. The size of the memory map is also the maximum size\n of the database. The value should be chosen as large as possible,\n to accommodate future growth of the database.\n This function should be called after #mdb_env_create() and before #mdb_env_open().\n It may be called at later times if no transactions are active in\n this process. Note that the library does not check for this condition,\n the caller must ensure it explicitly.\n\n The new size takes effect immediately for the current process but\n will not be persisted to any others until a write transaction has been\n committed by the current process. Also, only mapsize increases are\n persisted into the environment.\n\n If the mapsize is increased by another process, and data has grown\n beyond the range of the current mapsize, #mdb_txn_begin() will\n return #MDB_MAP_RESIZED. This function may be called with a size\n of zero to adopt the new size.\n\n Any attempt to set a size smaller than the space already consumed\n by the environment will be silently changed to the current size of the used space.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `size` (direction in) - The size in bytes\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified, or the environment has\n \tan active write transaction.\n </ul>"]
261 pub fn mdb_env_set_mapsize(env: *mut MDB_env, size: mdb_size_t) -> ::libc::c_int;
262}
263extern "C" {
264 #[doc = "Set the maximum number of threads/reader slots for the environment.\n\n This defines the number of slots in the lock table that is used to track readers in the\n the environment. The default is 126.\n Starting a read-only transaction normally ties a lock table slot to the\n current thread until the environment closes or the thread exits. If\n MDB_NOTLS is in use, #mdb_txn_begin() instead ties the slot to the\n MDB_txn object until it or the #MDB_env object is destroyed.\n This function may only be called after #mdb_env_create() and before #mdb_env_open().\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `readers` (direction in) - The maximum number of reader lock table slots\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified, or the environment is already open.\n </ul>"]
265 pub fn mdb_env_set_maxreaders(env: *mut MDB_env, readers: ::libc::c_uint) -> ::libc::c_int;
266}
267extern "C" {
268 #[doc = "Get the maximum number of threads/reader slots for the environment.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `readers` (direction out) - Address of an integer to store the number of readers\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
269 pub fn mdb_env_get_maxreaders(env: *mut MDB_env, readers: *mut ::libc::c_uint)
270 -> ::libc::c_int;
271}
272extern "C" {
273 #[doc = "Set the maximum number of named databases for the environment.\n\n This function is only needed if multiple databases will be used in the\n environment. Simpler applications that use the environment as a single\n unnamed database can ignore this option.\n This function may only be called after #mdb_env_create() and before #mdb_env_open().\n\n Currently a moderate number of slots are cheap but a huge number gets\n expensive: 7-120 words per transaction, and every #mdb_dbi_open()\n does a linear search of the opened slots.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `dbs` (direction in) - The maximum number of databases\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified, or the environment is already open.\n </ul>"]
274 pub fn mdb_env_set_maxdbs(env: *mut MDB_env, dbs: MDB_dbi) -> ::libc::c_int;
275}
276extern "C" {
277 #[doc = "Get the maximum size of keys and #MDB_DUPSORT data we can write.\n\n Depends on the compile-time constant #MDB_MAXKEYSIZE. Default 511.\n See MDB_val.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n # Returns\n\nThe maximum size of a key we can write"]
278 pub fn mdb_env_get_maxkeysize(env: *mut MDB_env) -> ::libc::c_int;
279}
280extern "C" {
281 #[doc = "Set application information associated with the #MDB_env.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `ctx` (direction in) - An arbitrary pointer for whatever the application needs.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
282 pub fn mdb_env_set_userctx(env: *mut MDB_env, ctx: *mut ::libc::c_void) -> ::libc::c_int;
283}
284extern "C" {
285 #[doc = "Get the application information associated with the #MDB_env.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n # Returns\n\nThe pointer set by #mdb_env_set_userctx()."]
286 pub fn mdb_env_get_userctx(env: *mut MDB_env) -> *mut ::libc::c_void;
287}
288#[doc = "A callback function for most LMDB assert() failures,\n called before printing the message and aborting.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create().\n * `msg` (direction in) - The assertion message, not including newline."]
289pub type MDB_assert_func =
290 ::std::option::Option<unsafe extern "C" fn(env: *mut MDB_env, msg: *const ::libc::c_char)>;
291extern "C" {
292 #[doc = "Set or reset the assert() callback of the environment.\n Disabled if liblmdb is built with NDEBUG.\n > **Note:** This hack should become obsolete as lmdb's error handling matures.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create().\n * `func` (direction in) - An #MDB_assert_func function, or 0.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
293 pub fn mdb_env_set_assert(env: *mut MDB_env, func: MDB_assert_func) -> ::libc::c_int;
294}
295extern "C" {
296 #[doc = "Create a transaction for use with the environment.\n\n The transaction handle may be discarded using #mdb_txn_abort() or #mdb_txn_commit().\n > **Note:** A transaction and its cursors must only be used by a single\n thread, and a thread may only have a single transaction at a time.\n If #MDB_NOTLS is in use, this does not apply to read-only transactions.\n > **Note:** Cursors may not span transactions.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `parent` (direction in) - If this parameter is non-NULL, the new transaction\n will be a nested transaction, with the transaction indicated by **parent**\n as its parent. Transactions may be nested to any level. A parent\n transaction and its cursors may not issue any other operations than\n mdb_txn_commit and mdb_txn_abort while it has active child transactions.\n * `flags` (direction in) - Special options for this transaction. This parameter\n must be set to 0 or by bitwise OR'ing together one or more of the\n values described here.\n <ul>\n\t<li>#MDB_RDONLY\n\t\tThis transaction will not perform any write operations.\n\t<li>#MDB_NOSYNC\n\t\tDon't flush system buffers to disk when committing this transaction.\n\t<li>#MDB_NOMETASYNC\n\t\tFlush system buffers but omit metadata flush when committing this transaction.\n </ul>\n * `txn` (direction out) - Address where the new #MDB_txn handle will be stored\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_PANIC - a fatal error occurred earlier and the environment\n\t\tmust be shut down.\n\t<li>#MDB_MAP_RESIZED - another process wrote data beyond this MDB_env's\n\t\tmapsize and this environment's map must be resized as well.\n\t\tSee #mdb_env_set_mapsize().\n\t<li>#MDB_READERS_FULL - a read-only transaction was requested and\n\t\tthe reader lock table is full. See #mdb_env_set_maxreaders().\n\t<li>ENOMEM - out of memory.\n </ul>"]
297 pub fn mdb_txn_begin(
298 env: *mut MDB_env,
299 parent: *mut MDB_txn,
300 flags: ::libc::c_uint,
301 txn: *mut *mut MDB_txn,
302 ) -> ::libc::c_int;
303}
304extern "C" {
305 #[doc = "Returns the transaction's #MDB_env\n\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()"]
306 pub fn mdb_txn_env(txn: *mut MDB_txn) -> *mut MDB_env;
307}
308extern "C" {
309 #[doc = "Return the transaction's ID.\n\n This returns the identifier associated with this transaction. For a\n read-only transaction, this corresponds to the snapshot being read;\n concurrent readers will frequently have the same transaction ID.\n\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n # Returns\n\nA transaction ID, valid if input is an active transaction."]
310 pub fn mdb_txn_id(txn: *mut MDB_txn) -> mdb_size_t;
311}
312extern "C" {
313 #[doc = "Commit all the operations of a transaction into the database.\n\n The transaction handle is freed. It and its cursors must not be used\n again after this call, except with #mdb_cursor_renew().\n > **Note:** Earlier documentation incorrectly said all cursors would be freed.\n Only write-transactions free cursors.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n\t<li>ENOSPC - no more disk space.\n\t<li>EIO - a low-level I/O error occurred while writing.\n\t<li>ENOMEM - out of memory.\n </ul>"]
314 pub fn mdb_txn_commit(txn: *mut MDB_txn) -> ::libc::c_int;
315}
316extern "C" {
317 #[doc = "Abandon all the operations of the transaction instead of saving them.\n\n The transaction handle is freed. It and its cursors must not be used\n again after this call, except with #mdb_cursor_renew().\n > **Note:** Earlier documentation incorrectly said all cursors would be freed.\n Only write-transactions free cursors.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()"]
318 pub fn mdb_txn_abort(txn: *mut MDB_txn);
319}
320extern "C" {
321 #[doc = "Reset a read-only transaction.\n\n Abort the transaction like #mdb_txn_abort(), but keep the transaction\n handle. #mdb_txn_renew() may reuse the handle. This saves allocation\n overhead if the process will start a new read-only transaction soon,\n and also locking overhead if #MDB_NOTLS is in use. The reader table\n lock is released, but the table slot stays tied to its thread or\n #MDB_txn. Use mdb_txn_abort() to discard a reset handle, and to free\n its lock table slot if MDB_NOTLS is in use.\n Cursors opened within the transaction must not be used\n again after this call, except with #mdb_cursor_renew().\n Reader locks generally don't interfere with writers, but they keep old\n versions of database pages allocated. Thus they prevent the old pages\n from being reused when writers commit new data, and so under heavy load\n the database size may grow much more rapidly than otherwise.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()"]
322 pub fn mdb_txn_reset(txn: *mut MDB_txn);
323}
324extern "C" {
325 #[doc = "Renew a read-only transaction.\n\n This acquires a new reader lock for a transaction handle that had been\n released by #mdb_txn_reset(). It must be called before a reset transaction\n may be used again.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_PANIC - a fatal error occurred earlier and the environment\n\t\tmust be shut down.\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
326 pub fn mdb_txn_renew(txn: *mut MDB_txn) -> ::libc::c_int;
327}
328extern "C" {
329 #[doc = "Open a database in the environment.\n\n A database handle denotes the name and parameters of a database,\n independently of whether such a database exists.\n The database handle may be discarded by calling #mdb_dbi_close().\n The old database handle is returned if the database was already open.\n The handle may only be closed once.\n\n The database handle will be private to the current transaction until\n the transaction is successfully committed. If the transaction is\n aborted the handle will be closed automatically.\n After a successful commit the handle will reside in the shared\n environment, and may be used by other transactions.\n\n This function must not be called from multiple concurrent\n transactions in the same process. A transaction that uses\n this function must finish (either commit or abort) before\n any other transaction in the process may use this function.\n\n To use named databases (with name != NULL), #mdb_env_set_maxdbs()\n must be called before opening the environment. Database names are\n keys in the unnamed database, and may be read but not written.\n\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `name` (direction in) - The name of the database to open. If only a single\n \tdatabase is needed in the environment, this value may be NULL.\n * `flags` (direction in) - Special options for this database. This parameter\n must be set to 0 or by bitwise OR'ing together one or more of the\n values described here.\n <ul>\n\t<li>#MDB_REVERSEKEY\n\t\tKeys are strings to be compared in reverse order, from the end\n\t\tof the strings to the beginning. By default, Keys are treated as strings and\n\t\tcompared from beginning to end.\n\t<li>#MDB_DUPSORT\n\t\tDuplicate keys may be used in the database. (Or, from another perspective,\n\t\tkeys may have multiple data items, stored in sorted order.) By default\n\t\tkeys must be unique and may have only a single data item.\n\t<li>#MDB_INTEGERKEY\n\t\tKeys are binary integers in native byte order, either unsigned int\n\t\tor #mdb_size_t, and will be sorted as such.\n\t\t(lmdb expects 32-bit int <= size_t <= 32/64-bit mdb_size_t.)\n\t\tThe keys must all be of the same size.\n\t<li>#MDB_DUPFIXED\n\t\tThis flag may only be used in combination with #MDB_DUPSORT. This option\n\t\ttells the library that the data items for this database are all the same\n\t\tsize, which allows further optimizations in storage and retrieval. When\n\t\tall data items are the same size, the #MDB_GET_MULTIPLE, #MDB_NEXT_MULTIPLE\n\t\tand #MDB_PREV_MULTIPLE cursor operations may be used to retrieve multiple\n\t\titems at once.\n\t<li>#MDB_INTEGERDUP\n\t\tThis option specifies that duplicate data items are binary integers,\n\t\tsimilar to #MDB_INTEGERKEY keys.\n\t<li>#MDB_REVERSEDUP\n\t\tThis option specifies that duplicate data items should be compared as\n\t\tstrings in reverse order.\n\t<li>#MDB_CREATE\n\t\tCreate the named database if it doesn't exist. This option is not\n\t\tallowed in a read-only transaction or a read-only environment.\n </ul>\n * `dbi` (direction out) - Address where the new #MDB_dbi handle will be stored\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_NOTFOUND - the specified database doesn't exist in the environment\n\t\tand #MDB_CREATE was not specified.\n\t<li>#MDB_DBS_FULL - too many databases have been opened. See #mdb_env_set_maxdbs().\n </ul>"]
330 pub fn mdb_dbi_open(
331 txn: *mut MDB_txn,
332 name: *const ::libc::c_char,
333 flags: ::libc::c_uint,
334 dbi: *mut MDB_dbi,
335 ) -> ::libc::c_int;
336}
337extern "C" {
338 #[doc = "Retrieve statistics for a database.\n\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `stat` (direction out) - The address of an #MDB_stat structure\n \twhere the statistics will be copied\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
339 pub fn mdb_stat(txn: *mut MDB_txn, dbi: MDB_dbi, stat: *mut MDB_stat) -> ::libc::c_int;
340}
341extern "C" {
342 #[doc = "Retrieve the DB flags for a database handle.\n\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `flags` (direction out) - Address where the flags will be returned.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
343 pub fn mdb_dbi_flags(
344 txn: *mut MDB_txn,
345 dbi: MDB_dbi,
346 flags: *mut ::libc::c_uint,
347 ) -> ::libc::c_int;
348}
349extern "C" {
350 #[doc = "Close a database handle. Normally unnecessary. Use with care:\n\n This call is not mutex protected. Handles should only be closed by\n a single thread, and only if no other threads are going to reference\n the database handle or one of its cursors any further. Do not close\n a handle if an existing transaction has modified its database.\n Doing so can cause misbehavior from database corruption to errors\n like MDB_BAD_VALSIZE (since the DB name is gone).\n\n Closing a database handle is not necessary, but lets #mdb_dbi_open()\n reuse the handle value. Usually it's better to set a bigger\n #mdb_env_set_maxdbs(), unless that value would be large.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()"]
351 pub fn mdb_dbi_close(env: *mut MDB_env, dbi: MDB_dbi);
352}
353extern "C" {
354 #[doc = "Empty or delete+close a database.\n\n See #mdb_dbi_close() for restrictions about closing the DB handle.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `del` (direction in) - 0 to empty the DB, 1 to delete it from the\n environment and close the DB handle.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
355 pub fn mdb_drop(txn: *mut MDB_txn, dbi: MDB_dbi, del: ::libc::c_int) -> ::libc::c_int;
356}
357extern "C" {
358 #[doc = "Set a custom key comparison function for a database.\n\n The comparison function is called whenever it is necessary to compare a\n key specified by the application with a key currently stored in the database.\n If no comparison function is specified, and no special key flags were specified\n with #mdb_dbi_open(), the keys are compared lexically, with shorter keys collating\n before longer keys.\n This function must be called before any data access functions are used,\n otherwise data corruption may occur. The same comparison function must be used by every\n program accessing the database, every time the database is used.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `cmp` (direction in) - A #MDB_cmp_func function\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
359 pub fn mdb_set_compare(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: MDB_cmp_func) -> ::libc::c_int;
360}
361extern "C" {
362 #[doc = "Set a custom data comparison function for a #MDB_DUPSORT database.\n\n This comparison function is called whenever it is necessary to compare a data\n item specified by the application with a data item currently stored in the database.\n This function only takes effect if the database was opened with the #MDB_DUPSORT\n flag.\n If no comparison function is specified, and no special key flags were specified\n with #mdb_dbi_open(), the data items are compared lexically, with shorter items collating\n before longer items.\n This function must be called before any data access functions are used,\n otherwise data corruption may occur. The same comparison function must be used by every\n program accessing the database, every time the database is used.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `cmp` (direction in) - A #MDB_cmp_func function\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
363 pub fn mdb_set_dupsort(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: MDB_cmp_func) -> ::libc::c_int;
364}
365extern "C" {
366 #[doc = "Set a relocation function for a #MDB_FIXEDMAP database.\n\n The relocation function is called whenever it is necessary to move the data\n of an item to a different position in the database (e.g. through tree\n balancing operations, shifts as a result of adds or deletes, etc.). It is\n intended to allow address/position-dependent data items to be stored in\n a database in an environment opened with the #MDB_FIXEDMAP option.\n Currently the relocation feature is unimplemented and setting\n this function has no effect.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `rel` (direction in) - A #MDB_rel_func function\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
367 pub fn mdb_set_relfunc(txn: *mut MDB_txn, dbi: MDB_dbi, rel: MDB_rel_func) -> ::libc::c_int;
368}
369extern "C" {
370 #[doc = "Set a context pointer for a #MDB_FIXEDMAP database's relocation function.\n\n See #mdb_set_relfunc and #MDB_rel_func for more details.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `ctx` (direction in) - An arbitrary pointer for whatever the application needs.\n It will be passed to the callback function set by #mdb_set_relfunc\n as its **relctx** parameter whenever the callback is invoked.\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
371 pub fn mdb_set_relctx(
372 txn: *mut MDB_txn,
373 dbi: MDB_dbi,
374 ctx: *mut ::libc::c_void,
375 ) -> ::libc::c_int;
376}
377extern "C" {
378 #[doc = "Get items from a database.\n\n This function retrieves key/data pairs from the database. The address\n and length of the data associated with the specified **key** are returned\n in the structure to which **data** refers.\n If the database supports duplicate keys (#MDB_DUPSORT) then the\n first data item for the key will be returned. Retrieval of other\n items requires the use of #mdb_cursor_get().\n\n > **Note:** The memory pointed to by the returned values is owned by the\n database. The caller need not dispose of the memory, and may not\n modify it in any way. For values returned in a read-only transaction\n any modification attempts will cause a SIGSEGV.\n > **Note:** Values returned from the database are valid only until a\n subsequent update operation, or the end of the transaction.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `key` (direction in) - The key to search for in the database\n * `data` (direction out) - The data corresponding to the key\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_NOTFOUND - the key was not in the database.\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
379 pub fn mdb_get(
380 txn: *mut MDB_txn,
381 dbi: MDB_dbi,
382 key: *mut MDB_val,
383 data: *mut MDB_val,
384 ) -> ::libc::c_int;
385}
386extern "C" {
387 #[doc = "Store items into a database.\n\n This function stores key/data pairs in the database. The default behavior\n is to enter the new key/data pair, replacing any previously existing key\n if duplicates are disallowed, or adding a duplicate data item if\n duplicates are allowed (#MDB_DUPSORT).\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `key` (direction in) - The key to store in the database\n * `data` (direction in, out) - The data to store\n * `flags` (direction in) - Special options for this operation. This parameter\n must be set to 0 or by bitwise OR'ing together one or more of the\n values described here.\n <ul>\n\t<li>#MDB_NODUPDATA - enter the new key/data pair only if it does not\n\t\talready appear in the database. This flag may only be specified\n\t\tif the database was opened with #MDB_DUPSORT. The function will\n\t\treturn #MDB_KEYEXIST if the key/data pair already appears in the\n\t\tdatabase.\n\t<li>#MDB_NOOVERWRITE - enter the new key/data pair only if the key\n\t\tdoes not already appear in the database. The function will return\n\t\t#MDB_KEYEXIST if the key already appears in the database, even if\n\t\tthe database supports duplicates (#MDB_DUPSORT). The **data**\n\t\tparameter will be set to point to the existing item.\n\t<li>#MDB_RESERVE - reserve space for data of the given size, but\n\t\tdon't copy the given data. Instead, return a pointer to the\n\t\treserved space, which the caller can fill in later - before\n\t\tthe next update operation or the transaction ends. This saves\n\t\tan extra memcpy if the data is being generated later.\n\t\tLMDB does nothing else with this memory, the caller is expected\n\t\tto modify all of the space requested. This flag must not be\n\t\tspecified if the database was opened with #MDB_DUPSORT.\n\t<li>#MDB_APPEND - append the given key/data pair to the end of the\n\t\tdatabase. This option allows fast bulk loading when keys are\n\t\talready known to be in the correct order. Loading unsorted keys\n\t\twith this flag will cause a #MDB_KEYEXIST error.\n\t<li>#MDB_APPENDDUP - as above, but for sorted dup data.\n </ul>\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_MAP_FULL - the database is full, see #mdb_env_set_mapsize().\n\t<li>#MDB_TXN_FULL - the transaction has too many dirty pages.\n\t<li>EACCES - an attempt was made to write in a read-only transaction.\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
388 pub fn mdb_put(
389 txn: *mut MDB_txn,
390 dbi: MDB_dbi,
391 key: *mut MDB_val,
392 data: *mut MDB_val,
393 flags: ::libc::c_uint,
394 ) -> ::libc::c_int;
395}
396extern "C" {
397 #[doc = "Delete items from a database.\n\n This function removes key/data pairs from the database.\n If the database does not support sorted duplicate data items\n (#MDB_DUPSORT) the data parameter is ignored.\n If the database supports sorted duplicates and the data parameter\n is NULL, all of the duplicate data items for the key will be\n deleted. Otherwise, if the data parameter is non-NULL\n only the matching data item will be deleted.\n This function will return #MDB_NOTFOUND if the specified key/data\n pair is not in the database.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `key` (direction in) - The key to delete from the database\n * `data` (direction in) - The data to delete\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EACCES - an attempt was made to write in a read-only transaction.\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
398 pub fn mdb_del(
399 txn: *mut MDB_txn,
400 dbi: MDB_dbi,
401 key: *mut MDB_val,
402 data: *mut MDB_val,
403 ) -> ::libc::c_int;
404}
405extern "C" {
406 #[doc = "Create a cursor handle.\n\n A cursor is associated with a specific transaction and database.\n A cursor cannot be used when its database handle is closed. Nor\n when its transaction has ended, except with #mdb_cursor_renew().\n It can be discarded with #mdb_cursor_close().\n A cursor in a write-transaction can be closed before its transaction\n ends, and will otherwise be closed when its transaction ends.\n A cursor in a read-only transaction must be closed explicitly, before\n or after its transaction ends. It can be reused with\n #mdb_cursor_renew() before finally closing it.\n > **Note:** Earlier documentation said that cursors in every transaction\n were closed when the transaction committed or aborted.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `cursor` (direction out) - Address where the new #MDB_cursor handle will be stored\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
407 pub fn mdb_cursor_open(
408 txn: *mut MDB_txn,
409 dbi: MDB_dbi,
410 cursor: *mut *mut MDB_cursor,
411 ) -> ::libc::c_int;
412}
413extern "C" {
414 #[doc = "Close a cursor handle.\n\n The cursor handle will be freed and must not be used again after this call.\n Its transaction must still be live if it is a write-transaction.\n # Arguments\n\n* `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()"]
415 pub fn mdb_cursor_close(cursor: *mut MDB_cursor);
416}
417extern "C" {
418 #[doc = "Renew a cursor handle.\n\n A cursor is associated with a specific transaction and database.\n Cursors that are only used in read-only\n transactions may be re-used, to avoid unnecessary malloc/free overhead.\n The cursor may be associated with a new read-only transaction, and\n referencing the same database handle as it was created with.\n This may be done whether the previous transaction is live or dead.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
419 pub fn mdb_cursor_renew(txn: *mut MDB_txn, cursor: *mut MDB_cursor) -> ::libc::c_int;
420}
421extern "C" {
422 #[doc = "Return the cursor's transaction handle.\n\n # Arguments\n\n* `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()"]
423 pub fn mdb_cursor_txn(cursor: *mut MDB_cursor) -> *mut MDB_txn;
424}
425extern "C" {
426 #[doc = "Return the cursor's database handle.\n\n # Arguments\n\n* `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()"]
427 pub fn mdb_cursor_dbi(cursor: *mut MDB_cursor) -> MDB_dbi;
428}
429extern "C" {
430 #[doc = "Retrieve by cursor.\n\n This function retrieves key/data pairs from the database. The address and length\n of the key are returned in the object to which **key** refers (except for the\n case of the #MDB_SET option, in which the **key** object is unchanged), and\n the address and length of the data are returned in the object to which **data**\n refers.\n See #mdb_get() for restrictions on using the output values.\n # Arguments\n\n* `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()\n * `key` (direction in, out) - The key for a retrieved item\n * `data` (direction in, out) - The data of a retrieved item\n * `op` (direction in) - A cursor operation #MDB_cursor_op\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_NOTFOUND - no matching key found.\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
431 pub fn mdb_cursor_get(
432 cursor: *mut MDB_cursor,
433 key: *mut MDB_val,
434 data: *mut MDB_val,
435 op: MDB_cursor_op,
436 ) -> ::libc::c_int;
437}
438extern "C" {
439 #[doc = "Store by cursor.\n\n This function stores key/data pairs into the database.\n The cursor is positioned at the new item, or on failure usually near it.\n > **Note:** Earlier documentation incorrectly said errors would leave the\n state of the cursor unchanged.\n # Arguments\n\n* `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()\n * `key` (direction in) - The key operated on.\n * `data` (direction in) - The data operated on.\n * `flags` (direction in) - Options for this operation. This parameter\n must be set to 0 or one of the values described here.\n <ul>\n\t<li>#MDB_CURRENT - replace the item at the current cursor position.\n\t\tThe **key** parameter must still be provided, and must match it.\n\t\tIf using sorted duplicates (#MDB_DUPSORT) the data item must still\n\t\tsort into the same place. This is intended to be used when the\n\t\tnew data is the same size as the old. Otherwise it will simply\n\t\tperform a delete of the old record followed by an insert.\n\t<li>#MDB_NODUPDATA - enter the new key/data pair only if it does not\n\t\talready appear in the database. This flag may only be specified\n\t\tif the database was opened with #MDB_DUPSORT. The function will\n\t\treturn #MDB_KEYEXIST if the key/data pair already appears in the\n\t\tdatabase.\n\t<li>#MDB_NOOVERWRITE - enter the new key/data pair only if the key\n\t\tdoes not already appear in the database. The function will return\n\t\t#MDB_KEYEXIST if the key already appears in the database, even if\n\t\tthe database supports duplicates (#MDB_DUPSORT).\n\t<li>#MDB_RESERVE - reserve space for data of the given size, but\n\t\tdon't copy the given data. Instead, return a pointer to the\n\t\treserved space, which the caller can fill in later - before\n\t\tthe next update operation or the transaction ends. This saves\n\t\tan extra memcpy if the data is being generated later. This flag\n\t\tmust not be specified if the database was opened with #MDB_DUPSORT.\n\t<li>#MDB_APPEND - append the given key/data pair to the end of the\n\t\tdatabase. No key comparisons are performed. This option allows\n\t\tfast bulk loading when keys are already known to be in the\n\t\tcorrect order. Loading unsorted keys with this flag will cause\n\t\ta #MDB_KEYEXIST error.\n\t<li>#MDB_APPENDDUP - as above, but for sorted dup data.\n\t<li>#MDB_MULTIPLE - store multiple contiguous data elements in a\n\t\tsingle request. This flag may only be specified if the database\n\t\twas opened with #MDB_DUPFIXED. The **data** argument must be an\n\t\tarray of two MDB_vals. The mv_size of the first MDB_val must be\n\t\tthe size of a single data element. The mv_data of the first MDB_val\n\t\tmust point to the beginning of the array of contiguous data elements.\n\t\tThe mv_size of the second MDB_val must be the count of the number\n\t\tof data elements to store. On return this field will be set to\n\t\tthe count of the number of elements actually written. The mv_data\n\t\tof the second MDB_val is unused.\n </ul>\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>#MDB_MAP_FULL - the database is full, see #mdb_env_set_mapsize().\n\t<li>#MDB_TXN_FULL - the transaction has too many dirty pages.\n\t<li>EACCES - an attempt was made to write in a read-only transaction.\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
440 pub fn mdb_cursor_put(
441 cursor: *mut MDB_cursor,
442 key: *mut MDB_val,
443 data: *mut MDB_val,
444 flags: ::libc::c_uint,
445 ) -> ::libc::c_int;
446}
447extern "C" {
448 #[doc = "Delete current key/data pair\n\n This function deletes the key/data pair to which the cursor refers.\n This does not invalidate the cursor, so operations such as MDB_NEXT\n can still be used on it.\n Both MDB_NEXT and MDB_GET_CURRENT will return the same record after\n this operation.\n # Arguments\n\n* `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()\n * `flags` (direction in) - Options for this operation. This parameter\n must be set to 0 or one of the values described here.\n <ul>\n\t<li>#MDB_NODUPDATA - delete all of the data items for the current key.\n\t\tThis flag may only be specified if the database was opened with #MDB_DUPSORT.\n </ul>\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EACCES - an attempt was made to write in a read-only transaction.\n\t<li>EINVAL - an invalid parameter was specified.\n </ul>"]
449 pub fn mdb_cursor_del(cursor: *mut MDB_cursor, flags: ::libc::c_uint) -> ::libc::c_int;
450}
451extern "C" {
452 #[doc = "Return count of duplicates for current key.\n\n This call is only valid on databases that support sorted duplicate\n data items #MDB_DUPSORT.\n # Arguments\n\n* `cursor` (direction in) - A cursor handle returned by #mdb_cursor_open()\n * `countp` (direction out) - Address where the count will be stored\n # Returns\n\nA non-zero error value on failure and 0 on success. Some possible\n errors are:\n <ul>\n\t<li>EINVAL - cursor is not initialized, or an invalid parameter was specified.\n </ul>"]
453 pub fn mdb_cursor_count(cursor: *mut MDB_cursor, countp: *mut mdb_size_t) -> ::libc::c_int;
454}
455extern "C" {
456 #[doc = "Compare two data items according to a particular database.\n\n This returns a comparison as if the two data items were keys in the\n specified database.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `a` (direction in) - The first item to compare\n * `b` (direction in) - The second item to compare\n # Returns\n\n< 0 if a < b, 0 if a == b, > 0 if a > b"]
457 pub fn mdb_cmp(
458 txn: *mut MDB_txn,
459 dbi: MDB_dbi,
460 a: *const MDB_val,
461 b: *const MDB_val,
462 ) -> ::libc::c_int;
463}
464extern "C" {
465 #[doc = "Compare two data items according to a particular database.\n\n This returns a comparison as if the two items were data items of\n the specified database. The database must have the #MDB_DUPSORT flag.\n # Arguments\n\n* `txn` (direction in) - A transaction handle returned by #mdb_txn_begin()\n * `dbi` (direction in) - A database handle returned by #mdb_dbi_open()\n * `a` (direction in) - The first item to compare\n * `b` (direction in) - The second item to compare\n # Returns\n\n< 0 if a < b, 0 if a == b, > 0 if a > b"]
466 pub fn mdb_dcmp(
467 txn: *mut MDB_txn,
468 dbi: MDB_dbi,
469 a: *const MDB_val,
470 b: *const MDB_val,
471 ) -> ::libc::c_int;
472}
473#[doc = "A callback function used to print a message from the library.\n\n # Arguments\n\n* `msg` (direction in) - The string to be printed.\n * `ctx` (direction in) - An arbitrary context pointer for the callback.\n # Returns\n\n< 0 on failure, >= 0 on success."]
474pub type MDB_msg_func = ::std::option::Option<
475 unsafe extern "C" fn(msg: *const ::libc::c_char, ctx: *mut ::libc::c_void) -> ::libc::c_int,
476>;
477extern "C" {
478 #[doc = "Dump the entries in the reader lock table.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `func` (direction in) - A #MDB_msg_func function\n * `ctx` (direction in) - Anything the message function needs\n # Returns\n\n< 0 on failure, >= 0 on success."]
479 pub fn mdb_reader_list(
480 env: *mut MDB_env,
481 func: MDB_msg_func,
482 ctx: *mut ::libc::c_void,
483 ) -> ::libc::c_int;
484}
485extern "C" {
486 #[doc = "Check for stale entries in the reader lock table.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create()\n * `dead` (direction out) - Number of stale slots that were cleared\n # Returns\n\n0 on success, non-zero on failure."]
487 pub fn mdb_reader_check(env: *mut MDB_env, dead: *mut ::libc::c_int) -> ::libc::c_int;
488}