Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Upgraded internal zlib to 1.2.1 (thanks, Adam!)
  • Loading branch information
icculus committed Dec 7, 2003
1 parent e3e3270 commit c7fb2e4
Show file tree
Hide file tree
Showing 27 changed files with 10,103 additions and 43 deletions.
52 changes: 25 additions & 27 deletions Makefile.am.newautomake
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Makefile.am.oldautomake
@@ -1,6 +1,6 @@
lib_LTLIBRARIES = libphysfs.la

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

libphysfsincludedir = $(includedir)
libphysfsinclude_HEADERS = \
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -494,7 +494,7 @@ AC_OUTPUT([
Makefile
archivers/Makefile
platform/Makefile
zlib114/Makefile
zlib121/Makefile
test/Makefile
extras/Makefile
physfs.spec
Expand Down
25 changes: 12 additions & 13 deletions makeos2.cmd
Expand Up @@ -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

Expand Down
29 changes: 29 additions & 0 deletions zlib121/Makefile.am
@@ -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)
74 changes: 74 additions & 0 deletions zlib121/adler32.c
@@ -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;
}
79 changes: 79 additions & 0 deletions zlib121/compress.c
@@ -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.