42 size_t block_len = buf_len % 5552;
47 for (i = 0; i + 7 < block_len; i += 8, ptr += 8)
49 s1 += ptr[0], s2 += s1;
50 s1 += ptr[1], s2 += s1;
51 s1 += ptr[2], s2 += s1;
52 s1 += ptr[3], s2 += s1;
53 s1 += ptr[4], s2 += s1;
54 s1 += ptr[5], s2 += s1;
55 s1 += ptr[6], s2 += s1;
56 s1 += ptr[7], s2 += s1;
58 for (; i < block_len; ++i)
59 s1 += *ptr++, s2 += s1;
60 s1 %= 65521U, s2 %= 65521U;
64 return (s2 << 16) + s1;
71 static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
72 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c };
80 crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)];
81 crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)];
92 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535,
93 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD,
94 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D,
95 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
96 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4,
97 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
98 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC,
99 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
100 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB,
101 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F,
102 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB,
103 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
104 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA,
105 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE,
106 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A,
107 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
108 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409,
109 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
110 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739,
111 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
112 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268,
113 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0,
114 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8,
115 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
116 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF,
117 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703,
118 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7,
119 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
120 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE,
121 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
122 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6,
123 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
124 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D,
125 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5,
126 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605,
127 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
128 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
162 (void)opaque, (
void)items, (void)size;
167 (void)opaque, (
void)address;
172 (void)opaque, (
void)address, (void)items, (
void)size;
181#ifndef MINIZ_NO_ZLIB_APIS
213 pStream->
state = (
struct mz_internal_state *)pComp;
226 if ((!pStream) || (!pStream->
state) || (!pStream->
zalloc) || (!pStream->
zfree))
235 size_t in_bytes, out_bytes;
236 mz_ulong orig_total_in, orig_total_out;
237 int mz_status =
MZ_OK;
282 if ((flush) || (pStream->
total_in != orig_total_in) || (pStream->
total_out != orig_total_out))
298 pStream->
state = NULL;
307 return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);
314 memset(&stream, 0,
sizeof(stream));
317 if ((source_len | *pDest_len) > 0xFFFFFFFFU)
382 pStream->
state = (
struct mz_internal_state *)pDecomp;
404 size_t in_bytes, out_bytes, orig_avail_in;
407 if ((!pStream) || (!pStream->
state))
428 if ((flush ==
MZ_FINISH) && (first_call))
519 pStream->
state = NULL;
528 memset(&stream, 0,
sizeof(stream));
531 if ((source_len | *pDest_len) > 0xFFFFFFFFU)
562 {
MZ_OK,
"" }, {
MZ_STREAM_END,
"stream end" }, {
MZ_NEED_DICT,
"need dictionary" }, {
MZ_ERRNO,
"file error" }, {
MZ_STREAM_ERROR,
"stream error" },
566 for (i = 0; i <
sizeof(s_error_descs) /
sizeof(s_error_descs[0]); ++i)
567 if (s_error_descs[i].m_err == err)
568 return s_error_descs[i].m_pDesc;
642 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,
643 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,
644 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,
645 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,
646 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,
647 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,
648 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,
649 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
654 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,
655 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,
656 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,
657 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
662 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,
663 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,
664 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,
665 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,
666 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,
667 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,
668 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,
669 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,
670 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,
671 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,
672 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,
673 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
678 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,
679 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,
680 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,
681 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,
682 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
683 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
684 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
685 7, 7, 7, 7, 7, 7, 7, 7
690 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,
691 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,
692 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
697 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,
698 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,
699 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
709 mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2];
712 for (i = 0; i < num_syms; i++)
716 hist[256 + ((freq >> 8) & 0xFF)]++;
718 while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256]))
720 for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8)
722 const mz_uint32 *pHist = &hist[pass << 8];
723 mz_uint offsets[256], cur_ofs = 0;
724 for (i = 0; i < 256; i++)
726 offsets[i] = cur_ofs;
729 for (i = 0; i < num_syms; i++)
730 pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i];
733 pCur_syms = pNew_syms;
743 int root, leaf, next, avbl, used, dpth;
754 for (next = 1; next < n - 1; next++)
756 if (leaf >= n || A[root].m_key < A[leaf].m_key)
763 if (leaf >= n || (root < next && A[root].m_key < A[leaf].m_key))
772 for (next = n - 3; next >= 0; next--)
773 A[next].m_key = A[A[next].m_key].m_key + 1;
780 while (root >= 0 && (
int)A[root].
m_key == dpth)
805 if (code_list_len <= 1)
808 pNum_codes[max_code_size] += pNum_codes[i];
809 for (i = max_code_size; i > 0; i--)
810 total += (((
mz_uint32)pNum_codes[i]) << (max_code_size - i));
811 while (total != (1UL << max_code_size))
813 pNum_codes[max_code_size]--;
814 for (i = max_code_size - 1; i > 0; i--)
818 pNum_codes[i + 1] += 2;
832 for (i = 0; i < table_len; i++)
838 int num_used_syms = 0;
840 for (i = 0; i < table_len; i++)
850 for (i = 0; i < num_used_syms; i++)
851 num_codes[pSyms[i].m_key]++;
857 for (i = 1, j = num_used_syms; i <= code_size_limit; i++)
858 for (l = num_codes[i]; l > 0; l--)
863 for (j = 0, i = 2; i <= code_size_limit; i++)
864 next_code[i] = j = ((j + num_codes[i - 1]) << 1);
866 for (i = 0; i < table_len; i++)
868 mz_uint rev_code = 0, code, code_size;
871 code = next_code[code_size]++;
872 for (l = code_size; l > 0; l--, code >>= 1)
873 rev_code = (rev_code << 1) | (code & 1);
878#define TDEFL_PUT_BITS(b, l) \
883 MZ_ASSERT(bits <= ((1U << len) - 1U)); \
884 d->m_bit_buffer |= (bits << d->m_bits_in); \
885 d->m_bits_in += len; \
886 while (d->m_bits_in >= 8) \
888 if (d->m_pOutput_buf < d->m_pOutput_buf_end) \
889 *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \
890 d->m_bit_buffer >>= 8; \
896#define TDEFL_RLE_PREV_CODE_SIZE() \
898 if (rle_repeat_count) \
900 if (rle_repeat_count < 3) \
902 d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \
903 while (rle_repeat_count--) \
904 packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \
908 d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); \
909 packed_code_sizes[num_packed_code_sizes++] = 16; \
910 packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \
912 rle_repeat_count = 0; \
916#define TDEFL_RLE_ZERO_CODE_SIZE() \
920 if (rle_z_count < 3) \
922 d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); \
923 while (rle_z_count--) \
924 packed_code_sizes[num_packed_code_sizes++] = 0; \
926 else if (rle_z_count <= 10) \
928 d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); \
929 packed_code_sizes[num_packed_code_sizes++] = 17; \
930 packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \
934 d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); \
935 packed_code_sizes[num_packed_code_sizes++] = 18; \
936 packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \
942static 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 };
946 int num_lit_codes, num_dist_codes, num_bit_lengths;
947 mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index;
955 for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--)
958 for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--)
963 memcpy(code_sizes_to_pack + num_lit_codes, &d->
m_huff_code_sizes[1][0], num_dist_codes);
964 total_code_sizes_to_pack = num_lit_codes + num_dist_codes;
965 num_packed_code_sizes = 0;
967 rle_repeat_count = 0;
970 for (i = 0; i < total_code_sizes_to_pack; i++)
972 mz_uint8 code_size = code_sizes_to_pack[i];
976 if (++rle_z_count == 138)
984 if (code_size != prev_code_size)
988 packed_code_sizes[num_packed_code_sizes++] = code_size;
990 else if (++rle_repeat_count == 6)
995 prev_code_size = code_size;
997 if (rle_repeat_count)
1013 for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--)
1016 num_bit_lengths =
MZ_MAX(4, (num_bit_lengths + 1));
1018 for (i = 0; (int)i < num_bit_lengths; i++)
1021 for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes;)
1023 mz_uint code = packed_code_sizes[packed_code_sizes_index++];
1027 TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++],
"\02\03\07"[code - 16]);
1036 for (i = 0; i <= 143; ++i)
1038 for (; i <= 255; ++i)
1040 for (; i <= 279; ++i)
1042 for (; i <= 287; ++i)
1053static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
1055#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN &&MINIZ_HAS_64BIT_REGISTERS
1065#define TDEFL_PUT_BITS_FAST(b, l) \
1067 bit_buffer |= (((mz_uint64)(b)) << bits_in); \
1072 for (pLZ_codes = d->
m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1)
1075 flags = *pLZ_codes++ | 0x100;
1079 mz_uint s0, s1, n0, n1, sym, num_extra_bits;
1080 mz_uint match_len = pLZ_codes[0], match_dist = *(
const mz_uint16 *)(pLZ_codes + 1);
1092 sym = (match_dist < 512) ? s0 : s1;
1093 num_extra_bits = (match_dist < 512) ? n0 : n1;
1097 TDEFL_PUT_BITS_FAST(match_dist &
mz_bitmasks[num_extra_bits], num_extra_bits);
1105 if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
1112 if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
1126 pOutput_buf += (bits_in >> 3);
1127 bit_buffer >>= (bits_in & ~7);
1131#undef TDEFL_PUT_BITS_FAST
1156 for (pLZ_codes = d->
m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1)
1159 flags = *pLZ_codes++ | 0x100;
1163 mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8));
1170 if (match_dist < 512)
1209 mz_uint saved_bit_buf, saved_bits_in;
1262 else if (!comp_block_succeeded)
1280 for (i = 0; i < 4; i++)
1295 for (i = 2; i; --i, z ^= 0xFFFF)
1327 if ((n -= bytes_to_copy) != 0)
1342#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
1343#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p)
1349 mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->
m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s);
1351 if (max_match_len <= match_len)
1357 if (--num_probes_left == 0)
1359#define TDEFL_PROBE \
1360 next_probe_pos = d->m_next[probe_pos]; \
1361 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \
1363 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
1364 if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) \
1373 if (TDEFL_READ_UNALIGNED_WORD(q) != s01)
1379 }
while ((TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
1380 (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0));
1383 *pMatch_dist = dist;
1389 *pMatch_dist = dist;
1390 if ((*pMatch_len = match_len =
MZ_MIN(max_match_len, probe_len)) == max_match_len)
1392 c01 = TDEFL_READ_UNALIGNED_WORD(&d->
m_dict[pos + match_len - 1]);
1404 if (max_match_len <= match_len)
1410 if (--num_probes_left == 0)
1412#define TDEFL_PROBE \
1413 next_probe_pos = d->m_next[probe_pos]; \
1414 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \
1416 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
1417 if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) \
1426 q = d->
m_dict + probe_pos;
1427 for (probe_len = 0; probe_len < max_match_len; probe_len++)
1430 if (probe_len > match_len)
1432 *pMatch_dist = dist;
1433 if ((*pMatch_len = match_len = probe_len) == max_match_len)
1435 c0 = d->
m_dict[pos + match_len];
1436 c1 = d->
m_dict[pos + match_len - 1];
1442#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN
1452 const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;
1456 lookahead_size += num_bytes_to_process;
1458 while (num_bytes_to_process)
1466 num_bytes_to_process -= n;
1470 if ((!d->
m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE))
1473 while (lookahead_size >= 4)
1475 mz_uint cur_match_dist, cur_match_len = 1;
1489 }
while ((TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
1490 (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0));
1498 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
1499 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
1505 cur_match_len =
MZ_MIN(cur_match_len, lookahead_size);
1514 *pLZ_flags = (
mz_uint8)((*pLZ_flags >> 1) | 0x80);
1518 d->
m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;
1525 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
1526 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
1530 if (--num_flags_left == 0)
1533 pLZ_flags = pLZ_code_buf++;
1536 total_lz_bytes += cur_match_len;
1537 lookahead_pos += cur_match_len;
1540 MZ_ASSERT(lookahead_size >= cur_match_len);
1541 lookahead_size -= cur_match_len;
1562 while (lookahead_size)
1567 *pLZ_code_buf++ = lit;
1568 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
1569 if (--num_flags_left == 0)
1572 pLZ_flags = pLZ_code_buf++;
1664 mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos;
1671 const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process;
1672 src_buf_left -= num_bytes_to_process;
1674 while (pSrc != pSrc_end)
1721 while (cur_match_len < d->m_lookahead_size)
1723 if (d->
m_dict[cur_pos + cur_match_len] != c)
1739 cur_match_dist = cur_match_len = 0;
1746 if (cur_match_len >= 128)
1750 len_to_move = cur_match_len;
1766 else if (!cur_match_dist)
1771 len_to_move = cur_match_len;
1843 (d->
m_wants_to_finish && (flush !=
TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf))
1856#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN
1861 if (!tdefl_compress_fast(d))
1893 return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush);
1903 d->
m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3;
1943 if (((buf_len) && (!pBuf)) || (!pPut_buf_func))
1964 size_t new_size = p->
m_size + len;
1973 new_capacity =
MZ_MAX(128U, new_capacity << 1U);
1974 }
while (new_size > new_capacity);
1997 *pOut_len = out_buf.
m_size;
2014static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2020 if (window_bits > 0)
2028 comp_flags &= ~TDEFL_MAX_PROBES_MASK;
2031 else if (strategy ==
MZ_RLE)
2038#pragma warning(push)
2039#pragma warning(disable : 4204)
2048 static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2051 int i, bpl =
w * num_chans, y, z;
2065 for (z = 41; z; --z)
2069 for (y = 0; y < h; ++y)
2081 *pLen_out = out_buf.
m_size - 41;
2083 static const mz_uint8 chans[] = { 0x00, 0x00, 0x04, 0x02, 0x06 };
2084 mz_uint8 pnghdr[41] = { 0x89, 0x50, 0x4e, 0x47, 0x0d,
2085 0x0a, 0x1a, 0x0a, 0x00, 0x00,
2086 0x00, 0x0d, 0x49, 0x48, 0x44,
2087 0x52, 0x00, 0x00, 0x00, 0x00,
2088 0x00, 0x00, 0x00, 0x00, 0x08,
2089 0x00, 0x00, 0x00, 0x00, 0x00,
2090 0x00, 0x00, 0x00, 0x00, 0x00,
2091 0x00, 0x00, 0x49, 0x44, 0x41,
2097 pnghdr[25] = chans[num_chans];
2098 pnghdr[33] = (
mz_uint8)(*pLen_out >> 24);
2099 pnghdr[34] = (
mz_uint8)(*pLen_out >> 16);
2100 pnghdr[35] = (
mz_uint8)(*pLen_out >> 8);
2103 for (i = 0; i < 4; ++i, c <<= 8)
2105 memcpy(out_buf.
m_pBuf, pnghdr, 41);
2116 for (i = 0; i < 4; ++i, c <<= 8)
2183#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l)
2184#define TINFL_MEMSET(p, c, l) memset(p, c, l)
2186#define TINFL_CR_BEGIN \
2187 switch (r->m_state) \
2190#define TINFL_CR_RETURN(state_index, result) \
2194 r->m_state = state_index; \
2200#define TINFL_CR_RETURN_FOREVER(state_index, result) \
2205 TINFL_CR_RETURN(state_index, result); \
2209#define TINFL_CR_FINISH }
2211#define TINFL_GET_BYTE(state_index, c) \
2214 while (pIn_buf_cur >= pIn_buf_end) \
2216 TINFL_CR_RETURN(state_index, (decomp_flags &TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \
2218 c = *pIn_buf_cur++; \
2222#define TINFL_NEED_BITS(state_index, n) \
2226 TINFL_GET_BYTE(state_index, c); \
2227 bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \
2229 } while (num_bits < (mz_uint)(n))
2230#define TINFL_SKIP_BITS(state_index, n) \
2233 if (num_bits < (mz_uint)(n)) \
2235 TINFL_NEED_BITS(state_index, n); \
2241#define TINFL_GET_BITS(state_index, b, n) \
2244 if (num_bits < (mz_uint)(n)) \
2246 TINFL_NEED_BITS(state_index, n); \
2248 b = bit_buf & ((1 << (n)) - 1); \
2258#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \
2261 temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \
2264 code_len = temp >> 9; \
2265 if ((code_len) && (num_bits >= code_len)) \
2268 else if (num_bits > TINFL_FAST_LOOKUP_BITS) \
2270 code_len = TINFL_FAST_LOOKUP_BITS; \
2273 temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
2274 } while ((temp < 0) && (num_bits >= (code_len + 1))); \
2278 TINFL_GET_BYTE(state_index, c); \
2279 bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \
2281 } while (num_bits < 15);
2289#define TINFL_HUFF_DECODE(state_index, sym, pHuff) \
2293 mz_uint code_len, c; \
2294 if (num_bits < 15) \
2296 if ((pIn_buf_end - pIn_buf_cur) < 2) \
2298 TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \
2302 bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); \
2307 if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \
2308 code_len = temp >> 9, temp &= 511; \
2311 code_len = TINFL_FAST_LOOKUP_BITS; \
2314 temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
2315 } while (temp < 0); \
2318 bit_buf >>= code_len; \
2319 num_bits -= code_len; \
2325 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 };
2326 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 };
2327 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 };
2328 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 };
2329 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 };
2330 static const int s_min_table_sizes[3] = { 257, 1, 4 };
2333 mz_uint32 num_bits, dist, counter, num_extra;
2335 const mz_uint8 *pIn_buf_cur = pIn_buf_next, *
const pIn_buf_end = pIn_buf_next + *pIn_buf_size;
2336 mz_uint8 *pOut_buf_cur = pOut_buf_next, *
const pOut_buf_end = pOut_buf_next + *pOut_buf_size;
2340 if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start))
2342 *pIn_buf_size = *pOut_buf_size = 0;
2354 bit_buf = num_bits = dist = counter = num_extra = r->
m_zhdr0 = r->
m_zhdr1 = 0;
2362 counter |= (((1U << (8U + (r->
m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (r->
m_zhdr0 >> 4)))));
2376 for (counter = 0; counter < 4; ++counter)
2387 while ((counter) && (num_bits))
2390 while (pOut_buf_cur >= pOut_buf_end)
2400 while (pOut_buf_cur >= pOut_buf_end)
2404 while (pIn_buf_cur >= pIn_buf_end)
2408 n =
MZ_MIN(
MZ_MIN((
size_t)(pOut_buf_end - pOut_buf_cur), (
size_t)(pIn_buf_end - pIn_buf_cur)), counter);
2428 for (i = 0; i <= 143; ++i)
2430 for (; i <= 255; ++i)
2432 for (; i <= 279; ++i)
2434 for (; i <= 287; ++i)
2439 for (counter = 0; counter < 3; counter++)
2455 int tree_next, tree_cur;
2457 mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16];
2464 used_syms = 0, total = 0;
2465 next_code[0] = next_code[1] = 0;
2466 for (i = 1; i <= 15; ++i)
2468 used_syms += total_syms[i];
2469 next_code[i + 1] = (total = ((total + total_syms[i]) << 1));
2471 if ((65536 != total) && (used_syms > 1))
2480 cur_code = next_code[code_size]++;
2481 for (l = code_size; l > 0; l--, cur_code >>= 1)
2482 rev_code = (rev_code << 1) | (cur_code & 1);
2489 rev_code += (1 << code_size);
2496 tree_cur = tree_next;
2502 tree_cur -= ((rev_code >>= 1) & 1);
2503 if (!pTable->
m_tree[-tree_cur - 1])
2506 tree_cur = tree_next;
2510 tree_cur = pTable->
m_tree[-tree_cur - 1];
2512 tree_cur -= ((rev_code >>= 1) & 1);
2526 if ((dist == 16) && (!counter))
2530 num_extra =
"\02\03\07"[dist - 16];
2532 s +=
"\03\03\013"[dist - 16];
2549 if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2))
2554 while (pOut_buf_cur >= pOut_buf_end)
2558 *pOut_buf_cur++ = (
mz_uint8)counter;
2564#if TINFL_USE_64BIT_BITBUF
2580 code_len = sym2 >> 9;
2586 sym2 = r->
m_tables[0].
m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];
2590 bit_buf >>= code_len;
2591 num_bits -= code_len;
2595#if !TINFL_USE_64BIT_BITBUF
2604 code_len = sym2 >> 9;
2610 sym2 = r->
m_tables[0].
m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];
2613 bit_buf >>= code_len;
2614 num_bits -= code_len;
2616 pOut_buf_cur[0] = (
mz_uint8)counter;
2627 if ((counter &= 511) == 256)
2630 num_extra = s_length_extra[counter - 257];
2631 counter = s_length_base[counter - 257];
2636 counter += extra_bits;
2640 num_extra = s_dist_extra[dist];
2641 dist = s_dist_base[dist];
2649 dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;
2655 pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask);
2657 if ((
MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end)
2661 while (pOut_buf_cur >= pOut_buf_end)
2665 *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask];
2669#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
2670 else if ((counter >= 9) && (counter <= dist))
2672 const mz_uint8 *pSrc_end = pSrc + (counter & ~7);
2678 }
while ((pSrc += 8) < pSrc_end);
2679 if ((counter &= 7) < 3)
2683 pOut_buf_cur[0] = pSrc[0];
2685 pOut_buf_cur[1] = pSrc[1];
2686 pOut_buf_cur += counter;
2694 pOut_buf_cur[0] = pSrc[0];
2695 pOut_buf_cur[1] = pSrc[1];
2696 pOut_buf_cur[2] = pSrc[2];
2699 }
while ((
int)(counter -= 3) > 2);
2700 if ((
int)counter > 0)
2702 pOut_buf_cur[0] = pSrc[0];
2703 if ((
int)counter > 1)
2704 pOut_buf_cur[1] = pSrc[1];
2705 pOut_buf_cur += counter;
2714 while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8))
2724 for (counter = 0; counter < 4; ++counter)
2744 while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8))
2756 *pIn_buf_size = pIn_buf_cur - pIn_buf_next;
2757 *pOut_buf_size = pOut_buf_cur - pOut_buf_next;
2760 const mz_uint8 *ptr = pOut_buf_next;
2761 size_t buf_len = *pOut_buf_size;
2763 size_t block_len = buf_len % 5552;
2766 for (i = 0; i + 7 < block_len; i += 8, ptr += 8)
2768 s1 += ptr[0], s2 += s1;
2769 s1 += ptr[1], s2 += s1;
2770 s1 += ptr[2], s2 += s1;
2771 s1 += ptr[3], s2 += s1;
2772 s1 += ptr[4], s2 += s1;
2773 s1 += ptr[5], s2 += s1;
2774 s1 += ptr[6], s2 += s1;
2775 s1 += ptr[7], s2 += s1;
2777 for (; i < block_len; ++i)
2778 s1 += *ptr++, s2 += s1;
2779 s1 %= 65521U, s2 %= 65521U;
2780 buf_len -= block_len;
2794 void *pBuf = NULL, *pNew_buf;
2795 size_t src_buf_ofs = 0, out_buf_capacity = 0;
2800 size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;
2809 src_buf_ofs += src_buf_size;
2810 *pOut_len += dst_buf_size;
2813 new_out_buf_capacity = out_buf_capacity * 2;
2814 if (new_out_buf_capacity < 128)
2815 new_out_buf_capacity = 128;
2816 pNew_buf =
MZ_REALLOC(pBuf, new_out_buf_capacity);
2824 out_buf_capacity = new_out_buf_capacity;
2843 size_t in_buf_ofs = 0, dict_ofs = 0;
2849 size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size =
TINFL_LZ_DICT_SIZE - dict_ofs;
2852 in_buf_ofs += in_buf_size;
2853 if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (
int)dst_buf_size, pPut_buf_user)))
2863 *pIn_buf_size = in_buf_ofs;
2911#ifndef MINIZ_NO_ARCHIVE_APIS
2919#ifdef MINIZ_NO_STDIO
2920#define MZ_FILE void *
2922#include <sys/stat.h>
2924#if defined(_MSC_VER) || defined(__MINGW64__)
2925static FILE *mz_fopen(
const char *pFilename,
const char *pMode)
2928 fopen_s(&pFile, pFilename, pMode);
2931static FILE *mz_freopen(
const char *pPath,
const char *pMode, FILE *pStream)
2934 if (freopen_s(&pFile, pPath, pMode, pStream))
2938#ifndef MINIZ_NO_TIME
2939#include <sys/utime.h>
2941#define MZ_FOPEN mz_fopen
2942#define MZ_FCLOSE fclose
2943#define MZ_FREAD fread
2944#define MZ_FWRITE fwrite
2945#define MZ_FTELL64 _ftelli64
2946#define MZ_FSEEK64 _fseeki64
2947#define MZ_FILE_STAT_STRUCT _stat
2948#define MZ_FILE_STAT _stat
2949#define MZ_FFLUSH fflush
2950#define MZ_FREOPEN mz_freopen
2951#define MZ_DELETE_FILE remove
2952#elif defined(__MINGW32__)
2953#ifndef MINIZ_NO_TIME
2954#include <sys/utime.h>
2956#define MZ_FOPEN(f, m) fopen(f, m)
2957#define MZ_FCLOSE fclose
2958#define MZ_FREAD fread
2959#define MZ_FWRITE fwrite
2960#define MZ_FTELL64 ftello64
2961#define MZ_FSEEK64 fseeko64
2962#define MZ_FILE_STAT_STRUCT _stat
2963#define MZ_FILE_STAT _stat
2964#define MZ_FFLUSH fflush
2965#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
2966#define MZ_DELETE_FILE remove
2967#elif defined(__TINYC__)
2968#ifndef MINIZ_NO_TIME
2969#include <sys/utime.h>
2971#define MZ_FOPEN(f, m) fopen(f, m)
2972#define MZ_FCLOSE fclose
2973#define MZ_FREAD fread
2974#define MZ_FWRITE fwrite
2975#define MZ_FTELL64 ftell
2976#define MZ_FSEEK64 fseek
2977#define MZ_FILE_STAT_STRUCT stat
2978#define MZ_FILE_STAT stat
2979#define MZ_FFLUSH fflush
2980#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
2981#define MZ_DELETE_FILE remove
2982#elif defined(__GNUC__) && _LARGEFILE64_SOURCE
2983#ifndef MINIZ_NO_TIME
2986#define MZ_FOPEN(f, m) fopen64(f, m)
2987#define MZ_FCLOSE fclose
2988#define MZ_FREAD fread
2989#define MZ_FWRITE fwrite
2990#define MZ_FTELL64 ftello64
2991#define MZ_FSEEK64 fseeko64
2992#define MZ_FILE_STAT_STRUCT stat64
2993#define MZ_FILE_STAT stat64
2994#define MZ_FFLUSH fflush
2995#define MZ_FREOPEN(p, m, s) freopen64(p, m, s)
2996#define MZ_DELETE_FILE remove
2997#elif defined(__APPLE__) && _LARGEFILE64_SOURCE
2998#ifndef MINIZ_NO_TIME
3001#define MZ_FOPEN(f, m) fopen(f, m)
3002#define MZ_FCLOSE fclose
3003#define MZ_FREAD fread
3004#define MZ_FWRITE fwrite
3005#define MZ_FTELL64 ftello
3006#define MZ_FSEEK64 fseeko
3007#define MZ_FILE_STAT_STRUCT stat
3008#define MZ_FILE_STAT stat
3009#define MZ_FFLUSH fflush
3010#define MZ_FREOPEN(p, m, s) freopen(p, m, s)
3011#define MZ_DELETE_FILE remove
3014#pragma message("Using fopen, ftello, fseeko, stat() etc. path for file I/O - this path may not support large files.")
3015#ifndef MINIZ_NO_TIME
3018#define MZ_FOPEN(f, m) fopen(f, m)
3019#define MZ_FCLOSE fclose
3020#define MZ_FREAD fread
3021#define MZ_FWRITE fwrite
3022#ifdef __STRICT_ANSI__
3023#define MZ_FTELL64 ftell
3024#define MZ_FSEEK64 fseek
3026#define MZ_FTELL64 ftello
3027#define MZ_FSEEK64 fseeko
3029#define MZ_FILE_STAT_STRUCT stat
3030#define MZ_FILE_STAT stat
3031#define MZ_FFLUSH fflush
3032#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
3033#define MZ_DELETE_FILE remove
3037#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
3160#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size
3162#if defined(DEBUG) || defined(_DEBUG) || defined(NDEBUG)
3168#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[mz_zip_array_range_check(array_ptr, index)]
3170#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index]
3188 size_t new_capacity = min_new_capacity;
3195 while (new_capacity < min_new_capacity)
3200 pArray->
m_p = pNew_p;
3222 pArray->
m_size = new_size;
3233 size_t orig_size = pArray->
m_size;
3240#ifndef MINIZ_NO_TIME
3244 memset(&tm, 0,
sizeof(tm));
3246 tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900;
3247 tm.tm_mon = ((dos_date >> 5) & 15) - 1;
3248 tm.tm_mday = dos_date & 31;
3249 tm.tm_hour = (dos_time >> 11) & 31;
3250 tm.tm_min = (dos_time >> 5) & 63;
3251 tm.tm_sec = (dos_time << 1) & 62;
3255#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
3259 struct tm tm_struct;
3260 struct tm *tm = &tm_struct;
3261 errno_t err = localtime_s(tm, &time);
3269 struct tm *tm = localtime(&time);
3272 *pDOS_time = (
mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1));
3273 *pDOS_date = (
mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday);
3277#ifndef MINIZ_NO_STDIO
3278#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
3287 *pTime = file_stat.st_mtime;
3297 memset(&t, 0,
sizeof(t));
3298 t.actime = access_time;
3299 t.modtime = modified_time;
3301 return !utime(pFilename, &t);
3355 pE = pL +
MZ_MIN(l_len, r_len);
3363 return (pL == pE) ? (l_len < r_len) : (l < r);
3366#define MZ_SWAP_UINT32(a, b) \
3390 start = (size - 2U) >> 1U;
3396 if ((child = (root << 1U) + 1U) >= size)
3398 child += (((child + 1U) < size) && (
mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1U])));
3416 if ((child = (root << 1U) + 1U) >= end)
3418 child += (((child + 1U) < end) &&
mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1U]));
3447 for (i = n - 4; i >= 0; --i)
3450 if (s == record_sig)
3467 cur_file_ofs =
MZ_MAX(cur_file_ofs - (
sizeof(buf_u32) - 3), 0);
3470 *pOfs = cur_file_ofs;
3476 mz_uint cdir_size = 0, cdir_entries_on_this_disk = 0, num_this_disk = 0, cdir_disk_index = 0;
3485 mz_uint8 *pZip64_locator = (
mz_uint8 *)zip64_end_of_central_dir_locator_u32;
3488 mz_uint8 *pZip64_end_of_central_dir = (
mz_uint8 *)zip64_end_of_central_dir_header_u32;
3490 mz_uint64 zip64_end_of_central_dir_ofs = 0;
3545 if (zip64_total_num_of_disks != 1U)
3557 cdir_entries_on_this_disk = (
mz_uint32)zip64_cdir_total_entries_on_this_disk;
3563 cdir_size = (
mz_uint32)zip64_size_of_central_directory;
3575 if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1)))
3594 if (sort_central_dir)
3607 mz_uint total_header_size, disk_index, bit_flags, filename_size, ext_data_size;
3608 mz_uint64 comp_size, decomp_size, local_header_ofs;
3615 if (sort_central_dir)
3629 mz_uint32 extra_size_remaining = ext_data_size;
3631 if (extra_size_remaining)
3640 if (extra_size_remaining < (
sizeof(
mz_uint16) * 2))
3646 if ((field_data_size +
sizeof(
mz_uint16) * 2) > extra_size_remaining)
3657 pExtra_data +=
sizeof(
mz_uint16) * 2 + field_data_size;
3658 extra_size_remaining = extra_size_remaining -
sizeof(
mz_uint16) * 2 - field_data_size;
3659 }
while (extra_size_remaining);
3671 if ((disk_index ==
MZ_UINT16_MAX) || ((disk_index != num_this_disk) && (disk_index != 1)))
3687 n -= total_header_size;
3688 p += total_header_size;
3692 if (sort_central_dir)
3728#ifndef MINIZ_NO_STDIO
3757 if ((!pZip) || (!pZip->
m_pRead))
3817#ifndef MINIZ_NO_STDIO
3848 file_size = archive_size;
3891 if ((!pZip) || (!pFile))
3901 archive_size =
MZ_FTELL64(pFile) - cur_file_ofs;
3988 mz_uint filename_len, attribute_mapping_id, external_attr;
4007 (void)attribute_mapping_id;
4021 const mz_uint8 *p = pCentral_dir_header;
4023 if (pFound_zip64_extra_data)
4024 *pFound_zip64_extra_data =
MZ_FALSE;
4026 if ((!p) || (!pStat))
4036#ifndef MINIZ_NO_TIME
4070 if (extra_size_remaining)
4079 if (extra_size_remaining < (
sizeof(
mz_uint16) * 2))
4085 if ((field_data_size +
sizeof(
mz_uint16) * 2) > extra_size_remaining)
4091 mz_uint32 field_data_remaining = field_data_size;
4093 if (pFound_zip64_extra_data)
4094 *pFound_zip64_extra_data =
MZ_TRUE;
4098 if (field_data_remaining <
sizeof(
mz_uint64))
4103 field_data_remaining -=
sizeof(
mz_uint64);
4108 if (field_data_remaining <
sizeof(
mz_uint64))
4113 field_data_remaining -=
sizeof(
mz_uint64);
4118 if (field_data_remaining <
sizeof(
mz_uint64))
4123 field_data_remaining -=
sizeof(
mz_uint64);
4129 pExtra_data +=
sizeof(
mz_uint16) * 2 + field_data_size;
4130 extra_size_remaining = extra_size_remaining -
sizeof(
mz_uint16) * 2 - field_data_size;
4131 }
while (extra_size_remaining);
4142 return 0 == memcmp(pA, pB, len);
4143 for (i = 0; i < len; ++i)
4155 pE = pL +
MZ_MIN(l_len, r_len);
4163 return (pL == pE) ? (int)(l_len - r_len) : (l - r);
4187 uint32_t file_index = pIndices[(uint32_t)m];
4193 *pIndex = file_index;
4218 size_t name_len, comment_len;
4223 if ((!pZip) || (!pZip->
m_pState) || (!pName))
4235 name_len = strlen(pName);
4239 comment_len = pComment ? strlen(pComment) : 0;
4243 for (file_index = 0; file_index < pZip->
m_total_files; file_index++)
4248 if (filename_len < name_len)
4253 const char *pFile_comment = pFilename + filename_len + file_extra_len;
4254 if ((file_comment_len != comment_len) || (!
mz_zip_string_equal(pComment, pFile_comment, file_comment_len, flags)))
4259 int ofs = filename_len - 1;
4262 if ((pFilename[ofs] ==
'/') || (pFilename[ofs] ==
'\\') || (pFilename[ofs] ==
':'))
4264 }
while (--ofs >= 0);
4267 filename_len -= ofs;
4269 if ((filename_len == name_len) && (
mz_zip_string_equal(pName, pFilename, filename_len, flags)))
4272 *pIndex = file_index;
4283 mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;
4290 if ((!pZip) || (!pZip->
m_pState) || ((buf_size) && (!pBuf)) || ((user_read_buf_size) && (!pUser_read_buf)) || (!pZip->
m_pRead))
4310 if (buf_size < needed_size)
4328 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pBuf, (
size_t)needed_size) != needed_size)
4331#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4349 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
4352 else if (pUser_read_buf)
4355 if (!user_read_buf_size)
4357 pRead_buf = (
mz_uint8 *)pUser_read_buf;
4358 read_buf_size = user_read_buf_size;
4366 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
4379 size_t in_buf_size, out_buf_size = (size_t)(file_stat.
m_uncomp_size - out_buf_ofs);
4382 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
4383 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4389 cur_file_ofs += read_buf_avail;
4390 comp_remaining -= read_buf_avail;
4393 in_buf_size = (size_t)read_buf_avail;
4395 read_buf_avail -= in_buf_size;
4396 read_buf_ofs += in_buf_size;
4397 out_buf_ofs += out_buf_size;
4408#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4443 mz_uint64 comp_size, uncomp_size, alloc_size;
4460 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (alloc_size > 0x7FFFFFFF))
4479 *pSize = (size_t)alloc_size;
4499 mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
4501 void *pRead_buf = NULL;
4502 void *pWrite_buf = NULL;
4540 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
4568#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4579 while (comp_remaining)
4581 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
4582 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4589#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4596 if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4603 cur_file_ofs += read_buf_avail;
4604 out_buf_ofs += read_buf_avail;
4605 comp_remaining -= read_buf_avail;
4627 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
4628 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4634 cur_file_ofs += read_buf_avail;
4635 comp_remaining -= read_buf_avail;
4639 in_buf_size = (size_t)read_buf_avail;
4641 read_buf_avail -= in_buf_size;
4642 read_buf_ofs += in_buf_size;
4646 if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size)
4653#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4656 if ((out_buf_ofs += out_buf_size) > file_stat.
m_uncomp_size)
4675#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4676 else if (file_crc32 != file_stat.
m_crc32)
4702#ifndef MINIZ_NO_STDIO
4722 pFile =
MZ_FOPEN(pDst_filename,
"wb");
4736#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_STDIO)
4788 const mz_uint8 *pCentral_dir_header;
4794 mz_uint32 local_header_filename_len, local_header_extra_len, local_header_crc32;
4795 mz_uint64 local_header_comp_size, local_header_uncomp_size;
4845 has_data_descriptor = (local_header_bit_flags & 8) != 0;
4847 if (local_header_filename_len != strlen(file_stat.
m_filename))
4856 if (local_header_filename_len)
4861 goto handle_failure;
4865 if (memcmp(file_stat.
m_filename, file_data_array.
m_p, local_header_filename_len) != 0)
4868 goto handle_failure;
4874 mz_uint32 extra_size_remaining = local_header_extra_len;
4880 goto handle_failure;
4885 mz_uint32 field_id, field_data_size, field_total_size;
4887 if (extra_size_remaining < (
sizeof(
mz_uint16) * 2))
4892 field_total_size = field_data_size +
sizeof(
mz_uint16) * 2;
4894 if (field_total_size > extra_size_remaining)
4901 if (field_data_size <
sizeof(
mz_uint64) * 2)
4904 goto handle_failure;
4907 local_header_uncomp_size =
MZ_READ_LE64(pSrc_field_data);
4910 found_zip64_ext_data_in_ldir =
MZ_TRUE;
4914 pExtra_data += field_total_size;
4915 extra_size_remaining -= field_total_size;
4916 }
while (extra_size_remaining);
4921 if ((has_data_descriptor) && (!local_header_comp_size) && (!local_header_crc32))
4927 mz_uint64 comp_size = 0, uncomp_size = 0;
4929 mz_uint32 num_descriptor_uint32s = ((pState->
m_zip64) || (found_zip64_ext_data_in_ldir)) ? 6 : 4;
4934 goto handle_failure;
4938 pSrc = has_id ? (descriptor_buf +
sizeof(
mz_uint32)) : descriptor_buf;
4942 if ((pState->
m_zip64) || (found_zip64_ext_data_in_ldir))
4956 goto handle_failure;
4961 if ((local_header_crc32 != file_stat.
m_crc32) || (local_header_comp_size != file_stat.
m_comp_size) || (local_header_uncomp_size != file_stat.
m_uncomp_size))
4964 goto handle_failure;
4976 if (uncomp_crc32 != file_stat.
m_crc32)
5032 if (found_index != i)
5049 if ((!pMem) || (!size))
5084#ifndef MINIZ_NO_STDIO
5129#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
5149#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v))
5150#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v))
5151#define MZ_WRITE_LE64(p, v) mz_write_le64((mz_uint8 *)(p), (mz_uint64)(v))
5163 if ((
sizeof(
size_t) ==
sizeof(
mz_uint32)) && (new_size > 0x7FFFFFFF))
5174 while (new_capacity < new_size)
5183 pState->
m_pMem = pNew_block;
5209#ifndef MINIZ_NO_STDIO
5306 if (0 != (initial_allocation_size =
MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning)))
5324#ifndef MINIZ_NO_STDIO
5370 if (size_to_reserve_at_beginning)
5379 size_t n = (size_t)
MZ_MIN(
sizeof(buf), size_to_reserve_at_beginning);
5386 size_to_reserve_at_beginning -= n;
5387 }
while (size_to_reserve_at_beginning);
5447#ifdef MINIZ_NO_STDIO
5530#define MZ_ZIP64_MAX_LOCAL_EXTRA_FIELD_SIZE (sizeof(mz_uint16) * 2 + sizeof(mz_uint64) * 2)
5531#define MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE (sizeof(mz_uint16) * 2 + sizeof(mz_uint64) * 3)
5555 if (pLocal_header_ofs)
5567static 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)
5611 const void *pExtra,
mz_uint16 extra_size,
const void *pComment,
mz_uint16 comment_size,
5615 const char *user_extra_data,
mz_uint user_extra_data_len)
5624 if (local_header_ofs > 0xFFFFFFFF)
5632 if (!
mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size + user_extra_data_len, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes))
5653 if (*pArchive_name ==
'/')
5656 while (*pArchive_name)
5658 if ((*pArchive_name ==
'\\') || (*pArchive_name ==
':'))
5679 memset(buf, 0,
MZ_MIN(
sizeof(buf), n));
5695 return mz_zip_writer_add_mem_ex_v2(pZip, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, uncomp_size, uncomp_crc32, NULL, NULL, 0, NULL, 0);
5700 const char *user_extra_data,
mz_uint user_extra_data_len,
const char *user_extra_data_central,
mz_uint user_extra_data_central_len)
5702 mz_uint16 method = 0, dos_time = 0, dos_date = 0;
5703 mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
5705 size_t archive_name_size;
5708 mz_bool store_data_uncompressed;
5721 if ((
int)level_and_flags < 0)
5723 level = level_and_flags & 0xF;
5743 if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
5756#ifndef MINIZ_NO_TIME
5757 if (last_modified != NULL)
5769 archive_name_size = strlen(pArchive_name);
5789 if ((archive_name_size) && (pArchive_name[archive_name_size - 1] ==
'/'))
5795 if ((buf_size) || (uncomp_size))
5803 if ((!store_data_uncompressed) && (buf_size))
5815 local_dir_header_ofs += num_alignment_padding_bytes;
5820 cur_archive_file_ofs += num_alignment_padding_bytes;
5833 pExtra_data = extra_data;
5838 if (!
mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (
mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
5841 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, local_dir_header_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
5844 cur_archive_file_ofs +=
sizeof(local_dir_header);
5846 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
5851 cur_archive_file_ofs += archive_name_size;
5853 if (pExtra_data != NULL)
5855 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
5858 cur_archive_file_ofs += extra_size;
5865 if (!
mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (
mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
5868 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, local_dir_header_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
5871 cur_archive_file_ofs +=
sizeof(local_dir_header);
5873 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
5878 cur_archive_file_ofs += archive_name_size;
5881 if (user_extra_data_len > 0)
5883 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
5886 cur_archive_file_ofs += user_extra_data_len;
5892 uncomp_size = buf_size;
5893 if (uncomp_size <= 3)
5896 store_data_uncompressed =
MZ_TRUE;
5900 if (store_data_uncompressed)
5908 cur_archive_file_ofs += buf_size;
5909 comp_size = buf_size;
5942 if (pExtra_data == NULL)
5957 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
5960 cur_archive_file_ofs += local_dir_footer_size;
5963 if (pExtra_data != NULL)
5970 comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
5971 user_extra_data_central, user_extra_data_central_len))
5980#ifndef MINIZ_NO_STDIO
5982 const char *user_extra_data,
mz_uint user_extra_data_len,
const char *user_extra_data_central,
mz_uint user_extra_data_central_len)
5986 mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;
5987 mz_uint64 local_dir_header_ofs, cur_archive_file_ofs = pZip->
m_archive_size, uncomp_size = size_to_add, comp_size = 0;
5988 size_t archive_name_size;
5998 if ((
int)level_and_flags < 0)
6000 level = level_and_flags & 0xF;
6036 archive_name_size = strlen(pArchive_name);
6056#ifndef MINIZ_NO_TIME
6063 if (uncomp_size <= 3)
6071 cur_archive_file_ofs += num_alignment_padding_bytes;
6072 local_dir_header_ofs = cur_archive_file_ofs;
6079 if (uncomp_size && level)
6089 pExtra_data = extra_data;
6094 if (!
mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (
mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
6097 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
6100 cur_archive_file_ofs +=
sizeof(local_dir_header);
6102 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
6107 cur_archive_file_ofs += archive_name_size;
6109 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
6112 cur_archive_file_ofs += extra_size;
6118 if (!
mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (
mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
6121 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, local_dir_header,
sizeof(local_dir_header)) !=
sizeof(local_dir_header))
6124 cur_archive_file_ofs +=
sizeof(local_dir_header);
6126 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
6131 cur_archive_file_ofs += archive_name_size;
6134 if (user_extra_data_len > 0)
6136 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
6139 cur_archive_file_ofs += user_extra_data_len;
6144 mz_uint64 uncomp_remaining = uncomp_size;
6153 while (uncomp_remaining)
6162 uncomp_remaining -= n;
6163 cur_archive_file_ofs += n;
6165 comp_size = uncomp_size;
6195 if (
MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
6202 uncomp_remaining -= in_buf_size;
6241 if (pExtra_data == NULL)
6256 if (pZip->
m_pWrite(pZip->
m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
6259 cur_archive_file_ofs += local_dir_footer_size;
6262 if (pExtra_data != NULL)
6269 uncomp_size, comp_size, uncomp_crc32, method, gen_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
6270 user_extra_data_central, user_extra_data_central_len))
6287 memset(&file_modified_time, 0,
sizeof(file_modified_time));
6289#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_STDIO)
6290 pFile_time = &file_modified_time;
6295 pSrc_file =
MZ_FOPEN(pSrc_filename,
"rb");
6303 status =
mz_zip_writer_add_cfile(pZip, pArchive_name, pSrc_file, uncomp_size, pFile_time, pComment, comment_size, level_and_flags, NULL, 0, NULL, 0);
6319 if ((pUncomp_size) || (pComp_size) || (pLocal_header_ofs) || (pDisk_start))
6339 if (pLocal_header_ofs)
6357 if ((pExt) && (ext_len))
6359 mz_uint32 extra_size_remaining = ext_len;
6360 const mz_uint8 *pExtra_data = pExt;
6364 mz_uint32 field_id, field_data_size, field_total_size;
6366 if (extra_size_remaining < (
sizeof(
mz_uint16) * 2))
6371 field_total_size = field_data_size +
sizeof(
mz_uint16) * 2;
6373 if (field_total_size > extra_size_remaining)
6382 pExtra_data += field_total_size;
6383 extra_size_remaining -= field_total_size;
6384 }
while (extra_size_remaining);
6393 mz_uint n, bit_flags, num_alignment_padding_bytes, src_central_dir_following_data_size;
6394 mz_uint64 src_archive_bytes_remaining, local_dir_header_ofs;
6395 mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;
6399 size_t orig_central_dir_size;
6402 const mz_uint8 *pSrc_central_header;
6404 mz_uint32 src_filename_len, src_comment_len, src_ext_len;
6405 mz_uint32 local_header_filename_size, local_header_extra_len;
6406 mz_uint64 local_header_comp_size, local_header_uncomp_size;
6420 if (NULL == (pSrc_central_header =
mz_zip_get_cdh(pSource_zip, src_file_index)))
6429 src_central_dir_following_data_size = src_filename_len + src_ext_len + src_comment_len;
6469 src_archive_bytes_remaining = local_header_filename_size + local_header_extra_len + src_file_stat.
m_comp_size;
6476 mz_uint32 extra_size_remaining = local_header_extra_len;
6490 pExtra_data = (
const mz_uint8 *)file_data_array.
m_p;
6494 mz_uint32 field_id, field_data_size, field_total_size;
6496 if (extra_size_remaining < (
sizeof(
mz_uint16) * 2))
6504 field_total_size = field_data_size +
sizeof(
mz_uint16) * 2;
6506 if (field_total_size > extra_size_remaining)
6516 if (field_data_size <
sizeof(
mz_uint64) * 2)
6522 local_header_uncomp_size =
MZ_READ_LE64(pSrc_field_data);
6525 found_zip64_ext_data_in_ldir =
MZ_TRUE;
6529 pExtra_data += field_total_size;
6530 extra_size_remaining -= field_total_size;
6531 }
while (extra_size_remaining);
6536 if (!pState->m_zip64)
6551 cur_dst_file_ofs += num_alignment_padding_bytes;
6553 local_dir_header_ofs = cur_dst_file_ofs;
6554 if (pZip->m_file_offset_alignment)
6556 MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
6569 while (src_archive_bytes_remaining)
6572 if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n)
6574 pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
6577 cur_src_file_ofs += n;
6579 if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
6581 pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
6584 cur_dst_file_ofs += n;
6586 src_archive_bytes_remaining -= n;
6594 if ((pSource_zip->m_pState->m_zip64) || (found_zip64_ext_data_in_ldir))
6603 if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, (
sizeof(
mz_uint32) * 6)) != (
sizeof(
mz_uint32) * 6))
6605 pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
6616 if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf,
sizeof(
mz_uint32) * 4) !=
sizeof(
mz_uint32) * 4)
6618 pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
6624 if (pZip->m_pState->m_zip64)
6628 const mz_uint32 src_crc32 = pSrc_descriptor[0];
6629 const mz_uint64 src_comp_size = pSrc_descriptor[1];
6630 const mz_uint64 src_uncomp_size = pSrc_descriptor[2];
6642 n =
sizeof(
mz_uint32) * (has_id ? 4 : 3);
6646 if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
6648 pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
6652 cur_src_file_ofs += n;
6653 cur_dst_file_ofs += n;
6655 pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
6658 orig_central_dir_size = pState->m_central_dir.m_size;
6662 if (pState->m_zip64)
6747 pZip->m_total_files++;
6748 pZip->m_archive_size = cur_dst_file_ofs;
6756 mz_uint64 central_dir_ofs, central_dir_size;
6775 central_dir_ofs = 0;
6776 central_dir_size = 0;
6830#ifndef MINIZ_NO_STDIO
6843 if ((!ppBuf) || (!pSize))
6871#ifndef MINIZ_NO_STDIO
6885 if ((
int)level_and_flags < 0)
6888 if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) >
MZ_UBER_COMPRESSION))
6914 created_new_archive =
MZ_TRUE;
6937 status =
mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0);
6957 if ((!status) && (created_new_archive))
6961 (void)ignoredStatus;
6979 if ((!pZip_filename) || (!pArchive_name))
7076 return "undefined error";
7078 return "too many files";
7080 return "file too large";
7082 return "unsupported method";
7084 return "unsupported encryption";
7086 return "unsupported feature";
7088 return "failed finding central directory";
7090 return "not a ZIP archive";
7092 return "invalid header or archive is corrupted";
7094 return "unsupported multidisk archive";
7096 return "decompression failed or archive is corrupted";
7098 return "compression failed";
7100 return "unexpected decompressed size";
7102 return "CRC-32 check failed";
7104 return "unsupported central directory size";
7106 return "allocation failed";
7108 return "file open failed";
7110 return "file create failed";
7112 return "file write failed";
7114 return "file read failed";
7116 return "file close failed";
7118 return "file seek failed";
7120 return "file stat failed";
7122 return "invalid parameter";
7124 return "invalid filename";
7126 return "buffer too small";
7128 return "internal error";
7130 return "file not found";
7132 return "archive is too large";
7134 return "validation failed";
7136 return "write calledback failed";
7141 return "unknown error";
7201 if (filename_buf_size)
7202 pFilename[0] =
'\0';
7207 if (filename_buf_size)
7209 n =
MZ_MIN(n, filename_buf_size - 1);
7211 pFilename[n] =
'\0';
7228#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
for(uint32_t i=0;i< queueCount;i++)
if(err !=VK_SUCCESS)
Creates the platform specific surface abstraction of the native platform window used for presentation...
#define MZ_WRITE_LE32(p, v)
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
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, const char *user_extra_data, mz_uint user_extra_data_len)
mz_bool mz_zip_is_zip64(mz_zip_archive *pZip)
static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n)
static const mz_uint8 s_tdefl_len_extra[256]
mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags)
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
mz_zip_type mz_zip_get_type(mz_zip_archive *pZip)
static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
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)
void * miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size)
static const mz_uint16 s_tdefl_len_sym[256]
mz_bool mz_zip_end(mz_zip_archive *pZip)
static int tdefl_flush_block(tdefl_compressor *d, int flush)
static MZ_FORCEINLINE void mz_write_le32(mz_uint8 *p, mz_uint32 v)
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
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)
mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning)
#define MZ_WRITE_LE16(p, v)
void * tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip)
static void tdefl_start_dynamic_block(tdefl_compressor *d)
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
int mz_deflateReset(mz_streamp pStream)
#define TINFL_GET_BYTE(state_index, c)
#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size)
static mz_bool mz_zip_writer_end_internal(mz_zip_archive *pZip, mz_bool set_last_error)
size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip)
static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint file_index, const mz_uint8 *pCentral_dir_header, mz_zip_archive_file_stat *pStat, mz_bool *pFound_zip64_extra_data)
int mz_inflateInit(mz_streamp pStream)
int mz_inflate(mz_streamp pStream, int flush)
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
mz_uint32 tdefl_get_adler32(tdefl_compressor *d)
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)
#define TDEFL_RLE_ZERO_CODE_SIZE()
mz_ulong mz_compressBound(mz_ulong source_len)
static mz_bool mz_zip_set_file_times(const char *pFilename, MZ_TIME_T access_time, MZ_TIME_T modified_time)
static MZ_FORCEINLINE void mz_write_le16(mz_uint8 *p, mz_uint16 v)
static mz_bool mz_zip_reader_locate_header_sig(mz_zip_archive *pZip, mz_uint32 record_sig, mz_uint32 record_size, mz_int64 *pOfs)
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)
int mz_deflateEnd(mz_streamp pStream)
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)
mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip)
#define MZ_FREOPEN(f, m, s)
static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n)
static const mz_uint8 s_tdefl_small_dist_sym[512]
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d)
size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n)
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)
mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags)
static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index)
void * tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser)
static mz_bool mz_zip_get_file_modified_time(const char *pFilename, MZ_TIME_T *pTime)
mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr)
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)
unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 :-1]
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)
void * miniz_def_alloc_func(void *opaque, size_t items, size_t size)
#define TINFL_MEMCPY(d, s, l)
#define TINFL_GET_BITS(state_index, b, n)
mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex)
static const mz_uint8 s_tdefl_small_dist_extra[512]
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d)
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size)
static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint flags)
static mz_bool mz_zip_reader_end_internal(mz_zip_archive *pZip, mz_bool set_last_error)
mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip)
mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags)
#define TINFL_HUFF_DECODE(state_index, sym, pHuff)
mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip)
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags)
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush)
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)
mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr)
static const mz_uint8 s_tdefl_large_dist_extra[128]
static const mz_uint s_tdefl_num_probes[11]
int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy)
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags)
const char * mz_version(void)
static mz_bool tdefl_compress_normal(tdefl_compressor *d)
int mz_deflateInit(mz_streamp pStream, int level)
static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n)
void * mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr)
static MZ_FORCEINLINE void mz_zip_array_init(mz_zip_array *pArray, mz_uint32 element_size)
const char * mz_zip_get_error_string(mz_zip_error mz_err)
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)
void * mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags)
static MZ_FORCEINLINE const mz_uint8 * mz_zip_get_cdh(mz_zip_archive *pZip, mz_uint file_index)
void miniz_def_free_func(void *opaque, void *address)
static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size)
static void tdefl_start_static_block(tdefl_compressor *d)
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level)
static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flags)
mz_bool mz_zip_writer_end(mz_zip_archive *pZip)
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)
mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags)
#define TINFL_MEMSET(p, c, l)
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)
static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
static void mz_zip_time_t_to_dos_time(MZ_TIME_T time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date)
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n)
static MZ_TIME_T mz_zip_dos_to_time_t(int dos_time, int dos_date)
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index)
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size)
const char * mz_error(int err)
mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len)
void mz_zip_zero_struct(mz_zip_archive *pZip)
static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray)
static MZ_FORCEINLINE int mz_zip_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)
static mz_uint32 mz_zip_writer_create_zip64_extra_data(mz_uint8 *pBuf, mz_uint64 *pUncomp_size, mz_uint64 *pComp_size, mz_uint64 *pLocal_header_ofs)
mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip)
tdefl_compressor * tdefl_compressor_alloc()
MZ_FILE * mz_zip_get_cfile(mz_zip_archive *pZip)
static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip)
int mz_inflateInit2(mz_streamp pStream, int window_bits)
static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len, void *pUser)
static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name)
static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
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)
static MZ_FORCEINLINE mz_bool mz_zip_set_error(mz_zip_archive *pZip, mz_zip_error err_num)
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index)
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index)
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)
#define TINFL_CR_RETURN(state_index, result)
#define TINFL_CR_RETURN_FOREVER(state_index, result)
mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num)
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
#define MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE
static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit)
void * mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags)
static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing)
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags)
static mz_bool mz_zip_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename, mz_uint32 *pIndex)
mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size)
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
void tdefl_compressor_free(tdefl_compressor *pComp)
@ MZ_ZIP64_ECDH_VERSION_MADE_BY_OFS
@ MZ_ZIP_CDH_FILENAME_LEN_OFS
@ MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR
@ MZ_ZIP_LOCAL_DIR_HEADER_SIG
@ MZ_ZIP_CDH_FILE_DATE_OFS
@ MZ_ZIP_LDH_BIT_FLAG_OFS
@ MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS
@ MZ_ZIP_CDH_VERSION_NEEDED_OFS
@ MZ_ZIP_DATA_DESCRIPTER_SIZE64
@ MZ_ZIP_CDH_LOCAL_HEADER_OFS
@ MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG
@ MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8
@ MZ_ZIP64_ECDH_NUM_DISK_CDIR_OFS
@ MZ_ZIP_CDH_COMPRESSED_SIZE_OFS
@ MZ_ZIP_DATA_DESCRIPTER_SIZE32
@ MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS
@ MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG
@ MZ_ZIP64_ECDL_NUM_DISK_CDIR_OFS
@ MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS
@ MZ_ZIP_ECDH_CDIR_SIZE_OFS
@ MZ_ZIP_LDH_FILENAME_LEN_OFS
@ MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE
@ MZ_ZIP_DOS_DIR_ATTRIBUTE_BITFLAG
@ MZ_ZIP_LDH_FILE_TIME_OFS
@ MZ_ZIP64_ECDH_VERSION_NEEDED_OFS
@ MZ_ZIP_CDH_EXTRA_LEN_OFS
@ MZ_ZIP_LDH_FILE_DATE_OFS
@ MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS
@ MZ_ZIP64_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS
@ MZ_ZIP_LDH_COMPRESSED_SIZE_OFS
@ MZ_ZIP_CDH_FILE_TIME_OFS
@ MZ_ZIP_VERSION_MADE_BY_DOS_FILESYSTEM_ID
@ MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS
@ MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID
@ MZ_ZIP_CENTRAL_DIR_HEADER_SIG
@ MZ_ZIP_ECDH_COMMENT_SIZE_OFS
@ MZ_ZIP64_ECDH_CDIR_SIZE_OFS
@ MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS
@ MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION
@ MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG
@ MZ_ZIP_CDH_DISK_START_OFS
@ MZ_ZIP64_ECDH_CDIR_TOTAL_ENTRIES_OFS
@ MZ_ZIP_CDH_INTERNAL_ATTR_OFS
@ MZ_ZIP_LDH_VERSION_NEEDED_OFS
@ MZ_ZIP_ECDH_CDIR_OFS_OFS
@ MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG
@ MZ_ZIP_LDH_EXTRA_LEN_OFS
@ MZ_ZIP_CDH_EXTERNAL_ATTR_OFS
@ MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_LOCAL_DIR_IS_MASKED
@ MZ_ZIP64_ECDH_NUM_THIS_DISK_OFS
@ MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE
@ MZ_ZIP_LOCAL_DIR_HEADER_SIZE
@ MZ_ZIP64_ECDH_CDIR_OFS_OFS
@ MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS
@ MZ_ZIP_CDH_BIT_FLAG_OFS
@ MZ_ZIP_CDH_COMMENT_LEN_OFS
@ MZ_ZIP_CENTRAL_DIR_HEADER_SIZE
@ MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE
@ MZ_ZIP_DATA_DESCRIPTOR_ID
@ MZ_ZIP_CDH_VERSION_MADE_BY_OFS
@ MZ_ZIP_ECDH_NUM_THIS_DISK_OFS
@ MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED
@ MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS
mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip)
unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 :-1]
int mz_inflateEnd(mz_streamp pStream)
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)
static const mz_uint mz_bitmasks[17]
void * mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags)
int mz_deflate(mz_streamp pStream, int flush)
@ TDEFL_MAX_SUPPORTED_HUFF_CODESIZE
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)
#define MZ_FILE_STAT_STRUCT
static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[]
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)
static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n)
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)
static MZ_FORCEINLINE mz_bool mz_zip_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags)
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)
#define MZ_SWAP_UINT32(a, b)
static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table)
static const mz_uint8 s_tdefl_large_dist_sym[128]
mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr)
mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags)
void * tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out)
mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len)
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy)
static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block)
static size_t mz_zip_compute_crc32_callback(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist)
#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index)
static mz_bool mz_zip_writer_update_zip64_extension_block(mz_zip_array *pNew_ext, mz_zip_archive *pZip, const mz_uint8 *pExt, uint32_t ext_len, mz_uint64 *pComp_size, mz_uint64 *pUncomp_size, mz_uint64 *pLocal_header_ofs, mz_uint32 *pDisk_start)
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *pFile, mz_uint flags)
mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags)
tinfl_decompressor * tinfl_decompressor_alloc()
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)
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize)
unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 :-1]
static MZ_FORCEINLINE void mz_write_le64(mz_uint8 *p, mz_uint64 v)
mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags)
#define MZ_WRITE_LE64(p, v)
mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags)
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)
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename)
static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing)
mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip)
#define TINFL_SKIP_BITS(state_index, n)
mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing)
#define TDEFL_RLE_PREV_CODE_SIZE()
mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags)
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d)
void tinfl_decompressor_free(tinfl_decompressor *pDecomp)
#define TDEFL_PUT_BITS(b, l)
static tdefl_sym_freq * tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq *pSyms0, tdefl_sym_freq *pSyms1)
@ MZ_ZIP_FLAG_ASCII_FILENAME
@ MZ_ZIP_FLAG_WRITE_ZIP64
@ MZ_ZIP_FLAG_WRITE_ALLOW_READING
@ MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY
@ MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG
@ MZ_ZIP_FLAG_COMPRESSED_DATA
@ MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY
@ MZ_ZIP_FLAG_CASE_SENSITIVE
@ MZ_ZIP_FLAG_IGNORE_PATH
size_t(* mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
@ TINFL_STATUS_ADLER32_MISMATCH
@ TINFL_STATUS_NEEDS_MORE_INPUT
@ TINFL_STATUS_HAS_MORE_OUTPUT
@ TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS
#define TINFL_LZ_DICT_SIZE
@ TDEFL_FORCE_ALL_RAW_BLOCKS
@ TDEFL_GREEDY_PARSING_FLAG
@ TDEFL_FORCE_ALL_STATIC_BLOCKS
@ TDEFL_WRITE_ZLIB_HEADER
@ TDEFL_NONDETERMINISTIC_PARSING_FLAG
#define MZ_CLEAR_OBJ(obj)
int(* tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)
#define tinfl_get_adler32(r)
#define MZ_DEFAULT_WINDOW_BITS
@ TDEFL_LEVEL1_HASH_SIZE_MASK
@ MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE
@ MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE
@ TDEFL_MAX_HUFF_SYMBOLS_0
@ TDEFL_LZ_DICT_SIZE_MASK
@ TDEFL_MAX_HUFF_SYMBOLS_1
@ TDEFL_MAX_HUFF_SYMBOLS_2
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED
@ TDEFL_STATUS_PUT_BUF_FAILED
@ MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED
mz_bool(* tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)
@ MZ_ZIP_UNSUPPORTED_METHOD
@ MZ_ZIP_UNSUPPORTED_FEATURE
@ MZ_ZIP_FILE_OPEN_FAILED
@ MZ_ZIP_WRITE_CALLBACK_FAILED
@ MZ_ZIP_CRC_CHECK_FAILED
@ MZ_ZIP_FILE_CLOSE_FAILED
@ MZ_ZIP_FILE_CREATE_FAILED
@ MZ_ZIP_VALIDATION_FAILED
@ MZ_ZIP_FILE_STAT_FAILED
@ MZ_ZIP_INVALID_FILENAME
@ MZ_ZIP_COMPRESSION_FAILED
@ MZ_ZIP_UNSUPPORTED_ENCRYPTION
@ MZ_ZIP_UNSUPPORTED_MULTIDISK
@ MZ_ZIP_ARCHIVE_TOO_LARGE
@ MZ_ZIP_DECOMPRESSION_FAILED
@ MZ_ZIP_FILE_WRITE_FAILED
@ MZ_ZIP_INVALID_PARAMETER
@ MZ_ZIP_INVALID_HEADER_OR_CORRUPTED
@ MZ_ZIP_UNSUPPORTED_CDIR_SIZE
@ MZ_ZIP_FILE_READ_FAILED
@ MZ_ZIP_FAILED_FINDING_CENTRAL_DIR
@ MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE
@ MZ_ZIP_FILE_SEEK_FAILED
@ TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF
@ TINFL_FLAG_HAS_MORE_INPUT
@ TINFL_FLAG_COMPUTE_ADLER32
@ TINFL_FLAG_PARSE_ZLIB_HEADER
mz_uint32 tinfl_bit_buf_t
mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]
tinfl_status m_last_status
tinfl_decompressor m_decomp
struct mz_internal_state * state
const unsigned char * next_in
mz_uint32 m_external_attr
mz_uint16 m_version_needed
mz_uint16 m_version_made_by
mz_uint64 m_central_dir_ofs
mz_uint64 m_local_header_ofs
mz_uint16 m_internal_attr
char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]
char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]
mz_uint64 m_central_directory_file_ofs
mz_zip_error m_last_error
mz_file_needs_keepalive m_pNeeds_keepalive
mz_file_write_func m_pWrite
mz_zip_internal_state * m_pState
mz_realloc_func m_pRealloc
mz_file_read_func m_pRead
mz_uint64 m_file_offset_alignment
mz_bool m_zip64_has_extended_info_fields
mz_zip_array m_sorted_central_dir_offsets
mz_uint64 m_file_archive_start_ofs
mz_zip_array m_central_dir_offsets
mz_zip_array m_central_dir
mz_uint64 m_cur_archive_file_ofs
mz_uint m_saved_match_dist
mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]
mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
mz_uint m_output_flush_remaining
mz_uint m_wants_to_finish
tdefl_status m_prev_return_status
mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE+TDEFL_MAX_MATCH_LEN - 1]
tdefl_put_buf_func_ptr m_pPut_buf_func
mz_uint m_output_flush_ofs
mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]
mz_uint8 * m_pOutput_buf_end
mz_uint m_saved_match_len
mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
mz_uint m_lz_code_buf_dict_pos
mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]
mz_uint8 * m_pLZ_code_buf
mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]
mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]
tinfl_bit_buf_t m_bit_buf
size_t m_dist_from_out_buf_start
mz_uint32 m_check_adler32
tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]
mz_uint32 m_table_sizes[TINFL_MAX_HUFF_TABLES]
mz_uint8 m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0+TINFL_MAX_HUFF_SYMBOLS_1+137]
mz_int16 m_tree[TINFL_MAX_HUFF_SYMBOLS_0 *2]
mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]
mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE]