rmultimarkdown 6.4.0.4 → 6.7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Rakefile +7 -13
- data/ext/Makefile +67 -55
- data/ext/extconf.rb +7 -5
- data/ext/mmd/aho-corasick.c +8 -8
- data/ext/mmd/aho-corasick.h +3 -3
- data/ext/mmd/argtable3.c +6537 -0
- data/ext/mmd/argtable3.h +273 -0
- data/ext/mmd/beamer.c +12 -1
- data/ext/mmd/char.c +120 -27
- data/ext/mmd/char.h +23 -23
- data/ext/mmd/critic_markup.c +7 -6
- data/ext/mmd/d_string.c +88 -32
- data/ext/mmd/{include/d_string.h → d_string.h} +50 -38
- data/ext/mmd/epub.c +36 -12
- data/ext/mmd/epub.h +2 -2
- data/ext/mmd/file.c +50 -40
- data/ext/mmd/file.h +2 -2
- data/ext/mmd/html.c +164 -99
- data/ext/mmd/html.h +3 -2
- data/ext/mmd/i18n.h +15 -11
- data/ext/mmd/itmz-lexer.c +16978 -0
- data/ext/mmd/itmz-lexer.h +132 -0
- data/ext/mmd/itmz-parser.c +1189 -0
- data/ext/mmd/itmz-parser.h +11 -0
- data/ext/mmd/itmz-reader.c +388 -0
- data/ext/mmd/itmz-reader.h +111 -0
- data/ext/mmd/itmz.c +567 -0
- data/ext/mmd/itmz.h +117 -0
- data/ext/mmd/latex.c +93 -41
- data/ext/mmd/lexer.c +3506 -2774
- data/ext/mmd/{include/libMultiMarkdown.h → libMultiMarkdown.h} +49 -2
- data/ext/mmd/main.c +612 -0
- data/ext/mmd/memoir.c +4 -1
- data/ext/mmd/miniz.c +6905 -6680
- data/ext/mmd/miniz.h +456 -476
- data/ext/mmd/mmd.c +399 -94
- data/ext/mmd/mmd.h +25 -25
- data/ext/mmd/object_pool.h +3 -3
- data/ext/mmd/opendocument-content.c +137 -69
- data/ext/mmd/opendocument-content.h +2 -2
- data/ext/mmd/opendocument.c +35 -14
- data/ext/mmd/opendocument.h +2 -2
- data/ext/mmd/opml-lexer.c +259 -637
- data/ext/mmd/opml-lexer.h +1 -17
- data/ext/mmd/opml-parser.c +194 -188
- data/ext/mmd/opml-reader.c +72 -142
- data/ext/mmd/opml-reader.h +1 -1
- data/ext/mmd/opml.c +13 -13
- data/ext/mmd/opml.h +1 -1
- data/ext/mmd/parser.c +1623 -1244
- data/ext/mmd/rng.c +8 -3
- data/ext/mmd/scanners.c +66625 -103198
- data/ext/mmd/scanners.h +1 -0
- data/ext/mmd/stack.c +62 -20
- data/ext/mmd/stack.h +10 -21
- data/ext/mmd/textbundle.c +23 -7
- data/ext/mmd/textbundle.h +2 -2
- data/ext/mmd/token.c +42 -16
- data/ext/mmd/{include/token.h → token.h} +22 -8
- data/ext/mmd/token_pairs.c +0 -16
- data/ext/mmd/transclude.c +6 -2
- data/ext/mmd/uthash.h +745 -745
- data/ext/mmd/version.h +8 -8
- data/ext/mmd/writer.c +225 -63
- data/ext/mmd/writer.h +50 -36
- data/ext/mmd/xml.c +855 -0
- data/ext/mmd/xml.h +134 -0
- data/ext/mmd/zip.c +71 -4
- data/ext/mmd/zip.h +7 -1
- data/ext/ruby_multi_markdown.c +9 -18
- data/lib/multi_markdown/version.rb +1 -1
- data/lib/multi_markdown.bundle +0 -0
- data/rmultimarkdown.gemspec +0 -2
- metadata +22 -28
- data/ext/mmd/char_lookup.c +0 -212
data/ext/mmd/miniz.h
CHANGED
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
/* Defines to completely disable specific portions of miniz.c:
|
|
119
|
+
/* Defines to completely disable specific portions of miniz.c:
|
|
120
120
|
If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. */
|
|
121
121
|
|
|
122
122
|
/* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */
|
|
@@ -139,49 +139,49 @@
|
|
|
139
139
|
/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. */
|
|
140
140
|
/*#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES */
|
|
141
141
|
|
|
142
|
-
/* Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc.
|
|
142
|
+
/* Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc.
|
|
143
143
|
Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc
|
|
144
144
|
callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user
|
|
145
145
|
functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */
|
|
146
146
|
/*#define MINIZ_NO_MALLOC */
|
|
147
147
|
|
|
148
148
|
#if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
|
|
149
|
-
/* TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux */
|
|
150
|
-
#define MINIZ_NO_TIME
|
|
149
|
+
/* TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux */
|
|
150
|
+
#define MINIZ_NO_TIME
|
|
151
151
|
#endif
|
|
152
152
|
|
|
153
153
|
#include <stddef.h>
|
|
154
154
|
|
|
155
155
|
#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
|
|
156
|
-
#include <time.h>
|
|
156
|
+
#include <time.h>
|
|
157
157
|
#endif
|
|
158
158
|
|
|
159
159
|
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
|
|
160
|
-
/* MINIZ_X86_OR_X64_CPU is only used to help set the below macros. */
|
|
161
|
-
#define MINIZ_X86_OR_X64_CPU 1
|
|
160
|
+
/* MINIZ_X86_OR_X64_CPU is only used to help set the below macros. */
|
|
161
|
+
#define MINIZ_X86_OR_X64_CPU 1
|
|
162
162
|
#else
|
|
163
|
-
#define MINIZ_X86_OR_X64_CPU 0
|
|
163
|
+
#define MINIZ_X86_OR_X64_CPU 0
|
|
164
164
|
#endif
|
|
165
165
|
|
|
166
166
|
#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU
|
|
167
|
-
/* Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. */
|
|
168
|
-
#define MINIZ_LITTLE_ENDIAN 1
|
|
167
|
+
/* Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. */
|
|
168
|
+
#define MINIZ_LITTLE_ENDIAN 1
|
|
169
169
|
#else
|
|
170
|
-
#define MINIZ_LITTLE_ENDIAN 0
|
|
170
|
+
#define MINIZ_LITTLE_ENDIAN 0
|
|
171
171
|
#endif
|
|
172
172
|
|
|
173
173
|
#if MINIZ_X86_OR_X64_CPU
|
|
174
|
-
/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. */
|
|
175
|
-
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
|
|
174
|
+
/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. */
|
|
175
|
+
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
|
|
176
176
|
#else
|
|
177
|
-
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
|
|
177
|
+
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
|
|
178
178
|
#endif
|
|
179
179
|
|
|
180
180
|
#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
|
|
181
|
-
/* Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). */
|
|
182
|
-
#define MINIZ_HAS_64BIT_REGISTERS 1
|
|
181
|
+
/* Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). */
|
|
182
|
+
#define MINIZ_HAS_64BIT_REGISTERS 1
|
|
183
183
|
#else
|
|
184
|
-
#define MINIZ_HAS_64BIT_REGISTERS 0
|
|
184
|
+
#define MINIZ_HAS_64BIT_REGISTERS 0
|
|
185
185
|
#endif
|
|
186
186
|
|
|
187
187
|
#ifdef __cplusplus
|
|
@@ -194,24 +194,23 @@ extern "C" {
|
|
|
194
194
|
typedef unsigned long mz_ulong;
|
|
195
195
|
|
|
196
196
|
/* mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. */
|
|
197
|
-
void mz_free(void *p);
|
|
197
|
+
void mz_free(void * p);
|
|
198
198
|
|
|
199
199
|
#define MZ_ADLER32_INIT (1)
|
|
200
200
|
/* mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. */
|
|
201
|
-
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
|
|
201
|
+
mz_ulong mz_adler32(mz_ulong adler, const unsigned char * ptr, size_t buf_len);
|
|
202
202
|
|
|
203
203
|
#define MZ_CRC32_INIT (0)
|
|
204
204
|
/* mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. */
|
|
205
|
-
mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
|
|
205
|
+
mz_ulong mz_crc32(mz_ulong crc, const unsigned char * ptr, size_t buf_len);
|
|
206
206
|
|
|
207
207
|
/* Compression strategies. */
|
|
208
|
-
enum
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
MZ_FIXED = 4
|
|
208
|
+
enum {
|
|
209
|
+
MZ_DEFAULT_STRATEGY = 0,
|
|
210
|
+
MZ_FILTERED = 1,
|
|
211
|
+
MZ_HUFFMAN_ONLY = 2,
|
|
212
|
+
MZ_RLE = 3,
|
|
213
|
+
MZ_FIXED = 4
|
|
215
214
|
};
|
|
216
215
|
|
|
217
216
|
/* Method */
|
|
@@ -219,19 +218,18 @@ enum
|
|
|
219
218
|
|
|
220
219
|
/* Heap allocation callbacks.
|
|
221
220
|
Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. */
|
|
222
|
-
typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size);
|
|
223
|
-
typedef void (*mz_free_func)(void *opaque, void *address);
|
|
224
|
-
typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size);
|
|
221
|
+
typedef void * (*mz_alloc_func)(void * opaque, size_t items, size_t size);
|
|
222
|
+
typedef void (*mz_free_func)(void * opaque, void * address);
|
|
223
|
+
typedef void * (*mz_realloc_func)(void * opaque, void * address, size_t items, size_t size);
|
|
225
224
|
|
|
226
225
|
/* Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. */
|
|
227
|
-
enum
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
MZ_DEFAULT_COMPRESSION = -1
|
|
226
|
+
enum {
|
|
227
|
+
MZ_NO_COMPRESSION = 0,
|
|
228
|
+
MZ_BEST_SPEED = 1,
|
|
229
|
+
MZ_BEST_COMPRESSION = 9,
|
|
230
|
+
MZ_UBER_COMPRESSION = 10,
|
|
231
|
+
MZ_DEFAULT_LEVEL = 6,
|
|
232
|
+
MZ_DEFAULT_COMPRESSION = -1
|
|
235
233
|
};
|
|
236
234
|
|
|
237
235
|
#define MZ_VERSION "10.0.1"
|
|
@@ -244,29 +242,27 @@ enum
|
|
|
244
242
|
#ifndef MINIZ_NO_ZLIB_APIS
|
|
245
243
|
|
|
246
244
|
/* Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). */
|
|
247
|
-
enum
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
MZ_BLOCK = 5
|
|
245
|
+
enum {
|
|
246
|
+
MZ_NO_FLUSH = 0,
|
|
247
|
+
MZ_PARTIAL_FLUSH = 1,
|
|
248
|
+
MZ_SYNC_FLUSH = 2,
|
|
249
|
+
MZ_FULL_FLUSH = 3,
|
|
250
|
+
MZ_FINISH = 4,
|
|
251
|
+
MZ_BLOCK = 5
|
|
255
252
|
};
|
|
256
253
|
|
|
257
254
|
/* Return status codes. MZ_PARAM_ERROR is non-standard. */
|
|
258
|
-
enum
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
MZ_PARAM_ERROR = -10000
|
|
255
|
+
enum {
|
|
256
|
+
MZ_OK = 0,
|
|
257
|
+
MZ_STREAM_END = 1,
|
|
258
|
+
MZ_NEED_DICT = 2,
|
|
259
|
+
MZ_ERRNO = -1,
|
|
260
|
+
MZ_STREAM_ERROR = -2,
|
|
261
|
+
MZ_DATA_ERROR = -3,
|
|
262
|
+
MZ_MEM_ERROR = -4,
|
|
263
|
+
MZ_BUF_ERROR = -5,
|
|
264
|
+
MZ_VERSION_ERROR = -6,
|
|
265
|
+
MZ_PARAM_ERROR = -10000
|
|
270
266
|
};
|
|
271
267
|
|
|
272
268
|
/* Window bits */
|
|
@@ -275,32 +271,31 @@ enum
|
|
|
275
271
|
struct mz_internal_state;
|
|
276
272
|
|
|
277
273
|
/* Compression/decompression stream struct. */
|
|
278
|
-
typedef struct mz_stream_s
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
mz_ulong reserved; /* not used */
|
|
274
|
+
typedef struct mz_stream_s {
|
|
275
|
+
const unsigned char * next_in; /* pointer to next byte to read */
|
|
276
|
+
unsigned int avail_in; /* number of bytes available at next_in */
|
|
277
|
+
mz_ulong total_in; /* total number of bytes consumed so far */
|
|
278
|
+
|
|
279
|
+
unsigned char * next_out; /* pointer to next byte to write */
|
|
280
|
+
unsigned int avail_out; /* number of bytes that can be written to next_out */
|
|
281
|
+
mz_ulong total_out; /* total number of bytes produced so far */
|
|
282
|
+
|
|
283
|
+
char * msg; /* error msg (unused) */
|
|
284
|
+
struct mz_internal_state * state; /* internal state, allocated by zalloc/zfree */
|
|
285
|
+
|
|
286
|
+
mz_alloc_func zalloc; /* optional heap allocation function (defaults to malloc) */
|
|
287
|
+
mz_free_func zfree; /* optional heap free function (defaults to free) */
|
|
288
|
+
void * opaque; /* heap alloc function user pointer */
|
|
289
|
+
|
|
290
|
+
int data_type; /* data_type (unused) */
|
|
291
|
+
mz_ulong adler; /* adler32 of the source or uncompressed data */
|
|
292
|
+
mz_ulong reserved; /* not used */
|
|
298
293
|
} mz_stream;
|
|
299
294
|
|
|
300
|
-
typedef mz_stream *mz_streamp;
|
|
295
|
+
typedef mz_stream * mz_streamp;
|
|
301
296
|
|
|
302
297
|
/* Returns the version string of miniz.c. */
|
|
303
|
-
const char *mz_version(void);
|
|
298
|
+
const char * mz_version(void);
|
|
304
299
|
|
|
305
300
|
/* mz_deflateInit() initializes a compressor with default options: */
|
|
306
301
|
/* Parameters: */
|
|
@@ -348,8 +343,8 @@ mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
|
|
|
348
343
|
|
|
349
344
|
/* Single-call compression functions mz_compress() and mz_compress2(): */
|
|
350
345
|
/* Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. */
|
|
351
|
-
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
|
|
352
|
-
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
|
|
346
|
+
int mz_compress(unsigned char * pDest, mz_ulong * pDest_len, const unsigned char * pSource, mz_ulong source_len);
|
|
347
|
+
int mz_compress2(unsigned char * pDest, mz_ulong * pDest_len, const unsigned char * pSource, mz_ulong source_len, int level);
|
|
353
348
|
|
|
354
349
|
/* mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). */
|
|
355
350
|
mz_ulong mz_compressBound(mz_ulong source_len);
|
|
@@ -382,10 +377,10 @@ int mz_inflateEnd(mz_streamp pStream);
|
|
|
382
377
|
|
|
383
378
|
/* Single-call decompression. */
|
|
384
379
|
/* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */
|
|
385
|
-
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
|
|
380
|
+
int mz_uncompress(unsigned char * pDest, mz_ulong * pDest_len, const unsigned char * pSource, mz_ulong source_len);
|
|
386
381
|
|
|
387
382
|
/* Returns a string description of the specified error code, or NULL if the error code is invalid. */
|
|
388
|
-
const char *mz_error(int err);
|
|
383
|
+
const char * mz_error(int err);
|
|
389
384
|
|
|
390
385
|
/* Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. */
|
|
391
386
|
/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. */
|
|
@@ -397,10 +392,10 @@ typedef Byte Bytef;
|
|
|
397
392
|
typedef uInt uIntf;
|
|
398
393
|
typedef char charf;
|
|
399
394
|
typedef int intf;
|
|
400
|
-
typedef void *voidpf;
|
|
395
|
+
typedef void * voidpf;
|
|
401
396
|
typedef uLong uLongf;
|
|
402
|
-
typedef void *voidp;
|
|
403
|
-
typedef void *const voidpc;
|
|
397
|
+
typedef void * voidp;
|
|
398
|
+
typedef void * const voidpc;
|
|
404
399
|
#define Z_NULL 0
|
|
405
400
|
#define Z_NO_FLUSH MZ_NO_FLUSH
|
|
406
401
|
#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
|
|
@@ -488,22 +483,21 @@ typedef int mz_bool;
|
|
|
488
483
|
|
|
489
484
|
/* Works around MSVC's spammy "warning C4127: conditional expression is constant" message. */
|
|
490
485
|
#ifdef _MSC_VER
|
|
491
|
-
#define MZ_MACRO_END while (0, 0)
|
|
486
|
+
#define MZ_MACRO_END while (0, 0)
|
|
492
487
|
#else
|
|
493
|
-
#define MZ_MACRO_END while (0)
|
|
488
|
+
#define MZ_MACRO_END while (0)
|
|
494
489
|
#endif
|
|
495
490
|
|
|
496
491
|
#ifdef MINIZ_NO_STDIO
|
|
497
|
-
#define MZ_FILE void *
|
|
492
|
+
#define MZ_FILE void *
|
|
498
493
|
#else
|
|
499
|
-
#include <stdio.h>
|
|
500
|
-
#define MZ_FILE FILE
|
|
494
|
+
#include <stdio.h>
|
|
495
|
+
#define MZ_FILE FILE
|
|
501
496
|
#endif /* #ifdef MINIZ_NO_STDIO */
|
|
502
497
|
|
|
503
498
|
#ifdef MINIZ_NO_TIME
|
|
504
|
-
typedef struct mz_dummy_time_t_tag
|
|
505
|
-
|
|
506
|
-
int m_dummy;
|
|
499
|
+
typedef struct mz_dummy_time_t_tag {
|
|
500
|
+
int m_dummy;
|
|
507
501
|
} mz_dummy_time_t;
|
|
508
502
|
#define MZ_TIME_T mz_dummy_time_t
|
|
509
503
|
#else
|
|
@@ -513,13 +507,13 @@ typedef struct mz_dummy_time_t_tag
|
|
|
513
507
|
#define MZ_ASSERT(x) assert(x)
|
|
514
508
|
|
|
515
509
|
#ifdef MINIZ_NO_MALLOC
|
|
516
|
-
#define MZ_MALLOC(x) NULL
|
|
517
|
-
#define MZ_FREE(x) (void)x, ((void)0)
|
|
518
|
-
#define MZ_REALLOC(p, x) NULL
|
|
510
|
+
#define MZ_MALLOC(x) NULL
|
|
511
|
+
#define MZ_FREE(x) (void)x, ((void)0)
|
|
512
|
+
#define MZ_REALLOC(p, x) NULL
|
|
519
513
|
#else
|
|
520
|
-
#define MZ_MALLOC(x) malloc(x)
|
|
521
|
-
#define MZ_FREE(x) free(x)
|
|
522
|
-
#define MZ_REALLOC(p, x) realloc(p, x)
|
|
514
|
+
#define MZ_MALLOC(x) malloc(x)
|
|
515
|
+
#define MZ_FREE(x) free(x)
|
|
516
|
+
#define MZ_REALLOC(p, x) realloc(p, x)
|
|
523
517
|
#endif
|
|
524
518
|
|
|
525
519
|
#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
@@ -527,30 +521,30 @@ typedef struct mz_dummy_time_t_tag
|
|
|
527
521
|
#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
|
|
528
522
|
|
|
529
523
|
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
|
|
530
|
-
#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
|
|
531
|
-
#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
|
|
524
|
+
#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
|
|
525
|
+
#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
|
|
532
526
|
#else
|
|
533
|
-
#define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
|
|
534
|
-
#define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
|
|
527
|
+
#define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
|
|
528
|
+
#define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
|
|
535
529
|
#endif
|
|
536
530
|
|
|
537
531
|
#define MZ_READ_LE64(p) (((mz_uint64)MZ_READ_LE32(p)) | (((mz_uint64)MZ_READ_LE32((const mz_uint8 *)(p) + sizeof(mz_uint32))) << 32U))
|
|
538
532
|
|
|
539
533
|
#ifdef _MSC_VER
|
|
540
|
-
#define MZ_FORCEINLINE __forceinline
|
|
534
|
+
#define MZ_FORCEINLINE __forceinline
|
|
541
535
|
#elif defined(__GNUC__)
|
|
542
|
-
#define MZ_FORCEINLINE __inline__ __attribute__((__always_inline__))
|
|
536
|
+
#define MZ_FORCEINLINE __inline__ __attribute__((__always_inline__))
|
|
543
537
|
#else
|
|
544
|
-
#define MZ_FORCEINLINE inline
|
|
538
|
+
#define MZ_FORCEINLINE inline
|
|
545
539
|
#endif
|
|
546
540
|
|
|
547
541
|
#ifdef __cplusplus
|
|
548
542
|
extern "C" {
|
|
549
543
|
#endif
|
|
550
544
|
|
|
551
|
-
extern void *miniz_def_alloc_func(void *opaque, size_t items, size_t size);
|
|
552
|
-
extern void miniz_def_free_func(void *opaque, void *address);
|
|
553
|
-
extern void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size);
|
|
545
|
+
extern void * miniz_def_alloc_func(void * opaque, size_t items, size_t size);
|
|
546
|
+
extern void miniz_def_free_func(void * opaque, void * address);
|
|
547
|
+
extern void * miniz_def_realloc_func(void * opaque, void * address, size_t items, size_t size);
|
|
554
548
|
|
|
555
549
|
#define MZ_UINT16_MAX (0xFFFFU)
|
|
556
550
|
#define MZ_UINT32_MAX (0xFFFFFFFFU)
|
|
@@ -571,11 +565,10 @@ extern "C" {
|
|
|
571
565
|
|
|
572
566
|
/* tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): */
|
|
573
567
|
/* TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). */
|
|
574
|
-
enum
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
TDEFL_MAX_PROBES_MASK = 0xFFF
|
|
568
|
+
enum {
|
|
569
|
+
TDEFL_HUFFMAN_ONLY = 0,
|
|
570
|
+
TDEFL_DEFAULT_MAX_PROBES = 128,
|
|
571
|
+
TDEFL_MAX_PROBES_MASK = 0xFFF
|
|
579
572
|
};
|
|
580
573
|
|
|
581
574
|
/* TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. */
|
|
@@ -587,16 +580,15 @@ enum
|
|
|
587
580
|
/* TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. */
|
|
588
581
|
/* TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. */
|
|
589
582
|
/* The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). */
|
|
590
|
-
enum
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000
|
|
583
|
+
enum {
|
|
584
|
+
TDEFL_WRITE_ZLIB_HEADER = 0x01000,
|
|
585
|
+
TDEFL_COMPUTE_ADLER32 = 0x02000,
|
|
586
|
+
TDEFL_GREEDY_PARSING_FLAG = 0x04000,
|
|
587
|
+
TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000,
|
|
588
|
+
TDEFL_RLE_MATCHES = 0x10000,
|
|
589
|
+
TDEFL_FILTER_MATCHES = 0x20000,
|
|
590
|
+
TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000,
|
|
591
|
+
TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000
|
|
600
592
|
};
|
|
601
593
|
|
|
602
594
|
/* High level compression functions: */
|
|
@@ -608,11 +600,11 @@ enum
|
|
|
608
600
|
/* Function returns a pointer to the compressed data, or NULL on failure. */
|
|
609
601
|
/* *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. */
|
|
610
602
|
/* The caller must free() the returned block when it's no longer needed. */
|
|
611
|
-
void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
|
|
603
|
+
void * tdefl_compress_mem_to_heap(const void * pSrc_buf, size_t src_buf_len, size_t * pOut_len, int flags);
|
|
612
604
|
|
|
613
605
|
/* tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. */
|
|
614
606
|
/* Returns 0 on failure. */
|
|
615
|
-
size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
|
|
607
|
+
size_t tdefl_compress_mem_to_mem(void * pOut_buf, size_t out_buf_len, const void * pSrc_buf, size_t src_buf_len, int flags);
|
|
616
608
|
|
|
617
609
|
/* Compresses an image to a compressed PNG file in memory. */
|
|
618
610
|
/* On entry: */
|
|
@@ -624,94 +616,90 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void
|
|
|
624
616
|
/* Function returns a pointer to the compressed data, or NULL on failure. */
|
|
625
617
|
/* *pLen_out will be set to the size of the PNG image file. */
|
|
626
618
|
/* The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. */
|
|
627
|
-
void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip);
|
|
628
|
-
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
|
|
619
|
+
void * tdefl_write_image_to_png_file_in_memory_ex(const void * pImage, int w, int h, int num_chans, size_t * pLen_out, mz_uint level, mz_bool flip);
|
|
620
|
+
void * tdefl_write_image_to_png_file_in_memory(const void * pImage, int w, int h, int num_chans, size_t * pLen_out);
|
|
629
621
|
|
|
630
622
|
/* Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. */
|
|
631
|
-
typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
|
|
623
|
+
typedef mz_bool (*tdefl_put_buf_func_ptr)(const void * pBuf, int len, void * pUser);
|
|
632
624
|
|
|
633
625
|
/* tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. */
|
|
634
|
-
mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
|
|
635
|
-
|
|
636
|
-
enum
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
TDEFL_MAX_MATCH_LEN = 258
|
|
626
|
+
mz_bool tdefl_compress_mem_to_output(const void * pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void * pPut_buf_user, int flags);
|
|
627
|
+
|
|
628
|
+
enum {
|
|
629
|
+
TDEFL_MAX_HUFF_TABLES = 3,
|
|
630
|
+
TDEFL_MAX_HUFF_SYMBOLS_0 = 288,
|
|
631
|
+
TDEFL_MAX_HUFF_SYMBOLS_1 = 32,
|
|
632
|
+
TDEFL_MAX_HUFF_SYMBOLS_2 = 19,
|
|
633
|
+
TDEFL_LZ_DICT_SIZE = 32768,
|
|
634
|
+
TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1,
|
|
635
|
+
TDEFL_MIN_MATCH_LEN = 3,
|
|
636
|
+
TDEFL_MAX_MATCH_LEN = 258
|
|
646
637
|
};
|
|
647
638
|
|
|
648
639
|
/* TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). */
|
|
649
640
|
#if TDEFL_LESS_MEMORY
|
|
650
|
-
enum
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
|
|
641
|
+
enum {
|
|
642
|
+
TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024,
|
|
643
|
+
TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
|
|
644
|
+
TDEFL_MAX_HUFF_SYMBOLS = 288,
|
|
645
|
+
TDEFL_LZ_HASH_BITS = 12,
|
|
646
|
+
TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
|
|
647
|
+
TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
|
|
648
|
+
TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
|
|
659
649
|
};
|
|
660
650
|
#else
|
|
661
|
-
enum
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
|
|
651
|
+
enum {
|
|
652
|
+
TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024,
|
|
653
|
+
TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
|
|
654
|
+
TDEFL_MAX_HUFF_SYMBOLS = 288,
|
|
655
|
+
TDEFL_LZ_HASH_BITS = 15,
|
|
656
|
+
TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
|
|
657
|
+
TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
|
|
658
|
+
TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
|
|
670
659
|
};
|
|
671
660
|
#endif
|
|
672
661
|
|
|
673
662
|
/* The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. */
|
|
674
663
|
typedef enum {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
664
|
+
TDEFL_STATUS_BAD_PARAM = -2,
|
|
665
|
+
TDEFL_STATUS_PUT_BUF_FAILED = -1,
|
|
666
|
+
TDEFL_STATUS_OKAY = 0,
|
|
667
|
+
TDEFL_STATUS_DONE = 1
|
|
679
668
|
} tdefl_status;
|
|
680
669
|
|
|
681
670
|
/* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */
|
|
682
671
|
typedef enum {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
672
|
+
TDEFL_NO_FLUSH = 0,
|
|
673
|
+
TDEFL_SYNC_FLUSH = 2,
|
|
674
|
+
TDEFL_FULL_FLUSH = 3,
|
|
675
|
+
TDEFL_FINISH = 4
|
|
687
676
|
} tdefl_flush;
|
|
688
677
|
|
|
689
678
|
/* tdefl's compression state structure. */
|
|
690
|
-
typedef struct
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE];
|
|
679
|
+
typedef struct {
|
|
680
|
+
tdefl_put_buf_func_ptr m_pPut_buf_func;
|
|
681
|
+
void * m_pPut_buf_user;
|
|
682
|
+
mz_uint m_flags, m_max_probes[2];
|
|
683
|
+
int m_greedy_parsing;
|
|
684
|
+
mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size;
|
|
685
|
+
mz_uint8 * m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end;
|
|
686
|
+
mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer;
|
|
687
|
+
mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish;
|
|
688
|
+
tdefl_status m_prev_return_status;
|
|
689
|
+
const void * m_pIn_buf;
|
|
690
|
+
void * m_pOut_buf;
|
|
691
|
+
size_t * m_pIn_buf_size, *m_pOut_buf_size;
|
|
692
|
+
tdefl_flush m_flush;
|
|
693
|
+
const mz_uint8 * m_pSrc;
|
|
694
|
+
size_t m_src_buf_left, m_out_buf_ofs;
|
|
695
|
+
mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1];
|
|
696
|
+
mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
|
|
697
|
+
mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
|
|
698
|
+
mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
|
|
699
|
+
mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE];
|
|
700
|
+
mz_uint16 m_next[TDEFL_LZ_DICT_SIZE];
|
|
701
|
+
mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE];
|
|
702
|
+
mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE];
|
|
715
703
|
} tdefl_compressor;
|
|
716
704
|
|
|
717
705
|
/* Initializes the compressor. */
|
|
@@ -719,17 +707,17 @@ typedef struct
|
|
|
719
707
|
/* pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. */
|
|
720
708
|
/* If pBut_buf_func is NULL the user should always call the tdefl_compress() API. */
|
|
721
709
|
/* flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) */
|
|
722
|
-
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
|
|
710
|
+
tdefl_status tdefl_init(tdefl_compressor * d, tdefl_put_buf_func_ptr pPut_buf_func, void * pPut_buf_user, int flags);
|
|
723
711
|
|
|
724
712
|
/* Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. */
|
|
725
|
-
tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush);
|
|
713
|
+
tdefl_status tdefl_compress(tdefl_compressor * d, const void * pIn_buf, size_t * pIn_buf_size, void * pOut_buf, size_t * pOut_buf_size, tdefl_flush flush);
|
|
726
714
|
|
|
727
715
|
/* tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. */
|
|
728
716
|
/* tdefl_compress_buffer() always consumes the entire input buffer. */
|
|
729
|
-
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush);
|
|
717
|
+
tdefl_status tdefl_compress_buffer(tdefl_compressor * d, const void * pIn_buf, size_t in_buf_size, tdefl_flush flush);
|
|
730
718
|
|
|
731
|
-
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);
|
|
732
|
-
mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
|
|
719
|
+
tdefl_status tdefl_get_prev_return_status(tdefl_compressor * d);
|
|
720
|
+
mz_uint32 tdefl_get_adler32(tdefl_compressor * d);
|
|
733
721
|
|
|
734
722
|
/* Create tdefl_compress() flags given zlib-style compression parameters. */
|
|
735
723
|
/* level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) */
|
|
@@ -740,8 +728,8 @@ mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int
|
|
|
740
728
|
/* Allocate the tdefl_compressor structure in C so that */
|
|
741
729
|
/* non-C language bindings to tdefl_ API don't need to worry about */
|
|
742
730
|
/* structure size and allocation mechanism. */
|
|
743
|
-
tdefl_compressor *tdefl_compressor_alloc();
|
|
744
|
-
void tdefl_compressor_free(tdefl_compressor *pComp);
|
|
731
|
+
tdefl_compressor * tdefl_compressor_alloc(void);
|
|
732
|
+
void tdefl_compressor_free(tdefl_compressor * pComp);
|
|
745
733
|
|
|
746
734
|
#ifdef __cplusplus
|
|
747
735
|
}
|
|
@@ -758,12 +746,11 @@ extern "C" {
|
|
|
758
746
|
/* TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. */
|
|
759
747
|
/* TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). */
|
|
760
748
|
/* TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. */
|
|
761
|
-
enum
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
TINFL_FLAG_COMPUTE_ADLER32 = 8
|
|
749
|
+
enum {
|
|
750
|
+
TINFL_FLAG_PARSE_ZLIB_HEADER = 1,
|
|
751
|
+
TINFL_FLAG_HAS_MORE_INPUT = 2,
|
|
752
|
+
TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4,
|
|
753
|
+
TINFL_FLAG_COMPUTE_ADLER32 = 8
|
|
767
754
|
};
|
|
768
755
|
|
|
769
756
|
/* High level decompression functions: */
|
|
@@ -774,17 +761,17 @@ enum
|
|
|
774
761
|
/* Function returns a pointer to the decompressed data, or NULL on failure. */
|
|
775
762
|
/* *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. */
|
|
776
763
|
/* The caller must call mz_free() on the returned block when it's no longer needed. */
|
|
777
|
-
void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
|
|
764
|
+
void * tinfl_decompress_mem_to_heap(const void * pSrc_buf, size_t src_buf_len, size_t * pOut_len, int flags);
|
|
778
765
|
|
|
779
766
|
/* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */
|
|
780
767
|
/* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */
|
|
781
768
|
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
|
|
782
|
-
size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
|
|
769
|
+
size_t tinfl_decompress_mem_to_mem(void * pOut_buf, size_t out_buf_len, const void * pSrc_buf, size_t src_buf_len, int flags);
|
|
783
770
|
|
|
784
771
|
/* tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. */
|
|
785
772
|
/* Returns 1 on success or 0 on failure. */
|
|
786
|
-
typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
|
|
787
|
-
int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
|
|
773
|
+
typedef int (*tinfl_put_buf_func_ptr)(const void * pBuf, int len, void * pUser);
|
|
774
|
+
int tinfl_decompress_mem_to_callback(const void * pIn_buf, size_t * pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void * pPut_buf_user, int flags);
|
|
788
775
|
|
|
789
776
|
struct tinfl_decompressor_tag;
|
|
790
777
|
typedef struct tinfl_decompressor_tag tinfl_decompressor;
|
|
@@ -793,74 +780,72 @@ typedef struct tinfl_decompressor_tag tinfl_decompressor;
|
|
|
793
780
|
/* non-C language bindings to tinfl_ API don't need to worry about */
|
|
794
781
|
/* structure size and allocation mechanism. */
|
|
795
782
|
|
|
796
|
-
tinfl_decompressor *tinfl_decompressor_alloc();
|
|
797
|
-
void tinfl_decompressor_free(tinfl_decompressor *pDecomp);
|
|
783
|
+
tinfl_decompressor * tinfl_decompressor_alloc(void);
|
|
784
|
+
void tinfl_decompressor_free(tinfl_decompressor * pDecomp);
|
|
798
785
|
|
|
799
786
|
/* Max size of LZ dictionary. */
|
|
800
787
|
#define TINFL_LZ_DICT_SIZE 32768
|
|
801
788
|
|
|
802
789
|
/* Return status. */
|
|
803
790
|
typedef enum {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
791
|
+
/* This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data */
|
|
792
|
+
/* is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). */
|
|
793
|
+
/* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */
|
|
794
|
+
TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4,
|
|
808
795
|
|
|
809
|
-
|
|
810
|
-
|
|
796
|
+
/* This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.) */
|
|
797
|
+
TINFL_STATUS_BAD_PARAM = -3,
|
|
811
798
|
|
|
812
|
-
|
|
813
|
-
|
|
799
|
+
/* This flags indicate the inflator is finished but the adler32 check of the uncompressed data didn't match. If you call it again it'll return TINFL_STATUS_DONE. */
|
|
800
|
+
TINFL_STATUS_ADLER32_MISMATCH = -2,
|
|
814
801
|
|
|
815
|
-
|
|
816
|
-
|
|
802
|
+
/* This flags indicate the inflator has somehow failed (bad code, corrupted input, etc.). If you call it again without resetting via tinfl_init() it it'll just keep on returning the same status failure code. */
|
|
803
|
+
TINFL_STATUS_FAILED = -1,
|
|
817
804
|
|
|
818
|
-
|
|
805
|
+
/* Any status code less than TINFL_STATUS_DONE must indicate a failure. */
|
|
819
806
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
807
|
+
/* This flag indicates the inflator has returned every byte of uncompressed data that it can, has consumed every byte that it needed, has successfully reached the end of the deflate stream, and */
|
|
808
|
+
/* if zlib headers and adler32 checking enabled that it has successfully checked the uncompressed data's adler32. If you call it again you'll just get TINFL_STATUS_DONE over and over again. */
|
|
809
|
+
TINFL_STATUS_DONE = 0,
|
|
823
810
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
811
|
+
/* This flag indicates the inflator MUST have more input data (even 1 byte) before it can make any more forward progress, or you need to clear the TINFL_FLAG_HAS_MORE_INPUT */
|
|
812
|
+
/* flag on the next call if you don't have any more source data. If the source data was somehow corrupted it's also possible (but unlikely) for the inflator to keep on demanding input to */
|
|
813
|
+
/* proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. */
|
|
814
|
+
TINFL_STATUS_NEEDS_MORE_INPUT = 1,
|
|
828
815
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
816
|
+
/* This flag indicates the inflator definitely has 1 or more bytes of uncompressed data available, but it cannot write this data into the output buffer. */
|
|
817
|
+
/* Note if the source compressed data was corrupted it's possible for the inflator to return a lot of uncompressed data to the caller. I've been assuming you know how much uncompressed data to expect */
|
|
818
|
+
/* (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible */
|
|
819
|
+
/* so I may need to add some code to address this. */
|
|
820
|
+
TINFL_STATUS_HAS_MORE_OUTPUT = 2
|
|
834
821
|
} tinfl_status;
|
|
835
822
|
|
|
836
823
|
/* Initializes the decompressor to its initial state. */
|
|
837
824
|
#define tinfl_init(r) \
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
825
|
+
do \
|
|
826
|
+
{ \
|
|
827
|
+
(r)->m_state = 0; \
|
|
828
|
+
} \
|
|
829
|
+
MZ_MACRO_END
|
|
843
830
|
#define tinfl_get_adler32(r) (r)->m_check_adler32
|
|
844
831
|
|
|
845
832
|
/* Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. */
|
|
846
833
|
/* This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. */
|
|
847
|
-
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
|
|
834
|
+
tinfl_status tinfl_decompress(tinfl_decompressor * r, const mz_uint8 * pIn_buf_next, size_t * pIn_buf_size, mz_uint8 * pOut_buf_start, mz_uint8 * pOut_buf_next, size_t * pOut_buf_size, const mz_uint32 decomp_flags);
|
|
848
835
|
|
|
849
836
|
/* Internal/private bits follow. */
|
|
850
|
-
enum
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS
|
|
837
|
+
enum {
|
|
838
|
+
TINFL_MAX_HUFF_TABLES = 3,
|
|
839
|
+
TINFL_MAX_HUFF_SYMBOLS_0 = 288,
|
|
840
|
+
TINFL_MAX_HUFF_SYMBOLS_1 = 32,
|
|
841
|
+
TINFL_MAX_HUFF_SYMBOLS_2 = 19,
|
|
842
|
+
TINFL_FAST_LOOKUP_BITS = 10,
|
|
843
|
+
TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS
|
|
858
844
|
};
|
|
859
845
|
|
|
860
|
-
typedef struct
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2];
|
|
846
|
+
typedef struct {
|
|
847
|
+
mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0];
|
|
848
|
+
mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2];
|
|
864
849
|
} tinfl_huff_table;
|
|
865
850
|
|
|
866
851
|
#if MINIZ_HAS_64BIT_REGISTERS
|
|
@@ -877,13 +862,12 @@ typedef mz_uint32 tinfl_bit_buf_t;
|
|
|
877
862
|
#define TINFL_BITBUF_SIZE (32)
|
|
878
863
|
#endif
|
|
879
864
|
|
|
880
|
-
struct tinfl_decompressor_tag
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137];
|
|
865
|
+
struct tinfl_decompressor_tag {
|
|
866
|
+
mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES];
|
|
867
|
+
tinfl_bit_buf_t m_bit_buf;
|
|
868
|
+
size_t m_dist_from_out_buf_start;
|
|
869
|
+
tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES];
|
|
870
|
+
mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137];
|
|
887
871
|
};
|
|
888
872
|
|
|
889
873
|
#ifdef __cplusplus
|
|
@@ -901,187 +885,183 @@ struct tinfl_decompressor_tag
|
|
|
901
885
|
extern "C" {
|
|
902
886
|
#endif
|
|
903
887
|
|
|
904
|
-
enum
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 512
|
|
888
|
+
enum {
|
|
889
|
+
/* Note: These enums can be reduced as needed to save memory or stack space - they are pretty conservative. */
|
|
890
|
+
MZ_ZIP_MAX_IO_BUF_SIZE = 64 * 1024,
|
|
891
|
+
MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 512,
|
|
892
|
+
MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 512
|
|
910
893
|
};
|
|
911
894
|
|
|
912
|
-
typedef struct
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
mz_uint32 m_file_index;
|
|
895
|
+
typedef struct {
|
|
896
|
+
/* Central directory file index. */
|
|
897
|
+
mz_uint32 m_file_index;
|
|
916
898
|
|
|
917
|
-
|
|
918
|
-
|
|
899
|
+
/* Byte offset of this entry in the archive's central directory. Note we currently only support up to UINT_MAX or less bytes in the central dir. */
|
|
900
|
+
mz_uint64 m_central_dir_ofs;
|
|
919
901
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
902
|
+
/* These fields are copied directly from the zip's central dir. */
|
|
903
|
+
mz_uint16 m_version_made_by;
|
|
904
|
+
mz_uint16 m_version_needed;
|
|
905
|
+
mz_uint16 m_bit_flag;
|
|
906
|
+
mz_uint16 m_method;
|
|
925
907
|
|
|
926
908
|
#ifndef MINIZ_NO_TIME
|
|
927
|
-
|
|
909
|
+
MZ_TIME_T m_time;
|
|
928
910
|
#endif
|
|
929
911
|
|
|
930
|
-
|
|
931
|
-
|
|
912
|
+
/* CRC-32 of uncompressed data. */
|
|
913
|
+
mz_uint32 m_crc32;
|
|
932
914
|
|
|
933
|
-
|
|
934
|
-
|
|
915
|
+
/* File's compressed size. */
|
|
916
|
+
mz_uint64 m_comp_size;
|
|
935
917
|
|
|
936
|
-
|
|
937
|
-
|
|
918
|
+
/* File's uncompressed size. Note, I've seen some old archives where directory entries had 512 bytes for their uncompressed sizes, but when you try to unpack them you actually get 0 bytes. */
|
|
919
|
+
mz_uint64 m_uncomp_size;
|
|
938
920
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
921
|
+
/* Zip internal and external file attributes. */
|
|
922
|
+
mz_uint16 m_internal_attr;
|
|
923
|
+
mz_uint32 m_external_attr;
|
|
942
924
|
|
|
943
|
-
|
|
944
|
-
|
|
925
|
+
/* Entry's local header file offset in bytes. */
|
|
926
|
+
mz_uint64 m_local_header_ofs;
|
|
945
927
|
|
|
946
|
-
|
|
947
|
-
|
|
928
|
+
/* Size of comment in bytes. */
|
|
929
|
+
mz_uint32 m_comment_size;
|
|
948
930
|
|
|
949
|
-
|
|
950
|
-
|
|
931
|
+
/* MZ_TRUE if the entry appears to be a directory. */
|
|
932
|
+
mz_bool m_is_directory;
|
|
951
933
|
|
|
952
|
-
|
|
953
|
-
|
|
934
|
+
/* MZ_TRUE if the entry uses encryption/strong encryption (which miniz_zip doesn't support) */
|
|
935
|
+
mz_bool m_is_encrypted;
|
|
954
936
|
|
|
955
|
-
|
|
956
|
-
|
|
937
|
+
/* MZ_TRUE if the file is not encrypted, a patch file, and if it uses a compression method we support. */
|
|
938
|
+
mz_bool m_is_supported;
|
|
957
939
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
940
|
+
/* Filename. If string ends in '/' it's a subdirectory entry. */
|
|
941
|
+
/* Guaranteed to be zero terminated, may be truncated to fit. */
|
|
942
|
+
char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE];
|
|
961
943
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
944
|
+
/* Comment field. */
|
|
945
|
+
/* Guaranteed to be zero terminated, may be truncated to fit. */
|
|
946
|
+
char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE];
|
|
965
947
|
|
|
966
948
|
} mz_zip_archive_file_stat;
|
|
967
949
|
|
|
968
|
-
typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n);
|
|
969
|
-
typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n);
|
|
970
|
-
typedef mz_bool (*mz_file_needs_keepalive)(void *pOpaque);
|
|
950
|
+
typedef size_t (*mz_file_read_func)(void * pOpaque, mz_uint64 file_ofs, void * pBuf, size_t n);
|
|
951
|
+
typedef size_t (*mz_file_write_func)(void * pOpaque, mz_uint64 file_ofs, const void * pBuf, size_t n);
|
|
952
|
+
typedef mz_bool (*mz_file_needs_keepalive)(void * pOpaque);
|
|
971
953
|
|
|
972
954
|
struct mz_zip_internal_state_tag;
|
|
973
955
|
typedef struct mz_zip_internal_state_tag mz_zip_internal_state;
|
|
974
956
|
|
|
975
957
|
typedef enum {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
958
|
+
MZ_ZIP_MODE_INVALID = 0,
|
|
959
|
+
MZ_ZIP_MODE_READING = 1,
|
|
960
|
+
MZ_ZIP_MODE_WRITING = 2,
|
|
961
|
+
MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3
|
|
980
962
|
} mz_zip_mode;
|
|
981
963
|
|
|
982
964
|
typedef enum {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
965
|
+
MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100,
|
|
966
|
+
MZ_ZIP_FLAG_IGNORE_PATH = 0x0200,
|
|
967
|
+
MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400,
|
|
968
|
+
MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800,
|
|
969
|
+
MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG = 0x1000, /* if enabled, mz_zip_reader_locate_file() will be called on each file as its validated to ensure the func finds the file in the central dir (intended for testing) */
|
|
970
|
+
MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY = 0x2000, /* validate the local headers, but don't decompress the entire file and check the crc32 */
|
|
971
|
+
MZ_ZIP_FLAG_WRITE_ZIP64 = 0x4000, /* always use the zip64 file format, instead of the original zip file format with automatic switch to zip64. Use as flags parameter with mz_zip_writer_init*_v2 */
|
|
972
|
+
MZ_ZIP_FLAG_WRITE_ALLOW_READING = 0x8000,
|
|
973
|
+
MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000
|
|
992
974
|
} mz_zip_flags;
|
|
993
975
|
|
|
994
976
|
typedef enum {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
977
|
+
MZ_ZIP_TYPE_INVALID = 0,
|
|
978
|
+
MZ_ZIP_TYPE_USER,
|
|
979
|
+
MZ_ZIP_TYPE_MEMORY,
|
|
980
|
+
MZ_ZIP_TYPE_HEAP,
|
|
981
|
+
MZ_ZIP_TYPE_FILE,
|
|
982
|
+
MZ_ZIP_TYPE_CFILE,
|
|
983
|
+
MZ_ZIP_TOTAL_TYPES
|
|
1002
984
|
} mz_zip_type;
|
|
1003
985
|
|
|
1004
986
|
/* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */
|
|
1005
987
|
typedef enum {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
988
|
+
MZ_ZIP_NO_ERROR = 0,
|
|
989
|
+
MZ_ZIP_UNDEFINED_ERROR,
|
|
990
|
+
MZ_ZIP_TOO_MANY_FILES,
|
|
991
|
+
MZ_ZIP_FILE_TOO_LARGE,
|
|
992
|
+
MZ_ZIP_UNSUPPORTED_METHOD,
|
|
993
|
+
MZ_ZIP_UNSUPPORTED_ENCRYPTION,
|
|
994
|
+
MZ_ZIP_UNSUPPORTED_FEATURE,
|
|
995
|
+
MZ_ZIP_FAILED_FINDING_CENTRAL_DIR,
|
|
996
|
+
MZ_ZIP_NOT_AN_ARCHIVE,
|
|
997
|
+
MZ_ZIP_INVALID_HEADER_OR_CORRUPTED,
|
|
998
|
+
MZ_ZIP_UNSUPPORTED_MULTIDISK,
|
|
999
|
+
MZ_ZIP_DECOMPRESSION_FAILED,
|
|
1000
|
+
MZ_ZIP_COMPRESSION_FAILED,
|
|
1001
|
+
MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE,
|
|
1002
|
+
MZ_ZIP_CRC_CHECK_FAILED,
|
|
1003
|
+
MZ_ZIP_UNSUPPORTED_CDIR_SIZE,
|
|
1004
|
+
MZ_ZIP_ALLOC_FAILED,
|
|
1005
|
+
MZ_ZIP_FILE_OPEN_FAILED,
|
|
1006
|
+
MZ_ZIP_FILE_CREATE_FAILED,
|
|
1007
|
+
MZ_ZIP_FILE_WRITE_FAILED,
|
|
1008
|
+
MZ_ZIP_FILE_READ_FAILED,
|
|
1009
|
+
MZ_ZIP_FILE_CLOSE_FAILED,
|
|
1010
|
+
MZ_ZIP_FILE_SEEK_FAILED,
|
|
1011
|
+
MZ_ZIP_FILE_STAT_FAILED,
|
|
1012
|
+
MZ_ZIP_INVALID_PARAMETER,
|
|
1013
|
+
MZ_ZIP_INVALID_FILENAME,
|
|
1014
|
+
MZ_ZIP_BUF_TOO_SMALL,
|
|
1015
|
+
MZ_ZIP_INTERNAL_ERROR,
|
|
1016
|
+
MZ_ZIP_FILE_NOT_FOUND,
|
|
1017
|
+
MZ_ZIP_ARCHIVE_TOO_LARGE,
|
|
1018
|
+
MZ_ZIP_VALIDATION_FAILED,
|
|
1019
|
+
MZ_ZIP_WRITE_CALLBACK_FAILED,
|
|
1020
|
+
MZ_ZIP_TOTAL_ERRORS
|
|
1039
1021
|
} mz_zip_error;
|
|
1040
1022
|
|
|
1041
|
-
typedef struct
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
mz_uint64 m_central_directory_file_ofs;
|
|
1023
|
+
typedef struct {
|
|
1024
|
+
mz_uint64 m_archive_size;
|
|
1025
|
+
mz_uint64 m_central_directory_file_ofs;
|
|
1045
1026
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1027
|
+
/* We only support up to UINT32_MAX files in zip64 mode. */
|
|
1028
|
+
mz_uint32 m_total_files;
|
|
1029
|
+
mz_zip_mode m_zip_mode;
|
|
1030
|
+
mz_zip_type m_zip_type;
|
|
1031
|
+
mz_zip_error m_last_error;
|
|
1051
1032
|
|
|
1052
|
-
|
|
1033
|
+
mz_uint64 m_file_offset_alignment;
|
|
1053
1034
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1035
|
+
mz_alloc_func m_pAlloc;
|
|
1036
|
+
mz_free_func m_pFree;
|
|
1037
|
+
mz_realloc_func m_pRealloc;
|
|
1038
|
+
void * m_pAlloc_opaque;
|
|
1058
1039
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1040
|
+
mz_file_read_func m_pRead;
|
|
1041
|
+
mz_file_write_func m_pWrite;
|
|
1042
|
+
mz_file_needs_keepalive m_pNeeds_keepalive;
|
|
1043
|
+
void * m_pIO_opaque;
|
|
1063
1044
|
|
|
1064
|
-
|
|
1045
|
+
mz_zip_internal_state * m_pState;
|
|
1065
1046
|
|
|
1066
1047
|
} mz_zip_archive;
|
|
1067
1048
|
|
|
1068
|
-
typedef struct
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
mz_uint flags;
|
|
1049
|
+
typedef struct {
|
|
1050
|
+
mz_zip_archive * pZip;
|
|
1051
|
+
mz_uint flags;
|
|
1072
1052
|
|
|
1073
|
-
|
|
1053
|
+
int status;
|
|
1074
1054
|
#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
|
|
1075
|
-
|
|
1055
|
+
mz_uint file_crc32;
|
|
1076
1056
|
#endif
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1057
|
+
mz_uint64 read_buf_size, read_buf_ofs, read_buf_avail, comp_remaining, out_buf_ofs, cur_file_ofs;
|
|
1058
|
+
mz_zip_archive_file_stat file_stat;
|
|
1059
|
+
void * pRead_buf;
|
|
1060
|
+
void * pWrite_buf;
|
|
1081
1061
|
|
|
1082
|
-
|
|
1062
|
+
size_t out_blk_remain;
|
|
1083
1063
|
|
|
1084
|
-
|
|
1064
|
+
tinfl_decompressor inflator;
|
|
1085
1065
|
|
|
1086
1066
|
} mz_zip_reader_extract_iter_state;
|
|
1087
1067
|
|
|
@@ -1089,150 +1069,150 @@ typedef struct
|
|
|
1089
1069
|
|
|
1090
1070
|
/* Inits a ZIP archive reader. */
|
|
1091
1071
|
/* These functions read and validate the archive's central directory. */
|
|
1092
|
-
mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags);
|
|
1072
|
+
mz_bool mz_zip_reader_init(mz_zip_archive * pZip, mz_uint64 size, mz_uint flags);
|
|
1093
1073
|
|
|
1094
|
-
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags);
|
|
1074
|
+
mz_bool mz_zip_reader_init_mem(mz_zip_archive * pZip, const void * pMem, size_t size, mz_uint flags);
|
|
1095
1075
|
|
|
1096
1076
|
#ifndef MINIZ_NO_STDIO
|
|
1097
1077
|
/* Read a archive from a disk file. */
|
|
1098
1078
|
/* file_start_ofs is the file offset where the archive actually begins, or 0. */
|
|
1099
1079
|
/* actual_archive_size is the true total size of the archive, which may be smaller than the file's actual size on disk. If zero the entire file is treated as the archive. */
|
|
1100
|
-
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
|
|
1101
|
-
mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size);
|
|
1080
|
+
mz_bool mz_zip_reader_init_file(mz_zip_archive * pZip, const char * pFilename, mz_uint32 flags);
|
|
1081
|
+
mz_bool mz_zip_reader_init_file_v2(mz_zip_archive * pZip, const char * pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size);
|
|
1102
1082
|
|
|
1103
1083
|
/* Read an archive from an already opened FILE, beginning at the current file position. */
|
|
1104
1084
|
/* The archive is assumed to be archive_size bytes long. If archive_size is < 0, then the entire rest of the file is assumed to contain the archive. */
|
|
1105
1085
|
/* The FILE will NOT be closed when mz_zip_reader_end() is called. */
|
|
1106
|
-
mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags);
|
|
1086
|
+
mz_bool mz_zip_reader_init_cfile(mz_zip_archive * pZip, MZ_FILE * pFile, mz_uint64 archive_size, mz_uint flags);
|
|
1107
1087
|
#endif
|
|
1108
1088
|
|
|
1109
1089
|
/* Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. */
|
|
1110
|
-
mz_bool mz_zip_reader_end(mz_zip_archive *pZip);
|
|
1090
|
+
mz_bool mz_zip_reader_end(mz_zip_archive * pZip);
|
|
1111
1091
|
|
|
1112
1092
|
/* -------- ZIP reading or writing */
|
|
1113
1093
|
|
|
1114
1094
|
/* Clears a mz_zip_archive struct to all zeros. */
|
|
1115
1095
|
/* Important: This must be done before passing the struct to any mz_zip functions. */
|
|
1116
|
-
void mz_zip_zero_struct(mz_zip_archive *pZip);
|
|
1096
|
+
void mz_zip_zero_struct(mz_zip_archive * pZip);
|
|
1117
1097
|
|
|
1118
|
-
mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip);
|
|
1119
|
-
mz_zip_type mz_zip_get_type(mz_zip_archive *pZip);
|
|
1098
|
+
mz_zip_mode mz_zip_get_mode(mz_zip_archive * pZip);
|
|
1099
|
+
mz_zip_type mz_zip_get_type(mz_zip_archive * pZip);
|
|
1120
1100
|
|
|
1121
1101
|
/* Returns the total number of files in the archive. */
|
|
1122
|
-
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
|
|
1102
|
+
mz_uint mz_zip_reader_get_num_files(mz_zip_archive * pZip);
|
|
1123
1103
|
|
|
1124
|
-
mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip);
|
|
1125
|
-
mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip);
|
|
1126
|
-
MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip);
|
|
1104
|
+
mz_uint64 mz_zip_get_archive_size(mz_zip_archive * pZip);
|
|
1105
|
+
mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive * pZip);
|
|
1106
|
+
MZ_FILE * mz_zip_get_cfile(mz_zip_archive * pZip);
|
|
1127
1107
|
|
|
1128
1108
|
/* Reads n bytes of raw archive data, starting at file offset file_ofs, to pBuf. */
|
|
1129
|
-
size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n);
|
|
1109
|
+
size_t mz_zip_read_archive_data(mz_zip_archive * pZip, mz_uint64 file_ofs, void * pBuf, size_t n);
|
|
1130
1110
|
|
|
1131
1111
|
/* Attempts to locates a file in the archive's central directory. */
|
|
1132
1112
|
/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
|
|
1133
1113
|
/* Returns -1 if the file cannot be found. */
|
|
1134
|
-
int mz_zip_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
|
|
1114
|
+
int mz_zip_locate_file(mz_zip_archive * pZip, const char * pName, const char * pComment, mz_uint flags);
|
|
1135
1115
|
/* Returns MZ_FALSE if the file cannot be found. */
|
|
1136
|
-
mz_bool mz_zip_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex);
|
|
1116
|
+
mz_bool mz_zip_locate_file_v2(mz_zip_archive * pZip, const char * pName, const char * pComment, mz_uint flags, mz_uint32 * pIndex);
|
|
1137
1117
|
|
|
1138
1118
|
/* All mz_zip funcs set the m_last_error field in the mz_zip_archive struct. These functions retrieve/manipulate this field. */
|
|
1139
1119
|
/* Note that the m_last_error functionality is not thread safe. */
|
|
1140
|
-
mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num);
|
|
1141
|
-
mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip);
|
|
1142
|
-
mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip);
|
|
1143
|
-
mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip);
|
|
1144
|
-
const char *mz_zip_get_error_string(mz_zip_error mz_err);
|
|
1120
|
+
mz_zip_error mz_zip_set_last_error(mz_zip_archive * pZip, mz_zip_error err_num);
|
|
1121
|
+
mz_zip_error mz_zip_peek_last_error(mz_zip_archive * pZip);
|
|
1122
|
+
mz_zip_error mz_zip_clear_last_error(mz_zip_archive * pZip);
|
|
1123
|
+
mz_zip_error mz_zip_get_last_error(mz_zip_archive * pZip);
|
|
1124
|
+
const char * mz_zip_get_error_string(mz_zip_error mz_err);
|
|
1145
1125
|
|
|
1146
1126
|
/* MZ_TRUE if the archive file entry is a directory entry. */
|
|
1147
|
-
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
|
|
1127
|
+
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive * pZip, mz_uint file_index);
|
|
1148
1128
|
|
|
1149
1129
|
/* MZ_TRUE if the file is encrypted/strong encrypted. */
|
|
1150
|
-
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
|
|
1130
|
+
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive * pZip, mz_uint file_index);
|
|
1151
1131
|
|
|
1152
1132
|
/* MZ_TRUE if the compression method is supported, and the file is not encrypted, and the file is not a compressed patch file. */
|
|
1153
|
-
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index);
|
|
1133
|
+
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive * pZip, mz_uint file_index);
|
|
1154
1134
|
|
|
1155
1135
|
/* Retrieves the filename of an archive file entry. */
|
|
1156
1136
|
/* Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. */
|
|
1157
|
-
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
|
|
1137
|
+
mz_uint mz_zip_reader_get_filename(mz_zip_archive * pZip, mz_uint file_index, char * pFilename, mz_uint filename_buf_size);
|
|
1158
1138
|
|
|
1159
1139
|
/* Attempts to locates a file in the archive's central directory. */
|
|
1160
1140
|
/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
|
|
1161
1141
|
/* Returns -1 if the file cannot be found. */
|
|
1162
|
-
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
|
|
1163
|
-
int mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index);
|
|
1142
|
+
int mz_zip_reader_locate_file(mz_zip_archive * pZip, const char * pName, const char * pComment, mz_uint flags);
|
|
1143
|
+
int mz_zip_reader_locate_file_v2(mz_zip_archive * pZip, const char * pName, const char * pComment, mz_uint flags, mz_uint32 * file_index);
|
|
1164
1144
|
|
|
1165
1145
|
/* Returns detailed information about an archive file entry. */
|
|
1166
|
-
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
|
|
1146
|
+
mz_bool mz_zip_reader_file_stat(mz_zip_archive * pZip, mz_uint file_index, mz_zip_archive_file_stat * pStat);
|
|
1167
1147
|
|
|
1168
1148
|
/* MZ_TRUE if the file is in zip64 format. */
|
|
1169
1149
|
/* A file is considered zip64 if it contained a zip64 end of central directory marker, or if it contained any zip64 extended file information fields in the central directory. */
|
|
1170
|
-
mz_bool mz_zip_is_zip64(mz_zip_archive *pZip);
|
|
1150
|
+
mz_bool mz_zip_is_zip64(mz_zip_archive * pZip);
|
|
1171
1151
|
|
|
1172
1152
|
/* Returns the total central directory size in bytes. */
|
|
1173
1153
|
/* The current max supported size is <= MZ_UINT32_MAX. */
|
|
1174
|
-
size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip);
|
|
1154
|
+
size_t mz_zip_get_central_dir_size(mz_zip_archive * pZip);
|
|
1175
1155
|
|
|
1176
1156
|
/* Extracts a archive file to a memory buffer using no memory allocation. */
|
|
1177
1157
|
/* There must be at least enough room on the stack to store the inflator's state (~34KB or so). */
|
|
1178
|
-
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
|
|
1179
|
-
mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
|
|
1158
|
+
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive * pZip, mz_uint file_index, void * pBuf, size_t buf_size, mz_uint flags, void * pUser_read_buf, size_t user_read_buf_size);
|
|
1159
|
+
mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive * pZip, const char * pFilename, void * pBuf, size_t buf_size, mz_uint flags, void * pUser_read_buf, size_t user_read_buf_size);
|
|
1180
1160
|
|
|
1181
1161
|
/* Extracts a archive file to a memory buffer. */
|
|
1182
|
-
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags);
|
|
1183
|
-
mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags);
|
|
1162
|
+
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive * pZip, mz_uint file_index, void * pBuf, size_t buf_size, mz_uint flags);
|
|
1163
|
+
mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive * pZip, const char * pFilename, void * pBuf, size_t buf_size, mz_uint flags);
|
|
1184
1164
|
|
|
1185
1165
|
/* Extracts a archive file to a dynamically allocated heap buffer. */
|
|
1186
1166
|
/* The memory will be allocated via the mz_zip_archive's alloc/realloc functions. */
|
|
1187
1167
|
/* Returns NULL and sets the last error on failure. */
|
|
1188
|
-
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags);
|
|
1189
|
-
void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
|
|
1168
|
+
void * mz_zip_reader_extract_to_heap(mz_zip_archive * pZip, mz_uint file_index, size_t * pSize, mz_uint flags);
|
|
1169
|
+
void * mz_zip_reader_extract_file_to_heap(mz_zip_archive * pZip, const char * pFilename, size_t * pSize, mz_uint flags);
|
|
1190
1170
|
|
|
1191
1171
|
/* Extracts a archive file using a callback function to output the file's data. */
|
|
1192
|
-
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
|
|
1193
|
-
mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
|
|
1172
|
+
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive * pZip, mz_uint file_index, mz_file_write_func pCallback, void * pOpaque, mz_uint flags);
|
|
1173
|
+
mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive * pZip, const char * pFilename, mz_file_write_func pCallback, void * pOpaque, mz_uint flags);
|
|
1194
1174
|
|
|
1195
1175
|
/* Extract a file iteratively */
|
|
1196
|
-
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
|
|
1197
|
-
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
|
|
1198
|
-
size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size);
|
|
1199
|
-
mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState);
|
|
1176
|
+
mz_zip_reader_extract_iter_state * mz_zip_reader_extract_iter_new(mz_zip_archive * pZip, mz_uint file_index, mz_uint flags);
|
|
1177
|
+
mz_zip_reader_extract_iter_state * mz_zip_reader_extract_file_iter_new(mz_zip_archive * pZip, const char * pFilename, mz_uint flags);
|
|
1178
|
+
size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state * pState, void * pvBuf, size_t buf_size);
|
|
1179
|
+
mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state * pState);
|
|
1200
1180
|
|
|
1201
1181
|
#ifndef MINIZ_NO_STDIO
|
|
1202
1182
|
/* Extracts a archive file to a disk file and sets its last accessed and modified times. */
|
|
1203
1183
|
/* This function only extracts files, not archive directory records. */
|
|
1204
|
-
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags);
|
|
1205
|
-
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags);
|
|
1184
|
+
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive * pZip, mz_uint file_index, const char * pDst_filename, mz_uint flags);
|
|
1185
|
+
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive * pZip, const char * pArchive_filename, const char * pDst_filename, mz_uint flags);
|
|
1206
1186
|
|
|
1207
1187
|
/* Extracts a archive file starting at the current position in the destination FILE stream. */
|
|
1208
|
-
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *File, mz_uint flags);
|
|
1209
|
-
mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags);
|
|
1188
|
+
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive * pZip, mz_uint file_index, MZ_FILE * File, mz_uint flags);
|
|
1189
|
+
mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive * pZip, const char * pArchive_filename, MZ_FILE * pFile, mz_uint flags);
|
|
1210
1190
|
#endif
|
|
1211
1191
|
|
|
1212
1192
|
#if 0
|
|
1213
1193
|
/* TODO */
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1194
|
+
typedef void * mz_zip_streaming_extract_state_ptr;
|
|
1195
|
+
mz_zip_streaming_extract_state_ptr mz_zip_streaming_extract_begin(mz_zip_archive * pZip, mz_uint file_index, mz_uint flags);
|
|
1196
|
+
uint64_t mz_zip_streaming_extract_get_size(mz_zip_archive * pZip, mz_zip_streaming_extract_state_ptr pState);
|
|
1197
|
+
uint64_t mz_zip_streaming_extract_get_cur_ofs(mz_zip_archive * pZip, mz_zip_streaming_extract_state_ptr pState);
|
|
1198
|
+
mz_bool mz_zip_streaming_extract_seek(mz_zip_archive * pZip, mz_zip_streaming_extract_state_ptr pState, uint64_t new_ofs);
|
|
1199
|
+
size_t mz_zip_streaming_extract_read(mz_zip_archive * pZip, mz_zip_streaming_extract_state_ptr pState, void * pBuf, size_t buf_size);
|
|
1200
|
+
mz_bool mz_zip_streaming_extract_end(mz_zip_archive * pZip, mz_zip_streaming_extract_state_ptr pState);
|
|
1221
1201
|
#endif
|
|
1222
1202
|
|
|
1223
1203
|
/* This function compares the archive's local headers, the optional local zip64 extended information block, and the optional descriptor following the compressed data vs. the data in the central directory. */
|
|
1224
1204
|
/* It also validates that each file can be successfully uncompressed unless the MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY is specified. */
|
|
1225
|
-
mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
|
|
1205
|
+
mz_bool mz_zip_validate_file(mz_zip_archive * pZip, mz_uint file_index, mz_uint flags);
|
|
1226
1206
|
|
|
1227
1207
|
/* Validates an entire archive by calling mz_zip_validate_file() on each file. */
|
|
1228
|
-
mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags);
|
|
1208
|
+
mz_bool mz_zip_validate_archive(mz_zip_archive * pZip, mz_uint flags);
|
|
1229
1209
|
|
|
1230
1210
|
/* Misc utils/helpers, valid for ZIP reading or writing */
|
|
1231
|
-
mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr);
|
|
1232
|
-
mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr);
|
|
1211
|
+
mz_bool mz_zip_validate_mem_archive(const void * pMem, size_t size, mz_uint flags, mz_zip_error * pErr);
|
|
1212
|
+
mz_bool mz_zip_validate_file_archive(const char * pFilename, mz_uint flags, mz_zip_error * pErr);
|
|
1233
1213
|
|
|
1234
1214
|
/* Universal end function - calls either mz_zip_reader_end() or mz_zip_writer_end(). */
|
|
1235
|
-
mz_bool mz_zip_end(mz_zip_archive *pZip);
|
|
1215
|
+
mz_bool mz_zip_end(mz_zip_archive * pZip);
|
|
1236
1216
|
|
|
1237
1217
|
/* -------- ZIP writing */
|
|
1238
1218
|
|
|
@@ -1241,16 +1221,16 @@ mz_bool mz_zip_end(mz_zip_archive *pZip);
|
|
|
1241
1221
|
/* Inits a ZIP archive writer. */
|
|
1242
1222
|
/*Set pZip->m_pWrite (and pZip->m_pIO_opaque) before calling mz_zip_writer_init or mz_zip_writer_init_v2*/
|
|
1243
1223
|
/*The output is streamable, i.e. file_ofs in mz_file_write_func always increases only by n*/
|
|
1244
|
-
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size);
|
|
1245
|
-
mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags);
|
|
1224
|
+
mz_bool mz_zip_writer_init(mz_zip_archive * pZip, mz_uint64 existing_size);
|
|
1225
|
+
mz_bool mz_zip_writer_init_v2(mz_zip_archive * pZip, mz_uint64 existing_size, mz_uint flags);
|
|
1246
1226
|
|
|
1247
|
-
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size);
|
|
1248
|
-
mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags);
|
|
1227
|
+
mz_bool mz_zip_writer_init_heap(mz_zip_archive * pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size);
|
|
1228
|
+
mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive * pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags);
|
|
1249
1229
|
|
|
1250
1230
|
#ifndef MINIZ_NO_STDIO
|
|
1251
|
-
mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning);
|
|
1252
|
-
mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags);
|
|
1253
|
-
mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags);
|
|
1231
|
+
mz_bool mz_zip_writer_init_file(mz_zip_archive * pZip, const char * pFilename, mz_uint64 size_to_reserve_at_beginning);
|
|
1232
|
+
mz_bool mz_zip_writer_init_file_v2(mz_zip_archive * pZip, const char * pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags);
|
|
1233
|
+
mz_bool mz_zip_writer_init_cfile(mz_zip_archive * pZip, MZ_FILE * pFile, mz_uint flags);
|
|
1254
1234
|
#endif
|
|
1255
1235
|
|
|
1256
1236
|
/* Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. */
|
|
@@ -1259,50 +1239,50 @@ mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint f
|
|
|
1259
1239
|
/* Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. */
|
|
1260
1240
|
/* Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before */
|
|
1261
1241
|
/* the archive is finalized the file's central directory will be hosed. */
|
|
1262
|
-
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename);
|
|
1263
|
-
mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
|
|
1242
|
+
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive * pZip, const char * pFilename);
|
|
1243
|
+
mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive * pZip, const char * pFilename, mz_uint flags);
|
|
1264
1244
|
|
|
1265
1245
|
/* Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. */
|
|
1266
1246
|
/* To add a directory entry, call this method with an archive name ending in a forwardslash with an empty buffer. */
|
|
1267
1247
|
/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
|
|
1268
|
-
mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags);
|
|
1248
|
+
mz_bool mz_zip_writer_add_mem(mz_zip_archive * pZip, const char * pArchive_name, const void * pBuf, size_t buf_size, mz_uint level_and_flags);
|
|
1269
1249
|
|
|
1270
1250
|
/* Like mz_zip_writer_add_mem(), except you can specify a file comment field, and optionally supply the function with already compressed data. */
|
|
1271
1251
|
/* uncomp_size/uncomp_crc32 are only used if the MZ_ZIP_FLAG_COMPRESSED_DATA flag is specified. */
|
|
1272
|
-
mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
|
1273
|
-
|
|
1252
|
+
mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive * pZip, const char * pArchive_name, const void * pBuf, size_t buf_size, const void * pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
|
1253
|
+
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32);
|
|
1274
1254
|
|
|
1275
|
-
mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
|
1276
|
-
|
|
1277
|
-
|
|
1255
|
+
mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive * pZip, const char * pArchive_name, const void * pBuf, size_t buf_size, const void * pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
|
1256
|
+
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T * last_modified, const char * user_extra_data_local, mz_uint user_extra_data_local_len,
|
|
1257
|
+
const char * user_extra_data_central, mz_uint user_extra_data_central_len);
|
|
1278
1258
|
|
|
1279
1259
|
#ifndef MINIZ_NO_STDIO
|
|
1280
1260
|
/* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */
|
|
1281
1261
|
/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
|
|
1282
|
-
mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
|
|
1262
|
+
mz_bool mz_zip_writer_add_file(mz_zip_archive * pZip, const char * pArchive_name, const char * pSrc_filename, const void * pComment, mz_uint16 comment_size, mz_uint level_and_flags);
|
|
1283
1263
|
|
|
1284
1264
|
/* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */
|
|
1285
|
-
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add,
|
|
1286
|
-
|
|
1287
|
-
|
|
1265
|
+
mz_bool mz_zip_writer_add_cfile(mz_zip_archive * pZip, const char * pArchive_name, MZ_FILE * pSrc_file, mz_uint64 size_to_add,
|
|
1266
|
+
const MZ_TIME_T * pFile_time, const void * pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char * user_extra_data_local, mz_uint user_extra_data_local_len,
|
|
1267
|
+
const char * user_extra_data_central, mz_uint user_extra_data_central_len);
|
|
1288
1268
|
#endif
|
|
1289
1269
|
|
|
1290
1270
|
/* Adds a file to an archive by fully cloning the data from another archive. */
|
|
1291
1271
|
/* This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data (it may add or modify the zip64 local header extra data field), and the optional descriptor following the compressed data. */
|
|
1292
|
-
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index);
|
|
1272
|
+
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive * pZip, mz_zip_archive * pSource_zip, mz_uint src_file_index);
|
|
1293
1273
|
|
|
1294
1274
|
/* Finalizes the archive by writing the central directory records followed by the end of central directory record. */
|
|
1295
1275
|
/* After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). */
|
|
1296
1276
|
/* An archive must be manually finalized by calling this function for it to be valid. */
|
|
1297
|
-
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip);
|
|
1277
|
+
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive * pZip);
|
|
1298
1278
|
|
|
1299
1279
|
/* Finalizes a heap archive, returning a poiner to the heap block and its size. */
|
|
1300
1280
|
/* The heap block will be allocated using the mz_zip_archive's alloc/realloc callbacks. */
|
|
1301
|
-
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize);
|
|
1281
|
+
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive * pZip, void ** ppBuf, size_t * pSize);
|
|
1302
1282
|
|
|
1303
1283
|
/* Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. */
|
|
1304
1284
|
/* Note for the archive to be valid, it *must* have been finalized before ending (this function will not do it for you). */
|
|
1305
|
-
mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
|
|
1285
|
+
mz_bool mz_zip_writer_end(mz_zip_archive * pZip);
|
|
1306
1286
|
|
|
1307
1287
|
/* -------- Misc. high-level helper functions: */
|
|
1308
1288
|
|
|
@@ -1310,14 +1290,14 @@ mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
|
|
|
1310
1290
|
/* Note this is NOT a fully safe operation. If it crashes or dies in some way your archive can be left in a screwed up state (without a central directory). */
|
|
1311
1291
|
/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
|
|
1312
1292
|
/* TODO: Perhaps add an option to leave the existing central dir in place in case the add dies? We could then truncate the file (so the old central dir would be at the end) if something goes wrong. */
|
|
1313
|
-
mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
|
|
1314
|
-
mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr);
|
|
1293
|
+
mz_bool mz_zip_add_mem_to_archive_file_in_place(const char * pZip_filename, const char * pArchive_name, const void * pBuf, size_t buf_size, const void * pComment, mz_uint16 comment_size, mz_uint level_and_flags);
|
|
1294
|
+
mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char * pZip_filename, const char * pArchive_name, const void * pBuf, size_t buf_size, const void * pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error * pErr);
|
|
1315
1295
|
|
|
1316
1296
|
/* Reads a single file from an archive into a heap block. */
|
|
1317
1297
|
/* If pComment is not NULL, only the file with the specified comment will be extracted. */
|
|
1318
1298
|
/* Returns NULL on failure. */
|
|
1319
|
-
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags);
|
|
1320
|
-
void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr);
|
|
1299
|
+
void * mz_zip_extract_archive_file_to_heap(const char * pZip_filename, const char * pArchive_name, size_t * pSize, mz_uint flags);
|
|
1300
|
+
void * mz_zip_extract_archive_file_to_heap_v2(const char * pZip_filename, const char * pArchive_name, const char * pComment, size_t * pSize, mz_uint flags, mz_zip_error * pErr);
|
|
1321
1301
|
|
|
1322
1302
|
#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */
|
|
1323
1303
|
|