11 typedef struct MDB_cursor MDB_cursor;
12 typedef struct MDB_txn MDB_txn;
13 typedef struct MDB_db MDB_db;
14 typedef struct MDB_env MDB_env;
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 short ms_depth;
51 unsigned short ms_flags;
52 unsigned long ms_branch_pages;
53 unsigned long ms_leaf_pages;
54 unsigned long ms_overflow_pages;
55 unsigned long ms_entries;
58 int mdbenv_create(MDB_env **env);
59 int mdbenv_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode);
60 int mdbenv_stat(MDB_env *env, MDB_stat **stat);
61 void mdbenv_close(MDB_env *env);
62 int mdbenv_get_flags(MDB_env *env, unsigned int *flags);
63 int mdbenv_get_path(MDB_env *env, const char **path);
64 int mdbenv_set_mapsize(MDB_env *env, size_t size);
65 int mdbenv_set_maxreaders(MDB_env *env, int readers);
66 int mdbenv_get_maxreaders(MDB_env *env, int *readers);
67 int mdbenv_sync(MDB_env *env);
68 int mdbenv_compact(MDB_env *env);
70 int mdb_txn_begin(MDB_env *env, int rdonly, MDB_txn **txn);
71 int mdb_txn_commit(MDB_txn *txn);
72 void mdb_txn_abort(MDB_txn *txn);
74 int mdb_open(MDB_env *env, MDB_txn *txn, const char *name, unsigned int flags, MDB_db **db);
75 int mdb_stat(MDB_db *db, MDB_stat **stat);
76 void mdb_close(MDB_db *db);
78 int mdb_get(MDB_db *db, MDB_txn *txn, MDB_val *key, MDB_val *data);
79 int mdb_put(MDB_db *db, MDB_txn *txn, MDB_val *key, MDB_val *data,
81 int mdb_del(MDB_db *db, MDB_txn *txn, MDB_val *key, MDB_val *data);
83 int mdb_cursor_open(MDB_db *db, MDB_txn *txn, MDB_cursor **cursor);
84 void mdb_cursor_close(MDB_cursor *cursor);
85 int mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
88 int mdb_cmp(MDB_db *db, const MDB_val *a, const MDB_val *b);