Commit a4ce93c6 authored by Roy Marmelstein's avatar Roy Marmelstein

Updating minizip

parent fe792d1d
This diff is collapsed.
More changes since 1.1
- Added support for AE-2 zip files
- Fixed error in AE-1 not testing CRC32
Credits
Steven Christy
Changes since 1.1
- Added PKZIP spanning support
- Added AES encryption support
- Added I/O buffering
- Clean up & changed unzLocateFile to support custom comparison function
- Clean up, removed zipRemoveExtraInfoBlock
Credits
Nathan Moinvaziri
Change in 1.1
- Added ZIP64 support for unzip ( by Even Rouault )
- Added ZIP64 support for zip ( by Mathias Svensson )
- Reverted some changed that Even Rouault did.
- Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
- Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
- Added BZIP Compress method for zip
- Did some refactoring and code cleanup
Credits
Gilles Vollant - Original MiniZip author
Even Rouault - ZIP64 unzip Support
2007-2008
- Addition of cpl_unzGetCurrentFileZStreamPos
- Decoration of symbol names unz* -> cpl_unz*
- Remove old C style function prototypes
- Add unzip support for ZIP64
Daniel Borca - BZip Compression method support in unzip
Mathias Svensson - ZIP64 zip support ( http://result42.com )
Oct-2009 unzip.c
- Removed cpl_* from symbol names
- Fixed problem if uncompressed size was > 4G and compressed size was <4G
should only read the compressed/uncompressed size from the Zip64 format if
the size from normal header was 0xffffffff
- Applied some bug fixes from patches received from Gilles Vollant
- Applied support to unzip files with compression method BZIP2 (bzip2 lib is required)
Patch created by Daniel Borca
Oct-2009 zip.c
- Remove old C style function prototypes
- Added Zip64 Support when creating new file archives
- Did some code cleanup and refactoring to get better overview of some functions.
- 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.
- Added support for BZIP2 as compression mode (bzip2 lib is required)
Oct-2009 ioapi.x
- Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux.
- Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
More if/def section may be needed to support other platforms
- Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
(but you should use iowin32.c for windows instead)
Change in 1.01e (12 feb 05)
- Fix in zipOpen2 for globalcomment (Rolf Kalbermatter)
- Fix possible memory leak in unzip.c (Zoran Stevanovic)
Change in 1.01b (20 may 04)
- Integrate patch from Debian package (Mark Brown)
- Add tools mztools from Xavier Roche
Change in 1.01 (8 may 04)
- Fix buffer overrun risk in unzip.c (Xavier Roche)
- Fix a minor buffer insecurity in minizip.c (Mike Whittaker)
Change in 1.00: (10 sept 03)
- Rename to 1.00
- Cosmetic code change
Change in 0.22: (19 May 03)
- Crypting support (unless you define NOCRYPT)
- Append file in existing zipfile
Change in 0.21: (10 Mar 03)
- Bug fixes
Change in 0.17: (27 Jan 02)
- Bug fixes
Change in 0.16: (19 Jan 02)
- Support of ioapi for virtualize zip file access
Change in 0.15: (19 Mar 98)
- Fix memory leak in minizip.c
Change in 0.14: (10 Mar 98)
- Fix bugs in minizip.c sample for zipping big file
- Fix problem in month in date handling
- Fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for comment handling
Change in 0.13: (6 Mar 98)
- Fix bugs in zip.c
- Add real minizip sample
Change in 0.12: (4 Mar 98)
- Add zip.c and zip.h for creates .zip file
- Fix change_file_date in miniunz.c for Unix (Jean-loup Gailly)
- Fix miniunz.c for file without specific record for directory
Change in 0.11: (3 Mar 98)
- Fix bug in unzGetCurrentFileInfo for get extra field and comment
- Enhance miniunz sample, remove the bad unztst.c sample
Change in 0.10: (2 Mar 98)
- Fix bug in unzReadCurrentFile
- Rename unzip* to unz* function and structure
- Remove Windows-like hungary notation variable name
- Modify some structure in unzip.h
- Add somes comment in source
- Remove unzipGetcCurrentFile function
- Replace ZUNZEXPORT by ZEXPORT
- Add unzGetLocalExtrafield for get the local extrafield info
- Add a new sample, miniunz.c
Change in 0.4: (25 Feb 98)
- Suppress the type unzipFileInZip.
Only on file in the zipfile can be open at the same time
- Fix somes typo in code
- Added tm_unz structure in unzip_file_info (date/time in readable format)
Change unknown?
- Added unzGetOffset (RX '2004)
- Added unzGetFilePos & unzGoToFilePos (Ryan Haksi)
- Added unzGetCurrentFileZStreamPos64 (GDAL)
Condition of use and distribution are the same as zlib:
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
\ No newline at end of file
CC=cc
CFLAGS=-O -I../.. -DHAVE_AES
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a libaes.a
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a libaes.a
TEST_FILES = test.zip readme.old readme.txt
.c.o:
$(CC) -c $(CFLAGS) $*.c
all: miniunz minizip
libaes.a:
cd aes; $(MAKE) $(MFLAGS)
miniunz: $(UNZ_OBJS) libaes.a
$(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)
minizip: $(ZIP_OBJS) libaes.a
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
.PHONY: test clean
test: miniunz minizip
@rm -f $(TEST_FILES)
@cp README.md readme.txt
@touch -t 200712301223.44 readme.txt
./minizip test.zip readme.txt
./miniunz -l test.zip
mv readme.txt readme.old
./miniunz test.zip
@diff -q README.md readme.txt || echo "Test failed: files differ"
@[[ "$$(stat -c %Y readme.txt)" = "$$(stat -c %Y readme.old)" ]] || echo "Test failed: timestamp not preserved"
@rm -f $(TEST_FILES)
clean:
/bin/rm -f *.o *~ minizip miniunz $(TEST_FILES)
lib_LTLIBRARIES = libminizip.la
if COND_DEMOS
bin_PROGRAMS = miniunzip minizip
endif
zlib_top_srcdir = $(top_srcdir)/../..
zlib_top_builddir = $(top_builddir)/../..
AM_CPPFLAGS = -I$(zlib_top_srcdir)
AM_LDFLAGS = -L$(zlib_top_builddir)
if WIN32
iowin32_src = iowin32.c
iowin32_h = iowin32.h
endif
libminizip_la_SOURCES = \
ioapi.c \
unzip.c \
zip.c \
${iowin32_src}
libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz
minizip_includedir = $(includedir)/minizip
minizip_include_HEADERS = \
crypt.h \
ioapi.h \
unzip.h \
zip.h \
${iowin32_h}
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = minizip.pc
EXTRA_PROGRAMS = miniunzip minizip
miniunzip_SOURCES = miniunz.c
miniunzip_LDADD = libminizip.la
minizip_SOURCES = minizip.c
minizip_LDADD = libminizip.la -lz
Minizip zlib contribution that includes:
- AES encryption
- I/O buffering
- PKWARE disk spanning
- Visual Studio 2008 project files
It also has the latest bug fixes that having been found all over the internet including the minizip forum and zlib developer's mailing list.
*AES Encryption*
+ Requires #define HAVE_AES
+ Requires AES library files
When zipping with a password it will always use AES 256-bit encryption.
When unzipping it will use AES decryption only if necessary.
*I/O Buffering*
Improves I/O performance by buffering read and write operations.
```
zlib_filefunc64_def filefunc64 = {0};
ourbuffer_t buffered = {0};
fill_win32_filefunc64(&buffered->filefunc64);
fill_buffer_filefunc64(&filefunc64, buffered);
unzOpen2_64(filename, &filefunc64)
```
*PKWARE disk spanning*
To create an archive with multiple disks use zipOpen3_64 supplying a disk_size value in bytes.
```
extern zipFile ZEXPORT zipOpen3_64 OF((const void *pathname, int append,
ZPOS64_T disk_size, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def));
```
The central directory is the only data stored in the .zip and doesn't follow disk_size restrictions.
When unzipping it will automatically determine when in needs to span disks.
*I/O Memory*
To unzip from a zip file in memory use fill_memory_filefunc and supply a proper ourmemory_t structure.
```
zlib_filefunc_def filefunc32 = {0};
ourmemory_t unzmem = {0};
unzmem.size = bufsize;
unzmem.base = (char *)malloc(unzmem.size);
memcpy(unzmem.base, buffer, unzmem.size);
fill_memory_filefunc(&filefunc32, &unzmem);
unzOpen2("__notused__", &filefunc32);
```
To create a zip file in memory use fill_memory_filefunc and supply a proper ourmemory_t structure. It is important
not to forget to free zipmem->base when finished. If grow is set, zipmem->base will expand to fit the size of the zip.
If grow is not set be sure to fill out zipmem.base and zipmem.size.
```
zlib_filefunc_def filefunc32 = {0};
ourmemory_t zipmem = {0};
zipmem.grow = 1;
fill_memory_filefunc(&filefunc32, &zipmem);
zipOpen3("__notused__", APPEND_STATUS_CREATE, 0, 0, &filefunc32);
```
*BZIP2*
+ Requires #define HAVE_BZIP2
+ Requires BZIP2 library
*Windows RT*
+ Requires #define IOWIN32_USING_WINRT_API
CC=cc
CFLAGS=-O -DHAVE_AES
OBJS=aescrypt.o aeskey.o aestab.o entropy.o fileenc.o hmac.o prng.o pwd2key.o sha1.o
ARFLAGS=rv
.c.o:
$(CC) -c $(CFLAGS) $*.c
libaes.a: $(OBJS)
$(ECHO) $(AR) $(ARFLAGS) ../libaes.a $?
$(AR) $(ARFLAGS) ../libaes.a $?
$(RANLIB) ../libaes.a
all: libaes.a
.PHONY: clean
clean:
rm *.o *.a
\ No newline at end of file
...@@ -42,7 +42,7 @@ int entropy_fun(unsigned char buf[], unsigned int len) ...@@ -42,7 +42,7 @@ int entropy_fun(unsigned char buf[], unsigned int len)
int rlen = 0; int rlen = 0;
if (frand != -1) if (frand != -1)
{ {
rlen = (int)read(frand, buf, len); rlen = read(frand, buf, len);
close(frand); close(frand);
} }
return rlen; return rlen;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
using AES in CTR mode, HMAC-SHA1 authentication and RFC2898 password using AES in CTR mode, HMAC-SHA1 authentication and RFC2898 password
based key derivation. based key derivation.
*/ */
#include <memory.h> #include <memory.h>
...@@ -50,14 +50,14 @@ extern "C" ...@@ -50,14 +50,14 @@ extern "C"
/* buffers and using 32 bit operations */ /* buffers and using 32 bit operations */
static void encr_data(unsigned char data[], unsigned long d_len, fcrypt_ctx cx[1]) static void encr_data(unsigned char data[], unsigned long d_len, fcrypt_ctx cx[1])
{ { unsigned long i = 0, pos = cx->encr_pos;
unsigned long i = 0, pos = cx->encr_pos;
while (i < d_len) { while(i < d_len)
if (pos == AES_BLOCK_SIZE) { {
unsigned int j = 0; if(pos == AES_BLOCK_SIZE)
{ unsigned int j = 0;
/* increment encryption nonce */ /* increment encryption nonce */
while (j < 8 && !++cx->nonce[j]) while(j < 8 && !++cx->nonce[j])
++j; ++j;
/* encrypt the nonce to form next xor buffer */ /* encrypt the nonce to form next xor buffer */
aes_encrypt(cx->nonce, cx->encr_bfr, cx->encr_ctx); aes_encrypt(cx->nonce, cx->encr_bfr, cx->encr_ctx);
...@@ -67,7 +67,7 @@ static void encr_data(unsigned char data[], unsigned long d_len, fcrypt_ctx cx[1 ...@@ -67,7 +67,7 @@ static void encr_data(unsigned char data[], unsigned long d_len, fcrypt_ctx cx[1
data[i++] ^= cx->encr_bfr[pos++]; data[i++] ^= cx->encr_bfr[pos++];
} }
cx->encr_pos = (unsigned int)pos; cx->encr_pos = pos;
} }
int fcrypt_init( int fcrypt_init(
...@@ -79,13 +79,12 @@ int fcrypt_init( ...@@ -79,13 +79,12 @@ int fcrypt_init(
unsigned char pwd_ver[PWD_VER_LENGTH], /* 2 byte password verifier (output) */ unsigned char pwd_ver[PWD_VER_LENGTH], /* 2 byte password verifier (output) */
#endif #endif
fcrypt_ctx cx[1]) /* the file encryption context (output) */ fcrypt_ctx cx[1]) /* the file encryption context (output) */
{ { unsigned char kbuf[2 * MAX_KEY_LENGTH + PWD_VER_LENGTH];
unsigned char kbuf[2 * MAX_KEY_LENGTH + PWD_VER_LENGTH];
if (pwd_len > MAX_PWD_LENGTH) if(pwd_len > MAX_PWD_LENGTH)
return PASSWORD_TOO_LONG; return PASSWORD_TOO_LONG;
if (mode < 1 || mode > 3) if(mode < 1 || mode > 3)
return BAD_MODE; return BAD_MODE;
cx->mode = mode; cx->mode = mode;
......
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT([minizip], [1.2.8], [bugzilla.redhat.com])
AC_CONFIG_SRCDIR([minizip.c])
AM_INIT_AUTOMAKE([foreign])
LT_INIT
AC_MSG_CHECKING([whether to build example programs])
AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs]))
AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes])
if test "$enable_demos" = yes
then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
case "${host}" in
*-mingw* | mingw*)
WIN32="yes"
;;
*)
;;
esac
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AC_SUBST([HAVE_UNISTD_H], [0])
AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], [])
AC_CONFIG_FILES([Makefile minizip.pc])
AC_OUTPUT
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
/*********************************************************************** /***********************************************************************
* Return the next byte in the pseudo-random sequence * Return the next byte in the pseudo-random sequence
*/ */
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) static int decrypt_byte(unsigned long* pkeys)
{ {
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem * unpredictable manner on 16-bit systems; not a problem
...@@ -44,7 +44,7 @@ static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) ...@@ -44,7 +44,7 @@ static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
/*********************************************************************** /***********************************************************************
* Update the encryption keys with the next byte of plain text * Update the encryption keys with the next byte of plain text
*/ */
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) static int update_keys(unsigned long* pkeys, const unsigned long* pcrc_32_tab, int c)
{ {
(*(pkeys+0)) = CRC32((*(pkeys+0)), c); (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff; (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
...@@ -61,22 +61,23 @@ static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int ...@@ -61,22 +61,23 @@ static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int
* Initialize the encryption keys and the random header according to * Initialize the encryption keys and the random header according to
* the given password. * the given password.
*/ */
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) static void init_keys(const char* passwd, unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{ {
*(pkeys+0) = 305419896L; *(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L; *(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L; *(pkeys+2) = 878082192L;
while (*passwd != 0) { while (*passwd != 0)
{
update_keys(pkeys,pcrc_32_tab,(int)*passwd); update_keys(pkeys,pcrc_32_tab,(int)*passwd);
passwd++; passwd++;
} }
} }
#define zdecode(pkeys,pcrc_32_tab,c) \ #define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys)))
#define zencode(pkeys,pcrc_32_tab,c,t) \ #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), update_keys(pkeys,pcrc_32_tab,c), t^(c))
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
...@@ -99,7 +100,7 @@ static int crypthead(const char* passwd, /* password string */ ...@@ -99,7 +100,7 @@ static int crypthead(const char* passwd, /* password string */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */ unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */ static unsigned calls = 0; /* ensure different random header each time */
if (bufSize<RAND_HEAD_LEN) if (bufSize < RAND_HEAD_LEN)
return 0; return 0;
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
......
...@@ -118,7 +118,7 @@ static voidpf file_build_ioposix(FILE *file, const char *filename) ...@@ -118,7 +118,7 @@ static voidpf file_build_ioposix(FILE *file, const char *filename)
return NULL; return NULL;
ioposix = (FILE_IOPOSIX*)malloc(sizeof(FILE_IOPOSIX)); ioposix = (FILE_IOPOSIX*)malloc(sizeof(FILE_IOPOSIX));
ioposix->file = file; ioposix->file = file;
ioposix->filenameLength = (int)strlen(filename) + 1; ioposix->filenameLength = strlen(filename) + 1;
ioposix->filename = (char*)malloc(ioposix->filenameLength * sizeof(char)); ioposix->filename = (char*)malloc(ioposix->filenameLength * sizeof(char));
strncpy(ioposix->filename, filename, ioposix->filenameLength); strncpy(ioposix->filename, filename, ioposix->filenameLength);
return (voidpf)ioposix; return (voidpf)ioposix;
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#ifdef HAVE_64BIT_INT_CUSTOM #ifdef HAVE_64BIT_INT_CUSTOM
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
#else #else
# ifdef HAS_STDINT_H # ifdef HAVE_STDINT_H
# include "stdint.h" # include "stdint.h"
typedef uint64_t ZPOS64_T; typedef uint64_t ZPOS64_T;
# else # else
......
This diff is collapsed.
/* ioapi_buf.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
This version of ioapi is designed to buffer IO.
Copyright (C) 1998-2003 Gilles Vollant
(C) 2012-2014 Nathan Moinvaziri
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _IOAPI_BUF_H
#define _IOAPI_BUF_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "ioapi.h"
#define IOBUF_BUFFERSIZE (64 * 1024)
#ifdef __cplusplus
extern "C" {
#endif
voidpf ZCALLBACK fopen_buf_func OF((voidpf opaque,const char* filename,int mode));
voidpf ZCALLBACK fopen64_buf_func OF((voidpf opaque,const char* filename,int mode));
voidpf ZCALLBACK fopendisk_buf_func OF((voidpf opaque, voidpf stream_cd, int number_disk, int mode));
voidpf ZCALLBACK fopendisk64_buf_func OF((voidpf opaque, voidpf stream_cd, int number_disk, int mode));
uLong ZCALLBACK fread_buf_func OF((voidpf opaque,voidpf stream,void* buf,uLong size));
uLong ZCALLBACK fwrite_buf_func OF((voidpf opaque,voidpf stream,const void* buf,uLong size));
long ZCALLBACK ftell_buf_func OF((voidpf opaque,voidpf stream));
ZPOS64_T ZCALLBACK ftell64_buf_func OF((voidpf opaque, voidpf stream));
long ZCALLBACK fseek_buf_func OF((voidpf opaque,voidpf stream,uLong offset,int origin));
long ZCALLBACK fseek64_buf_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
int ZCALLBACK fclose_buf_func OF((voidpf opaque,voidpf stream));
int ZCALLBACK ferror_buf_func OF((voidpf opaque,voidpf stream));
typedef struct ourbuffer_s {
zlib_filefunc_def filefunc;
zlib_filefunc64_def filefunc64;
} ourbuffer_t;
void fill_buffer_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def, ourbuffer_t *ourbuf));
void fill_buffer_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def, ourbuffer_t *ourbuf));
#ifdef __cplusplus
}
#endif
#endif
/* ioapi_mem.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
This version of ioapi is designed to access memory rather than files.
We do use a region of memory to put data in to and take it out of. We do
not have auto-extending buffers and do not inform anyone else that the
data has been written. It is really intended for accessing a zip archive
embedded in an application such that I can write an installer with no
external files. Creation of archives has not been attempted, although
parts of the framework are present.
Based on Unzip ioapi.c version 0.22, May 19th, 2003
Copyright (C) 1998-2003 Gilles Vollant
(C) 2003 Justin Fletcher
This file is under the same license as the Unzip tool it is distributed
with.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "ioapi.h"
#include "ioapi_mem.h"
#ifndef IOMEM_BUFFERSIZE
# define IOMEM_BUFFERSIZE (64 * 1024)
#endif
voidpf ZCALLBACK fopen_mem_func (opaque, filename, mode)
voidpf opaque;
const char* filename;
int mode;
{
ourmemory_t *mem = (ourmemory_t *)opaque;
if (mem == NULL)
return NULL; /* Mem structure passed in was null */
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
{
if (mem->grow)
{
mem->size = IOMEM_BUFFERSIZE;
mem->base = (char *)malloc(mem->size);
}
mem->limit = 0; /* When writing we start with 0 bytes written */
}
else
mem->limit = mem->size;
mem->cur_offset = 0;
return mem;
}
voidpf ZCALLBACK fopendisk_mem_func (opaque, stream, number_disk, mode)
voidpf opaque;
voidpf stream;
int number_disk;
int mode;
{
/* Not used */
return NULL;
}
uLong ZCALLBACK fread_mem_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
void* buf;
uLong size;
{
ourmemory_t *mem = (ourmemory_t *)stream;
if (size > mem->size - mem->cur_offset)
size = mem->size - mem->cur_offset;
memcpy(buf, mem->base + mem->cur_offset, size);
mem->cur_offset += size;
return size;
}
uLong ZCALLBACK fwrite_mem_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
const void* buf;
uLong size;
{
ourmemory_t *mem = (ourmemory_t *)stream;
char *newbase = NULL;
uLong newmemsize = 0;
if (size > mem->size - mem->cur_offset)
{
if (mem->grow)
{
newmemsize = mem->size;
if (size < IOMEM_BUFFERSIZE)
newmemsize += IOMEM_BUFFERSIZE;
else
newmemsize += size;
newbase = (char *)malloc(newmemsize);
memcpy(newbase, mem->base, mem->size);
free(mem->base);
mem->base = newbase;
mem->size = newmemsize;
}
else
size = mem->size - mem->cur_offset;
}
memcpy(mem->base + mem->cur_offset, buf, size);
mem->cur_offset += size;
if (mem->cur_offset > mem->limit)
mem->limit = mem->cur_offset;
return size;
}
long ZCALLBACK ftell_mem_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
ourmemory_t *mem = (ourmemory_t *)stream;
return mem->cur_offset;
}
long ZCALLBACK fseek_mem_func (opaque, stream, offset, origin)
voidpf opaque;
voidpf stream;
uLong offset;
int origin;
{
ourmemory_t *mem = (ourmemory_t *)stream;
uLong new_pos;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR:
new_pos = mem->cur_offset + offset;
break;
case ZLIB_FILEFUNC_SEEK_END:
new_pos = mem->limit + offset;
break;
case ZLIB_FILEFUNC_SEEK_SET:
new_pos = offset;
break;
default:
return -1;
}
if (new_pos > mem->size)
return 1; /* Failed to seek that far */
mem->cur_offset = new_pos;
return 0;
}
int ZCALLBACK fclose_mem_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
/* Even with grow = 1, caller must always free() memory */
return 0;
}
int ZCALLBACK ferror_mem_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
/* We never return errors */
return 0;
}
void fill_memory_filefunc (pzlib_filefunc_def, ourmem)
zlib_filefunc_def* pzlib_filefunc_def;
ourmemory_t *ourmem;
{
pzlib_filefunc_def->zopen_file = fopen_mem_func;
pzlib_filefunc_def->zopendisk_file = fopendisk_mem_func;
pzlib_filefunc_def->zread_file = fread_mem_func;
pzlib_filefunc_def->zwrite_file = fwrite_mem_func;
pzlib_filefunc_def->ztell_file = ftell_mem_func;
pzlib_filefunc_def->zseek_file = fseek_mem_func;
pzlib_filefunc_def->zclose_file = fclose_mem_func;
pzlib_filefunc_def->zerror_file = ferror_mem_func;
pzlib_filefunc_def->opaque = ourmem;
}
/* ioapi_mem.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
This version of ioapi is designed to access memory rather than files.
We do use a region of memory to put data in to and take it out of.
Copyright (C) 1998-2003 Gilles Vollant
(C) 2003 Justin Fletcher
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _IOAPI_MEM_H
#define _IOAPI_MEM_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "ioapi.h"
#ifdef __cplusplus
extern "C" {
#endif
voidpf ZCALLBACK fopen_mem_func OF((voidpf opaque,const char* filename,int mode));
voidpf ZCALLBACK fopendisk_mem_func OF((voidpf opaque, voidpf stream, int number_disk, int mode));
uLong ZCALLBACK fread_mem_func OF((voidpf opaque,voidpf stream,void* buf,uLong size));
uLong ZCALLBACK fwrite_mem_func OF((voidpf opaque,voidpf stream,const void* buf,uLong size));
long ZCALLBACK ftell_mem_func OF((voidpf opaque,voidpf stream));
long ZCALLBACK fseek_mem_func OF((voidpf opaque,voidpf stream,uLong offset,int origin));
int ZCALLBACK fclose_mem_func OF((voidpf opaque,voidpf stream));
int ZCALLBACK ferror_mem_func OF((voidpf opaque,voidpf stream));
typedef struct ourmemory_s {
char *base; /* Base of the region of memory we're using */
uLong size; /* Size of the region of memory we're using */
uLong limit; /* Furthest we've written */
uLong cur_offset; /* Current offset in the area */
int grow; /* Growable memory buffer */
} ourmemory_t;
void fill_memory_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def, ourmemory_t *ourmem));
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
/* iowin32.h -- IO base function header for compress/uncompress .zip
Version 1.1, February 14h, 2010
part of the MiniZip project
Copyright (C) 1998-2010 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson
http://result42.com
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _IOWIN32_H
#define _IOWIN32_H
#include <windows.h>
#ifdef __cplusplus
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));
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="miniunz"
ProjectGUID="{8D770B0A-A853-4FB7-8E71-5BDDC16A8C11}"
RootNamespace="miniunz"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\"
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\"
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\ioapi.c"
>
</File>
<File
RelativePath=".\iowin32.c"
>
</File>
<File
RelativePath=".\miniunz.c"
>
</File>
<File
RelativePath=".\unzip.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\crypt.h"
>
</File>
<File
RelativePath=".\ioapi.h"
>
</File>
<File
RelativePath=".\iowin32.h"
>
</File>
<File
RelativePath=".\unzip.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="Zlib"
>
<File
RelativePath="..\..\adler32.c"
>
</File>
<File
RelativePath="..\..\compress.c"
>
</File>
<File
RelativePath="..\..\crc32.c"
>
</File>
<File
RelativePath="..\..\crc32.h"
>
</File>
<File
RelativePath="..\..\deflate.c"
>
</File>
<File
RelativePath="..\..\deflate.h"
>
</File>
<File
RelativePath="..\..\infback.c"
>
</File>
<File
RelativePath="..\..\inffast.c"
>
</File>
<File
RelativePath="..\..\inffast.h"
>
</File>
<File
RelativePath="..\..\inffixed.h"
>
</File>
<File
RelativePath="..\..\inflate.c"
>
</File>
<File
RelativePath="..\..\inflate.h"
>
</File>
<File
RelativePath="..\..\inftrees.c"
>
</File>
<File
RelativePath="..\..\inftrees.h"
>
</File>
<File
RelativePath="..\..\trees.c"
>
</File>
<File
RelativePath="..\..\trees.h"
>
</File>
<File
RelativePath="..\..\uncompr.c"
>
</File>
<File
RelativePath="..\..\zconf.h"
>
</File>
<File
RelativePath="..\..\zlib.h"
>
</File>
<File
RelativePath="..\..\zutil.c"
>
</File>
<File
RelativePath="..\..\zutil.h"
>
</File>
</Filter>
<Filter
Name="AES"
>
<File
RelativePath=".\aes\aes.h"
>
</File>
<File
RelativePath=".\aes\aes_via_ace.h"
>
</File>
<File
RelativePath=".\aes\aescrypt.c"
>
</File>
<File
RelativePath=".\aes\aeskey.c"
>
</File>
<File
RelativePath=".\aes\aesopt.h"
>
</File>
<File
RelativePath=".\aes\aestab.c"
>
</File>
<File
RelativePath=".\aes\aestab.h"
>
</File>
<File
RelativePath=".\aes\brg_endian.h"
>
</File>
<File
RelativePath=".\aes\brg_types.h"
>
</File>
<File
RelativePath=".\aes\entropy.c"
>
</File>
<File
RelativePath=".\aes\entropy.h"
>
</File>
<File
RelativePath=".\aes\fileenc.c"
>
</File>
<File
RelativePath=".\aes\fileenc.h"
>
</File>
<File
RelativePath=".\aes\hmac.c"
>
</File>
<File
RelativePath=".\aes\hmac.h"
>
</File>
<File
RelativePath=".\aes\prng.c"
>
</File>
<File
RelativePath=".\aes\prng.h"
>
</File>
<File
RelativePath=".\aes\pwd2key.c"
>
</File>
<File
RelativePath=".\aes\pwd2key.h"
>
</File>
<File
RelativePath=".\aes\sha1.c"
>
</File>
<File
RelativePath=".\aes\sha1.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
This diff is collapsed.
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/minizip
Name: minizip
Description: Minizip zip file manipulation library
Requires:
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lminizip
Libs.private: -lz
Cflags: -I${includedir}

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{8D770B0A-A853-4FB7-8E71-5BDDC16A8C11}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{9C3AFF9E-022F-4A42-BCDC-C705AEE00DEB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D770B0A-A853-4FB7-8E71-5BDDC16A8C11}.Debug|Win32.ActiveCfg = Debug|Win32
{8D770B0A-A853-4FB7-8E71-5BDDC16A8C11}.Debug|Win32.Build.0 = Debug|Win32
{8D770B0A-A853-4FB7-8E71-5BDDC16A8C11}.Release|Win32.ActiveCfg = Release|Win32
{8D770B0A-A853-4FB7-8E71-5BDDC16A8C11}.Release|Win32.Build.0 = Release|Win32
{9C3AFF9E-022F-4A42-BCDC-C705AEE00DEB}.Debug|Win32.ActiveCfg = Debug|Win32
{9C3AFF9E-022F-4A42-BCDC-C705AEE00DEB}.Debug|Win32.Build.0 = Debug|Win32
{9C3AFF9E-022F-4A42-BCDC-C705AEE00DEB}.Release|Win32.ActiveCfg = Release|Win32
{9C3AFF9E-022F-4A42-BCDC-C705AEE00DEB}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="minizip"
ProjectGUID="{9C3AFF9E-022F-4A42-BCDC-C705AEE00DEB}"
RootNamespace="minizip"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\"
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\"
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\iowin32.c"
>
</File>
<File
RelativePath=".\minizip.c"
>
</File>
<File
RelativePath=".\zip.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\crypt.h"
>
</File>
<File
RelativePath=".\ioapi.c"
>
</File>
<File
RelativePath=".\ioapi.h"
>
</File>
<File
RelativePath=".\iowin32.h"
>
</File>
<File
RelativePath=".\zip.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="Zlib"
>
<File
RelativePath="..\..\adler32.c"
>
</File>
<File
RelativePath="..\..\compress.c"
>
</File>
<File
RelativePath="..\..\crc32.c"
>
</File>
<File
RelativePath="..\..\crc32.h"
>
</File>
<File
RelativePath="..\..\deflate.c"
>
</File>
<File
RelativePath="..\..\deflate.h"
>
</File>
<File
RelativePath="..\..\infback.c"
>
</File>
<File
RelativePath="..\..\inffast.c"
>
</File>
<File
RelativePath="..\..\inffast.h"
>
</File>
<File
RelativePath="..\..\inffixed.h"
>
</File>
<File
RelativePath="..\..\inflate.c"
>
</File>
<File
RelativePath="..\..\inflate.h"
>
</File>
<File
RelativePath="..\..\inftrees.c"
>
</File>
<File
RelativePath="..\..\inftrees.h"
>
</File>
<File
RelativePath="..\..\trees.c"
>
</File>
<File
RelativePath="..\..\trees.h"
>
</File>
<File
RelativePath="..\..\uncompr.c"
>
</File>
<File
RelativePath="..\..\zconf.h"
>
</File>
<File
RelativePath="..\..\zlib.h"
>
</File>
<File
RelativePath="..\..\zutil.c"
>
</File>
<File
RelativePath="..\..\zutil.h"
>
</File>
</Filter>
<Filter
Name="AES"
>
<File
RelativePath=".\aes\aes.h"
>
</File>
<File
RelativePath=".\aes\aes_via_ace.h"
>
</File>
<File
RelativePath=".\aes\aescrypt.c"
>
</File>
<File
RelativePath=".\aes\aeskey.c"
>
</File>
<File
RelativePath=".\aes\aesopt.h"
>
</File>
<File
RelativePath=".\aes\aestab.c"
>
</File>
<File
RelativePath=".\aes\aestab.h"
>
</File>
<File
RelativePath=".\aes\brg_endian.h"
>
</File>
<File
RelativePath=".\aes\brg_types.h"
>
</File>
<File
RelativePath=".\aes\entropy.c"
>
</File>
<File
RelativePath=".\aes\entropy.h"
>
</File>
<File
RelativePath=".\aes\fileenc.c"
>
</File>
<File
RelativePath=".\aes\fileenc.h"
>
</File>
<File
RelativePath=".\aes\hmac.c"
>
</File>
<File
RelativePath=".\aes\hmac.h"
>
</File>
<File
RelativePath=".\aes\prng.c"
>
</File>
<File
RelativePath=".\aes\prng.h"
>
</File>
<File
RelativePath=".\aes\pwd2key.c"
>
</File>
<File
RelativePath=".\aes\pwd2key.h"
>
</File>
<File
RelativePath=".\aes\sha1.c"
>
</File>
<File
RelativePath=".\aes\sha1.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
This diff is collapsed.
...@@ -14,13 +14,9 @@ ...@@ -14,13 +14,9 @@
See the accompanying LICENSE file for the full text of the license. See the accompanying LICENSE file for the full text of the license.
*/ */
#include "Common.h"
#ifndef _UNZ_H #ifndef _UNZ_H
#define _UNZ_H #define _UNZ_H
#define HAVE_AES
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -48,7 +44,6 @@ typedef unzFile__ *unzFile; ...@@ -48,7 +44,6 @@ typedef unzFile__ *unzFile;
typedef voidp unzFile; typedef voidp unzFile;
#endif #endif
#define UNZ_OK (0) #define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO) #define UNZ_ERRNO (Z_ERRNO)
...@@ -58,6 +53,78 @@ typedef voidp unzFile; ...@@ -58,6 +53,78 @@ typedef voidp unzFile;
#define UNZ_INTERNALERROR (-104) #define UNZ_INTERNALERROR (-104)
#define UNZ_CRCERROR (-105) #define UNZ_CRCERROR (-105)
/* 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] */
} tm_unz;
/* unz_global_info structure contain global data about the ZIPfile
These data comes from the end of central dir */
typedef struct unz_global_info64_s
{
ZPOS64_T number_entry; /* total number of entries in the central dir on this disk */
uLong number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info64;
typedef struct unz_global_info_s
{
uLong number_entry; /* total number of entries in the central dir on this disk */
uLong number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info;
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info64_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
ZPOS64_T compressed_size; /* compressed size 8 bytes */
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
ZPOS64_T disk_offset;
uLong size_file_extra_internal;
} unz_file_info64;
typedef struct unz_file_info_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
uLong compressed_size; /* compressed size 4 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
uLong disk_offset;
} unz_file_info;
/***************************************************************************/ /***************************************************************************/
/* Opening and close a zip file */ /* Opening and close a zip file */
...@@ -236,6 +303,10 @@ extern z_off_t ZEXPORT unztell OF((unzFile file)); ...@@ -236,6 +303,10 @@ extern z_off_t ZEXPORT unztell OF((unzFile file));
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
/* return current position in uncompressed data */ /* return current position in uncompressed data */
extern int ZEXPORT unzseek OF((unzFile file, z_off_t offset, int origin));
extern int ZEXPORT unzseek64 OF((unzFile file, ZPOS64_T offset, int origin));
/* Seek within the uncompressed data if compression method is storage */
extern int ZEXPORT unzeof OF((unzFile file)); extern int ZEXPORT unzeof OF((unzFile file));
/* return 1 if the end of file was reached, 0 elsewhere */ /* return 1 if the end of file was reached, 0 elsewhere */
......
This diff is collapsed.
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#ifndef _ZIP_H #ifndef _ZIP_H
#define _ZIP_H #define _ZIP_H
#define HAVE_AES
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -79,8 +77,6 @@ typedef struct ...@@ -79,8 +77,6 @@ typedef struct
uLong external_fa; /* external file attributes 4 bytes */ uLong external_fa; /* external file attributes 4 bytes */
} zip_fileinfo; } zip_fileinfo;
typedef const char* zipcharpc;
#define APPEND_STATUS_CREATE (0) #define APPEND_STATUS_CREATE (0)
#define APPEND_STATUS_CREATEAFTER (1) #define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2) #define APPEND_STATUS_ADDINZIP (2)
...@@ -107,18 +103,18 @@ extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); ...@@ -107,18 +103,18 @@ extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy
the file you did not want delete. */ the file you did not want delete. */
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, int append, zipcharpc* globalcomment, extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, int append, const char ** globalcomment,
zlib_filefunc_def* pzlib_filefunc_def)); zlib_filefunc_def* pzlib_filefunc_def));
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, int append, zipcharpc* globalcomment, extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, int append, const char ** globalcomment,
zlib_filefunc64_def* pzlib_filefunc_def)); zlib_filefunc64_def* pzlib_filefunc_def));
extern zipFile ZEXPORT zipOpen3 OF((const char *pathname, int append, ZPOS64_T disk_size, extern zipFile ZEXPORT zipOpen3 OF((const char *pathname, int append, ZPOS64_T disk_size,
zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc_def)); const char ** globalcomment, zlib_filefunc_def* pzlib_filefunc_def));
/* Same as zipOpen2 but allows specification of spanned zip size */ /* Same as zipOpen2 but allows specification of spanned zip size */
extern zipFile ZEXPORT zipOpen3_64 OF((const void *pathname, int append, ZPOS64_T disk_size, extern zipFile ZEXPORT zipOpen3_64 OF((const void *pathname, int append, ZPOS64_T disk_size,
zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def)); const char ** globalcomment, zlib_filefunc64_def* pzlib_filefunc_def));
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* filename, const zip_fileinfo* zipfi, 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, const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment