tcompress-snappy.c - dedup - data deduplication program
HTML git clone git://bitreich.org/dedup/ git://hg6vgqziawt5s4dj.onion/dedup/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
tcompress-snappy.c (965B)
---
1 #include <sys/types.h>
2
3 #include <err.h>
4 #include <stdint.h>
5 #include <string.h>
6
7 #include <snappy-c.h>
8
9 #include "blake2.h"
10 #include "dedup.h"
11
12 int
13 snappy_init(struct compr_ctx *ctx)
14 {
15 return 0;
16 }
17
18 size_t
19 snappy_size(struct compr_ctx *ctx, size_t n)
20 {
21 return snappy_max_compressed_length(n);
22 }
23
24 size_t
25 snappy_compr(struct compr_ctx *ctx, const void *in, void *out,
26 size_t insize, size_t outsize)
27 {
28 size_t n = outsize;
29 snappy_status ret;
30
31 ret = snappy_compress((char *)in, insize, (char *)out, &n);
32 if (ret != SNAPPY_OK)
33 errx(1, "snappy_compress failed: %d", ret);
34 return n;
35 }
36
37 size_t
38 snappy_decompr(struct compr_ctx *ctx, const void *in, void *out,
39 size_t insize, size_t outsize)
40 {
41 size_t n = outsize;
42 snappy_status ret;
43
44 ret = snappy_uncompress((char *)in, insize, (char *)out, &n);
45 if (ret != SNAPPY_OK)
46 errx(1, "snappy_uncompress failed: %d", ret);
47 return n;
48 }
49
50 int
51 snappy_final(struct compr_ctx *ctx)
52 {
53 return 0;
54 }