Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
unzip.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "unzip.h"
#include <errno.h>
+ Include dependency graph for unzip.c:

Go to the source code of this file.

Classes

struct  unz_file_info64_internal_s
 
struct  file_in_zip64_read_info_s
 
struct  unz64_s
 

Macros

#define NOUNCRYPT
 
#define local   static
 
#define CASESENSITIVITYDEFAULT_NO
 
#define UNZ_BUFSIZE   (16384)
 
#define UNZ_MAXFILENAMEINZIP   (256)
 
#define ALLOC(size)
 
#define TRYFREE(p)
 
#define SIZECENTRALDIRITEM   (0x2e)
 
#define SIZEZIPLOCALHEADER   (0x1e)
 
#define CASESENSITIVITYDEFAULTVALUE   2
 
#define STRCMPCASENOSENTIVEFUNCTION   strcmpcasenosensitive_internal
 
#define BUFREADCOMMENT   (0x400)
 

Typedefs

typedef struct unz_file_info64_internal_s unz_file_info64_internal
 

Functions

local int unz64local_getByte OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi))
 
local int unz64local_getByte (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
 
local int unz64local_getShort OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX))
 
local int unz64local_getShort (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
 
local int unz64local_getLong (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
 
local int unz64local_getLong64 OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX))
 
local int unz64local_getLong64 (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
 
local int strcmpcasenosensitive_internal (const char *fileName1, const char *fileName2)
 
int ZEXPORT unzStringFileNameCompare (const char *fileName1, const char *fileName2, int iCaseSensitivity)
 
local ZPOS64_T unz64local_SearchCentralDir OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream))
 
local ZPOS64_T unz64local_SearchCentralDir (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
 
local ZPOS64_T unz64local_SearchCentralDir64 (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
 
local unzFile unzOpenInternal (const void *path, zlib_filefunc64_32_def *pzlib_filefunc64_32_def, int is64bitOpenFunction)
 
unzFile ZEXPORT unzOpen2 (const char *path, zlib_filefunc_def *pzlib_filefunc32_def)
 
unzFile ZEXPORT unzOpen2_64 (const void *path, zlib_filefunc64_def *pzlib_filefunc_def)
 
unzFile ZEXPORT unzOpen (const char *path)
 
unzFile ZEXPORT unzOpen64 (const void *path)
 
int ZEXPORT unzClose (unzFile file)
 
int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64 *pglobal_info)
 
int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info32)
 
local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz *ptm)
 
local int unz64local_GetCurrentFileInfoInternal OF ((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))
 
local 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)
 
int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
 
int ZEXPORT unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
 
int ZEXPORT unzGoToFirstFile (unzFile file)
 
int ZEXPORT unzGoToNextFile (unzFile file)
 
int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
 
int ZEXPORT unzGetFilePos64 (unzFile file, unz64_file_pos *file_pos)
 
int ZEXPORT unzGetFilePos (unzFile file, unz_file_pos *file_pos)
 
int ZEXPORT unzGoToFilePos64 (unzFile file, const unz64_file_pos *file_pos)
 
int ZEXPORT unzGoToFilePos (unzFile file, unz_file_pos *file_pos)
 
local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s *s, uInt *piSizeVar, ZPOS64_T *poffset_local_extrafield, uInt *psize_local_extrafield)
 
int ZEXPORT unzOpenCurrentFile3 (unzFile file, int *method, int *level, int raw, const char *password)
 
int ZEXPORT unzOpenCurrentFile (unzFile file)
 
int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char *password)
 
int ZEXPORT unzOpenCurrentFile2 (unzFile file, int *method, int *level, int raw)
 
ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 (unzFile file)
 
int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
 
z_off_t ZEXPORT unztell (unzFile file)
 
ZPOS64_T ZEXPORT unztell64 (unzFile file)
 
int ZEXPORT unzeof (unzFile file)
 
int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
 
int ZEXPORT unzCloseCurrentFile (unzFile file)
 
int ZEXPORT unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)
 
ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file)
 
uLong ZEXPORT unzGetOffset (unzFile file)
 
int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos)
 
int ZEXPORT unzSetOffset (unzFile file, uLong pos)
 

Variables

static const char unz_copyright []
 

Macro Definition Documentation

◆ ALLOC

#define ALLOC ( size)
Value:
(malloc(size))
voidpf void uLong size
Definition ioapi.h:134

Definition at line 112 of file unzip.c.

Referenced by unz64local_SearchCentralDir(), unz64local_SearchCentralDir64(), unzOpenCurrentFile3(), and unzOpenInternal().

◆ BUFREADCOMMENT

#define BUFREADCOMMENT   (0x400)

Definition at line 408 of file unzip.c.

Referenced by unz64local_SearchCentralDir(), and unz64local_SearchCentralDir64().

◆ CASESENSITIVITYDEFAULT_NO

#define CASESENSITIVITYDEFAULT_NO

Definition at line 98 of file unzip.c.

◆ CASESENSITIVITYDEFAULTVALUE

#define CASESENSITIVITYDEFAULTVALUE   2

Definition at line 375 of file unzip.c.

Referenced by unzStringFileNameCompare().

◆ local

#define local   static

Definition at line 91 of file unzip.c.

◆ NOUNCRYPT

#define NOUNCRYPT

Definition at line 72 of file unzip.c.

◆ SIZECENTRALDIRITEM

#define SIZECENTRALDIRITEM   (0x2e)

Definition at line 118 of file unzip.c.

Referenced by unzGoToNextFile().

◆ SIZEZIPLOCALHEADER

#define SIZEZIPLOCALHEADER   (0x1e)

Definition at line 119 of file unzip.c.

Referenced by unz64local_CheckCurrentFileCoherencyHeader(), and unzOpenCurrentFile3().

◆ STRCMPCASENOSENTIVEFUNCTION

#define STRCMPCASENOSENTIVEFUNCTION   strcmpcasenosensitive_internal

Definition at line 381 of file unzip.c.

Referenced by unzStringFileNameCompare().

◆ TRYFREE

#define TRYFREE ( p)
Value:
{if (p) free(p);}

Definition at line 115 of file unzip.c.

Referenced by unz64local_SearchCentralDir(), unz64local_SearchCentralDir64(), unzClose(), unzCloseCurrentFile(), and unzOpenCurrentFile3().

◆ UNZ_BUFSIZE

#define UNZ_BUFSIZE   (16384)

Definition at line 104 of file unzip.c.

Referenced by unzOpenCurrentFile3(), and unzReadCurrentFile().

◆ UNZ_MAXFILENAMEINZIP

#define UNZ_MAXFILENAMEINZIP   (256)

Definition at line 108 of file unzip.c.

Referenced by unzLocateFile().

Typedef Documentation

◆ unz_file_info64_internal

Function Documentation

◆ OF() [1/5]

local ZPOS64_T unz64local_SearchCentralDir64 OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream) )

◆ OF() [2/5]

local int unz64local_getByte OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi) )

◆ OF() [3/5]

local int unz64local_getLong OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX) )

◆ OF() [4/5]

local int unz64local_getLong64 OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) )

◆ OF() [5/5]

local int unz64local_GetCurrentFileInfoInternal OF ( (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) )

◆ strcmpcasenosensitive_internal()

local int strcmpcasenosensitive_internal ( const char * fileName1,
const char * fileName2 )

Definition at line 352 of file unzip.c.

353{
354 for (;;)
355 {
356 char c1=*(fileName1++);
357 char c2=*(fileName2++);
358 if ((c1>='a') && (c1<='z'))
359 c1 -= 0x20;
360 if ((c2>='a') && (c2<='z'))
361 c2 -= 0x20;
362 if (c1=='\0')
363 return ((c2=='\0') ? 0 : -1);
364 if (c2=='\0')
365 return 1;
366 if (c1<c2)
367 return -1;
368 if (c1>c2)
369 return 1;
370 }
371}

◆ unz64local_CheckCurrentFileCoherencyHeader()

local int unz64local_CheckCurrentFileCoherencyHeader ( unz64_s * s,
uInt * piSizeVar,
ZPOS64_T * poffset_local_extrafield,
uInt * psize_local_extrafield )

Definition at line 1391 of file unzip.c.

