libdigidocpp
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)   (malloc(size))
#define TRYFREE(p)   {if (p) free(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

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

Macro Definition Documentation

#define ALLOC (   size)    (malloc(size))
#define BUFREADCOMMENT   (0x400)

Definition at line 405 of file unzip.c.

Referenced by unz64local_SearchCentralDir(), and unz64local_SearchCentralDir64().

#define CASESENSITIVITYDEFAULT_NO

Definition at line 98 of file unzip.c.

#define CASESENSITIVITYDEFAULTVALUE   2

Definition at line 372 of file unzip.c.

Referenced by unzStringFileNameCompare().

#define local   static

Definition at line 91 of file unzip.c.

#define NOUNCRYPT

Definition at line 72 of file unzip.c.

#define SIZECENTRALDIRITEM   (0x2e)

Definition at line 118 of file unzip.c.

Referenced by unzGoToNextFile().

#define SIZEZIPLOCALHEADER   (0x1e)

Definition at line 119 of file unzip.c.

Referenced by unz64local_CheckCurrentFileCoherencyHeader(), and unzOpenCurrentFile3().

#define STRCMPCASENOSENTIVEFUNCTION   strcmpcasenosensitive_internal

Definition at line 378 of file unzip.c.

Referenced by unzStringFileNameCompare().

#define TRYFREE (   p)    {if (p) free(p);}
#define UNZ_BUFSIZE   (16384)

Definition at line 104 of file unzip.c.

Referenced by unzOpenCurrentFile3(), and unzReadCurrentFile().

#define UNZ_MAXFILENAMEINZIP   (256)

Definition at line 108 of file unzip.c.

Referenced by unzLocateFile().

Typedef Documentation

Function Documentation

local int unz64local_getByte OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)  )
local int zip64local_getLong OF ( (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 ZPOS64_T zip64local_SearchCentralDir64 OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)  )
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 strcmpcasenosensitive_internal ( const char *  fileName1,
const char *  fileName2 
)

Definition at line 349 of file unzip.c.

local void unz64local_DosDateToTmuDate ( ZPOS64_T  ulDosDate,
tm_unz ptm 
)

Definition at line 852 of file unzip.c.

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:

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

Definition at line 212 of file unzip.c.

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:

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

Definition at line 266 of file unzip.c.

References i, uLong(), unz64local_getByte(), and UNZ_OK.

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:

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

Definition at line 302 of file unzip.c.

References i, unz64local_getByte(), and UNZ_OK.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 239 of file unzip.c.

References i, uLong(), unz64local_getByte(), and UNZ_OK.

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

Here is the call graph for this function:

Here is the caller graph for this function:

local ZPOS64_T unz64local_SearchCentralDir ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream 
)

Definition at line 413 of file unzip.c.

References ALLOC, BUFREADCOMMENT, i, TRYFREE, uLong(), 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:

local ZPOS64_T unz64local_SearchCentralDir64 ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream 
)

Definition at line 478 of file unzip.c.

References ALLOC, BUFREADCOMMENT, i, TRYFREE, uLong(), 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:

int ZEXPORT unzClose ( unzFile  file)

Definition at line 808 of file unzip.c.

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

Referenced by digidoc::ZipSerialize::extract().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1124 of file unzip.c.

References unz64local_GetCurrentFileInfoInternal().

Referenced by unzLocateFile().

Here is the call graph for this function:

Here is the caller graph for this function:

ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 ( unzFile  file)
int ZEXPORT unzGetFilePos ( unzFile  file,
unz_file_pos file_pos 
)
int ZEXPORT unzGetFilePos64 ( unzFile  file,
unz64_file_pos file_pos 
)
int ZEXPORT unzGetGlobalComment ( unzFile  file,
char *  szComment,
uLong  uSizeBuf 
)
int ZEXPORT unzGetGlobalInfo ( unzFile  file,
unz_global_info pglobal_info32 
)
int ZEXPORT unzGetGlobalInfo64 ( unzFile  file,
unz_global_info64 pglobal_info 
)

Definition at line 828 of file unzip.c.

References unz64_s::gi, UNZ_OK, and UNZ_PARAMERROR.

uLong ZEXPORT unzGetOffset ( unzFile  file)

Definition at line 2094 of file unzip.c.

References uLong(), and unzGetOffset64().

Here is the call graph for this function:

ZPOS64_T ZEXPORT unzGetOffset64 ( unzFile  file)

Definition at line 2079 of file unzip.c.

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:

int ZEXPORT unzGoToFilePos ( unzFile  file,
unz_file_pos file_pos 
)
int ZEXPORT unzGoToFilePos64 ( unzFile  file,
const unz64_file_pos file_pos 
)
int ZEXPORT unzGoToFirstFile ( unzFile  file)
int ZEXPORT unzLocateFile ( unzFile  file,
const char *  szFileName,
int  iCaseSensitivity 
)
unzFile ZEXPORT unzOpen ( const char *  path)

Definition at line 793 of file unzip.c.

References unzOpenInternal().

Here is the call graph for this function:

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

Definition at line 765 of file unzip.c.

References fill_zlib_filefunc64_32_def_from_filefunc32(), and unzOpenInternal().

Referenced by digidoc::ZipSerialize::extract().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 778 of file unzip.c.

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:

unzFile ZEXPORT unzOpen64 ( const void *  path)

Definition at line 798 of file unzip.c.

References unzOpenInternal().

Here is the call graph for this function:

int ZEXPORT unzOpenCurrentFile ( unzFile  file)

Definition at line 1641 of file unzip.c.

References unzOpenCurrentFile3().

Referenced by digidoc::ZipSerializePrivate::extractCurrentFile().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1651 of file unzip.c.

References unzOpenCurrentFile3().

Here is the call graph for this function:

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

Definition at line 1472 of file unzip.c.

References ALLOC, file_in_zip64_read_info_s::byte_before_the_zipfile, unz64_s::byte_before_the_zipfile, unz_file_info64_s::compressed_size, unz_file_info64_s::compression_method, file_in_zip64_read_info_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, i, if(), init_keys(), int(), 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, SEEK_SET, 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(), voidpf(), Z_BZIP2ED, file_in_zip64_read_info_s::z_filefunc, unz64_s::z_filefunc, zdecode, 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:

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

Definition at line 1646 of file unzip.c.

References unzOpenCurrentFile3().

Here is the call graph for this function:

int ZEXPORT unzSetOffset ( unzFile  file,
uLong  pos 
)

Definition at line 2122 of file unzip.c.

References unzSetOffset64().

Here is the call graph for this function:

int ZEXPORT unzSetOffset64 ( unzFile  file,
ZPOS64_T  pos 
)

Definition at line 2104 of file unzip.c.

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:

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

Definition at line 390 of file unzip.c.

References CASESENSITIVITYDEFAULTVALUE, and STRCMPCASENOSENTIVEFUNCTION.

Referenced by unzLocateFile().

Here is the caller graph for this function:

z_off_t ZEXPORT unztell ( unzFile  file)
ZPOS64_T ZEXPORT unztell64 ( unzFile  file)

Variable Documentation

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

Definition at line 122 of file unzip.c.

Referenced by unzOpenInternal().