Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
zbuff.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 * You may select, at your option, one of the above-listed licenses.
9 */
10
11/* ***************************************************************
12* NOTES/WARNINGS
13******************************************************************/
14/* The streaming API defined here is deprecated.
15 * Consider migrating towards ZSTD_compressStream() API in `zstd.h`
16 * See 'lib/README.md'.
17 *****************************************************************/
18
19
20#if defined (__cplusplus)
21extern "C" {
22#endif
23
24#ifndef ZSTD_BUFFERED_H_23987
25#define ZSTD_BUFFERED_H_23987
26
27/* *************************************
28* Dependencies
29***************************************/
30#include <stddef.h> /* size_t */
31#include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
32
33
34/* ***************************************************************
35* Compiler specifics
36*****************************************************************/
37/* Deprecation warnings */
38/* Should these warnings be a problem,
39 * it is generally possible to disable them,
40 * typically with -Wno-deprecated-declarations for gcc
41 * or _CRT_SECURE_NO_WARNINGS in Visual.
42 * Otherwise, it's also possible to define ZBUFF_DISABLE_DEPRECATE_WARNINGS
43 */
44#ifdef ZBUFF_DISABLE_DEPRECATE_WARNINGS
45# define ZBUFF_DEPRECATED(message) ZSTDLIB_API /* disable deprecation warnings */
46#else
47# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
48# define ZBUFF_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_API
49# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
50# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
51# elif defined(__GNUC__) && (__GNUC__ >= 3)
52# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
53# elif defined(_MSC_VER)
54# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
55# else
56# pragma message("WARNING: You need to implement ZBUFF_DEPRECATED for this compiler")
57# define ZBUFF_DEPRECATED(message) ZSTDLIB_API
58# endif
59#endif /* ZBUFF_DISABLE_DEPRECATE_WARNINGS */
60
61
62/* *************************************
63* Streaming functions
64***************************************/
65/* This is the easier "buffered" streaming API,
66* using an internal buffer to lift all restrictions on user-provided buffers
67* which can be any size, any place, for both input and output.
68* ZBUFF and ZSTD are 100% interoperable,
69* frames created by one can be decoded by the other one */
70
72ZBUFF_DEPRECATED("use ZSTD_createCStream") ZBUFF_CCtx* ZBUFF_createCCtx(void);
74
77
81
82/*-*************************************************
83* Streaming compression - howto
84*
85* A ZBUFF_CCtx object is required to track streaming operation.
86* Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
87* ZBUFF_CCtx objects can be reused multiple times.
88*
89* Start by initializing ZBUF_CCtx.
90* Use ZBUFF_compressInit() to start a new compression operation.
91* Use ZBUFF_compressInitDictionary() for a compression which requires a dictionary.
92*
93* Use ZBUFF_compressContinue() repetitively to consume input stream.
94* *srcSizePtr and *dstCapacityPtr can be any size.
95* The function will report how many bytes were read or written within *srcSizePtr and *dstCapacityPtr.
96* Note that it may not consume the entire input, in which case it's up to the caller to present again remaining data.
97* The content of `dst` will be overwritten (up to *dstCapacityPtr) at each call, so save its content if it matters or change @dst .
98* @return : a hint to preferred nb of bytes to use as input for next function call (it's just a hint, to improve latency)
99* or an error code, which can be tested using ZBUFF_isError().
100*
101* At any moment, it's possible to flush whatever data remains within buffer, using ZBUFF_compressFlush().
102* The nb of bytes written into `dst` will be reported into *dstCapacityPtr.
103* Note that the function cannot output more than *dstCapacityPtr,
104* therefore, some content might still be left into internal buffer if *dstCapacityPtr is too small.
105* @return : nb of bytes still present into internal buffer (0 if it's empty)
106* or an error code, which can be tested using ZBUFF_isError().
107*
108* ZBUFF_compressEnd() instructs to finish a frame.
109* It will perform a flush and write frame epilogue.
110* The epilogue is required for decoders to consider a frame completed.
111* Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
112* In which case, call again ZBUFF_compressFlush() to complete the flush.
113* @return : nb of bytes still present into internal buffer (0 if it's empty)
114* or an error code, which can be tested using ZBUFF_isError().
115*
116* Hint : _recommended buffer_ sizes (not compulsory) : ZBUFF_recommendedCInSize() / ZBUFF_recommendedCOutSize()
117* input : ZBUFF_recommendedCInSize==128 KB block size is the internal unit, use this value to reduce intermediate stages (better latency)
118* output : ZBUFF_recommendedCOutSize==ZSTD_compressBound(128 KB) + 3 + 3 : ensures it's always possible to write/flush/end a full block. Skip some buffering.
119* By using both, it ensures that input will be entirely consumed, and output will always contain the result, reducing intermediate buffering.
120* **************************************************/
121
122
126
129
131 void* dst, size_t* dstCapacityPtr,
132 const void* src, size_t* srcSizePtr);
133
134/*-***************************************************************************
135* Streaming decompression howto
136*
137* A ZBUFF_DCtx object is required to track streaming operations.
138* Use ZBUFF_createDCtx() and ZBUFF_freeDCtx() to create/release resources.
139* Use ZBUFF_decompressInit() to start a new decompression operation,
140* or ZBUFF_decompressInitDictionary() if decompression requires a dictionary.
141* Note that ZBUFF_DCtx objects can be re-init multiple times.
142*
143* Use ZBUFF_decompressContinue() repetitively to consume your input.
144* *srcSizePtr and *dstCapacityPtr can be any size.
145* The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
146* Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
147* The content of `dst` will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters, or change `dst`.
148* @return : 0 when a frame is completely decoded and fully flushed,
149* 1 when there is still some data left within internal buffer to flush,
150* >1 when more data is expected, with value being a suggested next input size (it's just a hint, which helps latency),
151* or an error code, which can be tested using ZBUFF_isError().
152*
153* Hint : recommended buffer sizes (not compulsory) : ZBUFF_recommendedDInSize() and ZBUFF_recommendedDOutSize()
154* output : ZBUFF_recommendedDOutSize== 128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
155* input : ZBUFF_recommendedDInSize == 128KB + 3;
156* just follow indications from ZBUFF_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
157* *******************************************************************************/
158
159
160/* *************************************
161* Tool functions
162***************************************/
163ZBUFF_DEPRECATED("use ZSTD_isError") unsigned ZBUFF_isError(size_t errorCode);
165
172
173#endif /* ZSTD_BUFFERED_H_23987 */
174
175
176#ifdef ZBUFF_STATIC_LINKING_ONLY
177#ifndef ZBUFF_STATIC_H_30298098432
178#define ZBUFF_STATIC_H_30298098432
179
180/* ====================================================================================
181 * The definitions in this section are considered experimental.
182 * They should never be used in association with a dynamic library, as they may change in the future.
183 * They are provided for advanced usages.
184 * Use them only in association with static linking.
185 * ==================================================================================== */
186
187/*--- Dependency ---*/
188#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_customMem */
189#include "../zstd.h"
190
191
192/*--- Custom memory allocator ---*/
195ZBUFF_DEPRECATED("use ZSTD_createCStream_advanced") ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
196
200
201
202/*--- Advanced Streaming Initialization ---*/
204 const void* dict, size_t dictSize,
205 ZSTD_parameters params, unsigned long long pledgedSrcSize);
206
207
208#endif /* ZBUFF_STATIC_H_30298098432 */
209#endif /* ZBUFF_STATIC_LINKING_ONLY */
210
211
212#if defined (__cplusplus)
213}
214#endif
Definition zstd_compress_internal.h:358
Definition zstd_decompress_internal.h:126
Definition zstd_v04.c:255
#define const
Definition zconf.h:230
const char * ZSTD_getErrorName(size_t code)
Definition zstd_common.c:41
#define ZSTD_isError
Definition zstd_internal.h:49
size_t ZSTD_compressStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
Definition zstd_compress.c:5507
size_t ZSTD_endStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output)
Definition zstd_compress.c:6167
size_t ZSTD_flushStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output)
Definition zstd_compress.c:6160
size_t ZSTD_initCStream(ZSTD_CStream *zcs, int compressionLevel)
Definition zstd_compress.c:5306
size_t ZSTD_CStreamInSize(void)
Definition zstd_compress.c:5181
size_t ZSTD_initCStream_usingDict(ZSTD_CStream *zcs, const void *dict, size_t dictSize, int compressionLevel)
Definition zstd_compress.c:5282
size_t ZSTD_freeCStream(ZSTD_CStream *zcs)
Definition zstd_compress.c:5172
size_t ZSTD_CStreamOutSize(void)
Definition zstd_compress.c:5183
ZSTD_DStream * ZSTD_createDStream(void)
Definition zstd_decompress.c:1549
size_t ZSTD_freeDStream(ZSTD_DStream *zds)
Definition zstd_decompress.c:1565
size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
Definition zstd_decompress.c:1924
ZSTD_DStream * ZSTD_createDStream_advanced(ZSTD_customMem customMem)
Definition zstd_decompress.c:1560
size_t ZSTD_initDStream(ZSTD_DStream *zds)
Definition zstd_decompress.c:1627
size_t ZSTD_DStreamOutSize(void)
Definition zstd_decompress.c:1574
size_t ZSTD_DStreamInSize(void)
Definition zstd_decompress.c:1573
size_t ZSTD_initDStream_usingDict(ZSTD_DStream *zds, const void *dict, size_t dictSize)
Definition zstd_decompress.c:1618
const void * dict
Definition zbuff.h:76
#define ZBUFF_DEPRECATED(message)
Definition zbuff.h:57
void size_t const void * src
Definition zbuff.h:78
void * dst
Definition zbuff.h:78
void size_t * dstCapacityPtr
Definition zbuff.h:78
const void size_t dictSize
Definition zbuff.h:76
ZSTD_CStream ZBUFF_CCtx
Definition zbuff.h:71
int compressionLevel
Definition zbuff.h:75
void size_t const void size_t * srcSizePtr
Definition zbuff.h:78
unsigned ZBUFF_isError(size_t errorCode)
Definition zbuff_common.c:23
const char * ZBUFF_getErrorName(size_t errorCode)
Definition zbuff_common.c:26
size_t ZBUFF_freeCCtx(ZBUFF_CCtx *zbc)
Definition zbuff_compress.c:64
size_t ZBUFF_compressInit(ZBUFF_CCtx *zbc, int compressionLevel)
Definition zbuff_compress.c:105
size_t ZBUFF_compressEnd(ZBUFF_CCtx *zbc, void *dst, size_t *dstCapacityPtr)
Definition zbuff_compress.c:149
ZBUFF_CCtx * ZBUFF_createCCtx(void)
Definition zbuff_compress.c:54
size_t ZBUFF_compressFlush(ZBUFF_CCtx *zbc, void *dst, size_t *dstCapacityPtr)
Definition zbuff_compress.c:136
size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx *zbc, const void *dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize)
Definition zbuff_compress.c:72
ZBUFF_CCtx * ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
Definition zbuff_compress.c:59
size_t ZBUFF_compressContinue(ZBUFF_CCtx *zbc, void *dst, size_t *dstCapacityPtr, const void *src, size_t *srcSizePtr)
Definition zbuff_compress.c:113
size_t ZBUFF_recommendedCOutSize(void)
Definition zbuff_compress.c:167
size_t ZBUFF_recommendedCInSize(void)
Definition zbuff_compress.c:166
size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx *zbc, const void *dict, size_t dictSize, int compressionLevel)
Definition zbuff_compress.c:97
size_t ZBUFF_decompressInit(ZBUFF_DCtx *zbd)
Definition zbuff_decompress.c:43
ZBUFF_DCtx * ZBUFF_createDCtx(void)
Definition zbuff_decompress.c:20
size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx *zbd, const void *dict, size_t dictSize)
Definition zbuff_decompress.c:38
ZBUFF_DCtx * ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
Definition zbuff_decompress.c:25
size_t ZBUFF_recommendedDInSize(void)
Definition zbuff_decompress.c:74
size_t ZBUFF_recommendedDOutSize(void)
Definition zbuff_decompress.c:75
size_t ZBUFF_decompressContinue(ZBUFF_DCtx *zbd, void *dst, size_t *dstCapacityPtr, const void *src, size_t *srcSizePtr)
Definition zbuff_decompress.c:51
size_t ZBUFF_freeDCtx(ZBUFF_DCtx *zbd)
Definition zbuff_decompress.c:30