Path: blob/main/sys/contrib/zstd/lib/legacy/zstd_v01.h
48378 views
/*1* Copyright (c) Yann Collet, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under both the BSD-style license (found in the5* LICENSE file in the root directory of this source tree) and the GPLv2 (found6* in the COPYING file in the root directory of this source tree).7* You may select, at your option, one of the above-listed licenses.8*/910#ifndef ZSTD_V01_H_2873987943211#define ZSTD_V01_H_287398794321213#if defined (__cplusplus)14extern "C" {15#endif1617/* *************************************18* Includes19***************************************/20#include <stddef.h> /* size_t */212223/* *************************************24* Simple one-step function25***************************************/26/**27ZSTDv01_decompress() : decompress ZSTD frames compliant with v0.1.x format28compressedSize : is the exact source size29maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated.30It must be equal or larger than originalSize, otherwise decompression will fail.31return : the number of bytes decompressed into destination buffer (originalSize)32or an errorCode if it fails (which can be tested using ZSTDv01_isError())33*/34size_t ZSTDv01_decompress( void* dst, size_t maxOriginalSize,35const void* src, size_t compressedSize);3637/**38ZSTDv01_findFrameSizeInfoLegacy() : get the source length and decompressed bound of a ZSTD frame compliant with v0.1.x format39srcSize : The size of the 'src' buffer, at least as large as the frame pointed to by 'src'40cSize (output parameter) : the number of bytes that would be read to decompress this frame41or an error code if it fails (which can be tested using ZSTDv01_isError())42dBound (output parameter) : an upper-bound for the decompressed size of the data in the frame43or ZSTD_CONTENTSIZE_ERROR if an error occurs4445note : assumes `cSize` and `dBound` are _not_ NULL.46*/47void ZSTDv01_findFrameSizeInfoLegacy(const void *src, size_t srcSize,48size_t* cSize, unsigned long long* dBound);4950/**51ZSTDv01_isError() : tells if the result of ZSTDv01_decompress() is an error52*/53unsigned ZSTDv01_isError(size_t code);545556/* *************************************57* Advanced functions58***************************************/59typedef struct ZSTDv01_Dctx_s ZSTDv01_Dctx;60ZSTDv01_Dctx* ZSTDv01_createDCtx(void);61size_t ZSTDv01_freeDCtx(ZSTDv01_Dctx* dctx);6263size_t ZSTDv01_decompressDCtx(void* ctx,64void* dst, size_t maxOriginalSize,65const void* src, size_t compressedSize);6667/* *************************************68* Streaming functions69***************************************/70size_t ZSTDv01_resetDCtx(ZSTDv01_Dctx* dctx);7172size_t ZSTDv01_nextSrcSizeToDecompress(ZSTDv01_Dctx* dctx);73size_t ZSTDv01_decompressContinue(ZSTDv01_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);74/**75Use above functions alternatively.76ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue().77ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block.78Result is the number of bytes regenerated within 'dst'.79It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header.80*/8182/* *************************************83* Prefix - version detection84***************************************/85#define ZSTDv01_magicNumber 0xFD2FB51E /* Big Endian version */86#define ZSTDv01_magicNumberLE 0x1EB52FFD /* Little Endian version */878889#if defined (__cplusplus)90}91#endif9293#endif /* ZSTD_V01_H_28739879432 */949596