1394{
1395 uLong uMagic,uData,uFlags;
1396 uLong size_filename;
1397 uLong size_extra_field;
1398 int err=UNZ_OK;
1399
1400 *piSizeVar = 0;
1401 *poffset_local_extrafield = 0;
1402 *psize_local_extrafield = 0;
1403
1406 return UNZ_ERRNO;
1407
1408
1409 if (err==UNZ_OK)
1410 {
1411 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
1412 err=UNZ_ERRNO;
1413 else if (uMagic!=0x04034b50)
1414 err=UNZ_BADZIPFILE;
1415 }
1416
1417 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1418 err=UNZ_ERRNO;
1419/*
1420 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
1421 err=UNZ_BADZIPFILE;
1422*/
1423 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
1424 err=UNZ_ERRNO;
1425
1426 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1427 err=UNZ_ERRNO;
1428 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
1429 err=UNZ_BADZIPFILE;
1430
1431 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
1432/* #ifdef HAVE_BZIP2 */
1434/* #endif */
1436 err=UNZ_BADZIPFILE;
1437
1438 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
1439 err=UNZ_ERRNO;
1440
1441 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
1442 err=UNZ_ERRNO;
1443 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
1444 err=UNZ_BADZIPFILE;
1445
1446 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
1447 err=UNZ_ERRNO;
1448 else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
1449 err=UNZ_BADZIPFILE;
1450
1451 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
1452 err=UNZ_ERRNO;
1453 else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
1454 err=UNZ_BADZIPFILE;
1455
1456 if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
1457 err=UNZ_ERRNO;
1458 else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
1459 err=UNZ_BADZIPFILE;
1460
1461 *piSizeVar += (uInt)size_filename;
1462
1463 if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
1464 err=UNZ_ERRNO;
1465 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
1466 SIZEZIPLOCALHEADER + size_filename;
1467 *psize_local_extrafield = (uInt)size_extra_field;
1468
1469 *piSizeVar += (uInt)size_extra_field;
1470
1471 return err;
1472}
#define ZSEEK64(filefunc, filestream, pos, mode)
Definition ioapi.h:200
#define ZLIB_FILEFUNC_SEEK_SET
Definition ioapi.h:112
mz_ulong uLong
Definition miniz.h:447
#define Z_DEFLATED
Definition miniz.h:482
unsigned int uInt
Definition miniz.h:446
zlib_filefunc64_32_def z_filefunc
Definition unzip.c:170
unz_file_info64 cur_file_info
Definition unzip.c:184
unz_file_info64_internal cur_file_info_internal
Definition unzip.c:185
voidpf filestream
Definition unzip.c:172
ZPOS64_T byte_before_the_zipfile
Definition unzip.c:174
ZPOS64_T uncompressed_size
Definition unzip.h:120
uLong size_filename
Definition unzip.h:121
uLong compression_method
Definition unzip.h:116
ZPOS64_T compressed_size
Definition unzip.h:119
#define SIZEZIPLOCALHEADER
Definition unzip.c:119
local int unz64local_getShort(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
Definition unzip.c:242
local int unz64local_getLong(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
Definition unzip.c:269
#define UNZ_BADZIPFILE
Definition unzip.h:79
#define UNZ_ERRNO
Definition unzip.h:76
#define UNZ_OK
Definition unzip.h:74
#define Z_BZIP2ED
Definition unzip.h:62

References unz64_s::byte_before_the_zipfile, unz_file_info64_s::compressed_size, unz_file_info64_s::compression_method, unz_file_info64_s::crc, unz64_s::cur_file_info, unz64_s::cur_file_info_internal, unz64_s::filestream, unz_file_info64_internal_s::offset_curfile, unz_file_info64_s::size_filename, SIZEZIPLOCALHEADER, unz_file_info64_s::uncompressed_size, unz64local_getLong(), unz64local_getShort(), UNZ_BADZIPFILE, UNZ_ERRNO, UNZ_OK, Z_BZIP2ED, Z_DEFLATED, unz64_s::z_filefunc, ZLIB_FILEFUNC_SEEK_SET, and ZSEEK64.

Referenced by unzOpenCurrentFile3().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unz64local_DosDateToTmuDate()

local void unz64local_DosDateToTmuDate ( ZPOS64_T ulDosDate,
tm_unz * ptm )

Definition at line 855 of file unzip.c.

856{
857 ZPOS64_T uDate;
858 uDate = (ZPOS64_T)(ulDosDate>>16);
859 ptm->tm_mday = (uInt)(uDate&0x1f) ;
860 ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
861 ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
862
863 ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
864 ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
865 ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
866}
unsigned long long int ZPOS64_T
Definition ioapi.h:98
uInt tm_mon
Definition unzip.h:90
uInt tm_mday
Definition unzip.h:89
uInt tm_year
Definition unzip.h:91
uInt tm_sec
Definition unzip.h:86
uInt tm_min
Definition unzip.h:87
uInt tm_hour
Definition unzip.h:88

References tm_unz_s::tm_hour, tm_unz_s::tm_mday, tm_unz_s::tm_min, tm_unz_s::tm_mon, tm_unz_s::tm_sec, and tm_unz_s::tm_year.

Referenced by unz64local_GetCurrentFileInfoInternal().

+ Here is the caller graph for this function:

◆ unz64local_getByte()

local int unz64local_getByte ( const zlib_filefunc64_32_def * pzlib_filefunc_def,
voidpf filestream,
int * pi )

Definition at line 215 of file unzip.c.

216{
217 unsigned char c;
218 int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
219 if (err==1)
220 {
221 *pi = (int)c;
222 return UNZ_OK;
223 }
224 else
225 {
226 if (ZERROR64(*pzlib_filefunc_def,filestream))
227 return UNZ_ERRNO;
228 else
229 return UNZ_EOF;
230 }
231}
#define ZERROR64(filefunc, filestream)
Definition ioapi.h:190
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
#define ZREAD64(filefunc, filestream, buf, size)
Definition ioapi.h:185
#define UNZ_EOF
Definition unzip.h:77

References int(), UNZ_EOF, UNZ_ERRNO, UNZ_OK, ZERROR64, and ZREAD64.

Referenced by unz64local_getLong(), unz64local_getLong64(), and unz64local_getShort().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unz64local_GetCurrentFileInfoInternal()

local 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 )

Definition at line 882 of file unzip.c.

892{
893 unz64_s* s;
894 unz_file_info64 file_info;
895 unz_file_info64_internal file_info_internal;
896 int err=UNZ_OK;
897 uLong uMagic;
898 long lSeek=0;
899 uLong uL;
900
901 if (file==NULL)
902 return UNZ_PARAMERROR;
903 s=(unz64_s*)file;
904 if (ZSEEK64(s->z_filefunc, s->filestream,
907 err=UNZ_ERRNO;
908
909
910 /* we check the magic */
911 if (err==UNZ_OK)
912 {
913 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
914 err=UNZ_ERRNO;
915 else if (uMagic!=0x02014b50)
916 err=UNZ_BADZIPFILE;
917 }
918
919 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
920 err=UNZ_ERRNO;
921
923 err=UNZ_ERRNO;
924
925 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
926 err=UNZ_ERRNO;
927
929 err=UNZ_ERRNO;
930
931 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
932 err=UNZ_ERRNO;
933
934 unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
935
936 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
937 err=UNZ_ERRNO;
938
940 err=UNZ_ERRNO;
941 file_info.compressed_size = uL;
942
944 err=UNZ_ERRNO;
945 file_info.uncompressed_size = uL;
946
948 err=UNZ_ERRNO;
949
951 err=UNZ_ERRNO;
952
954 err=UNZ_ERRNO;
955
957 err=UNZ_ERRNO;
958
960 err=UNZ_ERRNO;
961
962 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
963 err=UNZ_ERRNO;
964
965 // relative offset of local header
967 err=UNZ_ERRNO;
968 file_info_internal.offset_curfile = uL;
969
970 lSeek+=file_info.size_filename;
971 if ((err==UNZ_OK) && (szFileName!=NULL))
972 {
973 uLong uSizeRead ;
974 if (file_info.size_filename<fileNameBufferSize)
975 {
976 *(szFileName+file_info.size_filename)='\0';
977 uSizeRead = file_info.size_filename;
978 }
979 else
980 uSizeRead = fileNameBufferSize;
981
982 if ((file_info.size_filename>0) && (fileNameBufferSize>0))
983 if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
984 err=UNZ_ERRNO;
985 lSeek -= uSizeRead;
986 }
987
988 // Read extrafield
989 if ((err==UNZ_OK) && (extraField!=NULL))
990 {
991 ZPOS64_T uSizeRead ;
992 if (file_info.size_file_extra<extraFieldBufferSize)
993 uSizeRead = file_info.size_file_extra;
994 else
995 uSizeRead = extraFieldBufferSize;
996
997 if (lSeek!=0)
998 {
1000 lSeek=0;
1001 else
1002 err=UNZ_ERRNO;
1003 }
1004
1005 if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
1006 if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
1007 err=UNZ_ERRNO;
1008
1009 lSeek += file_info.size_file_extra - (uLong)uSizeRead;
1010 }
1011 else
1012 lSeek += file_info.size_file_extra;
1013
1014
1015 if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
1016 {
1017 uLong acc = 0;
1018
1019 // since lSeek now points to after the extra field we need to move back
1020 lSeek -= file_info.size_file_extra;
1021
1022 if (lSeek!=0)
1023 {
1025 lSeek=0;
1026 else
1027 err=UNZ_ERRNO;
1028 }
1029
1030 while(acc < file_info.size_file_extra)
1031 {
1032 uLong headerId;
1033 uLong dataSize;
1034
1035 if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
1036 err=UNZ_ERRNO;
1037
1038 if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
1039 err=UNZ_ERRNO;
1040
1041 /* ZIP64 extra fields */
1042 if (headerId == 0x0001)
1043 {
1044 uLong uL;
1045
1046 if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
1047 {
1049 err=UNZ_ERRNO;
1050 }
1051
1052 if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
1053 {
1055 err=UNZ_ERRNO;
1056 }
1057
1058 if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
1059 {
1060 /* Relative Header offset */
1061 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
1062 err=UNZ_ERRNO;
1063 }
1064
1065 if(file_info.disk_num_start == (unsigned long)-1)
1066 {
1067 /* Disk Start Number */
1068 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
1069 err=UNZ_ERRNO;
1070 }
1071
1072 }
1073 else
1074 {
1075 if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
1076 err=UNZ_ERRNO;
1077 }
1078
1079 acc += 2 + 2 + dataSize;
1080 }
1081 }
1082
1083 if ((err==UNZ_OK) && (szComment!=NULL))
1084 {
1085 uLong uSizeRead ;
1086 if (file_info.size_file_comment<commentBufferSize)
1087 {
1088 *(szComment+file_info.size_file_comment)='\0';
1089 uSizeRead = file_info.size_file_comment;
1090 }
1091 else
1092 uSizeRead = commentBufferSize;
1093
1094 if (lSeek!=0)
1095 {
1097 lSeek=0;
1098 else
1099 err=UNZ_ERRNO;
1100 }
1101
1102 if ((file_info.size_file_comment>0) && (commentBufferSize>0))
1103 if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
1104 err=UNZ_ERRNO;
1105/* commented out code from original minizip: compiler points out the
1106 * value doesn't get further use, so make it marginally more efficient
1107 * - CIM */
1108// lSeek+=file_info.size_file_comment - uSizeRead;
1109 }
1110 else
1111// lSeek+=file_info.size_file_comment;
1112
1113
1114 if ((err==UNZ_OK) && (pfile_info!=NULL))
1115 *pfile_info=file_info;
1116
1117 if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
1118 *pfile_info_internal=file_info_internal;
1119
1120 return err;
1121}
#define ZLIB_FILEFUNC_SEEK_CUR
Definition ioapi.h:110
ZPOS64_T pos_in_central_dir
Definition unzip.c:176
uLong size_file_extra
Definition unzip.h:122
uLong internal_fa
Definition unzip.h:126
tm_unz tmu_date
Definition unzip.h:129
uLong external_fa
Definition unzip.h:127
uLong version_needed
Definition unzip.h:114
uLong disk_num_start
Definition unzip.h:125
uLong size_file_comment
Definition unzip.h:123
local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz *ptm)
Definition unzip.c:855
local int unz64local_getLong64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
Definition unzip.c:305
#define UNZ_PARAMERROR
Definition unzip.h:78

References unz64_s::byte_before_the_zipfile, unz_file_info64_s::compressed_size, unz_file_info64_s::compression_method, unz_file_info64_s::crc, unz_file_info64_s::disk_num_start, unz_file_info64_s::dosDate, unz_file_info64_s::external_fa, unz64_s::filestream, unz_file_info64_s::flag, unz_file_info64_s::internal_fa, unz_file_info64_internal_s::offset_curfile, unz64_s::pos_in_central_dir, unz_file_info64_s::size_file_comment, unz_file_info64_s::size_file_extra, unz_file_info64_s::size_filename, unz_file_info64_s::tmu_date, unz_file_info64_s::uncompressed_size, unz64local_DosDateToTmuDate(), unz64local_getLong(), unz64local_getLong64(), unz64local_getShort(), UNZ_BADZIPFILE, UNZ_ERRNO, UNZ_OK, UNZ_PARAMERROR, unz_file_info64_s::version, unz_file_info64_s::version_needed, unz64_s::z_filefunc, ZLIB_FILEFUNC_SEEK_CUR, ZLIB_FILEFUNC_SEEK_SET, ZREAD64, and ZSEEK64.

Referenced by unzGetCurrentFileInfo(), unzGetCurrentFileInfo64(), unzGoToFilePos64(), unzGoToFirstFile(), unzGoToNextFile(), and unzSetOffset64().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unz64local_getLong()

local int unz64local_getLong ( const zlib_filefunc64_32_def * pzlib_filefunc_def,
voidpf filestream,
uLong * pX )

Definition at line 269 of file unzip.c.

272{
273 uLong x ;
274 int i = 0;
275 int err;
276
277 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
278 x = (uLong)i;
279
280 if (err==UNZ_OK)
281 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
282 x |= ((uLong)i)<<8;
283
284 if (err==UNZ_OK)
285 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
286 x |= ((uLong)i)<<16;
287
288 if (err==UNZ_OK)
289 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
290 x += ((uLong)i)<<24;
291
292 if (err==UNZ_OK)
293 *pX = x;
294 else
295 *pX = 0;
296 return err;
297}
float x
local int unz64local_getByte(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
Definition unzip.c:215

References unz64local_getByte(), UNZ_OK, and x.

Referenced by unz64local_CheckCurrentFileCoherencyHeader(), unz64local_GetCurrentFileInfoInternal(), unz64local_SearchCentralDir64(), and unzOpenInternal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unz64local_getLong64()

local int unz64local_getLong64 ( const zlib_filefunc64_32_def * pzlib_filefunc_def,
voidpf filestream,
ZPOS64_T * pX )

Definition at line 305 of file unzip.c.

308{
309 ZPOS64_T x ;
310 int i = 0;
311 int err;
312
313 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
314 x = (ZPOS64_T)i;
315
316 if (err==UNZ_OK)
317 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
318 x |= ((ZPOS64_T)i)<<8;
319
320 if (err==UNZ_OK)
321 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
322 x |= ((ZPOS64_T)i)<<16;
323
324 if (err==UNZ_OK)
325 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
326 x |= ((ZPOS64_T)i)<<24;
327
328 if (err==UNZ_OK)
329 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
330 x |= ((ZPOS64_T)i)<<32;
331
332 if (err==UNZ_OK)
333 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
334 x |= ((ZPOS64_T)i)<<40;
335
336 if (err==UNZ_OK)
337 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
338 x |= ((ZPOS64_T)i)<<48;
339
340 if (err==UNZ_OK)
341 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
342 x |= ((ZPOS64_T)i)<<56;
343
344 if (err==UNZ_OK)
345 *pX = x;
346 else
347 *pX = 0;
348 return err;
349}

References unz64local_getByte(), UNZ_OK, and x.

Referenced by unz64local_GetCurrentFileInfoInternal(), unz64local_SearchCentralDir64(), and unzOpenInternal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unz64local_getShort()

local int unz64local_getShort ( const zlib_filefunc64_32_def * pzlib_filefunc_def,
voidpf filestream,
uLong * pX )

Definition at line 242 of file unzip.c.

245{
246 uLong x ;
247 int i = 0;
248 int err;
249
250 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
251 x = (uLong)i;
252
253 if (err==UNZ_OK)
254 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
255 x |= ((uLong)i)<<8;
256
257 if (err==UNZ_OK)
258 *pX = x;
259 else
260 *pX = 0;
261 return err;
262}

References unz64local_getByte(), UNZ_OK, and x.

Referenced by unz64local_CheckCurrentFileCoherencyHeader(), unz64local_GetCurrentFileInfoInternal(), and unzOpenInternal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unz64local_SearchCentralDir()

local ZPOS64_T unz64local_SearchCentralDir ( const zlib_filefunc64_32_def * pzlib_filefunc_def,
voidpf filestream )

Definition at line 416 of file unzip.c.

417{
418 unsigned char* buf;
419 ZPOS64_T uSizeFile;
420 ZPOS64_T uBackRead;
421 ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
422 ZPOS64_T uPosFound=0;
423
424 if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
425 return 0;
426
427
428 uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
429
430 if (uMaxBack>uSizeFile)
431 uMaxBack = uSizeFile;
432
433 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
434 if (buf==NULL)
435 return 0;
436
437 uBackRead = 4;
438 while (uBackRead<uMaxBack)
439 {
440 uLong uReadSize;
441 ZPOS64_T uReadPos ;
442 int i;
443 if (uBackRead+BUFREADCOMMENT>uMaxBack)
444 uBackRead = uMaxBack;
445 else
446 uBackRead+=BUFREADCOMMENT;
447 uReadPos = uSizeFile-uBackRead ;
448
449 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
450 (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
451 if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
452 break;
453
454 if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
455 break;
456
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))
460 {
461 uPosFound = uReadPos+i;
462 break;
463 }
464
465 if (uPosFound!=0)
466 break;
467 }
468 TRYFREE(buf);
469 return uPosFound;
470}
voidpf void * buf
Definition ioapi.h:134
#define ZTELL64(filefunc, filestream)
Definition ioapi.h:199
#define ZLIB_FILEFUNC_SEEK_END
Definition ioapi.h:111
#define BUFREADCOMMENT
Definition unzip.c:408
#define TRYFREE(p)
Definition unzip.c:115
#define ALLOC(size)
Definition unzip.c:112

References ALLOC, BUFREADCOMMENT, TRYFREE, ZLIB_FILEFUNC_SEEK_END, ZLIB_FILEFUNC_SEEK_SET, ZREAD64, ZSEEK64, and ZTELL64.

Referenced by unzOpenInternal().

+ Here is the caller graph for this function:

◆ unz64local_SearchCentralDir64()

local ZPOS64_T unz64local_SearchCentralDir64 ( const zlib_filefunc64_32_def * pzlib_filefunc_def,
voidpf filestream )

Definition at line 481 of file unzip.c.

483{
484 unsigned char* buf;
485 ZPOS64_T uSizeFile;
486 ZPOS64_T uBackRead;
487 ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
488 ZPOS64_T uPosFound=0;
489 uLong uL;
490 ZPOS64_T relativeOffset;
491
492 if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
493 return 0;
494
495
496 uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
497
498 if (uMaxBack>uSizeFile)
499 uMaxBack = uSizeFile;
500
501 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
502 if (buf==NULL)
503 return 0;
504
505 uBackRead = 4;
506 while (uBackRead<uMaxBack)
507 {
508 uLong uReadSize;
509 ZPOS64_T uReadPos;
510 int i;
511 if (uBackRead+BUFREADCOMMENT>uMaxBack)
512 uBackRead = uMaxBack;
513 else
514 uBackRead+=BUFREADCOMMENT;
515 uReadPos = uSizeFile-uBackRead ;
516
517 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
518 (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
519 if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
520 break;
521
522 if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
523 break;
524
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))
528 {
529 uPosFound = uReadPos+i;
530 break;
531 }
532
533 if (uPosFound!=0)
534 break;
535 }
536 TRYFREE(buf);
537 if (uPosFound == 0)
538 return 0;
539
540 /* Zip64 end of central directory locator */
541 if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
542 return 0;
543
544 /* the signature, already checked */
545 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
546 return 0;
547
548 /* number of the disk with the start of the zip64 end of central directory */
549 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
550 return 0;
551 if (uL != 0)
552 return 0;
553
554 /* relative offset of the zip64 end of central directory record */
555 if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
556 return 0;
557
558 /* total number of disks */
559 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
560 return 0;
561 if (uL != 1)
562 return 0;
563
564 /* Goto end of central directory record */
565 if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
566 return 0;
567
568 /* the signature */
569 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
570 return 0;
571
572 if (uL != 0x06064b50)
573 return 0;
574
575 return relativeOffset;
576}

References ALLOC, BUFREADCOMMENT, TRYFREE, unz64local_getLong(), unz64local_getLong64(), UNZ_OK, ZLIB_FILEFUNC_SEEK_END, ZLIB_FILEFUNC_SEEK_SET, ZREAD64, ZSEEK64, and ZTELL64.

Referenced by unzOpenInternal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzClose()

int ZEXPORT unzClose ( unzFile file)
extern

Definition at line 811 of file unzip.c.

812{
813 unz64_s* s;
814 if (file==NULL)
815 return UNZ_PARAMERROR;
816 s=(unz64_s*)file;
817
818 if (s->pfile_in_zip_read!=NULL)
820
822 TRYFREE(s);
823 return UNZ_OK;
824}
#define ZCLOSE64(filefunc, filestream)
Definition ioapi.h:189
file_in_zip64_read_info_s * pfile_in_zip_read
Definition unzip.c:186
int ZEXPORT unzCloseCurrentFile(unzFile file)
Definition unzip.c:2016

References unz64_s::filestream, unz64_s::pfile_in_zip_read, TRYFREE, UNZ_OK, UNZ_PARAMERROR, unzCloseCurrentFile(), unz64_s::z_filefunc, and ZCLOSE64.

+ Here is the call graph for this function:

◆ unzCloseCurrentFile()

int ZEXPORT unzCloseCurrentFile ( unzFile file)
extern

Definition at line 2016 of file unzip.c.

2017{
2018 int err=UNZ_OK;
2019
2020 unz64_s* s;
2021 file_in_zip64_read_info_s* pfile_in_zip_read_info;
2022 if (file==NULL)
2023 return UNZ_PARAMERROR;
2024 s=(unz64_s*)file;
2025 pfile_in_zip_read_info=s->pfile_in_zip_read;
2026
2027 if (pfile_in_zip_read_info==NULL)
2028 return UNZ_PARAMERROR;
2029
2030
2031 if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
2032 (!pfile_in_zip_read_info->raw))
2033 {
2034 if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
2035 err=UNZ_CRCERROR;
2036 }
2037
2038
2039 TRYFREE(pfile_in_zip_read_info->read_buffer);
2040 pfile_in_zip_read_info->read_buffer = NULL;
2041 if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
2042 inflateEnd(&pfile_in_zip_read_info->stream);
2043#ifdef HAVE_BZIP2
2044 else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
2045 BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
2046#endif
2047
2048
2049 pfile_in_zip_read_info->stream_initialised = 0;
2050 TRYFREE(pfile_in_zip_read_info);
2051
2052 s->pfile_in_zip_read=NULL;
2053
2054 return err;
2055}
#define inflateEnd
Definition miniz.h:506
ZPOS64_T rest_read_uncompressed
Definition unzip.c:157
#define UNZ_CRCERROR
Definition unzip.h:81

