1 | /* |
---|
2 | zstd_v02 - decoder for 0.2 format |
---|
3 | Header File |
---|
4 | Copyright (C) 2015, Yann Collet. |
---|
5 | |
---|
6 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) |
---|
7 | |
---|
8 | Redistribution and use in source and binary forms, with or without |
---|
9 | modification, are permitted provided that the following conditions are |
---|
10 | met: |
---|
11 | * Redistributions of source code must retain the above copyright |
---|
12 | notice, this list of conditions and the following disclaimer. |
---|
13 | * Redistributions in binary form must reproduce the above |
---|
14 | copyright notice, this list of conditions and the following disclaimer |
---|
15 | in the documentation and/or other materials provided with the |
---|
16 | distribution. |
---|
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
28 | |
---|
29 | You can contact the author at : |
---|
30 | - zstd source repository : https://github.com/Cyan4973/zstd |
---|
31 | - ztsd public forum : https://groups.google.com/forum/#!forum/lz4c |
---|
32 | */ |
---|
33 | #pragma once |
---|
34 | |
---|
35 | #if defined (__cplusplus) |
---|
36 | extern "C" { |
---|
37 | #endif |
---|
38 | |
---|
39 | /* ************************************* |
---|
40 | * Includes |
---|
41 | ***************************************/ |
---|
42 | #include <stddef.h> /* size_t */ |
---|
43 | |
---|
44 | |
---|
45 | /* ************************************* |
---|
46 | * Simple one-step function |
---|
47 | ***************************************/ |
---|
48 | /** |
---|
49 | ZSTDv02_decompress() : decompress ZSTD frames compliant with v0.2.x format |
---|
50 | compressedSize : is the exact source size |
---|
51 | maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated. |
---|
52 | It must be equal or larger than originalSize, otherwise decompression will fail. |
---|
53 | return : the number of bytes decompressed into destination buffer (originalSize) |
---|
54 | or an errorCode if it fails (which can be tested using ZSTDv01_isError()) |
---|
55 | */ |
---|
56 | size_t ZSTDv02_decompress( void* dst, size_t maxOriginalSize, |
---|
57 | const void* src, size_t compressedSize); |
---|
58 | |
---|
59 | /** |
---|
60 | ZSTDv02_isError() : tells if the result of ZSTDv02_decompress() is an error |
---|
61 | */ |
---|
62 | unsigned ZSTDv02_isError(size_t code); |
---|
63 | |
---|
64 | |
---|
65 | /* ************************************* |
---|
66 | * Advanced functions |
---|
67 | ***************************************/ |
---|
68 | typedef struct ZSTDv02_Dctx_s ZSTDv02_Dctx; |
---|
69 | ZSTDv02_Dctx* ZSTDv02_createDCtx(void); |
---|
70 | size_t ZSTDv02_freeDCtx(ZSTDv02_Dctx* dctx); |
---|
71 | |
---|
72 | size_t ZSTDv02_decompressDCtx(void* ctx, |
---|
73 | void* dst, size_t maxOriginalSize, |
---|
74 | const void* src, size_t compressedSize); |
---|
75 | |
---|
76 | /* ************************************* |
---|
77 | * Streaming functions |
---|
78 | ***************************************/ |
---|
79 | size_t ZSTDv02_resetDCtx(ZSTDv02_Dctx* dctx); |
---|
80 | |
---|
81 | size_t ZSTDv02_nextSrcSizeToDecompress(ZSTDv02_Dctx* dctx); |
---|
82 | size_t ZSTDv02_decompressContinue(ZSTDv02_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize); |
---|
83 | /** |
---|
84 | Use above functions alternatively. |
---|
85 | ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue(). |
---|
86 | ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block. |
---|
87 | Result is the number of bytes regenerated within 'dst'. |
---|
88 | It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header. |
---|
89 | */ |
---|
90 | |
---|
91 | /* ************************************* |
---|
92 | * Prefix - version detection |
---|
93 | ***************************************/ |
---|
94 | #define ZSTDv02_magicNumber 0xFD2FB522 /* v0.2 */ |
---|
95 | |
---|
96 | |
---|
97 | #if defined (__cplusplus) |
---|
98 | } |
---|
99 | #endif |
---|