blob: 7e9d07035199f4670482bf3fa701d6ab41fbcbff [file] [log] [blame]
cyan49732e3b6592017-01-20 14:00:41 -08001/**
2 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
8 */
Yann Collet3d93f2f2016-12-27 07:19:36 +01009
Yann Collet107bcbb2017-01-12 01:25:46 +010010/* === Dependencies === */
Yann Collet3d93f2f2016-12-27 07:19:36 +010011#include <stddef.h> /* size_t */
Yann Collet19d670b2017-01-19 15:32:07 -080012#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */
Yann Collet317604e2017-01-20 17:18:41 -080013#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
Yann Collet107bcbb2017-01-12 01:25:46 +010014
15
16/* === Simple one-pass functions === */
Yann Collet3d93f2f2016-12-27 07:19:36 +010017
18typedef struct ZSTDMT_CCtx_s ZSTDMT_CCtx;
Yann Collet317604e2017-01-20 17:18:41 -080019ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbThreads);
20ZSTDLIB_API size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* cctx);
Yann Collet3d93f2f2016-12-27 07:19:36 +010021
Yann Collet317604e2017-01-20 17:18:41 -080022ZSTDLIB_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* cctx,
Yann Collet3d93f2f2016-12-27 07:19:36 +010023 void* dst, size_t dstCapacity,
24 const void* src, size_t srcSize,
25 int compressionLevel);
Yann Collet107bcbb2017-01-12 01:25:46 +010026
27
28/* === Streaming functions === */
29
Yann Collet317604e2017-01-20 17:18:41 -080030ZSTDLIB_API size_t ZSTDMT_initCStream(ZSTDMT_CCtx* zcs, int compressionLevel);
31ZSTDLIB_API size_t ZSTDMT_resetCStream(ZSTDMT_CCtx* zcs, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown */
32ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* zcs, const void* dict, size_t dictSize,
Yann Collet19d670b2017-01-19 15:32:07 -080033 ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown ; current limitation : no checksum */
34
Yann Collet317604e2017-01-20 17:18:41 -080035ZSTDLIB_API size_t ZSTDMT_compressStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
Yann Collet19d670b2017-01-19 15:32:07 -080036
Yann Collet317604e2017-01-20 17:18:41 -080037ZSTDLIB_API size_t ZSTDMT_flushStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
38ZSTDLIB_API size_t ZSTDMT_endStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */