-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
17,615 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* zlib.h -- interface of the 'zlib' general purpose compression library | ||
version 1.2.4, March 14th, 2010 | ||
|
||
Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler | ||
|
||
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 acknowledgment 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. | ||
|
||
Jean-loup Gailly | ||
Mark Adler | ||
|
||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Name: zlib | ||
URL: http://zlib.net/ | ||
Version: 1.2.3 | ||
|
||
Description: | ||
General purpose compression library | ||
|
||
Local Modifications: | ||
A few minor changes, all marked with "Google": | ||
- Added #ifdefs to avoid compile warnings when NO_GZCOMPRESS is defined. | ||
- Removed use of strerror for WinCE in gzio.c. | ||
- Added 'int z_errno' global for WinCE, to which 'errno' is defined in zutil.h. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* adler32.c -- compute the Adler-32 checksum of a data stream | ||
* Copyright (C) 1995-2004 Mark Adler | ||
* For conditions of distribution and use, see copyright notice in zlib.h | ||
*/ | ||
|
||
/* @(#) $Id: adler32.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */ | ||
|
||
#define ZLIB_INTERNAL | ||
#include "zlib.h" | ||
|
||
#define BASE 65521UL /* largest prime smaller than 65536 */ | ||
#define NMAX 5552 | ||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ | ||
|
||
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} | ||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); | ||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); | ||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); | ||
#define DO16(buf) DO8(buf,0); DO8(buf,8); | ||
|
||
/* use NO_DIVIDE if your processor does not do division in hardware */ | ||
#ifdef NO_DIVIDE | ||
# define MOD(a) \ | ||
do { \ | ||
if (a >= (BASE << 16)) a -= (BASE << 16); \ | ||
if (a >= (BASE << 15)) a -= (BASE << 15); \ | ||
if (a >= (BASE << 14)) a -= (BASE << 14); \ | ||
if (a >= (BASE << 13)) a -= (BASE << 13); \ | ||
if (a >= (BASE << 12)) a -= (BASE << 12); \ | ||
if (a >= (BASE << 11)) a -= (BASE << 11); \ | ||
if (a >= (BASE << 10)) a -= (BASE << 10); \ | ||
if (a >= (BASE << 9)) a -= (BASE << 9); \ | ||
if (a >= (BASE << 8)) a -= (BASE << 8); \ | ||
if (a >= (BASE << 7)) a -= (BASE << 7); \ | ||
if (a >= (BASE << 6)) a -= (BASE << 6); \ | ||
if (a >= (BASE << 5)) a -= (BASE << 5); \ | ||
if (a >= (BASE << 4)) a -= (BASE << 4); \ | ||
if (a >= (BASE << 3)) a -= (BASE << 3); \ | ||
if (a >= (BASE << 2)) a -= (BASE << 2); \ | ||
if (a >= (BASE << 1)) a -= (BASE << 1); \ | ||
if (a >= BASE) a -= BASE; \ | ||
} while (0) | ||
# define MOD4(a) \ | ||
do { \ | ||
if (a >= (BASE << 4)) a -= (BASE << 4); \ | ||
if (a >= (BASE << 3)) a -= (BASE << 3); \ | ||
if (a >= (BASE << 2)) a -= (BASE << 2); \ | ||
if (a >= (BASE << 1)) a -= (BASE << 1); \ | ||
if (a >= BASE) a -= BASE; \ | ||
} while (0) | ||
#else | ||
# define MOD(a) a %= BASE | ||
# define MOD4(a) a %= BASE | ||
#endif | ||
|
||
/* ========================================================================= */ | ||
uLong ZEXPORT adler32(adler, buf, len) | ||
uLong adler; | ||
const Bytef *buf; | ||
uInt len; | ||
{ | ||
unsigned long sum2; | ||
unsigned n; | ||
|
||
/* split Adler-32 into component sums */ | ||
sum2 = (adler >> 16) & 0xffff; | ||
adler &= 0xffff; | ||
|
||
/* in case user likes doing a byte at a time, keep it fast */ | ||
if (len == 1) { | ||
adler += buf[0]; | ||
if (adler >= BASE) | ||
adler -= BASE; | ||
sum2 += adler; | ||
if (sum2 >= BASE) | ||
sum2 -= BASE; | ||
return adler | (sum2 << 16); | ||
} | ||
|
||
/* initial Adler-32 value (deferred check for len == 1 speed) */ | ||
if (buf == Z_NULL) | ||
return 1L; | ||
|
||
/* in case short lengths are provided, keep it somewhat fast */ | ||
if (len < 16) { | ||
while (len--) { | ||
adler += *buf++; | ||
sum2 += adler; | ||
} | ||
if (adler >= BASE) | ||
adler -= BASE; | ||
MOD4(sum2); /* only added so many BASE's */ | ||
return adler | (sum2 << 16); | ||
} | ||
|
||
/* do length NMAX blocks -- requires just one modulo operation */ | ||
while (len >= NMAX) { | ||
len -= NMAX; | ||
n = NMAX / 16; /* NMAX is divisible by 16 */ | ||
do { | ||
DO16(buf); /* 16 sums unrolled */ | ||
buf += 16; | ||
} while (--n); | ||
MOD(adler); | ||
MOD(sum2); | ||
} | ||
|
||
/* do remaining bytes (less than NMAX, still just one modulo) */ | ||
if (len) { /* avoid modulos if none remaining */ | ||
while (len >= 16) { | ||
len -= 16; | ||
DO16(buf); | ||
buf += 16; | ||
} | ||
while (len--) { | ||
adler += *buf++; | ||
sum2 += adler; | ||
} | ||
MOD(adler); | ||
MOD(sum2); | ||
} | ||
|
||
/* return recombined sums */ | ||
return adler | (sum2 << 16); | ||
} | ||
|
||
/* ========================================================================= */ | ||
uLong ZEXPORT adler32_combine(adler1, adler2, len2) | ||
uLong adler1; | ||
uLong adler2; | ||
z_off_t len2; | ||
{ | ||
unsigned long sum1; | ||
unsigned long sum2; | ||
unsigned rem; | ||
|
||
/* the derivation of this formula is left as an exercise for the reader */ | ||
rem = (unsigned)(len2 % BASE); | ||
sum1 = adler1 & 0xffff; | ||
sum2 = rem * sum1; | ||
MOD(sum2); | ||
sum1 += (adler2 & 0xffff) + BASE - 1; | ||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; | ||
if (sum1 > BASE) sum1 -= BASE; | ||
if (sum1 > BASE) sum1 -= BASE; | ||
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); | ||
if (sum2 > BASE) sum2 -= BASE; | ||
return sum1 | (sum2 << 16); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* compress.c -- compress a memory buffer | ||
* Copyright (C) 1995-2003 Jean-loup Gailly. | ||
* For conditions of distribution and use, see copyright notice in zlib.h | ||
*/ | ||
|
||
/* @(#) $Id: compress.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */ | ||
|
||
#define ZLIB_INTERNAL | ||
#include "zlib.h" | ||
|
||
/* =========================================================================== | ||
Compresses the source buffer into the destination buffer. The level | ||
parameter has the same meaning as in deflateInit. sourceLen is the byte | ||
length of the source buffer. Upon entry, destLen is the total size of the | ||
destination buffer, which must be at least 0.1% larger than sourceLen plus | ||
12 bytes. Upon exit, destLen is the actual size of the compressed buffer. | ||
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough | ||
memory, Z_BUF_ERROR if there was not enough room in the output buffer, | ||
Z_STREAM_ERROR if the level parameter is invalid. | ||
*/ | ||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) | ||
Bytef *dest; | ||
uLongf *destLen; | ||
const Bytef *source; | ||
uLong sourceLen; | ||
int level; | ||
{ | ||
z_stream stream; | ||
int err; | ||
|
||
stream.next_in = (Bytef*)source; | ||
stream.avail_in = (uInt)sourceLen; | ||
#ifdef MAXSEG_64K | ||
/* Check for source > 64K on 16-bit machine: */ | ||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; | ||
#endif | ||
stream.next_out = dest; | ||
stream.avail_out = (uInt)*destLen; | ||
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; | ||
|
||
stream.zalloc = (alloc_func)0; | ||
stream.zfree = (free_func)0; | ||
stream.opaque = (voidpf)0; | ||
|
||
err = deflateInit(&stream, level); | ||
if (err != Z_OK) return err; | ||
|
||
err = deflate(&stream, Z_FINISH); | ||
if (err != Z_STREAM_END) { | ||
deflateEnd(&stream); | ||
return err == Z_OK ? Z_BUF_ERROR : err; | ||
} | ||
*destLen = stream.total_out; | ||
|
||
err = deflateEnd(&stream); | ||
return err; | ||
} | ||
|
||
/* =========================================================================== | ||
*/ | ||
int ZEXPORT compress (dest, destLen, source, sourceLen) | ||
Bytef *dest; | ||
uLongf *destLen; | ||
const Bytef *source; | ||
uLong sourceLen; | ||
{ | ||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); | ||
} | ||
|
||
/* =========================================================================== | ||
If the default memLevel or windowBits for deflateInit() is changed, then | ||
this function needs to be updated. | ||
*/ | ||
uLong ZEXPORT compressBound (sourceLen) | ||
uLong sourceLen; | ||
{ | ||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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 (submited by 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CC=cc | ||
CFLAGS=-O -I../.. | ||
|
||
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a | ||
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a | ||
|
||
.c.o: | ||
$(CC) -c $(CFLAGS) $*.c | ||
|
||
all: miniunz minizip | ||
|
||
miniunz: $(UNZ_OBJS) | ||
$(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) | ||
|
||
minizip: $(ZIP_OBJS) | ||
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) | ||
|
||
test: miniunz minizip | ||
./minizip test readme.txt | ||
./miniunz -l test.zip | ||
mv readme.txt readme.old | ||
./miniunz test.zip | ||
|
||
clean: | ||
/bin/rm -f *.o *~ minizip miniunz |
Oops, something went wrong.