tcompress-lz4.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-lz4.c (893B)
---
1 #include <sys/types.h>
2
3 #include <err.h>
4 #include <stdint.h>
5 #include <string.h>
6
7 #include <lz4.h>
8
9 #include "blake2.h"
10 #include "dedup.h"
11
12 int
13 lz4_init(struct compr_ctx *ctx)
14 {
15 return 0;
16 }
17
18 size_t
19 lz4_size(struct compr_ctx *ctx, size_t n)
20 {
21 return LZ4_compressBound(n);
22 }
23
24 size_t
25 lz4_compr(struct compr_ctx *ctx, const void *in, void *out,
26 size_t insize, size_t outsize)
27 {
28 int n;
29
30 n = LZ4_compress_default((char *)in, (char *)out, insize,
31 outsize);
32 if (n < 0)
33 errx(1, "LZ4_compress_default failed");
34 return n;
35 }
36
37 size_t
38 lz4_decompr(struct compr_ctx *ctx, const void *in, void *out,
39 size_t insize, size_t outsize)
40 {
41 int n;
42
43 n = LZ4_decompress_safe((char *)in, (char *)out, insize,
44 outsize);
45 if (n < 0)
46 errx(1, "LZ4_decompress_safe failed");
47 return n;
48 }
49
50 int
51 lz4_final(struct compr_ctx *ctx)
52 {
53 return 0;
54 }