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