1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Update minizip files for connect enginbe from last zlib 1.3.

This commit is contained in:
Oleksandr Byelkin
2024-01-22 15:27:58 +01:00
parent 01ca57ec16
commit a9172b8a43
2 changed files with 303 additions and 358 deletions

View File

@@ -14,8 +14,8 @@
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
It is used when recreting zip archive with RAW when deleting items from a zip. It is used when recreating zip archive with RAW when deleting items from a zip.
ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed. ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
@@ -25,15 +25,13 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <time.h> #include <time.h>
#include "zlib.h" #include "zlib.h"
#include "zip.h" #include "zip.h"
#include "my_attribute.h"
#ifdef STDC #ifdef STDC
# include <stddef.h> # include <stddef.h>
# include <string.h>
# include <stdlib.h>
#endif #endif
#ifdef NO_ERRNO_H #ifdef NO_ERRNO_H
extern int errno; extern int errno;
@@ -48,7 +46,7 @@
/* compile with -Dlocal if your debugger can't find static symbols */ /* compile with -Dlocal if your debugger can't find static symbols */
#ifndef VERSIONMADEBY #ifndef VERSIONMADEBY
# define VERSIONMADEBY (0x0) /* platform depedent */ # define VERSIONMADEBY (0x0) /* platform dependent */
#endif #endif
#ifndef Z_BUFSIZE #ifndef Z_BUFSIZE
@@ -62,9 +60,6 @@
#ifndef ALLOC #ifndef ALLOC
# define ALLOC(size) (malloc(size)) # define ALLOC(size) (malloc(size))
#endif #endif
#ifndef TRYFREE
# define TRYFREE(p) {if (p) free(p);}
#endif
/* /*
#define SIZECENTRALDIRITEM (0x2e) #define SIZECENTRALDIRITEM (0x2e)
@@ -117,7 +112,7 @@ typedef struct linkedlist_datablock_internal_s
struct linkedlist_datablock_internal_s* next_datablock; struct linkedlist_datablock_internal_s* next_datablock;
uLong avail_in_this_block; uLong avail_in_this_block;
uLong filled_in_this_block; uLong filled_in_this_block;
uLong unused; /* for future use and alignement */ uLong unused; /* for future use and alignment */
unsigned char data[SIZEDATA_INDATABLOCK]; unsigned char data[SIZEDATA_INDATABLOCK];
} linkedlist_datablock_internal; } linkedlist_datablock_internal;
@@ -139,40 +134,40 @@ typedef struct
uInt pos_in_buffered_data; /* last written byte in buffered_data */ uInt pos_in_buffered_data; /* last written byte in buffered_data */
ZPOS64_T pos_local_header; /* offset of the local header of the file ZPOS64_T pos_local_header; /* offset of the local header of the file
currenty writing */ currently writing */
char* central_header; /* central header data for the current file */ char* central_header; /* central header data for the current file */
uLong size_centralExtra; uLong size_centralExtra;
uLong size_centralheader; /* size of the central header for cur file */ uLong size_centralheader; /* size of the central header for cur file */
uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */
uLong flag; /* flag of the file currently writing */ uLong flag; /* flag of the file currently writing */
int method; /* compression method of file currenty wr.*/ int method; /* compression method of file currently wr.*/
int raw; /* 1 for directly writing raw data */ int raw; /* 1 for directly writing raw data */
Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
uLong dosDate; uLong dosDate;
uLong crc32; uLong crc32;
int encrypt; int encrypt;
int zip64; /* Add ZIP64 extened information in the extra field */ int zip64; /* Add ZIP64 extended information in the extra field */
ZPOS64_T pos_zip64extrainfo; ZPOS64_T pos_zip64extrainfo;
ZPOS64_T totalCompressedData; ZPOS64_T totalCompressedData;
ZPOS64_T totalUncompressedData; ZPOS64_T totalUncompressedData;
#ifndef NOCRYPT #ifndef NOCRYPT
unsigned long keys[3]; /* keys defining the pseudo-random sequence */ unsigned long keys[3]; /* keys defining the pseudo-random sequence */
const z_crc_t* pcrc_32_tab; const z_crc_t* pcrc_32_tab;
int crypt_header_size; unsigned crypt_header_size;
#endif #endif
} curfile64_info; } curfile64_info;
typedef struct typedef struct
{ {
zlib_filefunc64_32_def z_filefunc; zlib_filefunc64_32_def z_filefunc;
voidpf filestream; /* io structore of the zipfile */ voidpf filestream; /* io structure of the zipfile */
linkedlist_data central_dir;/* datablock with central dir in construction*/ linkedlist_data central_dir;/* datablock with central dir in construction*/
int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/
curfile64_info ci; /* info on the file curretly writing */ curfile64_info ci; /* info on the file currently writing */
ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ ZPOS64_T begin_pos; /* position of the beginning of the zipfile */
ZPOS64_T add_position_when_writting_offset; ZPOS64_T add_position_when_writing_offset;
ZPOS64_T number_entry; ZPOS64_T number_entry;
#ifndef NO_ADDFILEINEXISTINGZIP #ifndef NO_ADDFILEINEXISTINGZIP
@@ -187,8 +182,7 @@ typedef struct
#include "crypt.h" #include "crypt.h"
#endif #endif
local linkedlist_datablock_internal* allocate_new_datablock() local linkedlist_datablock_internal* allocate_new_datablock(void) {
{
linkedlist_datablock_internal* ldi; linkedlist_datablock_internal* ldi;
ldi = (linkedlist_datablock_internal*) ldi = (linkedlist_datablock_internal*)
ALLOC(sizeof(linkedlist_datablock_internal)); ALLOC(sizeof(linkedlist_datablock_internal));
@@ -201,30 +195,26 @@ local linkedlist_datablock_internal* allocate_new_datablock()
return ldi; return ldi;
} }
local void free_datablock(linkedlist_datablock_internal* ldi) local void free_datablock(linkedlist_datablock_internal* ldi) {
{
while (ldi!=NULL) while (ldi!=NULL)
{ {
linkedlist_datablock_internal* ldinext = ldi->next_datablock; linkedlist_datablock_internal* ldinext = ldi->next_datablock;
TRYFREE(ldi); free(ldi);
ldi = ldinext; ldi = ldinext;
} }
} }
local void init_linkedlist(linkedlist_data* ll) local void init_linkedlist(linkedlist_data* ll) {
{
ll->first_block = ll->last_block = NULL; ll->first_block = ll->last_block = NULL;
} }
local void free_linkedlist(linkedlist_data* ll) local void free_linkedlist(linkedlist_data* ll) {
{
free_datablock(ll->first_block); free_datablock(ll->first_block);
ll->first_block = ll->last_block = NULL; ll->first_block = ll->last_block = NULL;
} }
local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) {
{
linkedlist_datablock_internal* ldi; linkedlist_datablock_internal* ldi;
const unsigned char* from_copy; const unsigned char* from_copy;
@@ -239,7 +229,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
} }
ldi = ll->last_block; ldi = ll->last_block;
from_copy = (unsigned char*)buf; from_copy = (const unsigned char*)buf;
while (len>0) while (len>0)
{ {
@@ -284,9 +274,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T)
*/ */
local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) {
local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
{
unsigned char buf[8]; unsigned char buf[8];
int n; int n;
for (n = 0; n < nbByte; n++) for (n = 0; n < nbByte; n++)
@@ -302,15 +290,13 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def,
} }
} }
if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,(uLong)nbByte)!=(uLong)nbByte)
return ZIP_ERRNO; return ZIP_ERRNO;
else else
return ZIP_OK; return ZIP_OK;
} }
local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) {
local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
{
unsigned char* buf=(unsigned char*)dest; unsigned char* buf=(unsigned char*)dest;
int n; int n;
for (n = 0; n < nbByte; n++) { for (n = 0; n < nbByte; n++) {
@@ -330,25 +316,21 @@ local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
/****************************************************************************/ /****************************************************************************/
local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) {
{
uLong year = (uLong)ptm->tm_year; uLong year = (uLong)ptm->tm_year;
if (year>=1980) if (year>=1980)
year-=1980; year-=1980;
else if (year>=80) else if (year>=80)
year-=80; year-=80;
return return
(uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | (uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) |
((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); (((uLong)ptm->tm_sec/2) + (32 * (uLong)ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
} }
/****************************************************************************/ /****************************************************************************/
local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) {
local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi)
{
unsigned char c; unsigned char c;
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
if (err==1) if (err==1)
@@ -369,10 +351,7 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,vo
/* =========================================================================== /* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets Reads a long in LSB order from the given gz_stream. Sets
*/ */
local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
{
uLong x ; uLong x ;
int i = 0; int i = 0;
int err; int err;
@@ -391,10 +370,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
return err; return err;
} }
local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
{
uLong x ; uLong x ;
int i = 0; int i = 0;
int err; int err;
@@ -421,11 +397,8 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
return err; return err;
} }
local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX));
local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) {
local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
{
ZPOS64_T x; ZPOS64_T x;
int i = 0; int i = 0;
int err; int err;
@@ -476,10 +449,7 @@ local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def
Locate the Central directory of a zipfile (at the end, just before Locate the Central directory of a zipfile (at the end, just before
the global comment) the global comment)
*/ */
local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf; unsigned char* buf;
ZPOS64_T uSizeFile; ZPOS64_T uSizeFile;
ZPOS64_T uBackRead; ZPOS64_T uBackRead;
@@ -519,18 +489,18 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
break; break;
for (i=(int)uReadSize-3; (i--)>0;) { for (i=(int)uReadSize-3; (i--)>0;)
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{ {
uPosFound = uReadPos+i; uPosFound = uReadPos+(unsigned)i;
break; break;
} }
}
if (uPosFound!=0) if (uPosFound!=0)
break; break;
} }
TRYFREE(buf); free(buf);
return uPosFound; return uPosFound;
} }
@@ -538,10 +508,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before
the global comment) the global comment)
*/ */
local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf; unsigned char* buf;
ZPOS64_T uSizeFile; ZPOS64_T uSizeFile;
ZPOS64_T uBackRead; ZPOS64_T uBackRead;
@@ -587,7 +554,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
// Signature "0x07064b50" Zip64 end of central directory locater // Signature "0x07064b50" Zip64 end of central directory locater
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
{ {
uPosFound = uReadPos+i; uPosFound = uReadPos+(unsigned)i;
break; break;
} }
} }
@@ -596,7 +563,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
break; break;
} }
TRYFREE(buf); free(buf);
if (uPosFound == 0) if (uPosFound == 0)
return 0; return 0;
@@ -638,8 +605,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
return relativeOffset; return relativeOffset;
} }
static int LoadCentralDirectoryRecord(zip64_internal* pziinit) local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
{
int err=ZIP_OK; int err=ZIP_OK;
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
@@ -649,9 +615,9 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit)
uLong uL; uLong uL;
uLong number_disk; /* number of the current dist, used for uLong number_disk; /* number of the current dist, used for
spaning ZIP, unsupported, always 0*/ spanning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number the the disk with central dir, used uLong number_disk_with_CD; /* number the the disk with central dir, used
for spaning ZIP, unsupported, always 0*/ for spanning ZIP, unsupported, always 0*/
ZPOS64_T number_entry; ZPOS64_T number_entry;
ZPOS64_T number_entry_CD; /* total number of entries in ZPOS64_T number_entry_CD; /* total number of entries in
the central dir the central dir
@@ -808,7 +774,7 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit)
} }
byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir); byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir);
pziinit->add_position_when_writting_offset = byte_before_the_zipfile; pziinit->add_position_when_writing_offset = byte_before_the_zipfile;
{ {
ZPOS64_T size_central_dir_to_read = size_central_dir; ZPOS64_T size_central_dir_to_read = size_central_dir;
@@ -831,7 +797,7 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit)
size_central_dir_to_read-=read_this; size_central_dir_to_read-=read_this;
} }
TRYFREE(buf_read); free(buf_read);
} }
pziinit->begin_pos = byte_before_the_zipfile; pziinit->begin_pos = byte_before_the_zipfile;
pziinit->number_entry = number_entry_CD; pziinit->number_entry = number_entry_CD;
@@ -847,8 +813,7 @@ static int LoadCentralDirectoryRecord(zip64_internal* pziinit)
/************************************************************/ /************************************************************/
static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) {
{
zip64_internal ziinit; zip64_internal ziinit;
zip64_internal* zi; zip64_internal* zi;
int err=ZIP_OK; int err=ZIP_OK;
@@ -876,7 +841,7 @@ static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomm
ziinit.in_opened_file_inzip = 0; ziinit.in_opened_file_inzip = 0;
ziinit.ci.stream_initialised = 0; ziinit.ci.stream_initialised = 0;
ziinit.number_entry = 0; ziinit.number_entry = 0;
ziinit.add_position_when_writting_offset = 0; ziinit.add_position_when_writing_offset = 0;
init_linkedlist(&(ziinit.central_dir)); init_linkedlist(&(ziinit.central_dir));
@@ -906,9 +871,9 @@ static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomm
if (err != ZIP_OK) if (err != ZIP_OK)
{ {
# ifndef NO_ADDFILEINEXISTINGZIP # ifndef NO_ADDFILEINEXISTINGZIP
TRYFREE(ziinit.globalcomment); free(ziinit.globalcomment);
# endif /* !NO_ADDFILEINEXISTINGZIP*/ # endif /* !NO_ADDFILEINEXISTINGZIP*/
TRYFREE(zi); free(zi);
return NULL; return NULL;
} }
else else
@@ -918,8 +883,7 @@ static zipFile zipOpen3 (const void *pathname, int append, zipcharpc* globalcomm
} }
} }
extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) {
{
if (pzlib_filefunc32_def != NULL) if (pzlib_filefunc32_def != NULL)
{ {
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -930,8 +894,7 @@ extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* gl
return zipOpen3(pathname, append, globalcomment, NULL); return zipOpen3(pathname, append, globalcomment, NULL);
} }
extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) {
{
if (pzlib_filefunc_def != NULL) if (pzlib_filefunc_def != NULL)
{ {
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -946,18 +909,15 @@ extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc*
extern zipFile ZEXPORT zipOpen (const char* pathname, int append) extern zipFile ZEXPORT zipOpen(const char* pathname, int append) {
{
return zipOpen3((const void*)pathname,append,NULL,NULL); return zipOpen3((const void*)pathname,append,NULL,NULL);
} }
extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) {
{
return zipOpen3(pathname,append,NULL,NULL); return zipOpen3(pathname,append,NULL,NULL);
} }
static int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) {
{
/* write the local header */ /* write the local header */
int err; int err;
uInt size_filename = (uInt)strlen(filename); uInt size_filename = (uInt)strlen(filename);
@@ -1035,8 +995,8 @@ static int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt
// Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
@@ -1053,24 +1013,24 @@ static int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt
It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize
unnecessary allocations. unnecessary allocations.
*/ */
extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global, const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw, const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy, int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting __attribute__((unused)), const char* password, uLong crcForCrypting,
uLong versionMadeBy, uLong flagBase, int zip64) uLong versionMadeBy, uLong flagBase, int zip64) {
{
zip64_internal* zi; zip64_internal* zi;
uInt size_filename; uInt size_filename;
uInt size_comment; uInt size_comment;
uInt i; uInt i;
int err = ZIP_OK; int err = ZIP_OK;
#ifdef NOCRYPT # ifdef NOCRYPT
(crcForCrypting);
if (password != NULL) if (password != NULL)
return ZIP_PARAMERROR; return ZIP_PARAMERROR;
#endif # endif
if (file == NULL) if (file == NULL)
return ZIP_PARAMERROR; return ZIP_PARAMERROR;
@@ -1164,7 +1124,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
if(zi->ci.pos_local_header >= 0xffffffff) if(zi->ci.pos_local_header >= 0xffffffff)
zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4); zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4);
else else
zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writting_offset,4); zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writing_offset,4);
for (i=0;i<size_filename;i++) for (i=0;i<size_filename;i++)
*(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
@@ -1262,35 +1222,33 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
return err; return err;
} }
extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global, const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw, const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy, int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting, const char* password, uLong crcForCrypting,
uLong versionMadeBy, uLong flagBase) uLong versionMadeBy, uLong flagBase) {
{ return zipOpenNewFileInZip4_64(file, filename, zipfi,
return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local,
extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global,
extrafield_global, size_extrafield_global, comment, method, level, raw,
comment, method, level, raw, windowBits, memLevel, strategy,
windowBits, memLevel, strategy, password, crcForCrypting, versionMadeBy, flagBase, 0);
password, crcForCrypting, versionMadeBy, flagBase, 0);
} }
extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global, const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw, const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy, int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting) const char* password, uLong crcForCrypting) {
{ return zipOpenNewFileInZip4_64(file, filename, zipfi,
return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local,
extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global,
extrafield_global, size_extrafield_global, comment, method, level, raw,
comment, method, level, raw, windowBits, memLevel, strategy,
windowBits, memLevel, strategy, password, crcForCrypting, VERSIONMADEBY, 0, 0);
password, crcForCrypting, VERSIONMADEBY, 0, 0);
} }
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
@@ -1298,70 +1256,64 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c
const void* extrafield_global, uInt size_extrafield_global, const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw, const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy, int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting, int zip64) const char* password, uLong crcForCrypting, int zip64) {
{ return zipOpenNewFileInZip4_64(file, filename, zipfi,
return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local,
extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global,
extrafield_global, size_extrafield_global, comment, method, level, raw,
comment, method, level, raw, windowBits, memLevel, strategy,
windowBits, memLevel, strategy, password, crcForCrypting, VERSIONMADEBY, 0, zip64);
password, crcForCrypting, VERSIONMADEBY, 0, zip64);
} }
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global, const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw) const char* comment, int method, int level, int raw) {
{ return zipOpenNewFileInZip4_64(file, filename, zipfi,
return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local,
extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global,
extrafield_global, size_extrafield_global, comment, method, level, raw,
comment, method, level, raw, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, NULL, 0, VERSIONMADEBY, 0, 0);
NULL, 0, VERSIONMADEBY, 0, 0);
} }
extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global, const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw, int zip64) const char* comment, int method, int level, int raw, int zip64) {
{ return zipOpenNewFileInZip4_64(file, filename, zipfi,
return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local,
extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global,
extrafield_global, size_extrafield_global, comment, method, level, raw,
comment, method, level, raw, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, NULL, 0, VERSIONMADEBY, 0, zip64);
NULL, 0, VERSIONMADEBY, 0, zip64);
} }
extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_local, uInt size_extrafield_local,
const void*extrafield_global, uInt size_extrafield_global, const void*extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int zip64) const char* comment, int method, int level, int zip64) {
{ return zipOpenNewFileInZip4_64(file, filename, zipfi,
return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local,
extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global,
extrafield_global, size_extrafield_global, comment, method, level, 0,
comment, method, level, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, NULL, 0, VERSIONMADEBY, 0, zip64);
NULL, 0, VERSIONMADEBY, 0, zip64);
} }
extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_local, uInt size_extrafield_local,
const void*extrafield_global, uInt size_extrafield_global, const void*extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level) const char* comment, int method, int level) {
{ return zipOpenNewFileInZip4_64(file, filename, zipfi,
return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local,
extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global,
extrafield_global, size_extrafield_global, comment, method, level, 0,
comment, method, level, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, NULL, 0, VERSIONMADEBY, 0, 0);
NULL, 0, VERSIONMADEBY, 0, 0);
} }
local int zip64FlushWriteBuffer(zip64_internal* zi) local int zip64FlushWriteBuffer(zip64_internal* zi) {
{
int err=ZIP_OK; int err=ZIP_OK;
if (zi->ci.encrypt != 0) if (zi->ci.encrypt != 0)
@@ -1399,8 +1351,7 @@ local int zip64FlushWriteBuffer(zip64_internal* zi)
return err; return err;
} }
extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) {
{
zip64_internal* zi; zip64_internal* zi;
int err=ZIP_OK; int err=ZIP_OK;
@@ -1450,7 +1401,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
else else
#endif #endif
{ {
zi->ci.stream.next_in = (Bytef*)buf; zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf;
zi->ci.stream.avail_in = len; zi->ci.stream.avail_in = len;
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
@@ -1501,17 +1452,15 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
return err; return err;
} }
extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) {
{
return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32);
} }
extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) {
{
zip64_internal* zi; zip64_internal* zi;
ZPOS64_T compressed_size; ZPOS64_T compressed_size;
uLong invalidValue = 0xffffffff; uLong invalidValue = 0xffffffff;
short datasize = 0; unsigned datasize = 0;
int err=ZIP_OK; int err=ZIP_OK;
if (file == NULL) if (file == NULL)
@@ -1742,15 +1691,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
return err; return err;
} }
extern int ZEXPORT zipCloseFileInZip (zipFile file) extern int ZEXPORT zipCloseFileInZip(zipFile file) {
{
return zipCloseFileInZipRaw (file,0,0); return zipCloseFileInZipRaw (file,0,0);
} }
static int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) {
{
int err = ZIP_OK; int err = ZIP_OK;
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4);
@@ -1769,8 +1716,7 @@ static int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T
return err; return err;
} }
static int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
{
int err = ZIP_OK; int err = ZIP_OK;
uLong Zip64DataSize = 44; uLong Zip64DataSize = 44;
@@ -1803,13 +1749,13 @@ static int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size
if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */
{ {
ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8);
} }
return err; return err;
} }
static int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
{ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
int err = ZIP_OK; int err = ZIP_OK;
/*signature*/ /*signature*/
@@ -1844,20 +1790,19 @@ static int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_cent
if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */
{ {
ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff) if(pos >= 0xffffffff)
{ {
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4);
} }
else else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset),4);
} }
return err; return err;
} }
static int Write_GlobalComment(zip64_internal* zi, const char* global_comment) local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) {
{
int err = ZIP_OK; int err = ZIP_OK;
uInt size_global_comment = 0; uInt size_global_comment = 0;
@@ -1874,8 +1819,7 @@ static int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
return err; return err;
} }
extern int ZEXPORT zipClose (zipFile file, const char* global_comment) extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
{
zip64_internal* zi; zip64_internal* zi;
int err = 0; int err = 0;
uLong size_centraldir = 0; uLong size_centraldir = 0;
@@ -1916,7 +1860,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
} }
free_linkedlist(&(zi->central_dir)); free_linkedlist(&(zi->central_dir));
pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
{ {
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
@@ -1936,15 +1880,14 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
err = ZIP_ERRNO; err = ZIP_ERRNO;
#ifndef NO_ADDFILEINEXISTINGZIP #ifndef NO_ADDFILEINEXISTINGZIP
TRYFREE(zi->globalcomment); free(zi->globalcomment);
#endif #endif
TRYFREE(zi); free(zi);
return err; return err;
} }
extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) {
{
char* p = pData; char* p = pData;
int size = 0; int size = 0;
char* pNewHeader; char* pNewHeader;
@@ -1954,10 +1897,10 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
int retVal = ZIP_OK; int retVal = ZIP_OK;
if(pData == NULL || *dataLen < 4) if(pData == NULL || dataLen == NULL || *dataLen < 4)
return ZIP_PARAMERROR; return ZIP_PARAMERROR;
pNewHeader = (char*)ALLOC(*dataLen); pNewHeader = (char*)ALLOC((unsigned)*dataLen);
pTmp = pNewHeader; pTmp = pNewHeader;
while(p < (pData + *dataLen)) while(p < (pData + *dataLen))
@@ -1996,7 +1939,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
else else
retVal = ZIP_ERRNO; retVal = ZIP_ERRNO;
TRYFREE(pNewHeader); free(pNewHeader);
return retVal; return retVal;
} }

