4 #include <depot.h> /* QDBM's Depot API */
10 int qdbm_set(struct db_conn
*db
, const unsigned char *key
, size_t ksize
,
11 unsigned char *val
, size_t vsize
);
12 int qdbm_get(struct db_conn
*db
, const unsigned char *key
, size_t ksize
,
13 unsigned char *val
, size_t *vsize
);
14 int qdbm_del(struct db_conn
*db
, const unsigned char *key
, size_t ksize
);
15 int qdbm_close(struct db_conn
*db
);
18 struct db_conn
*qdbm_open(const char *name
, int flags
)
24 f
= DP_OREADER
| DP_OWRITER
| DP_ONOLCK
| DP_OCREAT
;
25 qdbm_db
= dpopen(name
, f
, 0);
29 db
= malloc(sizeof(struct db_conn
));
41 db
->close
= qdbm_close
;
47 int qdbm_close(struct db_conn
*db
)
51 rv
= dpclose(db
->conn
);
57 int qdbm_set(struct db_conn
*db
, const unsigned char *key
, size_t ksize
,
58 unsigned char *val
, size_t vsize
)
60 return dpput(db
->conn
, (char *) key
, ksize
,
61 (char *) val
, vsize
, DP_DOVER
);
65 int qdbm_get(struct db_conn
*db
, const unsigned char *key
, size_t ksize
,
66 unsigned char *val
, size_t *vsize
)
70 rv
= dpgetwb(db
->conn
, (char *) key
, ksize
, 0, *vsize
, (char *) val
);
79 int qdbm_del(struct db_conn
*db
, const unsigned char *key
, size_t ksize
)
81 return dpout(db
->conn
, (char *) key
, ksize
);
86 #include <stddef.h> /* NULL */
88 struct db_conn
*qdbm_open(const char *name
, int flags
)