References file_in_zip64_read_info_s::crc32, file_in_zip64_read_info_s::crc32_wait, inflateEnd, unz64_s::pfile_in_zip_read, file_in_zip64_read_info_s::raw, file_in_zip64_read_info_s::read_buffer, file_in_zip64_read_info_s::rest_read_uncompressed, file_in_zip64_read_info_s::stream, file_in_zip64_read_info_s::stream_initialised, TRYFREE, UNZ_CRCERROR, UNZ_OK, UNZ_PARAMERROR, Z_BZIP2ED, and Z_DEFLATED.

Referenced by unzClose(), and unzOpenCurrentFile3().

+ Here is the caller graph for this function:

◆ unzeof()

int ZEXPORT unzeof ( unzFile file)
extern

Definition at line 1936 of file unzip.c.

1937{
1938 unz64_s* s;
1939 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1940 if (file==NULL)
1941 return UNZ_PARAMERROR;
1942 s=(unz64_s*)file;
1943 pfile_in_zip_read_info=s->pfile_in_zip_read;
1944
1945 if (pfile_in_zip_read_info==NULL)
1946 return UNZ_PARAMERROR;
1947
1948 if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
1949 return 1;
1950 else
1951 return 0;
1952}

References unz64_s::pfile_in_zip_read, file_in_zip64_read_info_s::rest_read_uncompressed, and UNZ_PARAMERROR.

