00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #if defined (__cplusplus)
00036 extern "C" {
00037 #endif
00038
00039 #ifndef LZ4_H_2983827168210
00040 #define LZ4_H_2983827168210
00041
00042
00043 #include <stddef.h>
00044
00045
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #ifndef LZ4LIB_VISIBILITY
00079 # if defined(__GNUC__) && (__GNUC__ >= 4)
00080 # define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
00081 # else
00082 # define LZ4LIB_VISIBILITY
00083 # endif
00084 #endif
00085 #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
00086 # define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
00087 #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
00088 # define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY
00089 #else
00090 # define LZ4LIB_API LZ4LIB_VISIBILITY
00091 #endif
00092
00093
00094 #define LZ4_VERSION_MAJOR 1
00095 #define LZ4_VERSION_MINOR 8
00096 #define LZ4_VERSION_RELEASE 3
00097
00098 #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
00099
00100 #define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
00101 #define LZ4_QUOTE(str) #str
00102 #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
00103 #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)
00104
00105 LZ4LIB_API int LZ4_versionNumber (void);
00106 LZ4LIB_API const char* LZ4_versionString (void);
00109
00110
00111
00119 #ifndef LZ4_MEMORY_USAGE
00120 # define LZ4_MEMORY_USAGE 14
00121 #endif
00122
00123
00124
00125
00139 LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
00140
00149 LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
00150
00151
00152
00153
00154
00155 #define LZ4_MAX_INPUT_SIZE 0x7E000000
00156 #define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
00157
00168 LZ4LIB_API int LZ4_compressBound(int inputSize);
00169
00178 LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
00179
00180
00188 LZ4LIB_API int LZ4_sizeofState(void);
00189 LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
00190
00191
00204 LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
00205
00206
00226 LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
00227
00252 LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
00253
00254
00255
00256
00257
00258 typedef union LZ4_stream_u LZ4_stream_t;
00259
00264 LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
00265 LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
00266
00271 LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
00272
00279 LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
00280
00304 LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
00305
00313 LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
00314
00315
00316
00317
00318
00319
00320 typedef union LZ4_streamDecode_u LZ4_streamDecode_t;
00321
00326 LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
00327 LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
00328
00336 LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
00337
00349 LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
00350 #define LZ4_DECODER_RING_BUFFER_SIZE(mbs) (65536 + 14 + (mbs))
00351
00377 LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int srcSize, int dstCapacity);
00378 LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
00379
00380
00387 LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize);
00388 LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 #ifdef LZ4_STATIC_LINKING_ONLY
00405
00437 LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
00438
00450 LZ4LIB_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
00451
00478 LZ4LIB_API void LZ4_attach_dictionary(LZ4_stream_t *working_stream, const LZ4_stream_t *dictionary_stream);
00479
00480 #endif
00481
00482
00483
00484
00485
00486
00487
00488
00489 #define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
00490 #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
00491 #define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG)
00492
00493 #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) )
00494 #include <stdint.h>
00495
00496 typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
00497 struct LZ4_stream_t_internal {
00498 uint32_t hashTable[LZ4_HASH_SIZE_U32];
00499 uint32_t currentOffset;
00500 uint16_t initCheck;
00501 uint16_t tableType;
00502 const uint8_t* dictionary;
00503 const LZ4_stream_t_internal* dictCtx;
00504 uint32_t dictSize;
00505 };
00506
00507 typedef struct {
00508 const uint8_t* externalDict;
00509 size_t extDictSize;
00510 const uint8_t* prefixEnd;
00511 size_t prefixSize;
00512 } LZ4_streamDecode_t_internal;
00513
00514 #else
00515
00516 typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
00517 struct LZ4_stream_t_internal {
00518 unsigned int hashTable[LZ4_HASH_SIZE_U32];
00519 unsigned int currentOffset;
00520 unsigned short initCheck;
00521 unsigned short tableType;
00522 const unsigned char* dictionary;
00523 const LZ4_stream_t_internal* dictCtx;
00524 unsigned int dictSize;
00525 };
00526
00527 typedef struct {
00528 const unsigned char* externalDict;
00529 size_t extDictSize;
00530 const unsigned char* prefixEnd;
00531 size_t prefixSize;
00532 } LZ4_streamDecode_t_internal;
00533
00534 #endif
00535
00544 #define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
00545 #define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
00546 union LZ4_stream_u {
00547 unsigned long long table[LZ4_STREAMSIZE_U64];
00548 LZ4_stream_t_internal internal_donotuse;
00549 } ;
00550
00551
00560 #define LZ4_STREAMDECODESIZE_U64 4
00561 #define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
00562 union LZ4_streamDecode_u {
00563 unsigned long long table[LZ4_STREAMDECODESIZE_U64];
00564 LZ4_streamDecode_t_internal internal_donotuse;
00565 } ;
00566
00567
00568
00569
00570
00571
00578 #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
00579 # define LZ4_DEPRECATED(message)
00580 #else
00581 # define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
00582 # if defined (__cplusplus) && (__cplusplus >= 201402)
00583 # define LZ4_DEPRECATED(message) [[deprecated(message)]]
00584 # elif (LZ4_GCC_VERSION >= 405) || defined(__clang__)
00585 # define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
00586 # elif (LZ4_GCC_VERSION >= 301)
00587 # define LZ4_DEPRECATED(message) __attribute__((deprecated))
00588 # elif defined(_MSC_VER)
00589 # define LZ4_DEPRECATED(message) __declspec(deprecated(message))
00590 # else
00591 # pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
00592 # define LZ4_DEPRECATED(message)
00593 # endif
00594 #endif
00595
00596
00597 LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* source, char* dest, int sourceSize);
00598 LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
00599 LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
00600 LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
00601 LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
00602 LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
00603
00604
00605 LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize);
00606 LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617 LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer);
00618 LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void);
00619 LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer);
00620 LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state);
00621
00622
00623 LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
00624 LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
00625
00626 #endif
00627
00628
00629 #if defined (__cplusplus)
00630 }
00631 #endif