CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
miniz.h
Go to the documentation of this file.
1#ifndef MINIZ_EXPORT
2#define MINIZ_EXPORT
3#endif
4/* miniz.c 3.0.2 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
5 See "unlicense" statement at the end of this file.
6 Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
7 Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt
8
9 Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define
10 MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros).
11
12 * Low-level Deflate/Inflate implementation notes:
13
14 Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or
15 greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses
16 approximately as well as zlib.
17
18 Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function
19 coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory
20 block large enough to hold the entire file.
21
22 The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation.
23
24 * zlib-style API notes:
25
26 miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in
27 zlib replacement in many apps:
28 The z_stream struct, optional memory allocation callbacks
29 deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound
30 inflateInit/inflateInit2/inflate/inflateReset/inflateEnd
31 compress, compress2, compressBound, uncompress
32 CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines.
33 Supports raw deflate streams or standard zlib streams with adler-32 checking.
34
35 Limitations:
36 The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries.
37 I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but
38 there are no guarantees that miniz.c pulls this off perfectly.
39
40 * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by
41 Alex Evans. Supports 1-4 bytes/pixel images.
42
43 * ZIP archive API notes:
44
45 The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to
46 get the job done with minimal fuss. There are simple API's to retrieve file information, read files from
47 existing archives, create new archives, append new files to existing archives, or clone archive data from
48 one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h),
49 or you can specify custom file read/write callbacks.
50
51 - Archive reading: Just call this function to read a single file from a disk archive:
52
53 void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name,
54 size_t *pSize, mz_uint zip_flags);
55
56 For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central
57 directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files.
58
59 - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file:
60
61 int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
62
63 The locate operation can optionally check file comments too, which (as one example) can be used to identify
64 multiple versions of the same file in an archive. This function uses a simple linear search through the central
65 directory, so it's not very fast.
66
67 Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and
68 retrieve detailed info on each file by calling mz_zip_reader_file_stat().
69
70 - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data
71 to disk and builds an exact image of the central directory in memory. The central directory image is written
72 all at once at the end of the archive file when the archive is finalized.
73
74 The archive writer can optionally align each file's local header and file data to any power of 2 alignment,
75 which can be useful when the archive will be read from optical media. Also, the writer supports placing
76 arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still
77 readable by any ZIP tool.
78
79 - Archive appending: The simple way to add a single file to an archive is to call this function:
80
81 mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name,
82 const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
83
84 The archive will be created if it doesn't already exist, otherwise it'll be appended to.
85 Note the appending is done in-place and is not an atomic operation, so if something goes wrong
86 during the operation it's possible the archive could be left without a central directory (although the local
87 file headers and file data will be fine, so the archive will be recoverable).
88
89 For more complex archive modification scenarios:
90 1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to
91 preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the
92 compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and
93 you're done. This is safe but requires a bunch of temporary disk space or heap memory.
94
95 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(),
96 append new files as needed, then finalize the archive which will write an updated central directory to the
97 original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a
98 possibility that the archive's central directory could be lost with this method if anything goes wrong, though.
99
100 - ZIP archive support limitations:
101 No spanning support. Extraction functions can only handle unencrypted, stored or deflated files.
102 Requires streams capable of seeking.
103
104 * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the
105 below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it.
106
107 * Important: For best perf. be sure to customize the below macros for your target platform:
108 #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
109 #define MINIZ_LITTLE_ENDIAN 1
110 #define MINIZ_HAS_64BIT_REGISTERS 1
111
112 * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz
113 uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files
114 (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes).
115*/
116#pragma once
117
118
119
120/* Defines to completely disable specific portions of miniz.c:
121 If all macros here are defined the only functionality remaining will be CRC-32 and adler-32. */
122
123/* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */
124/*#define MINIZ_NO_STDIO */
125
126/* If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or */
127/* get/set file times, and the C run-time funcs that get/set times won't be called. */
128/* The current downside is the times written to your archives will be from 1979. */
129#define MINIZ_NO_TIME
130
131/* Define MINIZ_NO_DEFLATE_APIS to disable all compression API's. */
132#define MINIZ_NO_DEFLATE_APIS
133
134/* Define MINIZ_NO_INFLATE_APIS to disable all decompression API's. */
135/*#define MINIZ_NO_INFLATE_APIS */
136
137/* Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. */
138/*#define MINIZ_NO_ARCHIVE_APIS */
139
140/* Define MINIZ_NO_ARCHIVE_WRITING_APIS to disable all writing related ZIP archive API's. */
141#define MINIZ_NO_ARCHIVE_WRITING_APIS
142
143/* Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. */
144#define MINIZ_NO_ZLIB_APIS
145
146/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. */
147#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
148
149/* Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc.
150 Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc
151 callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user
152 functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */
153/*#define MINIZ_NO_MALLOC */
154
155#ifdef MINIZ_NO_INFLATE_APIS
156#define MINIZ_NO_ARCHIVE_APIS
157#endif
158
159#ifdef MINIZ_NO_DEFLATE_APIS
160#define MINIZ_NO_ARCHIVE_WRITING_APIS
161#endif
162
163#if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
164/* TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux */
165#define MINIZ_NO_TIME
166#endif
167
168#include <stddef.h>
169
170#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
171#include <time.h>
172#endif
173
174#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
175/* MINIZ_X86_OR_X64_CPU is only used to help set the below macros. */
176#define MINIZ_X86_OR_X64_CPU 1
177#else
178#define MINIZ_X86_OR_X64_CPU 0
179#endif
180
181/* Set MINIZ_LITTLE_ENDIAN only if not set */
182#if !defined(MINIZ_LITTLE_ENDIAN)
183#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
184
185#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
186/* Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. */
187#define MINIZ_LITTLE_ENDIAN 1
188#else
189#define MINIZ_LITTLE_ENDIAN 0
190#endif
191
192#else
193
194#if MINIZ_X86_OR_X64_CPU
195#define MINIZ_LITTLE_ENDIAN 1
196#else
197#define MINIZ_LITTLE_ENDIAN 0
198#endif
199
200#endif
201#endif
202
203/* Using unaligned loads and stores causes errors when using UBSan */
204#if defined(__has_feature)
205#if __has_feature(undefined_behavior_sanitizer)
206#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
207#endif
208#endif
209
210/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES only if not set */
211#if !defined(MINIZ_USE_UNALIGNED_LOADS_AND_STORES)
212#if MINIZ_X86_OR_X64_CPU
213/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. */
214#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
215#define MINIZ_UNALIGNED_USE_MEMCPY
216#else
217#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
218#endif
219#endif
220
221#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
222/* 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). */
223#define MINIZ_HAS_64BIT_REGISTERS 1
224#else
225#define MINIZ_HAS_64BIT_REGISTERS 0
226#endif
227
228#ifdef __cplusplus
229extern "C"
230{
231#endif
232
233 /* ------------------- zlib-style API Definitions. */
234
235 /* For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! */
236 typedef unsigned long mz_ulong;
237
238 /* 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. */
239 MINIZ_EXPORT void mz_free(void *p);
240
241#define MZ_ADLER32_INIT (1)
242 /* mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. */
243 MINIZ_EXPORT mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
244
245#define MZ_CRC32_INIT (0)
246 /* mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. */
247 MINIZ_EXPORT mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
248
249 /* Compression strategies. */
250 enum
251 {
256 MZ_FIXED = 4
257 };
258
259/* Method */
260#define MZ_DEFLATED 8
261
262 /* Heap allocation callbacks.
263 Note that mz_alloc_func parameter types purposely differ from zlib's: items/size is size_t, not unsigned long. */
264 typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size);
265 typedef void (*mz_free_func)(void *opaque, void *address);
266 typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size);
267
268 /* 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. */
269 enum
270 {
277 };
278
279#define MZ_VERSION "11.0.2"
280#define MZ_VERNUM 0xB002
281#define MZ_VER_MAJOR 11
282#define MZ_VER_MINOR 2
283#define MZ_VER_REVISION 0
284#define MZ_VER_SUBREVISION 0
285
286#ifndef MINIZ_NO_ZLIB_APIS
287
288 /* 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). */
289 enum
290 {
291 MZ_NO_FLUSH = 0,
293 MZ_SYNC_FLUSH = 2,
294 MZ_FULL_FLUSH = 3,
295 MZ_FINISH = 4,
296 MZ_BLOCK = 5
297 };
298
299 /* Return status codes. MZ_PARAM_ERROR is non-standard. */
300 enum
301 {
302 MZ_OK = 0,
303 MZ_STREAM_END = 1,
304 MZ_NEED_DICT = 2,
305 MZ_ERRNO = -1,
306 MZ_STREAM_ERROR = -2,
307 MZ_DATA_ERROR = -3,
308 MZ_MEM_ERROR = -4,
309 MZ_BUF_ERROR = -5,
310 MZ_VERSION_ERROR = -6,
311 MZ_PARAM_ERROR = -10000
312 };
313
314/* Window bits */
315#define MZ_DEFAULT_WINDOW_BITS 15
316
317 struct mz_internal_state;
318
319 /* Compression/decompression stream struct. */
320 typedef struct mz_stream_s
321 {
322 const unsigned char *next_in; /* pointer to next byte to read */
323 unsigned int avail_in; /* number of bytes available at next_in */
324 mz_ulong total_in; /* total number of bytes consumed so far */
325
326 unsigned char *next_out; /* pointer to next byte to write */
327 unsigned int avail_out; /* number of bytes that can be written to next_out */
328 mz_ulong total_out; /* total number of bytes produced so far */
329
330 char *msg; /* error msg (unused) */
331 struct mz_internal_state *state; /* internal state, allocated by zalloc/zfree */
332
333 mz_alloc_func zalloc; /* optional heap allocation function (defaults to malloc) */
334 mz_free_func zfree; /* optional heap free function (defaults to free) */
335 void *opaque; /* heap alloc function user pointer */
336
337 int data_type; /* data_type (unused) */
338 mz_ulong adler; /* adler32 of the source or uncompressed data */
339 mz_ulong reserved; /* not used */
340 } mz_stream;
341
342 typedef mz_stream *mz_streamp;
343
344 /* Returns the version string of miniz.c. */
345 MINIZ_EXPORT const char *mz_version(void);
346
347#ifndef MINIZ_NO_DEFLATE_APIS
348
349 /* mz_deflateInit() initializes a compressor with default options: */
350 /* Parameters: */
351 /* pStream must point to an initialized mz_stream struct. */
352 /* level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. */
353 /* level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio. */
354 /* (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) */
355 /* Return values: */
356 /* MZ_OK on success. */
357 /* MZ_STREAM_ERROR if the stream is bogus. */
358 /* MZ_PARAM_ERROR if the input parameters are bogus. */
359 /* MZ_MEM_ERROR on out of memory. */
361
362 /* mz_deflateInit2() is like mz_deflate(), except with more control: */
363 /* Additional parameters: */
364 /* method must be MZ_DEFLATED */
365 /* window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) */
366 /* mem_level must be between [1, 9] (it's checked but ignored by miniz.c) */
367 MINIZ_EXPORT int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
368
369 /* Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). */
371
372 /* mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. */
373 /* Parameters: */
374 /* pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. */
375 /* flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH. */
376 /* Return values: */
377 /* MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full). */
378 /* MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore. */
379 /* MZ_STREAM_ERROR if the stream is bogus. */
380 /* MZ_PARAM_ERROR if one of the parameters is invalid. */
381 /* MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) */
383
384 /* mz_deflateEnd() deinitializes a compressor: */
385 /* Return values: */
386 /* MZ_OK on success. */
387 /* MZ_STREAM_ERROR if the stream is bogus. */
389
390 /* mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. */
392
393 /* Single-call compression functions mz_compress() and mz_compress2(): */
394 /* Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. */
395 MINIZ_EXPORT int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
396 MINIZ_EXPORT int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
397
398 /* mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). */
400
401#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/
402
403#ifndef MINIZ_NO_INFLATE_APIS
404
405 /* Initializes a decompressor. */
407
408 /* mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: */
409 /* window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). */
411
412 /* Quickly resets a compressor without having to reallocate anything. Same as calling mz_inflateEnd() followed by mz_inflateInit()/mz_inflateInit2(). */
414
415 /* Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. */
416 /* Parameters: */
417 /* pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. */
418 /* flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. */
419 /* On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster). */
420 /* MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data. */
421 /* Return values: */
422 /* MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full. */
423 /* MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified. */
424 /* MZ_STREAM_ERROR if the stream is bogus. */
425 /* MZ_DATA_ERROR if the deflate stream is invalid. */
426 /* MZ_PARAM_ERROR if one of the parameters is invalid. */
427 /* MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again */
428 /* with more input data, or with more room in the output buffer (except when using single call decompression, described above). */
430
431 /* Deinitializes a decompressor. */
433
434 /* Single-call decompression. */
435 /* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */
436 MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
437 MINIZ_EXPORT int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len);
438#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/
439
440 /* Returns a string description of the specified error code, or NULL if the error code is invalid. */
441 MINIZ_EXPORT const char *mz_error(int err);
442
443/* 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. */
444/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. */
445#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
446 typedef unsigned char Byte;
447 typedef unsigned int uInt;
448 typedef mz_ulong uLong;
449 typedef Byte Bytef;
450 typedef uInt uIntf;
451 typedef char charf;
452 typedef int intf;
453 typedef void *voidpf;
454 typedef uLong uLongf;
455 typedef void *voidp;
456 typedef void *const voidpc;
457#define Z_NULL 0
458#define Z_NO_FLUSH MZ_NO_FLUSH
459#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
460#define Z_SYNC_FLUSH MZ_SYNC_FLUSH
461#define Z_FULL_FLUSH MZ_FULL_FLUSH
462#define Z_FINISH MZ_FINISH
463#define Z_BLOCK MZ_BLOCK
464#define Z_OK MZ_OK
465#define Z_STREAM_END MZ_STREAM_END
466#define Z_NEED_DICT MZ_NEED_DICT
467#define Z_ERRNO MZ_ERRNO
468#define Z_STREAM_ERROR MZ_STREAM_ERROR
469#define Z_DATA_ERROR MZ_DATA_ERROR
470#define Z_MEM_ERROR MZ_MEM_ERROR
471#define Z_BUF_ERROR MZ_BUF_ERROR
472#define Z_VERSION_ERROR MZ_VERSION_ERROR
473#define Z_PARAM_ERROR MZ_PARAM_ERROR
474#define Z_NO_COMPRESSION MZ_NO_COMPRESSION
475#define Z_BEST_SPEED MZ_BEST_SPEED
476#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION
477#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
478#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY
479#define Z_FILTERED MZ_FILTERED
480#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY
481#define Z_RLE MZ_RLE
482#define Z_FIXED MZ_FIXED
483#define Z_DEFLATED MZ_DEFLATED
484#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
485 /* See mz_alloc_func */
486 typedef void *(*alloc_func)(void *opaque, size_t items, size_t size);
487 /* See mz_free_func */
488 typedef void (*free_func)(void *opaque, void *address);
489
490#define internal_state mz_internal_state
491#define z_stream mz_stream
492
493#ifndef MINIZ_NO_DEFLATE_APIS
494 /* Compatiblity with zlib API. See called functions for documentation */
495 static int deflateInit(mz_streamp pStream, int level)
496 {
497 return mz_deflateInit(pStream, level);
498 }
499 static int deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy)
500 {
501 return mz_deflateInit2(pStream, level, method, window_bits, mem_level, strategy);
502 }
504 {
505 return mz_deflateReset(pStream);
506 }
507 static int deflate(mz_streamp pStream, int flush)
508 {
509 return mz_deflate(pStream, flush);
510 }
511 static int deflateEnd(mz_streamp pStream)
512 {
513 return mz_deflateEnd(pStream);
514 }
516 {
518 }
519 static int compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
520 {
522 }
523 static int compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level)
524 {
526 }
528 {
530 }
531#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/
532
533#ifndef MINIZ_NO_INFLATE_APIS
534 /* Compatiblity with zlib API. See called functions for documentation */
535 static int inflateInit(mz_streamp pStream)
536 {
537 return mz_inflateInit(pStream);
538 }
539
541 {
543 }
544
546 {
547 return mz_inflateReset(pStream);
548 }
549
550 static int inflate(mz_streamp pStream, int flush)
551 {
552 return mz_inflate(pStream, flush);
553 }
554
555 static int inflateEnd(mz_streamp pStream)
556 {
557 return mz_inflateEnd(pStream);
558 }
559
560 static int uncompress(unsigned char* pDest, mz_ulong* pDest_len, const unsigned char* pSource, mz_ulong source_len)
561 {
563 }
564
565 static int uncompress2(unsigned char* pDest, mz_ulong* pDest_len, const unsigned char* pSource, mz_ulong* pSource_len)
566 {
568 }
569#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/
570
571 static mz_ulong crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len)
572 {
573 return mz_crc32(crc, ptr, buf_len);
574 }
575
576 static mz_ulong adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
577 {
578 return mz_adler32(adler, ptr, buf_len);
579 }
580
581#define MAX_WBITS 15
582#define MAX_MEM_LEVEL 9
583
584 static const char* zError(int err)
585 {
586 return mz_error(err);
587 }
588#define ZLIB_VERSION MZ_VERSION
589#define ZLIB_VERNUM MZ_VERNUM
590#define ZLIB_VER_MAJOR MZ_VER_MAJOR
591#define ZLIB_VER_MINOR MZ_VER_MINOR
592#define ZLIB_VER_REVISION MZ_VER_REVISION
593#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION
594
595#define zlibVersion mz_version
596#define zlib_version mz_version()
597#endif /* #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES */
598
599#endif /* MINIZ_NO_ZLIB_APIS */
600
601#ifdef __cplusplus
602}
603#endif
604
605
606
607
608#pragma once
609#include <assert.h>
610#include <stdint.h>
611#include <stdlib.h>
612#include <string.h>
613
614
615
616/* ------------------- Types and macros */
617typedef unsigned char mz_uint8;
624typedef int mz_bool;
625
626#define MZ_FALSE (0)
627#define MZ_TRUE (1)
628
629/* Works around MSVC's spammy "warning C4127: conditional expression is constant" message. */
630#ifdef _MSC_VER
631#define MZ_MACRO_END while (0, 0)
632#else
633#define MZ_MACRO_END while (0)
634#endif
635
636#ifdef MINIZ_NO_STDIO
637#define MZ_FILE void *
638#else
639#include <stdio.h>
640#define MZ_FILE FILE
641#endif /* #ifdef MINIZ_NO_STDIO */
642
643#ifdef MINIZ_NO_TIME
649#define MZ_TIME_T mz_dummy_time_t
650#else
651#define MZ_TIME_T time_t
652#endif
653
654#define MZ_ASSERT(x) assert(x)
655
656#ifdef MINIZ_NO_MALLOC
657#define MZ_MALLOC(x) NULL
658#define MZ_FREE(x) (void)x, ((void)0)
659#define MZ_REALLOC(p, x) NULL
660#else
661#define MZ_MALLOC(x) malloc(x)
662#define MZ_FREE(x) free(x)
663#define MZ_REALLOC(p, x) realloc(p, x)
664#endif
665
666#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
667#define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b))
668#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
669#define MZ_CLEAR_ARR(obj) memset((obj), 0, sizeof(obj))
670#define MZ_CLEAR_PTR(obj) memset((obj), 0, sizeof(*obj))
671
672#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
673#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
674#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
675#else
676#define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
677#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))
678#endif
679
680#define MZ_READ_LE64(p) (((mz_uint64)MZ_READ_LE32(p)) | (((mz_uint64)MZ_READ_LE32((const mz_uint8 *)(p) + sizeof(mz_uint32))) << 32U))
681
682#ifdef _MSC_VER
683#define MZ_FORCEINLINE __forceinline
684#elif defined(__GNUC__)
685#define MZ_FORCEINLINE __inline__ __attribute__((__always_inline__))
686#else
687#define MZ_FORCEINLINE inline
688#endif
689
690#ifdef __cplusplus
691extern "C"
692{
693#endif
694
695 extern MINIZ_EXPORT void *miniz_def_alloc_func(void *opaque, size_t items, size_t size);
696 extern MINIZ_EXPORT void miniz_def_free_func(void *opaque, void *address);
697 extern MINIZ_EXPORT void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size);
698
699#define MZ_UINT16_MAX (0xFFFFU)
700#define MZ_UINT32_MAX (0xFFFFFFFFU)
701
702#ifdef __cplusplus
703}
704#endif
705 #pragma once
706
707
708#ifndef MINIZ_NO_DEFLATE_APIS
709
710#ifdef __cplusplus
711extern "C"
712{
713#endif
714/* ------------------- Low-level Compression API Definitions */
715
716/* Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). */
717#ifndef TDEFL_LESS_MEMORY
718#define TDEFL_LESS_MEMORY 0
719#endif
720
721 /* tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): */
722 /* 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). */
723 enum
724 {
728 };
729
730 /* 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. */
731 /* TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). */
732 /* TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. */
733 /* TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). */
734 /* TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) */
735 /* TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. */
736 /* TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. */
737 /* TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. */
738 /* The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). */
739 enum
740 {
741 TDEFL_WRITE_ZLIB_HEADER = 0x01000,
742 TDEFL_COMPUTE_ADLER32 = 0x02000,
745 TDEFL_RLE_MATCHES = 0x10000,
746 TDEFL_FILTER_MATCHES = 0x20000,
749 };
750
751 /* High level compression functions: */
752 /* tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). */
753 /* On entry: */
754 /* pSrc_buf, src_buf_len: Pointer and size of source block to compress. */
755 /* flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. */
756 /* On return: */
757 /* Function returns a pointer to the compressed data, or NULL on failure. */
758 /* *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. */
759 /* The caller must free() the returned block when it's no longer needed. */
760 MINIZ_EXPORT void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
761
762 /* tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. */
763 /* Returns 0 on failure. */
764 MINIZ_EXPORT 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);
765
766 /* Compresses an image to a compressed PNG file in memory. */
767 /* On entry: */
768 /* pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. */
769 /* The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. */
770 /* level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL */
771 /* If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). */
772 /* On return: */
773 /* Function returns a pointer to the compressed data, or NULL on failure. */
774 /* *pLen_out will be set to the size of the PNG image file. */
775 /* The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. */
776 MINIZ_EXPORT 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);
777 MINIZ_EXPORT void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
778
779 /* Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. */
780 typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
781
782 /* tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. */
784
785 enum
786 {
791 TDEFL_LZ_DICT_SIZE = 32768,
795 };
796
797/* TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). */
798#if TDEFL_LESS_MEMORY
799 enum
800 {
801 TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024,
808 };
809#else
810enum
811{
812 TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024,
819};
820#endif
821
822 /* 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. */
823 typedef enum
824 {
829 } tdefl_status;
830
831 /* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */
832 typedef enum
833 {
834 TDEFL_NO_FLUSH = 0,
837 TDEFL_FINISH = 4
838 } tdefl_flush;
839
840 /* tdefl's compression state structure. */
841 typedef struct
842 {
844 void *m_pPut_buf_user;
852 const void *m_pIn_buf;
853 void *m_pOut_buf;
856 const mz_uint8 *m_pSrc;
867
868 /* Initializes the compressor. */
869 /* There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. */
870 /* 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. */
871 /* If pBut_buf_func is NULL the user should always call the tdefl_compress() API. */
872 /* flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) */
874
875 /* 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. */
877
878 /* tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. */
879 /* tdefl_compress_buffer() always consumes the entire input buffer. */
881
884
885 /* Create tdefl_compress() flags given zlib-style compression parameters. */
886 /* level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) */
887 /* window_bits may be -15 (raw deflate) or 15 (zlib) */
888 /* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */
890
891#ifndef MINIZ_NO_MALLOC
892 /* Allocate the tdefl_compressor structure in C so that */
893 /* non-C language bindings to tdefl_ API don't need to worry about */
894 /* structure size and allocation mechanism. */
897#endif
898
899#ifdef __cplusplus
900}
901#endif
902
903#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/
904 #pragma once
905
906/* ------------------- Low-level Decompression API Definitions */
907
908#ifndef MINIZ_NO_INFLATE_APIS
909
910#ifdef __cplusplus
911extern "C"
912{
913#endif
914 /* Decompression flags used by tinfl_decompress(). */
915 /* TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. */
916 /* 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. */
917 /* 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). */
918 /* TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. */
919 enum
920 {
925 };
926
927 /* High level decompression functions: */
928 /* tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). */
929 /* On entry: */
930 /* pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. */
931 /* On return: */
932 /* Function returns a pointer to the decompressed data, or NULL on failure. */
933 /* *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. */
934 /* The caller must call mz_free() on the returned block when it's no longer needed. */
935 MINIZ_EXPORT void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
936
937/* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */
938/* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */
939#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
940 MINIZ_EXPORT 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);
941
942 /* 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. */
943 /* Returns 1 on success or 0 on failure. */
944 typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
946
949
950#ifndef MINIZ_NO_MALLOC
951 /* Allocate the tinfl_decompressor structure in C so that */
952 /* non-C language bindings to tinfl_ API don't need to worry about */
953 /* structure size and allocation mechanism. */
956#endif
957
958/* Max size of LZ dictionary. */
959#define TINFL_LZ_DICT_SIZE 32768
960
961 /* Return status. */
962 typedef enum
963 {
964 /* 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 */
965 /* 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). */
966 /* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */
968
969 /* 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.) */
971
972 /* 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. */
974
975 /* 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. */
977
978 /* Any status code less than TINFL_STATUS_DONE must indicate a failure. */
979
980 /* 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 */
981 /* 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. */
983
984 /* 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 */
985 /* 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 */
986 /* proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. */
988
989 /* 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. */
990 /* 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 */
991 /* (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 */
992 /* so I may need to add some code to address this. */
995
996/* Initializes the decompressor to its initial state. */
997#define tinfl_init(r) \
998 do \
999 { \
1000 (r)->m_state = 0; \
1001 } \
1002 MZ_MACRO_END
1003#define tinfl_get_adler32(r) (r)->m_check_adler32
1004
1005 /* 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. */
1006 /* 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. */
1008
1009 /* Internal/private bits follow. */
1010 enum
1011 {
1019
1020#if MINIZ_HAS_64BIT_REGISTERS
1021#define TINFL_USE_64BIT_BITBUF 1
1022#else
1023#define TINFL_USE_64BIT_BITBUF 0
1024#endif
1025
1026#if TINFL_USE_64BIT_BITBUF
1027 typedef mz_uint64 tinfl_bit_buf_t;
1028#define TINFL_BITBUF_SIZE (64)
1029#else
1031#define TINFL_BITBUF_SIZE (32)
1032#endif
1033
1048
1049#ifdef __cplusplus
1050}
1051#endif
1052
1053#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/
1054
1055#pragma once
1056
1057
1058/* ------------------- ZIP archive reading/writing */
1059
1060#ifndef MINIZ_NO_ARCHIVE_APIS
1061
1062#ifdef __cplusplus
1063extern "C"
1064{
1065#endif
1066
1067 enum
1068 {
1069 /* Note: These enums can be reduced as needed to save memory or stack space - they are pretty conservative. */
1074
1075 typedef struct
1076 {
1077 /* Central directory file index. */
1079
1080 /* 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. */
1082
1083 /* These fields are copied directly from the zip's central dir. */
1088
1089 /* CRC-32 of uncompressed data. */
1091
1092 /* File's compressed size. */
1094
1095 /* 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. */
1097
1098 /* Zip internal and external file attributes. */
1101
1102 /* Entry's local header file offset in bytes. */
1104
1105 /* Size of comment in bytes. */
1107
1108 /* MZ_TRUE if the entry appears to be a directory. */
1110
1111 /* MZ_TRUE if the entry uses encryption/strong encryption (which miniz_zip doesn't support) */
1113
1114 /* MZ_TRUE if the file is not encrypted, a patch file, and if it uses a compression method we support. */
1116
1117 /* Filename. If string ends in '/' it's a subdirectory entry. */
1118 /* Guaranteed to be zero terminated, may be truncated to fit. */
1120
1121 /* Comment field. */
1122 /* Guaranteed to be zero terminated, may be truncated to fit. */
1124
1125#ifdef MINIZ_NO_TIME
1127#else
1129#endif
1131
1132 typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n);
1133 typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n);
1135
1138
1146
1147 typedef enum
1148 {
1153 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) */
1154 MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY = 0x2000, /* validate the local headers, but don't decompress the entire file and check the crc32 */
1155 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 */
1158 /*After adding a compressed file, seek back
1159 to local file header and set the correct sizes*/
1163
1174
1175 /* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */
1212
1239
1240 typedef struct
1241 {
1244
1246
1247 mz_uint64 read_buf_size, read_buf_ofs, read_buf_avail, comp_remaining, out_buf_ofs, cur_file_ofs;
1251
1253
1255
1256#ifdef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
1258#else
1260#endif
1261
1263
1264 /* -------- ZIP reading */
1265
1266 /* Inits a ZIP archive reader. */
1267 /* These functions read and validate the archive's central directory. */
1269
1270 MINIZ_EXPORT mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags);
1271
1272#ifndef MINIZ_NO_STDIO
1273 /* Read a archive from a disk file. */
1274 /* file_start_ofs is the file offset where the archive actually begins, or 0. */
1275 /* 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. */
1278
1279 /* Read an archive from an already opened FILE, beginning at the current file position. */
1280 /* 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. */
1281 /* The FILE will NOT be closed when mz_zip_reader_end() is called. */
1283#endif
1284
1285 /* Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. */
1287
1288 /* -------- ZIP reading or writing */
1289
1290 /* Clears a mz_zip_archive struct to all zeros. */
1291 /* Important: This must be done before passing the struct to any mz_zip functions. */
1293
1296
1297 /* Returns the total number of files in the archive. */
1299
1303
1304 /* Reads n bytes of raw archive data, starting at file offset file_ofs, to pBuf. */
1306
1307 /* All mz_zip funcs set the m_last_error field in the mz_zip_archive struct. These functions retrieve/manipulate this field. */
1308 /* Note that the m_last_error functionality is not thread safe. */
1314
1315 /* MZ_TRUE if the archive file entry is a directory entry. */
1317
1318 /* MZ_TRUE if the file is encrypted/strong encrypted. */
1320
1321 /* MZ_TRUE if the compression method is supported, and the file is not encrypted, and the file is not a compressed patch file. */
1323
1324 /* Retrieves the filename of an archive file entry. */
1325 /* 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. */
1327
1328 /* Attempts to locates a file in the archive's central directory. */
1329 /* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
1330 /* Returns -1 if the file cannot be found. */
1331 MINIZ_EXPORT int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
1333
1334 /* Returns detailed information about an archive file entry. */
1336
1337 /* MZ_TRUE if the file is in zip64 format. */
1338 /* 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. */
1340
1341 /* Returns the total central directory size in bytes. */
1342 /* The current max supported size is <= MZ_UINT32_MAX. */
1344
1345 /* Extracts a archive file to a memory buffer using no memory allocation. */
1346 /* There must be at least enough room on the stack to store the inflator's state (~34KB or so). */
1349
1350 /* Extracts a archive file to a memory buffer. */
1353
1354 /* Extracts a archive file to a dynamically allocated heap buffer. */
1355 /* The memory will be allocated via the mz_zip_archive's alloc/realloc functions. */
1356 /* Returns NULL and sets the last error on failure. */
1358 MINIZ_EXPORT void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
1359
1360 /* Extracts a archive file using a callback function to output the file's data. */
1363
1364 /* Extract a file iteratively */
1369
1370#ifndef MINIZ_NO_STDIO
1371 /* Extracts a archive file to a disk file and sets its last accessed and modified times. */
1372 /* This function only extracts files, not archive directory records. */
1375
1376 /* Extracts a archive file starting at the current position in the destination FILE stream. */
1379#endif
1380
1381#if 0
1382/* TODO */
1390#endif
1391
1392 /* 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. */
1393 /* It also validates that each file can be successfully uncompressed unless the MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY is specified. */
1395
1396 /* Validates an entire archive by calling mz_zip_validate_file() on each file. */
1398
1399 /* Misc utils/helpers, valid for ZIP reading or writing */
1401#ifndef MINIZ_NO_STDIO
1403#endif
1404
1405 /* Universal end function - calls either mz_zip_reader_end() or mz_zip_writer_end(). */
1407
1408 /* -------- ZIP writing */
1409
1410#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
1411
1412 /* Inits a ZIP archive writer. */
1413 /*Set pZip->m_pWrite (and pZip->m_pIO_opaque) before calling mz_zip_writer_init or mz_zip_writer_init_v2*/
1414 /*The output is streamable, i.e. file_ofs in mz_file_write_func always increases only by n*/
1417
1420
1421#ifndef MINIZ_NO_STDIO
1425#endif
1426
1427 /* Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. */
1428 /* For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. */
1429 /* For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). */
1430 /* Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. */
1431 /* Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before */
1432 /* the archive is finalized the file's central directory will be hosed. */
1435
1436 /* Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. */
1437 /* To add a directory entry, call this method with an archive name ending in a forwardslash with an empty buffer. */
1438 /* 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. */
1440
1441 /* Like mz_zip_writer_add_mem(), except you can specify a file comment field, and optionally supply the function with already compressed data. */
1442 /* uncomp_size/uncomp_crc32 are only used if the MZ_ZIP_FLAG_COMPRESSED_DATA flag is specified. */
1445
1449
1450 /* Adds the contents of a file to an archive. This function also records the disk file's modified time into the archive. */
1451 /* File data is supplied via a read callback function. User mz_zip_writer_add_(c)file to add a file directly.*/
1455
1456#ifndef MINIZ_NO_STDIO
1457 /* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */
1458 /* 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. */
1460
1461 /* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */
1465#endif
1466
1467 /* Adds a file to an archive by fully cloning the data from another archive. */
1468 /* 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. */
1470
1471 /* Finalizes the archive by writing the central directory records followed by the end of central directory record. */
1472 /* After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). */
1473 /* An archive must be manually finalized by calling this function for it to be valid. */
1475
1476 /* Finalizes a heap archive, returning a pointer to the heap block and its size. */
1477 /* The heap block will be allocated using the mz_zip_archive's alloc/realloc callbacks. */
1479
1480 /* Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. */
1481 /* Note for the archive to be valid, it *must* have been finalized before ending (this function will not do it for you). */
1483
1484 /* -------- Misc. high-level helper functions: */
1485
1486 /* mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. */
1487 /* 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). */
1488 /* 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. */
1489 /* 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. */
1492
1493#ifndef MINIZ_NO_STDIO
1494 /* Reads a single file from an archive into a heap block. */
1495 /* If pComment is not NULL, only the file with the specified comment will be extracted. */
1496 /* Returns NULL on failure. */
1497 MINIZ_EXPORT void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags);
1498 MINIZ_EXPORT 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);
1499#endif
1500
1501#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */
1502
1503#ifdef __cplusplus
1504}
1505#endif
1506
1507#endif /* MINIZ_NO_ARCHIVE_APIS */
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
ait()
Definition ai.h:565
void err(int eval, const char *fmt,...)
Definition err.c:13
static int8_t r
Definition irep_hash.h:60
const char * mz_version(void)
Definition miniz.cpp:183
unsigned long mz_ulong
Definition miniz.h:236
@ MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE
Definition miniz.h:1072
@ MZ_ZIP_MAX_IO_BUF_SIZE
Definition miniz.h:1070
@ MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE
Definition miniz.h:1071
MINIZ_EXPORT mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
Definition miniz.cpp:4036
mz_zip_flags
Definition miniz.h:1148
@ MZ_ZIP_FLAG_ASCII_FILENAME
Definition miniz.h:1157
@ MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE
Definition miniz.h:1160
@ MZ_ZIP_FLAG_WRITE_ZIP64
Definition miniz.h:1155
@ MZ_ZIP_FLAG_WRITE_ALLOW_READING
Definition miniz.h:1156
@ MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY
Definition miniz.h:1154
@ MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG
Definition miniz.h:1153
@ MZ_ZIP_FLAG_COMPRESSED_DATA
Definition miniz.h:1151
@ MZ_ZIP_FLAG_READ_ALLOW_WRITING
Definition miniz.h:1161
@ MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY
Definition miniz.h:1152
@ MZ_ZIP_FLAG_CASE_SENSITIVE
Definition miniz.h:1149
@ MZ_ZIP_FLAG_IGNORE_PATH
Definition miniz.h:1150
MINIZ_EXPORT 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)
Definition miniz.cpp:2971
MINIZ_EXPORT size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip)
Definition miniz.cpp:7834
void *(* mz_alloc_func)(void *opaque, size_t items, size_t size)
Definition miniz.h:264
MINIZ_EXPORT mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags)
Definition miniz.cpp:5375
MINIZ_EXPORT size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state *pState, void *pvBuf, size_t buf_size)
Definition miniz.cpp:5135
int16_t mz_int16
Definition miniz.h:618
size_t(* mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
Definition miniz.h:1133
MINIZ_EXPORT mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags)
Definition miniz.cpp:5590
MINIZ_EXPORT void * mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags)
Definition miniz.cpp:4738
MINIZ_EXPORT mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip)
Definition miniz.cpp:7722
MINIZ_EXPORT void tinfl_decompressor_free(tinfl_decompressor *pDecomp)
Definition miniz.cpp:3010
MINIZ_EXPORT mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip)
Definition miniz.cpp:7699
MINIZ_EXPORT size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n)
Definition miniz.cpp:7868
MINIZ_EXPORT mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr)
Definition miniz.cpp:5640
MINIZ_EXPORT mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index)
Definition miniz.cpp:4274
MINIZ_EXPORT mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
Definition miniz.cpp:41
MINIZ_EXPORT const char * mz_zip_get_error_string(mz_zip_error mz_err)
Definition miniz.cpp:7748
@ MZ_BEST_SPEED
Definition miniz.h:272
@ MZ_NO_COMPRESSION
Definition miniz.h:271
@ MZ_UBER_COMPRESSION
Definition miniz.h:274
@ MZ_DEFAULT_LEVEL
Definition miniz.h:275
@ MZ_BEST_COMPRESSION
Definition miniz.h:273
@ MZ_DEFAULT_COMPRESSION
Definition miniz.h:276
tinfl_status
Definition miniz.h:963
@ TINFL_STATUS_ADLER32_MISMATCH
Definition miniz.h:973
@ TINFL_STATUS_FAILED
Definition miniz.h:976
@ TINFL_STATUS_NEEDS_MORE_INPUT
Definition miniz.h:987
@ TINFL_STATUS_HAS_MORE_OUTPUT
Definition miniz.h:993
@ TINFL_STATUS_BAD_PARAM
Definition miniz.h:970
@ TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS
Definition miniz.h:967
@ TINFL_STATUS_DONE
Definition miniz.h:982
MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags)
Definition miniz.cpp:5335
MINIZ_EXPORT void * miniz_def_alloc_func(void *opaque, size_t items, size_t size)
Definition miniz.cpp:167
MINIZ_EXPORT void * miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size)
Definition miniz.cpp:177
MINIZ_EXPORT mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
Definition miniz.cpp:7842
MINIZ_EXPORT void * tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
Definition miniz.cpp:2924
int64_t mz_int64
Definition miniz.h:622
MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, FILE *File, mz_uint flags)
Definition miniz.cpp:5344
MINIZ_EXPORT FILE * mz_zip_get_cfile(mz_zip_archive *pZip)
Definition miniz.cpp:7861
int(* tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)
Definition miniz.h:944
MINIZ_EXPORT mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len)
Definition miniz.cpp:96
MINIZ_EXPORT mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
Definition miniz.cpp:4116
MINIZ_EXPORT mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index)
Definition miniz.cpp:4238
MINIZ_EXPORT mz_zip_type mz_zip_get_type(mz_zip_archive *pZip)
Definition miniz.cpp:7704
MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, FILE *pFile, mz_uint flags)
Definition miniz.cpp:5357
#define MZ_FILE
Definition miniz.h:640
MINIZ_EXPORT mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state *pState)
Definition miniz.cpp:5252
MINIZ_EXPORT 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)
Definition miniz.cpp:4121
MINIZ_EXPORT void * mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags)
Definition miniz.cpp:4774
MINIZ_EXPORT mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
Definition miniz.cpp:7897
MINIZ_EXPORT mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr)
Definition miniz.cpp:5682
MINIZ_EXPORT 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)
Definition miniz.cpp:4715
size_t(* mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
Definition miniz.h:1132
#define MZ_TIME_T
Definition miniz.h:649
int mz_bool
Definition miniz.h:624
MINIZ_EXPORT void mz_zip_zero_struct(mz_zip_archive *pZip)
Definition miniz.cpp:3983
unsigned char mz_uint8
Definition miniz.h:617
MINIZ_EXPORT mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index)
Definition miniz.cpp:4224
MINIZ_EXPORT 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)
Definition miniz.cpp:2962
MINIZ_EXPORT void miniz_def_free_func(void *opaque, void *address)
Definition miniz.cpp:172
mz_zip_type
Definition miniz.h:1165
@ MZ_ZIP_TYPE_USER
Definition miniz.h:1167
@ MZ_ZIP_TYPE_FILE
Definition miniz.h:1170
@ MZ_ZIP_TYPE_HEAP
Definition miniz.h:1169
@ MZ_ZIP_TOTAL_TYPES
Definition miniz.h:1172
@ MZ_ZIP_TYPE_MEMORY
Definition miniz.h:1168
@ MZ_ZIP_TYPE_CFILE
Definition miniz.h:1171
@ MZ_ZIP_TYPE_INVALID
Definition miniz.h:1166
MINIZ_EXPORT mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index)
Definition miniz.cpp:4503
MINIZ_EXPORT mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip)
Definition miniz.cpp:7847
MINIZ_EXPORT 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)
Definition miniz.cpp:4728
MINIZ_EXPORT mz_zip_reader_extract_iter_state * mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags)
Definition miniz.cpp:5123
MINIZ_EXPORT void mz_free(void *p)
Definition miniz.cpp:162
@ MZ_FILTERED
Definition miniz.h:253
@ MZ_FIXED
Definition miniz.h:256
@ MZ_DEFAULT_STRATEGY
Definition miniz.h:252
@ MZ_RLE
Definition miniz.h:255
@ MZ_HUFFMAN_ONLY
Definition miniz.h:254
uint32_t mz_uint
Definition miniz.h:621
MINIZ_EXPORT 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)
Definition miniz.cpp:4720
struct mz_dummy_time_t_tag mz_dummy_time_t
void *(* mz_realloc_func)(void *opaque, void *address, size_t items, size_t size)
Definition miniz.h:266
MINIZ_EXPORT mz_bool mz_zip_end(mz_zip_archive *pZip)
Definition miniz.cpp:7902
@ TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF
Definition miniz.h:923
@ TINFL_FLAG_HAS_MORE_INPUT
Definition miniz.h:922
@ TINFL_FLAG_COMPUTE_ADLER32
Definition miniz.h:924
@ TINFL_FLAG_PARSE_ZLIB_HEADER
Definition miniz.h:921
MINIZ_EXPORT mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip)
Definition miniz.cpp:7735
MINIZ_EXPORT 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)
Definition miniz.cpp:4786
MINIZ_EXPORT mz_bool mz_zip_is_zip64(mz_zip_archive *pZip)
Definition miniz.cpp:7826
void(* mz_free_func)(void *opaque, void *address)
Definition miniz.h:265
@ TINFL_MAX_HUFF_SYMBOLS_2
Definition miniz.h:1015
@ TINFL_FAST_LOOKUP_SIZE
Definition miniz.h:1017
@ TINFL_MAX_HUFF_SYMBOLS_0
Definition miniz.h:1013
@ TINFL_MAX_HUFF_SYMBOLS_1
Definition miniz.h:1014
@ TINFL_MAX_HUFF_TABLES
Definition miniz.h:1012
@ TINFL_FAST_LOOKUP_BITS
Definition miniz.h:1016
uint32_t mz_uint32
Definition miniz.h:620
MINIZ_EXPORT mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
Definition miniz.cpp:7876
MINIZ_EXPORT mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip)
Definition miniz.cpp:7854
MINIZ_EXPORT tinfl_decompressor * tinfl_decompressor_alloc(void)
Definition miniz.cpp:3002
MINIZ_EXPORT 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)
Definition miniz.cpp:2431
uint64_t mz_uint64
Definition miniz.h:623
mz_bool(* mz_file_needs_keepalive)(void *pOpaque)
Definition miniz.h:1134
uint16_t mz_uint16
Definition miniz.h:619
mz_zip_mode
Definition miniz.h:1140
@ MZ_ZIP_MODE_WRITING
Definition miniz.h:1143
@ MZ_ZIP_MODE_READING
Definition miniz.h:1142
@ MZ_ZIP_MODE_INVALID
Definition miniz.h:1141
@ MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED
Definition miniz.h:1144
MINIZ_EXPORT mz_zip_reader_extract_iter_state * mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags)
Definition miniz.cpp:4995
MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
Definition miniz.cpp:5301
MINIZ_EXPORT int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
Definition miniz.cpp:4494
MINIZ_EXPORT mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, FILE *pFile, mz_uint64 archive_size, mz_uint flags)
Definition miniz.cpp:4175
mz_zip_error
Definition miniz.h:1177
@ MZ_ZIP_UNSUPPORTED_METHOD
Definition miniz.h:1182
@ MZ_ZIP_UNSUPPORTED_FEATURE
Definition miniz.h:1184
@ MZ_ZIP_FILE_OPEN_FAILED
Definition miniz.h:1195
@ MZ_ZIP_FILE_TOO_LARGE
Definition miniz.h:1181
@ MZ_ZIP_WRITE_CALLBACK_FAILED
Definition miniz.h:1209
@ MZ_ZIP_CRC_CHECK_FAILED
Definition miniz.h:1192
@ MZ_ZIP_INTERNAL_ERROR
Definition miniz.h:1205
@ MZ_ZIP_FILE_CLOSE_FAILED
Definition miniz.h:1199
@ MZ_ZIP_FILE_CREATE_FAILED
Definition miniz.h:1196
@ MZ_ZIP_BUF_TOO_SMALL
Definition miniz.h:1204
@ MZ_ZIP_VALIDATION_FAILED
Definition miniz.h:1208
@ MZ_ZIP_FILE_STAT_FAILED
Definition miniz.h:1201
@ MZ_ZIP_INVALID_FILENAME
Definition miniz.h:1203
@ MZ_ZIP_COMPRESSION_FAILED
Definition miniz.h:1190
@ MZ_ZIP_NO_ERROR
Definition miniz.h:1178
@ MZ_ZIP_UNSUPPORTED_ENCRYPTION
Definition miniz.h:1183
@ MZ_ZIP_TOO_MANY_FILES
Definition miniz.h:1180
@ MZ_ZIP_UNDEFINED_ERROR
Definition miniz.h:1179
@ MZ_ZIP_UNSUPPORTED_MULTIDISK
Definition miniz.h:1188
@ MZ_ZIP_ALLOC_FAILED
Definition miniz.h:1194
@ MZ_ZIP_ARCHIVE_TOO_LARGE
Definition miniz.h:1207
@ MZ_ZIP_DECOMPRESSION_FAILED
Definition miniz.h:1189
@ MZ_ZIP_FILE_WRITE_FAILED
Definition miniz.h:1197
@ MZ_ZIP_INVALID_PARAMETER
Definition miniz.h:1202
@ MZ_ZIP_INVALID_HEADER_OR_CORRUPTED
Definition miniz.h:1187
@ MZ_ZIP_UNSUPPORTED_CDIR_SIZE
Definition miniz.h:1193
@ MZ_ZIP_FILE_READ_FAILED
Definition miniz.h:1198
@ MZ_ZIP_FILE_NOT_FOUND
Definition miniz.h:1206
@ MZ_ZIP_FAILED_FINDING_CENTRAL_DIR
Definition miniz.h:1185
@ MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE
Definition miniz.h:1191
@ MZ_ZIP_NOT_AN_ARCHIVE
Definition miniz.h:1186
@ MZ_ZIP_TOTAL_ERRORS
Definition miniz.h:1210
@ MZ_ZIP_FILE_SEEK_FAILED
Definition miniz.h:1200
MINIZ_EXPORT mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip)
Definition miniz.cpp:7730
MINIZ_EXPORT mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags)
Definition miniz.cpp:4040
MINIZ_EXPORT mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num)
Definition miniz.cpp:7709
MINIZ_EXPORT 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)
Definition miniz.cpp:4733
mz_uint32 tinfl_bit_buf_t
Definition miniz.h:1030
MINIZ_EXPORT mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags)
Definition miniz.cpp:4068
MINIZ_EXPORT 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)
Definition miniz.cpp:4986
mz_uint32 m_dummy1
Definition miniz.h:646
mz_uint32 m_dummy2
Definition miniz.h:647
mz_uint32 m_external_attr
Definition miniz.h:1100
mz_uint16 m_version_needed
Definition miniz.h:1085
mz_uint16 m_version_made_by
Definition miniz.h:1084
mz_dummy_time_t m_padding
Definition miniz.h:1126
mz_uint64 m_central_dir_ofs
Definition miniz.h:1081
mz_uint64 m_uncomp_size
Definition miniz.h:1096
mz_uint32 m_comment_size
Definition miniz.h:1106
mz_uint64 m_local_header_ofs
Definition miniz.h:1103
mz_uint16 m_internal_attr
Definition miniz.h:1099
mz_uint64 m_central_directory_file_ofs
Definition miniz.h:1216
mz_zip_error m_last_error
Definition miniz.h:1222
mz_alloc_func m_pAlloc
Definition miniz.h:1226
mz_zip_mode m_zip_mode
Definition miniz.h:1220
mz_uint64 m_archive_size
Definition miniz.h:1215
void * m_pIO_opaque
Definition miniz.h:1234
void * m_pAlloc_opaque
Definition miniz.h:1229
mz_file_needs_keepalive m_pNeeds_keepalive
Definition miniz.h:1233
mz_file_write_func m_pWrite
Definition miniz.h:1232
mz_zip_internal_state * m_pState
Definition miniz.h:1236
mz_free_func m_pFree
Definition miniz.h:1227
mz_realloc_func m_pRealloc
Definition miniz.h:1228
mz_file_read_func m_pRead
Definition miniz.h:1231
mz_uint64 m_file_offset_alignment
Definition miniz.h:1224
mz_zip_type m_zip_type
Definition miniz.h:1221
mz_uint32 m_total_files
Definition miniz.h:1219
tinfl_decompressor inflator
Definition miniz.h:1254
mz_zip_archive_file_stat file_stat
Definition miniz.h:1248
mz_uint8 m_code_size_0[TINFL_MAX_HUFF_SYMBOLS_0]
Definition miniz.h:1043
tinfl_bit_buf_t m_bit_buf
Definition miniz.h:1037
mz_uint32 m_counter
Definition miniz.h:1036
size_t m_dist_from_out_buf_start
Definition miniz.h:1038
mz_uint32 m_check_adler32
Definition miniz.h:1036
mz_int16 m_tree_0[TINFL_MAX_HUFF_SYMBOLS_0 *2]
Definition miniz.h:1040
mz_int16 m_tree_1[TINFL_MAX_HUFF_SYMBOLS_1 *2]
Definition miniz.h:1041
mz_uint8 m_raw_header[4]
Definition miniz.h:1046
mz_uint32 m_num_bits
Definition miniz.h:1036
mz_int16 m_look_up[TINFL_MAX_HUFF_TABLES][TINFL_FAST_LOOKUP_SIZE]
Definition miniz.h:1039
mz_int16 m_tree_2[TINFL_MAX_HUFF_SYMBOLS_2 *2]
Definition miniz.h:1042
mz_uint32 m_z_adler32
Definition miniz.h:1036
mz_uint32 m_table_sizes[TINFL_MAX_HUFF_TABLES]
Definition miniz.h:1036
mz_uint8 m_code_size_2[TINFL_MAX_HUFF_SYMBOLS_2]
Definition miniz.h:1045
mz_uint8 m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0+TINFL_MAX_HUFF_SYMBOLS_1+137]
Definition miniz.h:1046
mz_uint32 m_num_extra
Definition miniz.h:1036
mz_uint8 m_code_size_1[TINFL_MAX_HUFF_SYMBOLS_1]
Definition miniz.h:1044