96 #ifndef CASESENSITIVITYDEFAULT_NO 97 # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) 98 # define CASESENSITIVITYDEFAULT_NO 104 #define UNZ_BUFSIZE (16384) 107 #ifndef UNZ_MAXFILENAMEINZIP 108 #define UNZ_MAXFILENAMEINZIP (256) 112 # define ALLOC(size) (malloc(size)) 115 # define TRYFREE(p) {if (p) free(p);} 118 #define SIZECENTRALDIRITEM (0x2e) 119 #define SIZEZIPLOCALHEADER (0x1e) 123 " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
126 typedef struct unz_file_info64_internal_s
190 unsigned long keys[3];
215 int err = (int)
ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
223 if (
ZERROR64(*pzlib_filefunc_def,filestream))
353 char c1=*(fileName1++);
354 char c2=*(fileName2++);
355 if ((c1>=
'a') && (c1<=
'z'))
357 if ((c2>=
'a') && (c2<=
'z'))
360 return ((c2==
'\0') ? 0 : -1);
371 #ifdef CASESENSITIVITYDEFAULT_NO 372 #define CASESENSITIVITYDEFAULTVALUE 2 374 #define CASESENSITIVITYDEFAULTVALUE 1 377 #ifndef STRCMPCASENOSENTIVEFUNCTION 378 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal 391 const char* fileName2,
392 int iCaseSensitivity)
395 if (iCaseSensitivity==0)
398 if (iCaseSensitivity==1)
399 return strcmp(fileName1,fileName2);
404 #ifndef BUFREADCOMMENT 405 #define BUFREADCOMMENT (0x400) 425 uSizeFile =
ZTELL64(*pzlib_filefunc_def,filestream);
427 if (uMaxBack>uSizeFile)
428 uMaxBack = uSizeFile;
435 while (uBackRead<uMaxBack)
441 uBackRead = uMaxBack;
444 uReadPos = uSizeFile-uBackRead ;
451 if (
ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
454 for (i=(
int)uReadSize-3; (i--)>0;)
455 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
456 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
458 uPosFound = uReadPos+i;
493 uSizeFile =
ZTELL64(*pzlib_filefunc_def,filestream);
495 if (uMaxBack>uSizeFile)
496 uMaxBack = uSizeFile;
503 while (uBackRead<uMaxBack)
509 uBackRead = uMaxBack;
512 uReadPos = uSizeFile-uBackRead ;
519 if (
ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
522 for (i=(
int)uReadSize-3; (i--)>0;)
523 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
524 ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
526 uPosFound = uReadPos+i;
569 if (uL != 0x06064b50)
572 return relativeOffset;
586 int is64bitOpenFunction)
595 uLong number_disk_with_CD;
608 if (pzlib_filefunc64_32_def==NULL)
668 (number_disk_with_CD!=0) ||
715 number_entry_CD = uL;
718 (number_disk_with_CD!=0) ||
768 if (pzlib_filefunc32_def != NULL)
781 if (pzlib_filefunc_def != NULL)
784 zlib_filefunc64_32_def_fill.
zfile_func64 = *pzlib_filefunc_def;
857 ptm->
tm_mon = (
uInt)((((uDate)&0x1E0)/0x20)-1) ;
858 ptm->
tm_year = (
uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
861 ptm->
tm_min = (
uInt) ((ulDosDate&0x7E0)/0x20) ;
871 *pfile_info_internal,
873 uLong fileNameBufferSize,
875 uLong extraFieldBufferSize,
877 uLong commentBufferSize));
882 *pfile_info_internal,
884 uLong fileNameBufferSize,
886 uLong extraFieldBufferSize,
888 uLong commentBufferSize)
912 else if (uMagic!=0x02014b50)
968 if ((err==
UNZ_OK) && (szFileName!=NULL))
977 uSizeRead = fileNameBufferSize;
986 if ((err==
UNZ_OK) && (extraField!=NULL))
992 uSizeRead = extraFieldBufferSize;
1039 if (headerId == 0x0001)
1076 acc += 2 + 2 + dataSize;
1080 if ((err==
UNZ_OK) && (szComment!=NULL))
1089 uSizeRead = commentBufferSize;
1108 if ((err==
UNZ_OK) && (pfile_info!=NULL))
1109 *pfile_info=file_info;
1111 if ((err==
UNZ_OK) && (pfile_info_internal!=NULL))
1112 *pfile_info_internal=file_info_internal;
1126 char * szFileName,
uLong fileNameBufferSize,
1127 void *extraField,
uLong extraFieldBufferSize,
1128 char* szComment,
uLong commentBufferSize)
1131 szFileName,fileNameBufferSize,
1132 extraField,extraFieldBufferSize,
1133 szComment,commentBufferSize);
1138 char * szFileName,
uLong fileNameBufferSize,
1139 void *extraField,
uLong extraFieldBufferSize,
1140 char* szComment,
uLong commentBufferSize)
1145 szFileName,fileNameBufferSize,
1146 extraField,extraFieldBufferSize,
1147 szComment,commentBufferSize);
1148 if ((err==
UNZ_OK) && (pfile_info != NULL))
1152 pfile_info->
flag = file_info64.
flag;
1155 pfile_info->
crc = file_info64.
crc;
1189 NULL,0,NULL,0,NULL,0);
1218 NULL,0,NULL,0,NULL,0);
1268 szCurrentFileName,
sizeof(szCurrentFileName)-1,
1273 szFileName,iCaseSensitivity)==0)
1312 if (file==NULL || file_pos==NULL)
1343 if (file==NULL || file_pos==NULL)
1354 NULL,0,NULL,0,NULL,0);
1365 if (file_pos == NULL)
1386 ZPOS64_T * poffset_local_extrafield,
1387 uInt * psize_local_extrafield)
1389 uLong uMagic,uData,uFlags;
1390 uLong size_filename;
1391 uLong size_extra_field;
1395 *poffset_local_extrafield = 0;
1396 *psize_local_extrafield = 0;
1407 else if (uMagic!=0x04034b50)
1455 *piSizeVar += (
uInt)size_filename;
1461 *psize_local_extrafield = (
uInt)size_extra_field;
1463 *piSizeVar += (
uInt)size_extra_field;
1473 int* level,
int raw,
const char* password)
1480 uInt size_local_extrafield;
1484 if (password != NULL)
1501 if (pfile_in_zip_read_info==NULL)
1508 pfile_in_zip_read_info->
raw=raw;
1512 TRYFREE(pfile_in_zip_read_info);
1526 case 6 : *level = 1;
break;
1527 case 4 : *level = 2;
break;
1528 case 2 : *level = 9;
break;
1541 pfile_in_zip_read_info->
crc32=0;
1553 pfile_in_zip_read_info->bstream.bzalloc = (
void *(*) (
void *, int, int))0;
1554 pfile_in_zip_read_info->bstream.bzfree = (
free_func)0;
1555 pfile_in_zip_read_info->bstream.opaque = (
voidpf)0;
1556 pfile_in_zip_read_info->bstream.state = (
voidpf)0;
1564 err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
1569 TRYFREE(pfile_in_zip_read_info);
1573 pfile_in_zip_read_info->
raw=1;
1589 TRYFREE(pfile_in_zip_read_info);
1616 if (password != NULL)
1620 init_keys(password,s->keys,s->pcrc_32_tab);
1629 for (i = 0; i<12; i++)
1630 zdecode(s->keys,s->pcrc_32_tab,source[i]);
1666 if (pfile_in_zip_read_info==NULL)
1695 if (pfile_in_zip_read_info==NULL)
1709 (!(pfile_in_zip_read_info->
raw)))
1715 (pfile_in_zip_read_info->
raw))
1739 uReadThis)!=uReadThis)
1747 for(i=0;i<uReadThis;i++)
1749 zdecode(s->keys,s->pcrc_32_tab,
1770 return (iRead==0) ?
UNZ_EOF : iRead;
1778 for (i=0;i<uDoCopy;i++)
1798 uLong uTotalOutBefore,uTotalOutAfter;
1799 const Bytef *bufBefore;
1802 pfile_in_zip_read_info->bstream.next_in = (
char*)pfile_in_zip_read_info->
stream.
next_in;
1803 pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->
stream.
avail_in;
1804 pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->
stream.
total_in;
1805 pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
1806 pfile_in_zip_read_info->bstream.next_out = (
char*)pfile_in_zip_read_info->
stream.
next_out;
1807 pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->
stream.
avail_out;
1808 pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->
stream.
total_out;
1809 pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
1811 uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
1812 bufBefore = (
const Bytef *)pfile_in_zip_read_info->bstream.next_out;
1814 err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
1816 uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
1817 uOutThis = uTotalOutAfter-uTotalOutBefore;
1821 pfile_in_zip_read_info->
crc32 =
crc32(pfile_in_zip_read_info->
crc32,bufBefore, (
uInt)(uOutThis));
1823 iRead += (
uInt)(uTotalOutAfter - uTotalOutBefore);
1825 pfile_in_zip_read_info->
stream.
next_in = (
Bytef*)pfile_in_zip_read_info->bstream.next_in;
1826 pfile_in_zip_read_info->
stream.
avail_in = pfile_in_zip_read_info->bstream.avail_in;
1827 pfile_in_zip_read_info->
stream.
total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
1828 pfile_in_zip_read_info->
stream.
next_out = (
Bytef*)pfile_in_zip_read_info->bstream.next_out;
1829 pfile_in_zip_read_info->
stream.
avail_out = pfile_in_zip_read_info->bstream.avail_out;
1830 pfile_in_zip_read_info->
stream.
total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
1832 if (err==BZ_STREAM_END)
1833 return (iRead==0) ?
UNZ_EOF : iRead;
1840 ZPOS64_T uTotalOutBefore,uTotalOutAfter;
1841 const Bytef *bufBefore;
1856 if ((err>=0) && (pfile_in_zip_read_info->
stream.
msg!=NULL))
1860 uOutThis = uTotalOutAfter-uTotalOutBefore;
1864 pfile_in_zip_read_info->
crc32 =
1865 crc32(pfile_in_zip_read_info->
crc32,bufBefore,
1871 iRead += (
uInt)(uTotalOutAfter - uTotalOutBefore);
1874 return (iRead==0) ?
UNZ_EOF : iRead;
1898 if (pfile_in_zip_read_info==NULL)
1914 if (pfile_in_zip_read_info==NULL)
1933 if (pfile_in_zip_read_info==NULL)
1968 if (pfile_in_zip_read_info==NULL)
1975 return (
int)size_to_read;
1977 if (len>size_to_read)
1978 read_now = (
uInt)size_to_read;
1980 read_now = (
uInt)len ;
1994 buf,read_now)!=read_now)
1997 return (
int)read_now;
2015 if (pfile_in_zip_read_info==NULL)
2020 (!pfile_in_zip_read_info->
raw))
2022 if (pfile_in_zip_read_info->
crc32 != pfile_in_zip_read_info->
crc32_wait)
2033 BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
2038 TRYFREE(pfile_in_zip_read_info);
2059 uReadThis = uSizeBuf;
2075 return (
int)uReadThis;
2101 return (
uLong)offset64;
2117 NULL,0,NULL,0,NULL,0);
static int unz64local_GetCurrentFileInfoInternal(unzFile file, unz_file_info64 *pfile_info, unz_file_info64_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
ZPOS64_T rest_read_uncompressed
unz_file_info64_internal cur_file_info_internal
ZPOS64_T pos_in_zip_directory
#define ZSEEK64(filefunc, filestream, pos, mode)
int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity)
int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len)
uInt size_local_extrafield
int ZEXPORT unzGoToFirstFile(unzFile file)
#define ZCLOSE64(filefunc, filestream)
ZPOS64_T rest_read_compressed
int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos)
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
int ZEXPORT unzGoToNextFile(unzFile file)
#define ZREAD64(filefunc, filestream, buf, size)
#define UNZ_INTERNALERROR
ZPOS64_T uncompressed_size
unzFile ZEXPORT unzOpen64(const void *path)
#define ZLIB_FILEFUNC_MODE_READ
#define STRCMPCASENOSENTIVEFUNCTION
ZPOS64_T offset_central_dir
int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password)
int ZEXPORT unzClose(unzFile file)
z_crc_t * get_crc_table()
unsigned long crc32(unsigned long crc, unsigned char *buf, uInt len)
int ZEXPORT unzeof(unzFile file)
int ZEXPORT unzOpenCurrentFile(unzFile file)
seek_file_func zseek32_file
int ZEXPORT unzSetOffset(unzFile file, uLong pos)
int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info)
static unzFile unzOpenInternal(const void *path, zlib_filefunc64_32_def *pzlib_filefunc64_32_def, int is64bitOpenFunction)
static ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc32_def)
static int unz64local_getLong64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
#define ZLIB_FILEFUNC_SEEK_CUR
#define inflateInit2(strm, windowBits)
int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
unzFile ZEXPORT unzOpen(const char *path)
static void init_keys(const char *passwd, unsigned long *pkeys, const z_crc_t *pcrc_32_tab)
ZPOS64_T pos_local_extrafield
int ZEXPORT unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw)
int ZEXPORT unzCloseCurrentFile(unzFile file)
const char unz_copyright[]
unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def)
zlib_filefunc64_32_def z_filefunc
unsigned long long int ZPOS64_T
static int unz64local_getLong(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
static int unz64local_getByte(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char *password)
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
#define ZLIB_FILEFUNC_MODE_EXISTING
ZPOS64_T byte_before_the_zipfile
static ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
int ZEXPORT unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf)
static int unz64local_getShort(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos)
ZPOS64_T size_central_dir
tell_file_func ztell32_file
ZPOS64_T offset_local_extrafield
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
#define ZTELL64(filefunc, filestream)
static int unz64local_getByte OF(( const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi))
static int strcmpcasenosensitive_internal(const char *fileName1, const char *fileName2)
ZPOS64_T ZEXPORT unztell64(unzFile file)
z_off_t ZEXPORT unztell(unzFile file)
file_in_zip64_read_info_s * pfile_in_zip_read
zlib_filefunc64_32_def z_filefunc
int ZEXPORT unzStringFileNameCompare(const char *fileName1, const char *fileName2, int iCaseSensitivity)
#define zdecode(pkeys, pcrc_32_tab, c)
#define CASESENSITIVITYDEFAULTVALUE
ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
#define UNZ_MAXFILENAMEINZIP
int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info32)
uLong ZEXPORT unzGetOffset(unzFile file)
int inflateEnd(z_streamp strm)
zlib_filefunc64_def zfile_func64
unz_file_info64 cur_file_info
int inflate(z_streamp strm, int flush)
#define ZERROR64(filefunc, filestream)
ZPOS64_T byte_before_the_zipfile
#define SIZECENTRALDIRITEM
#define ZOPEN64(filefunc, filename, mode)
#define ZLIB_FILEFUNC_SEEK_END
int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos *file_pos)
static int unz64local_CheckCurrentFileCoherencyHeader(unz64_s *s, uInt *piSizeVar, ZPOS64_T *poffset_local_extrafield, uInt *psize_local_extrafield)
int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
ZPOS64_T pos_in_central_dir
#define ZLIB_FILEFUNC_SEEK_SET
#define UNZ_END_OF_LIST_OF_FILE
uLong pos_in_zip_directory
#define SIZEZIPLOCALHEADER
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file)
static void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz *ptm)