◆ unzGetCurrentFileInfo()

int ZEXPORT unzGetCurrentFileInfo ( unzFile file,
unz_file_info * pfile_info,
char * szFileName,
uLong fileNameBufferSize,
void * extraField,
uLong extraFieldBufferSize,
char * szComment,
uLong commentBufferSize )
extern

Definition at line 1142 of file unzip.c.

1147{
1148 int err;
1149 unz_file_info64 file_info64;
1150 err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
1151 szFileName,fileNameBufferSize,
1152 extraField,extraFieldBufferSize,
1153 szComment,commentBufferSize);
1154 if (err==UNZ_OK)
1155 {
1156 pfile_info->version = file_info64.version;
1157 pfile_info->version_needed = file_info64.version_needed;
1158 pfile_info->flag = file_info64.flag;
1159 pfile_info->compression_method = file_info64.compression_method;
1160 pfile_info->dosDate = file_info64.dosDate;
1161 pfile_info->crc = file_info64.crc;
1162
1163 pfile_info->size_filename = file_info64.size_filename;
1164 pfile_info->size_file_extra = file_info64.size_file_extra;
1165 pfile_info->size_file_comment = file_info64.size_file_comment;
1166
1167 pfile_info->disk_num_start = file_info64.disk_num_start;
1168 pfile_info->internal_fa = file_info64.internal_fa;
1169 pfile_info->external_fa = file_info64.external_fa;
1170
1171 pfile_info->tmu_date = file_info64.tmu_date;
1172
1173
1174 pfile_info->compressed_size = (uLong)file_info64.compressed_size;
1175 pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
1176
1177 }
1178 return err;
1179}
uLong dosDate
Definition unzip.h:138
uLong version_needed
Definition unzip.h:135
uLong compressed_size
Definition unzip.h:140
uLong size_file_extra
Definition unzip.h:143
uLong version
Definition unzip.h:134
uLong uncompressed_size
Definition unzip.h:141
uLong internal_fa
Definition unzip.h:147
uLong compression_method
Definition unzip.h:137
uLong disk_num_start
Definition unzip.h:146
tm_unz tmu_date
Definition unzip.h:150
uLong external_fa
Definition unzip.h:148
uLong size_filename
Definition unzip.h:142
uLong size_file_comment
Definition unzip.h:144
local 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)
Definition unzip.c:882

References unz_file_info64_s::compressed_size, unz_file_info_s::compressed_size, unz_file_info64_s::compression_method, unz_file_info_s::compression_method, unz_file_info64_s::crc, unz_file_info_s::crc, unz_file_info64_s::disk_num_start, unz_file_info_s::disk_num_start, unz_file_info64_s::dosDate, unz_file_info_s::dosDate, unz_file_info64_s::external_fa, unz_file_info_s::external_fa, unz_file_info64_s::flag, unz_file_info_s::flag, unz_file_info64_s::internal_fa, unz_file_info_s::internal_fa, unz_file_info64_s::size_file_comment, unz_file_info_s::size_file_comment, unz_file_info64_s::size_file_extra, unz_file_info_s::size_file_extra, unz_file_info64_s::size_filename, unz_file_info_s::size_filename, unz_file_info64_s::tmu_date, unz_file_info_s::tmu_date, unz_file_info64_s::uncompressed_size, unz_file_info_s::uncompressed_size, unz64local_GetCurrentFileInfoInternal(), UNZ_OK, unz_file_info64_s::version, unz_file_info_s::version, unz_file_info64_s::version_needed, and unz_file_info_s::version_needed.

+ Here is the call graph for this function:

◆ unzGetCurrentFileInfo64()

int ZEXPORT unzGetCurrentFileInfo64 ( unzFile file,
unz_file_info64 * pfile_info,
char * szFileName,
uLong fileNameBufferSize,
void * extraField,
uLong extraFieldBufferSize,
char * szComment,
uLong commentBufferSize )
extern

Definition at line 1130 of file unzip.c.

1135{
1136 return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
1137 szFileName,fileNameBufferSize,
1138 extraField,extraFieldBufferSize,
1139 szComment,commentBufferSize);
1140}

References unz64local_GetCurrentFileInfoInternal().

Referenced by unzLocateFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzGetCurrentFileZStreamPos64()

ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 ( unzFile file)
extern

Addition for GDAL : START

Definition at line 1670 of file unzip.c.

1671{
1672 unz64_s* s;
1673 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1674 s=(unz64_s*)file;
1675 if (file==NULL)
1676 return 0; //UNZ_PARAMERROR;
1677 pfile_in_zip_read_info=s->pfile_in_zip_read;
1678 if (pfile_in_zip_read_info==NULL)
1679 return 0; //UNZ_PARAMERROR;
1680 return pfile_in_zip_read_info->pos_in_zipfile +
1681 pfile_in_zip_read_info->byte_before_the_zipfile;
1682}
ZPOS64_T byte_before_the_zipfile
Definition unzip.c:161

References file_in_zip64_read_info_s::byte_before_the_zipfile, unz64_s::pfile_in_zip_read, and file_in_zip64_read_info_s::pos_in_zipfile.

◆ unzGetFilePos()

int ZEXPORT unzGetFilePos ( unzFile file,
unz_file_pos * file_pos )
extern

Definition at line 1330 of file unzip.c.

1333{
1334 unz64_file_pos file_pos64;
1335 int err = unzGetFilePos64(file,&file_pos64);
1336 if (err==UNZ_OK)
1337 {
1338 file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
1339 file_pos->num_of_file = (uLong)file_pos64.num_of_file;
1340 }
1341 return err;
1342}
ZPOS64_T num_of_file
Definition unzip.h:275
ZPOS64_T pos_in_zip_directory
Definition unzip.h:274
uLong num_of_file
Definition unzip.h:261
uLong pos_in_zip_directory
Definition unzip.h:260
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
Definition unzip.c:1314

References unz64_file_pos_s::num_of_file, unz_file_pos_s::num_of_file, unz64_file_pos_s::pos_in_zip_directory, unz_file_pos_s::pos_in_zip_directory, UNZ_OK, and unzGetFilePos64().

+ Here is the call graph for this function:

◆ unzGetFilePos64()

int ZEXPORT unzGetFilePos64 ( unzFile file,
unz64_file_pos * file_pos )
extern

Definition at line 1314 of file unzip.c.

1315{
1316 unz64_s* s;
1317
1318 if (file==NULL || file_pos==NULL)
1319 return UNZ_PARAMERROR;
1320 s=(unz64_s*)file;
1321 if (!s->current_file_ok)
1323
1325 file_pos->num_of_file = s->num_file;
1326
1327 return UNZ_OK;
1328}
ZPOS64_T current_file_ok
Definition unzip.c:177
ZPOS64_T num_file
Definition unzip.c:175
#define UNZ_END_OF_LIST_OF_FILE
Definition unzip.h:75

References unz64_s::current_file_ok, unz64_s::num_file, unz64_file_pos_s::num_of_file, unz64_s::pos_in_central_dir, unz64_file_pos_s::pos_in_zip_directory, UNZ_END_OF_LIST_OF_FILE, UNZ_OK, and UNZ_PARAMERROR.

Referenced by unzGetFilePos().

+ Here is the caller graph for this function:

◆ unzGetGlobalComment()

int ZEXPORT unzGetGlobalComment ( unzFile file,
char * szComment,
uLong uSizeBuf )
extern

Definition at line 2063 of file unzip.c.

2064{
2065 unz64_s* s;
2066 uLong uReadThis ;
2067 if (file==NULL)
2068 return (int)UNZ_PARAMERROR;
2069 s=(unz64_s*)file;
2070
2071 uReadThis = uSizeBuf;
2072 if (uReadThis>s->gi.size_comment)
2073 uReadThis = s->gi.size_comment;
2074
2076 return UNZ_ERRNO;
2077
2078 if (uReadThis>0)
2079 {
2080 *szComment='\0';
2081 if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
2082 return UNZ_ERRNO;
2083 }
2084
2085 if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
2086 *(szComment+s->gi.size_comment)='\0';
2087 return (int)uReadThis;
2088}
unz_global_info64 gi
Definition unzip.c:173
ZPOS64_T central_pos
Definition unzip.c:178

References unz64_s::central_pos, unz64_s::filestream, unz64_s::gi, unz_global_info64_s::size_comment, UNZ_ERRNO, UNZ_PARAMERROR, unz64_s::z_filefunc, ZLIB_FILEFUNC_SEEK_SET, ZREAD64, and ZSEEK64.

◆ unzGetGlobalInfo()

int ZEXPORT unzGetGlobalInfo ( unzFile file,
unz_global_info * pglobal_info32 )
extern

Definition at line 841 of file unzip.c.

842{
843 unz64_s* s;
844 if (file==NULL)
845 return UNZ_PARAMERROR;
846 s=(unz64_s*)file;
847 /* to do : check if number_entry is not truncated */
848 pglobal_info32->number_entry = (uLong)s->gi.number_entry;
849 pglobal_info32->size_comment = s->gi.size_comment;
850 return UNZ_OK;
851}
ZPOS64_T number_entry
Definition unzip.h:98
uLong size_comment
Definition unzip.h:107
uLong number_entry
Definition unzip.h:105

References unz64_s::gi, unz_global_info64_s::number_entry, unz_global_info_s::number_entry, unz_global_info64_s::size_comment, unz_global_info_s::size_comment, UNZ_OK, and UNZ_PARAMERROR.

◆ unzGetGlobalInfo64()

int ZEXPORT unzGetGlobalInfo64 ( unzFile file,
unz_global_info64 * pglobal_info )
extern

Definition at line 831 of file unzip.c.

832{
833 unz64_s* s;
834 if (file==NULL)
835 return UNZ_PARAMERROR;
836 s=(unz64_s*)file;
837 *pglobal_info=s->gi;
838 return UNZ_OK;
839}

References unz64_s::gi, UNZ_OK, and UNZ_PARAMERROR.

◆ unzGetLocalExtrafield()

int ZEXPORT unzGetLocalExtrafield ( unzFile file,
voidp buf,
unsigned len )
extern

Definition at line 1968 of file unzip.c.

1969{
1970 unz64_s* s;
1971 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1972 uInt read_now;
1973 ZPOS64_T size_to_read;
1974
1975 if (file==NULL)
1976 return UNZ_PARAMERROR;
1977 s=(unz64_s*)file;
1978 pfile_in_zip_read_info=s->pfile_in_zip_read;
1979
1980 if (pfile_in_zip_read_info==NULL)
1981 return UNZ_PARAMERROR;
1982
1983 size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
1984 pfile_in_zip_read_info->pos_local_extrafield);
1985
1986 if (buf==NULL)
1987 return (int)size_to_read;
1988
1989 if (len>size_to_read)
1990 read_now = (uInt)size_to_read;
1991 else
1992 read_now = (uInt)len ;
1993
1994 if (read_now==0)
1995 return 0;
1996
1997 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
1998 pfile_in_zip_read_info->filestream,
1999 pfile_in_zip_read_info->offset_local_extrafield +
2000 pfile_in_zip_read_info->pos_local_extrafield,
2002 return UNZ_ERRNO;
2003
2004 if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
2005 pfile_in_zip_read_info->filestream,
2006 buf,read_now)!=read_now)
2007 return UNZ_ERRNO;
2008
2009 return (int)read_now;
2010}
ZPOS64_T offset_local_extrafield
Definition unzip.c:149
zlib_filefunc64_32_def z_filefunc
Definition unzip.c:158
ZPOS64_T pos_local_extrafield
Definition unzip.c:151

References file_in_zip64_read_info_s::filestream, file_in_zip64_read_info_s::offset_local_extrafield, unz64_s::pfile_in_zip_read, file_in_zip64_read_info_s::pos_local_extrafield, file_in_zip64_read_info_s::size_local_extrafield, UNZ_ERRNO, UNZ_PARAMERROR, file_in_zip64_read_info_s::z_filefunc, ZLIB_FILEFUNC_SEEK_SET, ZREAD64, and ZSEEK64.

◆ unzGetOffset()

uLong ZEXPORT unzGetOffset ( unzFile file)
extern

Definition at line 2106 of file unzip.c.

2107{
2108 ZPOS64_T offset64;
2109
2110 if (file==NULL)
2111 return 0; //UNZ_PARAMERROR;
2112 offset64 = unzGetOffset64(file);
2113 return (uLong)offset64;
2114}
ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
Definition unzip.c:2091

References unzGetOffset64().

+ Here is the call graph for this function:

◆ unzGetOffset64()

ZPOS64_T ZEXPORT unzGetOffset64 ( unzFile file)
extern

Definition at line 2091 of file unzip.c.

2092{
2093 unz64_s* s;
2094
2095 if (file==NULL)
2096 return 0; //UNZ_PARAMERROR;
2097 s=(unz64_s*)file;
2098 if (!s->current_file_ok)
2099 return 0;
2100 if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
2101 if (s->num_file==s->gi.number_entry)
2102 return 0;
2103 return s->pos_in_central_dir;
2104}

References unz64_s::current_file_ok, unz64_s::gi, unz64_s::num_file, unz_global_info64_s::number_entry, and unz64_s::pos_in_central_dir.

Referenced by unzGetOffset().

+ Here is the caller graph for this function:

◆ unzGoToFilePos()

int ZEXPORT unzGoToFilePos ( unzFile file,
unz_file_pos * file_pos )
extern

Definition at line 1366 of file unzip.c.

1369{
1370 unz64_file_pos file_pos64;
1371 if (file_pos == NULL)
1372 return UNZ_PARAMERROR;
1373
1374 file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
1375 file_pos64.num_of_file = file_pos->num_of_file;
1376 return unzGoToFilePos64(file,&file_pos64);
1377}
int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos)
Definition unzip.c:1344

References unz64_file_pos_s::num_of_file, unz_file_pos_s::num_of_file, unz64_file_pos_s::pos_in_zip_directory, unz_file_pos_s::pos_in_zip_directory, UNZ_PARAMERROR, and unzGoToFilePos64().

+ Here is the call graph for this function:

◆ unzGoToFilePos64()

int ZEXPORT unzGoToFilePos64 ( unzFile file,
const unz64_file_pos * file_pos )
extern

Definition at line 1344 of file unzip.c.

1345{
1346 unz64_s* s;
1347 int err;
1348
1349 if (file==NULL || file_pos==NULL)
1350 return UNZ_PARAMERROR;
1351 s=(unz64_s*)file;
1352
1353 /* jump to the right spot */
1355 s->num_file = file_pos->num_of_file;
1356
1357 /* set the current file */
1360 NULL,0,NULL,0,NULL,0);
1361 /* return results */
1362 s->current_file_ok = (err == UNZ_OK);
1363 return err;
1364}

References unz64_s::cur_file_info, unz64_s::cur_file_info_internal, unz64_s::current_file_ok, unz64_s::num_file, unz64_file_pos_s::num_of_file, unz64_s::pos_in_central_dir, unz64_file_pos_s::pos_in_zip_directory, unz64local_GetCurrentFileInfoInternal(), UNZ_OK, and UNZ_PARAMERROR.

Referenced by unzGoToFilePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzGoToFirstFile()

int ZEXPORT unzGoToFirstFile ( unzFile file)
extern

Definition at line 1184 of file unzip.c.

1185{
1186 int err=UNZ_OK;
1187 unz64_s* s;
1188 if (file==NULL)
1189 return UNZ_PARAMERROR;
1190 s=(unz64_s*)file;
1192 s->num_file=0;
1195 NULL,0,NULL,0,NULL,0);
1196 s->current_file_ok = (err == UNZ_OK);
1197 return err;
1198}
ZPOS64_T offset_central_dir
Definition unzip.c:181

References unz64_s::cur_file_info, unz64_s::cur_file_info_internal, unz64_s::current_file_ok, unz64_s::num_file, unz64_s::offset_central_dir, unz64_s::pos_in_central_dir, unz64local_GetCurrentFileInfoInternal(), UNZ_OK, and UNZ_PARAMERROR.

Referenced by unzLocateFile(), and unzOpenInternal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzGoToNextFile()

int ZEXPORT unzGoToNextFile ( unzFile file)
extern

Definition at line 1205 of file unzip.c.

1206{
1207 unz64_s* s;
1208 int err;
1209
1210 if (file==NULL)
1211 return UNZ_PARAMERROR;
1212 s=(unz64_s*)file;
1213 if (!s->current_file_ok)
1215 if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
1216 if (s->num_file+1==s->gi.number_entry)
1218
1221 s->num_file++;
1224 NULL,0,NULL,0,NULL,0);
1225 s->current_file_ok = (err == UNZ_OK);
1226 return err;
1227}
#define SIZECENTRALDIRITEM
Definition unzip.c:118

References unz64_s::cur_file_info, unz64_s::cur_file_info_internal, unz64_s::current_file_ok, unz64_s::gi, unz64_s::num_file, unz_global_info64_s::number_entry, unz64_s::pos_in_central_dir, unz_file_info64_s::size_file_comment, unz_file_info64_s::size_file_extra, unz_file_info64_s::size_filename, SIZECENTRALDIRITEM, unz64local_GetCurrentFileInfoInternal(), UNZ_END_OF_LIST_OF_FILE, UNZ_OK, and UNZ_PARAMERROR.

Referenced by unzLocateFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzLocateFile()

int ZEXPORT unzLocateFile ( unzFile file,
const char * szFileName,
int iCaseSensitivity )
extern

Definition at line 1238 of file unzip.c.

