提交 dc5a43eb 编写于 作者: M Mark Adler

zlib 1.2.3.6

上级 d004b047
......@@ -21,7 +21,6 @@ check_include_file(stddef.h HAVE_STDDEF_H)
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE)
# We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x.
......@@ -34,9 +33,7 @@ endif()
if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif()
check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE)
endif()
......@@ -62,23 +59,6 @@ if(NOT HAVE_ERRNO_H)
add_definitions(-DNO_ERRNO_H)
endif()
#
# Check for mmap support
#
set(mmap_test_code "
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
caddr_t hello() {
return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
}
int main() { return 0; }
")
check_c_source_compiles("${mmap_test_code}" USE_MMAP)
if(USE_MMAP)
add_definitions(-DUSE_MMAP)
endif()
#
# Create the zlibdefs.h file.
# Note: we create it in CMAKE_CURRENT_SOURCE_DIR instead
......@@ -88,7 +68,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h.cmakein
${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h)
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "D")
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
endif()
......@@ -130,15 +110,47 @@ set(ZLIB_SRCS
trees.c
uncompr.c
zutil.c
win32/zlib1.rc
)
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
if(MINGW)
# This gets us DLL resource information when compiling on MinGW.
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND windres.exe
-D GCC_WINDRES
-I ${CMAKE_CURRENT_SOURCE_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(zlib PROPERTIES VERSION 1.2.3.4)
set_target_properties(zlib PROPERTIES SOVERSION 1)
if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
# encoded into their final filename. We disable this on Cygwin because
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
# seems to be the default.
#
# This has no effect with MSVC, on that platform the version info for
# the DLL comes from the resource file win32/zlib1.rc
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
endif()
if(UNIX)
# On unix like platforms the library is almost always called libz
# On unix-like platforms the library is almost always called libz
set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
endif()
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
......
ChangeLog file for zlib
Changes in 1.2.3.6 (17 Jan 2010)
- Avoid void * arithmetic in gzread.c and gzwrite.c
- Make compilers happier with const char * for gz_error message
- Avoid unused parameter warning in inflate.c
- Avoid signed-unsigned comparison warning in inflate.c
- Indent #pragma's for traditional C
- Fix usage of strwinerror() in glib.c, change to gz_strwinerror()
- Correct email address in configure for system options
- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser]
- Update zlib.map [Brown]
- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Tšršk]
- Apply various fixes to CMakeLists.txt [Lowman]
- Add checks on len in gzread() and gzwrite()
- Add error message for no more room for gzungetc()
- Remove zlib version check in gzwrite()
- Defer compression of gzprintf() result until need to
- Use snprintf() in gzdopen() if available
- Remove USE_MMAP configuration determination (only used by minigzip)
- Remove examples/pigz.c (available separately)
- Update examples/gun.c to 1.6
Changes in 1.2.3.5 (8 Jan 2010)
- Add space after #if in zutil.h for some compilers
- Fix relatively harmless bug in deflate_fast() [Exarevsky]
......@@ -21,6 +42,7 @@ Changes in 1.2.3.5 (8 Jan 2010)
- Replace gzio.c with a new set of routines with the same functionality
- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above
- Update contrib/minizip to 1.1b
- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h
Changes in 1.2.3.4 (21 Dec 2009)
- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility
......
# Makefile for zlib
# Copyright (C) 1995-2006 Jean-loup Gailly.
# Copyright (C) 1995-2010 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
......@@ -32,7 +32,7 @@ CPP=$(CC) -E
STATICLIB=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.3.5
SHAREDLIBV=libz.so.1.2.3.6
SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIB) $(SHAREDLIBV)
......@@ -124,10 +124,10 @@ match.lo: match.S
rm -f _match.s
example64.o: example.c zlib.h zconf.h zlibdefs.h
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ $<
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
minigzip64.o: minigzip.c zlib.h zconf.h zlibdefs.h
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ $<
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
.SUFFIXES: .lo
......
# Makefile for zlib
# Copyright (C) 1995-2006 Jean-loup Gailly.
# Copyright (C) 1995-2010 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
......@@ -32,7 +32,7 @@ CPP=$(CC) -E
STATICLIB=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.3.5
SHAREDLIBV=libz.so.1.2.3.6
SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIB) $(SHAREDLIBV)
......@@ -124,10 +124,10 @@ match.lo: match.S
rm -f _match.s
example64.o: example.c zlib.h zconf.h zlibdefs.h
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ $<
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
minigzip64.o: minigzip.c zlib.h zconf.h zlibdefs.h
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ $<
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
.SUFFIXES: .lo
......
ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.3.5 is a general purpose data compression library. All the code is
zlib 1.2.3.6 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
......@@ -33,7 +33,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.2.3.5 are documented in the file ChangeLog.
The changes made in version 1.2.3.6 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib".
......
* ZLIB.INC - Interface to the general purpose compression library
*
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
* Version 1.2.3.5
* Version 1.2.3.6
*
*
* WARNING:
......@@ -22,8 +22,8 @@
*
* Versioning information.
*
D ZLIB_VERSION C '1.2.3.5'
D ZLIB_VERNUM C X'1235'
D ZLIB_VERSION C '1.2.3.6'
D ZLIB_VERNUM C X'1236'
*
* Other equates.
*
......
......@@ -78,6 +78,9 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc"
SFLAGS="${CFLAGS-"-O3"} -fPIC"
CFLAGS="${CFLAGS-"-O3"}"
if test "${ZLIBGCCWARN}" = "YES"; then
CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
fi
if test -z "$uname"; then
uname=`(uname -s || echo unknown) 2>/dev/null`
fi
......@@ -154,8 +157,8 @@ else
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
CFLAGS=${CFLAGS-"-O2"}
LDSHARED=${LDSHARED-"ld"} ;;
SunStudio\ 9*) SFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
CFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"}
SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
UNIX_System_V\ 4.2.0)
SFLAGS=${CFLAGS-"-KPIC -O"}
......@@ -173,7 +176,7 @@ else
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
LDSHARED=${LDSHARED-"xlc -G"} ;;
# send working options for other systems to support@gzip.org
# send working options for other systems to zlib@gzip.org
*) SFLAGS=${CFLAGS-"-O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -shared"} ;;
......@@ -488,22 +491,6 @@ else
SFLAGS="$SFLAGS -DNO_ERRNO_H"
fi
cat > $test.c <<EOF
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
caddr_t hello() {
return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
CFLAGS="$CFLAGS -DUSE_MMAP"
SFLAGS="$SFLAGS -DUSE_MMAP"
echo Checking for mmap support... Yes.
else
echo Checking for mmap support... No.
fi
CPP=${CPP-"$CC -E"}
case $CFLAGS in
*ASMV*)
......
/* inftree9.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2008 Mark Adler
* Copyright (C) 1995-2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
......@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate9_copyright[] =
" inflate9 1.2.3.5 Copyright 1995-2009 Mark Adler ";
" inflate9 1.2.3.6 Copyright 1995-2010 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
......@@ -64,7 +64,7 @@ unsigned short FAR *work;
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
133, 133, 133, 133, 144, 69, 199};
133, 133, 133, 133, 144, 199, 70};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
......
$ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig
$ open/write zdef vmsdefs.h
$ copy sys$input: zdef
$ deck
#define unix
#define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from
#define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator
#define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord
#define Write_EndOfCentralDirectoryRecord Write_EoDRecord
$ eod
$ close zdef
$ copy vmsdefs.h,ioapi.h_orig ioapi.h
$ cc/include=[--]/prefix=all ioapi.c
$ cc/include=[--]/prefix=all miniunz.c
$ cc/include=[--]/prefix=all unzip.c
$ cc/include=[--]/prefix=all minizip.c
$ cc/include=[--]/prefix=all zip.c
$ link miniunz,unzip,ioapi,[--]libz.olb/lib
$ link minizip,zip,ioapi,[--]libz.olb/lib
$ mcr []minizip test minizip64_info.txt
$ mcr []miniunz -l test.zip
$ rename minizip64_info.txt; minizip64_info.txt_old
$ mcr []miniunz test.zip
$ delete test.zip;*
$exit
......@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1,2,3,5
PRODUCTVERSION 1,2,3,5
FILEVERSION 1,2,3,6
PRODUCTVERSION 1,2,3,6
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
......@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression library\0"
VALUE "FileVersion", "1.2.3.5\0"
VALUE "FileVersion", "1.2.3.6\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlib.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2006 Jean-loup Gailly & Mark Adler\0"
VALUE "LegalCopyright", "(C) 1995-2010 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
......
......@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
" deflate 1.2.3.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
" deflate 1.2.3.6 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
......
......@@ -34,12 +34,6 @@ gzlog.h
and deflateSetDictionary()
- illustrates use of a gzip header extra field
pigz.c
parallel implementation of gzip compression
- uses pthreads to speed up compression on multiple core machines
- illustrates the use of deflateSetDictionary() with raw deflate
- illustrates the use of crc32_combine()
zlib_how.html
painfully comprehensive description of zpipe.c (see below)
- describes in excruciating detail the use of deflate() and inflate()
......
/* gun.c -- simple gunzip to give an example of the use of inflateBack()
* Copyright (C) 2003, 2005 Mark Adler
* Copyright (C) 2003, 2005, 2008, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
Version 1.3 12 June 2005 Mark Adler */
Version 1.6 17 January 2010 Mark Adler */
/* Version history:
1.0 16 Feb 2003 First version for testing of inflateBack()
......@@ -15,6 +15,9 @@
1.2 20 Mar 2005 Add Unix compress (LZW) decompression
Copy file attributes from input file to output file
1.3 12 Jun 2005 Add casts for error messages [Oberhumer]
1.4 8 Dec 2006 LZW decompression speed improvements
1.5 9 Feb 2008 Avoid warning in latest version of gcc
1.6 17 Jan 2010 Avoid signed/unsigned comparison warnings
*/
/*
......@@ -197,14 +200,14 @@ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp,
int outfile, z_stream *strm)
{
int last; /* last byte read by NEXT(), or -1 if EOF */
int chunk; /* bytes left in current chunk */
unsigned chunk; /* bytes left in current chunk */
int left; /* bits left in rem */
unsigned rem; /* unused bits from input */
int bits; /* current bits per code */
unsigned code; /* code, table traversal index */
unsigned mask; /* mask for current bits codes */
int max; /* maximum bits per code for this stream */
int flags; /* compress flags, then block compress flag */
unsigned flags; /* compress flags, then block compress flag */
unsigned end; /* last valid entry in prefix/suffix tables */
unsigned temp; /* current code */
unsigned prev; /* previous code */
......@@ -212,6 +215,7 @@ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp,
unsigned stack; /* next position for reversed string */
unsigned outcnt; /* bytes in output buffer */
struct outd outd; /* output structure */
unsigned char *p;
/* set up output */
outd.outfile = outfile;
......@@ -322,10 +326,12 @@ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp,
}
/* walk through linked list to generate output in reverse order */
p = match + stack;
while (code >= 256) {
match[stack++] = suffix[code];
*p++ = suffix[code];
code = prefix[code];
}
stack = p - match;
match[stack++] = (unsigned char)code;
final = code;
......@@ -349,9 +355,11 @@ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp,
}
outcnt = 0;
}
p = match + stack;
do {
outbuf[outcnt++] = match[--stack];
} while (stack);
outbuf[outcnt++] = *--p;
} while (p > match);
stack = 0;
/* loop for next code with final and prev as the last match, rem and
left provide the first 0..7 bits of the next code, end is the last
......@@ -375,7 +383,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
{
int ret, first, last;
unsigned have, flags, len;
unsigned char *next;
unsigned char *next = NULL;
struct ind ind, *indp;
struct outd outd;
......@@ -471,10 +479,10 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
/* check trailer */
ret = Z_BUF_ERROR;
if (NEXT() != (outd.crc & 0xff) ||
NEXT() != ((outd.crc >> 8) & 0xff) ||
NEXT() != ((outd.crc >> 16) & 0xff) ||
NEXT() != ((outd.crc >> 24) & 0xff)) {
if (NEXT() != (int)(outd.crc & 0xff) ||
NEXT() != (int)((outd.crc >> 8) & 0xff) ||
NEXT() != (int)((outd.crc >> 16) & 0xff) ||
NEXT() != (int)((outd.crc >> 24) & 0xff)) {
/* crc error */
if (last != -1) {
strm->msg = (char *)"incorrect data check";
......@@ -482,10 +490,10 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
}
break;
}
if (NEXT() != (outd.total & 0xff) ||
NEXT() != ((outd.total >> 8) & 0xff) ||
NEXT() != ((outd.total >> 16) & 0xff) ||
NEXT() != ((outd.total >> 24) & 0xff)) {
if (NEXT() != (int)(outd.total & 0xff) ||
NEXT() != (int)((outd.total >> 8) & 0xff) ||
NEXT() != (int)((outd.total >> 16) & 0xff) ||
NEXT() != (int)((outd.total >> 24) & 0xff)) {
/* length error */
if (last != -1) {
strm->msg = (char *)"incorrect length check";
......@@ -642,8 +650,8 @@ int main(int argc, char **argv)
argv++;
test = 0;
if (argc && strcmp(*argv, "-h") == 0) {
fprintf(stderr, "gun 1.3 (12 Jun 2005)\n");
fprintf(stderr, "Copyright (c) 2005 Mark Adler\n");
fprintf(stderr, "gun 1.6 (17 Jan 2010)\n");
fprintf(stderr, "Copyright (C) 2003-2010 Mark Adler\n");
fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]\n");
return 0;
}
......
/* pigz.c -- parallel implementation of gzip
* Copyright (C) 2007 Mark Adler
* Version 1.1 28 January 2007 Mark Adler
*/
/* Version history:
1.0 17 Jan 2007 First version
1.1 28 Jan 2007 Avoid void * arithmetic (some compilers don't get that)
Add note about requiring zlib 1.2.3
Allow compression level 0 (no compression)
Completely rewrite parallelism -- add a write thread
Use deflateSetDictionary() to make use of history
Tune argument defaults to best performance on four cores
*/
/*
pigz compresses from stdin to stdout using threads to make use of multiple
processors and cores. The input is broken up into 128 KB chunks, and each
is compressed separately. The CRC for each chunk is also calculated
separately. The compressed chunks are written in order to the output,
and the overall CRC is calculated from the CRC's of the chunks.
The compressed data format generated is the gzip format using the deflate
compression method. First a gzip header is written, followed by raw deflate
partial streams. They are partial, in that they do not have a terminating
block. At the end, the deflate stream is terminated with a final empty
static block, and lastly a gzip trailer is written with the CRC and the
number of input bytes.
Each raw deflate partial stream is terminated by an empty stored block
(using the Z_SYNC_FLUSH option of zlib), in order to end that partial
bit stream at a byte boundary. That allows the partial streams to be
concantenated simply as sequences of bytes. This adds a very small four
or five byte overhead to the output for each input chunk.
zlib's crc32_combine() routine allows the calcuation of the CRC of the
entire input using the independent CRC's of the chunks. pigz requires zlib
version 1.2.3 or later, since that is the first version that provides the
crc32_combine() function.
pigz uses the POSIX pthread library for thread control and communication.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include "zlib.h"
#define local static
/* exit with error */
local void bail(char *msg)
{
fprintf(stderr, "pigz abort: %s\n", msg);
exit(1);
}
/* read up to len bytes into buf, repeating read() calls as needed */
local size_t readn(int desc, unsigned char *buf, size_t len)
{
ssize_t ret;
size_t got;
got = 0;
while (len) {
ret = read(desc, buf, len);
if (ret < 0)
bail("read error");
if (ret == 0)
break;
buf += ret;
len -= ret;
got += ret;
}
return got;
}
/* write len bytes, repeating write() calls as needed */
local void writen(int desc, unsigned char *buf, size_t len)
{
ssize_t ret;
while (len) {
ret = write(desc, buf, len);
if (ret < 1)
bail("write error");
buf += ret;
len -= ret;
}
}
/* a flag variable for communication between two threads */
struct flag {
int value; /* value of flag */
pthread_mutex_t lock; /* lock for checking and changing flag */
pthread_cond_t cond; /* condition for signaling on flag change */
};
/* initialize a flag for use, starting with value val */
local void flag_init(struct flag *me, int val)
{
me->value = val;
pthread_mutex_init(&(me->lock), NULL);
pthread_cond_init(&(me->cond), NULL);
}
/* set the flag to val, signal another process that may be waiting for it */
local void flag_set(struct flag *me, int val)
{
pthread_mutex_lock(&(me->lock));
me->value = val;
pthread_cond_signal(&(me->cond));
pthread_mutex_unlock(&(me->lock));
}
/* if it isn't already, wait for some other thread to set the flag to val */
local void flag_wait(struct flag *me, int val)
{
pthread_mutex_lock(&(me->lock));
while (me->value != val)
pthread_cond_wait(&(me->cond), &(me->lock));
pthread_mutex_unlock(&(me->lock));
}
/* if flag is equal to val, wait for some other thread to change it */
local void flag_wait_not(struct flag *me, int val)
{
pthread_mutex_lock(&(me->lock));
while (me->value == val)
pthread_cond_wait(&(me->cond), &(me->lock));
pthread_mutex_unlock(&(me->lock));
}
/* clean up the flag when done with it */
local void flag_done(struct flag *me)
{
pthread_cond_destroy(&(me->cond));
pthread_mutex_destroy(&(me->lock));
}
/* a unit of work to feed to compress_thread() -- it is assumed that the out
buffer is large enough to hold the maximum size len bytes could deflate to,
plus five bytes for the final sync marker */
struct work {
size_t len; /* length of input */
unsigned long crc; /* crc of input */
unsigned char *buf; /* input */
unsigned char *out; /* space for output (guaranteed big enough) */
z_stream strm; /* pre-initialized z_stream */
struct flag busy; /* busy flag indicating work unit in use */
pthread_t comp; /* this compression thread */
};
/* busy flag values */
#define IDLE 0 /* compress and writing done -- can start compress */
#define COMP 1 /* compress -- input and output buffers in use */
#define WRITE 2 /* compress done, writing output -- can read input */
/* read-only globals (set by main/read thread before others started) */
local int ind; /* input file descriptor */
local int outd; /* output file descriptor */
local int level; /* compression level */
local int procs; /* number of compression threads (>= 2) */
local size_t size; /* uncompressed input size per thread (>= 32K) */
local struct work *jobs; /* work units: jobs[0..procs-1] */
/* next and previous jobs[] indices */
#define NEXT(n) ((n) == procs - 1 ? 0 : (n) + 1)
#define PREV(n) ((n) == 0 ? procs - 1 : (n) - 1)
/* sliding dictionary size for deflate */
#define DICT 32768U
/* largest power of 2 that fits in an unsigned int -- used to limit requests
to zlib functions that use unsigned int lengths */
#define MAX ((((unsigned)-1) >> 1) + 1)
/* compress thread: compress the input in the provided work unit and compute
its crc -- assume that the amount of space at job->out is guaranteed to be
enough for the compressed output, as determined by the maximum expansion
of deflate compression -- use the input in the previous work unit (if there
is one) to set the deflate dictionary for better compression */
local void *compress_thread(void *arg)
{
size_t len; /* input length for this work unit */
unsigned long crc; /* crc of input data */
struct work *prev; /* previous work unit */
struct work *job = arg; /* work unit for this thread */
z_stream *strm = &(job->strm); /* zlib stream for this work unit */
/* reset state for a new compressed stream */
(void)deflateReset(strm);
/* initialize input, output, and crc */
strm->next_in = job->buf;
strm->next_out = job->out;
len = job->len;
crc = crc32(0L, Z_NULL, 0);
/* set dictionary if this isn't the first work unit, and if we will be
compressing something (the read thread assures that the dictionary
data in the previous work unit is still there) */
prev = jobs + PREV(job - jobs);
if (prev->buf != NULL && len != 0)
deflateSetDictionary(strm, prev->buf + (size - DICT), DICT);
/* run MAX-sized amounts of input through deflate and crc32 -- this loop
is needed for those cases where the integer type is smaller than the
size_t type, or when len is close to the limit of the size_t type */
while (len > MAX) {
strm->avail_in = MAX;
strm->avail_out = (unsigned)-1;
crc = crc32(crc, strm->next_in, strm->avail_in);
(void)deflate(strm, Z_NO_FLUSH);
len -= MAX;
}
/* run last piece through deflate and crc32, follow with a sync marker */
if (len) {
strm->avail_in = len;
strm->avail_out = (unsigned)-1;
crc = crc32(crc, strm->next_in, strm->avail_in);
(void)deflate(strm, Z_SYNC_FLUSH);
}
/* don't need to Z_FINISH, since we'd delete the last two bytes anyway */
/* return result */
job->crc = crc;
return NULL;
}
/* put a 4-byte integer into a byte array in LSB order */
#define PUT4(a,b) (*(a)=(b),(a)[1]=(b)>>8,(a)[2]=(b)>>16,(a)[3]=(b)>>24)
/* write thread: wait for compression threads to complete, write output in
order, also write gzip header and trailer around the compressed data */
local void *write_thread(void *arg)
{
int n; /* compress thread index */
size_t len; /* length of input processed */
unsigned long tot; /* total uncompressed size (overflow ok) */
unsigned long crc; /* CRC-32 of uncompressed data */
unsigned char wrap[10]; /* gzip header or trailer */
/* write simple gzip header */
memcpy(wrap, "\037\213\10\0\0\0\0\0\0\3", 10);
wrap[8] = level == 9 ? 2 : (level == 1 ? 4 : 0);
writen(outd, wrap, 10);
/* process output of compress threads until end of input */
tot = 0;
crc = crc32(0L, Z_NULL, 0);
n = 0;
do {
/* wait for compress thread to start, then wait to complete */
flag_wait(&(jobs[n].busy), COMP);
pthread_join(jobs[n].comp, NULL);
/* now that compress is done, allow read thread to use input buffer */
flag_set(&(jobs[n].busy), WRITE);
/* write compressed data and update length and crc */
writen(outd, jobs[n].out, jobs[n].strm.next_out - jobs[n].out);
len = jobs[n].len;
tot += len;
crc = crc32_combine(crc, jobs[n].crc, len);
/* release this work unit and go to the next work unit */
flag_set(&(jobs[n].busy), IDLE);
n = NEXT(n);
/* an input buffer less than size in length indicates end of input */
} while (len == size);
/* write final static block and gzip trailer (crc and len mod 2^32) */
wrap[0] = 3; wrap[1] = 0;
PUT4(wrap + 2, crc);
PUT4(wrap + 6, tot);
writen(outd, wrap, 10);
return NULL;
}
/* one-time initialization of a work unit -- this is where we set the deflate
compression level and request raw deflate, and also where we set the size
of the output buffer to guarantee enough space for a worst-case deflate
ending with a Z_SYNC_FLUSH */
local void job_init(struct work *job)
{
int ret; /* deflateInit2() return value */
job->buf = malloc(size);
job->out = malloc(size + (size >> 11) + 10);
job->strm.zfree = Z_NULL;
job->strm.zalloc = Z_NULL;
job->strm.opaque = Z_NULL;
ret = deflateInit2(&(job->strm), level, Z_DEFLATED, -15, 8,
Z_DEFAULT_STRATEGY);
if (job->buf == NULL || job->out == NULL || ret != Z_OK)
bail("not enough memory");
}
/* compress ind to outd in the gzip format, using multiple threads for the
compression and crc calculation and another thread for writing the output --
the read thread is the main thread */
local void read_thread(void)
{
int n; /* general index */
size_t got; /* amount read */
pthread_attr_t attr; /* thread attributes (left at defaults) */
pthread_t write; /* write thread */
/* set defaults (not all pthread implementations default to joinable) */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
/* allocate and set up work list (individual work units will be initialized
as needed, in case the input is short), assure that allocation size
arithmetic does not overflow */
if (size + (size >> 11) + 10 < (size >> 11) + 10 ||
(ssize_t)(size + (size >> 11) + 10) < 0 ||
((size_t)0 - 1) / procs <= sizeof(struct work) ||
(jobs = malloc(procs * sizeof(struct work))) == NULL)
bail("not enough memory");
for (n = 0; n < procs; n++) {
jobs[n].buf = NULL;
flag_init(&(jobs[n].busy), IDLE);
}
/* start write thread */
pthread_create(&write, &attr, write_thread, NULL);
/* read from input and start compress threads (write thread will pick up
the output of the compress threads) */
n = 0;
do {
/* initialize this work unit if it's the first time it's used */
if (jobs[n].buf == NULL)
job_init(jobs + n);
/* read input data, but wait for last compress on this work unit to be
done, and wait for the dictionary to be used by the last compress on
the next work unit */
flag_wait_not(&(jobs[n].busy), COMP);
flag_wait_not(&(jobs[NEXT(n)].busy), COMP);
got = readn(ind, jobs[n].buf, size);
/* start compress thread, but wait for write to be done first */
flag_wait(&(jobs[n].busy), IDLE);
jobs[n].len = got;
pthread_create(&(jobs[n].comp), &attr, compress_thread, jobs + n);
/* mark work unit so write thread knows compress was started */
flag_set(&(jobs[n].busy), COMP);
/* go to the next work unit */
n = NEXT(n);
/* do until end of input, indicated by a read less than size */
} while (got == size);
/* wait for the write thread to complete -- the write thread will join with
all of the compress threads, so this waits for all of the threads to
complete */
pthread_join(write, NULL);
/* free up all requested resources and return */
for (n = procs - 1; n >= 0; n--) {
flag_done(&(jobs[n].busy));
(void)deflateEnd(&(jobs[n].strm));
free(jobs[n].out);
free(jobs[n].buf);
}
free(jobs);
pthread_attr_destroy(&attr);
}
/* Process arguments for level, size, and procs, compress from stdin to
stdout in the gzip format. Note that procs must be at least two in
order to provide a dictionary in one work unit for the other work
unit, and that size must be at least 32K to store a full dictionary. */
int main(int argc, char **argv)
{
int n; /* general index */
int get; /* command line parameters to get */
char *arg; /* command line argument */
/* set defaults -- 32 processes and 128K buffers was found to provide
good utilization of four cores (about 97%) and balanced the overall
execution time impact of more threads against more dictionary
processing for a fixed amount of memory -- the memory usage for these
settings and full use of all work units (at least 4 MB of input) is
16.2 MB
*/
level = Z_DEFAULT_COMPRESSION;
procs = 32;
size = 131072UL;
/* process command-line arguments */
get = 0;
for (n = 1; n < argc; n++) {
arg = argv[n];
if (*arg == '-') {
while (*++arg)
if (*arg >= '0' && *arg <= '9') /* compression level */
level = *arg - '0';
else if (*arg == 'b') /* chunk size in K */
get |= 1;
else if (*arg == 'p') /* number of processes */
get |= 2;
else if (*arg == 'h') { /* help */
fputs("usage: pigz [-0..9] [-b blocksizeinK]", stderr);
fputs(" [-p processes] < foo > foo.gz\n", stderr);
return 0;
}
else
bail("invalid option");
}
else if (get & 1) {
if (get & 2)
bail("you need to separate the -b and -p options");
size = (size_t)(atol(arg)) << 10; /* chunk size */
if (size < DICT)
bail("invalid option");
get = 0;
}
else if (get & 2) {
procs = atoi(arg); /* processes */
if (procs < 2)
bail("invalid option");
get = 0;
}
else
bail("invalid option (you need to pipe input and output)");
}
if (get)
bail("missing option argument");
/* do parallel compression from stdin to stdout (the read thread starts up
the write thread and the compression threads, and they all join before
the read thread returns) */
ind = 0;
outd = 1;
read_thread();
/* done */
return 0;
}
......@@ -15,10 +15,12 @@
#define ZLIB_INTERNAL
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "zlib.h"
#ifdef STDC
# include <string.h>
# include <stdlib.h>
#endif
#include <fcntl.h>
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS
......@@ -42,7 +44,8 @@
/* get errno and strerror definition */
#if defined UNDER_CE && defined NO_ERRNO_H
# define zstrerror(errnum) strwinerror((DWORD)errnum)
# include <windows.h>
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
#else
# ifdef STDC
# include <errno.h>
......@@ -54,7 +57,7 @@
/* MVS fdopen() */
#ifdef __MVS__
# pragma map (fdopen , "\174\174FDOPEN")
#pragma map (fdopen , "\174\174FDOPEN")
FILE *fdopen(int, const char *);
#endif
......@@ -106,4 +109,7 @@ typedef struct {
typedef gz_state FAR *gz_statep;
/* shared functions */
ZEXTERN void ZEXPORT gz_error OF((gz_statep, int, char *));
ZEXTERN void ZEXPORT gz_error OF((gz_statep, int, const char *));
#if defined UNDER_CE && defined NO_ERRNO_H
ZEXTERN char ZEXPORT *gz_strwinerror OF((DWORD error));
#endif
......@@ -95,7 +95,7 @@ local char *strwinerror (error)
#endif /* UNDER_CE && NO_ERRNO_H */
#ifdef __MVS__
# pragma map (fdopen , "\174\174FDOPEN")
#pragma map (fdopen , "\174\174FDOPEN")
FILE *fdopen(int, const char *);
#endif
......
......@@ -18,21 +18,17 @@ local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const char *, int, const char *, int));
#if defined UNDER_CE && defined NO_ERRNO_H
local char *strwinerror OF((DWORD error));
# include <windows.h>
/* Map the Windows error number in ERROR to a locale-dependent error message
string and return a pointer to it. Typically, the values for ERROR come
from GetLastError.
/* Map the Windows error number in ERROR to a locale-dependent error
message string and return a pointer to it. Typically, the values
for ERROR come from GetLastError.
The string pointed to shall not be modified by the application, but may be
overwritten by a subsequent call to gz_strwinerror
The string pointed to shall not be modified by the application,
but may be overwritten by a subsequent call to strwinerror
The strwinerror function does not change the current setting
of GetLastError. */
local char *strwinerror (error)
The gz_strwinerror function does not change the current setting of
GetLastError. */
char ZEXPORT *gz_strwinerror (error)
DWORD error;
{
static char buf[1024];
......@@ -82,18 +78,18 @@ local void gz_reset(state)
state->have = 0; /* no output data available */
state->eof = 0; /* not at end of file */
}
state->seek = 0; /* no seek request pending */
gz_error(state, Z_OK, NULL); /* clear error */
state->pos = 0; /* no uncompressed data yet */
state->strm.avail_in = 0; /* no input data yet */
state->seek = 0; /* no seek request pending */
gz_error(state, Z_OK, NULL); /* clear error */
state->pos = 0; /* no uncompressed data yet */
state->strm.avail_in = 0; /* no input data yet */
}
/* Open a gzip file either by name or file descriptor. */
local gzFile gz_open(path, fd, mode, use64)
local gzFile gz_open(path, fd, mode, large)
const char *path;
int fd;
const char *mode;
int use64;
int large;
{
gz_statep state;
......@@ -156,9 +152,13 @@ local gzFile gz_open(path, fd, mode, use64)
/* open the file with the appropriate mode (or just use fd) */
state->fd = fd != -1 ? fd :
open(path,
(large ?
#ifdef O_LARGEFILE
(use64 ? O_LARGEFILE : 0) |
O_LARGEFILE
#else
0
#endif
: 0) |
#ifdef O_BINARY
O_BINARY |
#endif
......@@ -214,13 +214,16 @@ gzFile ZEXPORT gzdopen(fd, mode)
int fd;
const char *mode;
{
char path[46]; /* allow up to 128-bit integers, so don't worry --
the sprintf() is safe */
char path[46]; /* identifier for error messages */
if (fd < 0)
return NULL;
sprintf(path, "<fd:%d>", fd); /* for error messages */
return gz_open(path, fd, mode, 1);
#ifdef NO_snprintf
sprintf(path, "<fd:%d>", fd); /* big enough for 128-bit integers */
#else
snprintf(path, sizeof(path), "<fd:%d>", fd);
#endif
return gz_open(path, fd, mode, 0);
}
/* -- see zlib.h -- */
......@@ -325,7 +328,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
return -1;
}
/* if reading, skip what's in output buffer (one less gz_getc() check) */
/* if reading, skip what's in output buffer (one less gzgetc() check) */
if (state->mode == GZ_READ) {
n = state->have > offset ? (unsigned)offset : state->have;
state->have -= n;
......@@ -422,10 +425,10 @@ int ZEXPORT gzeof(file)
/* get internal structure and check integrity */
if (file == NULL)
return -1;
return 0;
state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return -1;
return 0;
/* return end-of-file state */
return state->mode == GZ_READ ? (state->eof && state->have == 0) : 0;
......@@ -470,15 +473,15 @@ void ZEXPORT gzclearerr(file)
}
/* Create an error message in allocated memory and set state->err and
state->msg accordingly. Free any previous error message already there. Do
state->msg accordingly. Free any previous error message already there. Do
not try to free or allocate space if the error is Z_MEM_ERROR (out of
memory). Simply save the error message as a static string. If there is
an allocation failure constructing the error message, then convert the
error to out of memory. */
memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to
out of memory. */
void ZEXPORT gz_error(state, err, msg)
gz_statep state;
int err;
char *msg;
const char *msg;
{
/* free previously allocated message and clear */
if (state->msg != NULL) {
......@@ -494,14 +497,14 @@ void ZEXPORT gz_error(state, err, msg)
/* for an out of memory error, save as static string */
if (err == Z_MEM_ERROR) {
state->msg = msg;
state->msg = (char *)msg;
return;
}
/* construct error message with path */
if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
state->err = Z_MEM_ERROR;
state->msg = "out of memory";
state->msg = (char *)"out of memory";
return;
}
strcpy(state->msg, state->path);
......
......@@ -69,8 +69,8 @@ local int gz_avail(state)
(strm->avail_in == 0 ? -1 : \
(strm->avail_in--, *(strm->next_in)++)))
/* Get a four-byte little-endian integer and return 0 on success and the
value in *ret. Otherwise -1 is returned and *ret is not modified. */
/* Get a four-byte little-endian integer and return 0 on success and the value
in *ret. Otherwise -1 is returned and *ret is not modified. */
local int gz_next4(state, ret)
gz_statep state;
unsigned long *ret;
......@@ -93,7 +93,7 @@ local int gz_next4(state, ret)
/* Look for gzip header, set up for inflate or copy. state->have must be zero.
If this is the first time in, allocate required memory. state->how will be
left unchanged if there is no more input data available, will be set to 1 if
there is no gzip header and direct copying will be performned, or it will be
there is no gzip header and direct copying will be performed, or it will be
set to 2 for decompression, and the gzip header will be skipped so that the
next available input data is the raw deflate stream. If direct copying,
then leftover input data from the input buffer will be copied to the output
......@@ -190,6 +190,8 @@ local int gz_head(state)
NEXT();
NEXT();
}
/* an unexpected end of file is not checked for here -- it will be
noticed on the first request for uncompressed data */
/* set up for decompression */
inflateReset(strm);
......@@ -206,7 +208,7 @@ local int gz_head(state)
/* doing raw i/o, save start of raw data for seeking, copy any leftover
input to output -- this assumes that the output buffer is larger than
the input buffer */
the input buffer, which also assures space for gzungetc() */
state->raw = state->pos;
state->next = state->out;
if (strm->avail_in) {
......@@ -220,10 +222,10 @@ local int gz_head(state)
/* Decompress from input to the provided next_out and avail_out in the state.
If the end of the compressed data is reached, then verify the gzip trailer
check value and length (modulo 2^32). state->have and state->next are
set to point to the just decompressed data, and the crc is updated. If the
check value and length (modulo 2^32). state->have and state->next are set
to point to the just decompressed data, and the crc is updated. If the
trailer is verified, state->how is reset to zero to look for the next gzip
stream or raw data, once state->have is depleted. Returns 0 on success, -1
stream or raw data, once state->have is depleted. Returns 0 on success, -1
on failure. Failures may include invalid compressed data or a failed gzip
trailer verification. */
local int gz_decomp(state)
......@@ -372,6 +374,17 @@ int ZEXPORT gzread(file, buf, len)
if (state->mode != GZ_READ || state->err != Z_OK)
return -1;
/* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids the flaw in the interface) */
if ((int)len < 0) {
gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
return -1;
}
/* if len is zero, avoid unnecessary operations */
if (len == 0)
return 0;
/* process a skip request */
if (state->seek) {
state->seek = 0;
......@@ -381,8 +394,7 @@ int ZEXPORT gzread(file, buf, len)
/* get len bytes to buf, or less than len if at the end */
got = 0;
while (len) {
do {
/* first just try copying data from the output buffer */
if (state->have) {
n = state->have > len ? len : state->have;
......@@ -402,6 +414,8 @@ int ZEXPORT gzread(file, buf, len)
if (gz_make(state) == -1)
return -1;
continue; /* no progress yet -- go back to memcpy() above */
/* the copy above assures that we will leave with space in the
output buffer, allowing at least one gzungetc() to succeed */
}
/* large len -- read directly into user buffer */
......@@ -422,13 +436,13 @@ int ZEXPORT gzread(file, buf, len)
/* update progress */
len -= n;
buf += n;
buf = (char *)buf + n;
got += n;
state->pos += n;
}
} while (len);
/* return number of bytes read into user buffer */
return (int)got; /* len had better fit in int -- interface flaw */
/* return number of bytes read into user buffer (will fit in int) */
return (int)got;
}
/* -- see zlib.h -- */
......@@ -448,7 +462,7 @@ int ZEXPORT gzgetc(file)
if (state->mode != GZ_READ || state->err != Z_OK)
return -1;
/* try output buffer */
/* try output buffer (no need to check for skip request) */
if (state->have) {
state->have--;
state->pos++;
......@@ -496,9 +510,11 @@ int ZEXPORT gzungetc(c, file)
return c;
}
/* if no room, give up (must have already done a gz_ungetc()) */
if (state->have == (state->size << 1))
/* if no room, give up (must have already done a gzungetc()) */
if (state->have == (state->size << 1)) {
gz_error(state, Z_BUF_ERROR, "out of room to push characters");
return -1;
}
/* slide output data if needed and insert byte before existing data */
if (state->next == state->out) {
......
......@@ -20,15 +20,6 @@ local int gz_init(state)
int ret;
z_streamp strm = &(state->strm);
/* check version of zlib -- need 1.2.1 or later for gzip deflate() */
#ifdef ZLIB_VERNUM
if (ZLIB_VERNUM < 0x1210)
#endif
{
gz_error(state, Z_VERSION_ERROR, "need zlib 1.2.1 or later");
return -1;
}
/* allocate input and output buffers */
state->in = malloc(state->want);
state->out = malloc(state->want);
......@@ -169,6 +160,17 @@ int ZEXPORT gzwrite(file, buf, len)
if (state->mode != GZ_WRITE || state->err != Z_OK)
return -1;
/* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids the flaw in the interface) */
if ((int)len < 0) {
gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
return -1;
}
/* if len is zero, avoid unnecessary operations */
if (len == 0)
return 0;
/* allocate memory if this is the first time through */
if (state->size == 0 && gz_init(state) == -1)
return -1;
......@@ -183,7 +185,7 @@ int ZEXPORT gzwrite(file, buf, len)
/* for small len, copy to input buffer, otherwise compress directly */
if (len < state->size) {
/* copy to input buffer, compress when full */
while (len) {
do {
if (strm->avail_in == 0)
strm->next_in = state->in;
n = state->size - strm->avail_in;
......@@ -192,11 +194,11 @@ int ZEXPORT gzwrite(file, buf, len)
memcpy(strm->next_in + strm->avail_in, buf, n);
strm->avail_in += n;
state->pos += n;
buf += n;
buf = (char *)buf + n;
len -= n;
if (len && gz_comp(state, Z_NO_FLUSH) == -1)
return -1;
}
} while (len);
}
else {
/* consume whatever's left in the input buffer */
......@@ -211,7 +213,7 @@ int ZEXPORT gzwrite(file, buf, len)
return -1;
}
/* input was all buffered or compressed */
/* input was all buffered or compressed (put will fit in int) */
return (int)put;
}
......@@ -332,12 +334,10 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
return 0;
/* write out result of printf() */
/* update buffer and position, defer compression until needed */
strm->avail_in = (unsigned)len;
strm->next_in = state->in;
state->pos += len;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
return len;
}
......@@ -408,12 +408,10 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
return 0;
/* write out result of printf() */
/* update buffer and position, defer compression until needed */
strm->avail_in = (unsigned)len;
strm->next_in = state->in;
state->pos += len;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
return len;
}
......
......@@ -154,7 +154,7 @@ int windowBits;
/* set number of window bits, free window if different */
if (windowBits && (windowBits < 8 || windowBits > 15))
return Z_STREAM_ERROR;
if (state->wbits != windowBits && state->window != Z_NULL) {
if (state->wbits != (unsigned)windowBits && state->window != Z_NULL) {
ZFREE(strm, state->window);
state->window = Z_NULL;
}
......@@ -1458,8 +1458,8 @@ int subvert;
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
state->sane = !subvert;
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
return Z_OK;
#else
state->sane = 1;
......
......@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
" inflate 1.2.3.5 Copyright 1995-2010 Mark Adler ";
" inflate 1.2.3.6 Copyright 1995-2010 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
......@@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 69, 199};
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 70};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
......
......@@ -11,15 +11,18 @@ $!------------------------------------------------------------------------------
$! Version history
$! 0.01 20060120 First version to receive a number
$! 0.02 20061008 Adapt to new Makefile.in
$! 0.03 20091224 Add support for large file check
$! 0.04 20100110 Add new gzclose, gzlib, gzread, gzwrite
$!
$ on error then goto err_exit
$!
$!
$! Just some general constants...
$!
$ true = 1
$ false = 0
$ tmpnam = "temp_" + f$getjpi("","pid")
$ tt = tmpnam + ".txt"
$ tc = tmpnam + ".c"
$ th = tmpnam + ".h"
$ define/nolog tconfig 'th'
$ its_decc = false
$ its_vaxc = false
$ its_gnuc = false
......@@ -27,17 +30,25 @@ $ s_case = False
$!
$! Setup variables holding "config" information
$!
$ Make = ""
$ Make = ""
$ name = "Zlib"
$ version = "?.?.?"
$ v_string = "ZLIB_VERSION"
$ v_file = "zlib.h"
$ ccopt = ""
$ lopts = ""
$ ccopt = ""
$ lopts = ""
$ dnsrl = ""
$ aconf_in_file = "config.hin"
$ conf_check_string = ""
$ linkonly = false
$ optfile = name + ".opt"
$ axp = f$getsyi("HW_MODEL").ge.1024
$ libdefs = ""
$ axp = f$getsyi("HW_MODEL").ge.1024 .and. f$getsyi("HW_MODEL").lt.4096
$!
$ whoami = f$parse(f$enviornment("Procedure"),,,,"NO_CONCEAL")
$ mydef = F$parse(whoami,,,"DEVICE")
$ mydir = f$parse(whoami,,,"DIRECTORY") - "]["
$ myproc = f$parse(whoami,,,"Name") + f$parse(whoami,,,"type")
$!
$! Check for MMK/MMS
$!
......@@ -47,11 +58,16 @@ $!
$!
$ gosub find_version
$!
$ open/write topt tmp.opt
$ open/write optf 'optfile'
$!
$ gosub check_opts
$!
$! Look for the compiler used
$!
$ gosub check_compiler
$ close topt
$!
$ if its_decc
$ then
$ ccopt = "/prefix=all" + ccopt
......@@ -71,6 +87,49 @@ $ then
$ if f$trnlnm("SYS").eqs."" then define sys sys$library:
$ endif
$!
$! Build a fake configure input header
$!
$ open/write conf_hin config.hin
$ write conf_hin "#undef _LARGEFILE64_SOURCE"
$ close conf_hin
$!
$!
$ i = 0
$FIND_ACONF:
$ fname = f$element(i,"#",aconf_in_file)
$ if fname .eqs. "#" then goto AMISS_ERR
$ if f$search(fname) .eqs. ""
$ then
$ i = i + 1
$ goto find_aconf
$ endif
$ open/read/err=aconf_err aconf_in 'fname'
$ open/write aconf zlibdefs.h
$ACONF_LOOP:
$ read/end_of_file=aconf_exit aconf_in line
$ work = f$edit(line, "compress,trim")
$ if f$extract(0,6,work) .nes. "#undef"
$ then
$ write aconf line
$ else
$ cdef = f$element(1," ",work)
$ gosub check_config
$ endif
$ goto aconf_loop
$ACONF_EXIT:
$ write aconf "#define VMS 1"
$ write aconf "#include <unistd.h>"
$ write aconf "#include <unixio.h>"
$ write aconf "#ifdef _LARGEFILE"
$ write aconf "#define off64_t __off64_t"
$ write aconf "#define fopen64 fopen"
$ write aconf "#define fseeko64 fseeko"
$ write aconf "#define lseek64 lseek"
$ write aconf "#define ftello64 ftell"
$ write aconf "#endif"
$ close aconf_in
$ close aconf
$ delete 'th';*
$! Build the thing plain or with mms
$!
$ write sys$output "Compiling Zlib sources ..."
......@@ -86,15 +145,15 @@ $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
$ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
deflate.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
$ CALL MAKE gzclose.OBJ "CC ''CCOPT' gzclose" -
gzclose.c zlib.h zconf.h zlibdefs.h gzguts.h
gzclose.c zutil.h zlib.h zconf.h zlibdefs.h
$ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" -
gzio.c zutil.h zlib.h zconf.h zlibdefs.h
$ CALL MAKE gzlib.OBJ "CC ''CCOPT' gzlib" -
gzlib.c zlib.h zconf.h zlibdefs.h gzguts.h
gzlib.c zutil.h zlib.h zconf.h zlibdefs.h
$ CALL MAKE gzread.OBJ "CC ''CCOPT' gzread" -
gzread.c zlib.h zconf.h zlibdefs.h gzguts.h
gzread.c zutil.h zlib.h zconf.h zlibdefs.h
$ CALL MAKE gzwrite.OBJ "CC ''CCOPT' gzwrite" -
gzwrite.c zlib.h zconf.h zlibdefs.h gzguts.h
gzwrite.c zutil.h zlib.h zconf.h zlibdefs.h
$ CALL MAKE infback.OBJ "CC ''CCOPT' infback" -
infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
$ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" -
......@@ -153,6 +212,14 @@ $ goto err_exit
$ERR_EXIT:
$ set message/facil/ident/sever/text
$ close/nolog optf
$ close/nolog topt
$ close/nolog conf_hin
$ close/nolog aconf_in
$ close/nolog aconf
$ close/nolog out
$ close/nolog min
$ close/nolog mod
$ close/nolog h_in
$ write sys$output "Exiting..."
$ exit 2
$!
......@@ -200,61 +267,72 @@ $!------------------------------------------------------------------------------
$!
$! Check command line options and set symbols accordingly
$!
$!------------------------------------------------------------------------------
$! Version history
$! 0.01 20041206 First version to receive a number
$! 0.02 20060126 Add new "HELP" target
$ CHECK_OPTS:
$ i = 1
$ OPT_LOOP:
$ if i .lt. 9
$ then
$ cparm = f$edit(p'i',"upcase")
$ if cparm .eqs. "DEBUG"
$ then
$ ccopt = ccopt + "/noopt/deb"
$ lopts = lopts + "/deb"
$ endif
$ if f$locate("CCOPT=",cparm) .lt. f$length(cparm)
$ then
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ ccopt = ccopt + f$extract(start,len,cparm)
$ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) -
then s_case = true
$ endif
$ if cparm .eqs. "LINK" then linkonly = true
$ if f$locate("LOPTS=",cparm) .lt. f$length(cparm)
$ then
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ lopts = lopts + f$extract(start,len,cparm)
$ endif
$ if f$locate("CC=",cparm) .lt. f$length(cparm)
$!
$! Check if parameter actually contains something
$!
$ if f$edit(cparm,"trim") .nes. ""
$ then
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ cc_com = f$extract(start,len,cparm)
if (cc_com .nes. "DECC") .and. -
(cc_com .nes. "VAXC") .and. -
(cc_com .nes. "GNUC")
$ if cparm .eqs. "DEBUG"
$ then
$ write sys$output "Unsupported compiler choice ''cc_com' ignored"
$ write sys$output "Use DECC, VAXC, or GNUC instead"
$ else
$ if cc_com .eqs. "DECC" then its_decc = true
$ if cc_com .eqs. "VAXC" then its_vaxc = true
$ if cc_com .eqs. "GNUC" then its_gnuc = true
$ ccopt = ccopt + "/noopt/deb"
$ lopts = lopts + "/deb"
$ endif
$ endif
$ if f$locate("MAKE=",cparm) .lt. f$length(cparm)
$ then
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ mmks = f$extract(start,len,cparm)
$ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS")
$ if f$locate("CCOPT=",cparm) .lt. f$length(cparm)
$ then
$ make = mmks
$ else
$ write sys$output "Unsupported make choice ''mmks' ignored"
$ write sys$output "Use MMK or MMS instead"
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ ccopt = ccopt + f$extract(start,len,cparm)
$ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) -
then s_case = true
$ endif
$ if cparm .eqs. "LINK" then linkonly = true
$ if f$locate("LOPTS=",cparm) .lt. f$length(cparm)
$ then
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ lopts = lopts + f$extract(start,len,cparm)
$ endif
$ if f$locate("CC=",cparm) .lt. f$length(cparm)
$ then
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ cc_com = f$extract(start,len,cparm)
if (cc_com .nes. "DECC") .and. -
(cc_com .nes. "VAXC") .and. -
(cc_com .nes. "GNUC")
$ then
$ write sys$output "Unsupported compiler choice ''cc_com' ignored"
$ write sys$output "Use DECC, VAXC, or GNUC instead"
$ else
$ if cc_com .eqs. "DECC" then its_decc = true
$ if cc_com .eqs. "VAXC" then its_vaxc = true
$ if cc_com .eqs. "GNUC" then its_gnuc = true
$ endif
$ endif
$ if f$locate("MAKE=",cparm) .lt. f$length(cparm)
$ then
$ start = f$locate("=",cparm) + 1
$ len = f$length(cparm) - start
$ mmks = f$extract(start,len,cparm)
$ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS")
$ then
$ make = mmks
$ else
$ write sys$output "Unsupported make choice ''mmks' ignored"
$ write sys$output "Use MMK or MMS instead"
$ endif
$ endif
$ if cparm .eqs. "HELP" then gosub bhelp
$ endif
$ i = i + 1
$ goto opt_loop
......@@ -267,6 +345,8 @@ $!
$! Version history
$! 0.01 20040223 First version to receive a number
$! 0.02 20040229 Save/set value of decc$no_rooted_search_lists
$! 0.03 20060202 Extend handling of GNU C
$! 0.04 20090402 Compaq -> hp
$CHECK_COMPILER:
$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
$ then
......@@ -282,15 +362,21 @@ $ then goto CC_ERR
$ else
$ if its_decc
$ then
$ write sys$output "CC compiler check ... Compaq C"
$ write sys$output "CC compiler check ... hp C"
$ if f$trnlnm("decc$no_rooted_search_lists") .nes. ""
$ then
$ dnrsl = f$trnlnm("decc$no_rooted_search_lists")
$ endif
$ define decc$no_rooted_search_lists 1
$ define/nolog decc$no_rooted_search_lists 1
$ else
$ if its_vaxc then write sys$output "CC compiler check ... VAX C"
$ if its_gnuc then write sys$output "CC compiler check ... GNU C"
$ if its_gnuc
$ then
$ write sys$output "CC compiler check ... GNU C"
$ if f$trnlnm(topt) then write topt "gnu_cc:[000000]gcclib.olb/lib"
$ if f$trnlnm(optf) then write optf "gnu_cc:[000000]gcclib.olb/lib"
$ cc = "gcc"
$ endif
$ if f$trnlnm(topt) then write topt "sys$share:vaxcrtl.exe/share"
$ if f$trnlnm(optf) then write optf "sys$share:vaxcrtl.exe/share"
$ endif
......@@ -310,7 +396,8 @@ $ deck
# written by Martin P.J. Zinser
# <zinser@zinser.no-ip.info or zinser@sysdev.deutsche-boerse.com>
OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj, infback.obj\
OBJS = adler32.obj, compress.obj, crc32.obj, gzclose.obj, gzio.obj, gzlib.obj\
gzread.obj, gzwrite.obj, uncompr.obj, infback.obj\
deflate.obj, trees.obj, zutil.obj, inflate.obj, \
inftrees.obj, inffast.obj
......@@ -342,7 +429,11 @@ compress.obj : compress.c zlib.h zconf.h zlibdefs.h
crc32.obj : crc32.c zutil.h zlib.h zconf.h zlibdefs.h
deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
example.obj : example.c zlib.h zconf.h zlibdefs.h
gzclose.obj : gzclose.c zutil.h zlib.h zconf.h zlibdefs.h
gzio.obj : gzio.c zutil.h zlib.h zconf.h zlibdefs.h
gzlib.obj : gzlib.c zutil.h zlib.h zconf.h zlibdefs.h
gzread.obj : gzread.c zutil.h zlib.h zconf.h zlibdefs.h
gzwrite.obj : gzwrite.c zutil.h zlib.h zconf.h zlibdefs.h
inffast.obj : inffast.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inffast.h
inflate.obj : inflate.c zutil.h zlib.h zconf.h zlibdefs.h
inftrees.obj : inftrees.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
......@@ -416,6 +507,169 @@ $ close h_in
$ return
$!------------------------------------------------------------------------------
$!
$CHECK_CONFIG:
$!
$ in_ldef = f$locate(cdef,libdefs)
$ if (in_ldef .lt. f$length(libdefs))
$ then
$ write aconf "#define ''cdef' 1"
$ libdefs = f$extract(0,in_ldef,libdefs) + -
f$extract(in_ldef + f$length(cdef) + 1, -
f$length(libdefs) - in_ldef - f$length(cdef) - 1, -
libdefs)
$ else
$ if (f$type('cdef') .eqs. "INTEGER")
$ then
$ write aconf "#define ''cdef' ", 'cdef'
$ else
$ if (f$type('cdef') .eqs. "STRING")
$ then
$ write aconf "#define ''cdef' ", """", '''cdef'', """"
$ else
$ gosub check_cc_def
$ endif
$ endif
$ endif
$ return
$!------------------------------------------------------------------------------
$!
$! Check if this is a define relating to the properties of the C/C++
$! compiler
$!
$ CHECK_CC_DEF:
$ if (cdef .eqs. "_LARGEFILE64_SOURCE")
$ then
$ copy sys$input: 'tc'
$ deck
#include "tconfig"
#define _LARGEFILE
#include <stdio.h>
int main(){
FILE *fp;
fp = fopen("temp.txt","r");
fseeko(fp,1,SEEK_SET);
fclose(fp);
}
$ eod
$ test_inv = false
$ comm_h = false
$ gosub cc_prop_check
$ return
$ endif
$ write aconf "/* ", line, " */"
$ return
$!------------------------------------------------------------------------------
$!
$! Check for properties of C/C++ compiler
$!
$! Version history
$! 0.01 20031020 First version to receive a number
$! 0.02 20031022 Added logic for defines with value
$! 0.03 20040309 Make sure local config file gets not deleted
$! 0.04 20041230 Also write include for configure run
$! 0.05 20050103 Add processing of "comment defines"
$CC_PROP_CHECK:
$ cc_prop = true
$ is_need = false
$ is_need = (f$extract(0,4,cdef) .eqs. "NEED") .or. (test_inv .eq. true)
$ if f$search(th) .eqs. "" then create 'th'
$ set message/nofac/noident/nosever/notext
$ on error then continue
$ cc 'tmpnam'
$ if .not. ($status) then cc_prop = false
$ on error then continue
$! The headers might lie about the capabilities of the RTL
$ link 'tmpnam',tmp.opt/opt
$ if .not. ($status) then cc_prop = false
$ set message/fac/ident/sever/text
$ on error then goto err_exit
$ delete/nolog 'tmpnam'.*;*/exclude='th'
$ if (cc_prop .and. .not. is_need) .or. -
(.not. cc_prop .and. is_need)
$ then
$ write sys$output "Checking for ''cdef'... yes"
$ if f$type('cdef_val'_yes) .nes. ""
$ then
$ if f$type('cdef_val'_yes) .eqs. "INTEGER" -
then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_yes)
$ if f$type('cdef_val'_yes) .eqs. "STRING" -
then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_yes)
$ else
$ call write_config f$fao("#define !AS 1",cdef)
$ endif
$ if (cdef .eqs. "HAVE_FSEEKO") .or. (cdef .eqs. "_LARGE_FILES") .or. -
(cdef .eqs. "_LARGEFILE64_SOURCE") then -
call write_config f$string("#define _LARGEFILE 1")
$ else
$ write sys$output "Checking for ''cdef'... no"
$ if (comm_h)
$ then
call write_config f$fao("/* !AS */",line)
$ else
$ if f$type('cdef_val'_no) .nes. ""
$ then
$ if f$type('cdef_val'_no) .eqs. "INTEGER" -
then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_no)
$ if f$type('cdef_val'_no) .eqs. "STRING" -
then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_no)
$ else
$ call write_config f$fao("#undef !AS",cdef)
$ endif
$ endif
$ endif
$ return
$!------------------------------------------------------------------------------
$!
$! Check for properties of C/C++ compiler with multiple result values
$!
$! Version history
$! 0.01 20040127 First version
$! 0.02 20050103 Reconcile changes from cc_prop up to version 0.05
$CC_MPROP_CHECK:
$ cc_prop = true
$ i = 1
$ idel = 1
$ MT_LOOP:
$ if f$type(result_'i') .eqs. "STRING"
$ then
$ set message/nofac/noident/nosever/notext
$ on error then continue
$ cc 'tmpnam'_'i'
$ if .not. ($status) then cc_prop = false
$ on error then continue
$! The headers might lie about the capabilities of the RTL
$ link 'tmpnam'_'i',tmp.opt/opt
$ if .not. ($status) then cc_prop = false
$ set message/fac/ident/sever/text
$ on error then goto err_exit
$ delete/nolog 'tmpnam'_'i'.*;*
$ if (cc_prop)
$ then
$ write sys$output "Checking for ''cdef'... ", mdef_'i'
$ if f$type(mdef_'i') .eqs. "INTEGER" -
then call write_config f$fao("#define !AS !UL",cdef,mdef_'i')
$ if f$type('cdef_val'_yes) .eqs. "STRING" -
then call write_config f$fao("#define !AS !AS",cdef,mdef_'i')
$ goto msym_clean
$ else
$ i = i + 1
$ goto mt_loop
$ endif
$ endif
$ write sys$output "Checking for ''cdef'... no"
$ call write_config f$fao("#undef !AS",cdef)
$ MSYM_CLEAN:
$ if (idel .le. msym_max)
$ then
$ delete/sym mdef_'idel'
$ idel = idel + 1
$ goto msym_clean
$ endif
$ return
$!------------------------------------------------------------------------------
$!
$! Analyze Object files for OpenVMS AXP to extract Procedure and Data
$! information to build a symbol vector for a shareable image
$! All the "brains" of this logic was suggested by Hartmut Becker
......@@ -533,3 +787,16 @@ $ EXIT_AA:
$ if V then set verify
$ endsubroutine
$!------------------------------------------------------------------------------
$!
$! Write configuration to both permanent and temporary config file
$!
$! Version history
$! 0.01 20031029 First version to receive a number
$!
$WRITE_CONFIG: SUBROUTINE
$ write aconf 'p1'
$ open/append confh 'th'
$ write confh 'p1'
$ close confh
$ENDSUBROUTINE
$!------------------------------------------------------------------------------
此差异已折叠。
......@@ -25,10 +25,10 @@
<QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../libz.so.1.2.3.5" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.3.5"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.3.5"/>
<QPG:Add file="../libz.so.1.2.3.5" install="/opt/lib/" component="slib"/>
<QPG:Add file="../libz.so.1.2.3.6" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.3.6"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.3.6"/>
<QPG:Add file="../libz.so.1.2.3.6" install="/opt/lib/" component="slib"/>
</QPG:Files>
<QPG:PackageFilter>
......@@ -63,7 +63,7 @@
</QPM:ProductDescription>
<QPM:ReleaseDescription>
<QPM:ReleaseVersion>1.2.3.5</QPM:ReleaseVersion>
<QPM:ReleaseVersion>1.2.3.6</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
......
/* uncompr.c -- decompress a memory buffer
* Copyright (C) 1995-2003 Jean-loup Gailly.
* Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
......@@ -16,8 +16,6 @@
been saved previously by the compressor and transmitted to the decompressor
by some mechanism outside the scope of this compression library.)
Upon exit, destLen is the actual size of the compressed buffer.
This function can be used to decompress a whole file at once if the
input file is mmap'ed.
uncompress 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
......
......@@ -382,19 +382,19 @@ typedef uLong FAR uLongf;
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
# pragma map(deflateInit_,"DEIN")
# pragma map(deflateInit2_,"DEIN2")
# pragma map(deflateEnd,"DEEND")
# pragma map(deflateBound,"DEBND")
# pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(compressBound,"CMBND")
# pragma map(inflate_table,"INTABL")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_copyright,"INCOPY")
#pragma map(deflateInit_,"DEIN")
#pragma map(deflateInit2_,"DEIN2")
#pragma map(deflateEnd,"DEEND")
#pragma map(deflateBound,"DEBND")
#pragma map(inflateInit_,"ININ")
#pragma map(inflateInit2_,"ININ2")
#pragma map(inflateEnd,"INEND")
#pragma map(inflateSync,"INSY")
#pragma map(inflateSetDictionary,"INSEDI")
#pragma map(compressBound,"CMBND")
#pragma map(inflate_table,"INTABL")
#pragma map(inflate_fast,"INFA")
#pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */
.TH ZLIB 3 "8 January 2010"
.TH ZLIB 3 "17 January 2010"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
......@@ -17,7 +17,6 @@ but other algorithms will be added later
and will have the same stream interface.
.LP
Compression can be done in a single step if the buffers are large enough
(for example if an input file is mmap'ed),
or can be done by repeated calls of the compression function.
In the latter case,
the application must provide more input and/or consume the output
......@@ -133,8 +132,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS
Version 1.2.3.5
Copyright (C) 1995-2009 Jean-loup Gailly (jloup@gzip.org)
Version 1.2.3.6
Copyright (C) 1995-2010 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
.LP
This software is provided "as-is,"
......
此差异已折叠。
......@@ -14,6 +14,8 @@ ZLIB_1.2.0 {
zcalloc;
zcfree;
z_errmsg;
gz_error;
gzio_old;
_*;
};
......@@ -51,3 +53,11 @@ ZLIB_1.2.3.4 {
inflateReset2;
inflateMark;
} ZLIB_1.2.3.3;
ZLIB_1.2.3.5 {
gzbuffer;
gzoffset;
gzoffset64;
gzclose_r;
gzclose_w;
} ZLIB_1.2.3.4;
......@@ -34,25 +34,25 @@ uLong ZEXPORT zlibCompileFlags()
uLong flags;
flags = 0;
switch (sizeof(uInt)) {
switch ((int)(sizeof(uInt))) {
case 2: break;
case 4: flags += 1; break;
case 8: flags += 2; break;
default: flags += 3;
}
switch (sizeof(uLong)) {
switch ((int)(sizeof(uLong))) {
case 2: break;
case 4: flags += 1 << 2; break;
case 8: flags += 2 << 2; break;
default: flags += 3 << 2;
}
switch (sizeof(voidpf)) {
switch ((int)(sizeof(voidpf))) {
case 2: break;
case 4: flags += 1 << 4; break;
case 8: flags += 2 << 4; break;
default: flags += 3 << 4;
}
switch (sizeof(z_off_t)) {
switch ((int)(sizeof(z_off_t))) {
case 2: break;
case 4: flags += 1 << 6; break;
case 8: flags += 2 << 6; break;
......
......@@ -116,7 +116,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef OS2
# define OS_CODE 0x06
# ifdef M_I86
#include <malloc.h>
# include <malloc.h>
# endif
#endif
......@@ -162,9 +162,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
#if defined(__BORLANDC__)
#pragma warn -8004
#pragma warn -8008
#pragma warn -8066
#pragma warn -8004
#pragma warn -8008
#pragma warn -8066
#endif
#ifdef _LARGEFILE64_SOURCE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册