194#ifndef MINIZ_HEADER_INCLUDED
195#define MINIZ_HEADER_INCLUDED
228#if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
230 #define MINIZ_NO_TIME
233#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
237#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
239#define MINIZ_X86_OR_X64_CPU 1
242#if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU
244#define MINIZ_LITTLE_ENDIAN 1
247#if MINIZ_X86_OR_X64_CPU
249#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
252#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
254#define MINIZ_HAS_64BIT_REGISTERS 1
258#define ftello64 ftello
259#define fseeko64 fseeko
261#define freopen64 freopen
277#define MZ_ADLER32_INIT (1)
281#define MZ_CRC32_INIT (0)
291#ifndef MINIZ_NO_ZLIB_APIS
295typedef void *(*mz_alloc_func)(
void *opaque,
size_t items,
size_t size);
297typedef void *(*mz_realloc_func)(
void *opaque,
void *address,
size_t items,
size_t size);
299#define MZ_VERSION "9.1.15"
300#define MZ_VERNUM 0x91F0
301#define MZ_VER_MAJOR 9
302#define MZ_VER_MINOR 1
303#define MZ_VER_REVISION 15
304#define MZ_VER_SUBREVISION 0
316#define MZ_DEFAULT_WINDOW_BITS 15
318struct mz_internal_state;
435#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
448 #define Z_NO_FLUSH MZ_NO_FLUSH
449 #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
450 #define Z_SYNC_FLUSH MZ_SYNC_FLUSH
451 #define Z_FULL_FLUSH MZ_FULL_FLUSH
452 #define Z_FINISH MZ_FINISH
453 #define Z_BLOCK MZ_BLOCK
455 #define Z_STREAM_END MZ_STREAM_END
456 #define Z_NEED_DICT MZ_NEED_DICT
457 #define Z_ERRNO MZ_ERRNO
458 #define Z_STREAM_ERROR MZ_STREAM_ERROR
459 #define Z_DATA_ERROR MZ_DATA_ERROR
460 #define Z_MEM_ERROR MZ_MEM_ERROR
461 #define Z_BUF_ERROR MZ_BUF_ERROR
462 #define Z_VERSION_ERROR MZ_VERSION_ERROR
463 #define Z_PARAM_ERROR MZ_PARAM_ERROR
464 #define Z_NO_COMPRESSION MZ_NO_COMPRESSION
465 #define Z_BEST_SPEED MZ_BEST_SPEED
466 #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION
467 #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
468 #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY
469 #define Z_FILTERED MZ_FILTERED
470 #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY
472 #define Z_FIXED MZ_FIXED
473 #define Z_DEFLATED MZ_DEFLATED
474 #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
475 #define alloc_func mz_alloc_func
476 #define free_func mz_free_func
477 #define internal_state mz_internal_state
478 #define z_stream mz_stream
479 #define deflateInit mz_deflateInit
480 #define deflateInit2 mz_deflateInit2
481 #define deflateReset mz_deflateReset
482 #define deflate mz_deflate
483 #define deflateEnd mz_deflateEnd
484 #define deflateBound mz_deflateBound
485 #define compress mz_compress
486 #define compress2 mz_compress2
487 #define compressBound mz_compressBound
488 #define inflateInit mz_inflateInit
489 #define inflateInit2 mz_inflateInit2
490 #define inflate mz_inflate
491 #define inflateEnd mz_inflateEnd
492 #define uncompress mz_uncompress
493 #define crc32 mz_crc32
494 #define adler32 mz_adler32
496 #define MAX_MEM_LEVEL 9
497 #define zError mz_error
498 #define ZLIB_VERSION MZ_VERSION
499 #define ZLIB_VERNUM MZ_VERNUM
500 #define ZLIB_VER_MAJOR MZ_VER_MAJOR
501 #define ZLIB_VER_MINOR MZ_VER_MINOR
502 #define ZLIB_VER_REVISION MZ_VER_REVISION
503 #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION
504 #define zlibVersion mz_version
505 #define zlib_version mz_version()
526 #define MZ_MACRO_END while (0, 0)
528 #define MZ_MACRO_END while (0)
533#ifndef MINIZ_NO_ARCHIVE_APIS
615#ifndef MINIZ_NO_STDIO
654#ifndef MINIZ_NO_STDIO
666#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
672#ifndef MINIZ_NO_STDIO
690#ifndef MINIZ_NO_STDIO
751#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
762#define TINFL_LZ_DICT_SIZE 32768
776#define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END
777#define tinfl_get_adler32(r) (r)->m_check_adler32
796#if MINIZ_HAS_64BIT_REGISTERS
797 #define TINFL_USE_64BIT_BITBUF 1
800#if TINFL_USE_64BIT_BITBUF
802 #define TINFL_BITBUF_SIZE (64)
805 #define TINFL_BITBUF_SIZE (32)
810 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];
820#define TDEFL_LESS_MEMORY 0
863size_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);
957#ifndef MINIZ_NO_ZLIB_APIS
973#ifndef MINIZ_HEADER_FILE_ONLY
982#define MZ_ASSERT(x) assert(x)
984#ifdef MINIZ_NO_MALLOC
985 #define MZ_MALLOC(x) NULL
986 #define MZ_FREE(x) (void)x, ((void)0)
987 #define MZ_REALLOC(p, x) NULL
989 #define MZ_MALLOC(x) malloc(x)
990 #define MZ_FREE(x) free(x)
991 #define MZ_REALLOC(p, x) realloc(p, x)
994#define MZ_MAX(a,b) (((a)>(b))?(a):(b))
995#define MZ_MIN(a,b) (((a)<(b))?(a):(b))
996#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
998#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
999 #define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
1000 #define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
1002 #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
1003 #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))
1007 #define MZ_FORCEINLINE __forceinline
1008#elif defined(__GNUC__)
1009 #define MZ_FORCEINLINE inline __attribute__((__always_inline__))
1011 #define MZ_FORCEINLINE inline
1025 for (i = 0; i + 7 < block_len; i += 8, ptr += 8) {
1026 s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1;
1027 s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1;
1029 for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1;
1030 s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552;
1032 return (s2 << 16) + s1;
1038 static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
1039 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c };
1042 crcu32 = ~crcu32;
while (buf_len--) {
mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; }
1051#ifndef MINIZ_NO_ZLIB_APIS
1053static void *def_alloc_func(
void *opaque,
size_t items,
size_t size) { (void)opaque, (
void)items, (void)
size;
return MZ_MALLOC(items *
size); }
1054static void def_free_func(
void *opaque,
void *address) { (void)opaque, (
void)address;
MZ_FREE(address); }
1055static void *def_realloc_func(
void *opaque,
void *address,
size_t items,
size_t size) { (void)opaque, (
void)address, (void)items, (
void)
size;
return MZ_REALLOC(address, items *
size); }
1077 pStream->
msg = NULL;
1081 if (!pStream->
zalloc) pStream->
zalloc = def_alloc_func;
1082 if (!pStream->
zfree) pStream->
zfree = def_free_func;
1088 pStream->
state = (
struct mz_internal_state *)pComp;
1109 size_t in_bytes, out_bytes;
1110 mz_ulong orig_total_in, orig_total_out;
1111 int mz_status =
MZ_OK;
1134 if (defl_status < 0)
1148 if ((flush) || (pStream->
total_in != orig_total_in) || (pStream->
total_out != orig_total_out))
1162 pStream->
state = NULL;
1171 return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);
1178 memset(&stream, 0,
sizeof(stream));
1181 if ((source_len | *pDest_len) > 0xFFFFFFFFU)
return MZ_PARAM_ERROR;
1189 if (status !=
MZ_OK)
return status;
1228 pStream->
msg = NULL;
1232 if (!pStream->
zalloc) pStream->
zalloc = def_alloc_func;
1233 if (!pStream->
zfree) pStream->
zfree = def_free_func;
1238 pStream->
state = (
struct mz_internal_state *)pDecomp;
1260 size_t in_bytes, out_bytes, orig_avail_in;
1277 if ((flush ==
MZ_FINISH) && (first_call))
1354 pStream->
state = NULL;
1363 memset(&stream, 0,
sizeof(stream));
1366 if ((source_len | *pDest_len) > 0xFFFFFFFFU)
return MZ_PARAM_ERROR;
1374 if (status !=
MZ_OK)
1390 static struct {
int m_err;
const char *m_pDesc; } s_error_descs[] =
1392 {
MZ_OK,
"" }, {
MZ_STREAM_END,
"stream end" }, {
MZ_NEED_DICT,
"need dictionary" }, {
MZ_ERRNO,
"file error" }, {
MZ_STREAM_ERROR,
"stream error" },
1395 mz_uint i;
for (i = 0; i <
sizeof(s_error_descs) /
sizeof(s_error_descs[0]); ++i)
if (s_error_descs[i].m_err == err)
return s_error_descs[i].m_pDesc;
1403#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l)
1404#define TINFL_MEMSET(p, c, l) memset(p, c, l)
1406#define TINFL_CR_BEGIN switch(r->m_state) { case 0:
1407#define TINFL_CR_RETURN(state_index, result) do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END
1408#define TINFL_CR_RETURN_FOREVER(state_index, result) do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END
1409#define TINFL_CR_FINISH }
1413#define TINFL_GET_BYTE(state_index, c) do { \
1414 if (pIn_buf_cur >= pIn_buf_end) { \
1416 if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { \
1417 TINFL_CR_RETURN(state_index, TINFL_STATUS_NEEDS_MORE_INPUT); \
1418 if (pIn_buf_cur < pIn_buf_end) { \
1419 c = *pIn_buf_cur++; \
1427 } else c = *pIn_buf_cur++; } MZ_MACRO_END
1429#define TINFL_NEED_BITS(state_index, n) do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n))
1430#define TINFL_SKIP_BITS(state_index, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END
1431#define TINFL_GET_BITS(state_index, b, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END
1437#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \
1439 temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \
1441 code_len = temp >> 9; \
1442 if ((code_len) && (num_bits >= code_len)) \
1444 } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \
1445 code_len = TINFL_FAST_LOOKUP_BITS; \
1447 temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
1448 } while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \
1449 } TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \
1450 } while (num_bits < 15);
1456#define TINFL_HUFF_DECODE(state_index, sym, pHuff) do { \
1457 int temp; mz_uint code_len, c; \
1458 if (num_bits < 15) { \
1459 if ((pIn_buf_end - pIn_buf_cur) < 2) { \
1460 TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \
1462 bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; \
1465 if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \
1466 code_len = temp >> 9, temp &= 511; \
1468 code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \
1469 } sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END
1472#pragma warning(push)
1473#pragma warning(disable : 4334)
1478 static const int s_length_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 };
1479 static const int s_length_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 };
1480 static const int s_dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0};
1481 static const int s_dist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
1482 static const mz_uint8 s_length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
1483 static const int s_min_table_sizes[3] = { 257, 1, 4 };
1486 const mz_uint8 *pIn_buf_cur = pIn_buf_next, *
const pIn_buf_end = pIn_buf_next + *pIn_buf_size;
1487 mz_uint8 *pOut_buf_cur = pOut_buf_next, *
const pOut_buf_end = pOut_buf_next + *pOut_buf_size;
1491 if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) { *pIn_buf_size = *pOut_buf_size = 0;
return TINFL_STATUS_BAD_PARAM; }
1513 while ((counter) && (num_bits))
1523 while (pIn_buf_cur >= pIn_buf_end)
1534 n =
MZ_MIN(
MZ_MIN((
size_t)(pOut_buf_end - pOut_buf_cur), (
size_t)(pIn_buf_end - pIn_buf_cur)), counter);
1535 TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (
mz_uint)n;
1548 for ( i = 0; i <= 143; ++i) *p++ = 8;
for ( ; i <= 255; ++i) *p++ = 9;
for ( ; i <= 279; ++i) *p++ = 7;
for ( ; i <= 287; ++i) *p++ = 8;
1561 used_syms = 0, total = 0; next_code[0] = next_code[1] = 0;
1562 for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); }
1563 if ((65536 != total) && (used_syms > 1))
1569 mz_uint rev_code = 0, l, cur_code, code_size = pTable->
m_code_size[sym_index];
if (!code_size)
continue;
1570 cur_code = next_code[code_size]++;
for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1);
1576 tree_cur -= ((rev_code >>= 1) & 1);
1577 if (!pTable->
m_tree[-tree_cur - 1]) { pTable->
m_tree[-tree_cur - 1] = (
mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; }
else tree_cur = pTable->
m_tree[-tree_cur - 1];
1579 tree_cur -= ((rev_code >>= 1) & 1); pTable->
m_tree[-tree_cur - 1] = (
mz_int16)sym_index;
1586 if ((dist == 16) && (!counter))
1590 num_extra =
"\02\03\07"[dist - 16];
TINFL_GET_BITS(18, s, num_extra); s +=
"\03\03\013"[dist - 16];
1605 if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2))
1611 *pOut_buf_cur++ = (
mz_uint8)counter;
1616#if TINFL_USE_64BIT_BITBUF
1622 code_len = sym2 >> 9;
1627 counter = sym2; bit_buf >>= code_len; num_bits -= code_len;
1631#if !TINFL_USE_64BIT_BITBUF
1635 code_len = sym2 >> 9;
1640 bit_buf >>= code_len; num_bits -= code_len;
1642 pOut_buf_cur[0] = (
mz_uint8)counter;
1653 if ((counter &= 511) == 256)
break;
1655 num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257];
1656 if (num_extra) {
mz_uint extra_bits;
TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; }
1659 num_extra = s_dist_extra[dist]; dist = s_dist_base[dist];
1660 if (num_extra) {
mz_uint extra_bits;
TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; }
1662 dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;
1668 pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask);
1670 if ((
MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end)
1675 *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask];
1679#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
1680 else if ((counter >= 9) && (counter <= dist))
1682 const mz_uint8 *pSrc_end = pSrc + (counter & ~7);
1688 }
while ((pSrc += 8) < pSrc_end);
1689 if ((counter &= 7) < 3)
1693 pOut_buf_cur[0] = pSrc[0];
1695 pOut_buf_cur[1] = pSrc[1];
1696 pOut_buf_cur += counter;
1704 pOut_buf_cur[0] = pSrc[0];
1705 pOut_buf_cur[1] = pSrc[1];
1706 pOut_buf_cur[2] = pSrc[2];
1707 pOut_buf_cur += 3; pSrc += 3;
1708 }
while ((
int)(counter -= 3) > 2);
1709 if ((
int)counter > 0)
1711 pOut_buf_cur[0] = pSrc[0];
1712 if ((
int)counter > 1)
1713 pOut_buf_cur[1] = pSrc[1];
1714 pOut_buf_cur += counter;
1728 *pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next;
1731 const mz_uint8 *ptr = pOut_buf_next;
size_t buf_len = *pOut_buf_size;
1735 for (i = 0; i + 7 < block_len; i += 8, ptr += 8)
1737 s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1;
1738 s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1;
1740 for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1;
1741 s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552;
1755 tinfl_decompressor decomp;
void *pBuf = NULL, *pNew_buf;
size_t src_buf_ofs = 0, out_buf_capacity = 0;
1760 size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;
1765 MZ_FREE(pBuf); *pOut_len = 0;
return NULL;
1767 src_buf_ofs += src_buf_size;
1768 *pOut_len += dst_buf_size;
1770 new_out_buf_capacity = out_buf_capacity * 2;
if (new_out_buf_capacity < 128) new_out_buf_capacity = 128;
1771 pNew_buf =
MZ_REALLOC(pBuf, new_out_buf_capacity);
1774 MZ_FREE(pBuf); *pOut_len = 0;
return NULL;
1776 pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity;
1798 size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size =
TINFL_LZ_DICT_SIZE - dict_ofs;
1801 in_buf_ofs += in_buf_size;
1802 if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (
int)dst_buf_size, pPut_buf_user)))
1812 *pIn_buf_size = in_buf_ofs;
1819static const mz_uint16 s_tdefl_len_sym[256] = {
1820 257,258,259,260,261,262,263,264,265,265,266,266,267,267,268,268,269,269,269,269,270,270,270,270,271,271,271,271,272,272,272,272,
1821 273,273,273,273,273,273,273,273,274,274,274,274,274,274,274,274,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276,276,
1822 277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
1823 279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,
1824 281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,
1825 282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,
1826 283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,
1827 284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,285 };
1829static const mz_uint8 s_tdefl_len_extra[256] = {
1830 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
1831 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
1832 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
1833 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0 };
1835static const mz_uint8 s_tdefl_small_dist_sym[512] = {
1836 0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,
1837 11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,
1838 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,
1839 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
1840 14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
1841 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,
1842 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1843 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
1844 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
1845 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
1846 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
1847 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17 };
1849static const mz_uint8 s_tdefl_small_dist_extra[512] = {
1850 0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,
1851 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
1852 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
1853 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
1854 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
1855 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
1856 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
1859static const mz_uint8 s_tdefl_large_dist_sym[128] = {
1860 0,0,18,19,20,20,21,21,22,22,22,22,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,
1861 26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
1862 28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29 };
1864static const mz_uint8 s_tdefl_large_dist_extra[128] = {
1865 0,0,8,8,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
1866 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
1867 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13 };
1874 for (i = 0; i < num_syms; i++) {
mz_uint freq = pSyms0[i].
m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; }
1875 while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--;
1876 for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8)
1878 const mz_uint32* pHist = &hist[pass << 8];
1879 mz_uint offsets[256], cur_ofs = 0;
1880 for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; }
1881 for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i];
1882 {
tdefl_sym_freq* t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; }
1888static void tdefl_calculate_minimum_redundancy(
tdefl_sym_freq *
A,
int n)
1890 int root, leaf, next, avbl, used, dpth;
1891 if (n==0)
return;
else if (n==1) {
A[0].m_key = 1;
return; }
1892 A[0].m_key +=
A[1].m_key; root = 0; leaf = 2;
1893 for (next=1; next < n-1; next++)
1895 if (leaf>=n ||
A[root].m_key<
A[leaf].m_key) {
A[next].m_key =
A[root].m_key;
A[root++].m_key = (
mz_uint16)next; }
else A[next].m_key =
A[leaf++].m_key;
1896 if (leaf>=n || (root<next &&
A[root].m_key<
A[leaf].m_key)) {
A[next].m_key = (
mz_uint16)(
A[next].m_key +
A[root].m_key);
A[root++].m_key = (
mz_uint16)next; }
else A[next].m_key = (
mz_uint16)(
A[next].m_key +
A[leaf++].m_key);
1898 A[n-2].m_key = 0;
for (next=n-3; next>=0; next--)
A[next].m_key =
A[
A[next].m_key].m_key+1;
1899 avbl = 1; used = dpth = 0; root = n-2; next = n-1;
1902 while (root>=0 && (
int)
A[root].m_key==dpth) { used++; root--; }
1903 while (avbl>used) {
A[next--].m_key = (
mz_uint16)(dpth); avbl--; }
1904 avbl = 2*used; dpth++; used = 0;
1910static void tdefl_huffman_enforce_max_code_size(
int *pNum_codes,
int code_list_len,
int max_code_size)
1912 int i;
mz_uint32 total = 0;
if (code_list_len <= 1)
return;
1914 for (i = max_code_size; i > 0; i--) total += (((
mz_uint32)pNum_codes[i]) << (max_code_size - i));
1915 while (total != (1UL << max_code_size))
1917 pNum_codes[max_code_size]--;
1918 for (i = max_code_size - 1; i > 0; i--)
if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2;
break; }
1923static void tdefl_optimize_huffman_table(
tdefl_compressor *
d,
int table_num,
int table_len,
int code_size_limit,
int static_table)
1928 for (i = 0; i < table_len; i++) num_codes[
d->m_huff_code_sizes[table_num][i]]++;
1933 int num_used_syms = 0;
1934 const mz_uint16 *pSym_count = &
d->m_huff_count[table_num][0];
1937 pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); tdefl_calculate_minimum_redundancy(pSyms, num_used_syms);
1939 for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++;
1941 tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit);
1944 for (i = 1, j = num_used_syms; i <= code_size_limit; i++)
1945 for (l = num_codes[i]; l > 0; l--)
d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (
mz_uint8)(i);
1948 next_code[1] = 0;
for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1);
1950 for (i = 0; i < table_len; i++)
1952 mz_uint rev_code = 0,
code, code_size;
if ((code_size =
d->m_huff_code_sizes[table_num][i]) == 0)
continue;
1953 code = next_code[code_size]++;
for (l = code_size; l > 0; l--,
code >>= 1) rev_code = (rev_code << 1) | (
code & 1);
1954 d->m_huff_codes[table_num][i] = (
mz_uint16)rev_code;
1958#define TDEFL_PUT_BITS(b, l) do { \
1959 mz_uint bits = b; mz_uint len = l; MZ_ASSERT(bits <= ((1U << len) - 1U)); \
1960 d->m_bit_buffer |= (bits << d->m_bits_in); d->m_bits_in += len; \
1961 while (d->m_bits_in >= 8) { \
1962 if (d->m_pOutput_buf < d->m_pOutput_buf_end) \
1963 *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \
1964 d->m_bit_buffer >>= 8; \
1965 d->m_bits_in -= 8; \
1969#define TDEFL_RLE_PREV_CODE_SIZE() { if (rle_repeat_count) { \
1970 if (rle_repeat_count < 3) { \
1971 d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \
1972 while (rle_repeat_count--) packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \
1974 d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); packed_code_sizes[num_packed_code_sizes++] = 16; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \
1975} rle_repeat_count = 0; } }
1977#define TDEFL_RLE_ZERO_CODE_SIZE() { if (rle_z_count) { \
1978 if (rle_z_count < 3) { \
1979 d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \
1980 } else if (rle_z_count <= 10) { \
1981 d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); packed_code_sizes[num_packed_code_sizes++] = 17; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \
1983 d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); packed_code_sizes[num_packed_code_sizes++] = 18; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \
1984} rle_z_count = 0; } }
1986static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
1990 int num_lit_codes, num_dist_codes, num_bit_lengths;
mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index;
1993 d->m_huff_count[0][256] = 1;
1998 for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--)
if (
d->m_huff_code_sizes[0][num_lit_codes - 1])
break;
1999 for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--)
if (
d->m_huff_code_sizes[1][num_dist_codes - 1])
break;
2001 memcpy(code_sizes_to_pack, &
d->m_huff_code_sizes[0][0], num_lit_codes);
2002 memcpy(code_sizes_to_pack + num_lit_codes, &
d->m_huff_code_sizes[1][0], num_dist_codes);
2003 total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0;
2006 for (i = 0; i < total_code_sizes_to_pack; i++)
2008 mz_uint8 code_size = code_sizes_to_pack[i];
2017 if (code_size != prev_code_size)
2020 d->m_huff_count[2][code_size] = (
mz_uint16)(
d->m_huff_count[2][code_size] + 1); packed_code_sizes[num_packed_code_sizes++] = code_size;
2022 else if (++rle_repeat_count == 6)
2027 prev_code_size = code_size;
2038 for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--)
if (
d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]])
break;
2040 for (i = 0; (int)i < num_bit_lengths; i++)
TDEFL_PUT_BITS(
d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3);
2042 for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes; )
2053 mz_uint8 *p = &
d->m_huff_code_sizes[0][0];
2055 for (i = 0; i <= 143; ++i) *p++ = 8;
2056 for ( ; i <= 255; ++i) *p++ = 9;
2057 for ( ; i <= 279; ++i) *p++ = 7;
2058 for ( ; i <= 287; ++i) *p++ = 8;
2060 memset(
d->m_huff_code_sizes[1], 5, 32);
2062 tdefl_optimize_huffman_table(
d, 0, 288, 15,
MZ_TRUE);
2063 tdefl_optimize_huffman_table(
d, 1, 32, 15,
MZ_TRUE);
2068static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
2070#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS
2075 mz_uint8 *pOutput_buf =
d->m_pOutput_buf;
2076 mz_uint8 *pLZ_code_buf_end =
d->m_pLZ_code_buf;
2080#define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); }
2083 for (pLZ_codes =
d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1)
2086 flags = *pLZ_codes++ | 0x100;
2090 mz_uint s0, s1, n0, n1, sym, num_extra_bits;
2091 mz_uint match_len = pLZ_codes[0], match_dist = *(
const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3;
2093 MZ_ASSERT(
d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
2094 TDEFL_PUT_BITS_FAST(
d->m_huff_codes[0][s_tdefl_len_sym[match_len]],
d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
2095 TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]);
2098 s0 = s_tdefl_small_dist_sym[match_dist & 511];
2099 n0 = s_tdefl_small_dist_extra[match_dist & 511];
2100 s1 = s_tdefl_large_dist_sym[match_dist >> 8];
2101 n1 = s_tdefl_large_dist_extra[match_dist >> 8];
2102 sym = (match_dist < 512) ? s0 : s1;
2103 num_extra_bits = (match_dist < 512) ? n0 : n1;
2106 TDEFL_PUT_BITS_FAST(
d->m_huff_codes[1][sym],
d->m_huff_code_sizes[1][sym]);
2107 TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);
2113 TDEFL_PUT_BITS_FAST(
d->m_huff_codes[0][lit],
d->m_huff_code_sizes[0][lit]);
2115 if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
2120 TDEFL_PUT_BITS_FAST(
d->m_huff_codes[0][lit],
d->m_huff_code_sizes[0][lit]);
2122 if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
2127 TDEFL_PUT_BITS_FAST(
d->m_huff_codes[0][lit],
d->m_huff_code_sizes[0][lit]);
2132 if (pOutput_buf >=
d->m_pOutput_buf_end)
2136 pOutput_buf += (bits_in >> 3);
2137 bit_buffer >>= (bits_in & ~7);
2141#undef TDEFL_PUT_BITS_FAST
2143 d->m_pOutput_buf = pOutput_buf;
2145 d->m_bit_buffer = 0;
2157 return (
d->m_pOutput_buf <
d->m_pOutput_buf_end);
2166 for (pLZ_codes =
d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1)
2169 flags = *pLZ_codes++ | 0x100;
2173 mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3;
2175 MZ_ASSERT(
d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
2176 TDEFL_PUT_BITS(
d->m_huff_codes[0][s_tdefl_len_sym[match_len]],
d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
2177 TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]);
2179 if (match_dist < 512)
2181 sym = s_tdefl_small_dist_sym[match_dist]; num_extra_bits = s_tdefl_small_dist_extra[match_dist];
2185 sym = s_tdefl_large_dist_sym[match_dist >> 8]; num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8];
2189 TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);
2201 return (
d->m_pOutput_buf <
d->m_pOutput_buf_end);
2208 tdefl_start_static_block(
d);
2210 tdefl_start_dynamic_block(
d);
2211 return tdefl_compress_lz_codes(
d);
2216 mz_uint saved_bit_buf, saved_bits_in;
2220 mz_uint8 *pOutput_buf_start = ((
d->m_pPut_buf_func == NULL) && ((*
d->m_pOut_buf_size -
d->m_out_buf_ofs) >=
TDEFL_OUT_BUF_SIZE)) ? ((
mz_uint8 *)
d->m_pOut_buf +
d->m_out_buf_ofs) :
d->m_output_buf;
2222 d->m_pOutput_buf = pOutput_buf_start;
2226 d->m_output_flush_ofs = 0;
2227 d->m_output_flush_remaining = 0;
2229 *
d->m_pLZ_flags = (
mz_uint8)(*
d->m_pLZ_flags >>
d->m_num_flags_left);
2230 d->m_pLZ_code_buf -= (
d->m_num_flags_left == 8);
2239 pSaved_output_buf =
d->m_pOutput_buf; saved_bit_buf =
d->m_bit_buffer; saved_bits_in =
d->m_bits_in;
2245 if ( ((use_raw_block) || ((
d->m_total_lz_bytes) && ((
d->m_pOutput_buf - pSaved_output_buf + 1U) >=
d->m_total_lz_bytes))) &&
2246 ((
d->m_lookahead_pos -
d->m_lz_code_buf_dict_pos) <=
d->m_dict_size) )
2248 mz_uint i;
d->m_pOutput_buf = pSaved_output_buf;
d->m_bit_buffer = saved_bit_buf,
d->m_bits_in = saved_bits_in;
2251 for (i = 2; i; --i,
d->m_total_lz_bytes ^= 0xFFFF)
2255 for (i = 0; i <
d->m_total_lz_bytes; ++i)
2261 else if (!comp_block_succeeded)
2263 d->m_pOutput_buf = pSaved_output_buf;
d->m_bit_buffer = saved_bit_buf,
d->m_bits_in = saved_bits_in;
2280 MZ_ASSERT(
d->m_pOutput_buf <
d->m_pOutput_buf_end);
2285 d->m_pLZ_code_buf =
d->m_lz_code_buf + 1;
d->m_pLZ_flags =
d->m_lz_code_buf;
d->m_num_flags_left = 8;
d->m_lz_code_buf_dict_pos +=
d->m_total_lz_bytes;
d->m_total_lz_bytes = 0;
d->m_block_index++;
2287 if ((n = (
int)(
d->m_pOutput_buf - pOutput_buf_start)) != 0)
2289 if (
d->m_pPut_buf_func)
2291 *
d->m_pIn_buf_size =
d->m_pSrc - (
const mz_uint8 *)
d->m_pIn_buf;
2292 if (!(*
d->m_pPut_buf_func)(
d->m_output_buf, n,
d->m_pPut_buf_user))
2295 else if (pOutput_buf_start ==
d->m_output_buf)
2297 int bytes_to_copy = (int)
MZ_MIN((
size_t)n, (
size_t)(*
d->m_pOut_buf_size -
d->m_out_buf_ofs));
2298 memcpy((
mz_uint8 *)
d->m_pOut_buf +
d->m_out_buf_ofs,
d->m_output_buf, bytes_to_copy);
2299 d->m_out_buf_ofs += bytes_to_copy;
2300 if ((n -= bytes_to_copy) != 0)
2302 d->m_output_flush_ofs = bytes_to_copy;
2303 d->m_output_flush_remaining = n;
2308 d->m_out_buf_ofs += n;
2312 return d->m_output_flush_remaining;
2315#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
2316#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16*)(p)
2320 mz_uint num_probes_left =
d->m_max_probes[match_len >= 32];
2322 mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&
d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s);
2328 if (--num_probes_left == 0)
return;
2329 #define TDEFL_PROBE \
2330 next_probe_pos = d->m_next[probe_pos]; \
2331 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \
2332 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
2333 if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break;
2336 if (!dist)
break; q = (
const mz_uint16*)(
d->m_dict + probe_pos);
if (TDEFL_READ_UNALIGNED_WORD(q) != s01)
continue; p = s; probe_len = 32;
2337 do { }
while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
2338 (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
2345 *pMatch_dist = dist;
if ((*pMatch_len = match_len =
MZ_MIN(max_match_len, probe_len)) == max_match_len)
break;
2346 c01 = TDEFL_READ_UNALIGNED_WORD(&
d->m_dict[pos + match_len - 1]);
2354 mz_uint num_probes_left =
d->m_max_probes[match_len >= 32];
2355 const mz_uint8 *s =
d->m_dict + pos, *p, *q;
2356 mz_uint8 c0 =
d->m_dict[pos + match_len], c1 =
d->m_dict[pos + match_len - 1];
2362 if (--num_probes_left == 0)
return;
2363 #define TDEFL_PROBE \
2364 next_probe_pos = d->m_next[probe_pos]; \
2365 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \
2366 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
2367 if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break;
2370 if (!dist)
break; p = s; q =
d->m_dict + probe_pos;
for (probe_len = 0; probe_len < max_match_len; probe_len++)
if (*p++ != *q++)
break;
2371 if (probe_len > match_len)
2373 *pMatch_dist = dist;
if ((*pMatch_len = match_len = probe_len) == max_match_len)
return;
2374 c0 =
d->m_dict[pos + match_len]; c1 =
d->m_dict[pos + match_len - 1];
2380#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
2384 mz_uint lookahead_pos =
d->m_lookahead_pos, lookahead_size =
d->m_lookahead_size, dict_size =
d->m_dict_size, total_lz_bytes =
d->m_total_lz_bytes, num_flags_left =
d->m_num_flags_left;
2385 mz_uint8 *pLZ_code_buf =
d->m_pLZ_code_buf, *pLZ_flags =
d->m_pLZ_flags;
2388 while ((
d->m_src_buf_left) || ((
d->m_flush) && (lookahead_size)))
2390 const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;
2392 mz_uint num_bytes_to_process = (
mz_uint)
MZ_MIN(
d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size);
2393 d->m_src_buf_left -= num_bytes_to_process;
2394 lookahead_size += num_bytes_to_process;
2396 while (num_bytes_to_process)
2399 memcpy(
d->m_dict + dst_pos,
d->m_pSrc, n);
2404 num_bytes_to_process -= n;
2408 if ((!
d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE))
break;
2410 while (lookahead_size >= 4)
2412 mz_uint cur_match_dist, cur_match_len = 1;
2413 mz_uint8 *pCur_dict =
d->m_dict + cur_pos;
2416 mz_uint probe_pos =
d->m_hash[hash];
2424 do { }
while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
2425 (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
2433 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
2434 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
2435 d->m_huff_count[0][(
mz_uint8)first_trigram]++;
2440 cur_match_len =
MZ_MIN(cur_match_len, lookahead_size);
2449 *pLZ_flags = (
mz_uint8)((*pLZ_flags >> 1) | 0x80);
2451 s0 = s_tdefl_small_dist_sym[cur_match_dist & 511];
2452 s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8];
2453 d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;
2460 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
2461 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
2462 d->m_huff_count[0][(
mz_uint8)first_trigram]++;
2465 if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }
2467 total_lz_bytes += cur_match_len;
2468 lookahead_pos += cur_match_len;
2471 MZ_ASSERT(lookahead_size >= cur_match_len);
2472 lookahead_size -= cur_match_len;
2477 d->m_lookahead_pos = lookahead_pos;
d->m_lookahead_size = lookahead_size;
d->m_dict_size = dict_size;
2478 d->m_total_lz_bytes = total_lz_bytes;
d->m_pLZ_code_buf = pLZ_code_buf;
d->m_pLZ_flags = pLZ_flags;
d->m_num_flags_left = num_flags_left;
2479 if ((n = tdefl_flush_block(
d, 0)) != 0)
2481 total_lz_bytes =
d->m_total_lz_bytes; pLZ_code_buf =
d->m_pLZ_code_buf; pLZ_flags =
d->m_pLZ_flags; num_flags_left =
d->m_num_flags_left;
2485 while (lookahead_size)
2490 *pLZ_code_buf++ = lit;
2491 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
2492 if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }
2494 d->m_huff_count[0][lit]++;
2504 d->m_lookahead_pos = lookahead_pos;
d->m_lookahead_size = lookahead_size;
d->m_dict_size = dict_size;
2505 d->m_total_lz_bytes = total_lz_bytes;
d->m_pLZ_code_buf = pLZ_code_buf;
d->m_pLZ_flags = pLZ_flags;
d->m_num_flags_left = num_flags_left;
2506 if ((n = tdefl_flush_block(
d, 0)) != 0)
2508 total_lz_bytes =
d->m_total_lz_bytes; pLZ_code_buf =
d->m_pLZ_code_buf; pLZ_flags =
d->m_pLZ_flags; num_flags_left =
d->m_num_flags_left;
2513 d->m_lookahead_pos = lookahead_pos;
d->m_lookahead_size = lookahead_size;
d->m_dict_size = dict_size;
2514 d->m_total_lz_bytes = total_lz_bytes;
d->m_pLZ_code_buf = pLZ_code_buf;
d->m_pLZ_flags = pLZ_flags;
d->m_num_flags_left = num_flags_left;
2521 d->m_total_lz_bytes++;
2522 *
d->m_pLZ_code_buf++ = lit;
2523 *
d->m_pLZ_flags = (
mz_uint8)(*
d->m_pLZ_flags >> 1);
if (--
d->m_num_flags_left == 0) {
d->m_num_flags_left = 8;
d->m_pLZ_flags =
d->m_pLZ_code_buf++; }
2524 d->m_huff_count[0][lit]++;
2533 d->m_total_lz_bytes += match_len;
2538 d->m_pLZ_code_buf[1] = (
mz_uint8)(match_dist & 0xFF);
2539 d->m_pLZ_code_buf[2] = (
mz_uint8)(match_dist >> 8);
d->m_pLZ_code_buf += 3;
2541 *
d->m_pLZ_flags = (
mz_uint8)((*
d->m_pLZ_flags >> 1) | 0x80);
if (--
d->m_num_flags_left == 0) {
d->m_num_flags_left = 8;
d->m_pLZ_flags =
d->m_pLZ_code_buf++; }
2543 s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127];
2544 d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++;
2551 const mz_uint8 *pSrc =
d->m_pSrc;
size_t src_buf_left =
d->m_src_buf_left;
2554 while ((src_buf_left) || ((flush) && (
d->m_lookahead_size)))
2556 mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos;
2563 const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process;
2564 src_buf_left -= num_bytes_to_process;
2565 d->m_lookahead_size += num_bytes_to_process;
2566 while (pSrc != pSrc_end)
2581 d->m_dict[dst_pos] = c;
2586 mz_uint ins_pos =
d->m_lookahead_pos + (
d->m_lookahead_size - 1) - 2;
2603 cur_match_len = 0;
while (cur_match_len < d->m_lookahead_size) {
if (
d->m_dict[cur_pos + cur_match_len] != c)
break; cur_match_len++; }
2609 tdefl_find_match(
d,
d->m_lookahead_pos,
d->m_dict_size,
d->m_lookahead_size, &cur_match_dist, &cur_match_len);
2613 cur_match_dist = cur_match_len = 0;
2615 if (
d->m_saved_match_len)
2617 if (cur_match_len >
d->m_saved_match_len)
2619 tdefl_record_literal(
d, (
mz_uint8)
d->m_saved_lit);
2620 if (cur_match_len >= 128)
2622 tdefl_record_match(
d, cur_match_len, cur_match_dist);
2623 d->m_saved_match_len = 0; len_to_move = cur_match_len;
2627 d->m_saved_lit =
d->m_dict[cur_pos];
d->m_saved_match_dist = cur_match_dist;
d->m_saved_match_len = cur_match_len;
2632 tdefl_record_match(
d,
d->m_saved_match_len,
d->m_saved_match_dist);
2633 len_to_move =
d->m_saved_match_len - 1;
d->m_saved_match_len = 0;
2636 else if (!cur_match_dist)
2637 tdefl_record_literal(
d,
d->m_dict[
MZ_MIN(cur_pos,
sizeof(
d->m_dict) - 1)]);
2638 else if ((
d->m_greedy_parsing) || (
d->m_flags &
TDEFL_RLE_MATCHES) || (cur_match_len >= 128))
2640 tdefl_record_match(
d, cur_match_len, cur_match_dist);
2641 len_to_move = cur_match_len;
2645 d->m_saved_lit =
d->m_dict[
MZ_MIN(cur_pos,
sizeof(
d->m_dict) - 1)];
d->m_saved_match_dist = cur_match_dist;
d->m_saved_match_len = cur_match_len;
2648 d->m_lookahead_pos += len_to_move;
2649 MZ_ASSERT(
d->m_lookahead_size >= len_to_move);
2650 d->m_lookahead_size -= len_to_move;
2657 d->m_pSrc = pSrc;
d->m_src_buf_left = src_buf_left;
2658 if ((n = tdefl_flush_block(
d, 0)) != 0)
2663 d->m_pSrc = pSrc;
d->m_src_buf_left = src_buf_left;
2669 if (
d->m_pIn_buf_size)
2671 *
d->m_pIn_buf_size =
d->m_pSrc - (
const mz_uint8 *)
d->m_pIn_buf;
2674 if (
d->m_pOut_buf_size)
2676 size_t n =
MZ_MIN(*
d->m_pOut_buf_size -
d->m_out_buf_ofs,
d->m_output_flush_remaining);
2677 memcpy((
mz_uint8 *)
d->m_pOut_buf +
d->m_out_buf_ofs,
d->m_output_buf +
d->m_output_flush_ofs, n);
2678 d->m_output_flush_ofs += (
mz_uint)n;
2679 d->m_output_flush_remaining -= (
mz_uint)n;
2680 d->m_out_buf_ofs += n;
2682 *
d->m_pOut_buf_size =
d->m_out_buf_ofs;
2692 if (pIn_buf_size) *pIn_buf_size = 0;
2693 if (pOut_buf_size) *pOut_buf_size = 0;
2697 d->m_pIn_buf = pIn_buf;
d->m_pIn_buf_size = pIn_buf_size;
2698 d->m_pOut_buf = pOut_buf;
d->m_pOut_buf_size = pOut_buf_size;
2699 d->m_pSrc = (
const mz_uint8 *)(pIn_buf);
d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0;
2700 d->m_out_buf_ofs = 0;
2703 if ( ((
d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (
d->m_prev_return_status !=
TDEFL_STATUS_OKAY) ||
2704 (
d->m_wants_to_finish && (flush !=
TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) )
2706 if (pIn_buf_size) *pIn_buf_size = 0;
2707 if (pOut_buf_size) *pOut_buf_size = 0;
2712 if ((
d->m_output_flush_remaining) || (
d->m_finished))
2713 return (
d->m_prev_return_status = tdefl_flush_output_buffer(
d));
2715#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
2720 if (!tdefl_compress_fast(
d))
2721 return d->m_prev_return_status;
2726 if (!tdefl_compress_normal(
d))
2727 return d->m_prev_return_status;
2733 if ((flush) && (!
d->m_lookahead_size) && (!
d->m_src_buf_left) && (!
d->m_output_flush_remaining))
2735 if (tdefl_flush_block(
d, flush) < 0)
2736 return d->m_prev_return_status;
2741 return (
d->m_prev_return_status = tdefl_flush_output_buffer(
d));
2751 d->m_pPut_buf_func = pPut_buf_func;
d->m_pPut_buf_user = pPut_buf_user;
2753 d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3;
2755 d->m_lookahead_pos =
d->m_lookahead_size =
d->m_dict_size =
d->m_total_lz_bytes =
d->m_lz_code_buf_dict_pos =
d->m_bits_in = 0;
2756 d->m_output_flush_ofs =
d->m_output_flush_remaining =
d->m_finished =
d->m_block_index =
d->m_bit_buffer =
d->m_wants_to_finish = 0;
2757 d->m_pLZ_code_buf =
d->m_lz_code_buf + 1;
d->m_pLZ_flags =
d->m_lz_code_buf;
d->m_num_flags_left = 8;
2758 d->m_pOutput_buf =
d->m_output_buf;
d->m_pOutput_buf_end =
d->m_output_buf;
d->m_prev_return_status =
TDEFL_STATUS_OKAY;
2759 d->m_saved_match_dist =
d->m_saved_match_len =
d->m_saved_lit = 0;
d->m_adler32 = 1;
2760 d->m_pIn_buf = NULL;
d->m_pOut_buf = NULL;
2761 d->m_pIn_buf_size = NULL;
d->m_pOut_buf_size = NULL;
2762 d->m_flush =
TDEFL_NO_FLUSH;
d->m_pSrc = NULL;
d->m_src_buf_left = 0;
d->m_out_buf_ofs = 0;
2770 return d->m_prev_return_status;
2775 return d->m_adler32;
2784 MZ_FREE(pComp);
return succeeded;
2794static mz_bool tdefl_output_buffer_putter(
const void *pBuf,
int len,
void *pUser)
2797 size_t new_size = p->
m_size + len;
2801 do { new_capacity =
MZ_MAX(128U, new_capacity << 1U); }
while (new_size > new_capacity);
2812 if (!pOut_len)
return MZ_FALSE;
else *pOut_len = 0;
2821 if (!pOut_buf)
return 0;
2827#ifndef MINIZ_NO_ZLIB_APIS
2828static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2847#pragma warning (push)
2848#pragma warning (disable:4204)
2857 static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2859 if (!pComp)
return NULL;
2862 for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf);
2868 *pLen_out = out_buf.
m_size-41;
2870 static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06};
2871 mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
2872 0,0,(
mz_uint8)(w>>8),(
mz_uint8)w,0,0,(
mz_uint8)(h>>8),(
mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0,
2875 memcpy(out_buf.
m_pBuf, pnghdr, 41);
2878 if (!tdefl_output_buffer_putter(
"\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { *pLen_out = 0;
MZ_FREE(pComp);
MZ_FREE(out_buf.
m_pBuf);
return NULL; }
2890#pragma warning (pop)
2895#ifndef MINIZ_NO_ARCHIVE_APIS
2897#ifdef MINIZ_NO_STDIO
2898 #define MZ_FILE void *
2901 #include <sys/stat.h>
2903 #if defined(_MSC_VER) || defined(__MINGW64__)
2904 static FILE *mz_fopen(
const char *pFilename,
const char *pMode)
2907 fopen_s(&pFile, pFilename, pMode);
2910 static FILE *mz_freopen(
const char *pPath,
const char *pMode, FILE *pStream)
2913 if (freopen_s(&pFile, pPath, pMode, pStream))
2917 #ifndef MINIZ_NO_TIME
2918 #include <sys/utime.h>
2920 #define MZ_FILE FILE
2921 #define MZ_FOPEN mz_fopen
2922 #define MZ_FCLOSE fclose
2923 #define MZ_FREAD fread
2924 #define MZ_FWRITE fwrite
2925 #define MZ_FTELL64 _ftelli64
2926 #define MZ_FSEEK64 _fseeki64
2927 #define MZ_FILE_STAT_STRUCT _stat
2928 #define MZ_FILE_STAT _stat
2929 #define MZ_FFLUSH fflush
2930 #define MZ_FREOPEN mz_freopen
2931 #define MZ_DELETE_FILE remove
2932 #elif defined(__MINGW32__)
2933 #ifndef MINIZ_NO_TIME
2934 #include <sys/utime.h>
2936 #define MZ_FILE FILE
2937 #define MZ_FOPEN(f, m) fopen(f, m)
2938 #define MZ_FCLOSE fclose
2939 #define MZ_FREAD fread
2940 #define MZ_FWRITE fwrite
2941 #define MZ_FTELL64 ftello64
2942 #define MZ_FSEEK64 fseeko64
2943 #define MZ_FILE_STAT_STRUCT _stat
2944 #define MZ_FILE_STAT _stat
2945 #define MZ_FFLUSH fflush
2946 #define MZ_FREOPEN(f, m, s) freopen(f, m, s)
2947 #define MZ_DELETE_FILE remove
2948 #elif defined(__TINYC__)
2949 #ifndef MINIZ_NO_TIME
2950 #include <sys/utime.h>
2952 #define MZ_FILE FILE
2953 #define MZ_FOPEN(f, m) fopen(f, m)
2954 #define MZ_FCLOSE fclose
2955 #define MZ_FREAD fread
2956 #define MZ_FWRITE fwrite
2957 #define MZ_FTELL64 ftell
2958 #define MZ_FSEEK64 fseek
2959 #define MZ_FILE_STAT_STRUCT stat
2960 #define MZ_FILE_STAT stat
2961 #define MZ_FFLUSH fflush
2962 #define MZ_FREOPEN(f, m, s) freopen(f, m, s)
2963 #define MZ_DELETE_FILE remove
2964 #elif defined(__GNUC__) && _LARGEFILE64_SOURCE
2965 #ifndef MINIZ_NO_TIME
2968 #define MZ_FILE FILE
2969 #define MZ_FOPEN(f, m) fopen64(f, m)
2970 #define MZ_FCLOSE fclose
2971 #define MZ_FREAD fread
2972 #define MZ_FWRITE fwrite
2973 #define MZ_FTELL64 ftello64
2974 #define MZ_FSEEK64 fseeko64
2975 #define MZ_FILE_STAT_STRUCT stat64
2976 #define MZ_FILE_STAT stat64
2977 #define MZ_FFLUSH fflush
2978 #define MZ_FREOPEN(p, m, s) freopen64(p, m, s)
2979 #define MZ_DELETE_FILE remove
2981 #ifndef MINIZ_NO_TIME
2984 #define MZ_FILE FILE
2985 #define MZ_FOPEN(f, m) fopen(f, m)
2986 #define MZ_FCLOSE fclose
2987 #define MZ_FREAD fread
2988 #define MZ_FWRITE fwrite
2989 #define MZ_FTELL64 ftello
2990 #define MZ_FSEEK64 fseeko
2991 #define MZ_FILE_STAT_STRUCT stat
2992 #define MZ_FILE_STAT stat
2993 #define MZ_FFLUSH fflush
2994 #define MZ_FREOPEN(f, m, s) freopen(f, m, s)
2995 #define MZ_DELETE_FILE remove
2999#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
3039#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size
3040#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index]
3051 if (growing) { new_capacity =
MZ_MAX(1, pArray->
m_capacity);
while (new_capacity < min_new_capacity) new_capacity *= 2; }
3059 if (new_capacity > pArray->
m_capacity) {
if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing))
return MZ_FALSE; }
3065 if (new_size > pArray->
m_capacity) {
if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing))
return MZ_FALSE; }
3066 pArray->
m_size = new_size;
3072 return mz_zip_array_reserve(pZip, pArray, pArray->
m_size + n,
MZ_TRUE);
3077 size_t orig_size = pArray->
m_size;
if (!mz_zip_array_resize(pZip, pArray, orig_size + n,
MZ_TRUE))
return MZ_FALSE;
3082#ifndef MINIZ_NO_TIME
3083static time_t mz_zip_dos_to_time_t(
int dos_time,
int dos_date)
3086 memset(&tm, 0,
sizeof(tm)); tm.tm_isdst = -1;
3087 tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31;
3088 tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62;
3092static void mz_zip_time_to_dos_time(time_t time,
mz_uint16 *pDOS_time,
mz_uint16 *pDOS_date)
3095 struct tm tm_struct;
3096 struct tm *tm = &tm_struct;
3097 errno_t err = localtime_s(tm, &time);
3100 *pDOS_date = 0; *pDOS_time = 0;
3104 struct tm *tm = localtime(&time);
3106 *pDOS_time = (
mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1));
3107 *pDOS_date = (
mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday);
3111#ifndef MINIZ_NO_STDIO
3115 (void)pFilename; *pDOS_date = *pDOS_time = 0;
3121 mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date);
3126#ifndef MINIZ_NO_TIME
3127static mz_bool mz_zip_set_file_times(
const char *pFilename, time_t access_time, time_t modified_time)
3129 struct utimbuf t; t.actime = access_time; t.modtime = modified_time;
3130 return !utime(pFilename, &t);
3166 pE = pL +
MZ_MIN(l_len, r_len);
3173 return (pL == pE) ? (l_len < r_len) : (l < r);
3176#define MZ_SWAP_UINT32(a, b) do { mz_uint32 t = a; a = b; b = t; } MZ_MACRO_END
3179static void mz_zip_reader_sort_central_dir_offsets_by_filename(
mz_zip_archive *pZip)
3186 int start = (
size - 2) >> 1, end;
3189 int child, root = start;
3192 if ((child = (root << 1) + 1) >=
size)
3194 child += (((child + 1) <
size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])));
3195 if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child]))
3205 int child, root = 0;
3209 if ((child = (root << 1) + 1) >= end)
3211 child += (((child + 1) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]));
3212 if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child]))
3222 mz_uint cdir_size, num_this_disk, cdir_disk_index;
3238 for (i = n - 4; i >= 0; --i)
3248 cur_file_ofs =
MZ_MAX(cur_file_ofs - (
sizeof(buf_u32) - 3), 0);
3259 if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1)))
3280 if (sort_central_dir)
3293 mz_uint total_header_size, comp_size, decomp_size, disk_index;
3297 if (sort_central_dir)
3301 if (((!
MZ_READ_LE32(p +
MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF))
3304 if ((disk_index != num_this_disk) && (disk_index != 1))
3310 n -= total_header_size; p += total_header_size;
3314 if (sort_central_dir)
3315 mz_zip_reader_sort_central_dir_offsets_by_filename(pZip);
3322 if ((!pZip) || (!pZip->
m_pRead))
3324 if (!mz_zip_reader_init_internal(pZip, flags))
3327 if (!mz_zip_reader_read_central_dir(pZip, flags))
3335static size_t mz_zip_mem_read_func(
void *pOpaque,
mz_uint64 file_ofs,
void *pBuf,
size_t n)
3338 size_t s = (file_ofs >= pZip->
m_archive_size) ? 0 : (size_t)
MZ_MIN(pZip->m_archive_size - file_ofs, n);
3345 if (!mz_zip_reader_init_internal(pZip, flags))
3348 pZip->
m_pRead = mz_zip_mem_read_func;
3356 if (!mz_zip_reader_read_central_dir(pZip, flags))
3364#ifndef MINIZ_NO_STDIO
3365static size_t mz_zip_file_read_func(
void *pOpaque,
mz_uint64 file_ofs,
void *pBuf,
size_t n)
3386 if (!mz_zip_reader_init_internal(pZip, flags))
3391 pZip->
m_pRead = mz_zip_file_read_func;
3395 if (!mz_zip_reader_read_central_dir(pZip, flags))
3419 const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
3423 return (m_bit_flag & 1);
3428 mz_uint filename_len, external_attr;
3429 const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
3445 if ((external_attr & 0x10) != 0)
3454 const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
3455 if ((!p) || (!pStat))
3465#ifndef MINIZ_NO_TIME
3489 const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
3490 if (!p) {
if (filename_buf_size) pFilename[0] =
'\0';
return 0; }
3492 if (filename_buf_size)
3494 n =
MZ_MIN(n, filename_buf_size - 1);
3496 pFilename[n] =
'\0';
3505 return 0 == memcmp(pA, pB, len);
3506 for (i = 0; i < len; ++i)
3518 pE = pL +
MZ_MIN(l_len, r_len);
3525 return (pL == pE) ? (int)(l_len - r_len) : (l - r);
3528static int mz_zip_reader_locate_file_binary_search(
mz_zip_archive *pZip,
const char *pFilename)
3536 int l = 0, h =
size - 1;
3539 int m = (l + h) >> 1, file_index = pIndices[m], comp = mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len);
3552 mz_uint file_index;
size_t name_len, comment_len;
3556 return mz_zip_reader_locate_file_binary_search(pZip, pName);
3557 name_len = strlen(pName);
if (name_len > 0xFFFF)
return -1;
3558 comment_len = pComment ? strlen(pComment) : 0;
if (comment_len > 0xFFFF)
return -1;
3559 for (file_index = 0; file_index < pZip->
m_total_files; file_index++)
3564 if (filename_len < name_len)
3569 const char *pFile_comment = pFilename + filename_len + file_extra_len;
3570 if ((file_comment_len != comment_len) || (!mz_zip_reader_string_equal(pComment, pFile_comment, file_comment_len, flags)))
3575 int ofs = filename_len - 1;
3578 if ((pFilename[ofs] ==
'/') || (pFilename[ofs] ==
'\\') || (pFilename[ofs] ==
':'))
3580 }
while (--ofs >= 0);
3582 pFilename += ofs; filename_len -= ofs;
3584 if ((filename_len == name_len) && (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags)))
3593 mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;
3599 if ((buf_size) && (!pBuf))
3624 if (buf_size < needed_size)
3641 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pBuf, (
size_t)needed_size) != needed_size)
3653 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
3656 else if (pUser_read_buf)
3659 if (!user_read_buf_size)
3661 pRead_buf = (
mz_uint8 *)pUser_read_buf;
3662 read_buf_size = user_read_buf_size;
3671 if (((0,
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
3673 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
3684 size_t in_buf_size, out_buf_size = (size_t)(file_stat.
m_uncomp_size - out_buf_ofs);
3687 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
3688 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3693 cur_file_ofs += read_buf_avail;
3694 comp_remaining -= read_buf_avail;
3697 in_buf_size = (size_t)read_buf_avail;
3699 read_buf_avail -= in_buf_size;
3700 read_buf_ofs += in_buf_size;
3701 out_buf_ofs += out_buf_size;
3737 mz_uint64 comp_size, uncomp_size, alloc_size;
3738 const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
3751 if (((0,
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (alloc_size > 0x7FFFFFFF))
3753 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (alloc_size > 0x7FFFFFFF))
3765 if (pSize) *pSize = (size_t)alloc_size;
3774 if (pSize) *pSize = 0;
3783 mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
3785 void *pRead_buf = NULL;
void *pWrite_buf = NULL;
3823 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
3856 while (comp_remaining)
3858 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
3859 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3868 if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3873 cur_file_ofs += read_buf_avail;
3874 out_buf_ofs += read_buf_avail;
3875 comp_remaining -= read_buf_avail;
3894 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
3895 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3900 cur_file_ofs += read_buf_avail;
3901 comp_remaining -= read_buf_avail;
3905 in_buf_size = (size_t)read_buf_avail;
3907 read_buf_avail -= in_buf_size;
3908 read_buf_ofs += in_buf_size;
3912 if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size)
3918 if ((out_buf_ofs += out_buf_size) > file_stat.
m_uncomp_size)
3951#ifndef MINIZ_NO_STDIO
3952static size_t mz_zip_file_write_callback(
void *pOpaque,
mz_uint64 ofs,
const void *pBuf,
size_t n)
3964 pFile =
MZ_FOPEN(pDst_filename,
"wb");
3970#ifndef MINIZ_NO_TIME
3972 mz_zip_set_file_times(pDst_filename, file_stat.
m_time, file_stat.
m_time);
3990#ifndef MINIZ_NO_STDIO
4005#ifndef MINIZ_NO_STDIO
4017#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
4021#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v))
4022#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v))
4054static size_t mz_zip_heap_write_func(
void *pOpaque,
mz_uint64 file_ofs,
const void *pBuf,
size_t n)
4060 if ((!n) || ((0,
sizeof(
size_t) ==
sizeof(
mz_uint32)) && (new_size > 0x7FFFFFFF)))
4062 if ((!n) || ((
sizeof(
size_t) ==
sizeof(
mz_uint32)) && (new_size > 0x7FFFFFFF)))
4068 size_t new_capacity =
MZ_MAX(64, pState->
m_mem_capacity);
while (new_capacity < new_size) new_capacity *= 2;
4080 pZip->
m_pWrite = mz_zip_heap_write_func;
4084 if (0 != (initial_allocation_size =
MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning)))
4096#ifndef MINIZ_NO_STDIO
4097static size_t mz_zip_file_write_func(
void *pOpaque,
mz_uint64 file_ofs,
const void *pBuf,
size_t n)
4109 pZip->
m_pWrite = mz_zip_file_write_func;
4113 if (NULL == (pFile =
MZ_FOPEN(pFilename,
"wb")))
4119 if (size_to_reserve_at_beginning)
4124 size_t n = (size_t)
MZ_MIN(
sizeof(buf), size_to_reserve_at_beginning);
4130 cur_ofs += n; size_to_reserve_at_beginning -= n;
4131 }
while (size_to_reserve_at_beginning);
4150#ifdef MINIZ_NO_STDIO
4158 pZip->
m_pWrite = mz_zip_file_write_func;
4173 pZip->
m_pWrite = mz_zip_heap_write_func;
4199static mz_bool mz_zip_writer_add_put_buf_callback(
const void* pBuf,
int len,
void *pUser)
4209static mz_bool mz_zip_writer_create_local_dir_header(
mz_zip_archive *pZip,
mz_uint8 *pDst,
mz_uint16 filename_size,
mz_uint16 extra_size,
mz_uint64 uncomp_size,
mz_uint64 comp_size,
mz_uint32 uncomp_crc32,
mz_uint16 method,
mz_uint16 bit_flags,
mz_uint16 dos_time,
mz_uint16 dos_date)
4227static mz_bool mz_zip_writer_create_central_dir_header(
mz_zip_archive *pZip,
mz_uint8 *pDst,
mz_uint16 filename_size,
mz_uint16 extra_size,
mz_uint16 comment_size,
mz_uint64 uncomp_size,
mz_uint64 comp_size,
mz_uint32 uncomp_crc32,
mz_uint16 method,
mz_uint16 bit_flags,
mz_uint16 dos_time,
mz_uint16 dos_date,
mz_uint64 local_header_ofs,
mz_uint32 ext_attributes)
4248static mz_bool mz_zip_writer_add_to_central_dir(
mz_zip_archive *pZip,
const char *pFilename,
mz_uint16 filename_size,
const void *pExtra,
mz_uint16 extra_size,
const void *pComment,
mz_uint16 comment_size,
mz_uint64 uncomp_size,
mz_uint64 comp_size,
mz_uint32 uncomp_crc32,
mz_uint16 method,
mz_uint16 bit_flags,
mz_uint16 dos_time,
mz_uint16 dos_date,
mz_uint64 local_header_ofs,
mz_uint32 ext_attributes)
4259 if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes))
4263 (!mz_zip_array_push_back(pZip, &pState->
m_central_dir, pFilename, filename_size)) ||
4264 (!mz_zip_array_push_back(pZip, &pState->
m_central_dir, pExtra, extra_size)) ||
4265 (!mz_zip_array_push_back(pZip, &pState->
m_central_dir, pComment, comment_size)) ||
4276static mz_bool mz_zip_writer_validate_archive_name(
const char *pArchive_name)
4279 if (*pArchive_name ==
'/')
4281 while (*pArchive_name)
4283 if ((*pArchive_name ==
'\\') || (*pArchive_name ==
':'))
4302 memset(buf, 0,
MZ_MIN(
sizeof(buf), n));
4308 cur_file_ofs += s; n -= s;
4315 mz_uint16 method = 0, dos_time = 0, dos_date = 0;
4316 mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
4318 size_t archive_name_size;
4321 mz_bool store_data_uncompressed;
4324 if ((
int)level_and_flags < 0)
4326 level = level_and_flags & 0xF;
4337 if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
4339 if (!mz_zip_writer_validate_archive_name(pArchive_name))
4342#ifndef MINIZ_NO_TIME
4345 mz_zip_time_to_dos_time(
cur_time, &dos_time, &dos_date);
4349 archive_name_size = strlen(pArchive_name);
4350 if (archive_name_size > 0xFFFF)
4353 num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
4359 if ((archive_name_size) && (pArchive_name[archive_name_size - 1] ==
'/'))
4362 ext_attributes |= 0x10;
4364 if ((buf_size) || (uncomp_size))
4372 if ((!store_data_uncompressed) && (buf_size))
4378 if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes +
sizeof(local_dir_header)))
4383 local_dir_header_ofs += num_alignment_padding_bytes;
4385 cur_archive_file_ofs += num_alignment_padding_bytes +
sizeof(local_dir_header);
4388 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
4393 cur_archive_file_ofs += archive_name_size;
4398 uncomp_size = buf_size;
4399 if (uncomp_size <= 3)
4402 store_data_uncompressed =
MZ_TRUE;
4406 if (store_data_uncompressed)
4414 cur_archive_file_ofs += buf_size;
4415 comp_size = buf_size;
4445 if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))
4448 if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (
mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date))
4451 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, local_dir_header_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
4454 if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (
mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes))
4463#ifndef MINIZ_NO_STDIO
4467 mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;
4469 size_t archive_name_size;
4473 if ((
int)level_and_flags < 0)
4475 level = level_and_flags & 0xF;
4481 if (!mz_zip_writer_validate_archive_name(pArchive_name))
4484 archive_name_size = strlen(pArchive_name);
4485 if (archive_name_size > 0xFFFF)
4488 num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
4494 if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date))
4497 pSrc_file =
MZ_FOPEN(pSrc_filename,
"rb");
4504 if (uncomp_size > 0xFFFFFFFF)
4510 if (uncomp_size <= 3)
4513 if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes +
sizeof(local_dir_header)))
4518 local_dir_header_ofs += num_alignment_padding_bytes;
4520 cur_archive_file_ofs += num_alignment_padding_bytes +
sizeof(local_dir_header);
4523 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
4528 cur_archive_file_ofs += archive_name_size;
4532 mz_uint64 uncomp_remaining = uncomp_size;
4542 while (uncomp_remaining)
4552 uncomp_remaining -= n;
4553 cur_archive_file_ofs += n;
4555 comp_size = uncomp_size;
4586 if (
MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
4590 uncomp_remaining -= in_buf_size;
4623 if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))
4626 if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (
mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date))
4629 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, local_dir_header_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
4632 if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (
mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes))
4644 mz_uint n, bit_flags, num_alignment_padding_bytes;
4645 mz_uint64 comp_bytes_remaining, local_dir_header_ofs;
4646 mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;
4649 size_t orig_central_dir_size;
4651 void *pBuf;
const mz_uint8 *pSrc_central_header;
4655 if (NULL == (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index)))
4659 num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
4674 if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes))
4676 cur_dst_file_ofs += num_alignment_padding_bytes;
4677 local_dir_header_ofs = cur_dst_file_ofs;
4690 while (comp_bytes_remaining)
4698 cur_src_file_ofs += n;
4705 cur_dst_file_ofs += n;
4707 comp_bytes_remaining -= n;
4727 cur_src_file_ofs += n;
4728 cur_dst_file_ofs += n;
4733 if (cur_dst_file_ofs > 0xFFFFFFFF)
4768 mz_uint64 central_dir_ofs, central_dir_size;
4780 central_dir_ofs = 0;
4781 central_dir_size = 0;
4803#ifndef MINIZ_NO_STDIO
4816 if ((!pZip) || (!pZip->
m_pState) || (!pBuf) || (!pSize))
4818 if (pZip->
m_pWrite != mz_zip_heap_write_func)
4843#ifndef MINIZ_NO_STDIO
4851 if ((pZip->
m_pWrite == mz_zip_heap_write_func) && (pState->
m_pMem))
4862#ifndef MINIZ_NO_STDIO
4869 if ((
int)level_and_flags < 0)
4871 if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) >
MZ_UBER_COMPRESSION))
4873 if (!mz_zip_writer_validate_archive_name(pArchive_name))
4880 created_new_archive =
MZ_TRUE;
4893 status =
mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0);
4899 if ((!status) && (created_new_archive))
4903 (void)ignoredStatus;
4917 if ((!pZip_filename) || (!pArchive_name))
4984 for(
auto part : parts)
4986 joined.append(
part);
4988 if(i++ != parts.size() - 1)
4990 joined.append(1,
'/');
4998 std::vector<std::string>
split;
4999 std::string::size_type previous_index = 0;
5000 auto separator_index = path.find(delim);
5002 while(separator_index != std::string::npos)
5004 auto part = path.substr(previous_index, separator_index - previous_index);
5013 previous_index = separator_index + 1;
5014 separator_index = path.find(delim, previous_index);
5017 split.push_back(path.substr(previous_index));
5022 if(alternative.size() > 1)
5033 uint32_t oldcrc32 = 0xFFFFFFFF;
5035 uint32_t crc_32_tab[] = {
5036 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
5037 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
5038 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
5039 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
5040 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
5041 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
5042 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
5043 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
5044 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
5045 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
5046 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
5047 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
5048 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
5049 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
5050 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
5051 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
5052 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
5053 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
5054 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
5055 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
5056 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
5057 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
5058 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
5059 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
5060 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
5061 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
5062 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
5063 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
5064 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
5065 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
5066 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
5067 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
5068 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
5069 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
5070 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
5071 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
5072 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
5073 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
5074 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
5075 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
5076 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
5077 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
5078 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
5081#define UPDC32(octet,crc) (crc_32_tab[((crc)\
5082^ static_cast<uint8_t>(octet)) & 0xff] ^ ((crc) >> 8))
5084 for ( ; len; --len, ++buf)
5086 oldcrc32 =
UPDC32(*buf, oldcrc32);
5096 localtime_s(&time, &t);
5099 tm *time = localtime(&t);
5100 assert(time !=
nullptr);
5107 auto buffer =
static_cast<std::vector<char> *
>(opaque);
5109 if(file_ofs + n > buffer->size())
5111 auto new_size =
static_cast<std::vector<char>::size_type
>(file_ofs + n);
5112 buffer->resize(new_size);
5115 for(std::size_t i = 0; i < n; i++)
5117 (*buffer)[
static_cast<std::size_t
>(file_ofs + i)] = (
static_cast<const char *
>(pBuf))[i];
5185 buffer_.assign(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>());
5190 void load(
const std::string &filename)
5192 filename_ = filename;
5193 std::ifstream stream(filename, std::ios::binary);
5197 void load(
const std::vector<unsigned char> &bytes)
5200 buffer_.assign(bytes.begin(), bytes.end());
5205 void save(
const std::string &filename)
5207 filename_ = filename;
5208 std::ofstream stream(filename, std::ios::binary);
5230 stream.write(buffer_.data(),
static_cast<long>(buffer_.size()));
5233 void save(std::vector<unsigned char> &bytes)
5251 bytes.assign(buffer_.begin(), buffer_.end());
5256 switch(archive_->m_zip_mode)
5326 std::vector<zip_info>
info;
5338 std::vector<std::string> names;
5342 names.push_back(
info.filename);
5356 std::string data_string(
data.begin(),
data.end());
5357 open_stream_ << data_string;
5358 return open_stream_;
5361 void extract(
const std::string &member,
const std::string &path)
5363 std::fstream stream(
detail::join_path({path, member}), std::ios::binary | std::ios::out);
5364 stream <<
open(member).rdbuf();
5370 stream <<
open(member).rdbuf();
5378 void extractall(
const std::string &path,
const std::vector<std::string> &members)
5380 for(
auto &member : members)
5386 void extractall(
const std::string &path,
const std::vector<zip_info> &members)
5388 for(
auto &member : members)
5401 stream <<
" Length " <<
" " <<
" " <<
"Date" <<
" " <<
" " <<
"Time " <<
" " <<
"Name" << std::endl;
5402 stream <<
"--------- ---------- ----- ----" << std::endl;
5404 std::size_t sum_length = 0;
5405 std::size_t file_count = 0;
5409 sum_length += member.file_size;
5412 std::string length_string = std::to_string(member.file_size);
5413 while(length_string.length() < 9)
5415 length_string =
" " + length_string;
5417 stream << length_string;
5420 stream << (member.date_time.month < 10 ?
"0" :
"") << member.date_time.month;
5422 stream << (member.date_time.day < 10 ?
"0" :
"") << member.date_time.day;
5424 stream << member.date_time.year;
5426 stream << (member.date_time.hours < 10 ?
"0" :
"") << member.date_time.hours;
5428 stream << (member.date_time.minutes < 10 ?
"0" :
"") << member.date_time.minutes;
5430 stream << member.filename;
5431 stream << std::endl;
5434 stream <<
"--------- -------" << std::endl;
5436 std::string length_string = std::to_string(sum_length);
5437 while(length_string.length() < 9)
5439 length_string =
" " + length_string;
5441 stream << length_string <<
" " << file_count <<
" " << (file_count == 1 ?
"file" :
"files");
5442 stream << std::endl;
5472 auto content =
read(file);
5477 return {
false, file.filename};
5487 if(
split.size() > 1)
5492 write(filename, arcname);
5495 void write(
const std::string &filename,
const std::string &arcname)
5497 std::fstream file(filename, std::ios::binary | std::ios::in);
5498 std::stringstream ss;
5500 std::string bytes = ss.str();
5505 void writestr(
const std::string &arcname,
const std::string &bytes)
5520 if(
info.filename.empty() ||
info.date_time.year < 1980)
5567 switch(archive_->m_zip_mode)
5573 std::vector<char> buffer_copy(buffer_.begin(), buffer_.end());
5583 archive_->m_pIO_opaque = &buffer_;
5584 buffer_ = std::vector<char>();
5591 for(
unsigned int i = 0; i < static_cast<unsigned int>(archive_copy.
m_total_files); i++)
5611 archive_->m_pIO_opaque = &buffer_;
5619 void append_comment()
5623 auto comment_length = std::min(
static_cast<uint16_t
>(
comment.length()), std::numeric_limits<uint16_t>::max());
5624 buffer_[buffer_.size() - 2] =
static_cast<char>(comment_length);
5625 buffer_[buffer_.size() - 1] =
static_cast<char>(comment_length >> 8);
5626 std::copy(
comment.begin(),
comment.end(), std::back_inserter(buffer_));
5630 void remove_comment()
5632 if(buffer_.empty())
return;
5634 std::size_t position = buffer_.size() - 1;
5636 for(; position >= 3; position--)
5638 if(buffer_[position - 3] ==
'P'
5639 && buffer_[position - 2] ==
'K'
5640 && buffer_[position - 1] ==
'\x05'
5641 && buffer_[position] ==
'\x06')
5643 position = position + 17;
5653 uint16_t length =
static_cast<uint16_t
>(buffer_[position + 1]);
5654 length =
static_cast<uint16_t
>(length << 8) + static_cast<uint16_t>(buffer_[position]);
5659 comment = std::string(buffer_.data() + position, buffer_.data() + position + length);
5660 buffer_.resize(buffer_.size() - length);
5661 buffer_[buffer_.size() - 1] = 0;
5662 buffer_[buffer_.size() - 2] = 0;
5673 mz_zip_archive_file_stat stat;
5680 result.compress_size =
static_cast<std::size_t
>(stat.
m_comp_size);
5681 result.file_size =
static_cast<std::size_t
>(stat.
m_uncomp_size);
5685 result.date_time.year = 1900 + time.tm_year;
5686 result.date_time.month = 1 + time.tm_mon;
5687 result.date_time.day = time.tm_mday;
5688 result.date_time.hours = time.tm_hour;
5689 result.date_time.minutes = time.tm_min;
5690 result.date_time.seconds = time.tm_sec;
5697 result.create_system = stat.
m_method;
5702 std::unique_ptr<mz_zip_archive> archive_;
5703 std::vector<char> buffer_;
5704 std::stringstream open_stream_;
5705 std::string filename_;
void split(std::vector< FontInterfaceImpl::Bezier2d > &vec, FontInterfaceImpl::Bezier2d orig, float t, bool emit_left, bool emit_right)
Definition FreeType2.cc:134
GameApi::ML part(GameApi::EveryApi &ev, GameApi::ML ml, float x_trans, float y_rot, int x, int y, int mode=0)
Definition GameApi.cc:38016
float cur_time
Definition GameApi_main.cc:966
void info(std::string info)
Definition check.cc:24
Definition compiled_tests.cpp:1189
std::vector< zip_info > infolist()
Definition zip_file.hpp:5319
zip_file(const std::string &filename)
Definition zip_file.hpp:5162
void printdir()
Definition zip_file.hpp:5394
void write(const std::string &filename)
Definition zip_file.hpp:5484
void load(std::istream &stream)
Definition zip_file.hpp:5182
std::ostream & open(const std::string &name)
Definition zip_file.hpp:5348
zip_file(std::istream &stream)
Definition zip_file.hpp:5167
std::pair< bool, std::string > testzip()
Definition zip_file.hpp:5463
~zip_file()
Definition zip_file.hpp:5177
std::string read(const zip_info &info)
Definition zip_file.hpp:5445
bool has_file(const zip_info &name)
Definition zip_file.hpp:5297
void save(const std::string &filename)
Definition zip_file.hpp:5205
std::string read(const std::string &name)
Definition zip_file.hpp:5458
void extract(const std::string &member, const std::string &path)
Definition zip_file.hpp:5361
void printdir(std::ostream &stream)
Definition zip_file.hpp:5399
void writestr(const std::string &arcname, const std::string &bytes)
Definition zip_file.hpp:5505
void reset()
Definition zip_file.hpp:5254
void extractall(const std::string &path, const std::vector< std::string > &members)
Definition zip_file.hpp:5378
std::string get_filename() const
Definition zip_file.hpp:5538
zip_file()
Definition zip_file.hpp:5157
void extractall(const std::string &path)
Definition zip_file.hpp:5373
void load(const std::string &filename)
Definition zip_file.hpp:5190
std::vector< std::string > namelist()
Definition zip_file.hpp:5336
std::ostream & open(const zip_info &name)
Definition zip_file.hpp:5353
void extractall(const std::string &path, const std::vector< zip_info > &members)
Definition zip_file.hpp:5386
bool has_file(const std::string &name)
Definition zip_file.hpp:5285
void writestr(const zip_info &info, const std::string &bytes)
Definition zip_file.hpp:5518
void load(const std::vector< unsigned char > &bytes)
Definition zip_file.hpp:5197
void save(std::ostream &stream)
Definition zip_file.hpp:5212
void save(std::vector< unsigned char > &bytes)
Definition zip_file.hpp:5233
std::string comment
Definition zip_file.hpp:5540
void extract(const zip_info &member, const std::string &path)
Definition zip_file.hpp:5367
zip_info getinfo(const std::string &name)
Definition zip_file.hpp:5302
void write(const std::string &filename, const std::string &arcname)
Definition zip_file.hpp:5495
zip_file(const std::vector< unsigned char > &bytes)
Definition zip_file.hpp:5172
std::string code
Definition test.cpp:145
d
Definition meshpage.php:3895
iVBORw0KGgoAAAANSUhEUgAAANcAAAB5CAMAAACdtUQZAAAA51BMVEX</div ></div >< div style="padding: 0px 0px; width: 1324px;">< div style="height: 400px; width: 1324px;"></div >< div itemscope itemtype="https: </div><div itemscope itemtype="https:</div >< div itemscope itemtype="https: </div></div><p><div style="padding:0px 0px;width:1324px;"><div></div><div itemscope itemtype="https:< ul >< li >< b > Application name
8AkrcAgqgAs9wqQ0ey2tkAo8gAuuQfeI4hPUH09fXHy8z4+fng4uNKXF/Lz9BzfoAcgpkQMTUAKjAbOT4Qr9AXhJ8Rl7ktMCwTosA...
Definition meshpage.php:1610
lazy data
Definition meshpage.php:1583
n< br > font size
Definition meshpage.php:3536
Definition zip_file.hpp:4970
std::size_t write_callback(void *opaque, mz_uint64 file_ofs, const void *pBuf, std::size_t n)
Definition zip_file.hpp:5105
std::vector< std::string > split_path(const std::string &path, char delim=directory_separator)
Definition zip_file.hpp:4996
char directory_separator
Definition zip_file.hpp:4976
char alt_directory_separator
Definition zip_file.hpp:4977
uint32_t crc32buf(const char *buf, std::size_t len)
Definition zip_file.hpp:5031
std::string join_path(const std::vector< std::string > &parts)
Definition zip_file.hpp:4980
tm safe_localtime(const time_t &t)
Definition zip_file.hpp:5092
Definition zip_file.hpp:4969
Definition zip_file.hpp:1213
int m_window_bits
Definition zip_file.hpp:1215
mz_uint m_dict_ofs
Definition zip_file.hpp:1215
mz_uint m_has_flushed
Definition zip_file.hpp:1215
mz_uint m_dict_avail
Definition zip_file.hpp:1215
mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]
Definition zip_file.hpp:1216
mz_uint m_first_call
Definition zip_file.hpp:1215
tinfl_status m_last_status
Definition zip_file.hpp:1217
tinfl_decompressor m_decomp
Definition zip_file.hpp:1214
Definition zip_file.hpp:5126
std::size_t header_offset
Definition zip_file.hpp:5148
uint32_t internal_attr
Definition zip_file.hpp:5146
uint16_t create_version
Definition zip_file.hpp:5142
struct miniz_cpp::zip_info::@254227211326164276175326067341304314256262050374 date_time
std::string extra
Definition zip_file.hpp:5140
int year
Definition zip_file.hpp:5131
std::size_t file_size
Definition zip_file.hpp:5151
uint16_t extract_version
Definition zip_file.hpp:5143
int seconds
Definition zip_file.hpp:5136
std::size_t compress_size
Definition zip_file.hpp:5150
std::string filename
Definition zip_file.hpp:5127
uint16_t create_system
Definition zip_file.hpp:5141
int month
Definition zip_file.hpp:5132
int day
Definition zip_file.hpp:5133
std::size_t volume
Definition zip_file.hpp:5145
int hours
Definition zip_file.hpp:5134
uint32_t crc
Definition zip_file.hpp:5149
uint16_t flag_bits
Definition zip_file.hpp:5144
std::string comment
Definition zip_file.hpp:5139
int minutes
Definition zip_file.hpp:5135
uint32_t external_attr
Definition zip_file.hpp:5147
Definition zip_file.hpp:322
mz_ulong adler
Definition zip_file.hpp:339
unsigned char * next_out
Definition zip_file.hpp:327
void * opaque
Definition zip_file.hpp:336
int data_type
Definition zip_file.hpp:338
mz_free_func zfree
Definition zip_file.hpp:335
mz_ulong total_out
Definition zip_file.hpp:329
unsigned int avail_out
Definition zip_file.hpp:328
struct mz_internal_state * state
Definition zip_file.hpp:332
const unsigned char * next_in
Definition zip_file.hpp:323
unsigned int avail_in
Definition zip_file.hpp:324
mz_alloc_func zalloc
Definition zip_file.hpp:334
mz_ulong total_in
Definition zip_file.hpp:325
char * msg
Definition zip_file.hpp:331
mz_ulong reserved
Definition zip_file.hpp:340
Definition zip_file.hpp:543
mz_uint32 m_external_attr
Definition zip_file.hpp:557
mz_uint16 m_version_needed
Definition zip_file.hpp:547
time_t m_time
Definition zip_file.hpp:551
mz_uint16 m_version_made_by
Definition zip_file.hpp:546
mz_uint32 m_file_index
Definition zip_file.hpp:544
mz_uint32 m_central_dir_ofs
Definition zip_file.hpp:545
mz_uint64 m_uncomp_size
Definition zip_file.hpp:555
mz_uint32 m_comment_size
Definition zip_file.hpp:559
mz_uint16 m_bit_flag
Definition zip_file.hpp:548
mz_uint64 m_local_header_ofs
Definition zip_file.hpp:558
mz_uint16 m_internal_attr
Definition zip_file.hpp:556
mz_uint16 m_method
Definition zip_file.hpp:549
mz_uint64 m_comp_size
Definition zip_file.hpp:554
char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]
Definition zip_file.hpp:560
mz_uint32 m_crc32
Definition zip_file.hpp:553
char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]
Definition zip_file.hpp:561
Definition zip_file.hpp:579
mz_zip_mode m_zip_mode
Definition zip_file.hpp:583
mz_uint m_total_files
Definition zip_file.hpp:582
mz_alloc_func m_pAlloc
Definition zip_file.hpp:587
mz_file_write_func m_pWrite
Definition zip_file.hpp:593
mz_uint m_file_offset_alignment
Definition zip_file.hpp:585
mz_realloc_func m_pRealloc
Definition zip_file.hpp:589
mz_free_func m_pFree
Definition zip_file.hpp:588
mz_zip_internal_state * m_pState
Definition zip_file.hpp:596
mz_file_read_func m_pRead
Definition zip_file.hpp:592
mz_uint64 m_central_directory_file_ofs
Definition zip_file.hpp:581
void * m_pAlloc_opaque
Definition zip_file.hpp:590
mz_uint64 m_archive_size
Definition zip_file.hpp:580
void * m_pIO_opaque
Definition zip_file.hpp:594
Definition zip_file.hpp:3022
size_t m_size
Definition zip_file.hpp:3024
void * m_p
Definition zip_file.hpp:3023
size_t m_capacity
Definition zip_file.hpp:3024
mz_uint m_element_size
Definition zip_file.hpp:3025
Definition zip_file.hpp:3029
mz_zip_array m_sorted_central_dir_offsets
Definition zip_file.hpp:3032
size_t m_mem_size
Definition zip_file.hpp:3035
mz_zip_array m_central_dir_offsets
Definition zip_file.hpp:3031
mz_zip_array m_central_dir
Definition zip_file.hpp:3030
size_t m_mem_capacity
Definition zip_file.hpp:3036
MZ_FILE * m_pFile
Definition zip_file.hpp:3033
void * m_pMem
Definition zip_file.hpp:3034
Definition zip_file.hpp:4193
mz_uint64 m_cur_archive_file_ofs
Definition zip_file.hpp:4195
mz_uint64 m_comp_size
Definition zip_file.hpp:4196
mz_zip_archive * m_pZip
Definition zip_file.hpp:4194
Definition zip_file.hpp:913
mz_uint m_max_probes[2]
Definition zip_file.hpp:916
mz_uint m_block_index
Definition zip_file.hpp:921
mz_uint m_saved_lit
Definition zip_file.hpp:921
mz_uint m_saved_match_dist
Definition zip_file.hpp:921
size_t * m_pOut_buf_size
Definition zip_file.hpp:925
mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]
Definition zip_file.hpp:935
const mz_uint8 * m_pSrc
Definition zip_file.hpp:927
mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
Definition zip_file.hpp:931
mz_uint m_output_flush_remaining
Definition zip_file.hpp:921
mz_uint m_num_flags_left
Definition zip_file.hpp:920
mz_uint m_lookahead_pos
Definition zip_file.hpp:918
mz_uint m_wants_to_finish
Definition zip_file.hpp:921
mz_uint m_finished
Definition zip_file.hpp:921
mz_uint m_total_lz_bytes
Definition zip_file.hpp:920
size_t m_src_buf_left
Definition zip_file.hpp:928
tdefl_status m_prev_return_status
Definition zip_file.hpp:922
mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE+TDEFL_MAX_MATCH_LEN - 1]
Definition zip_file.hpp:929
tdefl_put_buf_func_ptr m_pPut_buf_func
Definition zip_file.hpp:914
tdefl_flush m_flush
Definition zip_file.hpp:926
mz_uint m_output_flush_ofs
Definition zip_file.hpp:921
size_t m_out_buf_ofs
Definition zip_file.hpp:928
mz_uint m_bit_buffer
Definition zip_file.hpp:920
mz_uint m_bits_in
Definition zip_file.hpp:920
mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]
Definition zip_file.hpp:934
mz_uint8 * m_pOutput_buf_end
Definition zip_file.hpp:919
mz_uint m_lookahead_size
Definition zip_file.hpp:918
mz_uint8 * m_pLZ_flags
Definition zip_file.hpp:919
mz_uint m_saved_match_len
Definition zip_file.hpp:921
mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
Definition zip_file.hpp:930
void * m_pOut_buf
Definition zip_file.hpp:924
mz_uint m_lz_code_buf_dict_pos
Definition zip_file.hpp:920
const void * m_pIn_buf
Definition zip_file.hpp:923
mz_uint m_flags
Definition zip_file.hpp:916
mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]
Definition zip_file.hpp:933
int m_greedy_parsing
Definition zip_file.hpp:917
void * m_pPut_buf_user
Definition zip_file.hpp:915
mz_uint8 * m_pLZ_code_buf
Definition zip_file.hpp:919
mz_uint m_dict_size
Definition zip_file.hpp:918
mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
Definition zip_file.hpp:932
size_t * m_pIn_buf_size
Definition zip_file.hpp:925
mz_uint m_adler32
Definition zip_file.hpp:918
mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]
Definition zip_file.hpp:936
mz_uint8 * m_pOutput_buf
Definition zip_file.hpp:919
Definition zip_file.hpp:2788
mz_bool m_expandable
Definition zip_file.hpp:2791
mz_uint8 * m_pBuf
Definition zip_file.hpp:2790
size_t m_capacity
Definition zip_file.hpp:2789
size_t m_size
Definition zip_file.hpp:2789
Definition zip_file.hpp:1870
mz_uint16 m_sym_index
Definition zip_file.hpp:1870
mz_uint16 m_key
Definition zip_file.hpp:1870
Definition zip_file.hpp:809
mz_uint32 m_type
Definition zip_file.hpp:810
mz_uint32 m_final
Definition zip_file.hpp:810
mz_uint32 m_zhdr0
Definition zip_file.hpp:810
tinfl_bit_buf_t m_bit_buf
Definition zip_file.hpp:811
mz_uint32 m_counter
Definition zip_file.hpp:810
size_t m_dist_from_out_buf_start
Definition zip_file.hpp:812
mz_uint32 m_check_adler32
Definition zip_file.hpp:810
mz_uint32 m_state
Definition zip_file.hpp:810
tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]
Definition zip_file.hpp:813
mz_uint8 m_raw_header[4]
Definition zip_file.hpp:814
mz_uint32 m_zhdr1
Definition zip_file.hpp:810
mz_uint32 m_num_bits
Definition zip_file.hpp:810
mz_uint32 m_z_adler32
Definition zip_file.hpp:810
mz_uint32 m_table_sizes[TINFL_MAX_HUFF_TABLES]
Definition zip_file.hpp:810
mz_uint32 m_dist
Definition zip_file.hpp:810
mz_uint8 m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0+TINFL_MAX_HUFF_SYMBOLS_1+137]
Definition zip_file.hpp:814
mz_uint32 m_num_extra
Definition zip_file.hpp:810
Definition zip_file.hpp:791
mz_int16 m_tree[TINFL_MAX_HUFF_SYMBOLS_0 *2]
Definition zip_file.hpp:793
mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]
Definition zip_file.hpp:792
mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE]
Definition zip_file.hpp:793
unsigned long mz_ulong
Definition zip_file.hpp:272
@ MZ_BEST_SPEED
Definition zip_file.hpp:313
@ MZ_NO_COMPRESSION
Definition zip_file.hpp:313
@ MZ_UBER_COMPRESSION
Definition zip_file.hpp:313
@ MZ_DEFAULT_LEVEL
Definition zip_file.hpp:313
@ MZ_BEST_COMPRESSION
Definition zip_file.hpp:313
@ MZ_DEFAULT_COMPRESSION
Definition zip_file.hpp:313
#define MZ_WRITE_LE32(p, v)
Definition zip_file.hpp:4022
#define MZ_FILE_STAT
Definition zip_file.hpp:2992
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
Definition zip_file.hpp:1020
#define MZ_MALLOC(x)
Definition zip_file.hpp:989
mz_zip_flags
Definition zip_file.hpp:601
@ MZ_ZIP_FLAG_COMPRESSED_DATA
Definition zip_file.hpp:604
@ MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY
Definition zip_file.hpp:605
@ MZ_ZIP_FLAG_CASE_SENSITIVE
Definition zip_file.hpp:602
@ MZ_ZIP_FLAG_IGNORE_PATH
Definition zip_file.hpp:603
mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
Definition zip_file.hpp:3978
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
Definition zip_file.hpp:4765
#define MZ_READ_LE16(p)
Definition zip_file.hpp:1002
#define MZ_REALLOC(p, x)
Definition zip_file.hpp:991
void *(* mz_alloc_func)(void *opaque, size_t items, size_t size)
Definition zip_file.hpp:295
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)
Definition zip_file.hpp:2778
struct mz_stream_s mz_stream
void * mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags)
Definition zip_file.hpp:4908
#define TINFL_CR_BEGIN
Definition zip_file.hpp:1406
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
Definition zip_file.hpp:3404
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)
Definition zip_file.hpp:2854
mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning)
Definition zip_file.hpp:4106
#define MZ_WRITE_LE16(p, v)
Definition zip_file.hpp:4021
void * tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
Definition zip_file.hpp:2809
size_t(* mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
Definition zip_file.hpp:565
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
Definition zip_file.hpp:3374
@ TDEFL_DEFAULT_MAX_PROBES
Definition zip_file.hpp:826
@ TDEFL_HUFFMAN_ONLY
Definition zip_file.hpp:826
@ TDEFL_MAX_PROBES_MASK
Definition zip_file.hpp:826
int mz_deflateReset(mz_streamp pStream)
Definition zip_file.hpp:1099
#define TINFL_GET_BYTE(state_index, c)
Definition zip_file.hpp:1413
#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size)
Definition zip_file.hpp:3039
#define MZ_FALSE
Definition zip_file.hpp:521
#define MZ_FORCEINLINE
Definition zip_file.hpp:1011
#define MZ_FFLUSH
Definition zip_file.hpp:2993
int mz_inflateInit(mz_streamp pStream)
Definition zip_file.hpp:1251
int mz_inflate(mz_streamp pStream, int flush)
Definition zip_file.hpp:1256
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
Definition zip_file.hpp:1202
mz_uint32 tdefl_get_adler32(tdefl_compressor *d)
Definition zip_file.hpp:2773
struct mz_zip_internal_state_tag mz_zip_internal_state
Definition zip_file.hpp:568
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 zip_file.hpp:3943
#define TDEFL_RLE_ZERO_CODE_SIZE()
Definition zip_file.hpp:1977
mz_ulong mz_compressBound(mz_ulong source_len)
Definition zip_file.hpp:1207
#define MZ_ASSERT(x)
Definition zip_file.hpp:982
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)
Definition zip_file.hpp:4863
int mz_deflateEnd(mz_streamp pStream)
Definition zip_file.hpp:1156
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)
Definition zip_file.hpp:2818
#define tinfl_init(r)
Definition zip_file.hpp:776
tinfl_status
Definition zip_file.hpp:766
@ TINFL_STATUS_ADLER32_MISMATCH
Definition zip_file.hpp:768
@ TINFL_STATUS_FAILED
Definition zip_file.hpp:769
@ TINFL_STATUS_NEEDS_MORE_INPUT
Definition zip_file.hpp:771
@ TINFL_STATUS_HAS_MORE_OUTPUT
Definition zip_file.hpp:772
@ TINFL_STATUS_BAD_PARAM
Definition zip_file.hpp:767
@ TINFL_STATUS_DONE
Definition zip_file.hpp:770
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index)
Definition zip_file.hpp:4642
#define MZ_FREOPEN(f, m, s)
Definition zip_file.hpp:2994
#define TINFL_LZ_DICT_SIZE
Definition zip_file.hpp:762
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
Definition zip_file.hpp:2749
#define MZ_CLEAR_OBJ(obj)
Definition zip_file.hpp:996
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 zip_file.hpp:1788
#define MZ_DEFLATED
Definition zip_file.hpp:289
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index)
Definition zip_file.hpp:3426
void * tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
Definition zip_file.hpp:1753
unsigned int mz_uint
Definition zip_file.hpp:516
@ TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF
Definition zip_file.hpp:735
@ TINFL_FLAG_HAS_MORE_INPUT
Definition zip_file.hpp:734
@ TINFL_FLAG_COMPUTE_ADLER32
Definition zip_file.hpp:736
@ TINFL_FLAG_PARSE_ZLIB_HEADER
Definition zip_file.hpp:733
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 zip_file.hpp:3590
unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 :-1]
Definition zip_file.hpp:976
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, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32)
Definition zip_file.hpp:4313
#define TINFL_MEMCPY(d, s, l)
Definition zip_file.hpp:1403
#define TINFL_GET_BITS(state_index, b, n)
Definition zip_file.hpp:1431
#define MZ_ADLER32_INIT
Definition zip_file.hpp:277
#define MZ_CRC32_INIT
Definition zip_file.hpp:281
int(* tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)
Definition zip_file.hpp:756
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d)
Definition zip_file.hpp:2768
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size)
Definition zip_file.hpp:4078
#define MZ_FREAD
Definition zip_file.hpp:2987
#define tinfl_get_adler32(r)
Definition zip_file.hpp:777
@ MZ_SYNC_FLUSH
Definition zip_file.hpp:307
@ MZ_BLOCK
Definition zip_file.hpp:307
@ MZ_FULL_FLUSH
Definition zip_file.hpp:307
@ MZ_FINISH
Definition zip_file.hpp:307
@ MZ_PARTIAL_FLUSH
Definition zip_file.hpp:307
@ MZ_NO_FLUSH
Definition zip_file.hpp:307
unsigned long long mz_uint64
Definition zip_file.hpp:518
signed short mz_int16
Definition zip_file.hpp:513
#define TINFL_HUFF_DECODE(state_index, sym, pHuff)
Definition zip_file.hpp:1456
mz_ulong uLong
Definition zip_file.hpp:438
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags)
Definition zip_file.hpp:3343
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 zip_file.hpp:4006
#define MZ_FWRITE
Definition zip_file.hpp:2988
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush)
Definition zip_file.hpp:2744
#define MZ_DEFAULT_WINDOW_BITS
Definition zip_file.hpp:316
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 zip_file.hpp:3780
#define MZ_TOLOWER(c)
Definition zip_file.hpp:2999
@ TDEFL_FORCE_ALL_RAW_BLOCKS
Definition zip_file.hpp:847
@ TDEFL_GREEDY_PARSING_FLAG
Definition zip_file.hpp:842
@ TDEFL_FORCE_ALL_STATIC_BLOCKS
Definition zip_file.hpp:846
@ TDEFL_COMPUTE_ADLER32
Definition zip_file.hpp:841
@ TDEFL_FILTER_MATCHES
Definition zip_file.hpp:845
@ TDEFL_WRITE_ZLIB_HEADER
Definition zip_file.hpp:840
@ TDEFL_NONDETERMINISTIC_PARSING_FLAG
Definition zip_file.hpp:843
@ TDEFL_RLE_MATCHES
Definition zip_file.hpp:844
int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy)
Definition zip_file.hpp:1067
const char * mz_version(void)
Definition zip_file.hpp:1057
#define MZ_VERSION
Definition zip_file.hpp:299
int mz_deflateInit(mz_streamp pStream, int level)
Definition zip_file.hpp:1062
#define MZ_FILE
Definition zip_file.hpp:2984
#define MZ_FSEEK64
Definition zip_file.hpp:2990
@ TDEFL_MAX_HUFF_SYMBOLS
Definition zip_file.hpp:890
@ TDEFL_LEVEL1_HASH_SIZE_MASK
Definition zip_file.hpp:890
@ TDEFL_LZ_HASH_BITS
Definition zip_file.hpp:890
@ TDEFL_LZ_HASH_SIZE
Definition zip_file.hpp:890
@ TDEFL_LZ_CODE_BUF_SIZE
Definition zip_file.hpp:890
@ TDEFL_LZ_HASH_SHIFT
Definition zip_file.hpp:890
@ TDEFL_OUT_BUF_SIZE
Definition zip_file.hpp:890
void * mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags)
Definition zip_file.hpp:3735
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level)
Definition zip_file.hpp:1174
#define MZ_FOPEN(f, m)
Definition zip_file.hpp:2985
mz_bool mz_zip_writer_end(mz_zip_archive *pZip)
Definition zip_file.hpp:4830
void mz_free(void *p)
Definition zip_file.hpp:1046
int intf
Definition zip_file.hpp:442
#define TINFL_MEMSET(p, c, l)
Definition zip_file.hpp:1404
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)
Definition zip_file.hpp:4464
uInt uIntf
Definition zip_file.hpp:440
@ TDEFL_MAX_SUPPORTED_HUFF_CODESIZE
Definition zip_file.hpp:1909
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
Definition zip_file.hpp:3550
char charf
Definition zip_file.hpp:441
unsigned int uInt
Definition zip_file.hpp:437
size_t(* mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
Definition zip_file.hpp:564
int mz_bool
Definition zip_file.hpp:519
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index)
Definition zip_file.hpp:3416
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size)
Definition zip_file.hpp:4024
const char * mz_error(int err)
Definition zip_file.hpp:1388
unsigned char mz_uint8
Definition zip_file.hpp:512
@ MZ_ZIP_CDH_FILENAME_LEN_OFS
Definition zip_file.hpp:3010
@ MZ_ZIP_LOCAL_DIR_HEADER_SIG
Definition zip_file.hpp:3005
@ MZ_ZIP_CDH_FILE_DATE_OFS
Definition zip_file.hpp:3009
@ MZ_ZIP_LDH_CRC32_OFS
Definition zip_file.hpp:3014
@ MZ_ZIP_LDH_BIT_FLAG_OFS
Definition zip_file.hpp:3013
@ MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS
Definition zip_file.hpp:3017
@ MZ_ZIP_CDH_VERSION_NEEDED_OFS
Definition zip_file.hpp:3008
@ MZ_ZIP_CDH_LOCAL_HEADER_OFS
Definition zip_file.hpp:3011
@ MZ_ZIP_CDH_COMPRESSED_SIZE_OFS
Definition zip_file.hpp:3010
@ MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS
Definition zip_file.hpp:3017
@ MZ_ZIP_CDH_SIG_OFS
Definition zip_file.hpp:3008
@ MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS
Definition zip_file.hpp:3010
@ MZ_ZIP_ECDH_CDIR_SIZE_OFS
Definition zip_file.hpp:3018
@ MZ_ZIP_CDH_METHOD_OFS
Definition zip_file.hpp:3009
@ MZ_ZIP_LDH_FILENAME_LEN_OFS
Definition zip_file.hpp:3015
@ MZ_ZIP_LDH_FILE_TIME_OFS
Definition zip_file.hpp:3013
@ MZ_ZIP_CDH_EXTRA_LEN_OFS
Definition zip_file.hpp:3010
@ MZ_ZIP_LDH_FILE_DATE_OFS
Definition zip_file.hpp:3014
@ MZ_ZIP_LDH_METHOD_OFS
Definition zip_file.hpp:3013
@ MZ_ZIP_LDH_COMPRESSED_SIZE_OFS
Definition zip_file.hpp:3014
@ MZ_ZIP_CDH_FILE_TIME_OFS
Definition zip_file.hpp:3009
@ MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS
Definition zip_file.hpp:3018
@ MZ_ZIP_CENTRAL_DIR_HEADER_SIG
Definition zip_file.hpp:3005
@ MZ_ZIP_ECDH_SIG_OFS
Definition zip_file.hpp:3017
@ MZ_ZIP_ECDH_COMMENT_SIZE_OFS
Definition zip_file.hpp:3018
@ MZ_ZIP_LDH_SIG_OFS
Definition zip_file.hpp:3013
@ MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG
Definition zip_file.hpp:3005
@ MZ_ZIP_CDH_CRC32_OFS
Definition zip_file.hpp:3009
@ MZ_ZIP_CDH_DISK_START_OFS
Definition zip_file.hpp:3011
@ MZ_ZIP_CDH_INTERNAL_ATTR_OFS
Definition zip_file.hpp:3011
@ MZ_ZIP_LDH_VERSION_NEEDED_OFS
Definition zip_file.hpp:3013
@ MZ_ZIP_ECDH_CDIR_OFS_OFS
Definition zip_file.hpp:3018
@ MZ_ZIP_LDH_EXTRA_LEN_OFS
Definition zip_file.hpp:3015
@ MZ_ZIP_CDH_EXTERNAL_ATTR_OFS
Definition zip_file.hpp:3011
@ MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE
Definition zip_file.hpp:3006
@ MZ_ZIP_LOCAL_DIR_HEADER_SIZE
Definition zip_file.hpp:3006
@ MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS
Definition zip_file.hpp:3014
@ MZ_ZIP_CDH_BIT_FLAG_OFS
Definition zip_file.hpp:3008
@ MZ_ZIP_CDH_COMMENT_LEN_OFS
Definition zip_file.hpp:3011
@ MZ_ZIP_CENTRAL_DIR_HEADER_SIZE
Definition zip_file.hpp:3006
@ MZ_ZIP_CDH_VERSION_MADE_BY_OFS
Definition zip_file.hpp:3008
@ MZ_ZIP_ECDH_NUM_THIS_DISK_OFS
Definition zip_file.hpp:3017
int mz_inflateInit2(mz_streamp pStream, int window_bits)
Definition zip_file.hpp:1220
#define TINFL_CR_FINISH
Definition zip_file.hpp:1409
@ MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE
Definition zip_file.hpp:539
@ MZ_ZIP_MAX_IO_BUF_SIZE
Definition zip_file.hpp:537
@ MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE
Definition zip_file.hpp:538
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 zip_file.hpp:3725
#define TINFL_CR_RETURN(state_index, result)
Definition zip_file.hpp:1407
#define TINFL_CR_RETURN_FOREVER(state_index, result)
Definition zip_file.hpp:1408
tdefl_flush
Definition zip_file.hpp:904
@ TDEFL_SYNC_FLUSH
Definition zip_file.hpp:906
@ TDEFL_NO_FLUSH
Definition zip_file.hpp:905
@ TDEFL_FULL_FLUSH
Definition zip_file.hpp:907
@ TDEFL_FINISH
Definition zip_file.hpp:908
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
Definition zip_file.hpp:1359
#define UPDC32(octet, crc)
mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags)
Definition zip_file.hpp:3320
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
Definition zip_file.hpp:3451
unsigned int mz_uint32
Definition zip_file.hpp:515
unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 :-1]
Definition zip_file.hpp:977
int mz_inflateEnd(mz_streamp pStream)
Definition zip_file.hpp:1347
void *(* mz_realloc_func)(void *opaque, void *address, size_t items, size_t size)
Definition zip_file.hpp:297
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)
Definition zip_file.hpp:4187
void * mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags)
Definition zip_file.hpp:3769
int mz_deflate(mz_streamp pStream, int flush)
Definition zip_file.hpp:1107
unsigned short mz_uint16
Definition zip_file.hpp:514
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 zip_file.hpp:3730
#define MZ_FILE_STAT_STRUCT
Definition zip_file.hpp:2991
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED
Definition zip_file.hpp:751
#define MZ_MIN(a, b)
Definition zip_file.hpp:995
tdefl_status
Definition zip_file.hpp:895
@ TDEFL_STATUS_OKAY
Definition zip_file.hpp:898
@ TDEFL_STATUS_DONE
Definition zip_file.hpp:899
@ TDEFL_STATUS_BAD_PARAM
Definition zip_file.hpp:896
@ TDEFL_STATUS_PUT_BUF_FAILED
Definition zip_file.hpp:897
void(* mz_free_func)(void *opaque, void *address)
Definition zip_file.hpp:296
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 zip_file.hpp:3717
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 zip_file.hpp:1781
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 zip_file.hpp:1476
#define MZ_SWAP_UINT32(a, b)
Definition zip_file.hpp:3176
Byte Bytef
Definition zip_file.hpp:439
#define MZ_FREE(x)
Definition zip_file.hpp:990
struct mz_zip_archive_tag mz_zip_archive
#define MZ_FCLOSE
Definition zip_file.hpp:2986
void * voidpf
Definition zip_file.hpp:443
void * tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out)
Definition zip_file.hpp:2883
mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len)
Definition zip_file.hpp:1167
mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len)
Definition zip_file.hpp:1036
uLong uLongf
Definition zip_file.hpp:444
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy)
Definition zip_file.hpp:2831
@ TDEFL_MAX_MATCH_LEN
Definition zip_file.hpp:884
@ TDEFL_MAX_HUFF_TABLES
Definition zip_file.hpp:884
@ TDEFL_MAX_HUFF_SYMBOLS_0
Definition zip_file.hpp:884
@ TDEFL_LZ_DICT_SIZE_MASK
Definition zip_file.hpp:884
@ TDEFL_LZ_DICT_SIZE
Definition zip_file.hpp:884
@ TDEFL_MIN_MATCH_LEN
Definition zip_file.hpp:884
@ TDEFL_MAX_HUFF_SYMBOLS_1
Definition zip_file.hpp:884
@ TDEFL_MAX_HUFF_SYMBOLS_2
Definition zip_file.hpp:884
#define MZ_READ_LE32(p)
Definition zip_file.hpp:1003
struct tinfl_decompressor_tag tinfl_decompressor
Definition zip_file.hpp:759
#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index)
Definition zip_file.hpp:3040
mz_zip_mode
Definition zip_file.hpp:571
@ MZ_ZIP_MODE_WRITING
Definition zip_file.hpp:574
@ MZ_ZIP_MODE_READING
Definition zip_file.hpp:573
@ MZ_ZIP_MODE_INVALID
Definition zip_file.hpp:572
@ MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED
Definition zip_file.hpp:575
mz_bool(* tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)
Definition zip_file.hpp:879
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize)
Definition zip_file.hpp:4814
unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 :-1]
Definition zip_file.hpp:975
@ MZ_MEM_ERROR
Definition zip_file.hpp:310
@ MZ_PARAM_ERROR
Definition zip_file.hpp:310
@ MZ_NEED_DICT
Definition zip_file.hpp:310
@ MZ_VERSION_ERROR
Definition zip_file.hpp:310
@ MZ_STREAM_END
Definition zip_file.hpp:310
@ MZ_ERRNO
Definition zip_file.hpp:310
@ MZ_OK
Definition zip_file.hpp:310
@ MZ_BUF_ERROR
Definition zip_file.hpp:310
@ MZ_STREAM_ERROR
Definition zip_file.hpp:310
@ MZ_DATA_ERROR
Definition zip_file.hpp:310
unsigned char Byte
Definition zip_file.hpp:436
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)
Definition zip_file.hpp:2688
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename)
Definition zip_file.hpp:4137
mz_stream * mz_streamp
Definition zip_file.hpp:343
#define MZ_MAX(a, b)
Definition zip_file.hpp:994
#define TINFL_SKIP_BITS(state_index, n)
Definition zip_file.hpp:1430
@ MZ_FILTERED
Definition zip_file.hpp:286
@ MZ_FIXED
Definition zip_file.hpp:286
@ MZ_DEFAULT_STRATEGY
Definition zip_file.hpp:286
@ MZ_RLE
Definition zip_file.hpp:286
@ MZ_HUFFMAN_ONLY
Definition zip_file.hpp:286
#define MZ_TRUE
Definition zip_file.hpp:522
long long mz_int64
Definition zip_file.hpp:517
void * voidp
Definition zip_file.hpp:445
#define TDEFL_RLE_PREV_CODE_SIZE()
Definition zip_file.hpp:1969
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
Definition zip_file.hpp:3957
@ TINFL_MAX_HUFF_SYMBOLS_2
Definition zip_file.hpp:786
@ TINFL_FAST_LOOKUP_SIZE
Definition zip_file.hpp:787
@ TINFL_MAX_HUFF_SYMBOLS_0
Definition zip_file.hpp:786
@ TINFL_MAX_HUFF_SYMBOLS_1
Definition zip_file.hpp:786
@ TINFL_MAX_HUFF_TABLES
Definition zip_file.hpp:786
@ TINFL_FAST_LOOKUP_BITS
Definition zip_file.hpp:787
#define MZ_FTELL64
Definition zip_file.hpp:2989
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
Definition zip_file.hpp:3486
mz_uint32 tinfl_bit_buf_t
Definition zip_file.hpp:804
#define TDEFL_PUT_BITS(b, l)
Definition zip_file.hpp:1958
#define MZ_DELETE_FILE
Definition zip_file.hpp:2995
void *const voidpc
Definition zip_file.hpp:446