1239{
1240 unz64_s* s;
1241 int err;
1242
1243 /* We remember the 'current' position in the file so that we can jump
1244 * back there if we fail.
1245 */
1246 unz_file_info64 cur_file_infoSaved;
1247 unz_file_info64_internal cur_file_info_internalSaved;
1248 ZPOS64_T num_fileSaved;
1249 ZPOS64_T pos_in_central_dirSaved;
1250
1251
1252 if (file==NULL)
1253 return UNZ_PARAMERROR;
1254
1255 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
1256 return UNZ_PARAMERROR;
1257
1258 s=(unz64_s*)file;
1259 if (!s->current_file_ok)
1261
1262 /* Save the current state */
1263 num_fileSaved = s->num_file;
1264 pos_in_central_dirSaved = s->pos_in_central_dir;
1265 cur_file_infoSaved = s->cur_file_info;
1266 cur_file_info_internalSaved = s->cur_file_info_internal;
1267
1268 err = unzGoToFirstFile(file);
1269
1270 while (err == UNZ_OK)
1271 {
1272 char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
1273 err = unzGetCurrentFileInfo64(file,NULL,
1274 szCurrentFileName,sizeof(szCurrentFileName)-1,
1275 NULL,0,NULL,0);
1276 if (err == UNZ_OK)
1277 {
1278 if (unzStringFileNameCompare(szCurrentFileName,
1279 szFileName,iCaseSensitivity)==0)
1280 return UNZ_OK;
1281 err = unzGoToNextFile(file);
1282 }
1283 }
1284
1285 /* We failed, so restore the state of the 'current file' to where we
1286 * were.
1287 */
1288 s->num_file = num_fileSaved ;
1289 s->pos_in_central_dir = pos_in_central_dirSaved ;
1290 s->cur_file_info = cur_file_infoSaved;
1291 s->cur_file_info_internal = cur_file_info_internalSaved;
1292 return err;
1293}
int ZEXPORT unzStringFileNameCompare(const char *fileName1, const char *fileName2, int iCaseSensitivity)
Definition unzip.c:393
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
Definition unzip.c:1130
int ZEXPORT unzGoToFirstFile(unzFile file)
Definition unzip.c:1184
#define UNZ_MAXFILENAMEINZIP
Definition unzip.c:108
int ZEXPORT unzGoToNextFile(unzFile file)
Definition unzip.c:1205

References unz64_s::cur_file_info, unz64_s::cur_file_info_internal, unz64_s::current_file_ok, unz64_s::num_file, unz64_s::pos_in_central_dir, UNZ_END_OF_LIST_OF_FILE, UNZ_MAXFILENAMEINZIP, UNZ_OK, UNZ_PARAMERROR, unzGetCurrentFileInfo64(), unzGoToFirstFile(), unzGoToNextFile(), and unzStringFileNameCompare().

+ Here is the call graph for this function:

◆ unzOpen()

unzFile ZEXPORT unzOpen ( const char * path)
extern

Definition at line 796 of file unzip.c.

797{
798 return unzOpenInternal(path, NULL, 0);
799}
local unzFile unzOpenInternal(const void *path, zlib_filefunc64_32_def *pzlib_filefunc64_32_def, int is64bitOpenFunction)
Definition unzip.c:587

References unzOpenInternal().

+ Here is the call graph for this function:

◆ unzOpen2()

unzFile ZEXPORT unzOpen2 ( const char * path,
zlib_filefunc_def * pzlib_filefunc32_def )
extern

Definition at line 768 of file unzip.c.

770{
771 if (pzlib_filefunc32_def != NULL)
772 {
773 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
774 fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
775 return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
776 }
777 else
778 return unzOpenInternal(path, NULL, 0);
779}
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
Definition ioapi.c:64

References fill_zlib_filefunc64_32_def_from_filefunc32(), and unzOpenInternal().

+ Here is the call graph for this function:

◆ unzOpen2_64()

unzFile ZEXPORT unzOpen2_64 ( const void * path,
zlib_filefunc64_def * pzlib_filefunc_def )
extern

Definition at line 781 of file unzip.c.

783{
784 if (pzlib_filefunc_def != NULL)
785 {
786 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
787 zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
788 zlib_filefunc64_32_def_fill.ztell32_file = NULL;
789 zlib_filefunc64_32_def_fill.zseek32_file = NULL;
790 return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
791 }
792 else
793 return unzOpenInternal(path, NULL, 1);
794}
seek_file_func zseek32_file
Definition ioapi.h:181
zlib_filefunc64_def zfile_func64
Definition ioapi.h:178
tell_file_func ztell32_file
Definition ioapi.h:180

References unzOpenInternal(), zlib_filefunc64_32_def_s::zfile_func64, zlib_filefunc64_32_def_s::zseek32_file, and zlib_filefunc64_32_def_s::ztell32_file.

+ Here is the call graph for this function:

◆ unzOpen64()

unzFile ZEXPORT unzOpen64 ( const void * path)
extern

Definition at line 801 of file unzip.c.

802{
803 return unzOpenInternal(path, NULL, 1);
804}

References unzOpenInternal().

+ Here is the call graph for this function:

◆ unzOpenCurrentFile()

int ZEXPORT unzOpenCurrentFile ( unzFile file)
extern

Definition at line 1653 of file unzip.c.

1654{
1655 return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
1656}
int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password)
Definition unzip.c:1478

References unzOpenCurrentFile3().

+ Here is the call graph for this function:

◆ unzOpenCurrentFile2()

int ZEXPORT unzOpenCurrentFile2 ( unzFile file,
int * method,
int * level,
int raw )
extern

Definition at line 1663 of file unzip.c.

1664{
1665 return unzOpenCurrentFile3(file, method, level, raw, NULL);
1666}

References unzOpenCurrentFile3().

+ Here is the call graph for this function:

◆ unzOpenCurrentFile3()

int ZEXPORT unzOpenCurrentFile3 ( unzFile file,
int * method,
int * level,
int raw,
const char * password )
extern

Definition at line 1478 of file unzip.c.

1480{
1481 int err=UNZ_OK;
1482 uInt iSizeVar;
1483 unz64_s* s;
1484 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1485 ZPOS64_T offset_local_extrafield; /* offset of the local extra field */
1486 uInt size_local_extrafield; /* size of the local extra field */
1487# ifndef NOUNCRYPT
1488 char source[12];
1489# else
1490 if (password != NULL)
1491 return UNZ_PARAMERROR;
1492# endif
1493
1494 if (file==NULL)
1495 return UNZ_PARAMERROR;
1496 s=(unz64_s*)file;
1497 if (!s->current_file_ok)
1498 return UNZ_PARAMERROR;
1499
1500 if (s->pfile_in_zip_read != NULL)
1501 unzCloseCurrentFile(file);
1502
1503 if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
1504 return UNZ_BADZIPFILE;
1505
1506 pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
1507 if (pfile_in_zip_read_info==NULL)
1508 return UNZ_INTERNALERROR;
1509
1510 pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
1511 pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
1512 pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
1513 pfile_in_zip_read_info->pos_local_extrafield=0;
1514 pfile_in_zip_read_info->raw=raw;
1515
1516 if (pfile_in_zip_read_info->read_buffer==NULL)
1517 {
1518 TRYFREE(pfile_in_zip_read_info);
1519 return UNZ_INTERNALERROR;
1520 }
1521
1522 pfile_in_zip_read_info->stream_initialised=0;
1523
1524 if (method!=NULL)
1525 *method = (int)s->cur_file_info.compression_method;
1526
1527 if (level!=NULL)
1528 {
1529 *level = 6;
1530 switch (s->cur_file_info.flag & 0x06)
1531 {
1532 case 6 : *level = 1; break;
1533 case 4 : *level = 2; break;
1534 case 2 : *level = 9; break;
1535 }
1536 }
1537
1538 if ((s->cur_file_info.compression_method!=0) &&
1539/* #ifdef HAVE_BZIP2 */
1541/* #endif */
1543 {
1544 err=UNZ_BADZIPFILE;
1545 /* Compiler notes that 'err' is never actually used here after
1546 * being set. Guessing from the below uses that it's supposed
1547 * to free the struct and then return the error. - CIM */
1548 TRYFREE(pfile_in_zip_read_info);
1549 return err;
1550 }
1551
1552 pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
1553 pfile_in_zip_read_info->crc32=0;
1554 pfile_in_zip_read_info->total_out_64=0;
1555 pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
1556 pfile_in_zip_read_info->filestream=s->filestream;
1557 pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
1558 pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
1559
1560 pfile_in_zip_read_info->stream.total_out = 0;
1561
1562 if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
1563 {
1564#ifdef HAVE_BZIP2
1565 pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
1566 pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
1567 pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
1568 pfile_in_zip_read_info->bstream.state = (voidpf)0;
1569
1570 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1571 pfile_in_zip_read_info->stream.zfree = (free_func)0;
1572 pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1573 pfile_in_zip_read_info->stream.next_in = (voidpf)0;
1574 pfile_in_zip_read_info->stream.avail_in = 0;
1575
1576 err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
1577 if (err == Z_OK)
1578 pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
1579 else
1580 {
1581 TRYFREE(pfile_in_zip_read_info);
1582 return err;
1583 }
1584#else
1585 pfile_in_zip_read_info->raw=1;
1586#endif
1587 }
1588 else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
1589 {
1590 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1591 pfile_in_zip_read_info->stream.zfree = (free_func)0;
1592 pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1593 pfile_in_zip_read_info->stream.next_in = 0;
1594 pfile_in_zip_read_info->stream.avail_in = 0;
1595
1596 err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
1597 if (err == Z_OK)
1598 pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
1599 else
1600 {
1601 TRYFREE(pfile_in_zip_read_info);
1602 return err;
1603 }
1604 /* windowBits is passed < 0 to tell that there is no zlib header.
1605 * Note that in this case inflate *requires* an extra "dummy" byte
1606 * after the compressed stream in order to complete decompression and
1607 * return Z_STREAM_END.
1608 * In unzip, i don't wait absolutely Z_STREAM_END because I known the
1609 * size of both compressed and uncompressed data
1610 */
1611 }
1612 pfile_in_zip_read_info->rest_read_compressed =
1614 pfile_in_zip_read_info->rest_read_uncompressed =
1616
1617
1618 pfile_in_zip_read_info->pos_in_zipfile =
1620 iSizeVar;
1621
1622 pfile_in_zip_read_info->stream.avail_in = (uInt)0;
1623
1624 s->pfile_in_zip_read = pfile_in_zip_read_info;
1625 s->encrypted = 0;
1626
1627# ifndef NOUNCRYPT
1628 if (password != NULL)
1629 {
1630 int i;
1631 s->pcrc_32_tab = get_crc_table();
1632 init_keys(password,s->keys,s->pcrc_32_tab);
1633 if (ZSEEK64(s->z_filefunc, s->filestream,
1636 SEEK_SET)!=0)
1637 return UNZ_INTERNALERROR;
1638 if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
1639 return UNZ_INTERNALERROR;
1640
1641 for (i = 0; i<12; i++)
1642 zdecode(s->keys,s->pcrc_32_tab,source[i]);
1643
1645 s->encrypted=1;
1646 }
1647# endif
1648
1649
1650 return UNZ_OK;
1651}
#define alloc_func
Definition miniz.h:484
void * voidpf
Definition miniz.h:452
#define Z_OK
Definition miniz.h:463
#define inflateInit2
Definition miniz.h:503
#define MAX_WBITS
Definition miniz.h:513
#define free_func
Definition miniz.h:485
ZPOS64_T rest_read_compressed
Definition unzip.c:156
int encrypted
Definition unzip.c:188
local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s *s, uInt *piSizeVar, ZPOS64_T *poffset_local_extrafield, uInt *psize_local_extrafield)
Definition unzip.c:1391
#define UNZ_BUFSIZE
Definition unzip.c:104
#define UNZ_INTERNALERROR
Definition unzip.h:80

