75 #if (ZLIB_VERNUM < 0x1270)
98 #ifndef CASESENSITIVITYDEFAULT_NO
99 # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
100 # define CASESENSITIVITYDEFAULT_NO
106 #define UNZ_BUFSIZE (16384)
109 #ifndef UNZ_MAXFILENAMEINZIP
110 #define UNZ_MAXFILENAMEINZIP (256)
114 # define ALLOC(size) (malloc(size))
117 # define TRYFREE(p) {if (p) free(p);}
120 #define SIZECENTRALDIRITEM (0x2e)
121 #define SIZEZIPLOCALHEADER (0x1e)
125 " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
193 unsigned long keys[3];
218 int err = (int)
ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
226 if (
ZERROR64(*pzlib_filefunc_def,filestream))
356 char c1=*(fileName1++);
357 char c2=*(fileName2++);
358 if ((c1>=
'a') && (c1<=
'z'))
360 if ((c2>=
'a') && (c2<=
'z'))
363 return ((c2==
'\0') ? 0 : -1);
374 #ifdef CASESENSITIVITYDEFAULT_NO
375 #define CASESENSITIVITYDEFAULTVALUE 2
377 #define CASESENSITIVITYDEFAULTVALUE 1
380 #ifndef STRCMPCASENOSENTIVEFUNCTION
381 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
394 const char* fileName2,
395 int iCaseSensitivity)
398 if (iCaseSensitivity==0)
401 if (iCaseSensitivity==1)
402 return strcmp(fileName1,fileName2);
407 #ifndef BUFREADCOMMENT
408 #define BUFREADCOMMENT (0x400)
428 uSizeFile =
ZTELL64(*pzlib_filefunc_def,filestream);
430 if (uMaxBack>uSizeFile)
431 uMaxBack = uSizeFile;
438 while (uBackRead<uMaxBack)
444 uBackRead = uMaxBack;
447 uReadPos = uSizeFile-uBackRead ;
454 if (
ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
457 for (i=(
int)uReadSize-3; (i--)>0;)
458 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
459 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
461 uPosFound = uReadPos+i;
496 uSizeFile =
ZTELL64(*pzlib_filefunc_def,filestream);
498 if (uMaxBack>uSizeFile)
499 uMaxBack = uSizeFile;
506 while (uBackRead<uMaxBack)
512 uBackRead = uMaxBack;
515 uReadPos = uSizeFile-uBackRead ;
522 if (
ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
525 for (i=(
int)uReadSize-3; (i--)>0;)
526 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
527 ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
529 uPosFound = uReadPos+i;
572 if (uL != 0x06064b50)
575 return relativeOffset;
589 int is64bitOpenFunction,
unsigned flags)
598 uLong number_disk_with_CD;
612 if (pzlib_filefunc64_32_def==NULL)
672 (number_disk_with_CD!=0) ||
719 number_entry_CD = uL;
722 (number_disk_with_CD!=0) ||
775 if (pzlib_filefunc32_def != NULL)
788 if (pzlib_filefunc_def != NULL)
791 zlib_filefunc64_32_def_fill.
zfile_func64 = *pzlib_filefunc_def;
866 ptm->
tm_mday = (uInt)(uDate&0x1f) ;
867 ptm->
tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
868 ptm->
tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
870 ptm->
tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
871 ptm->
tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
872 ptm->
tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
881 *pfile_info_internal,
883 uLong fileNameBufferSize,
885 uLong extraFieldBufferSize,
887 uLong commentBufferSize));
892 *pfile_info_internal,
894 uLong fileNameBufferSize,
896 uLong extraFieldBufferSize,
898 uLong commentBufferSize)
922 else if (uMagic!=0x02014b50)
978 if ((err==
UNZ_OK) && (szFileName!=NULL))
987 uSizeRead = fileNameBufferSize;
996 if ((err==
UNZ_OK) && (extraField!=NULL))
1002 uSizeRead = extraFieldBufferSize;
1049 if (headerId == 0x0001)
1086 acc += 2 + 2 + dataSize;
1090 if ((err==
UNZ_OK) && (szComment!=NULL))
1099 uSizeRead = commentBufferSize;
1118 if ((err==
UNZ_OK) && (pfile_info!=NULL))
1119 *pfile_info=file_info;
1121 if ((err==
UNZ_OK) && (pfile_info_internal!=NULL))
1122 *pfile_info_internal=file_info_internal;
1136 char * szFileName, uLong fileNameBufferSize,
1137 void *extraField, uLong extraFieldBufferSize,
1138 char* szComment, uLong commentBufferSize)
1141 szFileName,fileNameBufferSize,
1142 extraField,extraFieldBufferSize,
1143 szComment,commentBufferSize);
1148 char * szFileName, uLong fileNameBufferSize,
1149 void *extraField, uLong extraFieldBufferSize,
1150 char* szComment, uLong commentBufferSize)
1155 szFileName,fileNameBufferSize,
1156 extraField,extraFieldBufferSize,
1157 szComment,commentBufferSize);
1158 if (err==
UNZ_OK && pfile_info != NULL)
1162 pfile_info->
flag = file_info64.
flag;
1165 pfile_info->
crc = file_info64.
crc;
1199 NULL,0,NULL,0,NULL,0);
1228 NULL,0,NULL,0,NULL,0);
1278 szCurrentFileName,
sizeof(szCurrentFileName)-1,
1283 szFileName,iCaseSensitivity)==0)
1322 if (file==NULL || file_pos==NULL)
1353 if (file==NULL || file_pos==NULL)
1364 NULL,0,NULL,0,NULL,0);
1375 if (file_pos == NULL)
1394 ZPOS64_T * poffset_local_extrafield,
1395 uInt * psize_local_extrafield)
1397 uLong uMagic,uData,uFlags;
1398 uLong size_filename;
1399 uLong size_extra_field;
1403 *poffset_local_extrafield = 0;
1404 *psize_local_extrafield = 0;
1415 else if (uMagic!=0x04034b50)
1463 *piSizeVar += (uInt)size_filename;
1469 *psize_local_extrafield = (uInt)size_extra_field;
1471 *piSizeVar += (uInt)size_extra_field;
1481 int* level,
int raw,
const char* password)
1488 uInt size_local_extrafield;
1492 if (password != NULL)
1509 if (pfile_in_zip_read_info==NULL)
1516 pfile_in_zip_read_info->
raw=raw;
1520 TRYFREE(pfile_in_zip_read_info);
1534 case 6 : *level = 1;
break;
1535 case 4 : *level = 2;
break;
1536 case 2 : *level = 9;
break;
1549 pfile_in_zip_read_info->
crc32=0;
1556 pfile_in_zip_read_info->
stream.total_out = 0;
1561 pfile_in_zip_read_info->bstream.bzalloc = (
void *(*) (
void *, int, int))0;
1562 pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
1563 pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
1564 pfile_in_zip_read_info->bstream.state = (voidpf)0;
1566 pfile_in_zip_read_info->
stream.zalloc = (alloc_func)0;
1567 pfile_in_zip_read_info->
stream.zfree = (free_func)0;
1568 pfile_in_zip_read_info->
stream.opaque = (voidpf)0;
1569 pfile_in_zip_read_info->
stream.next_in = (voidpf)0;
1570 pfile_in_zip_read_info->
stream.avail_in = 0;
1572 err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
1577 TRYFREE(pfile_in_zip_read_info);
1581 pfile_in_zip_read_info->
raw=1;
1586 pfile_in_zip_read_info->
stream.zalloc = (alloc_func)0;
1587 pfile_in_zip_read_info->
stream.zfree = (free_func)0;
1588 pfile_in_zip_read_info->
stream.opaque = (voidpf)0;
1589 pfile_in_zip_read_info->
stream.next_in = 0;
1590 pfile_in_zip_read_info->
stream.avail_in = 0;
1592 err=inflateInit2(&pfile_in_zip_read_info->
stream, -MAX_WBITS);
1597 TRYFREE(pfile_in_zip_read_info);
1618 pfile_in_zip_read_info->
stream.avail_in = (uInt)0;
1624 if (password != NULL)
1637 for (i = 0; i<12; i++)
1674 if (pfile_in_zip_read_info==NULL)
1703 if (pfile_in_zip_read_info==NULL)
1712 pfile_in_zip_read_info->
stream.next_out = (Bytef*)buf;
1714 pfile_in_zip_read_info->
stream.avail_out = (uInt)len;
1717 (!(pfile_in_zip_read_info->
raw)))
1718 pfile_in_zip_read_info->
stream.avail_out =
1722 pfile_in_zip_read_info->
stream.avail_in) &&
1723 (pfile_in_zip_read_info->
raw))
1724 pfile_in_zip_read_info->
stream.avail_out =
1726 pfile_in_zip_read_info->
stream.avail_in;
1728 while (pfile_in_zip_read_info->
stream.avail_out>0)
1730 if ((pfile_in_zip_read_info->
stream.avail_in==0) &&
1747 uReadThis)!=uReadThis)
1755 for(i=0;i<uReadThis;i++)
1767 pfile_in_zip_read_info->
stream.next_in =
1769 pfile_in_zip_read_info->
stream.avail_in = (uInt)uReadThis;
1776 if ((pfile_in_zip_read_info->
stream.avail_in == 0) &&
1778 return (iRead==0) ?
UNZ_EOF : iRead;
1780 if (pfile_in_zip_read_info->
stream.avail_out <
1781 pfile_in_zip_read_info->
stream.avail_in)
1782 uDoCopy = pfile_in_zip_read_info->
stream.avail_out ;
1784 uDoCopy = pfile_in_zip_read_info->
stream.avail_in ;
1786 for (i=0;i<uDoCopy;i++)
1787 *(pfile_in_zip_read_info->
stream.next_out+i) =
1788 *(pfile_in_zip_read_info->
stream.next_in+i);
1792 pfile_in_zip_read_info->
crc32 = crc32(pfile_in_zip_read_info->
crc32,
1793 pfile_in_zip_read_info->
stream.next_out,
1796 pfile_in_zip_read_info->
stream.avail_in -= uDoCopy;
1797 pfile_in_zip_read_info->
stream.avail_out -= uDoCopy;
1798 pfile_in_zip_read_info->
stream.next_out += uDoCopy;
1799 pfile_in_zip_read_info->
stream.next_in += uDoCopy;
1800 pfile_in_zip_read_info->
stream.total_out += uDoCopy;
1806 uLong uTotalOutBefore,uTotalOutAfter;
1807 const Bytef *bufBefore;
1810 pfile_in_zip_read_info->bstream.next_in = (
char*)pfile_in_zip_read_info->
stream.next_in;
1811 pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->
stream.avail_in;
1812 pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->
stream.total_in;
1813 pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
1814 pfile_in_zip_read_info->bstream.next_out = (
char*)pfile_in_zip_read_info->
stream.next_out;
1815 pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->
stream.avail_out;
1816 pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->
stream.total_out;
1817 pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
1819 uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
1820 bufBefore = (
const Bytef *)pfile_in_zip_read_info->bstream.next_out;
1822 err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
1824 uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
1825 uOutThis = uTotalOutAfter-uTotalOutBefore;
1829 pfile_in_zip_read_info->
crc32 = crc32(pfile_in_zip_read_info->
crc32,bufBefore, (uInt)(uOutThis));
1831 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1833 pfile_in_zip_read_info->
stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
1834 pfile_in_zip_read_info->
stream.avail_in = pfile_in_zip_read_info->bstream.avail_in;
1835 pfile_in_zip_read_info->
stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
1836 pfile_in_zip_read_info->
stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
1837 pfile_in_zip_read_info->
stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
1838 pfile_in_zip_read_info->
stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
1840 if (err==BZ_STREAM_END)
1841 return (iRead==0) ?
UNZ_EOF : iRead;
1848 ZPOS64_T uTotalOutBefore,uTotalOutAfter;
1849 const Bytef *bufBefore;
1851 int flush=Z_SYNC_FLUSH;
1853 uTotalOutBefore = pfile_in_zip_read_info->
stream.total_out;
1854 bufBefore = pfile_in_zip_read_info->
stream.next_out;
1862 err=inflate(&pfile_in_zip_read_info->
stream,flush);
1864 if ((err>=0) && (pfile_in_zip_read_info->
stream.msg!=NULL))
1867 uTotalOutAfter = pfile_in_zip_read_info->
stream.total_out;
1868 uOutThis = uTotalOutAfter-uTotalOutBefore;
1872 pfile_in_zip_read_info->
crc32 =
1873 crc32(pfile_in_zip_read_info->
crc32,bufBefore,
1879 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1881 if (err==Z_STREAM_END)
1882 return (iRead==0) ?
UNZ_EOF : iRead;
1906 if (pfile_in_zip_read_info==NULL)
1909 return (z_off_t)pfile_in_zip_read_info->
stream.total_out;
1922 if (pfile_in_zip_read_info==NULL)
1941 if (pfile_in_zip_read_info==NULL)
1976 if (pfile_in_zip_read_info==NULL)
1983 return (
int)size_to_read;
1985 if (len>size_to_read)
1986 read_now = (uInt)size_to_read;
1988 read_now = (uInt)len ;
2002 buf,read_now)!=read_now)
2005 return (
int)read_now;
2023 if (pfile_in_zip_read_info==NULL)
2028 (!pfile_in_zip_read_info->
raw))
2030 if (pfile_in_zip_read_info->
crc32 != pfile_in_zip_read_info->
crc32_wait)
2038 inflateEnd(&pfile_in_zip_read_info->
stream);
2041 BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
2046 TRYFREE(pfile_in_zip_read_info);
2067 uReadThis = uSizeBuf;
2083 return (
int)uReadThis;
2109 return (uLong)offset64;
2125 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
unzFile ZEXPORT unzOpen(voidpf file)
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)
void fill_qiodevice64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
unzFile unzOpenInternal(voidpf file, zlib_filefunc64_32_def *pzlib_filefunc64_32_def, int is64bitOpenFunction, unsigned flags)
ZPOS64_T rest_read_compressed
int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos)
ZPOS64_T pos_in_zip_directory
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
int ZEXPORT unzGoToNextFile(unzFile file)
#define UNZ_INTERNALERROR
#define ZERROR64(filefunc, filestream)
#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 unzSetFlags(unzFile file, unsigned flags)
int ZEXPORT unzClose(unzFile file)
zlib_filefunc64_def zfile_func64
tell_file_func ztell32_file
int ZEXPORT unzeof(unzFile file)
int ZEXPORT unzOpenCurrentFile(unzFile file)
int ZEXPORT unzSetOffset(unzFile file, uLong pos)
int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info)
static ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
static int unz64local_getLong64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
#define ZLIB_FILEFUNC_SEEK_CUR
uLong pos_in_zip_directory
ZPOS64_T uncompressed_size
int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
Addition for GDAL : END.
int ZEXPORT unzClearFlags(unzFile file, unsigned flags)
#define ZCLOSE64(filefunc, filestream)
ZPOS64_T pos_local_extrafield
#define ZFAKECLOSE64(filefunc, filestream)
static void init_keys(const char *passwd, unsigned long *pkeys, const z_crc_t FAR *pcrc_32_tab)
int ZEXPORT unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw)
#define ZREAD64(filefunc, filestream, buf, size)
#define ZOPEN64(filefunc, filename, mode)
#define UNZ_DEFAULT_FLAGS
int ZEXPORT unzCloseCurrentFile(unzFile file)
unzFile ZEXPORT unzOpen2_64(voidpf file, zlib_filefunc64_def *pzlib_filefunc_def)
const z_crc_t FAR * pcrc_32_tab
const char unz_copyright[]
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)
#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)
#define ZTELL64(filefunc, 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
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)
static int strcmpcasenosensitive_internal(const char *fileName1, const char *fileName2)
ZPOS64_T ZEXPORT unztell64(unzFile file)
seek_file_func zseek32_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)
unzFile ZEXPORT unzOpen64(voidpf file)
unz_file_info64 cur_file_info
#define ZSEEK64(filefunc, filestream, pos, mode)
ZPOS64_T byte_before_the_zipfile
#define SIZECENTRALDIRITEM
#define ZLIB_FILEFUNC_SEEK_END
struct unz_file_info64_internal_s unz_file_info64_internal
unzFile ZEXPORT unzOpen2(voidpf file, zlib_filefunc_def *pzlib_filefunc32_def)
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
#define SIZEZIPLOCALHEADER
ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file)
Addition for GDAL : START.
static void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz *ptm)