d5cf5351 |
1 | #ifndef _STORE_H |
2 | #define _STORE_H |
3 | |
4 | #include <sys/types.h> |
5 | |
6 | #define STORE_MAXBLSZ 65535 |
7 | |
8 | struct addr { |
9 | unsigned char hash[32]; |
10 | }; |
11 | |
12 | struct storecache { |
13 | struct addr a; |
14 | void *data; |
15 | ssize_t dlen; |
16 | }; |
17 | |
18 | struct store { |
19 | struct storeops *ops; |
20 | void *pdata; |
21 | struct storecache *cache; |
22 | }; |
23 | |
24 | struct storeops { |
25 | int (*put)(struct store *st, const void *buf, size_t len, struct addr *at); |
26 | ssize_t (*get)(struct store *st, void *buf, size_t len, struct addr *at); |
27 | int (*release)(struct store *st); |
28 | }; |
29 | |
30 | struct store *newstore(struct storeops *ops); |
31 | int storeput(struct store *st, const void *buf, size_t len, struct addr *at); |
32 | ssize_t storeget(struct store *st, void *buf, size_t len, struct addr *at); |
33 | int releasestore(struct store *st); |
34 | int addrcmp(struct addr *a1, struct addr *a2); |
35 | char *formataddr(struct addr *a); |
36 | int parseaddr(char *buf, struct addr *a); |
37 | int niladdr(struct addr *a); |
38 | |
39 | struct store *newfstore(char *dir); |
40 | int mkfstore(char *dir); |
41 | |
42 | #endif |