References ALLOC, alloc_func, file_in_zip64_read_info_s::byte_before_the_zipfile, unz64_s::byte_before_the_zipfile, unz_file_info64_s::compressed_size, file_in_zip64_read_info_s::compression_method, unz_file_info64_s::compression_method, unz_file_info64_s::crc, file_in_zip64_read_info_s::crc32, file_in_zip64_read_info_s::crc32_wait, unz64_s::cur_file_info, unz64_s::cur_file_info_internal, unz64_s::current_file_ok, unz64_s::encrypted, file_in_zip64_read_info_s::filestream, unz64_s::filestream, unz_file_info64_s::flag, free_func, inflateInit2, int(), MAX_WBITS, unz_file_info64_internal_s::offset_curfile, file_in_zip64_read_info_s::offset_local_extrafield, unz64_s::pfile_in_zip_read, file_in_zip64_read_info_s::pos_in_zipfile, file_in_zip64_read_info_s::pos_local_extrafield, file_in_zip64_read_info_s::raw, file_in_zip64_read_info_s::read_buffer, file_in_zip64_read_info_s::rest_read_compressed, file_in_zip64_read_info_s::rest_read_uncompressed, file_in_zip64_read_info_s::size_local_extrafield, SIZEZIPLOCALHEADER, file_in_zip64_read_info_s::stream, file_in_zip64_read_info_s::stream_initialised, file_in_zip64_read_info_s::total_out_64, TRYFREE, unz_file_info64_s::uncompressed_size, unz64local_CheckCurrentFileCoherencyHeader(), UNZ_BADZIPFILE, UNZ_BUFSIZE, UNZ_INTERNALERROR, UNZ_OK, UNZ_PARAMERROR, unzCloseCurrentFile(), Z_BZIP2ED, Z_DEFLATED, file_in_zip64_read_info_s::z_filefunc, unz64_s::z_filefunc, Z_OK, ZREAD64, and ZSEEK64.

Referenced by unzOpenCurrentFile(), unzOpenCurrentFile2(), and unzOpenCurrentFilePassword().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzOpenCurrentFilePassword()

int ZEXPORT unzOpenCurrentFilePassword ( unzFile file,
const char * password )
extern

Definition at line 1658 of file unzip.c.

1659{
1660 return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
1661}

References unzOpenCurrentFile3().

+ Here is the call graph for this function:

◆ unzOpenInternal()

local unzFile unzOpenInternal ( const void * path,
zlib_filefunc64_32_def * pzlib_filefunc64_32_def,
int is64bitOpenFunction )

Definition at line 587 of file unzip.c.

590{
591 unz64_s us;
592 unz64_s *s;
593 ZPOS64_T central_pos;
594 uLong uL;
595
596 uLong number_disk; /* number of the current dist, used for
597 spaning ZIP, unsupported, always 0*/
598 uLong number_disk_with_CD; /* number the the disk with central dir, used
599 for spaning ZIP, unsupported, always 0*/
600 ZPOS64_T number_entry_CD; /* total number of entries in
601 the central dir
602 (same than number_entry on nospan) */
603
604 int err=UNZ_OK;
605
606 if (unz_copyright[0]!=' ')
607 return NULL;
608
609 us.z_filefunc.zseek32_file = NULL;
610 us.z_filefunc.ztell32_file = NULL;
611 if (pzlib_filefunc64_32_def==NULL)
613 else
614 us.z_filefunc = *pzlib_filefunc64_32_def;
615 us.is64bitOpenFunction = is64bitOpenFunction;
616
617
618
620 path,
623 if (us.filestream==NULL)
624 return NULL;
625
627 if (central_pos)
628 {
629 uLong uS;
630 ZPOS64_T uL64;
631
632 us.isZip64 = 1;
633
634 if (ZSEEK64(us.z_filefunc, us.filestream,
635 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
636 err=UNZ_ERRNO;
637
638 /* the signature, already checked */
640 err=UNZ_ERRNO;
641
642 /* size of zip64 end of central directory record */
644 err=UNZ_ERRNO;
645
646 /* version made by */
648 err=UNZ_ERRNO;
649
650 /* version needed to extract */
652 err=UNZ_ERRNO;
653
654 /* number of this disk */
655 if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
656 err=UNZ_ERRNO;
657
658 /* number of the disk with the start of the central directory */
659 if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
660 err=UNZ_ERRNO;
661
662 /* total number of entries in the central directory on this disk */
664 err=UNZ_ERRNO;
665
666 /* total number of entries in the central directory */
667 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
668 err=UNZ_ERRNO;
669
670 if ((number_entry_CD!=us.gi.number_entry) ||
671 (number_disk_with_CD!=0) ||
672 (number_disk!=0))
673 err=UNZ_BADZIPFILE;
674
675 /* size of the central directory */
677 err=UNZ_ERRNO;
678
679 /* offset of start of central directory with respect to the
680 starting disk number */
682 err=UNZ_ERRNO;
683
684 us.gi.size_comment = 0;
685 }
686 else
687 {
689 if (central_pos==0)
690 err=UNZ_ERRNO;
691
692 us.isZip64 = 0;
693
694 if (ZSEEK64(us.z_filefunc, us.filestream,
695 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
696 err=UNZ_ERRNO;
697
698 /* the signature, already checked */
700 err=UNZ_ERRNO;
701
702 /* number of this disk */
703 if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
704 err=UNZ_ERRNO;
705
706 /* number of the disk with the start of the central directory */
707 if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
708 err=UNZ_ERRNO;
709
710 /* total number of entries in the central dir on this disk */
712 err=UNZ_ERRNO;
713 us.gi.number_entry = uL;
714
715 /* total number of entries in the central dir */
717 err=UNZ_ERRNO;
718 number_entry_CD = uL;
719
720 if ((number_entry_CD!=us.gi.number_entry) ||
721 (number_disk_with_CD!=0) ||
722 (number_disk!=0))
723 err=UNZ_BADZIPFILE;
724
725 /* size of the central directory */
727 err=UNZ_ERRNO;
728 us.size_central_dir = uL;
729
730 /* offset of start of central directory with respect to the
731 starting disk number */
733 err=UNZ_ERRNO;
734 us.offset_central_dir = uL;
735
736 /* zipfile comment length */
738 err=UNZ_ERRNO;
739 }
740
741 if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
742 (err==UNZ_OK))
743 err=UNZ_BADZIPFILE;
744
745 if (err!=UNZ_OK)
746 {
748 return NULL;
749 }
750
751 us.byte_before_the_zipfile = central_pos -
753 us.central_pos = central_pos;
754 us.pfile_in_zip_read = NULL;
755 us.encrypted = 0;
756
757
758 s=(unz64_s*)ALLOC(sizeof(unz64_s));
759 if( s != NULL)
760 {
761 *s=us;
763 }
764 return (unzFile)s;
765}
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
Definition ioapi.c:232
#define ZLIB_FILEFUNC_MODE_EXISTING
Definition ioapi.h:118
#define ZOPEN64(filefunc, filename, mode)
Definition ioapi.h:198
#define ZLIB_FILEFUNC_MODE_READ
Definition ioapi.h:114
int is64bitOpenFunction
Definition unzip.c:171
ZPOS64_T size_central_dir
Definition unzip.c:180
int isZip64
Definition unzip.c:190
local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
Definition unzip.c:481
local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
Definition unzip.c:416
static const char unz_copyright[]
Definition unzip.c:125
voidp unzFile
Definition unzip.h:70

References ALLOC, unz64_s::byte_before_the_zipfile, unz64_s::central_pos, unz64_s::encrypted, unz64_s::filestream, fill_fopen64_filefunc(), unz64_s::gi, unz64_s::is64bitOpenFunction, unz64_s::isZip64, unz_global_info64_s::number_entry, unz64_s::offset_central_dir, unz64_s::pfile_in_zip_read, unz64_s::size_central_dir, unz_global_info64_s::size_comment, unz64local_getLong(), unz64local_getLong64(), unz64local_getShort(), unz64local_SearchCentralDir(), unz64local_SearchCentralDir64(), UNZ_BADZIPFILE, unz_copyright, UNZ_ERRNO, UNZ_OK, unzGoToFirstFile(), unz64_s::z_filefunc, ZCLOSE64, zlib_filefunc64_32_def_s::zfile_func64, ZLIB_FILEFUNC_MODE_EXISTING, ZLIB_FILEFUNC_MODE_READ, ZLIB_FILEFUNC_SEEK_SET, ZOPEN64, zlib_filefunc64_32_def_s::zseek32_file, ZSEEK64, and zlib_filefunc64_32_def_s::ztell32_file.

Referenced by unzOpen(), unzOpen2(), unzOpen2_64(), and unzOpen64().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzReadCurrentFile()

int ZEXPORT unzReadCurrentFile ( unzFile file,
voidp buf,
unsigned len )
extern

Addition for GDAL : END

Definition at line 1696 of file unzip.c.

1697{
1698 int err=UNZ_OK;
1699 uInt iRead = 0;
1700 unz64_s* s;
1701 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1702 if (file==NULL)
1703 return UNZ_PARAMERROR;
1704 s=(unz64_s*)file;
1705 pfile_in_zip_read_info=s->pfile_in_zip_read;
1706
1707 if (pfile_in_zip_read_info==NULL)
1708 return UNZ_PARAMERROR;
1709
1710
1711 if (pfile_in_zip_read_info->read_buffer == NULL)
1713 if (len==0)
1714 return 0;
1715
1716 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1717
1718 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1719
1720 if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
1721 (!(pfile_in_zip_read_info->raw)))
1722 pfile_in_zip_read_info->stream.avail_out =
1723 (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1724
1725 if ((len>pfile_in_zip_read_info->rest_read_compressed+
1726 pfile_in_zip_read_info->stream.avail_in) &&
1727 (pfile_in_zip_read_info->raw))
1728 pfile_in_zip_read_info->stream.avail_out =
1729 (uInt)pfile_in_zip_read_info->rest_read_compressed+
1730 pfile_in_zip_read_info->stream.avail_in;
1731
1732 while (pfile_in_zip_read_info->stream.avail_out>0)
1733 {
1734 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1735 (pfile_in_zip_read_info->rest_read_compressed>0))
1736 {
1737 uInt uReadThis = UNZ_BUFSIZE;
1738 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
1739 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
1740 if (uReadThis == 0)
1741 return UNZ_EOF;
1742 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
1743 pfile_in_zip_read_info->filestream,
1744 pfile_in_zip_read_info->pos_in_zipfile +
1745 pfile_in_zip_read_info->byte_before_the_zipfile,
1747 return UNZ_ERRNO;
1748 if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
1749 pfile_in_zip_read_info->filestream,
1750 pfile_in_zip_read_info->read_buffer,
1751 uReadThis)!=uReadThis)
1752 return UNZ_ERRNO;
1753
1754
1755# ifndef NOUNCRYPT
1756 if(s->encrypted)
1757 {
1758 uInt i;
1759 for(i=0;i<uReadThis;i++)
1760 pfile_in_zip_read_info->read_buffer[i] =
1761 zdecode(s->keys,s->pcrc_32_tab,
1762 pfile_in_zip_read_info->read_buffer[i]);
1763 }
1764# endif
1765
1766
1767 pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
1768
1769 pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
1770
1771 pfile_in_zip_read_info->stream.next_in =
1772 (Bytef*)pfile_in_zip_read_info->read_buffer;
1773 pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
1774 }
1775
1776 if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
1777 {
1778 uInt uDoCopy,i ;
1779
1780 if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
1781 (pfile_in_zip_read_info->rest_read_compressed == 0))
1782 return (iRead==0) ? UNZ_EOF : iRead;
1783
1784 if (pfile_in_zip_read_info->stream.avail_out <
1785 pfile_in_zip_read_info->stream.avail_in)
1786 uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
1787 else
1788 uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
1789
1790 for (i=0;i<uDoCopy;i++)
1791 *(pfile_in_zip_read_info->stream.next_out+i) =
1792 *(pfile_in_zip_read_info->stream.next_in+i);
1793
1794 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
1795
1796 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
1797 pfile_in_zip_read_info->stream.next_out,
1798 uDoCopy);
1799 pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
1800 pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
1801 pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
1802 pfile_in_zip_read_info->stream.next_out += uDoCopy;
1803 pfile_in_zip_read_info->stream.next_in += uDoCopy;
1804 pfile_in_zip_read_info->stream.total_out += uDoCopy;
1805 iRead += uDoCopy;
1806 }
1807 else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
1808 {
1809#ifdef HAVE_BZIP2
1810 uLong uTotalOutBefore,uTotalOutAfter;
1811 const Bytef *bufBefore;
1812 uLong uOutThis;
1813
1814 pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in;
1815 pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in;
1816 pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in;
1817 pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
1818 pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out;
1819 pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out;
1820 pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
1821 pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
1822
1823 uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
1824 bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
1825
1826 err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
1827
1828 uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
1829 uOutThis = uTotalOutAfter-uTotalOutBefore;
1830
1831 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
1832
1833 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
1834 pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
1835 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1836
1837 pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
1838 pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in;
1839 pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
1840 pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
1841 pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
1842 pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
1843
1844 if (err==BZ_STREAM_END)
1845 return (iRead==0) ? UNZ_EOF : iRead;
1846 if (err!=BZ_OK)
1847 break;
1848#endif
1849 } // end Z_BZIP2ED
1850 else
1851 {
1852 ZPOS64_T uTotalOutBefore,uTotalOutAfter;
1853 const Bytef *bufBefore;
1854 ZPOS64_T uOutThis;
1855 int flush=Z_SYNC_FLUSH;
1856
1857 uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
1858 bufBefore = pfile_in_zip_read_info->stream.next_out;
1859
1860 /*
1861 if ((pfile_in_zip_read_info->rest_read_uncompressed ==
1862 pfile_in_zip_read_info->stream.avail_out) &&
1863 (pfile_in_zip_read_info->rest_read_compressed == 0))
1864 flush = Z_FINISH;
1865 */
1866 err=inflate(&pfile_in_zip_read_info->stream,flush);
1867
1868 if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
1869 err = Z_DATA_ERROR;
1870
1871 uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
1872 uOutThis = uTotalOutAfter-uTotalOutBefore;
1873
1874 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
1875
1876 pfile_in_zip_read_info->crc32 =
1877 crc32(pfile_in_zip_read_info->crc32,bufBefore,
1878 (uInt)(uOutThis));
1879
1880 pfile_in_zip_read_info->rest_read_uncompressed -=
1881 uOutThis;
1882
1883 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1884
1885 if (err==Z_STREAM_END)
1886 return (iRead==0) ? UNZ_EOF : iRead;
1887 if (err!=Z_OK)
1888 break;
1889 }
1890 }
1891
1892 if (err==Z_OK)
1893 return iRead;
1894 return err;
1895}
#define Z_STREAM_END
Definition miniz.h:464
#define inflate
Definition miniz.h:505
#define Z_DATA_ERROR
Definition miniz.h:468
#define crc32
Definition miniz.h:511
#define Z_SYNC_FLUSH
Definition miniz.h:459
Byte Bytef
Definition miniz.h:448

