![]() |
Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
|
#include <limits.h>
#include "lz4frame.h"
#include "lz4.h"
#include "lz4hc.h"
#include "xxhash.h"
#include <string.h>
Data Structures | |
struct | LZ4F_cctx_s |
struct | LZ4F_CDict_s |
struct | LZ4F_dctx_s |
Macros | |
#define | LZ4F_HEAPMODE 0 |
#define | LZ4F_STATIC_LINKING_ONLY |
#define | LZ4_STATIC_LINKING_ONLY |
#define | LZ4_HC_STATIC_LINKING_ONLY |
#define | XXH_STATIC_LINKING_ONLY |
#define | assert(condition) |
#define | LZ4F_STATIC_ASSERT(c) |
#define | DEBUGLOG(l, ...) |
#define | _1BIT 0x01 |
#define | _2BITS 0x03 |
#define | _3BITS 0x07 |
#define | _4BITS 0x0F |
#define | _8BITS 0xFF |
#define | LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U |
#define | LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB |
#define | LZ4F_GENERATE_STRING(STRING) |
#define | RETURN_ERROR(e) |
#define | RETURN_ERROR_IF(c, e) |
#define | FORWARD_IF_ERROR(r) |
#define | MIN(a, b) |
Typedefs | |
typedef struct LZ4F_cctx_s | LZ4F_cctx_t |
typedef int(* | compressFunc_t) (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level, const LZ4F_CDict *cdict) |
Enumerations | |
enum | LZ4F_BlockCompressMode_e { LZ4B_COMPRESSED , LZ4B_UNCOMPRESSED } |
enum | LZ4F_CtxType_e { ctxNone , ctxFast , ctxHC } |
enum | LZ4F_lastBlockStatus { notDone , fromTmpBuffer , fromSrcBuffer } |
enum | dStage_t { dstage_getFrameHeader =0 , dstage_storeFrameHeader , dstage_init , dstage_getBlockHeader , dstage_storeBlockHeader , dstage_copyDirect , dstage_getBlockChecksum , dstage_getCBlock , dstage_storeCBlock , dstage_flushOut , dstage_getSuffix , dstage_storeSuffix , dstage_getSFrameSize , dstage_storeSFrameSize , dstage_skipSkippable } |
Functions | |
unsigned | LZ4F_isError (LZ4F_errorCode_t code) |
const char * | LZ4F_getErrorName (LZ4F_errorCode_t code) |
LZ4F_errorCodes | LZ4F_getErrorCode (size_t functionResult) |
unsigned | LZ4F_getVersion (void) |
int | LZ4F_compressionLevel_max (void) |
size_t | LZ4F_getBlockSize (LZ4F_blockSizeID_t blockSizeID) |
size_t | LZ4F_compressFrameBound (size_t srcSize, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressFrame_usingCDict (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressFrame (void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_preferences_t *preferencesPtr) |
LZ4F_CDict * | LZ4F_createCDict_advanced (LZ4F_CustomMem cmem, const void *dictBuffer, size_t dictSize) |
LZ4F_CDict * | LZ4F_createCDict (const void *dictBuffer, size_t dictSize) |
void | LZ4F_freeCDict (LZ4F_CDict *cdict) |
LZ4F_cctx * | LZ4F_createCompressionContext_advanced (LZ4F_CustomMem customMem, unsigned version) |
LZ4F_errorCode_t | LZ4F_createCompressionContext (LZ4F_cctx **LZ4F_compressionContextPtr, unsigned version) |
LZ4F_errorCode_t | LZ4F_freeCompressionContext (LZ4F_cctx *cctxPtr) |
size_t | LZ4F_compressBegin_internal (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *dictBuffer, size_t dictSize, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressBegin (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressBegin_usingDictOnce (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *dict, size_t dictSize, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressBegin_usingDict (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *dict, size_t dictSize, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressBegin_usingCDict (LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressBound (size_t srcSize, const LZ4F_preferences_t *preferencesPtr) |
size_t | LZ4F_compressUpdate (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr) |
size_t | LZ4F_uncompressedUpdate (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr) |
size_t | LZ4F_flush (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr) |
size_t | LZ4F_compressEnd (LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr) |
LZ4F_dctx * | LZ4F_createDecompressionContext_advanced (LZ4F_CustomMem customMem, unsigned version) |
LZ4F_errorCode_t | LZ4F_createDecompressionContext (LZ4F_dctx **LZ4F_decompressionContextPtr, unsigned versionNumber) |
LZ4F_errorCode_t | LZ4F_freeDecompressionContext (LZ4F_dctx *dctx) |
void | LZ4F_resetDecompressionContext (LZ4F_dctx *dctx) |
size_t | LZ4F_headerSize (const void *src, size_t srcSize) |
LZ4F_errorCode_t | LZ4F_getFrameInfo (LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr) |
size_t | LZ4F_decompress (LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const LZ4F_decompressOptions_t *decompressOptionsPtr) |
size_t | LZ4F_decompress_usingDict (LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const void *dict, size_t dictSize, const LZ4F_decompressOptions_t *decompressOptionsPtr) |
#define _1BIT 0x01 |
#define _2BITS 0x03 |
#define _3BITS 0x07 |
#define _4BITS 0x0F |
#define _8BITS 0xFF |
#define assert | ( | condition | ) |
#define DEBUGLOG | ( | l, | |
... ) |
#define FORWARD_IF_ERROR | ( | r | ) |
#define LZ4_HC_STATIC_LINKING_ONLY |
#define LZ4_STATIC_LINKING_ONLY |
#define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB |
#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U |
#define LZ4F_GENERATE_STRING | ( | STRING | ) |
#define LZ4F_HEAPMODE 0 |
#define LZ4F_STATIC_ASSERT | ( | c | ) |
#define LZ4F_STATIC_LINKING_ONLY |
#define RETURN_ERROR | ( | e | ) |
#define XXH_STATIC_LINKING_ONLY |
typedef int(* compressFunc_t) (void *ctx, const char *src, char *dst, int srcSize, int dstSize, int level, const LZ4F_CDict *cdict) |
typedef struct LZ4F_cctx_s LZ4F_cctx_t |
enum dStage_t |
enum LZ4F_CtxType_e |
enum LZ4F_lastBlockStatus |
size_t LZ4F_compressBegin | ( | LZ4F_cctx * | cctx, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_preferences_t * | prefsPtr ) |
LZ4F_compressBegin() : will write the frame header into dstBuffer. dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. prefsPtr
is optional : NULL can be provided to set all preferences to default.
size_t LZ4F_compressBegin_internal | ( | LZ4F_cctx * | cctx, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | dictBuffer, | ||
size_t | dictSize, | ||
const LZ4F_CDict * | cdict, | ||
const LZ4F_preferences_t * | preferencesPtr ) |
size_t LZ4F_compressBegin_usingCDict | ( | LZ4F_cctx * | cctx, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_CDict * | cdict, | ||
const LZ4F_preferences_t * | prefsPtr ) |
LZ4F_compressBegin_usingCDict() : stable since v1.10 Inits streaming dictionary compression, and writes the frame header into dstBuffer. @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. @prefsPtr is optional : one may provide NULL as argument, note however that it's the only way to insert a @dictID in the frame header. @cdict must outlive the compression session.
size_t LZ4F_compressBegin_usingDict | ( | LZ4F_cctx * | cctx, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | dictBuffer, | ||
size_t | dictSize, | ||
const LZ4F_preferences_t * | prefsPtr ) |
LZ4F_compressBegin_usingDict() : stable since v1.10 Inits dictionary compression streaming, and writes the frame header into dstBuffer. @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. @prefsPtr is optional : one may provide NULL as argument, however, it's the only way to provide dictID in the frame header. @dictBuffer must outlive the compression session.
size_t LZ4F_compressBegin_usingDictOnce | ( | LZ4F_cctx * | cctx, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | dict, | ||
size_t | dictSize, | ||
const LZ4F_preferences_t * | preferencesPtr ) |
size_t LZ4F_compressBound | ( | size_t | srcSize, |
const LZ4F_preferences_t * | prefsPtr ) |
LZ4F_compressBound() : Provides minimum dstCapacity required to guarantee success of LZ4F_compressUpdate(), given a srcSize and preferences, for a worst case scenario. When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() instead. Note that the result is only valid for a single invocation of LZ4F_compressUpdate(). When invoking LZ4F_compressUpdate() multiple times, if the output buffer is gradually filled up instead of emptied and re-used from its start, one must check if there is enough remaining capacity before each invocation, using LZ4F_compressBound().
size_t LZ4F_compressEnd | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_compressOptions_t * | compressOptionsPtr ) |
LZ4F_compressEnd() : When you want to properly finish the compressed frame, just call LZ4F_compressEnd(). It will flush whatever data remained within compressionContext (like LZ4_flush()) but also properly finalize the frame, with an endMark and an (optional) checksum. LZ4F_compressOptions_t structure is optional : you can provide NULL as argument.
size_t LZ4F_compressFrame | ( | void * | dstBuffer, |
size_t | dstCapacity, | ||
const void * | srcBuffer, | ||
size_t | srcSize, | ||
const LZ4F_preferences_t * | preferencesPtr ) |
LZ4F_compressFrame() : Compress an entire srcBuffer into a valid LZ4 frame, in a single step. dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). The LZ4F_preferences_t structure is optional : you can provide NULL as argument. All preferences will be set to default.
size_t LZ4F_compressFrame_usingCDict | ( | LZ4F_cctx * | cctx, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | srcBuffer, | ||
size_t | srcSize, | ||
const LZ4F_CDict * | cdict, | ||
const LZ4F_preferences_t * | preferencesPtr ) |
LZ4F_compressFrame_usingCDict() : Compress srcBuffer using a dictionary, in a single step. cdict can be NULL, in which case, no dictionary is used. dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). The LZ4F_preferences_t structure is optional : you may provide NULL as argument, however, it's the only way to provide a dictID, so it's not recommended.
size_t LZ4F_compressFrameBound | ( | size_t | srcSize, |
const LZ4F_preferences_t * | preferencesPtr ) |
LZ4F_compressFrameBound() : Returns the maximum possible compressed size with LZ4F_compressFrame() given srcSize and preferences. preferencesPtr
is optional. It can be replaced by NULL, in which case, the function will assume default preferences. Note : this result is only usable with LZ4F_compressFrame(). It may also be relevant to LZ4F_compressUpdate() only if no flush() operation is ever performed.
int LZ4F_compressionLevel_max | ( | void | ) |
size_t LZ4F_compressUpdate | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | srcBuffer, | ||
size_t | srcSize, | ||
const LZ4F_compressOptions_t * | compressOptionsPtr ) |
LZ4F_compressUpdate() : LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. When successful, the function always entirely consumes @srcBuffer. src data is either buffered or compressed into @dstBuffer. If previously an uncompressed block was written, buffered data is flushed before appending compressed data is continued. @dstCapacity MUST be >= LZ4F_compressBound(srcSize, preferencesPtr). @compressOptionsPtr is optional : provide NULL to mean "default".
LZ4F_CDict * LZ4F_createCDict | ( | const void * | dictBuffer, |
size_t | dictSize ) |
LZ4F_createCDict() : When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once. LZ4F_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. LZ4F_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. @dictBuffer can be released after LZ4F_CDict creation, since its content is copied within CDict
LZ4F_CDict * LZ4F_createCDict_advanced | ( | LZ4F_CustomMem | cmem, |
const void * | dictBuffer, | ||
size_t | dictSize ) |
LZ4F_errorCode_t LZ4F_createCompressionContext | ( | LZ4F_cctx ** | LZ4F_compressionContextPtr, |
unsigned | version ) |
LZ4F_createCompressionContext() : The first thing to do is to create a compressionContext object, which will be used in all compression operations. This is achieved using LZ4F_createCompressionContext(), which takes as argument a version and an LZ4F_preferences_t structure. The version provided MUST be LZ4F_VERSION. It is intended to track potential incompatible differences between different binaries. The function will provide a pointer to an allocated LZ4F_compressionContext_t object. If the result LZ4F_errorCode_t is not OK_NoError, there was an error during context creation. Object can release its memory using LZ4F_freeCompressionContext();
LZ4F_cctx * LZ4F_createCompressionContext_advanced | ( | LZ4F_CustomMem | customMem, |
unsigned | version ) |
LZ4F_errorCode_t LZ4F_createDecompressionContext | ( | LZ4F_dctx ** | LZ4F_decompressionContextPtr, |
unsigned | versionNumber ) |
LZ4F_createDecompressionContext() : Create a decompressionContext object, which will track all decompression operations. Provides a pointer to a fully allocated and initialized LZ4F_decompressionContext object. Object can later be released using LZ4F_freeDecompressionContext().
LZ4F_dctx * LZ4F_createDecompressionContext_advanced | ( | LZ4F_CustomMem | customMem, |
unsigned | version ) |
size_t LZ4F_decompress | ( | LZ4F_dctx * | dctx, |
void * | dstBuffer, | ||
size_t * | dstSizePtr, | ||
const void * | srcBuffer, | ||
size_t * | srcSizePtr, | ||
const LZ4F_decompressOptions_t * | decompressOptionsPtr ) |
LZ4F_decompress() : Call this function repetitively to regenerate compressed data in srcBuffer. The function will attempt to decode up to *srcSizePtr bytes from srcBuffer into dstBuffer of capacity *dstSizePtr.
The number of bytes regenerated into dstBuffer will be provided within *dstSizePtr (necessarily <= original value).
The number of bytes effectively read from srcBuffer will be provided within *srcSizePtr (necessarily <= original value). If number of bytes read is < number of bytes provided, then decompression operation is not complete. Remaining data will have to be presented again in a subsequent invocation.
The function result is an hint of the better srcSize to use for next call to LZ4F_decompress. Schematically, it's the size of the current (or remaining) compressed block + header of next block. Respecting the hint provides a small boost to performance, since it allows less buffer shuffling. Note that this is just a hint, and it's always possible to any srcSize value. When a frame is fully decoded,
size_t LZ4F_decompress_usingDict | ( | LZ4F_dctx * | dctx, |
void * | dstBuffer, | ||
size_t * | dstSizePtr, | ||
const void * | srcBuffer, | ||
size_t * | srcSizePtr, | ||
const void * | dict, | ||
size_t | dictSize, | ||
const LZ4F_decompressOptions_t * | decompressOptionsPtr ) |
LZ4F_decompress_usingDict() : Same as LZ4F_decompress(), using a predefined dictionary. Dictionary is used "in place", without any preprocessing. It must remain accessible throughout the entire frame decoding.
size_t LZ4F_flush | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const LZ4F_compressOptions_t * | compressOptionsPtr ) |
LZ4F_flush() : When compressed data must be sent immediately, without waiting for a block to be filled, invoke LZ4_flush(), which will immediately compress any remaining data stored within LZ4F_cctx. The result of the function is the number of bytes written into dstBuffer. It can be zero, this means there was no data left within LZ4F_cctx. The function outputs an error code if it fails (can be tested using LZ4F_isError()) LZ4F_compressOptions_t* is optional. NULL is a valid argument.
void LZ4F_freeCDict | ( | LZ4F_CDict * | cdict | ) |
LZ4F_errorCode_t LZ4F_freeCompressionContext | ( | LZ4F_cctx * | cctxPtr | ) |
LZ4F_errorCode_t LZ4F_freeDecompressionContext | ( | LZ4F_dctx * | dctx | ) |
size_t LZ4F_getBlockSize | ( | LZ4F_blockSizeID_t | blockSizeID | ) |
LZ4F_errorCodes LZ4F_getErrorCode | ( | size_t | functionResult | ) |
const char * LZ4F_getErrorName | ( | LZ4F_errorCode_t | code | ) |
return error code string; for debugging
LZ4F_errorCode_t LZ4F_getFrameInfo | ( | LZ4F_dctx * | dctx, |
LZ4F_frameInfo_t * | frameInfoPtr, | ||
const void * | srcBuffer, | ||
size_t * | srcSizePtr ) |
LZ4F_getFrameInfo() : This function extracts frame parameters (max blockSize, frame checksum, etc.). Usage is optional. Objective is to provide relevant information for allocation purposes. This function works in 2 situations :
srcBuffer
, and start the decoding process. Amount of input data provided must be large enough to successfully decode the frame header. A header size is variable, but is guaranteed to be <= LZ4F_HEADER_SIZE_MAX bytes. It's possible to provide more input data than this minimum.unsigned LZ4F_getVersion | ( | void | ) |
size_t LZ4F_headerSize | ( | const void * | src, |
size_t | srcSize ) |
unsigned LZ4F_isError | ( | LZ4F_errorCode_t | code | ) |
tells when a function result is an error code
void LZ4F_resetDecompressionContext | ( | LZ4F_dctx * | dctx | ) |
LZ4F_resetDecompressionContext() : added in v1.8.0 In case of an error, the context is left in "undefined" state. In which case, it's necessary to reset it, before re-using it. This method can also be used to abruptly stop any unfinished decompression, and start a new one using same context resources.
size_t LZ4F_uncompressedUpdate | ( | LZ4F_cctx * | cctxPtr, |
void * | dstBuffer, | ||
size_t | dstCapacity, | ||
const void * | srcBuffer, | ||
size_t | srcSize, | ||
const LZ4F_compressOptions_t * | compressOptionsPtr ) |
LZ4F_uncompressedUpdate() : Same as LZ4F_compressUpdate(), but requests blocks to be sent uncompressed. This symbol is only supported when LZ4F_blockIndependent is used @dstCapacity MUST be >= LZ4F_compressBound(srcSize, preferencesPtr). @compressOptionsPtr is optional : provide NULL to mean "default".