160 #ifndef MINIZ_HEADER_INCLUDED 161 #define MINIZ_HEADER_INCLUDED 194 #if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) 196 #define MINIZ_NO_TIME 199 #if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) 203 #if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) 205 #define MINIZ_X86_OR_X64_CPU 1 208 #if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU 210 #define MINIZ_LITTLE_ENDIAN 1 213 #if MINIZ_X86_OR_X64_CPU 215 #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 218 #if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__) 220 #define MINIZ_HAS_64BIT_REGISTERS 1 224 #define ftello64 ftello 225 #define fseeko64 fseeko 226 #define fopen64 fopen 227 #define freopen64 freopen 242 #define MZ_ADLER32_INIT (1) 246 #define MZ_CRC32_INIT (0) 254 #define MZ_DEFLATED 8 256 #ifndef MINIZ_NO_ZLIB_APIS 260 typedef void *(*mz_alloc_func)(
void *opaque,
size_t items,
size_t size);
262 typedef void *(*mz_realloc_func)(
void *opaque,
void *address,
size_t items,
size_t size);
264 #define MZ_VERSION "9.1.15" 265 #define MZ_VERNUM 0x91F0 266 #define MZ_VER_MAJOR 9 267 #define MZ_VER_MINOR 1 268 #define MZ_VER_REVISION 15 269 #define MZ_VER_SUBREVISION 0 281 #define MZ_DEFAULT_WINDOW_BITS 15 283 struct mz_internal_state;
400 #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES 413 #define Z_NO_FLUSH MZ_NO_FLUSH 414 #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH 415 #define Z_SYNC_FLUSH MZ_SYNC_FLUSH 416 #define Z_FULL_FLUSH MZ_FULL_FLUSH 417 #define Z_FINISH MZ_FINISH 418 #define Z_BLOCK MZ_BLOCK 420 #define Z_STREAM_END MZ_STREAM_END 421 #define Z_NEED_DICT MZ_NEED_DICT 422 #define Z_ERRNO MZ_ERRNO 423 #define Z_STREAM_ERROR MZ_STREAM_ERROR 424 #define Z_DATA_ERROR MZ_DATA_ERROR 425 #define Z_MEM_ERROR MZ_MEM_ERROR 426 #define Z_BUF_ERROR MZ_BUF_ERROR 427 #define Z_VERSION_ERROR MZ_VERSION_ERROR 428 #define Z_PARAM_ERROR MZ_PARAM_ERROR 429 #define Z_NO_COMPRESSION MZ_NO_COMPRESSION 430 #define Z_BEST_SPEED MZ_BEST_SPEED 431 #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION 432 #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION 433 #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY 434 #define Z_FILTERED MZ_FILTERED 435 #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY 437 #define Z_FIXED MZ_FIXED 438 #define Z_DEFLATED MZ_DEFLATED 439 #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS 440 #define alloc_func mz_alloc_func 441 #define free_func mz_free_func 442 #define internal_state mz_internal_state 443 #define z_stream mz_stream 444 #define deflateInit mz_deflateInit 445 #define deflateInit2 mz_deflateInit2 446 #define deflateReset mz_deflateReset 447 #define deflate mz_deflate 448 #define deflateEnd mz_deflateEnd 449 #define deflateBound mz_deflateBound 450 #define compress mz_compress 451 #define compress2 mz_compress2 452 #define compressBound mz_compressBound 453 #define inflateInit mz_inflateInit 454 #define inflateInit2 mz_inflateInit2 455 #define inflate mz_inflate 456 #define inflateEnd mz_inflateEnd 457 #define uncompress mz_uncompress 458 #define crc32 mz_crc32 459 #define adler32 mz_adler32 461 #define MAX_MEM_LEVEL 9 462 #define zError mz_error 463 #define ZLIB_VERSION MZ_VERSION 464 #define ZLIB_VERNUM MZ_VERNUM 465 #define ZLIB_VER_MAJOR MZ_VER_MAJOR 466 #define ZLIB_VER_MINOR MZ_VER_MINOR 467 #define ZLIB_VER_REVISION MZ_VER_REVISION 468 #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION 469 #define zlibVersion mz_version 470 #define zlib_version mz_version() 471 #endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES 473 #endif // MINIZ_NO_ZLIB_APIS 491 #define MZ_MACRO_END while (0, 0) 493 #define MZ_MACRO_END while (0) 498 #ifndef MINIZ_NO_ARCHIVE_APIS 515 #ifndef MINIZ_NO_TIME 580 #ifndef MINIZ_NO_STDIO 619 #ifndef MINIZ_NO_STDIO 631 #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS 637 #ifndef MINIZ_NO_STDIO 655 #ifndef MINIZ_NO_STDIO 685 #endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS 687 #endif // #ifndef MINIZ_NO_ARCHIVE_APIS 716 #define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) 727 #define TINFL_LZ_DICT_SIZE 32768 741 #define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END 742 #define tinfl_get_adler32(r) (r)->m_check_adler32 761 #if MINIZ_HAS_64BIT_REGISTERS 762 #define TINFL_USE_64BIT_BITBUF 1 765 #if TINFL_USE_64BIT_BITBUF 767 #define TINFL_BITBUF_SIZE (64) 770 #define TINFL_BITBUF_SIZE (32) 775 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];
785 #define TDEFL_LESS_MEMORY 0 828 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);
852 #if TDEFL_LESS_MEMORY 886 mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index,
m_wants_to_finish;
922 #ifndef MINIZ_NO_ZLIB_APIS 928 #endif // #ifndef MINIZ_NO_ZLIB_APIS 934 #endif // MINIZ_HEADER_INCLUDED 938 #ifndef MINIZ_HEADER_FILE_ONLY 947 #define MZ_ASSERT(x) assert(x) 949 #ifdef MINIZ_NO_MALLOC 950 #define MZ_MALLOC(x) NULL 951 #define MZ_FREE(x) (void)x, ((void)0) 952 #define MZ_REALLOC(p, x) NULL 954 #define MZ_MALLOC(x) malloc(x) 955 #define MZ_FREE(x) free(x) 956 #define MZ_REALLOC(p, x) realloc(p, x) 959 #define MZ_MAX(a,b) (((a)>(b))?(a):(b)) 960 #define MZ_MIN(a,b) (((a)<(b))?(a):(b)) 961 #define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) 963 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN 964 #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) 965 #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) 967 #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) 968 #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)) 972 #define MZ_FORCEINLINE __forceinline 973 #elif defined(__GNUC__) 974 #define MZ_FORCEINLINE inline __attribute__((__always_inline__)) 976 #define MZ_FORCEINLINE inline 990 for (i = 0; i + 7 < block_len; i += 8, ptr += 8) {
991 s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1;
992 s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1;
994 for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1;
995 s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552;
997 return (s2 << 16) + s1;
1003 static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
1004 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c };
1007 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)]; }
1016 #ifndef MINIZ_NO_ZLIB_APIS 1018 static void *
def_alloc_func(
void *opaque,
size_t items,
size_t size) { (void)opaque, (
void)items, (void)size;
return MZ_MALLOC(items * size); }
1020 static 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); }
1053 pStream->
state = (
struct mz_internal_state *)pComp;
1074 size_t in_bytes, out_bytes;
1075 mz_ulong orig_total_in, orig_total_out;
1076 int mz_status =
MZ_OK;
1099 if (defl_status < 0)
1113 if ((flush) || (pStream->
total_in != orig_total_in) || (pStream->
total_out != orig_total_out))
1136 return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);
1143 memset(&stream, 0,
sizeof(stream));
1146 if ((source_len | *pDest_len) > 0xFFFFFFFFU)
return MZ_PARAM_ERROR;
1154 if (status !=
MZ_OK)
return status;
1203 pStream->
state = (
struct mz_internal_state *)pDecomp;
1225 size_t in_bytes, out_bytes, orig_avail_in;
1242 if ((flush ==
MZ_FINISH) && (first_call))
1328 memset(&stream, 0,
sizeof(stream));
1331 if ((source_len | *pDest_len) > 0xFFFFFFFFU)
return MZ_PARAM_ERROR;
1339 if (status !=
MZ_OK)
1355 static struct {
int m_err;
const char *m_pDesc; } s_error_descs[] =
1357 {
MZ_OK,
"" }, {
MZ_STREAM_END,
"stream end" }, {
MZ_NEED_DICT,
"need dictionary" }, {
MZ_ERRNO,
"file error" }, {
MZ_STREAM_ERROR,
"stream error" },
1360 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;
1364 #endif //MINIZ_NO_ZLIB_APIS 1368 #define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) 1369 #define TINFL_MEMSET(p, c, l) memset(p, c, l) 1371 #define TINFL_CR_BEGIN switch(r->m_state) { case 0: 1372 #define TINFL_CR_RETURN(state_index, result) do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END 1373 #define TINFL_CR_RETURN_FOREVER(state_index, result) do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END 1374 #define TINFL_CR_FINISH } 1378 #define TINFL_GET_BYTE(state_index, c) do { \ 1379 if (pIn_buf_cur >= pIn_buf_end) { \ 1381 if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { \ 1382 TINFL_CR_RETURN(state_index, TINFL_STATUS_NEEDS_MORE_INPUT); \ 1383 if (pIn_buf_cur < pIn_buf_end) { \ 1384 c = *pIn_buf_cur++; \ 1392 } else c = *pIn_buf_cur++; } MZ_MACRO_END 1394 #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)) 1395 #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 1396 #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 1402 #define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \ 1404 temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ 1406 code_len = temp >> 9; \ 1407 if ((code_len) && (num_bits >= code_len)) \ 1409 } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ 1410 code_len = TINFL_FAST_LOOKUP_BITS; \ 1412 temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ 1413 } while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \ 1414 } TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \ 1415 } while (num_bits < 15); 1421 #define TINFL_HUFF_DECODE(state_index, sym, pHuff) do { \ 1422 int temp; mz_uint code_len, c; \ 1423 if (num_bits < 15) { \ 1424 if ((pIn_buf_end - pIn_buf_cur) < 2) { \ 1425 TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \ 1427 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; \ 1430 if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \ 1431 code_len = temp >> 9, temp &= 511; \ 1433 code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \ 1434 } sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END 1438 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 };
1439 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 };
1440 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};
1441 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};
1442 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 };
1443 static const int s_min_table_sizes[3] = { 257, 1, 4 };
1446 const mz_uint8 *pIn_buf_cur = pIn_buf_next, *
const pIn_buf_end = pIn_buf_next + *pIn_buf_size;
1447 mz_uint8 *pOut_buf_cur = pOut_buf_next, *
const pOut_buf_end = pOut_buf_next + *pOut_buf_size;
1451 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; }
1473 while ((counter) && (num_bits))
1483 while (pIn_buf_cur >= pIn_buf_end)
1494 n =
MZ_MIN(
MZ_MIN((
size_t)(pOut_buf_end - pOut_buf_cur), (
size_t)(pIn_buf_end - pIn_buf_cur)), counter);
1495 TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (
mz_uint)n;
1508 for ( i = 0; i <= 143; ++i) {
1511 for ( ; i <= 255; ++i) {
1514 for ( ; i <= 279; ++i) {
1517 for ( ; i <= 287; ++i) {
1532 used_syms = 0, total = 0; next_code[0] = next_code[1] = 0;
1533 for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); }
1534 if ((65536 != total) && (used_syms > 1))
1540 mz_uint rev_code = 0, l, cur_code, code_size = pTable->
m_code_size[sym_index];
if (!code_size)
continue;
1541 cur_code = next_code[code_size]++;
for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1);
1547 tree_cur -= ((rev_code >>= 1) & 1);
1548 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];
1550 tree_cur -= ((rev_code >>= 1) & 1); pTable->
m_tree[-tree_cur - 1] = (
mz_int16)sym_index;
1557 if ((dist == 16) && (!counter))
1561 num_extra =
"\02\03\07"[dist - 16];
TINFL_GET_BITS(18, s, num_extra); s +=
"\03\03\013"[dist - 16];
1576 if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2))
1582 *pOut_buf_cur++ = (
mz_uint8)counter;
1587 #if TINFL_USE_64BIT_BITBUF 1593 code_len = sym2 >> 9;
1598 counter = sym2; bit_buf >>= code_len; num_bits -= code_len;
1602 #if !TINFL_USE_64BIT_BITBUF 1606 code_len = sym2 >> 9;
1611 bit_buf >>= code_len; num_bits -= code_len;
1613 pOut_buf_cur[0] = (
mz_uint8)counter;
1624 if ((counter &= 511) == 256)
break;
1626 num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257];
1627 if (num_extra) {
mz_uint extra_bits;
TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; }
1630 num_extra = s_dist_extra[dist]; dist = s_dist_base[dist];
1631 if (num_extra) {
mz_uint extra_bits;
TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; }
1633 dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;
1639 pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask);
1641 if ((
MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end)
1646 *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask];
1650 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1651 else if ((counter >= 9) && (counter <= dist))
1653 const mz_uint8 *pSrc_end = pSrc + (counter & ~7);
1659 }
while ((pSrc += 8) < pSrc_end);
1660 if ((counter &= 7) < 3)
1664 pOut_buf_cur[0] = pSrc[0];
1666 pOut_buf_cur[1] = pSrc[1];
1667 pOut_buf_cur += counter;
1675 pOut_buf_cur[0] = pSrc[0];
1676 pOut_buf_cur[1] = pSrc[1];
1677 pOut_buf_cur[2] = pSrc[2];
1678 pOut_buf_cur += 3; pSrc += 3;
1679 }
while ((
int)(counter -= 3) > 2);
1680 if ((
int)counter > 0)
1682 pOut_buf_cur[0] = pSrc[0];
1683 if ((
int)counter > 1)
1684 pOut_buf_cur[1] = pSrc[1];
1685 pOut_buf_cur += counter;
1699 *pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next;
1702 const mz_uint8 *ptr = pOut_buf_next;
size_t buf_len = *pOut_buf_size;
1706 for (i = 0; i + 7 < block_len; i += 8, ptr += 8)
1708 s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1;
1709 s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1;
1711 for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1;
1712 s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552;
1727 size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;
1734 src_buf_ofs += src_buf_size;
1735 *pOut_len += dst_buf_size;
1737 new_out_buf_capacity = out_buf_capacity * 2;
if (new_out_buf_capacity < 128) new_out_buf_capacity = 128;
1738 pNew_buf =
MZ_REALLOC(pBuf, new_out_buf_capacity);
1743 pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity;
1765 size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size =
TINFL_LZ_DICT_SIZE - dict_ofs;
1768 in_buf_ofs += in_buf_size;
1769 if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (
int)dst_buf_size, pPut_buf_user)))
1779 *pIn_buf_size = in_buf_ofs;
1787 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,
1788 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,
1789 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,
1790 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,
1791 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,
1792 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,
1793 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,
1794 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 };
1797 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,
1798 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,
1799 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,
1800 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 };
1803 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,
1804 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,
1805 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,
1806 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,
1807 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,
1808 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,
1809 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,
1810 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,
1811 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,
1812 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,
1813 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,
1814 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 };
1817 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,
1818 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,
1819 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,
1820 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,
1821 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,
1822 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,
1823 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,
1827 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,
1828 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,
1829 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 };
1832 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,
1833 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,
1834 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 };
1841 for (i = 0; i < num_syms; i++) {
mz_uint freq = pSyms0[i].
m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; }
1842 while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--;
1843 for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8)
1845 const mz_uint32* pHist = &hist[pass << 8];
1846 mz_uint offsets[256], cur_ofs = 0;
1847 for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; }
1848 for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i];
1849 {
tdefl_sym_freq* t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; }
1857 int root, leaf, next, avbl, used, dpth;
1858 if (n==0)
return;
else if (n==1) { A[0].
m_key = 1;
return; }
1859 A[0].
m_key += A[1].
m_key; root = 0; leaf = 2;
1860 for (next=1; next < n-1; next++)
1863 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);
1865 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;
1866 avbl = 1; used = dpth = 0; root = n-2; next = n-1;
1869 while (root>=0 && (
int)A[root].
m_key==dpth) { used++; root--; }
1870 while (avbl>used) { A[next--].
m_key = (
mz_uint16)(dpth); avbl--; }
1871 avbl = 2*used; dpth++; used = 0;
1879 int i;
mz_uint32 total = 0;
if (code_list_len <= 1)
return;
1881 for (i = max_code_size; i > 0; i--) total += (((
mz_uint32)pNum_codes[i]) << (max_code_size - i));
1882 while (total != (1UL << max_code_size))
1884 pNum_codes[max_code_size]--;
1885 for (i = max_code_size - 1; i > 0; i--)
if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2;
break; }
1895 for (i = 0; i < table_len; i++) num_codes[d->
m_huff_code_sizes[table_num][i]]++;
1900 int num_used_syms = 0;
1906 for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++;
1911 for (i = 1, j = num_used_syms; i <= code_size_limit; i++)
1915 next_code[1] = 0;
for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1);
1917 for (i = 0; i < table_len; i++)
1920 code = next_code[code_size]++;
for (l = code_size; l > 0; l--,
code >>= 1) rev_code = (rev_code << 1) | (
code & 1);
1925 #define TDEFL_PUT_BITS(b, l) do { \ 1926 mz_uint bits = b; mz_uint len = l; MZ_ASSERT(bits <= ((1U << len) - 1U)); \ 1927 d->m_bit_buffer |= (bits << d->m_bits_in); d->m_bits_in += len; \ 1928 while (d->m_bits_in >= 8) { \ 1929 if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ 1930 *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ 1931 d->m_bit_buffer >>= 8; \ 1932 d->m_bits_in -= 8; \ 1936 #define TDEFL_RLE_PREV_CODE_SIZE() { if (rle_repeat_count) { \ 1937 if (rle_repeat_count < 3) { \ 1938 d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ 1939 while (rle_repeat_count--) packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ 1941 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); \ 1942 } rle_repeat_count = 0; } } 1944 #define TDEFL_RLE_ZERO_CODE_SIZE() { if (rle_z_count) { \ 1945 if (rle_z_count < 3) { \ 1946 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; \ 1947 } else if (rle_z_count <= 10) { \ 1948 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); \ 1950 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); \ 1951 } rle_z_count = 0; } } 1953 static 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 };
1957 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;
1965 for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--)
if (d->
m_huff_code_sizes[0][num_lit_codes - 1])
break;
1966 for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--)
if (d->
m_huff_code_sizes[1][num_dist_codes - 1])
break;
1970 total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0;
1973 for (i = 0; i < total_code_sizes_to_pack; i++)
1975 mz_uint8 code_size = code_sizes_to_pack[i];
1984 if (code_size != prev_code_size)
1989 else if (++rle_repeat_count == 6)
1994 prev_code_size = code_size;
2009 for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes; )
2022 for (i = 0; i <= 143; ++i) *p++ = 8;
2023 for ( ; i <= 255; ++i) *p++ = 9;
2024 for ( ; i <= 279; ++i) *p++ = 7;
2025 for ( ; i <= 287; ++i) *p++ = 8;
2035 static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
2037 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS 2047 #define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); } 2050 for (pLZ_codes = d->
m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1)
2053 flags = *pLZ_codes++ | 0x100;
2057 mz_uint s0, s1, n0, n1, sym, num_extra_bits;
2058 mz_uint match_len = pLZ_codes[0], match_dist = *(
const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3;
2069 sym = (match_dist < 512) ? s0 : s1;
2070 num_extra_bits = (match_dist < 512) ? n0 : n1;
2074 TDEFL_PUT_BITS_FAST(match_dist &
mz_bitmasks[num_extra_bits], num_extra_bits);
2082 if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
2089 if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
2103 pOutput_buf += (bits_in >> 3);
2104 bit_buffer >>= (bits_in & ~7);
2108 #undef TDEFL_PUT_BITS_FAST 2133 for (pLZ_codes = d->
m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1)
2136 flags = *pLZ_codes++ | 0x100;
2140 mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3;
2146 if (match_dist < 512)
2170 #endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS 2183 mz_uint saved_bit_buf, saved_bits_in;
2228 else if (!comp_block_succeeded)
2267 if ((n -= bytes_to_copy) != 0)
2282 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES 2283 #define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16*)(p) 2289 mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->
m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s);
2295 if (--num_probes_left == 0)
return;
2296 #define TDEFL_PROBE \ 2297 next_probe_pos = d->m_next[probe_pos]; \ 2298 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ 2299 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ 2300 if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break; 2306 q = (
const mz_uint16*)(d->
m_dict + probe_pos);
if (TDEFL_READ_UNALIGNED_WORD(q) != s01)
continue; p = s; probe_len = 32;
2307 do { }
while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
2308 (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
2315 *pMatch_dist = dist;
if ((*pMatch_len = match_len =
MZ_MIN(max_match_len, probe_len)) == max_match_len)
break;
2316 c01 = TDEFL_READ_UNALIGNED_WORD(&d->
m_dict[pos + match_len - 1]);
2332 if (--num_probes_left == 0)
return;
2333 #define TDEFL_PROBE \ 2334 next_probe_pos = d->m_next[probe_pos]; \ 2335 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ 2336 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ 2337 if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break; 2340 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;
2341 if (probe_len > match_len)
2343 *pMatch_dist = dist;
if ((*pMatch_len = match_len = probe_len) == max_match_len)
return;
2344 c0 = d->
m_dict[pos + match_len]; c1 = d->
m_dict[pos + match_len - 1];
2348 #endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES 2350 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN 2360 const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;
2364 lookahead_size += num_bytes_to_process;
2366 while (num_bytes_to_process)
2374 num_bytes_to_process -= n;
2378 if ((!d->
m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE))
break;
2380 while (lookahead_size >= 4)
2382 mz_uint cur_match_dist, cur_match_len = 1;
2394 do { }
while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
2395 (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
2403 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
2404 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
2410 cur_match_len =
MZ_MIN(cur_match_len, lookahead_size);
2419 *pLZ_flags = (
mz_uint8)((*pLZ_flags >> 1) | 0x80);
2423 d->
m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;
2430 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
2431 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
2435 if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }
2437 total_lz_bytes += cur_match_len;
2438 lookahead_pos += cur_match_len;
2441 MZ_ASSERT(lookahead_size >= cur_match_len);
2442 lookahead_size -= cur_match_len;
2455 while (lookahead_size)
2460 *pLZ_code_buf++ = lit;
2461 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
2462 if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }
2487 #endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN 2526 mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos;
2533 const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process;
2534 src_buf_left -= num_bytes_to_process;
2536 while (pSrc != pSrc_end)
2573 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++; }
2583 cur_match_dist = cur_match_len = 0;
2590 if (cur_match_len >= 128)
2606 else if (!cur_match_dist)
2611 len_to_move = cur_match_len;
2662 if (pIn_buf_size) *pIn_buf_size = 0;
2663 if (pOut_buf_size) *pOut_buf_size = 0;
2674 (d->
m_wants_to_finish && (flush !=
TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) )
2676 if (pIn_buf_size) *pIn_buf_size = 0;
2677 if (pOut_buf_size) *pOut_buf_size = 0;
2685 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN 2690 if (!tdefl_compress_fast(d))
2694 #endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN 2723 d->
m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3;
2754 MZ_FREE(pComp);
return succeeded;
2767 size_t new_size = p->
m_size + len;
2771 do { new_capacity =
MZ_MAX(128U, new_capacity << 1U); }
while (new_size > new_capacity);
2782 if (!pOut_len)
return MZ_FALSE;
else *pOut_len = 0;
2791 if (!pOut_buf)
return 0;
2797 #ifndef MINIZ_NO_ZLIB_APIS 2798 static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2814 #endif //MINIZ_NO_ZLIB_APIS 2817 #pragma warning (push) 2818 #pragma warning (disable:4204) // nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal) 2827 static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2829 if (!pComp)
return NULL;
2838 *pLen_out = out_buf.
m_size-41;
2840 static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06};
2841 mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
2842 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,
2845 memcpy(out_buf.
m_pBuf, pnghdr, 41);
2860 #pragma warning (pop) 2865 #ifndef MINIZ_NO_ARCHIVE_APIS 2867 #ifdef MINIZ_NO_STDIO 2868 #define MZ_FILE void * 2871 #include <sys/stat.h> 2873 #if defined(_MSC_VER) || defined(__MINGW64__) 2874 static FILE *mz_fopen(
const char *pFilename,
const char *pMode)
2877 fopen_s(&pFile, pFilename, pMode);
2880 static FILE *mz_freopen(
const char *pPath,
const char *pMode, FILE *pStream)
2883 if (freopen_s(&pFile, pPath, pMode, pStream))
2887 #ifndef MINIZ_NO_TIME 2888 #include <sys/utime.h> 2890 #define MZ_FILE FILE 2891 #define MZ_FOPEN mz_fopen 2892 #define MZ_FCLOSE fclose 2893 #define MZ_FREAD fread 2894 #define MZ_FWRITE fwrite 2895 #define MZ_FTELL64 _ftelli64 2896 #define MZ_FSEEK64 _fseeki64 2897 #define MZ_FILE_STAT_STRUCT _stat 2898 #define MZ_FILE_STAT _stat 2899 #define MZ_FFLUSH fflush 2900 #define MZ_FREOPEN mz_freopen 2901 #define MZ_DELETE_FILE remove 2902 #elif defined(__MINGW32__) 2903 #ifndef MINIZ_NO_TIME 2904 #include <sys/utime.h> 2906 #define MZ_FILE FILE 2907 #define MZ_FOPEN(f, m) fopen(f, m) 2908 #define MZ_FCLOSE fclose 2909 #define MZ_FREAD fread 2910 #define MZ_FWRITE fwrite 2911 #define MZ_FTELL64 ftello64 2912 #define MZ_FSEEK64 fseeko64 2913 #define MZ_FILE_STAT_STRUCT _stat 2914 #define MZ_FILE_STAT _stat 2915 #define MZ_FFLUSH fflush 2916 #define MZ_FREOPEN(f, m, s) freopen(f, m, s) 2917 #define MZ_DELETE_FILE remove 2918 #elif defined(__TINYC__) 2919 #ifndef MINIZ_NO_TIME 2920 #include <sys/utime.h> 2922 #define MZ_FILE FILE 2923 #define MZ_FOPEN(f, m) fopen(f, m) 2924 #define MZ_FCLOSE fclose 2925 #define MZ_FREAD fread 2926 #define MZ_FWRITE fwrite 2927 #define MZ_FTELL64 ftell 2928 #define MZ_FSEEK64 fseek 2929 #define MZ_FILE_STAT_STRUCT stat 2930 #define MZ_FILE_STAT stat 2931 #define MZ_FFLUSH fflush 2932 #define MZ_FREOPEN(f, m, s) freopen(f, m, s) 2933 #define MZ_DELETE_FILE remove 2934 #elif defined(__GNUC__) && _LARGEFILE64_SOURCE 2935 #ifndef MINIZ_NO_TIME 2938 #define MZ_FILE FILE 2939 #define MZ_FOPEN(f, m) fopen64(f, m) 2940 #define MZ_FCLOSE fclose 2941 #define MZ_FREAD fread 2942 #define MZ_FWRITE fwrite 2943 #define MZ_FTELL64 ftello64 2944 #define MZ_FSEEK64 fseeko64 2945 #define MZ_FILE_STAT_STRUCT stat64 2946 #define MZ_FILE_STAT stat64 2947 #define MZ_FFLUSH fflush 2948 #define MZ_FREOPEN(p, m, s) freopen64(p, m, s) 2949 #define MZ_DELETE_FILE remove 2951 #ifndef MINIZ_NO_TIME 2954 #define MZ_FILE FILE 2955 #define MZ_FOPEN(f, m) fopen(f, m) 2956 #define MZ_FCLOSE fclose 2957 #define MZ_FREAD fread 2958 #define MZ_FWRITE fwrite 2959 #define MZ_FTELL64 ftello 2960 #define MZ_FSEEK64 fseeko 2961 #define MZ_FILE_STAT_STRUCT stat 2962 #define MZ_FILE_STAT stat 2963 #define MZ_FFLUSH fflush 2964 #define MZ_FREOPEN(f, m, s) freopen(f, m, s) 2965 #define MZ_DELETE_FILE remove 2966 #endif // #ifdef _MSC_VER 2967 #endif // #ifdef MINIZ_NO_STDIO 2969 #define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) 3009 #define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size 3010 #define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index] 3021 if (growing) { new_capacity =
MZ_MAX(1, pArray->
m_capacity);
while (new_capacity < min_new_capacity) new_capacity *= 2; }
3036 pArray->
m_size = new_size;
3055 #ifndef MINIZ_NO_TIME 3059 memset(&tm, 0,
sizeof(tm)); tm.tm_isdst = -1;
3060 tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31;
3061 tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62;
3068 struct tm tm_struct;
3069 struct tm *tm = &tm_struct;
3070 errno_t err = localtime_s(tm, &time);
3073 *pDOS_date = 0; *pDOS_time = 0;
3077 struct tm *tm = localtime(&time);
3079 *pDOS_time = (
mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1));
3080 *pDOS_date = (
mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday);
3084 #ifndef MINIZ_NO_STDIO 3087 #ifdef MINIZ_NO_TIME 3088 (void)pFilename; *pDOS_date = *pDOS_time = 0;
3095 #endif // #ifdef MINIZ_NO_TIME 3099 #ifndef MINIZ_NO_TIME 3102 struct utimbuf t; t.actime = access_time; t.modtime = modified_time;
3103 return !utime(pFilename, &t);
3105 #endif // #ifndef MINIZ_NO_TIME 3106 #endif // #ifndef MINIZ_NO_STDIO 3139 pE = pL +
MZ_MIN(l_len, r_len);
3146 return (pL == pE) ? (l_len < r_len) : (l < r);
3149 #define MZ_SWAP_UINT32(a, b) do { mz_uint32 t = a; a = b; b = t; } MZ_MACRO_END 3159 int start = (size - 2) >> 1, end;
3162 int child, root = start;
3165 if ((child = (root << 1) + 1) >= size)
3167 child += (((child + 1) < size) && (
mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])));
3178 int child, root = 0;
3182 if ((child = (root << 1) + 1) >= end)
3184 child += (((child + 1) < end) &&
mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]));
3195 mz_uint cdir_size, num_this_disk, cdir_disk_index;
3211 for (i = n - 4; i >= 0; --i)
3221 cur_file_ofs =
MZ_MAX(cur_file_ofs - (
sizeof(buf_u32) - 3), 0);
3232 if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1)))
3253 if (sort_central_dir)
3266 mz_uint total_header_size, comp_size, decomp_size, disk_index;
3270 if (sort_central_dir)
3274 if (((!
MZ_READ_LE32(p +
MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF))
3277 if ((disk_index != num_this_disk) && (disk_index != 1))
3283 n -= total_header_size; p += total_header_size;
3287 if (sort_central_dir)
3295 if ((!pZip) || (!pZip->
m_pRead))
3337 #ifndef MINIZ_NO_STDIO 3375 #endif // #ifndef MINIZ_NO_STDIO 3396 return (m_bit_flag & 1);
3401 mz_uint filename_len, external_attr;
3418 if ((external_attr & 0x10) != 0)
3428 if ((!p) || (!pStat))
3438 #ifndef MINIZ_NO_TIME 3463 if (!p) {
if (filename_buf_size) pFilename[0] =
'\0';
return 0; }
3465 if (filename_buf_size)
3467 n =
MZ_MIN(n, filename_buf_size - 1);
3469 pFilename[n] =
'\0';
3478 return 0 == memcmp(pA, pB, len);
3479 for (i = 0; i < len; ++i)
3491 pE = pL +
MZ_MIN(l_len, r_len);
3498 return (pL == pE) ? (int)(l_len - r_len) : (l - r);
3509 int l = 0, h = size - 1;
3512 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);
3525 mz_uint file_index;
size_t name_len, comment_len;
3530 name_len = strlen(pName);
if (name_len > 0xFFFF)
return -1;
3531 comment_len = pComment ? strlen(pComment) : 0;
if (comment_len > 0xFFFF)
return -1;
3532 for (file_index = 0; file_index < pZip->
m_total_files; file_index++)
3537 if (filename_len < name_len)
3542 const char *pFile_comment = pFilename + filename_len + file_extra_len;
3548 int ofs = filename_len - 1;
3551 if ((pFilename[ofs] ==
'/') || (pFilename[ofs] ==
'\\') || (pFilename[ofs] ==
':'))
3553 }
while (--ofs >= 0);
3555 pFilename += ofs; filename_len -= ofs;
3566 mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;
3572 if ((buf_size) && (!pBuf))
3597 if (buf_size < needed_size)
3614 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pBuf, (
size_t)needed_size) != needed_size)
3626 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
3629 else if (pUser_read_buf)
3632 if (!user_read_buf_size)
3634 pRead_buf = (
mz_uint8 *)pUser_read_buf;
3635 read_buf_size = user_read_buf_size;
3644 if (((0,
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
3646 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
3657 size_t in_buf_size, out_buf_size = (size_t)(file_stat.
m_uncomp_size - out_buf_ofs);
3660 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
3661 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3666 cur_file_ofs += read_buf_avail;
3667 comp_remaining -= read_buf_avail;
3670 in_buf_size = (size_t)read_buf_avail;
3672 read_buf_avail -= in_buf_size;
3673 read_buf_ofs += in_buf_size;
3674 out_buf_ofs += out_buf_size;
3710 mz_uint64 comp_size, uncomp_size, alloc_size;
3724 if (((0,
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (alloc_size > 0x7FFFFFFF))
3726 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (alloc_size > 0x7FFFFFFF))
3738 if (pSize) *pSize = (size_t)alloc_size;
3747 if (pSize) *pSize = 0;
3756 mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
3758 void *pRead_buf =
NULL;
void *pWrite_buf =
NULL;
3796 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
3829 while (comp_remaining)
3831 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
3832 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3841 if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3846 cur_file_ofs += read_buf_avail;
3847 out_buf_ofs += read_buf_avail;
3848 comp_remaining -= read_buf_avail;
3867 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
3868 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
3873 cur_file_ofs += read_buf_avail;
3874 comp_remaining -= read_buf_avail;
3878 in_buf_size = (size_t)read_buf_avail;
3880 read_buf_avail -= in_buf_size;
3881 read_buf_ofs += in_buf_size;
3885 if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size)
3891 if ((out_buf_ofs += out_buf_size) > file_stat.
m_uncomp_size)
3924 #ifndef MINIZ_NO_STDIO 3937 pFile =
MZ_FOPEN(pDst_filename,
"wb");
3943 #ifndef MINIZ_NO_TIME 3949 #endif // #ifndef MINIZ_NO_STDIO 3961 #ifndef MINIZ_NO_STDIO 3967 #endif // #ifndef MINIZ_NO_STDIO 3976 #ifndef MINIZ_NO_STDIO 3988 #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS 3992 #define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) 3993 #define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) 4031 if ((!n) || ((
sizeof(
size_t) ==
sizeof(
mz_uint32)) && (new_size > 0x7FFFFFFF)))
4036 size_t new_capacity =
MZ_MAX(64, pState->
m_mem_capacity);
while (new_capacity < new_size) new_capacity *= 2;
4052 if (0 != (initial_allocation_size =
MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning)))
4064 #ifndef MINIZ_NO_STDIO 4087 if (size_to_reserve_at_beginning)
4092 size_t n = (size_t)
MZ_MIN(
sizeof(buf), size_to_reserve_at_beginning);
4098 cur_ofs += n; size_to_reserve_at_beginning -= n;
4099 }
while (size_to_reserve_at_beginning);
4103 #endif // #ifndef MINIZ_NO_STDIO 4118 #ifdef MINIZ_NO_STDIO 4133 #endif // #ifdef MINIZ_NO_STDIO 4177 static 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)
4195 static 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)
4216 static 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)
4227 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))
4247 if (*pArchive_name ==
'/')
4249 while (*pArchive_name)
4251 if ((*pArchive_name ==
'\\') || (*pArchive_name ==
':'))
4270 memset(buf, 0,
MZ_MIN(
sizeof(buf), n));
4276 cur_file_ofs += s; n -= s;
4283 mz_uint16 method = 0, dos_time = 0, dos_date = 0;
4284 mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
4285 mz_uint64 local_dir_header_ofs, cur_archive_file_ofs, comp_size = 0;
4286 size_t archive_name_size;
4289 mz_bool store_data_uncompressed;
4292 if ((
int)level_and_flags < 0)
4294 level = level_and_flags & 0xF;
4300 local_dir_header_ofs = cur_archive_file_ofs = pZip->
m_archive_size;
4306 if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
4311 #ifndef MINIZ_NO_TIME 4313 time_t cur_time; time(&cur_time);
4316 #endif // #ifndef MINIZ_NO_TIME 4318 archive_name_size = strlen(pArchive_name);
4319 if (archive_name_size > 0xFFFF)
4328 if ((archive_name_size) && (pArchive_name[archive_name_size - 1] ==
'/'))
4331 ext_attributes |= 0x10;
4333 if ((buf_size) || (uncomp_size))
4341 if ((!store_data_uncompressed) && (buf_size))
4352 local_dir_header_ofs += num_alignment_padding_bytes;
4354 cur_archive_file_ofs += num_alignment_padding_bytes +
sizeof(local_dir_header);
4357 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
4362 cur_archive_file_ofs += archive_name_size;
4367 uncomp_size = buf_size;
4368 if (uncomp_size <= 3)
4371 store_data_uncompressed =
MZ_TRUE;
4375 if (store_data_uncompressed)
4383 cur_archive_file_ofs += buf_size;
4384 comp_size = buf_size;
4414 if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))
4417 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))
4420 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, local_dir_header_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
4423 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))
4432 #ifndef MINIZ_NO_STDIO 4436 mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;
4437 mz_uint64 local_dir_header_ofs, cur_archive_file_ofs, uncomp_size = 0, comp_size = 0;
4438 size_t archive_name_size;
4442 if ((
int)level_and_flags < 0)
4444 level = level_and_flags & 0xF;
4449 local_dir_header_ofs = cur_archive_file_ofs = pZip->
m_archive_size;
4456 archive_name_size = strlen(pArchive_name);
4457 if (archive_name_size > 0xFFFF)
4469 pSrc_file =
MZ_FOPEN(pSrc_filename,
"rb");
4476 if (uncomp_size > 0xFFFFFFFF)
4482 if (uncomp_size <= 3)
4490 local_dir_header_ofs += num_alignment_padding_bytes;
4492 cur_archive_file_ofs += num_alignment_padding_bytes +
sizeof(local_dir_header);
4495 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
4500 cur_archive_file_ofs += archive_name_size;
4504 mz_uint64 uncomp_remaining = uncomp_size;
4514 while (uncomp_remaining)
4524 uncomp_remaining -= n;
4525 cur_archive_file_ofs += n;
4527 comp_size = uncomp_size;
4558 if (
MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
4562 uncomp_remaining -= in_buf_size;
4595 if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))
4598 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))
4601 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, local_dir_header_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
4604 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))
4612 #endif // #ifndef MINIZ_NO_STDIO 4616 mz_uint n, bit_flags, num_alignment_padding_bytes;
4617 mz_uint64 comp_bytes_remaining, local_dir_header_ofs;
4618 mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;
4621 size_t orig_central_dir_size;
4623 void *pBuf;
const mz_uint8 *pSrc_central_header;
4648 cur_dst_file_ofs += num_alignment_padding_bytes;
4649 local_dir_header_ofs = cur_dst_file_ofs;
4662 while (comp_bytes_remaining)
4670 cur_src_file_ofs += n;
4677 cur_dst_file_ofs += n;
4679 comp_bytes_remaining -= n;
4700 cur_dst_file_ofs += n;
4705 if (cur_dst_file_ofs > 0xFFFFFFFF)
4740 mz_uint64 central_dir_ofs, central_dir_size;
4752 central_dir_ofs = 0;
4753 central_dir_size = 0;
4775 #ifndef MINIZ_NO_STDIO 4778 #endif // #ifndef MINIZ_NO_STDIO 4788 if ((!pZip) || (!pZip->
m_pState) || (!pBuf) || (!pSize))
4815 #ifndef MINIZ_NO_STDIO 4821 #endif // #ifndef MINIZ_NO_STDIO 4834 #ifndef MINIZ_NO_STDIO 4841 if ((
int)level_and_flags < 0)
4843 if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) >
MZ_UBER_COMPRESSION))
4852 created_new_archive =
MZ_TRUE;
4865 status =
mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0);
4871 if ((!status) && (created_new_archive))
4875 (void)ignoredStatus;
4889 if ((!pZip_filename) || (!pArchive_name))
4903 #endif // #ifndef MINIZ_NO_STDIO 4905 #endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS 4907 #endif // #ifndef MINIZ_NO_ARCHIVE_APIS 4913 #endif // MINIZ_HEADER_FILE_ONLY
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED
Definition: miniz.h:716
mz_uint m_dict_size
Definition: miniz.h:883
mz_uint32 m_z_adler32
Definition: miniz.h:775
static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip)
Definition: miniz.h:4258
char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]
Definition: miniz.h:526
#define TINFL_CR_RETURN(state_index, result)
Definition: miniz.h:1372
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
Definition: miniz.h:3563
static 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)
Definition: miniz.h:4216
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
Definition: miniz.h:3753
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: miniz.h:4281
static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d)
Definition: miniz.h:2637
static void mz_write_le32(mz_uint8 *p, mz_uint32 v)
Definition: miniz.h:3991
mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE]
Definition: miniz.h:758
mz_uint32 m_type
Definition: miniz.h:775
unsigned long mz_ulong
Definition: miniz.h:237
#define TINFL_SKIP_BITS(state_index, n)
Definition: miniz.h:1395
mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
Definition: miniz.h:897
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize)
Definition: miniz.h:4786
static const mz_uint8 s_tdefl_large_dist_sym[128]
Definition: miniz.h:1826
static const mz_uint mz_bitmasks[17]
Definition: miniz.h:2035
mz_uint m_lz_code_buf_dict_pos
Definition: miniz.h:885
mz_alloc_func m_pAlloc
Definition: miniz.h:552
mz_zip_array m_central_dir
Definition: miniz.h:3000
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
Definition: miniz.h:2719
static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint32 flags)
Definition: miniz.h:3108
#define TINFL_MEMCPY(d, s, l)
Definition: miniz.h:1368
static int tdefl_flush_block(tdefl_compressor *d, int flush)
Definition: miniz.h:2181
mz_uint m_saved_match_dist
Definition: miniz.h:886
static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d)
Definition: miniz.h:2127
#define TDEFL_PUT_BITS(b, l)
Definition: miniz.h:1925
mz_ulong uLong
Definition: miniz.h:403
unsigned int avail_in
Definition: miniz.h:289
int m_greedy_parsing
Definition: miniz.h:882
struct mz_zip_archive_tag mz_zip_archive
static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index)
Definition: miniz.h:3132
mz_uint32 m_state
Definition: miniz.h:775
const mz_uint8 * m_pSrc
Definition: miniz.h:892
mz_file_read_func m_pRead
Definition: miniz.h:557
mz_ulong total_out
Definition: miniz.h:294
mz_uint32 m_zhdr0
Definition: miniz.h:775
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags)
Definition: miniz.h:3698
mz_zip_internal_state * m_pState
Definition: miniz.h:561
#define MZ_ADLER32_INIT
Definition: miniz.h:242
#define MZ_ASSERT(x)
Definition: miniz.h:947
size_t m_src_buf_left
Definition: miniz.h:893
static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name)
Definition: miniz.h:4244
mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
Definition: miniz.h:3690
#define MZ_DELETE_FILE
Definition: miniz.h:2965
static void tdefl_start_dynamic_block(tdefl_compressor *d)
Definition: miniz.h:1955
mz_uint m_file_offset_alignment
Definition: miniz.h:550
static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n)
Definition: miniz.h:4267
size_t * m_pIn_buf_size
Definition: miniz.h:890
#define TINFL_CR_RETURN_FOREVER(state_index, result)
Definition: miniz.h:1373
static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
Definition: miniz.h:4065
mz_uint m_dict_ofs
Definition: miniz.h:1180
mz_uint m_wants_to_finish
Definition: miniz.h:886
long long mz_int64
Definition: miniz.h:482
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
Definition: miniz.h:3459
int mz_deflate(mz_streamp pStream, int flush)
Definition: miniz.h:1072
#define SEEK_END
Definition: zconf.h:298
int mz_deflateInit(mz_streamp pStream, int level)
Definition: miniz.h:1027
mz_uint m_output_flush_ofs
Definition: miniz.h:886
#define MZ_FALSE
Definition: miniz.h:486
mz_uint32 m_external_attr
Definition: miniz.h:522
#define MZ_FILE_STAT
Definition: miniz.h:2962
mz_uint64 m_archive_size
Definition: miniz.h:545
int mz_inflate(mz_streamp pStream, int flush)
Definition: miniz.h:1221
#define NULL
Definition: glib.h:121
void *(* mz_realloc_func)(void *opaque, void *address, size_t items, size_t size)
Definition: miniz.h:262
unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 :-1]
Definition: miniz.h:941
mz_uint m_output_flush_remaining
Definition: miniz.h:886
tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]
Definition: miniz.h:778
unsigned char * next_out
Definition: miniz.h:292
void * opaque
Definition: miniz.h:301
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags)
Definition: miniz.h:3316
const void * m_pIn_buf
Definition: miniz.h:888
mz_uint16 m_version_made_by
Definition: miniz.h:511
size_t m_mem_capacity
Definition: miniz.h:3006
static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table)
Definition: miniz.h:1890
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: miniz.h:2788
mz_uint m_bits_in
Definition: miniz.h:885
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
Definition: miniz.h:3377
mz_zip_mode
Definition: miniz.h:535
static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing)
Definition: miniz.h:3018
unsigned int uInt
Definition: miniz.h:402
#define MZ_FSEEK64
Definition: miniz.h:2960
mz_realloc_func m_pRealloc
Definition: miniz.h:554
unsigned int avail_out
Definition: miniz.h:293
int data_type
Definition: miniz.h:303
struct mz_internal_state * state
Definition: miniz.h:297
mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len)
Definition: miniz.h:1001
static void * def_alloc_func(void *opaque, size_t items, size_t size)
Definition: miniz.h:1018
static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
Definition: miniz.h:3338
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index)
Definition: miniz.h:4614
#define MZ_VERSION
Definition: miniz.h:264
mz_uint8 * m_pBuf
Definition: miniz.h:2760
static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, time_t modified_time)
Definition: miniz.h:3100
void * m_pAlloc_opaque
Definition: miniz.h:555
void * tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out)
Definition: miniz.h:2853
static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n)
Definition: miniz.h:1855
void * mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags)
Definition: miniz.h:3742
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags)
Definition: miniz.h:3977
#define MZ_MAX(a, b)
Definition: miniz.h:959
mz_zip_archive * m_pZip
Definition: miniz.h:4162
#define MZ_REALLOC(p, x)
Definition: miniz.h:956
struct mz_stream_s mz_stream
mz_free_func zfree
Definition: miniz.h:300
mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]
Definition: miniz.h:757
void * m_pOut_buf
Definition: miniz.h:889
static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing)
Definition: miniz.h:3033
static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len)
Definition: miniz.h:2321
#define TINFL_CR_FINISH
Definition: miniz.h:1374
#define MZ_WRITE_LE16(p, v)
Definition: miniz.h:3992
#define MZ_FREAD
Definition: miniz.h:2957
static const mz_uint8 s_tdefl_small_dist_extra[512]
Definition: miniz.h:1816
static void tdefl_start_static_block(tdefl_compressor *d)
Definition: miniz.h:2017
mz_uint16 m_key
Definition: miniz.h:1837
size_t m_size
Definition: miniz.h:2759
unsigned long long mz_uint64
Definition: miniz.h:483
mz_bool mz_zip_writer_end(mz_zip_archive *pZip)
Definition: miniz.h:4802
mz_alloc_func zalloc
Definition: miniz.h:299
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: miniz.h:2824
size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags)
Definition: miniz.h:1748
void * mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags)
Definition: miniz.h:3708
mz_uint8 * m_pOutput_buf_end
Definition: miniz.h:884
mz_uint32 tinfl_bit_buf_t
Definition: miniz.h:769
mz_uint64 m_central_directory_file_ofs
Definition: miniz.h:546
size_t(* mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
Definition: miniz.h:530
static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n)
Definition: miniz.h:3045
mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
Definition: miniz.h:895
tdefl_put_buf_func_ptr m_pPut_buf_func
Definition: miniz.h:879
size_t m_mem_size
Definition: miniz.h:3005
mz_uint m_max_probes[2]
Definition: miniz.h:881
void * tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
Definition: miniz.h:1720
unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 :-1]
Definition: miniz.h:940
mz_uint m_num_flags_left
Definition: miniz.h:885
static tdefl_sym_freq * tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq *pSyms0, tdefl_sym_freq *pSyms1)
Definition: miniz.h:1838
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
Definition: miniz.h:1324
int intf
Definition: miniz.h:407
static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist)
Definition: miniz.h:2497
mz_uint8 m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0+TINFL_MAX_HUFF_SYMBOLS_1+137]
Definition: miniz.h:779
tdefl_status
Definition: miniz.h:859
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
Definition: miniz.h:4737
#define TDEFL_RLE_ZERO_CODE_SIZE()
Definition: miniz.h:1944
static void def_free_func(void *opaque, void *address)
Definition: miniz.h:1019
mz_uint m_has_flushed
Definition: miniz.h:1180
mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags)
Definition: miniz.h:3293
#define MZ_CRC32_INIT
Definition: miniz.h:246
mz_uint64 m_comp_size
Definition: miniz.h:4164
tinfl_bit_buf_t m_bit_buf
Definition: miniz.h:776
static const mz_uint8 s_tdefl_len_extra[256]
Definition: miniz.h:1796
static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit)
Definition: miniz.h:2489
mz_uint m_total_lz_bytes
Definition: miniz.h:885
#define MZ_FORCEINLINE
Definition: miniz.h:976
mz_uint m_saved_match_len
Definition: miniz.h:886
void *const voidpc
Definition: miniz.h:411
mz_uint32 tdefl_get_adler32(tdefl_compressor *d)
Definition: miniz.h:2743
mz_uint8 * m_pOutput_buf
Definition: miniz.h:884
void * mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags)
Definition: miniz.h:4880
static const mz_uint8 s_tdefl_large_dist_extra[128]
Definition: miniz.h:1831
mz_bool m_expandable
Definition: miniz.h:2761
mz_uint16 m_bit_flag
Definition: miniz.h:513
void * m_p
Definition: miniz.h:2993
void * voidp
Definition: miniz.h:410
void * voidpf
Definition: miniz.h:408
static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray)
Definition: miniz.h:3012
#define MZ_FILE_STAT_STRUCT
Definition: miniz.h:2961
void *(* mz_alloc_func)(void *opaque, size_t items, size_t size)
Definition: miniz.h:260
static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename)
Definition: miniz.h:3501
mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]
Definition: miniz.h:1181
#define tinfl_get_adler32(r)
Definition: miniz.h:742
void mz_free(void *p)
Definition: miniz.h:1011
mz_uint m_saved_lit
Definition: miniz.h:886
const unsigned char * next_in
Definition: miniz.h:288
#define MZ_WRITE_LE32(p, v)
Definition: miniz.h:3993
const char * mz_version(void)
Definition: miniz.h:1022
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
Definition: miniz.h:3424
void * m_pPut_buf_user
Definition: miniz.h:880
mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE+TDEFL_MAX_MATCH_LEN - 1]
Definition: miniz.h:894
mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
Definition: miniz.h:3916
size_t(* mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
Definition: miniz.h:529
mz_uint m_total_files
Definition: miniz.h:547
int(* tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)
Definition: miniz.h:721
mz_uint32 m_crc32
Definition: miniz.h:518
mz_uint8 m_raw_header[4]
Definition: miniz.h:779
#define tinfl_init(r)
Definition: miniz.h:741
#define TINFL_GET_BITS(state_index, b, n)
Definition: miniz.h:1396
mz_uint32 m_num_extra
Definition: miniz.h:775
static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block)
Definition: miniz.h:2172
#define MZ_FREOPEN(f, m, s)
Definition: miniz.h:2964
tinfl_decompressor m_decomp
Definition: miniz.h:1179
Byte Bytef
Definition: miniz.h:404
mz_file_write_func m_pWrite
Definition: miniz.h:558
#define MZ_READ_LE16(p)
Definition: miniz.h:967
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index)
Definition: miniz.h:3389
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: miniz.h:2658
mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]
Definition: miniz.h:900
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
Definition: miniz.h:3523
static void * def_realloc_func(void *opaque, void *address, size_t items, size_t size)
Definition: miniz.h:1020
unsigned int mz_uint
Definition: miniz.h:481
static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date)
Definition: miniz.h:3056
size_t m_dist_from_out_buf_start
Definition: miniz.h:777
static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[]
Definition: miniz.h:1953
#define TINFL_HUFF_DECODE(state_index, sym, pHuff)
Definition: miniz.h:1421
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy)
Definition: miniz.h:2801
mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]
Definition: miniz.h:898
tdefl_flush
Definition: miniz.h:868
mz_uint m_dict_avail
Definition: miniz.h:1180
static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len, void *pUser)
Definition: miniz.h:4167
uInt uIntf
Definition: miniz.h:405
mz_ulong mz_compressBound(mz_ulong source_len)
Definition: miniz.h:1172
#define MZ_FTELL64
Definition: miniz.h:2959
mz_int16 m_tree[TINFL_MAX_HUFF_SYMBOLS_0 *2]
Definition: miniz.h:758
#define TINFL_MEMSET(p, c, l)
Definition: miniz.h:1369
mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
Definition: miniz.h:3951
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d)
Definition: miniz.h:2738
unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 :-1]
Definition: miniz.h:942
tdefl_status m_prev_return_status
Definition: miniz.h:887
static mz_bool tdefl_compress_normal(tdefl_compressor *d)
Definition: miniz.h:2519
#define MZ_SWAP_UINT32(a, b)
Definition: miniz.h:3149
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
Definition: miniz.h:985
#define MZ_FWRITE
Definition: miniz.h:2958
mz_uint64 m_uncomp_size
Definition: miniz.h:520
mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning)
Definition: miniz.h:4074
#define MZ_READ_LE32(p)
Definition: miniz.h:968
#define MZ_MALLOC(x)
Definition: miniz.h:954
int mz_bool
Definition: miniz.h:484
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: miniz.h:4155
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level)
Definition: miniz.h:1139
static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing)
Definition: miniz.h:3027
int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
Definition: miniz.h:1755
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: miniz.h:4433
mz_ulong reserved
Definition: miniz.h:305
void * m_pMem
Definition: miniz.h:3004
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags)
Definition: miniz.h:1436
static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags)
Definition: miniz.h:3193
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size)
Definition: miniz.h:4046
Definition: inftrees.h:24
static MZ_FORCEINLINE const mz_uint8 * mz_zip_reader_get_cdh(mz_zip_archive *pZip, mz_uint file_index)
Definition: miniz.h:3382
#define SEEK_SET
Definition: zconf.h:296
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size)
Definition: miniz.h:3995
#define MZ_CLEAR_OBJ(obj)
Definition: miniz.h:961
int mz_inflateEnd(mz_streamp pStream)
Definition: miniz.h:1312
static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip)
Definition: miniz.h:3152
#define TINFL_LZ_DICT_SIZE
Definition: miniz.h:727
#define TDEFL_RLE_PREV_CODE_SIZE()
Definition: miniz.h:1936
mz_uint16 m_method
Definition: miniz.h:514
#define MZ_MIN(a, b)
Definition: miniz.h:960
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index)
Definition: miniz.h:3399
unsigned short mz_uint16
Definition: miniz.h:479
#define MZ_FILE
Definition: miniz.h:2954
const char * mz_error(int err)
Definition: miniz.h:1353
mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags)
Definition: miniz.h:3703
mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]
Definition: miniz.h:901
size_t m_out_buf_ofs
Definition: miniz.h:893
#define MZ_FREE(x)
Definition: miniz.h:955
mz_free_func m_pFree
Definition: miniz.h:553
MZ_FILE * m_pFile
Definition: miniz.h:3003
mz_uint m_first_call
Definition: miniz.h:1180
static 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)
Definition: miniz.h:4195
mz_uint32 m_num_bits
Definition: miniz.h:775
mz_uint32 m_zhdr1
Definition: miniz.h:775
mz_uint64 m_comp_size
Definition: miniz.h:519
mz_stream * mz_streamp
Definition: miniz.h:308
static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
Definition: miniz.h:3308
mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]
Definition: miniz.h:899
unsigned int mz_uint32
Definition: miniz.h:480
#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index)
Definition: miniz.h:3010
static const mz_uint s_tdefl_num_probes[11]
Definition: miniz.h:2798
tdefl_flush m_flush
Definition: miniz.h:891
#define MZ_TRUE
Definition: miniz.h:487
mz_zip_mode m_zip_mode
Definition: miniz.h:548
void * tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
Definition: miniz.h:2779
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
Definition: miniz.h:3930
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: miniz.h:2748
mz_zip_flags
Definition: miniz.h:565
size_t m_capacity
Definition: miniz.h:2994
mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len)
Definition: miniz.h:1132
#define MZ_DEFAULT_WINDOW_BITS
Definition: miniz.h:281
mz_uint16 m_internal_attr
Definition: miniz.h:521
mz_uint32 m_central_dir_ofs
Definition: miniz.h:510
mz_uint32 m_comment_size
Definition: miniz.h:524
mz_uint8 * m_pLZ_flags
Definition: miniz.h:884
mz_uint32 m_final
Definition: miniz.h:775
#define TINFL_CR_BEGIN
Definition: miniz.h:1371
static void mz_write_le16(mz_uint8 *p, mz_uint16 v)
Definition: miniz.h:3990
static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags)
Definition: miniz.h:3474
#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size)
Definition: miniz.h:3009
static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser)
Definition: miniz.h:2764
size_t m_size
Definition: miniz.h:2994
mz_uint64 m_cur_archive_file_ofs
Definition: miniz.h:4163
mz_uint m_bit_buffer
Definition: miniz.h:885
int mz_deflateEnd(mz_streamp pStream)
Definition: miniz.h:1121
static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date)
Definition: miniz.h:3065
mz_uint32 m_dist
Definition: miniz.h:775
int mz_inflateInit(mz_streamp pStream)
Definition: miniz.h:1216
unsigned char Byte
Definition: miniz.h:401
#define MZ_FOPEN(f, m)
Definition: miniz.h:2955
mz_zip_array m_central_dir_offsets
Definition: miniz.h:3001
int mz_deflateReset(mz_streamp pStream)
Definition: miniz.h:1064
mz_uint32 m_counter
Definition: miniz.h:775
size_t m_capacity
Definition: miniz.h:2759
tinfl_status
Definition: miniz.h:730
mz_uint m_adler32
Definition: miniz.h:883
mz_uint m_element_size
Definition: miniz.h:2995
static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date)
Definition: miniz.h:3085
int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy)
Definition: miniz.h:1032
mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
Definition: miniz.h:896
void * m_pIO_opaque
Definition: miniz.h:559
mz_uint m_flags
Definition: miniz.h:881
#define MZ_TOLOWER(c)
Definition: miniz.h:2969
unsigned char mz_uint8
Definition: miniz.h:477
int m_window_bits
Definition: miniz.h:1180
void(* mz_free_func)(void *opaque, void *address)
Definition: miniz.h:261
mz_uint m_finished
Definition: miniz.h:886
static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size)
Definition: miniz.h:1877
mz_uint64 m_local_header_ofs
Definition: miniz.h:523
mz_uint32 m_check_adler32
Definition: miniz.h:775
char * msg
Definition: miniz.h:296
int mz_inflateInit2(mz_streamp pStream, int window_bits)
Definition: miniz.h:1185
size_t * m_pOut_buf_size
Definition: miniz.h:890
char charf
Definition: miniz.h:406
uLong uLongf
Definition: miniz.h:409
mz_zip_array m_sorted_central_dir_offsets
Definition: miniz.h:3002
mz_uint8 * m_pLZ_code_buf
Definition: miniz.h:884
mz_bool(* tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)
Definition: miniz.h:844
mz_uint m_block_index
Definition: miniz.h:886
static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n)
Definition: miniz.h:3040
#define TINFL_GET_BYTE(state_index, c)
Definition: miniz.h:1378
mz_uint m_lookahead_pos
Definition: miniz.h:883
static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
Definition: miniz.h:4025
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: miniz.h:4835
char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]
Definition: miniz.h:525
mz_ulong adler
Definition: miniz.h:304
#define MZ_FFLUSH
Definition: miniz.h:2963
static const mz_uint8 s_tdefl_small_dist_sym[512]
Definition: miniz.h:1802
mz_uint16 m_version_needed
Definition: miniz.h:512
static const mz_uint16 s_tdefl_len_sym[256]
Definition: miniz.h:1786
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
Definition: miniz.h:3347
static MZ_FORCEINLINE int mz_zip_reader_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len)
Definition: miniz.h:3485
signed short mz_int16
Definition: miniz.h:478
tinfl_status m_last_status
Definition: miniz.h:1182
#define MZ_FCLOSE
Definition: miniz.h:2956
mz_uint16 m_sym_index
Definition: miniz.h:1837
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename)
Definition: miniz.h:4105
mz_uint m_lookahead_size
Definition: miniz.h:883
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush)
Definition: miniz.h:2714
static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n)
Definition: miniz.h:3925
mz_uint32 m_file_index
Definition: miniz.h:509
time_t m_time
Definition: miniz.h:516
mz_uint32 m_table_sizes[TINFL_MAX_HUFF_TABLES]
Definition: miniz.h:775
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
Definition: miniz.h:1167
static 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)
Definition: miniz.h:4177
mz_ulong total_in
Definition: miniz.h:290
#define MZ_DEFLATED
Definition: miniz.h:254