+/* mdb.h - memory-mapped database library header file */
+/*
+ * Copyright 2011 Howard Chu, Symas Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ *
+ * This code is derived from btree.c written by Martin Hedenfalk.
+ *
+ * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
#ifndef _MDB_H_
#define _MDB_H_
/* DB flags */
#define MDB_REVERSEKEY 0x02 /* use reverse string keys */
-#define MDB_NOSYNC 0x10000 /* don't fsync after commit */
-#define MDB_RDONLY 0x20000 /* read only */
-#define MDB_CREATE 0x40000 /* create if not present */
+#define MDB_DUPSORT 0x04 /* use sorted duplicates */
/* environment flags */
#define MDB_FIXEDMAP 0x01 /* mmap at a fixed address */
+#define MDB_NOSYNC 0x10000 /* don't fsync after commit */
+#define MDB_RDONLY 0x20000 /* read only */
+
+/* DB or env flags */
+#define MDB_CREATE 0x40000 /* create if not present */
typedef struct MDB_stat {
unsigned int ms_psize;
int mdbenv_set_mapsize(MDB_env *env, size_t size);
int mdbenv_set_maxreaders(MDB_env *env, int readers);
int mdbenv_get_maxreaders(MDB_env *env, int *readers);
+int mdbenv_set_maxdbs(MDB_env *env, int dbs);
int mdbenv_sync(MDB_env *env);
int mdb_txn_begin(MDB_env *env, int rdonly, MDB_txn **txn);
int mdb_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat);
void mdb_close(MDB_txn *txn, MDB_dbi dbi);
+int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp);
+int mdb_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp);
+int mdb_set_relfunc(MDB_txn *txn, MDB_dbi dbi, MDB_rel_func *rel);
+
int mdb_get(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data);
int mdb_put(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data,
unsigned int flags);