5 #include <stddef.h> /* size_t */
8 /* This is where the backend sets a reference to the connection, which
9 * will be properly casted when needed */
13 int (*set
)(struct db_conn
*db
, const unsigned char *key
, size_t ksize
,
14 unsigned char *val
, size_t vsize
);
15 int (*get
)(struct db_conn
*db
, const unsigned char *key
, size_t ksize
,
16 unsigned char *val
, size_t *vsize
);
17 int (*del
)(struct db_conn
*db
, const unsigned char *key
, size_t ksize
);
18 int (*firstkey
)(struct db_conn
*db
, unsigned char *key
, size_t *ksize
);
19 int (*nextkey
)(struct db_conn
*db
,
20 const unsigned char *key
, size_t ksize
,
21 unsigned char *nextkey
, size_t *nksize
);
22 int (*close
)(struct db_conn
*db
);
26 /* The first two are special, used to indicate unknown and unsupported
38 /* Generic opener that knows about all the backends */
39 struct db_conn
*db_open(enum backend_type type
, const char *name
, int flags
);
41 /* Returns the backend type for the given name. */
42 enum backend_type
be_type_from_str(const char *name
);
44 /* Returns the backend name for the given type. */
45 const char *be_str_from_type(enum backend_type type
);
47 /* String containing a list of all supported backends */
49 #define _QDBM_SUPP "qdbm "
55 #define _BDB_SUPP "bdb "
61 #define _TC_SUPP "tc "
67 #define _TDB_SUPP "tdb "
73 #define _LEVELDB_SUPP "leveldb "
75 #define _LEVELDB_SUPP ""
79 #define _NULL_SUPP "null "
84 #define SUPPORTED_BE \
85 _QDBM_SUPP _BDB_SUPP _TC_SUPP _TDB_SUPP _LEVELDB_SUPP _NULL_SUPP
90 #define DEFAULT_BE BE_TDB
91 #define DEFAULT_BE_NAME "tdb"
93 #define DEFAULT_BE BE_TC
94 #define DEFAULT_BE_NAME "tc"
96 #define DEFAULT_BE BE_QDBM
97 #define DEFAULT_BE_NAME "qdbm"
99 #define DEFAULT_BE BE_BDB
100 #define DEFAULT_BE_NAME "bdb"
101 #elif BE_ENABLE_LEVELDB
102 #define DEFAULT_BE BE_LEVELDB
103 #define DEFAULT_BE_NAME "leveldb"
105 #warning "using null backend as the default"
106 #define DEFAULT_BE BE_NULL
107 #define DEFAULT_BE_NAME "null"
109 #error "no backend available"