Skip to content
Permalink
Browse files
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
  • Loading branch information
icculus committed Dec 7, 2003
1 parent e3e3270 commit c7fb2e4cba856dc5587c9df43ebb5748f22bd664
Showing with 10,103 additions and 43 deletions.
  1. +25 −27 Makefile.am.newautomake
  2. +2 −2 Makefile.am.oldautomake
  3. +1 −1 configure.in
  4. +12 −13 makeos2.cmd
  5. +29 −0 zlib121/Makefile.am
  6. +74 −0 zlib121/adler32.c
  7. +79 −0 zlib121/compress.c
  8. +311 −0 zlib121/crc32.c
  9. +441 −0 zlib121/crc32.h
  10. +1,502 −0 zlib121/deflate.c
  11. +326 −0 zlib121/deflate.h
  12. +1,005 −0 zlib121/gzio.c
  13. +619 −0 zlib121/infback.c
  14. +305 −0 zlib121/inffast.c
  15. +11 −0 zlib121/inffast.h
  16. +94 −0 zlib121/inffixed.h
  17. +1,270 −0 zlib121/inflate.c
  18. +117 −0 zlib121/inflate.h
  19. +321 −0 zlib121/inftrees.c
  20. +55 −0 zlib121/inftrees.h
  21. +1,215 −0 zlib121/trees.c
  22. +128 −0 zlib121/trees.h
  23. +61 −0 zlib121/uncompr.c
  24. +323 −0 zlib121/zconf.h
  25. +1,200 −0 zlib121/zlib.h
  26. +319 −0 zlib121/zutil.c
  27. +258 −0 zlib121/zutil.h
@@ -6,35 +6,33 @@ libphysfsinclude_HEADERS = \

if BUILD_MACOSX

ZLIB_FILES = zlib114/adler32.c \
zlib114/compress.c \
zlib114/crc32.c \
zlib114/deflate.c \
zlib114/deflate.h \
zlib114/infblock.c \
zlib114/infblock.h \
zlib114/infcodes.c \
zlib114/infcodes.h \
zlib114/inffast.c \
zlib114/inffast.h \
zlib114/inffixed.h \
zlib114/inflate.c \
zlib114/inftrees.c \
zlib114/inftrees.h \
zlib114/infutil.c \
zlib114/infutil.h \
zlib114/trees.c \
zlib114/trees.h \
zlib114/uncompr.c \
zlib114/zconf.h \
zlib114/zlib.h \
zlib114/zutil.c \
zlib114/zutil.h
ZLIB_FILES = zlib121/adler32.c \
zlib121/compress.c \
zlib121/crc32.c \
zlib121/crc32.h \
zlib121/deflate.c \
zlib121/deflate.h \
zlib121/gzio.c \
zlib121/infback.c \
zlib121/inffast.c \
zlib121/inffast.h \
zlib121/inffixed.h \
zlib121/inflate.c \
zlib121/inflate.h \
zlib121/inftrees.c \
zlib121/inftrees.h \
zlib121/trees.c \
zlib121/trees.h \
zlib121/uncompr.c \
zlib121/zconf.h \
zlib121/zlib.h \
zlib121/zutil.c \
zlib121/zutil.h


if BUILD_ZLIB
ZLIB_SRC = $(ZLIB_FILES)
ZLIB_INC = -I$(top_srcdir)/zlib114
ZLIB_INC = -I$(top_srcdir)/zlib121
ZLIB_EXTRADIST =
else
ZLIB_SRC =
@@ -100,15 +98,15 @@ EXTRA_DIST = \

else

SUBDIRS = platform archivers zlib114 . test extras
SUBDIRS = platform archivers zlib121 . test extras

libphysfs_la_SOURCES = \
physfs.c \
physfs_internal.h \
physfs_byteorder.c

if BUILD_ZLIB
ZLIB_LIB = zlib114/libz.la
ZLIB_LIB = zlib121/libz.la
else
ZLIB_LIB =
endif
@@ -1,6 +1,6 @@
lib_LTLIBRARIES = libphysfs.la

SUBDIRS = platform archivers zlib114 . test extras
SUBDIRS = platform archivers zlib121 . test extras

libphysfsincludedir = $(includedir)
libphysfsinclude_HEADERS = \
@@ -12,7 +12,7 @@ libphysfs_la_SOURCES = \
physfs_byteorder.c