View File

@@ -88,12 +88,12 @@ typedef voidp zipFile;
/* tm_zip contain date/time info */ /* tm_zip contain date/time info */
typedef struct tm_zip_s typedef struct tm_zip_s
{ {
uInt tm_sec; /* seconds after the minute - [0,59] */ int tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */ int tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */ int tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */ int tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */ int tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */ int tm_year; /* years - [1980..2044] */
} tm_zip; } tm_zip;
typedef struct typedef struct
@@ -113,8 +113,8 @@ typedef const char* zipcharpc;
#define APPEND_STATUS_CREATEAFTER (1) #define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2) #define APPEND_STATUS_ADDINZIP (2)
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); extern zipFile ZEXPORT zipOpen(const char *pathname, int append);
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
/* /*
Create a zipfile. Create a zipfile.
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
@@ -131,41 +131,46 @@ extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
/* Note : there is no delete function into a zipfile. /* Note : there is no delete function into a zipfile.
If you want delete file into a zipfile, you must open a zipfile, and create another If you want delete file into a zipfile, you must open a zipfile, and create another
Of couse, you can use RAW reading and writing to copy the file you did not want delte Of course, you can use RAW reading and writing to copy the file you did not want delete
*/ */
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, extern zipFile ZEXPORT zipOpen2(const char *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def);
extern zipFile ZEXPORT zipOpen2_64(const void *pathname,
int append, int append,
zipcharpc* globalcomment, zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def)); zlib_filefunc64_def* pzlib_filefunc_def);
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, extern zipFile ZEXPORT zipOpen3(const void *pathname,
int append, int append,
zipcharpc* globalcomment, zipcharpc* globalcomment,
zlib_filefunc64_def* pzlib_filefunc_def)); zlib_filefunc64_32_def* pzlib_filefunc64_32_def);
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level)); int level);
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level, int level,
int zip64)); int zip64);
/* /*
Open a file in the ZIP for writing. Open a file in the ZIP for writing.
@@ -184,70 +189,69 @@ extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
*/ */
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level, int level,
int raw)); int raw);
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level, int level,
int raw, int raw,
int zip64)); int zip64);
/* /*
Same than zipOpenNewFileInZip, except if raw=1, we write raw file Same than zipOpenNewFileInZip, except if raw=1, we write raw file
*/ */
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip3(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level, int level,
int raw, int raw,
int windowBits, int windowBits,
int memLevel, int memLevel,
int strategy, int strategy,
const char* password, const char* password,
uLong crcForCrypting)); uLong crcForCrypting);
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level, int level,
int raw, int raw,
int windowBits, int windowBits,
int memLevel, int memLevel,
int strategy, int strategy,
const char* password, const char* password,
uLong crcForCrypting, uLong crcForCrypting,
int zip64 int zip64);
));
/* /*
Same than zipOpenNewFileInZip2, except Same than zipOpenNewFileInZip2, except
@@ -256,47 +260,45 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
crcForCrypting : crc of file to compress (needed for crypting) crcForCrypting : crc of file to compress (needed for crypting)
*/ */
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip4(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level, int level,
int raw, int raw,
int windowBits, int windowBits,
int memLevel, int memLevel,
int strategy, int strategy,
const char* password, const char* password,
uLong crcForCrypting, uLong crcForCrypting,
uLong versionMadeBy, uLong versionMadeBy,
uLong flagBase uLong flagBase);
));
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file,
const char* filename, const char* filename,
const zip_fileinfo* zipfi, const zip_fileinfo* zipfi,
const void* extrafield_local, const void* extrafield_local,
uInt size_extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, const void* extrafield_global,
uInt size_extrafield_global, uInt size_extrafield_global,
const char* comment, const char* comment,
int method, int method,
int level, int level,
int raw, int raw,
int windowBits, int windowBits,
int memLevel, int memLevel,
int strategy, int strategy,
const char* password, const char* password,
uLong crcForCrypting, uLong crcForCrypting,
uLong versionMadeBy, uLong versionMadeBy,
uLong flagBase, uLong flagBase,
int zip64 int zip64);
));
/* /*
Same than zipOpenNewFileInZip4, except Same than zipOpenNewFileInZip4, except
versionMadeBy : value for Version made by field versionMadeBy : value for Version made by field
@@ -304,25 +306,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
*/ */
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, extern int ZEXPORT zipWriteInFileInZip(zipFile file,
const void* buf, const void* buf,
unsigned len)); unsigned len);
/* /*
Write data in the zipfile Write data in the zipfile
*/ */
extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); extern int ZEXPORT zipCloseFileInZip(zipFile file);
/* /*
Close the current file in the zipfile Close the current file in the zipfile
*/ */
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
uLong uncompressed_size, uLong uncompressed_size,
uLong crc32)); uLong crc32);
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
ZPOS64_T uncompressed_size, ZPOS64_T uncompressed_size,
uLong crc32)); uLong crc32);
/* /*
Close the current file in the zipfile, for file opened with Close the current file in the zipfile, for file opened with
@@ -330,14 +332,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
uncompressed_size and crc32 are value for the uncompressed size uncompressed_size and crc32 are value for the uncompressed size
*/ */
extern int ZEXPORT zipClose OF((zipFile file, extern int ZEXPORT zipClose(zipFile file,
const char* global_comment)); const char* global_comment);
/* /*
Close the zipfile Close the zipfile
*/ */
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);
/* /*
zipRemoveExtraInfoBlock - Added by Mathias Svensson zipRemoveExtraInfoBlock - Added by Mathias Svensson