1 #include "../idlib/precompiled.h"
89 # define MAX_MEM_LEVEL 8
91 # define MAX_MEM_LEVEL 9
101 # define MAX_WBITS 15
120 #define OF(args) args
136 #define ZLIB_VERSION "1.1.3"
194 #define Z_PARTIAL_FLUSH 1
195 #define Z_SYNC_FLUSH 2
196 #define Z_FULL_FLUSH 3
201 #define Z_STREAM_END 1
202 #define Z_NEED_DICT 2
204 #define Z_STREAM_ERROR (-2)
205 #define Z_DATA_ERROR (-3)
206 #define Z_MEM_ERROR (-4)
207 #define Z_BUF_ERROR (-5)
208 #define Z_VERSION_ERROR (-6)
213 #define Z_NO_COMPRESSION 0
214 #define Z_BEST_SPEED 1
215 #define Z_BEST_COMPRESSION 9
216 #define Z_DEFAULT_COMPRESSION (-1)
220 #define Z_HUFFMAN_ONLY 2
221 #define Z_DEFAULT_STRATEGY 0
234 #define zlib_version zlibVersion()
239 const char * zlibVersion
OF((
void));
513 const Byte *dictionary,
622 const Byte *dictionary,
727 gzFile gzopen
OF((
const char *
path,
const char *
mode));
743 gzFile gzdopen
OF((
int fd,
const char *
mode));
756 int gzsetparams
OF((gzFile file,
int level,
int strategy));
764 int gzread
OF((gzFile file,
voidp buf,
unsigned len));
772 int gzwrite
OF((gzFile file,
780 int gzprintf
OF((gzFile file,
const char *
format, ...));
787 int gzputs
OF((gzFile file,
const char *
s));
794 char * gzgets
OF((gzFile file,
char *buf,
int len));
803 int gzputc
OF((gzFile file,
int c));
809 int gzgetc
OF((gzFile file));
815 int gzflush
OF((gzFile file,
int flush));
825 long gzseek
OF((gzFile file,
826 long offset,
int whence));
843 int gzrewind
OF((gzFile file));
850 long gztell
OF((gzFile file));
859 int gzeof
OF((gzFile file));
865 int gzclose
OF((gzFile file));
872 const char * gzerror
OF((gzFile file,
int *errnum));
929 const char *
version,
int stream_size));
931 const char *
version,
int stream_size));
933 int windowBits,
int memLevel,
934 int strategy,
const char *
version,
937 const char *
version,
int stream_size));
938 #define deflateInit(strm, level) \
939 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
940 #define inflateInit(strm) \
941 inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
942 #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
943 deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
944 (strategy), ZLIB_VERSION, sizeof(z_stream))
945 #define inflateInit2(strm, windowBits) \
946 inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
949 const char * zError
OF((
int err));
953 typedef unsigned char uch;
954 typedef unsigned short ush;
955 typedef unsigned long ulg;
960 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
962 #define ERR_RETURN(strm,err) \
963 return (strm->msg = (char*)ERR_MSG(err), (err))
969 # define DEF_WBITS MAX_WBITS
973 #if MAX_MEM_LEVEL >= 8
974 # define DEF_MEM_LEVEL 8
976 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
980 #define STORED_BLOCK 0
981 #define STATIC_TREES 1
986 #define MAX_MATCH 258
989 #define PRESET_DICT 0x20
996 # define OS_CODE 0x03
1000 # define F_OPEN(name, mode) fopen((name), (mode))
1005 #ifdef HAVE_STRERROR
1006 extern char *strerror
OF((
int));
1007 # define zstrerror(errnum) strerror(errnum)
1009 # define zstrerror(errnum) ""
1012 #define zmemcpy memcpy
1013 #define zmemcmp memcmp
1014 #define zmemzero(dest, len) memset(dest, 0, len)
1019 # define Assert(cond,msg) assert(cond);
1021 # define Trace(x) {if (z_verbose>=0) Sys_Error x ;}
1022 # define Tracev(x) {if (z_verbose>0) Sys_Error x ;}
1023 # define Tracevv(x) {if (z_verbose>1) Sys_Error x ;}
1024 # define Tracec(c,x) {if (z_verbose>0 && (c)) Sys_Error x ;}
1025 # define Tracecv(c,x) {if (z_verbose>1 && (c)) Sys_Error x ;}
1027 # define Assert(cond,msg)
1031 # define Tracec(c,x)
1032 # define Tracecv(c,x)
1040 #define ZALLOC(strm, items, size) \
1041 (*((strm)->zalloc))((strm)->opaque, (items), (size))
1042 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidp)(addr))
1043 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
1046 #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \
1047 !defined(CASESENSITIVITYDEFAULT_NO)
1048 #define CASESENSITIVITYDEFAULT_NO
1053 #define UNZ_BUFSIZE (65536)
1056 #ifndef UNZ_MAXFILENAMEINZIP
1057 #define UNZ_MAXFILENAMEINZIP (256)
1061 # define ALLOC(size) (Mem_Alloc(size))
1064 # define TRYFREE(p) {if (p) Mem_Free(p);}
1067 #define SIZECENTRALDIRITEM (0x2e)
1068 #define SIZEZIPLOCALHEADER (0x1e)
1101 static int unzlocal_getShort (FILE* fin,
uLong *pX)
1105 fread( &v,
sizeof(v), 1, fin );
1130 static int unzlocal_getLong (FILE *fin,
uLong *pX)
1134 fread( &v,
sizeof(v), 1, fin );
1169 static int strcmpcasenosensitive_internal (
const char* fileName1,
const char* fileName2)
1173 char c1=*(fileName1++);
1174 char c2=*(fileName2++);
1175 if ((c1>=
'a') && (c1<=
'z'))
1177 if ((c2>=
'a') && (c2<=
'z'))
1180 return ((c2==
'\0') ? 0 : -1);
1191 #ifdef CASESENSITIVITYDEFAULT_NO
1192 #define CASESENSITIVITYDEFAULTVALUE 2
1194 #define CASESENSITIVITYDEFAULTVALUE 1
1197 #ifndef STRCMPCASENOSENTIVEFUNCTION
1198 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
1212 if (iCaseSensitivity==0)
1215 if (iCaseSensitivity==1)
1216 return strcmp(fileName1,fileName2);
1221 #define BUFREADCOMMENT (0x400)
1227 static uLong unzlocal_SearchCentralDir(FILE *fin)
1232 uLong uMaxBack=0xffff;
1239 uSizeFile = ftell( fin );
1241 if (uMaxBack>uSizeFile)
1242 uMaxBack = uSizeFile;
1249 while (uBackRead<uMaxBack)
1251 uLong uReadSize,uReadPos ;
1254 uBackRead = uMaxBack;
1257 uReadPos = uSizeFile-uBackRead ;
1261 if (fseek(fin,uReadPos,
SEEK_SET)!=0)
1264 if (
fread(buf,(
uInt)uReadSize,1,fin)!=1)
1267 for (i=(
int)uReadSize-3; (i--)>0;)
1268 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
1269 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
1271 uPosFound = uReadPos+
i;
1287 fin=fopen(path,
"rb");
1313 uLong central_pos,uL;
1318 uLong number_disk_with_CD;
1320 uLong number_entry_CD;
1326 fin=fopen(path,
"rb");
1330 central_pos = unzlocal_SearchCentralDir(fin);
1334 if (fseek(fin,central_pos,
SEEK_SET)!=0)
1338 if (unzlocal_getLong(fin,&uL)!=
UNZ_OK)
1342 if (unzlocal_getShort(fin,&number_disk)!=
UNZ_OK)
1346 if (unzlocal_getShort(fin,&number_disk_with_CD)!=
UNZ_OK)
1354 if (unzlocal_getShort(fin,&number_entry_CD)!=
UNZ_OK)
1358 (number_disk_with_CD!=0) ||
1430 *pglobal_info=s->
gi;
1438 static void unzlocal_DosDateToTmuDate (
uLong ulDosDate,
tm_unz* ptm)
1441 uDate = (
uLong)(ulDosDate>>16);
1443 ptm->
tm_mon = (
uInt)((((uDate)&0x1E0)/0x20)-1) ;
1444 ptm->
tm_year = (
uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
1446 ptm->
tm_hour = (
uInt) ((ulDosDate &0xF800)/0x800);
1447 ptm->
tm_min = (
uInt) ((ulDosDate&0x7E0)/0x20) ;
1454 static int unzlocal_GetCurrentFileInfoInternal (
unzFile file,
1457 *pfile_info_internal,
1459 uLong fileNameBufferSize,
1461 uLong extraFieldBufferSize,
1463 uLong commentBufferSize)
1481 if (unzlocal_getLong(s->
file,&uMagic) !=
UNZ_OK)
1483 else if (uMagic!=0x02014b50)
1543 uSizeRead = fileNameBufferSize;
1558 uSizeRead = extraFieldBufferSize;
1583 uSizeRead = commentBufferSize;
1599 *pfile_info=file_info;
1601 if ((err==
UNZ_OK) && (pfile_info_internal!=
NULL))
1602 *pfile_info_internal=file_info_internal;
1613 char *szFileName,
uLong fileNameBufferSize,
1614 void *extraField,
uLong extraFieldBufferSize,
1615 char *szComment,
uLong commentBufferSize)
1617 return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,
NULL,
1618 szFileName,fileNameBufferSize,
1619 extraField,extraFieldBufferSize,
1620 szComment,commentBufferSize);
1636 err=unzlocal_GetCurrentFileInfoInternal(file,&s->
cur_file_info,
1664 err = unzlocal_GetCurrentFileInfoInternal(file,&s->
cur_file_info,
1701 err = unzlocal_GetCurrentFileInfoInternal(file,&s->
cur_file_info,
1722 uLong num_fileSaved;
1723 uLong pos_in_central_dirSaved;
1745 szCurrentFileName,
sizeof(szCurrentFileName)-1,
1748 szFileName,iCaseSensitivity)==0)
1766 static int unzlocal_CheckCurrentFileCoherencyHeader (
unz_s* s,
uInt* piSizeVar,
1767 uLong *poffset_local_extrafield,
1768 uInt *psize_local_extrafield)
1771 uLong size_filename;
1772 uLong size_extra_field;
1776 *poffset_local_extrafield = 0;
1777 *psize_local_extrafield = 0;
1785 if (unzlocal_getLong(s->
file,&uMagic) !=
UNZ_OK)
1787 else if (uMagic!=0x04034b50)
1790 if (unzlocal_getShort(s->
file,&uData) !=
UNZ_OK)
1796 if (unzlocal_getShort(s->
file,&uFlags) !=
UNZ_OK)
1799 if (unzlocal_getShort(s->
file,&uData) !=
UNZ_OK)
1808 if (unzlocal_getLong(s->
file,&uData) !=
UNZ_OK)
1811 if (unzlocal_getLong(s->
file,&uData) !=
UNZ_OK)
1817 if (unzlocal_getLong(s->
file,&uData) !=
UNZ_OK)
1823 if (unzlocal_getLong(s->
file,&uData) !=
UNZ_OK)
1830 if (unzlocal_getShort(s->
file,&size_filename) !=
UNZ_OK)
1835 *piSizeVar += (
uInt)size_filename;
1837 if (unzlocal_getShort(s->
file,&size_extra_field) !=
UNZ_OK)
1841 *psize_local_extrafield = (
uInt)size_extra_field;
1843 *piSizeVar += (
uInt)size_extra_field;
1859 uLong offset_local_extrafield;
1860 uInt size_local_extrafield;
1871 if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
1872 &offset_local_extrafield,&size_local_extrafield)!=
UNZ_OK)
1877 if (pfile_in_zip_read_info==
NULL)
1887 TRYFREE(pfile_in_zip_read_info);
1899 pfile_in_zip_read_info->
crc32=0;
1902 pfile_in_zip_read_info->
file=s->
file;
1963 if (pfile_in_zip_read_info==
NULL)
1991 if (fseek(pfile_in_zip_read_info->
file,
1996 pfile_in_zip_read_info->
file)!=1)
2016 for (i=0;i<uDoCopy;i++)
2033 uLong uTotalOutBefore,uTotalOutAfter;
2034 const Byte *bufBefore;
2050 uOutThis = uTotalOutAfter-uTotalOutBefore;
2052 pfile_in_zip_read_info->
crc32 =
2053 crc32(pfile_in_zip_read_info->
crc32,bufBefore,
2059 iRead += (
uInt)(uTotalOutAfter - uTotalOutBefore);
2062 return (iRead==0) ?
UNZ_EOF : iRead;
2086 if (pfile_in_zip_read_info==
NULL)
2105 if (pfile_in_zip_read_info==
NULL)
2140 if (pfile_in_zip_read_info==
NULL)
2147 return (
int)size_to_read;
2149 if (len>size_to_read)
2150 read_now = (
uInt)size_to_read;
2152 read_now = (
uInt)len ;
2157 if (fseek(pfile_in_zip_read_info->
file,
2162 if (
fread(buf,(
uInt)size_to_read,1,pfile_in_zip_read_info->
file)!=1)
2165 return (
int)read_now;
2183 if (pfile_in_zip_read_info==
NULL)
2189 if (pfile_in_zip_read_info->
crc32 != pfile_in_zip_read_info->
crc32_wait)
2200 TRYFREE(pfile_in_zip_read_info);
2221 uReadThis = uSizeBuf;
2237 return (
int)uReadThis;
2247 #ifdef DYNAMIC_CRC_TABLE
2249 static int crc_table_empty = 1;
2250 static uLong crc_table[256];
2251 static void make_crc_table
OF((
void));
2277 static void make_crc_table()
2283 static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
2287 for (n = 0; n <
sizeof(
p)/
sizeof(
Byte); n++)
2288 poly |= 1
L << (31 - p[n]);
2290 for (n = 0; n < 256; n++)
2293 for (k = 0; k < 8; k++)
2294 c = c & 1 ? poly ^ (c >> 1) : c >> 1;
2297 crc_table_empty = 0;
2303 static const uLong crc_table[256] = {
2304 0x00000000
L, 0x77073096
L, 0xee0e612c
L, 0x990951ba
L, 0x076dc419
L,
2305 0x706af48f
L, 0xe963a535
L, 0x9e6495a3
L, 0x0edb8832
L, 0x79dcb8a4
L,
2306 0xe0d5e91e
L, 0x97d2d988
L, 0x09b64c2b
L, 0x7eb17cbd
L, 0xe7b82d07
L,
2307 0x90bf1d91
L, 0x1db71064
L, 0x6ab020f2
L, 0xf3b97148
L, 0x84be41de
L,
2308 0x1adad47d
L, 0x6ddde4eb
L, 0xf4d4b551
L, 0x83d385c7
L, 0x136c9856
L,
2309 0x646ba8c0
L, 0xfd62f97a
L, 0x8a65c9ec
L, 0x14015c4f
L, 0x63066cd9
L,
2310 0xfa0f3d63
L, 0x8d080df5
L, 0x3b6e20c8
L, 0x4c69105e
L, 0xd56041e4
L,
2311 0xa2677172
L, 0x3c03e4d1
L, 0x4b04d447
L, 0xd20d85fd
L, 0xa50ab56b
L,
2312 0x35b5a8fa
L, 0x42b2986c
L, 0xdbbbc9d6
L, 0xacbcf940
L, 0x32d86ce3
L,
2313 0x45df5c75
L, 0xdcd60dcf
L, 0xabd13d59
L, 0x26d930ac
L, 0x51de003a
L,
2314 0xc8d75180
L, 0xbfd06116
L, 0x21b4f4b5
L, 0x56b3c423
L, 0xcfba9599
L,
2315 0xb8bda50f
L, 0x2802b89e
L, 0x5f058808
L, 0xc60cd9b2
L, 0xb10be924
L,
2316 0x2f6f7c87
L, 0x58684c11
L, 0xc1611dab
L, 0xb6662d3d
L, 0x76dc4190
L,
2317 0x01db7106
L, 0x98d220bc
L, 0xefd5102a
L, 0x71b18589
L, 0x06b6b51f
L,
2318 0x9fbfe4a5
L, 0xe8b8d433
L, 0x7807c9a2
L, 0x0f00f934
L, 0x9609a88e
L,
2319 0xe10e9818
L, 0x7f6a0dbb
L, 0x086d3d2d
L, 0x91646c97
L, 0xe6635c01
L,
2320 0x6b6b51f4
L, 0x1c6c6162
L, 0x856530d8
L, 0xf262004e
L, 0x6c0695ed
L,
2321 0x1b01a57b
L, 0x8208f4c1
L, 0xf50fc457
L, 0x65b0d9c6
L, 0x12b7e950
L,
2322 0x8bbeb8ea
L, 0xfcb9887c
L, 0x62dd1ddf
L, 0x15da2d49
L, 0x8cd37cf3
L,
2323 0xfbd44c65
L, 0x4db26158
L, 0x3ab551ce
L, 0xa3bc0074
L, 0xd4bb30e2
L,
2324 0x4adfa541
L, 0x3dd895d7
L, 0xa4d1c46d
L, 0xd3d6f4fb
L, 0x4369e96a
L,
2325 0x346ed9fc
L, 0xad678846
L, 0xda60b8d0
L, 0x44042d73
L, 0x33031de5
L,
2326 0xaa0a4c5f
L, 0xdd0d7cc9
L, 0x5005713c
L, 0x270241aa
L, 0xbe0b1010
L,
2327 0xc90c2086
L, 0x5768b525
L, 0x206f85b3
L, 0xb966d409
L, 0xce61e49f
L,
2328 0x5edef90e
L, 0x29d9c998
L, 0xb0d09822
L, 0xc7d7a8b4
L, 0x59b33d17
L,
2329 0x2eb40d81
L, 0xb7bd5c3b
L, 0xc0ba6cad
L, 0xedb88320
L, 0x9abfb3b6
L,
2330 0x03b6e20c
L, 0x74b1d29a
L, 0xead54739
L, 0x9dd277af
L, 0x04db2615
L,
2331 0x73dc1683
L, 0xe3630b12
L, 0x94643b84
L, 0x0d6d6a3e
L, 0x7a6a5aa8
L,
2332 0xe40ecf0b
L, 0x9309ff9d
L, 0x0a00ae27
L, 0x7d079eb1
L, 0xf00f9344
L,
2333 0x8708a3d2
L, 0x1e01f268
L, 0x6906c2fe
L, 0xf762575d
L, 0x806567cb
L,
2334 0x196c3671
L, 0x6e6b06e7
L, 0xfed41b76
L, 0x89d32be0
L, 0x10da7a5a
L,
2335 0x67dd4acc
L, 0xf9b9df6f
L, 0x8ebeeff9
L, 0x17b7be43
L, 0x60b08ed5
L,
2336 0xd6d6a3e8
L, 0xa1d1937e
L, 0x38d8c2c4
L, 0x4fdff252
L, 0xd1bb67f1
L,
2337 0xa6bc5767
L, 0x3fb506dd
L, 0x48b2364b
L, 0xd80d2bda
L, 0xaf0a1b4c
L,
2338 0x36034af6
L, 0x41047a60
L, 0xdf60efc3
L, 0xa867df55
L, 0x316e8eef
L,
2339 0x4669be79
L, 0xcb61b38c
L, 0xbc66831a
L, 0x256fd2a0
L, 0x5268e236
L,
2340 0xcc0c7795
L, 0xbb0b4703
L, 0x220216b9
L, 0x5505262f
L, 0xc5ba3bbe
L,
2341 0xb2bd0b28
L, 0x2bb45a92
L, 0x5cb36a04
L, 0xc2d7ffa7
L, 0xb5d0cf31
L,
2342 0x2cd99e8b
L, 0x5bdeae1d
L, 0x9b64c2b0
L, 0xec63f226
L, 0x756aa39c
L,
2343 0x026d930a
L, 0x9c0906a9
L, 0xeb0e363f
L, 0x72076785
L, 0x05005713
L,
2344 0x95bf4a82
L, 0xe2b87a14
L, 0x7bb12bae
L, 0x0cb61b38
L, 0x92d28e9b
L,
2345 0xe5d5be0d
L, 0x7cdcefb7
L, 0x0bdbdf21
L, 0x86d3d2d4
L, 0xf1d4e242
L,
2346 0x68ddb3f8
L, 0x1fda836e
L, 0x81be16cd
L, 0xf6b9265b
L, 0x6fb077e1
L,
2347 0x18b74777
L, 0x88085ae6
L, 0xff0f6a70
L, 0x66063bca
L, 0x11010b5c
L,
2348 0x8f659eff
L, 0xf862ae69
L, 0x616bffd3
L, 0x166ccf45
L, 0xa00ae278
L,
2349 0xd70dd2ee
L, 0x4e048354
L, 0x3903b3c2
L, 0xa7672661
L, 0xd06016f7
L,
2350 0x4969474d
L, 0x3e6e77db
L, 0xaed16a4a
L, 0xd9d65adc
L, 0x40df0b66
L,
2351 0x37d83bf0
L, 0xa9bcae53
L, 0xdebb9ec5
L, 0x47b2cf7f
L, 0x30b5ffe9
L,
2352 0xbdbdf21c
L, 0xcabac28a
L, 0x53b39330
L, 0x24b4a3a6
L, 0xbad03605
L,
2353 0xcdd70693
L, 0x54de5729
L, 0x23d967bf
L, 0xb3667a2e
L, 0xc4614ab8
L,
2354 0x5d681b02
L, 0x2a6f2b94
L, 0xb40bbe37
L, 0xc30c8ea1
L, 0x5a05df1b
L,
2364 #ifdef DYNAMIC_CRC_TABLE
2365 if (crc_table_empty) make_crc_table();
2367 return (
const uLong *)crc_table;
2371 #define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
2372 #define DO2(buf) DO1(buf); DO1(buf);
2373 #define DO4(buf) DO2(buf); DO2(buf);
2374 #define DO8(buf) DO4(buf); DO4(buf);
2380 #ifdef DYNAMIC_CRC_TABLE
2381 if (crc_table_empty)
2384 crc = crc ^ 0xffffffff
L;
2393 return crc ^ 0xffffffff
L;
2437 #define exop word.what.Exop
2438 #define bits word.what.Bits
2442 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
2596 #define UPDBITS {s->bitb=b;s->bitk=k;}
2597 #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
2598 #define UPDOUT {s->write=q;}
2599 #define UPDATE {UPDBITS UPDIN UPDOUT}
2600 #define LEAVE {UPDATE return inflate_flush(s,z,r);}
2602 #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
2603 #define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
2604 #define NEXTBYTE (n--,*p++)
2605 #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
2606 #define DUMPBITS(j) {b>>=(j);k-=(j);}
2608 #define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
2609 #define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
2610 #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
2611 #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
2612 #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
2613 #define OUTBYTE(a) {*q++=(Byte)(a);m--;}
2615 #define LOAD {LOADIN LOADOUT}
2619 uInt inflate_mask[17] = {
2621 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
2622 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
2694 Tracev((
"inflate: blocks reset\n"));
2720 Tracev((
"inflate: blocks allocated\n"));
2740 while (1)
switch (s->
mode)
2749 Tracev((
"inflate: stored block%s\n",
2750 s->
last ?
" (last)" :
""));
2757 Tracev((
"inflate: fixed codes block%s\n",
2758 s->
last ?
" (last)" :
""));
2775 Tracev((
"inflate: dynamic codes block%s\n",
2776 s->
last ?
" (last)" :
""));
2783 z->
msg = (
char*)
"invalid block type";
2790 if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
2793 z->
msg = (
char*)
"invalid stored block lengths";
2809 #ifdef MACOS_X // Optimization
2815 for (t1=0; t1<
t; t1++) {
2826 Tracev((
"inflate: stored end, %lu total out\n",
2834 #ifndef PKZIP_BUG_WORKAROUND
2835 if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
2838 z->
msg = (
char*)
"too many length or distance symbols";
2843 t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
2851 Tracev((
"inflate: table sizes ok\n"));
2874 Tracev((
"inflate: bits tree ok\n"));
2878 s->
sub.
trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
2895 i = c == 18 ? 7 : c - 14;
2896 j = c == 18 ? 11 : 3;
2899 j += (
uInt)b & inflate_mask[i];
2903 if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
2908 z->
msg = (
char*)
"invalid bit length repeat";
2912 c = c == 16 ? s->
sub.
trees.blens[i - 1] : 0;
2929 s->
sub.
trees.blens, &bl, &bd, &tl, &td,
2939 Tracev((
"inflate: trees ok\n"));
2955 Tracev((
"inflate: codes end, %lu total out\n",
2988 Tracev((
"inflate: blocks freed\n"));
3034 #ifdef MACOS_X // Optimization
3040 for (t1=0; t1<
n; t1++) {
3072 #ifdef MACOS_X // Optimization
3078 for (t1=0; t1<
n; t1++) {
3103 " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
3112 #define exop word.what.Exop
3113 #define bits word.what.Bits
3116 static int huft_build
OF((
3129 static const uInt cplens[31] = {
3130 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
3131 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
3133 static const uInt cplext[31] = {
3134 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3135 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112};
3136 static const uInt cpdist[30] = {
3137 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
3138 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
3139 8193, 12289, 16385, 24577};
3140 static const uInt cpdext[30] = {
3141 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
3142 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
3222 #define C0 *p++ = 0;
3223 #define C2 C0 C0 C0 C0
3224 #define C4 C2 C2 C2 C2
3240 for (j = 1; j <=
BMAX; j++)
3246 for (i =
BMAX;
i; i--)
3256 for (y = 1 << j; j <
i; j++, y <<= 1)
3257 if ((y -= c[j]) < 0)
3259 if ((y -= c[i]) < 0)
3266 p = c + 1; xp = x + 2;
3268 *xp++ = (j += *p++);
3275 if ((j = *p++) != 0)
3305 z = z > (
uInt)l ? l : z;
3306 if ((f = 1 << (j = k - w)) > a + 1)
3313 if ((f <<= 1) <= *++xp)
3323 u[h] = q = hp + *hn;
3341 r.bits = (
Byte)(k - w);
3346 r.exop = (
Byte)(*p < 256 ? 0 : 32 + 64);
3351 r.exop = (
Byte)(e[*p - s] + 16 + 64);
3352 r.
base = d[*p++ -
s];
3357 for (j = i >> w; j <
z; j +=
f)
3361 for (j = 1 << (k - 1); i &
j; j >>= 1)
3366 mask = (1 <<
w) - 1;
3367 while ((i & mask) != x[h])
3371 mask = (1 <<
w) - 1;
3396 tb, bb, hp, &hn, v);
3398 z->
msg = (
char*)
"oversubscribed dynamic bit lengths tree";
3401 z->
msg = (
char*)
"incomplete dynamic bit lengths tree";
3429 r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
3430 if (r !=
Z_OK || *bl == 0)
3433 z->
msg = (
char*)
"oversubscribed literal/length tree";
3436 z->
msg = (
char*)
"incomplete literal/length tree";
3444 r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
3445 if (r !=
Z_OK || (*bd == 0 && nl > 257))
3448 z->
msg = (
char*)
"oversubscribed distance tree";
3450 #ifdef PKZIP_BUG_WORKAROUND
3454 z->
msg = (
char*)
"incomplete distance tree";
3459 z->
msg = (
char*)
"empty distance tree with lengths";
3481 static uInt fixed_bl = 9;
3482 static uInt fixed_bd = 5;
3484 {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
3485 {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
3486 {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
3487 {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
3488 {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
3489 {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
3490 {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
3491 {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
3492 {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
3493 {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
3494 {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
3495 {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
3496 {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
3497 {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
3498 {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
3499 {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
3500 {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
3501 {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
3502 {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
3503 {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
3504 {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
3505 {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
3506 {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
3507 {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
3508 {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
3509 {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
3510 {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
3511 {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
3512 {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
3513 {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
3514 {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
3515 {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
3516 {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
3517 {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
3518 {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
3519 {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
3520 {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
3521 {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
3522 {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
3523 {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
3524 {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
3525 {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
3526 {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
3527 {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
3528 {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
3529 {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
3530 {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
3531 {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
3532 {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
3533 {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
3534 {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
3535 {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
3536 {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
3537 {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
3538 {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
3539 {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
3540 {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
3541 {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
3542 {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
3543 {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
3544 {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
3545 {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
3546 {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
3547 {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
3548 {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
3549 {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
3550 {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
3551 {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
3552 {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
3553 {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
3554 {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
3555 {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
3556 {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
3557 {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
3558 {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
3559 {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
3560 {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
3561 {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
3562 {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
3563 {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
3564 {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
3565 {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
3566 {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
3567 {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
3568 {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
3569 {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
3570 {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
3571 {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
3572 {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
3573 {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
3574 {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
3575 {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
3576 {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
3577 {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
3578 {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
3579 {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
3580 {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
3581 {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
3582 {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
3583 {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
3584 {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
3585 {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
3586 {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
3587 {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
3588 {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
3589 {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
3590 {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
3591 {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
3592 {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
3593 {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
3594 {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
3595 {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
3596 {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
3597 {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
3598 {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
3599 {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
3600 {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
3601 {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
3602 {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
3603 {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
3604 {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
3605 {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
3606 {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
3607 {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
3608 {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
3609 {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
3610 {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
3611 {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
3614 {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
3615 {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
3616 {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
3617 {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
3618 {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
3619 {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
3620 {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
3621 {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
3639 #define exop word.what.Exop
3640 #define bits word.what.Bits
3643 #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
3644 #define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
3671 ml = inflate_mask[bl];
3672 md = inflate_mask[bd];
3678 if ((e = (t = tl + ((
uInt)b & ml))->
exop) == 0)
3682 "inflate: * literal '%c'\n" :
3683 "inflate: * literal 0x%02x\n", t->
base));
3694 c = t->
base + ((
uInt)b & inflate_mask[e]);
3696 Tracevv((
"inflate: * length %u\n", c));
3700 e = (t = td + ((
uInt)b & md))->
exop;
3708 d = t->
base + ((
uInt)b & inflate_mask[e]);
3710 Tracevv((
"inflate: * distance %u\n", d));
3738 else if ((e & 64) == 0)
3741 e = (t += ((
uInt)b & inflate_mask[e]))->
exop;
3745 z->
msg = (
char*)
"invalid distance code";
3756 if ((e = (t += ((
uInt)b & inflate_mask[e]))->exop) == 0)
3760 "inflate: * literal '%c'\n" :
3761 "inflate: * literal 0x%02x\n", t->
base));
3769 Tracevv((
"inflate: * end of block\n"));
3776 z->
msg = (
char*)
"invalid literal/length code";
3782 }
while (m >= 258 && n >= 10);
3796 #define exop word.what.Exop
3797 #define bits word.what.Bits
3853 Tracev((
"inflate: codes new\n"));
3877 while (1)
switch (c->
mode)
3881 if (m >= 258 && n >= 10)
3899 t = c->
sub.
code.tree + ((
uInt)b & inflate_mask[j]);
3901 e = (
uInt)(t->exop);
3906 "inflate: literal '%c'\n" :
3907 "inflate: literal 0x%02x\n", t->
base));
3926 Tracevv((
"inflate: end of block\n"));
3931 z->
msg = (
char*)
"invalid literal/length code";
3937 c->
len += (
uInt)b & inflate_mask[j];
3946 t = c->
sub.
code.tree + ((
uInt)b & inflate_mask[j]);
3948 e = (
uInt)(t->exop);
3963 z->
msg = (
char*)
"invalid distance code";
4001 Assert(k < 16,
"inflate_codes grabbed too many bytes")
4020 #ifdef NEED_DUMMY_RETURN
4029 Tracev((
"inflate: codes free\n"));
4046 #define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
4047 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
4048 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
4049 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
4050 #define DO16(buf) DO8(buf,0); DO8(buf,8);
4055 unsigned long s1 = adler & 0xffff;
4056 unsigned long s2 = (adler >> 16) & 0xffff;
4076 return (s2 << 16) | s1;
4168 Tracev((
"inflate: reset\n"));
4181 Tracev((
"inflate: end\n"));
4232 Tracev((
"inflate: allocated\n"));
4246 #define iNEEDBYTE {if(z->avail_in==0)return r;r=f;}
4247 #define iNEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
4265 z->
msg = (
char*)
"unknown compression method";
4272 z->
msg = (
char*)
"invalid window size";
4283 z->
msg = (
char*)
"incorrect header check";
4287 Tracev((
"inflate: zlib header ok\n"));
4314 z->
msg = (
char*)
"need dictionary";
4356 z->
msg = (
char*)
"incorrect data check";
4360 Tracev((
"inflate: zlib check ok\n"));
4369 #ifdef NEED_DUMMY_RETURN
4388 dictionary += dictLength -
length;
4419 static const Byte mark[4] = {0, 0, 0xff, 0xff};
4462 if (opaque) items += size -
size;
GLdouble GLdouble GLdouble GLdouble q
unsigned long offset_local_extrafield
unsigned long size_file_extra
union inflate_blocks_state::@53 sub
unsigned long size_comment
struct internal_state::@59::@60 check
struct inflate_codes_state::@56::@58 copy
int unzClose(unzFile file)
unsigned long compression_method
const char inflate_copyright[]
int inflate_trees_bits(uInt *c, uInt *bb, inflate_huft **tb, inflate_huft *hp, z_streamp z)
GLenum GLsizei GLenum format
const uLong * get_crc_table()
unsigned long offset_curfile
void(* free_func)(void *opaque, void *address)
void inflate_blocks_reset(inflate_blocks_statef *s, z_streamp z, uLong *c)
unzFile unzOpen(const char *path)
inflate_codes_statef * inflate_codes_new(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, z_streamp z)
struct inflate_blocks_state::@53::@55 decode
int unzGetLocalExtrafield(unzFile file, void *buf, unsigned len)
voidp zcalloc(voidp opaque, unsigned items, unsigned size)
unsigned long offset_central_dir
int inflate_blocks_sync_point(inflate_blocks_statef *s)
int inflate_trees_dynamic(uInt nl, uInt nd, uInt *c, uInt *bl, uInt *bd, inflate_huft **tl, inflate_huft **td, inflate_huft *hp, z_streamp z)
unsigned long rest_read_uncompressed
int unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info)
#define UNZ_END_OF_LIST_OF_FILE
unsigned long byte_before_the_zipfile
int unzSetCurrentFileInfoPosition(unzFile file, unsigned long pos)
unsigned long pos_local_extrafield
long unztell(unzFile file)
#define ZFREE(strm, addr)
int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)
unsigned long stream_initialised
int unzStringFileNameCompare(const char *fileName1, const char *fileName2, int iCaseSensitivity)
int unzGoToNextFile(unzFile file)
int inflate(z_streamp z, int f)
GLsizei GLsizei GLcharARB * source
void zcfree(voidp opaque, voidp ptr)
int inflate_blocks_free(inflate_blocks_statef *s, z_streamp z)
int unzOpenCurrentFile(unzFile file)
file_in_zip_read_info_s * pfile_in_zip_read
int inflateInit_(z_streamp z, const char *version, int stream_size)
#define UNZ_MAXFILENAMEINZIP
GLubyte GLubyte GLubyte GLubyte w
union inflate_codes_state::@56 sub
int inflateInit2_(z_streamp z, int w, const char *version, int stream_size)
unsigned long version_needed
unsigned long uncompressed_size
unsigned long rest_read_compressed
int unzCloseCurrentFile(unzFile file)
unsigned long compression_method
void inflate_codes_free(inflate_codes_statef *c, z_streamp z)
unsigned long pos_in_central_dir
int inflate_flush(inflate_blocks_statef *s, z_streamp z, int r)
inflate_blocks_statef * blocks
unsigned long central_pos
int unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity)
unz_file_info cur_file_info
unsigned int size_local_extrafield
unsigned long disk_num_start
int inflateSyncPoint(z_streamp z)
GLubyte GLubyte GLubyte a
int inflateSetDictionary(z_streamp z, const Byte *dictionary, uInt dictLength)
#define SIZEZIPLOCALHEADER
unsigned long internal_fa
uLong crc32(uLong crc, const Byte *buf, uInt len)
#define CASESENSITIVITYDEFAULTVALUE
struct inflate_huft_s::@51::@52 what
unsigned long pos_in_zipfile
GLint GLint GLsizei GLsizei GLsizei GLint border
short LittleShort(short l)
GLdouble GLdouble GLdouble r
int unzGetCurrentFileInfoPosition(unzFile file, unsigned long *pos)
int unzGoToFirstFile(unzFile file)
unzFile unzReOpen(const char *path, unzFile file)
static WindowRef ValidModeCallbackProc inCallback OSStatus err
unsigned long current_file_ok
void inflate_set_dictionary(inflate_blocks_statef *s, const Byte *d, uInt n)
int unzReadCurrentFile(unzFile file, void *buf, unsigned len)
int inflate_codes(inflate_blocks_statef *s, z_streamp z, int r)
unsigned long number_entry
int inflateReset(z_streamp z)
inflate_blocks_statef * inflate_blocks_new(z_streamp z, check_func c, uInt w)
int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
union inflate_huft_s::@51 word
unsigned long byte_before_the_zipfile
int inflate_trees_fixed(uInt *bl, uInt *bd, inflate_huft **tl, inflate_huft **td, z_streamp z)
const char * z_errmsg[10]
struct inflate_codes_state::@56::@57 code
int inflateEnd(z_streamp z)
#define ZALLOC(strm, items, size)
int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_blocks_statef *s, z_streamp z)
GLsizei const GLcharARB const GLint * length
void * Mem_ClearedAlloc(const int size)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
unsigned long compressed_size
int unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf)
#define UNZ_INTERNALERROR
#define STRCMPCASENOSENTIVEFUNCTION
inflate_codes_statef * codes
unsigned long external_fa
void *(* alloc_func)(void *opaque, unsigned int items, unsigned int size)
struct internal_state * state
unz_file_info_internal cur_file_info_internal
union internal_state::@59 sub
unsigned long size_file_comment
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
#define inflateInit2(strm, windowBits)
uLong adler32(uLong adler, const Byte *buf, uInt len)
unsigned long size_central_dir
struct inflate_blocks_state::@53::@54 trees
#define SIZECENTRALDIRITEM
int inflateSync(z_streamp z)
unsigned long size_filename
#define Assert(cond, msg)