extlz4 0.2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/HISTORY.ja.md +116 -0
- data/LICENSE +24 -0
- data/README.md +203 -0
- data/Rakefile +212 -0
- data/bin/extlz4 +220 -0
- data/contrib/lz4/INSTALL +15 -0
- data/contrib/lz4/LICENSE +11 -0
- data/contrib/lz4/NEWS +231 -0
- data/contrib/lz4/README.md +114 -0
- data/contrib/lz4/circle.yml +39 -0
- data/contrib/lz4/lib/LICENSE +24 -0
- data/contrib/lz4/lib/README.md +73 -0
- data/contrib/lz4/lib/liblz4.pc.in +14 -0
- data/contrib/lz4/lib/lz4.c +1478 -0
- data/contrib/lz4/lib/lz4.h +463 -0
- data/contrib/lz4/lib/lz4frame.c +1669 -0
- data/contrib/lz4/lib/lz4frame.h +391 -0
- data/contrib/lz4/lib/lz4frame_static.h +143 -0
- data/contrib/lz4/lib/lz4hc.c +807 -0
- data/contrib/lz4/lib/lz4hc.h +278 -0
- data/contrib/lz4/lib/lz4opt.h +366 -0
- data/contrib/lz4/lib/xxhash.c +894 -0
- data/contrib/lz4/lib/xxhash.h +293 -0
- data/examples/frameapi.rb +43 -0
- data/ext/blockapi.c +1046 -0
- data/ext/depend +4 -0
- data/ext/extconf.rb +60 -0
- data/ext/extlz4.c +69 -0
- data/ext/extlz4.h +109 -0
- data/ext/frameapi.c +780 -0
- data/ext/hashargs.c +151 -0
- data/ext/hashargs.h +110 -0
- data/ext/lz4_amalgam.c +31 -0
- data/gemstub.rb +40 -0
- data/lib/extlz4.rb +327 -0
- data/lib/extlz4/compat.rb +12 -0
- data/lib/extlz4/fix-0.1bug.rb +96 -0
- data/lib/extlz4/oldstream.rb +529 -0
- data/lib/extlz4/version.rb +3 -0
- data/test/common.rb +18 -0
- data/test/test_blockapi.rb +105 -0
- data/test/test_frameapi.rb +59 -0
- metadata +126 -0
@@ -0,0 +1,463 @@
|
|
1
|
+
/*
|
2
|
+
* LZ4 - Fast LZ compression algorithm
|
3
|
+
* Header File
|
4
|
+
* Copyright (C) 2011-2017, Yann Collet.
|
5
|
+
|
6
|
+
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions are
|
10
|
+
met:
|
11
|
+
|
12
|
+
* Redistributions of source code must retain the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer.
|
14
|
+
* Redistributions in binary form must reproduce the above
|
15
|
+
copyright notice, this list of conditions and the following disclaimer
|
16
|
+
in the documentation and/or other materials provided with the
|
17
|
+
distribution.
|
18
|
+
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
You can contact the author at :
|
32
|
+
- LZ4 homepage : http://www.lz4.org
|
33
|
+
- LZ4 source repository : https://github.com/lz4/lz4
|
34
|
+
*/
|
35
|
+
#if defined (__cplusplus)
|
36
|
+
extern "C" {
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#ifndef LZ4_H_2983827168210
|
40
|
+
#define LZ4_H_2983827168210
|
41
|
+
|
42
|
+
/* --- Dependency --- */
|
43
|
+
#include <stddef.h> /* size_t */
|
44
|
+
|
45
|
+
|
46
|
+
/**
|
47
|
+
Introduction
|
48
|
+
|
49
|
+
LZ4 is lossless compression algorithm, providing compression speed at 400 MB/s per core,
|
50
|
+
scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
|
51
|
+
multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
|
52
|
+
|
53
|
+
The LZ4 compression library provides in-memory compression and decompression functions.
|
54
|
+
Compression can be done in:
|
55
|
+
- a single step (described as Simple Functions)
|
56
|
+
- a single step, reusing a context (described in Advanced Functions)
|
57
|
+
- unbounded multiple steps (described as Streaming compression)
|
58
|
+
|
59
|
+
lz4.h provides block compression functions. It gives full buffer control to user.
|
60
|
+
Decompressing an lz4-compressed block also requires metadata (such as compressed size).
|
61
|
+
Each application is free to encode such metadata in whichever way it wants.
|
62
|
+
|
63
|
+
An additional format, called LZ4 frame specification (doc/lz4_Frame_format.md),
|
64
|
+
take care of encoding standard metadata alongside LZ4-compressed blocks.
|
65
|
+
If your application requires interoperability, it's recommended to use it.
|
66
|
+
A library is provided to take care of it, see lz4frame.h.
|
67
|
+
*/
|
68
|
+
|
69
|
+
/*^***************************************************************
|
70
|
+
* Export parameters
|
71
|
+
*****************************************************************/
|
72
|
+
/*
|
73
|
+
* LZ4_DLL_EXPORT :
|
74
|
+
* Enable exporting of functions when building a Windows DLL
|
75
|
+
* LZ4LIB_API :
|
76
|
+
* Control library symbols visibility.
|
77
|
+
*/
|
78
|
+
#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
|
79
|
+
# define LZ4LIB_API __declspec(dllexport)
|
80
|
+
#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
|
81
|
+
# define LZ4LIB_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
82
|
+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
83
|
+
# define LZ4LIB_API __attribute__ ((__visibility__ ("default")))
|
84
|
+
#else
|
85
|
+
# define LZ4LIB_API
|
86
|
+
#endif
|
87
|
+
|
88
|
+
|
89
|
+
/*------ Version ------*/
|
90
|
+
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
|
91
|
+
#define LZ4_VERSION_MINOR 8 /* for new (non-breaking) interface capabilities */
|
92
|
+
#define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
|
93
|
+
|
94
|
+
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
|
95
|
+
|
96
|
+
#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
|
97
|
+
#define LZ4_QUOTE(str) #str
|
98
|
+
#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
|
99
|
+
#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)
|
100
|
+
|
101
|
+
LZ4LIB_API int LZ4_versionNumber (void); /**< library version number; to be used when checking dll version */
|
102
|
+
LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; to be used when checking dll version */
|
103
|
+
|
104
|
+
|
105
|
+
/*-************************************
|
106
|
+
* Tuning parameter
|
107
|
+
**************************************/
|
108
|
+
/*!
|
109
|
+
* LZ4_MEMORY_USAGE :
|
110
|
+
* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
|
111
|
+
* Increasing memory usage improves compression ratio
|
112
|
+
* Reduced memory usage can improve speed, due to cache effect
|
113
|
+
* Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
|
114
|
+
*/
|
115
|
+
#ifndef LZ4_MEMORY_USAGE
|
116
|
+
# define LZ4_MEMORY_USAGE 14
|
117
|
+
#endif
|
118
|
+
|
119
|
+
/*-************************************
|
120
|
+
* Simple Functions
|
121
|
+
**************************************/
|
122
|
+
/*! LZ4_compress_default() :
|
123
|
+
Compresses 'sourceSize' bytes from buffer 'source'
|
124
|
+
into already allocated 'dest' buffer of size 'maxDestSize'.
|
125
|
+
Compression is guaranteed to succeed if 'maxDestSize' >= LZ4_compressBound(sourceSize).
|
126
|
+
It also runs faster, so it's a recommended setting.
|
127
|
+
If the function cannot compress 'source' into a more limited 'dest' budget,
|
128
|
+
compression stops *immediately*, and the function result is zero.
|
129
|
+
As a consequence, 'dest' content is not valid.
|
130
|
+
This function never writes outside 'dest' buffer, nor read outside 'source' buffer.
|
131
|
+
sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE
|
132
|
+
maxDestSize : full or partial size of buffer 'dest' (which must be already allocated)
|
133
|
+
return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize)
|
134
|
+
or 0 if compression fails */
|
135
|
+
LZ4LIB_API int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize);
|
136
|
+
|
137
|
+
/*! LZ4_decompress_safe() :
|
138
|
+
compressedSize : is the precise full size of the compressed block.
|
139
|
+
maxDecompressedSize : is the size of destination buffer, which must be already allocated.
|
140
|
+
return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize)
|
141
|
+
If destination buffer is not large enough, decoding will stop and output an error code (<0).
|
142
|
+
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
143
|
+
This function is protected against buffer overflow exploits, including malicious data packets.
|
144
|
+
It never writes outside output buffer, nor reads outside input buffer.
|
145
|
+
*/
|
146
|
+
LZ4LIB_API int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
147
|
+
|
148
|
+
|
149
|
+
/*-************************************
|
150
|
+
* Advanced Functions
|
151
|
+
**************************************/
|
152
|
+
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
|
153
|
+
#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
|
154
|
+
|
155
|
+
/*!
|
156
|
+
LZ4_compressBound() :
|
157
|
+
Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
|
158
|
+
This function is primarily useful for memory allocation purposes (destination buffer size).
|
159
|
+
Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
|
160
|
+
Note that LZ4_compress_default() compress faster when dest buffer size is >= LZ4_compressBound(srcSize)
|
161
|
+
inputSize : max supported value is LZ4_MAX_INPUT_SIZE
|
162
|
+
return : maximum output size in a "worst case" scenario
|
163
|
+
or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE)
|
164
|
+
*/
|
165
|
+
LZ4LIB_API int LZ4_compressBound(int inputSize);
|
166
|
+
|
167
|
+
/*!
|
168
|
+
LZ4_compress_fast() :
|
169
|
+
Same as LZ4_compress_default(), but allows to select an "acceleration" factor.
|
170
|
+
The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
|
171
|
+
It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
|
172
|
+
An acceleration value of "1" is the same as regular LZ4_compress_default()
|
173
|
+
Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1.
|
174
|
+
*/
|
175
|
+
LZ4LIB_API int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration);
|
176
|
+
|
177
|
+
|
178
|
+
/*!
|
179
|
+
LZ4_compress_fast_extState() :
|
180
|
+
Same compression function, just using an externally allocated memory space to store compression state.
|
181
|
+
Use LZ4_sizeofState() to know how much memory must be allocated,
|
182
|
+
and allocate it on 8-bytes boundaries (using malloc() typically).
|
183
|
+
Then, provide it as 'void* state' to compression function.
|
184
|
+
*/
|
185
|
+
LZ4LIB_API int LZ4_sizeofState(void);
|
186
|
+
LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration);
|
187
|
+
|
188
|
+
|
189
|
+
/*!
|
190
|
+
LZ4_compress_destSize() :
|
191
|
+
Reverse the logic, by compressing as much data as possible from 'source' buffer
|
192
|
+
into already allocated buffer 'dest' of size 'targetDestSize'.
|
193
|
+
This function either compresses the entire 'source' content into 'dest' if it's large enough,
|
194
|
+
or fill 'dest' buffer completely with as much data as possible from 'source'.
|
195
|
+
*sourceSizePtr : will be modified to indicate how many bytes where read from 'source' to fill 'dest'.
|
196
|
+
New value is necessarily <= old value.
|
197
|
+
return : Nb bytes written into 'dest' (necessarily <= targetDestSize)
|
198
|
+
or 0 if compression fails
|
199
|
+
*/
|
200
|
+
LZ4LIB_API int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize);
|
201
|
+
|
202
|
+
|
203
|
+
/*!
|
204
|
+
LZ4_decompress_fast() :
|
205
|
+
originalSize : is the original and therefore uncompressed size
|
206
|
+
return : the number of bytes read from the source buffer (in other words, the compressed size)
|
207
|
+
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
208
|
+
Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes.
|
209
|
+
note : This function fully respect memory boundaries for properly formed compressed data.
|
210
|
+
It is a bit faster than LZ4_decompress_safe().
|
211
|
+
However, it does not provide any protection against intentionally modified data stream (malicious input).
|
212
|
+
Use this function in trusted environment only (data to decode comes from a trusted source).
|
213
|
+
*/
|
214
|
+
LZ4LIB_API int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
|
215
|
+
|
216
|
+
/*!
|
217
|
+
LZ4_decompress_safe_partial() :
|
218
|
+
This function decompress a compressed block of size 'compressedSize' at position 'source'
|
219
|
+
into destination buffer 'dest' of size 'maxDecompressedSize'.
|
220
|
+
The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached,
|
221
|
+
reducing decompression time.
|
222
|
+
return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize)
|
223
|
+
Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller.
|
224
|
+
Always control how many bytes were decoded.
|
225
|
+
If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
226
|
+
This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
|
227
|
+
*/
|
228
|
+
LZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize);
|
229
|
+
|
230
|
+
|
231
|
+
/*-*********************************************
|
232
|
+
* Streaming Compression Functions
|
233
|
+
***********************************************/
|
234
|
+
typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
|
235
|
+
|
236
|
+
/*! LZ4_createStream() and LZ4_freeStream() :
|
237
|
+
* LZ4_createStream() will allocate and initialize an `LZ4_stream_t` structure.
|
238
|
+
* LZ4_freeStream() releases its memory.
|
239
|
+
*/
|
240
|
+
LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
|
241
|
+
LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
|
242
|
+
|
243
|
+
/*! LZ4_resetStream() :
|
244
|
+
* An LZ4_stream_t structure can be allocated once and re-used multiple times.
|
245
|
+
* Use this function to init an allocated `LZ4_stream_t` structure and start a new compression.
|
246
|
+
*/
|
247
|
+
LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
|
248
|
+
|
249
|
+
/*! LZ4_loadDict() :
|
250
|
+
* Use this function to load a static dictionary into LZ4_stream.
|
251
|
+
* Any previous data will be forgotten, only 'dictionary' will remain in memory.
|
252
|
+
* Loading a size of 0 is allowed.
|
253
|
+
* Return : dictionary size, in bytes (necessarily <= 64 KB)
|
254
|
+
*/
|
255
|
+
LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
|
256
|
+
|
257
|
+
/*! LZ4_compress_fast_continue() :
|
258
|
+
* Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio.
|
259
|
+
* Important : Previous data blocks are assumed to remain present and unmodified !
|
260
|
+
* 'dst' buffer must be already allocated.
|
261
|
+
* If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
|
262
|
+
* If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function @return==0.
|
263
|
+
* After an error, the stream status is invalid, it can only be reset or freed.
|
264
|
+
*/
|
265
|
+
LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
266
|
+
|
267
|
+
/*! LZ4_saveDict() :
|
268
|
+
* If previously compressed data block is not guaranteed to remain available at its current memory location,
|
269
|
+
* save it into a safer place (char* safeBuffer).
|
270
|
+
* Note : it's not necessary to call LZ4_loadDict() after LZ4_saveDict(), dictionary is immediately usable.
|
271
|
+
* @return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error.
|
272
|
+
*/
|
273
|
+
LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize);
|
274
|
+
|
275
|
+
|
276
|
+
/*-**********************************************
|
277
|
+
* Streaming Decompression Functions
|
278
|
+
* Bufferless synchronous API
|
279
|
+
************************************************/
|
280
|
+
typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* incomplete type (defined later) */
|
281
|
+
|
282
|
+
/*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
|
283
|
+
* creation / destruction of streaming decompression tracking structure */
|
284
|
+
LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
|
285
|
+
LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
|
286
|
+
|
287
|
+
/*! LZ4_setStreamDecode() :
|
288
|
+
* Use this function to instruct where to find the dictionary.
|
289
|
+
* Setting a size of 0 is allowed (same effect as reset).
|
290
|
+
* @return : 1 if OK, 0 if error
|
291
|
+
*/
|
292
|
+
LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
|
293
|
+
|
294
|
+
/*! LZ4_decompress_*_continue() :
|
295
|
+
* These decoding functions allow decompression of multiple blocks in "streaming" mode.
|
296
|
+
* Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64 KB)
|
297
|
+
* In the case of a ring buffers, decoding buffer must be either :
|
298
|
+
* - Exactly same size as encoding buffer, with same update rule (block boundaries at same positions)
|
299
|
+
* In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64 KB).
|
300
|
+
* - Larger than encoding buffer, by a minimum of maxBlockSize more bytes.
|
301
|
+
* maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single block.
|
302
|
+
* In which case, encoding and decoding buffers do not need to be synchronized,
|
303
|
+
* and encoding ring buffer can have any size, including small ones ( < 64 KB).
|
304
|
+
* - _At least_ 64 KB + 8 bytes + maxBlockSize.
|
305
|
+
* In which case, encoding and decoding buffers do not need to be synchronized,
|
306
|
+
* and encoding ring buffer can have any size, including larger than decoding buffer.
|
307
|
+
* Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer,
|
308
|
+
* and indicate where it is saved using LZ4_setStreamDecode()
|
309
|
+
*/
|
310
|
+
LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize);
|
311
|
+
LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize);
|
312
|
+
|
313
|
+
|
314
|
+
/*! LZ4_decompress_*_usingDict() :
|
315
|
+
* These decoding functions work the same as
|
316
|
+
* a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue()
|
317
|
+
* They are stand-alone, and don't need an LZ4_streamDecode_t structure.
|
318
|
+
*/
|
319
|
+
LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize);
|
320
|
+
LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
|
321
|
+
|
322
|
+
|
323
|
+
/*^**********************************************
|
324
|
+
* !!!!!! STATIC LINKING ONLY !!!!!!
|
325
|
+
***********************************************/
|
326
|
+
/*-************************************
|
327
|
+
* Private definitions
|
328
|
+
**************************************
|
329
|
+
* Do not use these definitions.
|
330
|
+
* They are exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
|
331
|
+
* Using these definitions will expose code to API and/or ABI break in future versions of the library.
|
332
|
+
**************************************/
|
333
|
+
#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
|
334
|
+
#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
|
335
|
+
#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
|
336
|
+
|
337
|
+
#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
338
|
+
#include <stdint.h>
|
339
|
+
|
340
|
+
typedef struct {
|
341
|
+
uint32_t hashTable[LZ4_HASH_SIZE_U32];
|
342
|
+
uint32_t currentOffset;
|
343
|
+
uint32_t initCheck;
|
344
|
+
const uint8_t* dictionary;
|
345
|
+
uint8_t* bufferStart; /* obsolete, used for slideInputBuffer */
|
346
|
+
uint32_t dictSize;
|
347
|
+
} LZ4_stream_t_internal;
|
348
|
+
|
349
|
+
typedef struct {
|
350
|
+
const uint8_t* externalDict;
|
351
|
+
size_t extDictSize;
|
352
|
+
const uint8_t* prefixEnd;
|
353
|
+
size_t prefixSize;
|
354
|
+
} LZ4_streamDecode_t_internal;
|
355
|
+
|
356
|
+
#else
|
357
|
+
|
358
|
+
typedef struct {
|
359
|
+
unsigned int hashTable[LZ4_HASH_SIZE_U32];
|
360
|
+
unsigned int currentOffset;
|
361
|
+
unsigned int initCheck;
|
362
|
+
const unsigned char* dictionary;
|
363
|
+
unsigned char* bufferStart; /* obsolete, used for slideInputBuffer */
|
364
|
+
unsigned int dictSize;
|
365
|
+
} LZ4_stream_t_internal;
|
366
|
+
|
367
|
+
typedef struct {
|
368
|
+
const unsigned char* externalDict;
|
369
|
+
size_t extDictSize;
|
370
|
+
const unsigned char* prefixEnd;
|
371
|
+
size_t prefixSize;
|
372
|
+
} LZ4_streamDecode_t_internal;
|
373
|
+
|
374
|
+
#endif
|
375
|
+
|
376
|
+
/*!
|
377
|
+
* LZ4_stream_t :
|
378
|
+
* information structure to track an LZ4 stream.
|
379
|
+
* init this structure before first use.
|
380
|
+
* note : only use in association with static linking !
|
381
|
+
* this definition is not API/ABI safe,
|
382
|
+
* it may change in a future version !
|
383
|
+
*/
|
384
|
+
#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
|
385
|
+
#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
|
386
|
+
union LZ4_stream_u {
|
387
|
+
unsigned long long table[LZ4_STREAMSIZE_U64];
|
388
|
+
LZ4_stream_t_internal internal_donotuse;
|
389
|
+
} ; /* previously typedef'd to LZ4_stream_t */
|
390
|
+
|
391
|
+
|
392
|
+
/*!
|
393
|
+
* LZ4_streamDecode_t :
|
394
|
+
* information structure to track an LZ4 stream during decompression.
|
395
|
+
* init this structure using LZ4_setStreamDecode (or memset()) before first use
|
396
|
+
* note : only use in association with static linking !
|
397
|
+
* this definition is not API/ABI safe,
|
398
|
+
* and may change in a future version !
|
399
|
+
*/
|
400
|
+
#define LZ4_STREAMDECODESIZE_U64 4
|
401
|
+
#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
|
402
|
+
union LZ4_streamDecode_u {
|
403
|
+
unsigned long long table[LZ4_STREAMDECODESIZE_U64];
|
404
|
+
LZ4_streamDecode_t_internal internal_donotuse;
|
405
|
+
} ; /* previously typedef'd to LZ4_streamDecode_t */
|
406
|
+
|
407
|
+
|
408
|
+
/*-************************************
|
409
|
+
* Obsolete Functions
|
410
|
+
**************************************/
|
411
|
+
|
412
|
+
/*! Deprecation warnings
|
413
|
+
Should deprecation warnings be a problem,
|
414
|
+
it is generally possible to disable them,
|
415
|
+
typically with -Wno-deprecated-declarations for gcc
|
416
|
+
or _CRT_SECURE_NO_WARNINGS in Visual.
|
417
|
+
Otherwise, it's also possible to define LZ4_DISABLE_DEPRECATE_WARNINGS */
|
418
|
+
#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
|
419
|
+
# define LZ4_DEPRECATED(message) /* disable deprecation warnings */
|
420
|
+
#else
|
421
|
+
# define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
422
|
+
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
423
|
+
# define LZ4_DEPRECATED(message) [[deprecated(message)]]
|
424
|
+
# elif (LZ4_GCC_VERSION >= 405) || defined(__clang__)
|
425
|
+
# define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
|
426
|
+
# elif (LZ4_GCC_VERSION >= 301)
|
427
|
+
# define LZ4_DEPRECATED(message) __attribute__((deprecated))
|
428
|
+
# elif defined(_MSC_VER)
|
429
|
+
# define LZ4_DEPRECATED(message) __declspec(deprecated(message))
|
430
|
+
# else
|
431
|
+
# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
|
432
|
+
# define LZ4_DEPRECATED(message)
|
433
|
+
# endif
|
434
|
+
#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
|
435
|
+
|
436
|
+
/* Obsolete compression functions */
|
437
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress (const char* source, char* dest, int sourceSize);
|
438
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
|
439
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
|
440
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
441
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
|
442
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
443
|
+
|
444
|
+
/* Obsolete decompression functions */
|
445
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_decompress_fast() instead") int LZ4_uncompress (const char* source, char* dest, int outputSize);
|
446
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_decompress_safe() instead") int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
|
447
|
+
|
448
|
+
/* Obsolete streaming functions; use new streaming interface whenever possible */
|
449
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer);
|
450
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void);
|
451
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer);
|
452
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state);
|
453
|
+
|
454
|
+
/* Obsolete streaming decoding functions */
|
455
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
|
456
|
+
LZ4LIB_API LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
|
457
|
+
|
458
|
+
#endif /* LZ4_H_2983827168210 */
|
459
|
+
|
460
|
+
|
461
|
+
#if defined (__cplusplus)
|
462
|
+
}
|
463
|
+
#endif
|