zlib 1.1.0
This commit is contained in:
parent
b8c9ecb076
commit
965fe72aed
11
ChangeLog
11
ChangeLog
@ -1,6 +1,17 @@
|
||||
|
||||
ChangeLog file for zlib
|
||||
|
||||
Changes in 1.1 (24 Feb 98)
|
||||
- do not return STREAM_END prematurely in inflate (John Bowler)
|
||||
- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
|
||||
- compile with -DFASTEST to get compression code optimized for speed only
|
||||
- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
|
||||
- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
|
||||
on Sun but significant on HP)
|
||||
|
||||
- add a pointer to experimental unzip library in README (Gilles Vollant)
|
||||
- initialize variable gcc in configure (Chris Herborth)
|
||||
|
||||
Changes in 1.0.9 (17 Feb 1998)
|
||||
- added gzputs and gzgets functions
|
||||
- do not clear eof flag in gzseek (Mark Diekhans)
|
||||
|
2
Makefile
2
Makefile
@ -23,7 +23,7 @@ CFLAGS=-O
|
||||
LDFLAGS=-L. -lz
|
||||
LDSHARED=$(CC)
|
||||
|
||||
VER=1.0.9
|
||||
VER=1.1.0
|
||||
LIBS=libz.a
|
||||
SHAREDLIB=libz.so
|
||||
|
||||
|
@ -23,7 +23,7 @@ CFLAGS=-O
|
||||
LDFLAGS=-L. -lz
|
||||
LDSHARED=$(CC)
|
||||
|
||||
VER=1.0.9
|
||||
VER=1.1.0
|
||||
LIBS=libz.a
|
||||
SHAREDLIB=libz.so
|
||||
|
||||
|
31
README
31
README
@ -1,4 +1,4 @@
|
||||
zlib 1.0.9 is a general purpose data compression library. All the code
|
||||
zlib 1.1.0 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
|
||||
ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
|
||||
@ -25,21 +25,15 @@ Mark Nelson wrote an article about zlib for the Jan. 1997 issue of
|
||||
Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.0.9 are documented in the file ChangeLog.
|
||||
The main changes since 1.0.8 are:
|
||||
The changes made in version 1.1.0 are documented in the file ChangeLog.
|
||||
The main changes since 1.0.9 are:
|
||||
|
||||
- added gzputs and gzgets functions
|
||||
- do not clear eof flag in gzseek (Mark Diekhans)
|
||||
- fix gzseek for files in transparent mode (Mark Diekhans)
|
||||
- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
|
||||
- replace EXPORT with ZEXPORT to avoid conflict with other programs
|
||||
- added compress2 in zconf.h, zlib.def, zlib.dnt
|
||||
- new asm code from Gilles Vollant in contrib/asm386
|
||||
- simplify the inflate code (Mark):
|
||||
. Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
|
||||
. ZALLOC the length list in inflate_trees_fixed() instead of using stack
|
||||
. ZALLOC the value area for huft_build() instead of using stack
|
||||
. Simplify Z_FINISH check in inflate()
|
||||
- do not return STREAM_END prematurely in inflate (John Bowler)
|
||||
- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
|
||||
- compile with -DFASTEST to get compression code optimized for speed only
|
||||
- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
|
||||
- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
|
||||
on Sun but significant on HP)
|
||||
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
@ -56,6 +50,11 @@ A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
|
||||
is available from the Python Software Association sites, such as:
|
||||
ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz
|
||||
|
||||
An experimental package to read files in .zip format, written on top of
|
||||
zlib by Gilles Vollant <info@winimage.com>, is available at
|
||||
http://www.winimage.com/zLibDll/unzip.html
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
||||
@ -83,7 +82,7 @@ Notes for some targets:
|
||||
writes to pointers are atomic. Also the functions zalloc and zfree passed
|
||||
to deflateInit must be multi-threaded in this case.
|
||||
|
||||
- gzdopen is not supported on RISCOS, BEOS and Mac
|
||||
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
||||
|
||||
- For Turbo C the small model is supported only with reduced performance to
|
||||
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
|
||||
|
19
configure
vendored
19
configure
vendored
@ -27,6 +27,7 @@ prefix=${prefix-/usr/local}
|
||||
exec_prefix=${exec_prefix-$prefix}
|
||||
shared_ext='.so'
|
||||
shared=0
|
||||
gcc=0
|
||||
old_cc="$CC"
|
||||
old_cflags="$CFLAGS"
|
||||
|
||||
@ -114,7 +115,6 @@ if test $shared -eq 0; then
|
||||
LDSHARED="$CC"
|
||||
echo Building static library $LIBS version $VER with $CC.
|
||||
fi
|
||||
rm -f $test.[co] $test$shared_ext
|
||||
|
||||
if test -f /usr/include/unistd.h; then
|
||||
CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
|
||||
@ -124,6 +124,23 @@ if test ! -f /usr/include/errno.h; then
|
||||
CFLAGS="$CFLAGS -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"
|
||||
echo Checking for mmap support... Yes.
|
||||
else
|
||||
echo Checking for mmap support... No.
|
||||
fi
|
||||
|
||||
rm -f $test.[co] $test$shared_ext
|
||||
|
||||
# udpate Makefile
|
||||
sed < Makefile.in "
|
||||
/^CC *=/s%=.*%=$CC%
|
||||
|
93
deflate.c
93
deflate.c
@ -52,7 +52,7 @@
|
||||
#include "deflate.h"
|
||||
|
||||
const char deflate_copyright[] =
|
||||
" deflate 1.0.9 Copyright 1995-1998 Jean-loup Gailly ";
|
||||
" deflate 1.1.0 Copyright 1995-1998 Jean-loup Gailly ";
|
||||
/*
|
||||
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
|
||||
@ -160,14 +160,23 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
||||
* Insert string str in the dictionary and set match_head to the previous head
|
||||
* of the hash chain (the most recent string with same hash key). Return
|
||||
* the previous length of the hash chain.
|
||||
* If this file is compiled with -DFASTEST, the compression level is forced
|
||||
* to 1, and no hash chains are maintained.
|
||||
* IN assertion: all calls to to INSERT_STRING are made with consecutive
|
||||
* input characters and the first MIN_MATCH bytes of str are valid
|
||||
* (except for the last MIN_MATCH-1 bytes of the input file).
|
||||
*/
|
||||
#ifdef FASTEST
|
||||
#define INSERT_STRING(s, str, match_head) \
|
||||
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
|
||||
match_head = s->head[s->ins_h], \
|
||||
s->head[s->ins_h] = (Pos)(str))
|
||||
#else
|
||||
#define INSERT_STRING(s, str, match_head) \
|
||||
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
|
||||
s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \
|
||||
s->head[s->ins_h] = (Pos)(str))
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Initialize the hash table (avoiding 64K overflow for 16 bit systems).
|
||||
@ -224,6 +233,9 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||
if (strm->zfree == Z_NULL) strm->zfree = zcfree;
|
||||
|
||||
if (level == Z_DEFAULT_COMPRESSION) level = 6;
|
||||
#ifdef FASTEST
|
||||
level = 1;
|
||||
#endif
|
||||
|
||||
if (windowBits < 0) { /* undocumented feature: suppress zlib header */
|
||||
noheader = 1;
|
||||
@ -708,6 +720,7 @@ local void lm_init (s)
|
||||
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
||||
* match.S. The code will be functionally equivalent.
|
||||
*/
|
||||
#ifndef FASTEST
|
||||
local uInt longest_match(s, cur_match)
|
||||
deflate_state *s;
|
||||
IPos cur_match; /* current match */
|
||||
@ -845,6 +858,64 @@ local uInt longest_match(s, cur_match)
|
||||
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
|
||||
return s->lookahead;
|
||||
}
|
||||
|
||||
#else /* FASTEST */
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Optimized version for level == 1 only
|
||||
*/
|
||||
local uInt longest_match(s, cur_match)
|
||||
deflate_state *s;
|
||||
IPos cur_match; /* current match */
|
||||
{
|
||||
register Bytef *scan = s->window + s->strstart; /* current string */
|
||||
register Bytef *match; /* matched string */
|
||||
register int len; /* length of current match */
|
||||
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
|
||||
|
||||
/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
|
||||
* It is easy to get rid of this optimization if necessary.
|
||||
*/
|
||||
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
||||
|
||||
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
||||
|
||||
Assert(cur_match < s->strstart, "no future");
|
||||
|
||||
match = s->window + cur_match;
|
||||
|
||||
/* Return failure if the match length is less than 2:
|
||||
*/
|
||||
if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
|
||||
|
||||
/* The check at best_len-1 can be removed because it will be made
|
||||
* again later. (This heuristic is not always a win.)
|
||||
* It is not necessary to compare scan[2] and match[2] since they
|
||||
* are always equal when the other bytes match, given that
|
||||
* the hash keys are equal and that HASH_BITS >= 8.
|
||||
*/
|
||||
scan += 2, match += 2;
|
||||
Assert(*scan == *match, "match[2]?");
|
||||
|
||||
/* We check for insufficient lookahead only every 8th comparison;
|
||||
* the 256th check will be made at strstart+258.
|
||||
*/
|
||||
do {
|
||||
} while (*++scan == *++match && *++scan == *++match &&
|
||||
*++scan == *++match && *++scan == *++match &&
|
||||
*++scan == *++match && *++scan == *++match &&
|
||||
*++scan == *++match && *++scan == *++match &&
|
||||
scan < strend);
|
||||
|
||||
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
||||
|
||||
len = MAX_MATCH - (int)(strend - scan);
|
||||
|
||||
if (len < MIN_MATCH) return MIN_MATCH - 1;
|
||||
|
||||
s->match_start = cur_match;
|
||||
return len <= s->lookahead ? len : s->lookahead;
|
||||
}
|
||||
#endif /* FASTEST */
|
||||
#endif /* ASMV */
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -930,6 +1001,7 @@ local void fill_window(s)
|
||||
} while (--n);
|
||||
|
||||
n = wsize;
|
||||
#ifndef FASTEST
|
||||
p = &s->prev[n];
|
||||
do {
|
||||
m = *--p;
|
||||
@ -938,6 +1010,7 @@ local void fill_window(s)
|
||||
* its value will never be used.
|
||||
*/
|
||||
} while (--n);
|
||||
#endif
|
||||
more += wsize;
|
||||
}
|
||||
if (s->strm->avail_in == 0) return;
|
||||
@ -1105,14 +1178,15 @@ local block_state deflate_fast(s, flush)
|
||||
if (s->match_length >= MIN_MATCH) {
|
||||
check_match(s, s->strstart, s->match_start, s->match_length);
|
||||
|
||||
bflush = _tr_tally(s, s->strstart - s->match_start,
|
||||
s->match_length - MIN_MATCH);
|
||||
_tr_tally_dist(s, s->strstart - s->match_start,
|
||||
s->match_length - MIN_MATCH, bflush);
|
||||
|
||||
s->lookahead -= s->match_length;
|
||||
|
||||
/* Insert new strings in the hash table only if the match length
|
||||
* is not too large. This saves time but degrades compression.
|
||||
*/
|
||||
#ifndef FASTEST
|
||||
if (s->match_length <= s->max_insert_length &&
|
||||
s->lookahead >= MIN_MATCH) {
|
||||
s->match_length--; /* string at strstart already in hash table */
|
||||
@ -1124,7 +1198,9 @@ local block_state deflate_fast(s, flush)
|
||||
*/
|
||||
} while (--s->match_length != 0);
|
||||
s->strstart++;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
s->strstart += s->match_length;
|
||||
s->match_length = 0;
|
||||
s->ins_h = s->window[s->strstart];
|
||||
@ -1139,7 +1215,7 @@ local block_state deflate_fast(s, flush)
|
||||
} else {
|
||||
/* No match, output a literal byte */
|
||||
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||
bflush = _tr_tally (s, 0, s->window[s->strstart]);
|
||||
_tr_tally_lit (s, s->window[s->strstart], bflush);
|
||||
s->lookahead--;
|
||||
s->strstart++;
|
||||
}
|
||||
@ -1219,7 +1295,7 @@ local block_state deflate_slow(s, flush)
|
||||
check_match(s, s->strstart-1, s->prev_match, s->prev_length);
|
||||
|
||||
bflush = _tr_tally(s, s->strstart -1 - s->prev_match,
|
||||
s->prev_length - MIN_MATCH);
|
||||
s->prev_length - MIN_MATCH);
|
||||
|
||||
/* Insert in hash table all strings up to the end of the match.
|
||||
* strstart-1 and strstart are already inserted. If there is not
|
||||
@ -1245,7 +1321,8 @@ local block_state deflate_slow(s, flush)
|
||||
* is longer, truncate the previous match to a single literal.
|
||||
*/
|
||||
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
||||
if (_tr_tally (s, 0, s->window[s->strstart-1])) {
|
||||
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
||||
if (bflush) {
|
||||
FLUSH_BLOCK_ONLY(s, 0);
|
||||
}
|
||||
s->strstart++;
|
||||
@ -1263,7 +1340,7 @@ local block_state deflate_slow(s, flush)
|
||||
Assert (flush != Z_NO_FLUSH, "no flush?");
|
||||
if (s->match_available) {
|
||||
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
||||
_tr_tally (s, 0, s->window[s->strstart-1]);
|
||||
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
||||
s->match_available = 0;
|
||||
}
|
||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
||||
|
42
deflate.h
42
deflate.h
@ -273,4 +273,46 @@ ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
void _tr_align OF((deflate_state *s));
|
||||
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
int eof));
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
||||
* must not have side effects. _dist_code[256] and _dist_code[257] are never
|
||||
* used.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG
|
||||
/* Inline versions of _tr_tally for speed: */
|
||||
|
||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
extern uch _length_code[];
|
||||
extern uch _dist_code[];
|
||||
#else
|
||||
extern const uch _length_code[];
|
||||
extern const uch _dist_code[];
|
||||
#endif
|
||||
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->d_buf[s->last_lit] = 0; \
|
||||
s->l_buf[s->last_lit++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (length); \
|
||||
ush dist = (distance); \
|
||||
s->d_buf[s->last_lit] = dist; \
|
||||
s->l_buf[s->last_lit++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
}
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) _tr_tally(s, 0, c, flush)
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
_tr_tally(s, distance, length, flush)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
7
gzio.c
7
gzio.c
@ -13,7 +13,8 @@
|
||||
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
#define Z_BUFSIZE 4096
|
||||
#define Z_BUFSIZE 16384
|
||||
#define Z_PRINTF_BUFSIZE 4096
|
||||
|
||||
#define ALLOC(size) malloc(size)
|
||||
#define TRYFREE(p) {if (p) free(p);}
|
||||
@ -506,7 +507,7 @@ int ZEXPORT gzwrite (file, buf, len)
|
||||
|
||||
int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
|
||||
{
|
||||
char buf[Z_BUFSIZE];
|
||||
char buf[Z_PRINTF_BUFSIZE];
|
||||
va_list va;
|
||||
int len;
|
||||
|
||||
@ -531,7 +532,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
||||
{
|
||||
char buf[Z_BUFSIZE];
|
||||
char buf[Z_PRINTF_BUFSIZE];
|
||||
int len;
|
||||
|
||||
#ifdef HAS_snprintf
|
||||
|
@ -229,6 +229,7 @@ int f;
|
||||
r = f;
|
||||
if (r != Z_STREAM_END)
|
||||
return r;
|
||||
r = f;
|
||||
inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
|
||||
if (z->state->nowrap)
|
||||
{
|
||||
@ -322,7 +323,8 @@ z_streamp z;
|
||||
/* search */
|
||||
while (n && m < 4)
|
||||
{
|
||||
if (*p == (Byte)(m < 2 ? 0 : (Byte)0xff))
|
||||
static const Byte mark[4] = {0, 0, 0xff, 0xff};
|
||||
if (*p == mark[m])
|
||||
m++;
|
||||
else if (*p)
|
||||
m = 0;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "inftrees.h"
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.0.9 Copyright 1995-1998 Mark Adler ";
|
||||
" inflate 1.1.0 Copyright 1995-1998 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
|
||||
|
66
minigzip.c
66
minigzip.c
@ -25,6 +25,11 @@
|
||||
extern void exit OF((int));
|
||||
#endif
|
||||
|
||||
#ifdef USE_MMAP
|
||||
# include <sys/types.h>
|
||||
# include <sys/mman.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32)
|
||||
# include <fcntl.h>
|
||||
@ -53,7 +58,7 @@
|
||||
#endif
|
||||
#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
|
||||
|
||||
#define BUFLEN 4096
|
||||
#define BUFLEN 16384
|
||||
#define MAX_NAME_LEN 1024
|
||||
|
||||
#ifdef MAXSEG_64K
|
||||
@ -65,12 +70,15 @@
|
||||
|
||||
char *prog;
|
||||
|
||||
void error OF((const char *msg));
|
||||
void gz_compress OF((FILE *in, gzFile out));
|
||||
void gz_uncompress OF((gzFile in, FILE *out));
|
||||
void file_compress OF((char *file, char *mode));
|
||||
void file_uncompress OF((char *file));
|
||||
int main OF((int argc, char *argv[]));
|
||||
void error OF((const char *msg));
|
||||
void gz_compress OF((FILE *in, gzFile out));
|
||||
#ifdef USE_MMAP
|
||||
int gz_compress_mmap OF((FILE *in, gzFile out));
|
||||
#endif
|
||||
void gz_uncompress OF((gzFile in, FILE *out));
|
||||
void file_compress OF((char *file, char *mode));
|
||||
void file_uncompress OF((char *file));
|
||||
int main OF((int argc, char *argv[]));
|
||||
|
||||
/* ===========================================================================
|
||||
* Display error message and exit
|
||||
@ -85,6 +93,7 @@ void error(msg)
|
||||
/* ===========================================================================
|
||||
* Compress input to output then close both files.
|
||||
*/
|
||||
|
||||
void gz_compress(in, out)
|
||||
FILE *in;
|
||||
gzFile out;
|
||||
@ -93,6 +102,12 @@ void gz_compress(in, out)
|
||||
int len;
|
||||
int err;
|
||||
|
||||
#ifdef USE_MMAP
|
||||
/* Try first compressing with mmap. If mmap fails (minigzip used in a
|
||||
* pipe), use the normal fread loop.
|
||||
*/
|
||||
if (gz_compress_mmap(in, out) == Z_OK) return;
|
||||
#endif
|
||||
for (;;) {
|
||||
len = fread(buf, 1, sizeof(buf), in);
|
||||
if (ferror(in)) {
|
||||
@ -107,6 +122,43 @@ void gz_compress(in, out)
|
||||
if (gzclose(out) != Z_OK) error("failed gzclose");
|
||||
}
|
||||
|
||||
#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
|
||||
|
||||
/* Try compressing the input file at once using mmap. Return Z_OK if
|
||||
* if success, Z_ERRNO otherwise.
|
||||
*/
|
||||
int gz_compress_mmap(in, out)
|
||||
FILE *in;
|
||||
gzFile out;
|
||||
{
|
||||
int len;
|
||||
int err;
|
||||
int ifd = fileno(in);
|
||||
caddr_t buf; /* mmap'ed buffer for the entire input file */
|
||||
off_t buf_len; /* length of the input file */
|
||||
struct stat sb;
|
||||
|
||||
/* Determine the size of the file, needed for mmap: */
|
||||
if (fstat(ifd, &sb) < 0) return Z_ERRNO;
|
||||
buf_len = sb.st_size;
|
||||
if (buf_len <= 0) return Z_ERRNO;
|
||||
|
||||
/* Now do the actual mmap: */
|
||||
buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
|
||||
if (buf == (caddr_t)(-1)) return Z_ERRNO;
|
||||
|
||||
/* Compress the whole file at once: */
|
||||
len = gzwrite(out, (char *)buf, (unsigned)buf_len);
|
||||
|
||||
if (len != (int)buf_len) error(gzerror(out, &err));
|
||||
|
||||
munmap(buf, buf_len);
|
||||
fclose(in);
|
||||
if (gzclose(out) != Z_OK) error("failed gzclose");
|
||||
return Z_OK;
|
||||
}
|
||||
#endif /* USE_MMAP */
|
||||
|
||||
/* ===========================================================================
|
||||
* Uncompress input to output then close both files.
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ SUBSYSTEM WINDOWS
|
||||
|
||||
STUB 'WINSTUB.EXE'
|
||||
|
||||
VERSION 1.09
|
||||
VERSION 1.1
|
||||
|
||||
CODE EXECUTE READ
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#define IDR_VERSION1 1
|
||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||
FILEVERSION 1,0,9,0
|
||||
PRODUCTVERSION 1,0,9,0
|
||||
FILEVERSION 1,1,0,0
|
||||
PRODUCTVERSION 1,1,0,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS 0
|
||||
FILEOS VOS_DOS_WINDOWS32
|
||||
@ -17,7 +17,7 @@ BEGIN
|
||||
|
||||
BEGIN
|
||||
VALUE "FileDescription", "zlib data compression library\0"
|
||||
VALUE "FileVersion", "1.0.9\0"
|
||||
VALUE "FileVersion", "1.1.0\0"
|
||||
VALUE "InternalName", "zlib\0"
|
||||
VALUE "OriginalFilename", "zlib.dll\0"
|
||||
VALUE "ProductName", "ZLib.DLL\0"
|
||||
|
31
trees.c
31
trees.c
@ -99,13 +99,13 @@ local ct_data static_dtree[D_CODES];
|
||||
* 5 bits.)
|
||||
*/
|
||||
|
||||
local uch dist_code[DIST_CODE_LEN];
|
||||
uch _dist_code[DIST_CODE_LEN];
|
||||
/* Distance codes. The first 256 values correspond to the distances
|
||||
* 3 .. 258, the last 256 values correspond to the top 8 bits of
|
||||
* the 15 bit distances.
|
||||
*/
|
||||
|
||||
local uch length_code[MAX_MATCH-MIN_MATCH+1];
|
||||
uch _length_code[MAX_MATCH-MIN_MATCH+1];
|
||||
/* length code for each normalized match length (0 == MIN_MATCH) */
|
||||
|
||||
local int base_length[LENGTH_CODES];
|
||||
@ -173,13 +173,6 @@ local void gen_trees_header OF((void));
|
||||
send_bits(s, tree[c].Code, tree[c].Len); }
|
||||
#endif
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
|
||||
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
||||
* must not have side effects. dist_code[256] and dist_code[257] are never
|
||||
* used.
|
||||
*/
|
||||
|
||||
/* ===========================================================================
|
||||
* Output a short LSB first on the stream.
|
||||
* IN assertion: there is enough room in pendingBuf.
|
||||
@ -262,7 +255,7 @@ local void tr_static_init()
|
||||
for (code = 0; code < LENGTH_CODES-1; code++) {
|
||||
base_length[code] = length;
|
||||
for (n = 0; n < (1<<extra_lbits[code]); n++) {
|
||||
length_code[length++] = (uch)code;
|
||||
_length_code[length++] = (uch)code;
|
||||
}
|
||||
}
|
||||
Assert (length == 256, "tr_static_init: length != 256");
|
||||
@ -270,14 +263,14 @@ local void tr_static_init()
|
||||
* in two different ways: code 284 + 5 bits or code 285, so we
|
||||
* overwrite length_code[255] to use the best encoding:
|
||||
*/
|
||||
length_code[length-1] = (uch)code;
|
||||
_length_code[length-1] = (uch)code;
|
||||
|
||||
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
||||
dist = 0;
|
||||
for (code = 0 ; code < 16; code++) {
|
||||
base_dist[code] = dist;
|
||||
for (n = 0; n < (1<<extra_dbits[code]); n++) {
|
||||
dist_code[dist++] = (uch)code;
|
||||
_dist_code[dist++] = (uch)code;
|
||||
}
|
||||
}
|
||||
Assert (dist == 256, "tr_static_init: dist != 256");
|
||||
@ -285,7 +278,7 @@ local void tr_static_init()
|
||||
for ( ; code < D_CODES; code++) {
|
||||
base_dist[code] = dist << 7;
|
||||
for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
|
||||
dist_code[256 + dist++] = (uch)code;
|
||||
_dist_code[256 + dist++] = (uch)code;
|
||||
}
|
||||
}
|
||||
Assert (dist == 256, "tr_static_init: 256+dist != 512");
|
||||
@ -349,15 +342,15 @@ void gen_trees_header()
|
||||
static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
|
||||
}
|
||||
|
||||
fprintf(header, "local const uch dist_code[DIST_CODE_LEN] = {\n");
|
||||
fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
|
||||
for (i = 0; i < DIST_CODE_LEN; i++) {
|
||||
fprintf(header, "%2u%s", dist_code[i],
|
||||
fprintf(header, "%2u%s", _dist_code[i],
|
||||
SEPARATOR(i, DIST_CODE_LEN-1, 20));
|
||||
}
|
||||
|
||||
fprintf(header, "local const uch length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
|
||||
fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
|
||||
for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
|
||||
fprintf(header, "%2u%s", length_code[i],
|
||||
fprintf(header, "%2u%s", _length_code[i],
|
||||
SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
|
||||
}
|
||||
|
||||
@ -1045,7 +1038,7 @@ int _tr_tally (s, dist, lc)
|
||||
(ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
|
||||
(ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
|
||||
|
||||
s->dyn_ltree[length_code[lc]+LITERALS+1].Freq++;
|
||||
s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
|
||||
s->dyn_dtree[d_code(dist)].Freq++;
|
||||
}
|
||||
|
||||
@ -1094,7 +1087,7 @@ local void compress_block(s, ltree, dtree)
|
||||
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
||||
} else {
|
||||
/* Here, lc is the match length - MIN_MATCH */
|
||||
code = length_code[lc];
|
||||
code = _length_code[lc];
|
||||
send_code(s, code+LITERALS+1, ltree); /* send the length code */
|
||||
extra = extra_lbits[code];
|
||||
if (extra != 0) {
|
||||
|
4
trees.h
4
trees.h
@ -70,7 +70,7 @@ local const ct_data static_dtree[D_CODES] = {
|
||||
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
||||
};
|
||||
|
||||
local const uch dist_code[DIST_CODE_LEN] = {
|
||||
const uch _dist_code[DIST_CODE_LEN] = {
|
||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
@ -99,7 +99,7 @@ local const uch dist_code[DIST_CODE_LEN] = {
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||
};
|
||||
|
||||
local const uch length_code[MAX_MATCH-MIN_MATCH+1]= {
|
||||
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
||||
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
||||
|
4
zlib.3
4
zlib.3
@ -1,4 +1,4 @@
|
||||
.TH ZLIB 3 "16 February 1998"
|
||||
.TH ZLIB 3 "24 February 1998"
|
||||
.SH NAME
|
||||
zlib \- compression/decompression library
|
||||
.SH SYNOPSIS
|
||||
@ -81,7 +81,7 @@ These documents are also available in other formats from:
|
||||
.IP
|
||||
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
.SH AUTHORS
|
||||
Version 1.0.9.
|
||||
Version 1.1.0
|
||||
Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org)
|
||||
and Mark Adler (madler@alumni.caltech.edu).
|
||||
.LP
|
||||
|
4
zlib.h
4
zlib.h
@ -1,5 +1,5 @@
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.0.9, Feb 16th, 1998
|
||||
version 1.1.0, Feb 24th, 1998
|
||||
|
||||
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
|
||||
|
||||
@ -37,7 +37,7 @@ extern "C" {
|
||||
|
||||
#include "zconf.h"
|
||||
|
||||
#define ZLIB_VERSION "1.0.9"
|
||||
#define ZLIB_VERSION "1.1.0"
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
|
Loading…
Reference in New Issue
Block a user