]> git.sur5r.net Git - openldap/blobdiff - libraries/libmdb/mdb.h
Added cursor_get for sorted dups
[openldap] / libraries / libmdb / mdb.h
index 2a303fa5a78b91916f9ac30861f25b07e6420816..f76f1ba0e49c5b977fa3aab02cc1aeb2c66e0ac3 100644 (file)
@@ -1,3 +1,32 @@
+/* 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_
 
@@ -21,20 +50,30 @@ typedef struct MDB_val {
 typedef int  (MDB_cmp_func)(const MDB_val *a, const MDB_val *b);
 typedef void (MDB_rel_func)(void *ptr, void *oldptr);
 
-#define MDB_NOOVERWRITE         1
-
 typedef enum MDB_cursor_op {           /* cursor operations */
-       MDB_CURSOR,                             /* position at given key */
-       MDB_CURSOR_EXACT,               /* position at key, or fail */
+       MDB_CURRENT,
        MDB_FIRST,
+       MDB_GET_BOTH,                   /* position at key/data */
+       MDB_GET_BOTH_RANGE,             /* position at key, nearest data */
+       MDB_LAST,
        MDB_NEXT,
-       MDB_LAST,                               /* not implemented */
-       MDB_PREV                                /* not implemented */
+       MDB_NEXT_DUP,
+       MDB_NEXT_NODUP,
+       MDB_NODUPDATA,
+       MDB_NOOVERWRITE,
+       MDB_PREV,
+       MDB_PREV_DUP,
+       MDB_PREV_NODUP,
+       MDB_SET,                                /* position at key, or fail */
+       MDB_SET_RANGE                   /* position at given key */
 } MDB_cursor_op;
 
 /* return codes */
-#define MDB_FAIL               -1
 #define MDB_SUCCESS     0
+#define MDB_FAIL               -1
+#define MDB_KEYEXIST   -2
+#define MDB_NOTFOUND   -3
+#define MDB_VERSION_MISMATCH   -4
 
 /* DB flags */
 #define MDB_REVERSEKEY 0x02            /* use reverse string keys */
@@ -90,6 +129,9 @@ int  mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor);
 void mdb_cursor_close(MDB_cursor *cursor);
 int  mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
                            MDB_cursor_op op);
+int  mdb_cursor_put(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
+                           MDB_cursor_op op);
+int  mdb_cursor_del(MDB_cursor *cursor, unsigned int flags);
 
 int  mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b);