62 #ifndef CASESENSITIVITYDEFAULT_NO 63 # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) 64 # define CASESENSITIVITYDEFAULT_NO 70 #define UNZ_BUFSIZE (16384) 73 #ifndef UNZ_MAXFILENAMEINZIP 74 #define UNZ_MAXFILENAMEINZIP (256) 78 # define ALLOC(size) (malloc(size)) 81 # define TRYFREE(p) {if (p) free(p);} 84 #define SIZECENTRALDIRITEM (0x2e) 85 #define SIZEZIPLOCALHEADER (0x1e) 91 " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
149 unsigned long keys[3];
177 int err = (
int)
ZREAD(*pzlib_filefunc_def,filestream,&c,1);
185 if (
ZERROR(*pzlib_filefunc_def,filestream))
263 const
char* fileName1;
264 const
char* fileName2;
268 char c1=*(fileName1++);
269 char c2=*(fileName2++);
270 if ((c1>=
'a') && (c1<=
'z'))
272 if ((c2>=
'a') && (c2<=
'z'))
275 return ((c2==
'\0') ? 0 : -1);
286 #ifdef CASESENSITIVITYDEFAULT_NO 287 #define CASESENSITIVITYDEFAULTVALUE 2 289 #define CASESENSITIVITYDEFAULTVALUE 1 292 #ifndef STRCMPCASENOSENTIVEFUNCTION 293 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal 306 const
char* fileName1;
307 const
char* fileName2;
308 int iCaseSensitivity;
310 if (iCaseSensitivity==0)
313 if (iCaseSensitivity==1)
314 return strcmp(fileName1,fileName2);
319 #ifndef BUFREADCOMMENT 320 #define BUFREADCOMMENT (0x400) 338 uLong uMaxBack=0xffff;
345 uSizeFile =
ZTELL(*pzlib_filefunc_def,filestream);
347 if (uMaxBack>uSizeFile)
348 uMaxBack = uSizeFile;
355 while (uBackRead<uMaxBack)
357 uLong uReadSize,uReadPos ;
360 uBackRead = uMaxBack;
363 uReadPos = uSizeFile-uBackRead ;
370 if (
ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
373 for (i=(
int)uReadSize-3; (i--)>0;)
374 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
375 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
377 uPosFound = uReadPos+i;
403 uLong central_pos,uL;
407 uLong number_disk_with_CD;
409 uLong number_entry_CD;
418 if (pzlib_filefunc_def==NULL)
459 (number_disk_with_CD!=0) ||
553 uDate = (
uLong)(ulDosDate>>16);
554 ptm->
tm_mday = (uInt)(uDate&0x1f) ;
555 ptm->
tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
556 ptm->
tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
558 ptm->
tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
559 ptm->
tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
560 ptm->
tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
569 *pfile_info_internal,
571 uLong fileNameBufferSize,
573 uLong extraFieldBufferSize,
575 uLong commentBufferSize));
580 szFileName, fileNameBufferSize,
581 extraField, extraFieldBufferSize,
582 szComment, commentBufferSize)
587 uLong fileNameBufferSize;
589 uLong extraFieldBufferSize;
591 uLong commentBufferSize;
614 else if (uMagic!=0x02014b50)
666 if ((err==
UNZ_OK) && (szFileName!=NULL))
675 uSizeRead = fileNameBufferSize;
684 if ((err==
UNZ_OK) && (extraField!=NULL))
690 uSizeRead = extraFieldBufferSize;
708 if ((err==
UNZ_OK) && (szComment!=NULL))
717 uSizeRead = commentBufferSize;
734 if ((err==
UNZ_OK) && (pfile_info!=NULL))
735 *pfile_info=file_info;
737 if ((err==
UNZ_OK) && (pfile_info_internal!=NULL))
738 *pfile_info_internal=file_info_internal;
752 szFileName, fileNameBufferSize,
753 extraField, extraFieldBufferSize,
754 szComment, commentBufferSize)
758 uLong fileNameBufferSize;
760 uLong extraFieldBufferSize;
762 uLong commentBufferSize;
765 szFileName,fileNameBufferSize,
766 extraField,extraFieldBufferSize,
767 szComment,commentBufferSize);
786 NULL,0,NULL,0,NULL,0);
816 NULL,0,NULL,0,NULL,0);
832 const
char *szFileName;
833 int iCaseSensitivity;
844 uLong pos_in_central_dirSaved;
869 szCurrentFileName,
sizeof(szCurrentFileName)-1,
874 szFileName,iCaseSensitivity)==0)
915 if (file==NULL || file_pos==NULL)
934 if (file==NULL || file_pos==NULL)
945 NULL,0,NULL,0,NULL,0);
964 poffset_local_extrafield,
965 psize_local_extrafield)
968 uLong *poffset_local_extrafield;
969 uInt *psize_local_extrafield;
971 uLong uMagic,uData,uFlags;
973 uLong size_extra_field;
977 *poffset_local_extrafield = 0;
978 *psize_local_extrafield = 0;
980 if (
ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
989 else if (uMagic!=0x04034b50)
1004 else if ((err==
UNZ_OK) && (uData!=s->cur_file_info.compression_method))
1007 if ((err==
UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
1008 (s->cur_file_info.compression_method!=Z_DEFLATED))
1016 else if ((err==
UNZ_OK) && (uData!=s->cur_file_info.crc) &&
1022 else if ((err==
UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
1028 else if ((err==
UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
1035 else if ((err==
UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
1038 *piSizeVar += (uInt)size_filename;
1042 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
1044 *psize_local_extrafield = (uInt)size_extra_field;
1046 *piSizeVar += (uInt)size_extra_field;
1060 const
char* password;
1066 uLong offset_local_extrafield;
1067 uInt size_local_extrafield;
1071 if (password != NULL)
1085 &offset_local_extrafield,&size_local_extrafield)!=
UNZ_OK)
1090 if (pfile_in_zip_read_info==NULL)
1097 pfile_in_zip_read_info->
raw=raw;
1101 TRYFREE(pfile_in_zip_read_info);
1115 case 6 : *level = 1;
break;
1116 case 4 : *level = 2;
break;
1117 case 2 : *level = 9;
break;
1126 pfile_in_zip_read_info->
crc32=0;
1133 pfile_in_zip_read_info->
stream.total_out = 0;
1138 pfile_in_zip_read_info->
stream.zalloc = (alloc_func)0;
1139 pfile_in_zip_read_info->
stream.zfree = (free_func)0;
1142 pfile_in_zip_read_info->
stream.avail_in = 0;
1144 err=inflateInit2(&pfile_in_zip_read_info->
stream, -MAX_WBITS);
1149 TRYFREE(pfile_in_zip_read_info);
1170 pfile_in_zip_read_info->
stream.avail_in = (uInt)0;
1175 if (password != NULL)
1178 s->
pcrc_32_tab = (
const unsigned long *)get_crc_table();
1188 for (i = 0; i<12; i++)
1208 const
char* password;
1246 if (pfile_in_zip_read_info==NULL)
1250 if ((pfile_in_zip_read_info->
read_buffer == NULL))
1255 pfile_in_zip_read_info->
stream.next_out = (Bytef*)buf;
1257 pfile_in_zip_read_info->
stream.avail_out = (uInt)len;
1260 (!(pfile_in_zip_read_info->
raw)))
1261 pfile_in_zip_read_info->
stream.avail_out =
1265 pfile_in_zip_read_info->
stream.avail_in) &&
1266 (pfile_in_zip_read_info->
raw))
1267 pfile_in_zip_read_info->
stream.avail_out =
1269 pfile_in_zip_read_info->
stream.avail_in;
1271 while (pfile_in_zip_read_info->
stream.avail_out>0)
1273 if ((pfile_in_zip_read_info->
stream.avail_in==0) &&
1290 uReadThis)!=uReadThis)
1298 for(i=0;i<uReadThis;i++)
1310 pfile_in_zip_read_info->
stream.next_in =
1312 pfile_in_zip_read_info->
stream.avail_in = (uInt)uReadThis;
1319 if ((pfile_in_zip_read_info->
stream.avail_in == 0) &&
1321 return (iRead==0) ?
UNZ_EOF : iRead;
1323 if (pfile_in_zip_read_info->
stream.avail_out <
1324 pfile_in_zip_read_info->
stream.avail_in)
1325 uDoCopy = pfile_in_zip_read_info->
stream.avail_out ;
1327 uDoCopy = pfile_in_zip_read_info->
stream.avail_in ;
1329 for (i=0;i<uDoCopy;i++)
1330 *(pfile_in_zip_read_info->
stream.next_out+i) =
1331 *(pfile_in_zip_read_info->
stream.next_in+i);
1333 pfile_in_zip_read_info->
crc32 = crc32(pfile_in_zip_read_info->
crc32,
1334 pfile_in_zip_read_info->
stream.next_out,
1337 pfile_in_zip_read_info->
stream.avail_in -= uDoCopy;
1338 pfile_in_zip_read_info->
stream.avail_out -= uDoCopy;
1339 pfile_in_zip_read_info->
stream.next_out += uDoCopy;
1340 pfile_in_zip_read_info->
stream.next_in += uDoCopy;
1341 pfile_in_zip_read_info->
stream.total_out += uDoCopy;
1346 uLong uTotalOutBefore,uTotalOutAfter;
1347 const Bytef *bufBefore;
1349 int flush=Z_SYNC_FLUSH;
1351 uTotalOutBefore = pfile_in_zip_read_info->
stream.total_out;
1352 bufBefore = pfile_in_zip_read_info->
stream.next_out;
1360 err=inflate(&pfile_in_zip_read_info->
stream,flush);
1362 if ((err>=0) && (pfile_in_zip_read_info->
stream.msg!=NULL))
1365 uTotalOutAfter = pfile_in_zip_read_info->
stream.total_out;
1366 uOutThis = uTotalOutAfter-uTotalOutBefore;
1368 pfile_in_zip_read_info->
crc32 =
1369 crc32(pfile_in_zip_read_info->
crc32,bufBefore,
1375 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1377 if (err==Z_STREAM_END)
1378 return (iRead==0) ?
UNZ_EOF : iRead;
1403 if (pfile_in_zip_read_info==NULL)
1406 return (z_off_t)pfile_in_zip_read_info->
stream.total_out;
1423 if (pfile_in_zip_read_info==NULL)
1461 if (pfile_in_zip_read_info==NULL)
1468 return (
int)size_to_read;
1470 if (len>size_to_read)
1471 read_now = (uInt)size_to_read;
1473 read_now = (uInt)len ;
1487 buf,read_now)!=read_now)
1490 return (
int)read_now;
1509 if (pfile_in_zip_read_info==NULL)
1514 (!pfile_in_zip_read_info->
raw))
1516 if (pfile_in_zip_read_info->
crc32 != pfile_in_zip_read_info->
crc32_wait)
1524 inflateEnd(&pfile_in_zip_read_info->
stream);
1527 TRYFREE(pfile_in_zip_read_info);
1551 uReadThis = uSizeBuf;
1567 return (
int)uReadThis;
1602 NULL,0,NULL,0,NULL,0);
uLong rest_read_compressed
unzFile ZEXPORT unzOpen2(char *path, zlib_filefunc_def *pzlib_filefunc_def) const
local int unzlocal_getByte OF((const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, int *pi))
#define ZTELL(filefunc, filestream)
#define ZREAD(filefunc, filestream, buf, size)
int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity)
int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len)
int ZEXPORT unzGoToFirstFile(unzFile file)
int ZEXPORT unzStringFileNameCompare(char *fileName1, const char *fileName2, int iCaseSensitivity) const
local void unzlocal_DosDateToTmuDate(uLong ulDosDate, tm_unz *ptm)
int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info)
uLong pos_in_zip_directory
zlib_filefunc_def z_filefunc
int ZEXPORT unzGoToNextFile(unzFile file)
#define UNZ_INTERNALERROR
#define ZLIB_FILEFUNC_MODE_READ
#define STRCMPCASENOSENTIVEFUNCTION
int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
int ZEXPORT unzClose(unzFile file)
int ZEXPORT unzeof(unzFile file)
int ZEXPORT unzOpenCurrentFile(unzFile file)
int ZEXPORT unzSetOffset(unzFile file, uLong pos)
local int unzlocal_CheckCurrentFileCoherencyHeader(unz_s *s, uInt *piSizeVar, uLong *poffset_local_extrafield, uInt *psize_local_extrafield)
#define ZERROR(filefunc, filestream)
#define ZSEEK(filefunc, filestream, pos, mode)
int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
#define ZLIB_FILEFUNC_SEEK_CUR
const unsigned long * pcrc_32_tab
int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
local int unzlocal_getByte(zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, int *pi) const
file_in_zip_read_info_s * pfile_in_zip_read
typedef voidpf(ZCALLBACK *open_file_func) OF((voidpf opaque
uLong offset_local_extrafield
int ZEXPORT unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw)
int ZEXPORT unzCloseCurrentFile(unzFile file)
const char unz_copyright[]
uLong pos_local_extrafield
unz_file_info cur_file_info
struct unz_file_info_internal_s unz_file_info_internal
local int unzlocal_getLong(zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, uLong *pX) const
int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char *password)
#define ZLIB_FILEFUNC_MODE_EXISTING
local uLong unzlocal_SearchCentralDir(zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream) const
unzFile ZEXPORT unzOpen(char *path) const
int ZEXPORT unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf)
int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos)
zlib_filefunc_def z_filefunc
#define ZCLOSE(filefunc, filestream)
open_file_func zopen_file
z_off_t ZEXPORT unztell(unzFile file)
#define zdecode(pkeys, pcrc_32_tab, c)
#define CASESENSITIVITYDEFAULTVALUE
#define UNZ_MAXFILENAMEINZIP
uLong byte_before_the_zipfile
uLong ZEXPORT unzGetOffset(unzFile file)
uLong byte_before_the_zipfile
local int unzlocal_GetCurrentFileInfoInternal(unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
#define SIZECENTRALDIRITEM
#define ZLIB_FILEFUNC_SEEK_END
local int strcmpcasenosensitive_internal(char *fileName1, const char *fileName2) const
unz_file_info_internal cur_file_info_internal
local int unzlocal_getShort(zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, uLong *pX) const
int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos *file_pos)
void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
#define ZLIB_FILEFUNC_SEEK_SET
#define UNZ_END_OF_LIST_OF_FILE
typedef uLong(ZCALLBACK *read_file_func) OF((voidpf opaque
uInt size_local_extrafield
#define SIZEZIPLOCALHEADER
uLong rest_read_uncompressed