egeditor: more VaVoom C highlighting
[iv.d.git] / lmdb.d
blob6343021e1be25f6cb95f3d4d7dd5c06f306b053f
1 /*
2 * @author Howard Chu, Symas Corporation.
4 * @copyright Copyright 2011-2015 Howard Chu, Symas Corp. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted only as authorized by the OpenLDAP
8 * Public License.
10 * A copy of this license is available in the file LICENSE in the
11 * top-level directory of the distribution or, alternatively, at
12 * <http://www.OpenLDAP.org/license.html>.
14 * @par Derived From:
15 * This code is derived from btree.c written by Martin Hedenfalk.
17 * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
19 * Permission to use, copy, modify, and distribute this software for any
20 * purpose with or without fee is hereby granted, provided that the above
21 * copyright notice and this permission notice appear in all copies.
23 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
24 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
26 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
28 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
29 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 module iv.lmdb /*is aliced*/;
32 pragma(lib, "lmdb");
34 // ////////////////////////////////////////////////////////////////////////// //
35 // C API
36 import iv.alice;
37 extern(C):
38 nothrow:
39 @nogc:
41 alias mdb_mode_t = uint;
42 struct mdb_filehandle_ts {}
43 alias mdb_filehandle_t = mdb_filehandle_ts*;
45 enum {
46 MDB_VERSION_MAJOR = 0,
47 MDB_VERSION_MINOR = 9,
48 MDB_VERSION_PATCH = 14,
49 MDB_VERSION_DATE = "September 20, 2014",
52 struct MDB_env_s {}
53 alias MDB_envp = MDB_env_s*;
54 struct MDB_txn_s {}
55 alias MDB_txnp = MDB_txn_s*;
56 alias MDB_dbi = uint;
57 struct MDB_cursor_s {}
58 alias MDB_cursorp = MDB_cursor_s*;
60 struct MDB_val {
61 usize mv_size;
62 void* mv_data;
65 enum {
66 MDB_FIXEDMAP = 0x01,
67 MDB_NOSUBDIR = 0x4000,
68 MDB_NOSYNC = 0x10000,
69 MDB_RDONLY = 0x20000,
70 MDB_NOMETASYNC = 0x40000,
71 MDB_WRITEMAP = 0x80000,
72 MDB_MAPASYNC = 0x100000,
73 MDB_NOTLS = 0x200000,
74 MDB_NOLOCK = 0x400000,
75 MDB_NORDAHEAD = 0x800000,
76 MDB_NOMEMINIT = 0x1000000
79 enum {
80 MDB_REVERSEKEY = 0x02,
81 MDB_DUPSORT = 0x04,
82 MDB_INTEGERKEY = 0x08,
83 MDB_DUPFIXED = 0x10,
84 MDB_INTEGERDUP = 0x20,
85 MDB_REVERSEDUP = 0x40,
86 MDB_CREATE = 0x40000
89 enum {
90 MDB_NOOVERWRITE = 0x10,
91 MDB_NODUPDATA = 0x20,
92 MDB_RESERVE = 0x10000,
93 MDB_APPEND = 0x20000,
94 MDB_APPENDDUP = 0x40000,
95 MDB_MULTIPLE = 0x80000
98 enum /*MDB_cursor_op*/ {
99 MDB_FIRST,
100 MDB_FIRST_DUP,
101 MDB_GET_BOTH,
102 MDB_GET_BOTH_RANGE,
103 MDB_GET_CURRENT,
104 MDB_GET_MULTIPLE,
105 MDB_LAST,
106 MDB_LAST_DUP,
107 MDB_NEXT,
108 MDB_NEXT_DUP,
109 MDB_NEXT_MULTIPLE,
110 MDB_NEXT_NODUP,
111 MDB_PREV,
112 MDB_PREV_DUP,
113 MDB_PREV_NODUP,
114 MDB_SET,
115 MDB_SET_KEY,
116 MDB_SET_RANGE,
119 enum {
120 MDB_SUCCESS = 0,
121 MDB_KEYEXIST = (-30799),
122 MDB_NOTFOUND = (-30798),
123 MDB_PAGE_NOTFOUND = (-30797),
124 MDB_CORRUPTED = (-30796),
125 MDB_PANIC = (-30795),
126 MDB_VERSION_MISMATCH = (-30794),
127 MDB_INVALID = (-30793),
128 MDB_MAP_FULL = (-30792),
129 MDB_DBS_FULL = (-30791),
130 MDB_READERS_FULL = (-30790),
131 MDB_TLS_FULL = (-30789),
132 MDB_TXN_FULL = (-30788),
133 MDB_CURSOR_FULL = (-30787),
134 MDB_PAGE_FULL = (-30786),
135 MDB_MAP_RESIZED = (-30785),
136 MDB_INCOMPATIBLE = (-30784),
137 MDB_BAD_RSLOT = (-30783),
138 MDB_BAD_TXN = (-30782),
139 MDB_BAD_VALSIZE = (-30781),
140 MDB_BAD_DBI = (-30780),
141 MDB_LAST_ERRCODE = MDB_BAD_DBI
144 struct MDB_stat {
145 uint ms_psize;
146 uint ms_depth;
147 usize ms_branch_pages;
148 usize ms_leaf_pages;
149 usize ms_overflow_pages;
150 usize ms_entries;
153 struct MDB_envinfo {
154 void* me_mapaddr;
155 usize me_mapsize;
156 usize me_last_pgno;
157 usize me_last_txnid;
158 uint me_maxreaders;
159 uint me_numreaders;
162 const(char)* mdb_version (int* major, int* minor, int* patch);
163 const(char)* mdb_strerror (int err);
165 int mdb_env_create (MDB_envp* env);
166 int mdb_env_open (MDB_envp env, const(char)* path, uint flags, mdb_mode_t mode);
167 int mdb_env_copy (MDB_envp env, const(char)* path);
168 int mdb_env_copyfd (MDB_envp env, mdb_filehandle_t fd);
169 int mdb_env_stat (MDB_envp env, MDB_stat* stat);
170 int mdb_env_info (MDB_envp env, MDB_envinfo* stat);
171 int mdb_env_sync (MDB_envp env, int force);
172 void mdb_env_close (MDB_envp env);
173 int mdb_env_set_flags (MDB_envp env, uint flags, int onoff);
174 int mdb_env_get_flags (MDB_envp env, uint* flags);
175 int mdb_env_get_path (MDB_envp env, const(char)** path);
176 int mdb_env_get_fd (MDB_envp env, mdb_filehandle_t* fd);
177 int mdb_env_set_mapsize (MDB_envp env, usize size);
178 int mdb_env_set_maxreaders (MDB_envp env, uint readers);
179 int mdb_env_get_maxreaders (MDB_envp env, uint* readers);
180 int mdb_env_set_maxdbs (MDB_envp env, MDB_dbi dbs);
181 int mdb_env_get_maxkeysize (MDB_envp env);
182 int mdb_env_set_userctx (MDB_envp env, void* ctx);
183 void* mdb_env_get_userctx (MDB_envp env);
184 int mdb_env_set_assert (MDB_envp env, void function (MDB_envp env, const(char)* msg) func);
186 int mdb_txn_begin (MDB_envp env, MDB_txnp parent, uint flags, MDB_txnp* txn);
187 MDB_envp mdb_txn_env (MDB_txnp txn);
188 usize mdb_txn_id (MDB_txnp txn);
189 int mdb_txn_commit (MDB_txnp txn);
190 void mdb_txn_abort (MDB_txnp txn);
191 void mdb_txn_reset (MDB_txnp txn);
192 int mdb_txn_renew (MDB_txnp txn);
194 int mdb_dbi_open (MDB_txnp txn, const(char)* name, uint flags, MDB_dbi* dbi);
195 int mdb_stat (MDB_txnp txn, MDB_dbi dbi, MDB_stat* stat);
196 int mdb_dbi_flags (MDB_txnp txn, MDB_dbi dbi, uint* flags);
197 void mdb_dbi_close (MDB_envp env, MDB_dbi dbi);
198 int mdb_drop (MDB_txnp txn, MDB_dbi dbi, int del);
199 int mdb_set_compare (MDB_txnp txn, MDB_dbi dbi, int function (MDB_val* a, MDB_val* b) cmp);
200 int mdb_set_dupsort (MDB_txnp txn, MDB_dbi dbi, int function (MDB_val* a, MDB_val* b) cmp);
201 int mdb_set_relfunc (MDB_txnp txn, MDB_dbi dbi, void function (MDB_val* item, void* oldptr, void* newptr, void* relctx) rel);
202 int mdb_set_relctx (MDB_txnp txn, MDB_dbi dbi, void* ctx);
203 int mdb_get (MDB_txnp txn, MDB_dbi dbi, MDB_val* key, MDB_val* data);
204 int mdb_put (MDB_txnp txn, MDB_dbi dbi, MDB_val* key, MDB_val* data, uint flags);
205 int mdb_del (MDB_txnp txn, MDB_dbi dbi, MDB_val* key, MDB_val* data);
206 int mdb_cursor_open (MDB_txnp txn, MDB_dbi dbi, MDB_cursorp* cursor);
207 void mdb_cursor_close (MDB_cursorp cursor);
208 int mdb_cursor_renew (MDB_txnp txn, MDB_cursorp cursor);
209 MDB_txnp mdb_cursor_txn (MDB_cursorp cursor);
210 MDB_dbi mdb_cursor_dbi (MDB_cursorp cursor);
211 int mdb_cursor_get (MDB_cursorp cursor, MDB_val* key, MDB_val* data, /*MDB_cursor_op*/uint op);
212 int mdb_cursor_put (MDB_cursorp cursor, MDB_val* key, MDB_val* data, uint flags);
213 int mdb_cursor_del (MDB_cursorp cursor, uint flags);
214 int mdb_cursor_count (MDB_cursorp cursor, usize* countp);
215 int mdb_cmp (MDB_txnp txn, MDB_dbi dbi, MDB_val* a, MDB_val* b);
216 int mdb_dcmp (MDB_txnp txn, MDB_dbi dbi, MDB_val* a, MDB_val* b);
217 int mdb_reader_list (MDB_envp env, int function (const(char)* msg, void* ctx) func, void* ctx);
218 int mdb_reader_check (MDB_envp env, int* dead);