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
37 /* Generic opener that knows about all the backends */
38 struct db_conn
*db_open(enum backend_type type
, const char *name
, int flags
);
40 /* Returns the backend type for the given name. */
41 enum backend_type
be_type_from_str(const char *name
);
43 /* Returns the backend name for the given type. */
44 const char *be_str_from_type(enum backend_type type
);
46 /* String containing a list of all supported backends */
48 #define _QDBM_SUPP "qdbm "
54 #define _BDB_SUPP "bdb "
60 #define _TC_SUPP "tc "
66 #define _TDB_SUPP "tdb "
72 #define _NULL_SUPP "null "
77 #define SUPPORTED_BE _QDBM_SUPP _BDB_SUPP _TC_SUPP _TDB_SUPP _NULL_SUPP
82 #define DEFAULT_BE BE_TDB
83 #define DEFAULT_BE_NAME "tdb"
85 #define DEFAULT_BE BE_TC
86 #define DEFAULT_BE_NAME "tc"
88 #define DEFAULT_BE BE_QDBM
89 #define DEFAULT_BE_NAME "qdbm"
91 #define DEFAULT_BE BE_BDB
92 #define DEFAULT_BE_NAME "bdb"
94 #warning "using null backend as the default"
95 #define DEFAULT_BE BE_NULL
96 #define DEFAULT_BE_NAME "null"
98 #error "no backend available"