1
2
3
4
5
6 #include <cmajor/rt/Compression.hpp>
7 #include <cmajor/rt/ZlibInterface.h>
8 #include <cmajor/rt/BZ2Interface.h>
9
10
11
12 extern "C" int32_t RtInitZlib(int32_t mode, int32_t level, void** handle)
13 {
14 return zlib_init(mode, level, handle);
15 }
16
17 extern "C" void RtDoneZlib(int32_t mode, void* handle)
18 {
19 zlib_done(mode, handle);
20 }
21
22 extern "C" void RtSetInputZlib(void* inChunk, uint32_t inAvail, void* handle)
23 {
24 zlib_set_input(inChunk, inAvail, handle);
25 }
26
27 extern "C" int32_t RtDeflateZlib(void* outChunk, uint32_t outChunkSize, uint32_t* have, uint32_t* outAvail, void* handle, int32_t flush)
28 {
29 return zlib_deflate(outChunk, outChunkSize, have, outAvail, handle, flush);
30 }
31
32 extern "C" int32_t RtInflateZlib(void* outChunk, uint32_t outChunkSize, uint32_t* have, uint32_t* outAvail, uint32_t* inAvail, void* handle)
33 {
34 return zlib_inflate(outChunk, outChunkSize, have, outAvail, inAvail, handle);
35 }
36
37 extern "C" const char* RtRetvalStrZlib(int32_t retVal)
38 {
39 return zlib_retval_str(retVal);
40 }
41
42
43
44 extern "C" int32_t RtInitBZip2(int32_t mode, int32_t compressionLevel, int32_t compressionWorkFactor, void** handle)
45 {
46 return bz2_init(mode, compressionLevel, compressionWorkFactor, handle);
47 }
48
49 extern "C" void RtDoneBZip2(int32_t mode, void* handle)
50 {
51 bz2_done(mode, handle);
52 }
53
54 extern "C" void RtSetInputBZip2(void* inChunk, uint32_t inAvail, void* handle)
55 {
56 bz2_set_input(inChunk, inAvail, handle);
57 }
58
59 extern "C" int32_t RtCompressBZip2(void* outChunk, uint32_t outChunkSize, uint32_t* have, uint32_t* outAvail, void* handle, int32_t action)
60 {
61 return bz2_compress(outChunk, outChunkSize, have, outAvail, handle, action);
62 }
63
64 extern "C" int32_t RtDecompressBZip2(void* outChunk, uint32_t outChunkSize, uint32_t* have, uint32_t* outAvail, uint32_t* inAvail, void* handle)
65 {
66 return bz2_decompress(outChunk, outChunkSize, have, outAvail, inAvail, handle);
67 }
68
69 extern "C" const char* RtRetvalStrBZip2(int32_t retVal)
70 {
71 return bz2_retval_str(retVal);
72 }