References file_in_zip64_read_info_s::byte_before_the_zipfile, file_in_zip64_read_info_s::compression_method, crc32, file_in_zip64_read_info_s::crc32, unz64_s::encrypted, file_in_zip64_read_info_s::filestream, inflate, unz64_s::pfile_in_zip_read, file_in_zip64_read_info_s::pos_in_zipfile, file_in_zip64_read_info_s::raw, file_in_zip64_read_info_s::read_buffer, file_in_zip64_read_info_s::rest_read_compressed, file_in_zip64_read_info_s::rest_read_uncompressed, file_in_zip64_read_info_s::stream, file_in_zip64_read_info_s::total_out_64, UNZ_BUFSIZE, UNZ_END_OF_LIST_OF_FILE, UNZ_EOF, UNZ_ERRNO, UNZ_OK, UNZ_PARAMERROR, Z_BZIP2ED, Z_DATA_ERROR, file_in_zip64_read_info_s::z_filefunc, Z_OK, Z_STREAM_END, Z_SYNC_FLUSH, ZLIB_FILEFUNC_SEEK_SET, ZREAD64, and ZSEEK64.

Referenced by OOReadOXZVorbis().

+ Here is the caller graph for this function:

◆ unzSetOffset()

int ZEXPORT unzSetOffset ( unzFile file,
uLong pos )
extern

Definition at line 2134 of file unzip.c.

2135{
2136 return unzSetOffset64(file,pos);
2137}
int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
Definition unzip.c:2116

References unzSetOffset64().

+ Here is the call graph for this function:

◆ unzSetOffset64()

int ZEXPORT unzSetOffset64 ( unzFile file,
ZPOS64_T pos )
extern

Definition at line 2116 of file unzip.c.

2117{
2118 unz64_s* s;
2119 int err;
2120
2121 if (file==NULL)
2122 return UNZ_PARAMERROR;
2123 s=(unz64_s*)file;
2124
2125 s->pos_in_central_dir = pos;
2126 s->num_file = s->gi.number_entry; /* hack */
2129 NULL,0,NULL,0,NULL,0);
2130 s->current_file_ok = (err == UNZ_OK);
2131 return err;
2132}

References unz64_s::cur_file_info, unz64_s::cur_file_info_internal, unz64_s::current_file_ok, unz64_s::gi, unz64_s::num_file, unz_global_info64_s::number_entry, unz64_s::pos_in_central_dir, unz64local_GetCurrentFileInfoInternal(), UNZ_OK, and UNZ_PARAMERROR.

Referenced by unzSetOffset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzStringFileNameCompare()

int ZEXPORT unzStringFileNameCompare ( const char * fileName1,
const char * fileName2,
int iCaseSensitivity )
extern

Definition at line 393 of file unzip.c.

397{
398 if (iCaseSensitivity==0)
399 iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
400
401 if (iCaseSensitivity==1)
402 return strcmp(fileName1,fileName2);
403
404 return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
405}
#define CASESENSITIVITYDEFAULTVALUE
Definition unzip.c:375
#define STRCMPCASENOSENTIVEFUNCTION
Definition unzip.c:381

References CASESENSITIVITYDEFAULTVALUE, and STRCMPCASENOSENTIVEFUNCTION.

Referenced by unzLocateFile().

+ Here is the caller graph for this function:

◆ unztell()

z_off_t ZEXPORT unztell ( unzFile file)
extern

Definition at line 1901 of file unzip.c.

1902{
1903 unz64_s* s;
1904 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1905 if (file==NULL)
1906 return UNZ_PARAMERROR;
1907 s=(unz64_s*)file;
1908 pfile_in_zip_read_info=s->pfile_in_zip_read;
1909
1910 if (pfile_in_zip_read_info==NULL)
1911 return UNZ_PARAMERROR;
1912
1913 return (z_off_t)pfile_in_zip_read_info->stream.total_out;
1914}

References unz64_s::pfile_in_zip_read, file_in_zip64_read_info_s::stream, and UNZ_PARAMERROR.

◆ unztell64()

ZPOS64_T ZEXPORT unztell64 ( unzFile file)
extern

Definition at line 1916 of file unzip.c.

1917{
1918
1919 unz64_s* s;
1920 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1921 if (file==NULL)
1922 return (ZPOS64_T)-1;
1923 s=(unz64_s*)file;
1924 pfile_in_zip_read_info=s->pfile_in_zip_read;
1925
1926 if (pfile_in_zip_read_info==NULL)
1927 return (ZPOS64_T)-1;
1928
1929 return pfile_in_zip_read_info->total_out_64;
1930}

References unz64_s::pfile_in_zip_read, and file_in_zip64_read_info_s::total_out_64.

Variable Documentation

◆ unz_copyright

const char unz_copyright[]
static
Initial value:
=
" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"

Definition at line 125 of file unzip.c.

Referenced by unzOpenInternal().