10 typedef struct MDB_cursor MDB_cursor;
11 typedef struct MDB_txn MDB_txn;
12 typedef struct MDB_env MDB_env;
14 typedef unsigned int MDB_dbi;
16 typedef struct MDB_val {
21 typedef int (MDB_cmp_func)(const MDB_val *a, const MDB_val *b);
22 typedef void (MDB_rel_func)(void *ptr, void *oldptr);
24 #define MDB_NOOVERWRITE 1
26 typedef enum MDB_cursor_op { /* cursor operations */
27 MDB_CURSOR, /* position at given key */
28 MDB_CURSOR_EXACT, /* position at key, or fail */
31 MDB_LAST, /* not implemented */
32 MDB_PREV /* not implemented */
40 #define MDB_REVERSEKEY 0x02 /* use reverse string keys */
41 #define MDB_NOSYNC 0x10000 /* don't fsync after commit */
42 #define MDB_RDONLY 0x20000 /* read only */
43 #define MDB_CREATE 0x40000 /* create if not present */
45 /* environment flags */
46 #define MDB_FIXEDMAP 0x01 /* mmap at a fixed address */
48 typedef struct MDB_stat {
49 unsigned int ms_psize;
50 unsigned int ms_depth;
51 unsigned long ms_branch_pages;
52 unsigned long ms_leaf_pages;
53 unsigned long ms_overflow_pages;
54 unsigned long ms_entries;
57 int mdbenv_create(MDB_env **env);
58 int mdbenv_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode);
59 int mdbenv_stat(MDB_env *env, MDB_stat *stat);
60 void mdbenv_close(MDB_env *env);
61 int mdbenv_get_flags(MDB_env *env, unsigned int *flags);
62 int mdbenv_get_path(MDB_env *env, const char **path);
63 int mdbenv_set_mapsize(MDB_env *env, size_t size);
64 int mdbenv_set_maxreaders(MDB_env *env, int readers);
65 int mdbenv_get_maxreaders(MDB_env *env, int *readers);
66 int mdbenv_sync(MDB_env *env);
68 int mdb_txn_begin(MDB_env *env, int rdonly, MDB_txn **txn);
69 int mdb_txn_commit(MDB_txn *txn);
70 void mdb_txn_abort(MDB_txn *txn);
72 int mdb_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi);
73 int mdb_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat);
74 void mdb_close(MDB_env *env, MDB_dbi dbi);
76 int mdb_get(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data);
77 int mdb_put(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data,
79 int mdb_del(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data);
81 int mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor);
82 void mdb_cursor_close(MDB_cursor *cursor);
83 int mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
86 int mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b);