| Yann Collet | 439eb77 | 2015-01-31 10:52:59 +0100 | [diff] [blame] | 1 | /* |
| 2 | zstd - standard compression library |
| 3 | Header File for static linking only |
| 4 | Copyright (C) 2014-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 "zstd.h" |
| 43 | |
| 44 | |
| 45 | /************************************** |
| 46 | * Streaming functions |
| 47 | **************************************/ |
| Yann Collet | 7393c5a | 2015-07-04 18:20:42 -0800 | [diff] [blame] | 48 | typedef struct ZSTD_Cctx_s ZSTD_Cctx; |
| 49 | ZSTD_Cctx* ZSTD_createCCtx(void); |
| 50 | size_t ZSTD_freeCCtx(ZSTD_Cctx* cctx); |
| Yann Collet | 439eb77 | 2015-01-31 10:52:59 +0100 | [diff] [blame] | 51 | |
| Yann Collet | 7393c5a | 2015-07-04 18:20:42 -0800 | [diff] [blame] | 52 | size_t ZSTD_compressBegin(ZSTD_Cctx* cctx, void* dst, size_t maxDstSize); |
| 53 | size_t ZSTD_compressContinue(ZSTD_Cctx* cctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize); |
| 54 | size_t ZSTD_compressEnd(ZSTD_Cctx* cctx, void* dst, size_t maxDstSize); |
| Yann Collet | 439eb77 | 2015-01-31 10:52:59 +0100 | [diff] [blame] | 55 | |
| Yann Collet | 439eb77 | 2015-01-31 10:52:59 +0100 | [diff] [blame] | 56 | |
| Yann Collet | 7393c5a | 2015-07-04 18:20:42 -0800 | [diff] [blame] | 57 | typedef struct ZSTD_Dctx_s ZSTD_Dctx; |
| 58 | ZSTD_Dctx* ZSTD_createDCtx(void); |
| Yann Collet | be50aaa | 2015-09-10 23:26:09 +0100 | [diff] [blame] | 59 | size_t ZSTD_resetDCtx(ZSTD_Dctx* dctx); |
| Yann Collet | 7393c5a | 2015-07-04 18:20:42 -0800 | [diff] [blame] | 60 | size_t ZSTD_freeDCtx(ZSTD_Dctx* dctx); |
| 61 | |
| 62 | size_t ZSTD_nextSrcSizeToDecompress(ZSTD_Dctx* dctx); |
| 63 | size_t ZSTD_decompressContinue(ZSTD_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize); |
| Yann Collet | 00be343 | 2015-02-20 18:53:31 +0100 | [diff] [blame] | 64 | /* |
| 65 | Use above functions alternatively. |
| 66 | ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as input to ZSTD_decompressContinue(). |
| 67 | This value is expected to be provided, precisely, as 'srcSize'. |
| 68 | Otherwise, compression will fail (result is an error code, which can be tested using ZSTD_isError() ) |
| 69 | ZSTD_decompressContinue() result is the number of bytes regenerated within 'dst'. |
| 70 | It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header. |
| 71 | */ |
| Yann Collet | 439eb77 | 2015-01-31 10:52:59 +0100 | [diff] [blame] | 72 | |
| 73 | /************************************** |
| 74 | * Error management |
| 75 | **************************************/ |
| 76 | #define ZSTD_LIST_ERRORS(ITEM) \ |
| 77 | ITEM(ZSTD_OK_NoError) ITEM(ZSTD_ERROR_GENERIC) \ |
| Yann Collet | f4ce891 | 2015-08-11 14:18:45 +0100 | [diff] [blame] | 78 | ITEM(ZSTD_ERROR_MagicNumber) \ |
| 79 | ITEM(ZSTD_ERROR_SrcSize) ITEM(ZSTD_ERROR_maxDstSize_tooSmall) \ |
| 80 | ITEM(ZSTD_ERROR_corruption) \ |
| Yann Collet | 439eb77 | 2015-01-31 10:52:59 +0100 | [diff] [blame] | 81 | ITEM(ZSTD_ERROR_maxCode) |
| 82 | |
| 83 | #define ZSTD_GENERATE_ENUM(ENUM) ENUM, |
| 84 | typedef enum { ZSTD_LIST_ERRORS(ZSTD_GENERATE_ENUM) } ZSTD_errorCodes; /* exposed list of errors; static linking only */ |
| 85 | |
| 86 | |
| 87 | #if defined (__cplusplus) |
| 88 | } |
| Yann Collet | c5d46b5 | 2015-02-16 18:06:26 +0100 | [diff] [blame] | 89 | #endif |