mirror of
https://github.com/jmcnamara/libxlsxwriter
synced 2025-03-28 21:13:14 +00:00
Raw copy of minizip source files from zlib v1.3 release
This commit is contained in:
parent
29355a0887
commit
957ed5ca74
12
third_party/minizip/Makefile.orig
vendored
12
third_party/minizip/Makefile.orig
vendored
@ -1,5 +1,5 @@
|
||||
CC=cc
|
||||
CFLAGS=-O -I../..
|
||||
CFLAGS := $(CFLAGS) -O -I../..
|
||||
|
||||
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
|
||||
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
|
||||
@ -16,10 +16,14 @@ minizip: $(ZIP_OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
|
||||
|
||||
test: miniunz minizip
|
||||
./minizip test readme.txt
|
||||
@rm -f test.*
|
||||
@echo hello hello hello > test.txt
|
||||
./minizip test test.txt
|
||||
./miniunz -l test.zip
|
||||
mv readme.txt readme.old
|
||||
@mv test.txt test.old
|
||||
./miniunz test.zip
|
||||
@cmp test.txt test.old
|
||||
@rm -f test.*
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o *~ minizip miniunz
|
||||
/bin/rm -f *.o *~ minizip miniunz test.*
|
||||
|
2
third_party/minizip/MiniZip64_Changes.txt
vendored
2
third_party/minizip/MiniZip64_Changes.txt
vendored
@ -1,5 +1,5 @@
|
||||
|
||||
MiniZip 1.1 was derrived from MiniZip at version 1.01f
|
||||
MiniZip 1.1 was derived from MiniZip at version 1.01f
|
||||
|
||||
Change in 1.0 (Okt 2009)
|
||||
- **TODO - Add history**
|
||||
|
2
third_party/minizip/configure.ac
vendored
2
third_party/minizip/configure.ac
vendored
@ -1,7 +1,7 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT([minizip], [1.2.8], [bugzilla.redhat.com])
|
||||
AC_INIT([minizip], [1.3.0], [bugzilla.redhat.com])
|
||||
AC_CONFIG_SRCDIR([minizip.c])
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
LT_INIT
|
||||
|
29
third_party/minizip/crypt.h
vendored
29
third_party/minizip/crypt.h
vendored
@ -32,12 +32,12 @@
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||
{
|
||||
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
(void)pcrc_32_tab;
|
||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
@ -45,8 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
|
||||
{
|
||||
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
|
||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||
@ -62,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
|
||||
{
|
||||
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
|
||||
*(pkeys+0) = 305419896L;
|
||||
*(pkeys+1) = 591751049L;
|
||||
*(pkeys+2) = 878082192L;
|
||||
@ -77,24 +75,23 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
|
||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))
|
||||
|
||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
# ifndef ZCR_SEED2
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static int crypthead(const char* passwd, /* password string */
|
||||
unsigned char* buf, /* where to write header */
|
||||
int bufSize,
|
||||
unsigned long* pkeys,
|
||||
const z_crc_t* pcrc_32_tab,
|
||||
unsigned long crcForCrypting)
|
||||
{
|
||||
int n; /* index in random header */
|
||||
static unsigned crypthead(const char* passwd, /* password string */
|
||||
unsigned char* buf, /* where to write header */
|
||||
int bufSize,
|
||||
unsigned long* pkeys,
|
||||
const z_crc_t* pcrc_32_tab,
|
||||
unsigned long crcForCrypting) {
|
||||
unsigned n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||
|
87
third_party/minizip/ioapi.c
vendored
87
third_party/minizip/ioapi.c
vendored
@ -14,7 +14,7 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
@ -28,8 +28,7 @@
|
||||
|
||||
#include "ioapi.h"
|
||||
|
||||
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
|
||||
{
|
||||
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) {
|
||||
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
|
||||
else
|
||||
@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename
|
||||
}
|
||||
}
|
||||
|
||||
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
|
||||
{
|
||||
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) {
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
||||
else
|
||||
@ -52,13 +50,12 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
|
||||
}
|
||||
}
|
||||
|
||||
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
|
||||
{
|
||||
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) {
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||
else
|
||||
{
|
||||
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||
uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||
if ((tell_uLong) == MAXU32)
|
||||
return (ZPOS64_T)-1;
|
||||
else
|
||||
@ -66,11 +63,9 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream
|
||||
}
|
||||
}
|
||||
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
|
||||
{
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) {
|
||||
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
||||
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
||||
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
||||
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
|
||||
@ -84,19 +79,10 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
|
||||
|
||||
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
|
||||
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
||||
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
||||
{
|
||||
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) {
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else
|
||||
@ -111,11 +97,10 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
|
||||
return file;
|
||||
}
|
||||
|
||||
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
||||
{
|
||||
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) {
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else
|
||||
@ -131,44 +116,39 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
|
||||
}
|
||||
|
||||
|
||||
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
||||
{
|
||||
static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) {
|
||||
uLong ret;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
||||
{
|
||||
static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
|
||||
uLong ret;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) {
|
||||
long ret;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
ret = ftell((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) {
|
||||
ZPOS64_T ret;
|
||||
(void) opaque;
|
||||
ret = FTELLO_FUNC((FILE *)stream);
|
||||
(void)opaque;
|
||||
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
|
||||
{
|
||||
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
|
||||
int fseek_origin=0;
|
||||
long ret;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
@ -183,16 +163,15 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
|
||||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
||||
if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
|
||||
{
|
||||
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
|
||||
int fseek_origin=0;
|
||||
long ret;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
@ -208,31 +187,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
|
||||
if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
ret = fclose((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret;
|
||||
(void) opaque;
|
||||
(void)opaque;
|
||||
ret = ferror((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
{
|
||||
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
@ -243,8 +219,7 @@ void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
|
58
third_party/minizip/ioapi.h
vendored
58
third_party/minizip/ioapi.h
vendored
@ -18,12 +18,6 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Pragma added by libxlsxwriter to avoid warnings with -pedantic -ansi. */
|
||||
#ifndef _WIN32
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI64_H
|
||||
#define _ZLIBIOAPI64_H
|
||||
|
||||
@ -56,7 +50,7 @@
|
||||
#define ftello64 ftell
|
||||
#define fseeko64 fseek
|
||||
#else
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
#define fopen64 fopen
|
||||
#define ftello64 ftello
|
||||
#define fseeko64 fseeko
|
||||
@ -88,7 +82,7 @@
|
||||
#include "mz64conf.h"
|
||||
#endif
|
||||
|
||||
/* a type choosen by DEFINE */
|
||||
/* a type chosen by DEFINE */
|
||||
#ifdef HAVE_64BIT_INT_CUSTOM
|
||||
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||
#else
|
||||
@ -97,8 +91,7 @@ typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||
typedef uint64_t ZPOS64_T;
|
||||
#else
|
||||
|
||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||
#define MAXU32 0xffffffff
|
||||
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ZPOS64_T;
|
||||
@ -108,7 +101,10 @@ typedef unsigned long long int ZPOS64_T;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||
#ifndef MAXU32
|
||||
#define MAXU32 (0xffffffff)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -137,19 +133,15 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
/* Workaround for modified zconf.h on Gentoo system. */
|
||||
#if defined(_Z_OF)
|
||||
#define OF _Z_OF
|
||||
#endif
|
||||
|
||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
|
||||
typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
|
||||
typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
|
||||
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
|
||||
typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
|
||||
|
||||
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
|
||||
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
|
||||
|
||||
|
||||
/* here is the "old" 32 bits structure structure */
|
||||
@ -165,9 +157,9 @@ typedef struct zlib_filefunc_def_s
|
||||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
|
||||
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
|
||||
typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
|
||||
typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode);
|
||||
|
||||
typedef struct zlib_filefunc64_def_s
|
||||
{
|
||||
@ -181,8 +173,8 @@ typedef struct zlib_filefunc64_def_s
|
||||
voidpf opaque;
|
||||
} zlib_filefunc64_def;
|
||||
|
||||
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
|
||||
|
||||
/* now internal definition, only for zip.c and unzip.h */
|
||||
typedef struct zlib_filefunc64_32_def_s
|
||||
@ -196,16 +188,16 @@ typedef struct zlib_filefunc64_32_def_s
|
||||
|
||||
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||
/* #define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) */
|
||||
/* #define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) */
|
||||
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
|
||||
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
|
||||
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
|
||||
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
|
||||
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
|
||||
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
|
||||
long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
|
||||
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
|
||||
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
|
||||
|
||||
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
|
||||
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
|
||||
|
74
third_party/minizip/iowin32.c
vendored
74
third_party/minizip/iowin32.c
vendored
@ -26,14 +26,17 @@
|
||||
#endif
|
||||
|
||||
|
||||
// see Include/shared/winapifamily.h in the Windows Kit
|
||||
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
|
||||
long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
|
||||
int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
|
||||
#if !defined(WINAPI_FAMILY_ONE_PARTITION)
|
||||
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)
|
||||
#endif
|
||||
|
||||
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
|
||||
#define IOWIN32_USING_WINRT_API 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -46,8 +49,7 @@ static void win32_translate_open_mode(int mode,
|
||||
DWORD* lpdwDesiredAccess,
|
||||
DWORD* lpdwCreationDisposition,
|
||||
DWORD* lpdwShareMode,
|
||||
DWORD* lpdwFlagsAndAttributes)
|
||||
{
|
||||
DWORD* lpdwFlagsAndAttributes) {
|
||||
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
|
||||
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
@ -68,8 +70,7 @@ static void win32_translate_open_mode(int mode,
|
||||
}
|
||||
}
|
||||
|
||||
static voidpf win32_build_iowin(HANDLE hFile)
|
||||
{
|
||||
static voidpf win32_build_iowin(HANDLE hFile) {
|
||||
voidpf ret=NULL;
|
||||
|
||||
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
|
||||
@ -87,8 +88,7 @@ static voidpf win32_build_iowin(HANDLE hFile)
|
||||
return ret;
|
||||
}
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
@ -116,8 +116,7 @@ voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
@ -140,8 +139,7 @@ voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
@ -160,8 +158,7 @@ voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
|
||||
{
|
||||
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
@ -189,8 +186,7 @@ voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mo
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
|
||||
{
|
||||
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
@ -211,8 +207,7 @@ uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uL
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
|
||||
{
|
||||
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
@ -232,8 +227,7 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b
|
||||
return ret;
|
||||
}
|
||||
|
||||
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
|
||||
{
|
||||
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) {
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
|
||||
#else
|
||||
@ -252,8 +246,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
|
||||
#endif
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
|
||||
{
|
||||
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
|
||||
long ret=-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
@ -275,8 +268,7 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
|
||||
ZPOS64_T ret= (ZPOS64_T)-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
@ -300,8 +292,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
|
||||
}
|
||||
|
||||
|
||||
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
|
||||
{
|
||||
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
@ -338,8 +329,7 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
|
||||
{
|
||||
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
long ret=-1;
|
||||
@ -377,8 +367,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret=-1;
|
||||
|
||||
if (stream!=NULL)
|
||||
@ -395,8 +384,7 @@ int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
|
||||
{
|
||||
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
|
||||
int ret=-1;
|
||||
if (stream!=NULL)
|
||||
{
|
||||
@ -405,8 +393,7 @@ int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
{
|
||||
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen_file = win32_open_file_func;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
@ -417,8 +404,7 @@ void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
@ -430,8 +416,7 @@ void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
@ -443,8 +428,7 @@ void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) {
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
|
8
third_party/minizip/iowin32.h
vendored
8
third_party/minizip/iowin32.h
vendored
@ -18,10 +18,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
85
third_party/minizip/miniunz.c
vendored
85
third_party/minizip/miniunz.c
vendored
@ -27,7 +27,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
@ -45,6 +45,7 @@
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
@ -80,11 +81,7 @@
|
||||
filename : the filename of the file where date/time must be modified
|
||||
dosdate : the new date at the MSDos format (4 bytes)
|
||||
tmu_date : the SAME new date at the tm_unz format */
|
||||
void change_file_date(filename,dosdate,tmu_date)
|
||||
const char *filename;
|
||||
uLong dosdate;
|
||||
tm_unz tmu_date;
|
||||
{
|
||||
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
|
||||
#ifdef _WIN32
|
||||
HANDLE hFile;
|
||||
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
|
||||
@ -97,7 +94,8 @@ void change_file_date(filename,dosdate,tmu_date)
|
||||
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
|
||||
CloseHandle(hFile);
|
||||
#else
|
||||
#ifdef unix || __APPLE__
|
||||
#if defined(unix) || defined(__APPLE__)
|
||||
(void)dosdate;
|
||||
struct utimbuf ut;
|
||||
struct tm newdate;
|
||||
newdate.tm_sec = tmu_date.tm_sec;
|
||||
@ -113,6 +111,10 @@ void change_file_date(filename,dosdate,tmu_date)
|
||||
|
||||
ut.actime=ut.modtime=mktime(&newdate);
|
||||
utime(filename,&ut);
|
||||
#else
|
||||
(void)filename;
|
||||
(void)dosdate;
|
||||
(void)tmu_date;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -121,9 +123,7 @@ void change_file_date(filename,dosdate,tmu_date)
|
||||
/* mymkdir and change_file_date are not 100 % portable
|
||||
As I don't know well Unix, I wait feedback for the unix portion */
|
||||
|
||||
int mymkdir(dirname)
|
||||
const char* dirname;
|
||||
{
|
||||
static int mymkdir(const char* dirname) {
|
||||
int ret=0;
|
||||
#ifdef _WIN32
|
||||
ret = _mkdir(dirname);
|
||||
@ -131,18 +131,18 @@ int mymkdir(dirname)
|
||||
ret = mkdir (dirname,0775);
|
||||
#elif __APPLE__
|
||||
ret = mkdir (dirname,0775);
|
||||
#else
|
||||
(void)dirname;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int makedir (newdir)
|
||||
char *newdir;
|
||||
{
|
||||
static int makedir(const char *newdir) {
|
||||
char *buffer ;
|
||||
char *p;
|
||||
int len = (int)strlen(newdir);
|
||||
size_t len = strlen(newdir);
|
||||
|
||||
if (len <= 0)
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
buffer = (char*)malloc(len+1);
|
||||
@ -185,14 +185,12 @@ int makedir (newdir)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void do_banner()
|
||||
{
|
||||
static void do_banner(void) {
|
||||
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
|
||||
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
||||
}
|
||||
|
||||
void do_help()
|
||||
{
|
||||
static void do_help(void) {
|
||||
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
|
||||
" -e Extract without pathname (junk paths)\n" \
|
||||
" -x Extract with pathname\n" \
|
||||
@ -200,11 +198,10 @@ void do_help()
|
||||
" -l list files\n" \
|
||||
" -d directory to extract into\n" \
|
||||
" -o overwrite files without prompting\n" \
|
||||
" -p extract crypted file using password\n\n");
|
||||
" -p extract encrypted file using password\n\n");
|
||||
}
|
||||
|
||||
void Display64BitsSize(ZPOS64_T n, int size_char)
|
||||
{
|
||||
static void Display64BitsSize(ZPOS64_T n, int size_char) {
|
||||
/* to avoid compatibility problem , we do here the conversion */
|
||||
char number[21];
|
||||
int offset=19;
|
||||
@ -231,9 +228,7 @@ void Display64BitsSize(ZPOS64_T n, int size_char)
|
||||
printf("%s",&number[pos_string]);
|
||||
}
|
||||
|
||||
int do_list(uf)
|
||||
unzFile uf;
|
||||
{
|
||||
static int do_list(unzFile uf) {
|
||||
uLong i;
|
||||
unz_global_info64 gi;
|
||||
int err;
|
||||
@ -248,7 +243,7 @@ int do_list(uf)
|
||||
char filename_inzip[256];
|
||||
unz_file_info64 file_info;
|
||||
uLong ratio=0;
|
||||
const char *string_method;
|
||||
const char *string_method = "";
|
||||
char charCrypt=' ';
|
||||
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||
if (err!=UNZ_OK)
|
||||
@ -259,7 +254,7 @@ int do_list(uf)
|
||||
if (file_info.uncompressed_size>0)
|
||||
ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
|
||||
|
||||
/* display a '*' if the file is crypted */
|
||||
/* display a '*' if the file is encrypted */
|
||||
if ((file_info.flag & 1) != 0)
|
||||
charCrypt='*';
|
||||
|
||||
@ -309,12 +304,7 @@ int do_list(uf)
|
||||
}
|
||||
|
||||
|
||||
int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||
unzFile uf;
|
||||
const int* popt_extract_without_path;
|
||||
int* popt_overwrite;
|
||||
const char* password;
|
||||
{
|
||||
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
|
||||
char filename_inzip[256];
|
||||
char* filename_withoutpath;
|
||||
char* p;
|
||||
@ -324,7 +314,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||
uInt size_buf;
|
||||
|
||||
unz_file_info64 file_info;
|
||||
uLong ratio=0;
|
||||
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||
|
||||
if (err!=UNZ_OK)
|
||||
@ -439,7 +428,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||
break;
|
||||
}
|
||||
if (err>0)
|
||||
if (fwrite(buf,err,1,fout)!=1)
|
||||
if (fwrite(buf,(unsigned)err,1,fout)!=1)
|
||||
{
|
||||
printf("error in writing extracted file\n");
|
||||
err=UNZ_ERRNO;
|
||||
@ -472,16 +461,10 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||
}
|
||||
|
||||
|
||||
int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||
unzFile uf;
|
||||
int opt_extract_without_path;
|
||||
int opt_overwrite;
|
||||
const char* password;
|
||||
{
|
||||
static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
|
||||
uLong i;
|
||||
unz_global_info64 gi;
|
||||
int err;
|
||||
FILE* fout=NULL;
|
||||
|
||||
err = unzGetGlobalInfo64(uf,&gi);
|
||||
if (err!=UNZ_OK)
|
||||
@ -508,14 +491,7 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
|
||||
unzFile uf;
|
||||
const char* filename;
|
||||
int opt_extract_without_path;
|
||||
int opt_overwrite;
|
||||
const char* password;
|
||||
{
|
||||
int err = UNZ_OK;
|
||||
static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
|
||||
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
|
||||
{
|
||||
printf("file %s not found in the zipfile\n",filename);
|
||||
@ -531,10 +507,7 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo
|
||||
}
|
||||
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
const char *zipfilename=NULL;
|
||||
const char *filename_to_extract=NULL;
|
||||
const char *password=NULL;
|
||||
@ -565,7 +538,7 @@ int main(argc,argv)
|
||||
|
||||
while ((*p)!='\0')
|
||||
{
|
||||
char c=*(p++);;
|
||||
char c=*(p++);
|
||||
if ((c=='l') || (c=='L'))
|
||||
opt_do_list = 1;
|
||||
if ((c=='v') || (c=='V'))
|
||||
@ -607,7 +580,7 @@ int main(argc,argv)
|
||||
# endif
|
||||
|
||||
strncpy(filename_try, zipfilename,MAXFILENAME-1);
|
||||
/* strncpy doesnt append the trailing NULL, of the string is too long. */
|
||||
/* strncpy doesn't append the trailing NULL, of the string is too long. */
|
||||
filename_try[ MAXFILENAME ] = '\0';
|
||||
|
||||
# ifdef USEWIN32IOAPI
|
||||
|
87
third_party/minizip/minizip.c
vendored
87
third_party/minizip/minizip.c
vendored
@ -28,7 +28,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
@ -71,11 +71,9 @@
|
||||
#define MAXFILENAME (256)
|
||||
|
||||
#ifdef _WIN32
|
||||
uLong filetime(f, tmzip, dt)
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
uLong *dt; /* dostime */
|
||||
{
|
||||
/* f: name of file to get info on, tmzip: return value: access,
|
||||
modification and creation times, dt: dostime */
|
||||
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
int ret = 0;
|
||||
{
|
||||
FILETIME ftLocal;
|
||||
@ -94,12 +92,11 @@ uLong filetime(f, tmzip, dt)
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#ifdef unix || __APPLE__
|
||||
uLong filetime(f, tmzip, dt)
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
uLong *dt; /* dostime */
|
||||
{
|
||||
#if defined(unix) || defined(__APPLE__)
|
||||
/* f: name of file to get info on, tmzip: return value: access,
|
||||
modification and creation times, dt: dostime */
|
||||
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
(void)dt;
|
||||
int ret=0;
|
||||
struct stat s; /* results of stat() */
|
||||
struct tm* filedate;
|
||||
@ -108,12 +105,12 @@ uLong filetime(f, tmzip, dt)
|
||||
if (strcmp(f,"-")!=0)
|
||||
{
|
||||
char name[MAXFILENAME+1];
|
||||
int len = strlen(f);
|
||||
size_t len = strlen(f);
|
||||
if (len > MAXFILENAME)
|
||||
len = MAXFILENAME;
|
||||
|
||||
strncpy(name, f,MAXFILENAME-1);
|
||||
/* strncpy doesnt append the trailing NULL, of the string is too long. */
|
||||
/* strncpy doesn't append the trailing NULL, of the string is too long. */
|
||||
name[ MAXFILENAME ] = '\0';
|
||||
|
||||
if (name[len - 1] == '/')
|
||||
@ -137,11 +134,12 @@ uLong filetime(f, tmzip, dt)
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
uLong filetime(f, tmzip, dt)
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
uLong *dt; /* dostime */
|
||||
{
|
||||
/* f: name of file to get info on, tmzip: return value: access,
|
||||
modification and creation times, dt: dostime */
|
||||
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
(void)f;
|
||||
(void)tmzip;
|
||||
(void)dt;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -150,9 +148,7 @@ uLong filetime(f, tmzip, dt)
|
||||
|
||||
|
||||
|
||||
int check_exist_file(filename)
|
||||
const char* filename;
|
||||
{
|
||||
static int check_exist_file(const char* filename) {
|
||||
FILE* ftestexist;
|
||||
int ret = 1;
|
||||
ftestexist = FOPEN_FUNC(filename,"rb");
|
||||
@ -163,14 +159,12 @@ int check_exist_file(filename)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void do_banner()
|
||||
{
|
||||
static void do_banner(void) {
|
||||
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
|
||||
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
|
||||
}
|
||||
|
||||
void do_help()
|
||||
{
|
||||
static void do_help(void) {
|
||||
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
|
||||
" -o Overwrite existing file.zip\n" \
|
||||
" -a Append to existing file.zip\n" \
|
||||
@ -182,14 +176,13 @@ void do_help()
|
||||
|
||||
/* calculate the CRC32 of a file,
|
||||
because to encrypt a file, we need known the CRC32 of the file before */
|
||||
int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
|
||||
{
|
||||
static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) {
|
||||
unsigned long calculate_crc=0;
|
||||
int err=ZIP_OK;
|
||||
FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
|
||||
|
||||
unsigned long size_read = 0;
|
||||
unsigned long total_read = 0;
|
||||
/* unsigned long total_read = 0; */
|
||||
if (fin==NULL)
|
||||
{
|
||||
err = ZIP_ERRNO;
|
||||
@ -199,7 +192,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||
do
|
||||
{
|
||||
err = ZIP_OK;
|
||||
size_read = (int)fread(buf,1,size_buf,fin);
|
||||
size_read = fread(buf,1,size_buf,fin);
|
||||
if (size_read < size_buf)
|
||||
if (feof(fin)==0)
|
||||
{
|
||||
@ -208,8 +201,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||
}
|
||||
|
||||
if (size_read>0)
|
||||
calculate_crc = crc32(calculate_crc,buf,size_read);
|
||||
total_read += size_read;
|
||||
calculate_crc = crc32_z(calculate_crc,buf,size_read);
|
||||
/* total_read += size_read; */
|
||||
|
||||
} while ((err == ZIP_OK) && (size_read>0));
|
||||
|
||||
@ -221,18 +214,17 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||
return err;
|
||||
}
|
||||
|
||||
int isLargeFile(const char* filename)
|
||||
{
|
||||
static int isLargeFile(const char* filename) {
|
||||
int largeFile = 0;
|
||||
ZPOS64_T pos = 0;
|
||||
FILE* pFile = FOPEN_FUNC(filename, "rb");
|
||||
|
||||
if(pFile != NULL)
|
||||
{
|
||||
int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||
pos = FTELLO_FUNC(pFile);
|
||||
FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
|
||||
|
||||
printf("File : %s is %lld bytes\n", filename, pos);
|
||||
printf("File : %s is %llu bytes\n", filename, pos);
|
||||
|
||||
if(pos >= 0xffffffff)
|
||||
largeFile = 1;
|
||||
@ -243,10 +235,7 @@ int isLargeFile(const char* filename)
|
||||
return largeFile;
|
||||
}
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
int opt_overwrite=0;
|
||||
int opt_compress_level=Z_DEFAULT_COMPRESSION;
|
||||
@ -255,7 +244,7 @@ int main(argc,argv)
|
||||
char filename_try[MAXFILENAME+16];
|
||||
int zipok;
|
||||
int err=0;
|
||||
int size_buf=0;
|
||||
size_t size_buf=0;
|
||||
void* buf=NULL;
|
||||
const char* password=NULL;
|
||||
|
||||
@ -276,7 +265,7 @@ int main(argc,argv)
|
||||
|
||||
while ((*p)!='\0')
|
||||
{
|
||||
char c=*(p++);;
|
||||
char c=*(p++);
|
||||
if ((c=='o') || (c=='O'))
|
||||
opt_overwrite = 1;
|
||||
if ((c=='a') || (c=='A'))
|
||||
@ -322,7 +311,7 @@ int main(argc,argv)
|
||||
|
||||
zipok = 1 ;
|
||||
strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
|
||||
/* strncpy doesnt append the trailing NULL, of the string is too long. */
|
||||
/* strncpy doesn't append the trailing NULL, of the string is too long. */
|
||||
filename_try[ MAXFILENAME ] = '\0';
|
||||
|
||||
len=(int)strlen(filename_try);
|
||||
@ -392,11 +381,11 @@ int main(argc,argv)
|
||||
((argv[i][1]=='o') || (argv[i][1]=='O') ||
|
||||
(argv[i][1]=='a') || (argv[i][1]=='A') ||
|
||||
(argv[i][1]=='p') || (argv[i][1]=='P') ||
|
||||
((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
|
||||
((argv[i][1]>='0') && (argv[i][1]<='9'))) &&
|
||||
(strlen(argv[i]) == 2)))
|
||||
{
|
||||
FILE * fin;
|
||||
int size_read;
|
||||
FILE * fin = NULL;
|
||||
size_t size_read;
|
||||
const char* filenameinzip = argv[i];
|
||||
const char *savefilenameinzip;
|
||||
zip_fileinfo zi;
|
||||
@ -472,7 +461,7 @@ int main(argc,argv)
|
||||
do
|
||||
{
|
||||
err = ZIP_OK;
|
||||
size_read = (int)fread(buf,1,size_buf,fin);
|
||||
size_read = fread(buf,1,size_buf,fin);
|
||||
if (size_read < size_buf)
|
||||
if (feof(fin)==0)
|
||||
{
|
||||
@ -482,7 +471,7 @@ int main(argc,argv)
|
||||
|
||||
if (size_read>0)
|
||||
{
|
||||
err = zipWriteInFileInZip (zf,buf,size_read);
|
||||
err = zipWriteInFileInZip (zf,buf,(unsigned)size_read);
|
||||
if (err<0)
|
||||
{
|
||||
printf("error in writing %s in the zipfile\n",
|
||||
|
8
third_party/minizip/mztools.c
vendored
8
third_party/minizip/mztools.c
vendored
@ -27,13 +27,7 @@
|
||||
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
|
||||
} while(0)
|
||||
|
||||
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
|
||||
const char* file;
|
||||
const char* fileOut;
|
||||
const char* fileOutTmp;
|
||||
uLong* nRecovered;
|
||||
uLong* bytesRecovered;
|
||||
{
|
||||
extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
|
||||
int err = Z_OK;
|
||||
FILE* fpZip = fopen(file, "rb");
|
||||
FILE* fpOut = fopen(fileOut, "wb");
|
||||
|
548
third_party/minizip/unzip.c
vendored
548
third_party/minizip/unzip.c
vendored
File diff suppressed because it is too large
Load Diff
146
third_party/minizip/unzip.h
vendored
146
third_party/minizip/unzip.h
vendored
@ -83,12 +83,12 @@ typedef voidp unzFile;
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
int tm_sec; /* seconds after the minute - [0,59] */
|
||||
int tm_min; /* minutes after the hour - [0,59] */
|
||||
int tm_hour; /* hours since midnight - [0,23] */
|
||||
int tm_mday; /* day of the month - [1,31] */
|
||||
int tm_mon; /* months since January - [0,11] */
|
||||
int tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
@ -150,21 +150,21 @@ typedef struct unz_file_info_s
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
extern int ZEXPORT unzStringFileNameCompare(const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity);
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
Compare two filenames (fileName1,fileName2).
|
||||
If iCaseSensitivity = 1, comparison is case sensitive (like strcmp)
|
||||
If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
If iCaseSensitivity = 0, case sensitivity is default of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
||||
extern unzFile ZEXPORT unzOpen(const char *path);
|
||||
extern unzFile ZEXPORT unzOpen64(const void *path);
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
@ -181,41 +181,41 @@ extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
extern unzFile ZEXPORT unzOpen2(const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def);
|
||||
/*
|
||||
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
extern unzFile ZEXPORT unzOpen2_64(const void *path,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
/*
|
||||
Open a Zip file, like unz64Open, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
extern int ZEXPORT unzClose(unzFile file);
|
||||
/*
|
||||
Close a ZipFile opened with unzOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzCloseCurrentFile before call unzClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
extern int ZEXPORT unzGetGlobalInfo(unzFile file,
|
||||
unz_global_info *pglobal_info);
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
|
||||
unz_global_info64 *pglobal_info));
|
||||
extern int ZEXPORT unzGetGlobalInfo64(unzFile file,
|
||||
unz_global_info64 *pglobal_info);
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
extern int ZEXPORT unzGetGlobalComment(unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf);
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
@ -226,22 +226,22 @@ extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
extern int ZEXPORT unzGoToFirstFile(unzFile file);
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
extern int ZEXPORT unzGoToNextFile(unzFile file);
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
extern int ZEXPORT unzLocateFile(unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity);
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
@ -285,26 +285,26 @@ extern int ZEXPORT unzGoToFilePos64(
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
|
||||
unz_file_info64 *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file,
|
||||
unz_file_info64 *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize);
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize);
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain some info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
@ -318,7 +318,7 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
|
||||
/** Addition for GDAL : START */
|
||||
|
||||
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
|
||||
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
|
||||
|
||||
/** Addition for GDAL : END */
|
||||
|
||||
@ -328,24 +328,24 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
extern int ZEXPORT unzOpenCurrentFile(unzFile file);
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||
const char* password));
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file,
|
||||
const char* password);
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw));
|
||||
extern int ZEXPORT unzOpenCurrentFile2(unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw);
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
@ -355,11 +355,11 @@ extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password));
|
||||
extern int ZEXPORT unzOpenCurrentFile3(unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password);
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
@ -370,41 +370,41 @@ extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
extern int ZEXPORT unzCloseCurrentFile(unzFile file);
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
extern int ZEXPORT unzReadCurrentFile(unzFile file,
|
||||
voidp buf,
|
||||
unsigned len);
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return the number of byte copied if some bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
extern z_off_t ZEXPORT unztell(unzFile file);
|
||||
|
||||
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
|
||||
extern ZPOS64_T ZEXPORT unztell64(unzFile file);
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
extern int ZEXPORT unzeof(unzFile file);
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
extern int ZEXPORT unzGetLocalExtrafield(unzFile file,
|
||||
voidp buf,
|
||||
unsigned len);
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
|
372
third_party/minizip/zip.c
vendored
372
third_party/minizip/zip.c
vendored
@ -14,8 +14,8 @@
|
||||
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 - 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.
|
||||
ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed.
|
||||
It is used when recreating zip archive with RAW when deleting items from a zip.
|
||||
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)
|
||||
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
|
||||
|
||||
@ -25,14 +25,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include "zlib.h"
|
||||
#include "zip.h"
|
||||
|
||||
#ifdef STDC
|
||||
# include <stddef.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef NO_ERRNO_H
|
||||
extern int errno;
|
||||
@ -47,7 +46,7 @@
|
||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||
|
||||
#ifndef VERSIONMADEBY
|
||||
# define VERSIONMADEBY (0x0) /* platform depedent */
|
||||
# define VERSIONMADEBY (0x0) /* platform dependent */
|
||||
#endif
|
||||
|
||||
#ifndef Z_BUFSIZE
|
||||
@ -61,9 +60,6 @@
|
||||
#ifndef ALLOC
|
||||
# define ALLOC(size) (malloc(size))
|
||||
#endif
|
||||
#ifndef TRYFREE
|
||||
# define TRYFREE(p) {if (p) free(p);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
#define SIZECENTRALDIRITEM (0x2e)
|
||||
@ -116,7 +112,7 @@ typedef struct linkedlist_datablock_internal_s
|
||||
struct linkedlist_datablock_internal_s* next_datablock;
|
||||
uLong avail_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];
|
||||
} linkedlist_datablock_internal;
|
||||
|
||||
@ -138,40 +134,40 @@ typedef struct
|
||||
uInt pos_in_buffered_data; /* last written byte in buffered_data */
|
||||
|
||||
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 */
|
||||
uLong size_centralExtra;
|
||||
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 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 */
|
||||
Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
|
||||
uLong dosDate;
|
||||
uLong crc32;
|
||||
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 totalCompressedData;
|
||||
ZPOS64_T totalUncompressedData;
|
||||
#ifndef NOCRYPT
|
||||
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
||||
const z_crc_t* pcrc_32_tab;
|
||||
int crypt_header_size;
|
||||
unsigned crypt_header_size;
|
||||
#endif
|
||||
} curfile64_info;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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*/
|
||||
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 add_position_when_writting_offset;
|
||||
ZPOS64_T add_position_when_writing_offset;
|
||||
ZPOS64_T number_entry;
|
||||
|
||||
#ifndef NO_ADDFILEINEXISTINGZIP
|
||||
@ -186,8 +182,7 @@ typedef struct
|
||||
#include "crypt.h"
|
||||
#endif
|
||||
|
||||
local linkedlist_datablock_internal* allocate_new_datablock(void)
|
||||
{
|
||||
local linkedlist_datablock_internal* allocate_new_datablock(void) {
|
||||
linkedlist_datablock_internal* ldi;
|
||||
ldi = (linkedlist_datablock_internal*)
|
||||
ALLOC(sizeof(linkedlist_datablock_internal));
|
||||
@ -200,30 +195,26 @@ local linkedlist_datablock_internal* allocate_new_datablock(void)
|
||||
return ldi;
|
||||
}
|
||||
|
||||
local void free_datablock(linkedlist_datablock_internal* ldi)
|
||||
{
|
||||
local void free_datablock(linkedlist_datablock_internal* ldi) {
|
||||
while (ldi!=NULL)
|
||||
{
|
||||
linkedlist_datablock_internal* ldinext = ldi->next_datablock;
|
||||
TRYFREE(ldi);
|
||||
free(ldi);
|
||||
ldi = ldinext;
|
||||
}
|
||||
}
|
||||
|
||||
local void init_linkedlist(linkedlist_data* ll)
|
||||
{
|
||||
local void init_linkedlist(linkedlist_data* ll) {
|
||||
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);
|
||||
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;
|
||||
const unsigned char* from_copy;
|
||||
|
||||
@ -238,7 +229,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
|
||||
}
|
||||
|
||||
ldi = ll->last_block;
|
||||
from_copy = (unsigned char*)buf;
|
||||
from_copy = (const unsigned char*)buf;
|
||||
|
||||
while (len>0)
|
||||
{
|
||||
@ -283,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)
|
||||
*/
|
||||
|
||||
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];
|
||||
int n;
|
||||
for (n = 0; n < nbByte; n++)
|
||||
@ -301,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;
|
||||
else
|
||||
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;
|
||||
int n;
|
||||
for (n = 0; n < nbByte; n++) {
|
||||
@ -329,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;
|
||||
if (year>=1980)
|
||||
year-=1980;
|
||||
else if (year>=80)
|
||||
year-=80;
|
||||
return
|
||||
(uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
|
||||
((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
|
||||
(uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) |
|
||||
(((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;
|
||||
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
|
||||
if (err==1)
|
||||
@ -368,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
|
||||
*/
|
||||
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 ;
|
||||
int i = 0;
|
||||
int err;
|
||||
@ -390,10 +370,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
||||
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 ;
|
||||
int i = 0;
|
||||
int err;
|
||||
@ -420,11 +397,8 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
||||
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;
|
||||
int i = 0;
|
||||
int err;
|
||||
@ -475,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
|
||||
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;
|
||||
ZPOS64_T uSizeFile;
|
||||
ZPOS64_T uBackRead;
|
||||
@ -519,19 +490,17 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
|
||||
break;
|
||||
|
||||
for (i=(int)uReadSize-3; (i--)>0;)
|
||||
{
|
||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||
{
|
||||
uPosFound = uReadPos+i;
|
||||
uPosFound = uReadPos+(unsigned)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (uPosFound!=0)
|
||||
break;
|
||||
if (uPosFound!=0)
|
||||
break;
|
||||
}
|
||||
TRYFREE(buf);
|
||||
free(buf);
|
||||
return uPosFound;
|
||||
}
|
||||
|
||||
@ -539,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
|
||||
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;
|
||||
ZPOS64_T uSizeFile;
|
||||
ZPOS64_T uBackRead;
|
||||
@ -588,7 +554,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||
// Signature "0x07064b50" Zip64 end of central directory locater
|
||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
||||
{
|
||||
uPosFound = uReadPos+i;
|
||||
uPosFound = uReadPos+(unsigned)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -597,7 +563,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||
break;
|
||||
}
|
||||
|
||||
TRYFREE(buf);
|
||||
free(buf);
|
||||
if (uPosFound == 0)
|
||||
return 0;
|
||||
|
||||
@ -639,8 +605,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||
return relativeOffset;
|
||||
}
|
||||
|
||||
int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
{
|
||||
local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
|
||||
int err=ZIP_OK;
|
||||
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
||||
|
||||
@ -650,9 +615,9 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
uLong uL;
|
||||
|
||||
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
|
||||
for spaning ZIP, unsupported, always 0*/
|
||||
for spanning ZIP, unsupported, always 0*/
|
||||
ZPOS64_T number_entry;
|
||||
ZPOS64_T number_entry_CD; /* total number of entries in
|
||||
the central dir
|
||||
@ -809,7 +774,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
}
|
||||
|
||||
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;
|
||||
@ -832,7 +797,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
|
||||
size_central_dir_to_read-=read_this;
|
||||
}
|
||||
TRYFREE(buf_read);
|
||||
free(buf_read);
|
||||
}
|
||||
pziinit->begin_pos = byte_before_the_zipfile;
|
||||
pziinit->number_entry = number_entry_CD;
|
||||
@ -848,8 +813,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
|
||||
|
||||
/************************************************************/
|
||||
extern zipFile ZEXPORT 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* zi;
|
||||
int err=ZIP_OK;
|
||||
@ -877,7 +841,7 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
|
||||
ziinit.in_opened_file_inzip = 0;
|
||||
ziinit.ci.stream_initialised = 0;
|
||||
ziinit.number_entry = 0;
|
||||
ziinit.add_position_when_writting_offset = 0;
|
||||
ziinit.add_position_when_writing_offset = 0;
|
||||
init_linkedlist(&(ziinit.central_dir));
|
||||
|
||||
|
||||
@ -907,9 +871,9 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
|
||||
if (err != ZIP_OK)
|
||||
{
|
||||
# ifndef NO_ADDFILEINEXISTINGZIP
|
||||
TRYFREE(ziinit.globalcomment);
|
||||
free(ziinit.globalcomment);
|
||||
# endif /* !NO_ADDFILEINEXISTINGZIP*/
|
||||
TRYFREE(zi);
|
||||
free(zi);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
@ -919,8 +883,7 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
|
||||
@ -931,8 +894,7 @@ extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* gl
|
||||
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)
|
||||
{
|
||||
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
|
||||
@ -947,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);
|
||||
}
|
||||
|
||||
extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append)
|
||||
{
|
||||
extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) {
|
||||
return zipOpen3(pathname,append,NULL,NULL);
|
||||
}
|
||||
|
||||
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 */
|
||||
int err;
|
||||
uInt size_filename = (uInt)strlen(filename);
|
||||
@ -1036,8 +995,8 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
|
||||
// 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);
|
||||
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);
|
||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,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)CompressedSize,8);
|
||||
@ -1054,14 +1013,13 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
|
||||
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.
|
||||
*/
|
||||
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_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase, int zip64)
|
||||
{
|
||||
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_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase, int zip64) {
|
||||
zip64_internal* zi;
|
||||
uInt size_filename;
|
||||
uInt size_comment;
|
||||
@ -1069,7 +1027,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
|
||||
int err = ZIP_OK;
|
||||
|
||||
# ifdef NOCRYPT
|
||||
(void)(crcForCrypting);
|
||||
(crcForCrypting);
|
||||
if (password != NULL)
|
||||
return ZIP_PARAMERROR;
|
||||
# endif
|
||||
@ -1166,7 +1124,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
|
||||
if(zi->ci.pos_local_header >= 0xffffffff)
|
||||
zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4);
|
||||
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++)
|
||||
*(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
|
||||
@ -1264,35 +1222,33 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
|
||||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, versionMadeBy, flagBase, 0);
|
||||
extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting,
|
||||
uLong versionMadeBy, uLong flagBase) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, versionMadeBy, flagBase, 0);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, 0);
|
||||
extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, 0);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
@ -1300,70 +1256,64 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw,
|
||||
int windowBits,int memLevel, int strategy,
|
||||
const char* password, uLong crcForCrypting, int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, zip64);
|
||||
const char* password, uLong crcForCrypting, int zip64) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0, zip64);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
const char* comment, int method, int level, int raw) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
}
|
||||
|
||||
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_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw, int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void* extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int raw, int zip64) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level, int zip64) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, zip64);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local, uInt size_extrafield_local,
|
||||
const void*extrafield_global, uInt size_extrafield_global,
|
||||
const char* comment, int method, int level) {
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0, 0);
|
||||
}
|
||||
|
||||
local int zip64FlushWriteBuffer(zip64_internal* zi)
|
||||
{
|
||||
local int zip64FlushWriteBuffer(zip64_internal* zi) {
|
||||
int err=ZIP_OK;
|
||||
|
||||
if (zi->ci.encrypt != 0)
|
||||
@ -1401,8 +1351,7 @@ local int zip64FlushWriteBuffer(zip64_internal* zi)
|
||||
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;
|
||||
int err=ZIP_OK;
|
||||
|
||||
@ -1452,7 +1401,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
||||
else
|
||||
#endif
|
||||
{
|
||||
zi->ci.stream.next_in = (Bytef*)buf;
|
||||
zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf;
|
||||
zi->ci.stream.avail_in = len;
|
||||
|
||||
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
||||
@ -1473,11 +1422,6 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
||||
{
|
||||
uLong uTotalOutBefore = zi->ci.stream.total_out;
|
||||
err=deflate(&zi->ci.stream, Z_NO_FLUSH);
|
||||
if(uTotalOutBefore > zi->ci.stream.total_out)
|
||||
{
|
||||
int bBreak = 0;
|
||||
bBreak++;
|
||||
}
|
||||
|
||||
zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
|
||||
}
|
||||
@ -1508,17 +1452,15 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
ZPOS64_T compressed_size;
|
||||
uLong invalidValue = 0xffffffff;
|
||||
short datasize = 0;
|
||||
unsigned datasize = 0;
|
||||
int err=ZIP_OK;
|
||||
|
||||
if (file == NULL)
|
||||
@ -1749,15 +1691,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
|
||||
return err;
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip (zipFile file)
|
||||
{
|
||||
extern int ZEXPORT zipCloseFileInZip(zipFile file) {
|
||||
return zipCloseFileInZipRaw (file,0,0);
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
|
||||
@ -1776,8 +1716,7 @@ int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo
|
||||
return err;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
uLong Zip64DataSize = 44;
|
||||
@ -1810,13 +1749,13 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
|
||||
|
||||
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);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
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;
|
||||
|
||||
/*signature*/
|
||||
@ -1851,20 +1790,19 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir,
|
||||
|
||||
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)
|
||||
{
|
||||
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
uInt size_global_comment = 0;
|
||||
|
||||
@ -1881,8 +1819,7 @@ int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
||||
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;
|
||||
int err = 0;
|
||||
uLong size_centraldir = 0;
|
||||
@ -1923,7 +1860,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
|
||||
}
|
||||
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)
|
||||
{
|
||||
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
|
||||
@ -1943,15 +1880,14 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
|
||||
err = ZIP_ERRNO;
|
||||
|
||||
#ifndef NO_ADDFILEINEXISTINGZIP
|
||||
TRYFREE(zi->globalcomment);
|
||||
free(zi->globalcomment);
|
||||
#endif
|
||||
TRYFREE(zi);
|
||||
free(zi);
|
||||
|
||||
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;
|
||||
int size = 0;
|
||||
char* pNewHeader;
|
||||
@ -1961,10 +1897,10 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
|
||||
|
||||
int retVal = ZIP_OK;
|
||||
|
||||
if(pData == NULL || *dataLen < 4)
|
||||
if(pData == NULL || dataLen == NULL || *dataLen < 4)
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
pNewHeader = (char*)ALLOC(*dataLen);
|
||||
pNewHeader = (char*)ALLOC((unsigned)*dataLen);
|
||||
pTmp = pNewHeader;
|
||||
|
||||
while(p < (pData + *dataLen))
|
||||
@ -2003,7 +1939,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
|
||||
else
|
||||
retVal = ZIP_ERRNO;
|
||||
|
||||
TRYFREE(pNewHeader);
|
||||
free(pNewHeader);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
307
third_party/minizip/zip.h
vendored
307
third_party/minizip/zip.h
vendored
@ -37,11 +37,6 @@
|
||||
|
||||
*/
|
||||
|
||||
/* Pragma added by libxlsxwriter to avoid warnings with -pedantic -ansi. */
|
||||
#ifndef _WIN32
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef _zip12_H
|
||||
#define _zip12_H
|
||||
|
||||
@ -49,7 +44,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* #define HAVE_BZIP2 */
|
||||
//#define HAVE_BZIP2
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
@ -59,14 +54,6 @@ extern "C" {
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
/* Encryption not required by libxlsxwriter. */
|
||||
#ifndef NOCRYPT
|
||||
#define NOCRYPT
|
||||
#endif
|
||||
#ifndef NOUNCRYPT
|
||||
#define NOUNCRYPT
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BZIP2
|
||||
#include "bzlib.h"
|
||||
#endif
|
||||
@ -101,12 +88,12 @@ typedef voidp zipFile;
|
||||
/* tm_zip contain date/time info */
|
||||
typedef struct tm_zip_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
int tm_sec; /* seconds after the minute - [0,59] */
|
||||
int tm_min; /* minutes after the hour - [0,59] */
|
||||
int tm_hour; /* hours since midnight - [0,23] */
|
||||
int tm_mday; /* day of the month - [1,31] */
|
||||
int tm_mon; /* months since January - [0,11] */
|
||||
int tm_year; /* years - [1980..2044] */
|
||||
} tm_zip;
|
||||
|
||||
typedef struct
|
||||
@ -126,8 +113,8 @@ typedef const char* zipcharpc;
|
||||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
|
||||
extern zipFile ZEXPORT zipOpen(const char *pathname, int append);
|
||||
extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
|
||||
/*
|
||||
Create a zipfile.
|
||||
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
|
||||
@ -144,41 +131,46 @@ extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
|
||||
|
||||
/* 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
|
||||
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,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
zlib_filefunc64_def* pzlib_filefunc_def);
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
extern zipFile ZEXPORT zipOpen3(const void *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc64_32_def* pzlib_filefunc64_32_def);
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level));
|
||||
extern int ZEXPORT zipOpenNewFileInZip(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level);
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int zip64));
|
||||
extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int zip64);
|
||||
|
||||
/*
|
||||
Open a file in the ZIP for writing.
|
||||
@ -197,70 +189,69 @@ extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw));
|
||||
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw);
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int zip64));
|
||||
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_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int zip64);
|
||||
/*
|
||||
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting));
|
||||
extern int ZEXPORT zipOpenNewFileInZip3(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting);
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
int zip64
|
||||
));
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
int zip64);
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
@ -269,47 +260,45 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
|
||||
crcForCrypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase
|
||||
));
|
||||
extern int ZEXPORT zipOpenNewFileInZip4(zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase);
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase,
|
||||
int zip64
|
||||
));
|
||||
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_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase,
|
||||
int zip64);
|
||||
/*
|
||||
Same than zipOpenNewFileInZip4, except
|
||||
versionMadeBy : value for Version made by field
|
||||
@ -317,25 +306,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const void* buf,
|
||||
unsigned len));
|
||||
extern int ZEXPORT zipWriteInFileInZip(zipFile file,
|
||||
const void* buf,
|
||||
unsigned len);
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32));
|
||||
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32);
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
|
||||
ZPOS64_T uncompressed_size,
|
||||
uLong crc32));
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
|
||||
ZPOS64_T uncompressed_size,
|
||||
uLong crc32);
|
||||
|
||||
/*
|
||||
Close the current file in the zipfile, for file opened with
|
||||
@ -343,14 +332,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
|
||||
uncompressed_size and crc32 are value for the uncompressed size
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipClose OF((zipFile file,
|
||||
const char* global_comment));
|
||||
extern int ZEXPORT zipClose(zipFile file,
|
||||
const char* global_comment);
|
||||
/*
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user