if BUILD_ZLIB
ZLIB_LIB = zlib114/libz.la
ZLIB_LIB = zlib121/libz.la
else
ZLIB_LIB =
endif
@@ -494,7 +494,7 @@ AC_OUTPUT([
Makefile
archivers/Makefile
platform/Makefile
zlib114/Makefile
zlib121/Makefile
test/Makefile
extras/Makefile
physfs.spec
@@ -114,19 +114,18 @@ gcc %CFLAGS% -o bin/qpak.obj archivers/qpak.c
gcc %CFLAGS% -o bin/hog.obj archivers/hog.c
gcc %CFLAGS% -o bin/mvl.obj archivers/mvl.c

gcc %CFLAGS% -o bin/adler32.obj zlib114/adler32.c
gcc %CFLAGS% -o bin/compress.obj zlib114/compress.c
gcc %CFLAGS% -o bin/crc32.obj zlib114/crc32.c
gcc %CFLAGS% -o bin/deflate.obj zlib114/deflate.c
gcc %CFLAGS% -o bin/infblock.obj zlib114/infblock.c
gcc %CFLAGS% -o bin/infcodes.obj zlib114/infcodes.c
gcc %CFLAGS% -o bin/inffast.obj zlib114/inffast.c
gcc %CFLAGS% -o bin/inflate.obj zlib114/inflate.c
gcc %CFLAGS% -o bin/inftrees.obj zlib114/inftrees.c
gcc %CFLAGS% -o bin/infutil.obj zlib114/infutil.c
gcc %CFLAGS% -o bin/trees.obj zlib114/trees.c
gcc %CFLAGS% -o bin/uncompr.obj zlib114/uncompr.c
gcc %CFLAGS% -o bin/zutil.obj zlib114/zutil.c
gcc %CFLAGS% -o bin/adler32.obj zlib121/adler32.c
gcc %CFLAGS% -o bin/compress.obj zlib121/compress.c
gcc %CFLAGS% -o bin/crc32.obj zlib121/crc32.c
gcc %CFLAGS% -o bin/deflate.obj zlib121/deflate.c
gcc %CFLAGS% -o bin/gzio.obj zlib121/gzio.c
gcc %CFLAGS% -o bin/infback.obj zlib121/infback.c
gcc %CFLAGS% -o bin/inffast.obj zlib121/inffast.c
gcc %CFLAGS% -o bin/inflate.obj zlib121/inflate.c
gcc %CFLAGS% -o bin/inftrees.obj zlib121/inftrees.c
gcc %CFLAGS% -o bin/trees.obj zlib121/trees.c
gcc %CFLAGS% -o bin/uncompr.obj zlib121/uncompr.c
gcc %CFLAGS% -o bin/zutil.obj zlib121/zutil.c

gcc %DEBUGFLAGS% -Zdll -Zcrtdll -Zomf -Zmt -Zmtd -o bin/physfs.dll bin/*.obj bin/physfs.def

@@ -0,0 +1,29 @@
X = adler32.c \
compress.c \
crc32.c \
crc32.h \
deflate.c \
deflate.h \
gzio.c \
infback.c \
inffast.c \
inffast.h \
inffixed.h \
inflate.c \
inflate.h \
inftrees.c \
inftrees.h \
trees.c \
trees.h \
uncompr.c \
zconf.h \
zlib.h \
zutil.c \
zutil.h

if BUILD_ZLIB
noinst_LTLIBRARIES = libz.la
libz_la_SOURCES = $(X)
endif

EXTRA_DIST = $(X)
@@ -0,0 +1,74 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

/* @(#) $Id: adler32.c,v 1.1 2003/12/07 05:29:20 icculus 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) {s1 += buf[i]; s2 += s1;}
#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);

#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)
#else
# define MOD(a) a %= BASE
#endif

/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
const Bytef *buf;
uInt len;
{
unsigned long s1 = adler & 0xffff;
unsigned long s2 = (adler >> 16) & 0xffff;
int k;

if (buf == Z_NULL) return 1L;

while (len > 0) {
k = len < NMAX ? (int)len : NMAX;
len -= k;
while (k >= 16) {
DO16(buf);
buf += 16;
k -= 16;
}
if (k != 0) do {
s1 += *buf++;
s2 += s1;
} while (--k);
MOD(s1);
MOD(s2);
}
return (s2 << 16) | s1;
}
@@ -0,0 +1,79 @@
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/

/* @(#) $Id: compress.c,v 1.1 2003/12/07 05:29:20 icculus 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;
}

0 comments on commit c7fb2e4

Please sign in to comment.