Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
f7aee86a
Commit
f7aee86a
authored
Aug 09, 2005
by
jimw@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import zlib-1.2.3 library
parent
535ba76b
Changes
22
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1008 additions
and
213 deletions
+1008
-213
zlib/ChangeLog
zlib/ChangeLog
+92
-6
zlib/FAQ
zlib/FAQ
+14
-12
zlib/README
zlib/README
+4
-5
zlib/README.MySQL
zlib/README.MySQL
+7
-0
zlib/adler32.c
zlib/adler32.c
+93
-18
zlib/compress.c
zlib/compress.c
+1
-1
zlib/crc32.c
zlib/crc32.c
+96
-6
zlib/deflate.c
zlib/deflate.c
+258
-24
zlib/deflate.h
zlib/deflate.h
+8
-2
zlib/gzio.c
zlib/gzio.c
+34
-17
zlib/infback.c
zlib/infback.c
+6
-5
zlib/inffast.c
zlib/inffast.c
+13
-0
zlib/inflate.c
zlib/inflate.c
+110
-16
zlib/inflate.h
zlib/inflate.h
+3
-5
zlib/inftrees.c
zlib/inftrees.c
+5
-4
zlib/inftrees.h
zlib/inftrees.h
+5
-5
zlib/trees.c
zlib/trees.c
+20
-16
zlib/zconf.h
zlib/zconf.h
+9
-3
zlib/zlib.3
zlib/zlib.3
+3
-3
zlib/zlib.h
zlib/zlib.h
+193
-36
zlib/zutil.c
zlib/zutil.c
+16
-17
zlib/zutil.h
zlib/zutil.h
+18
-12
No files found.
zlib/ChangeLog
View file @
f7aee86a
ChangeLog file for zlib
ChangeLog file for zlib
Changes in port for MySQL (19 July 2004)
- removed contrib, nt, os2, amiga, directories and some other files not used
Changes in 1.2.3 (18 July 2005)
in MySQL distribution. If you are working on porting MySQL to one of rare
- Apply security vulnerability fixes to contrib/infback9 as well
platforms, you might find worth looking at the original zlib distribution
- Clean up some text files (carriage returns, trailing space)
and using appropriate Makefiles/project files from it.
- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]
Changes in 1.2.2.4 (11 July 2005)
- Add inflatePrime() function for starting inflation at bit boundary
- Avoid some Visual C warnings in deflate.c
- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit
compile
- Fix some spelling errors in comments [Betts]
- Correct inflateInit2() error return documentation in zlib.h
- Added zran.c example of compressed data random access to examples
directory, shows use of inflatePrime()
- Fix cast for assignments to strm->state in inflate.c and infback.c
- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
- Move declarations of gf2 functions to right place in crc32.c [Oberhumer]
- Add cast in trees.c t avoid a warning [Oberhumer]
- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer]
- Update make_vms.com [Zinser]
- Initialize state->write in inflateReset() since copied in inflate_fast()
- Be more strict on incomplete code sets in inflate_table() and increase
ENOUGH and MAXD -- this repairs a possible security vulnerability for
invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
discovering the vulnerability and providing test cases.
- Add ia64 support to configure for HP-UX [Smith]
- Add error return to gzread() for format or i/o error [Levin]
- Use malloc.h for OS/2 [Necasek]
Changes in 1.2.2.3 (27 May 2005)
- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile
- Typecast fread() return values in gzio.c [Vollant]
- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)
- Fix crc check bug in gzread() after gzungetc() [Heiner]
- Add the deflateTune() function to adjust internal compression parameters
- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)
- Remove an incorrect assertion in examples/zpipe.c
- Add C++ wrapper in infback9.h [Donais]
- Fix bug in inflateCopy() when decoding fixed codes
- Note in zlib.h how much deflateSetDictionary() actually uses
- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)
- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]
- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]
- Add gzdirect() function to indicate transparent reads
- Update contrib/minizip [Vollant]
- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]
- Add casts in crc32.c to avoid warnings [Oberhumer]
- Add contrib/masmx64 [Vollant]
- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]
Changes in 1.2.2.2 (30 December 2004)
- Replace structure assignments in deflate.c and inflate.c with zmemcpy to
avoid implicit memcpy calls (portability for no-library compilation)
- Increase sprintf() buffer size in gzdopen() to allow for large numbers
- Add INFLATE_STRICT to check distances against zlib header
- Improve WinCE errno handling and comments [Chang]
- Remove comment about no gzip header processing in FAQ
- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
- Add updated make_vms.com [Coghlan], update README
- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.
- Add FAQ entry and comments in deflate.c on uninitialized memory access
- Add Solaris 9 make options in configure [Gilbert]
- Allow strerror() usage in gzio.c for STDC
- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]
- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]
- Use z_off_t for adler32_combine() and crc32_combine() lengths
- Make adler32() much faster for small len
- Use OS_CODE in deflate() default gzip header
Changes in 1.2.2.1 (31 October 2004)
- Allow inflateSetDictionary() call for raw inflate
- Fix inflate header crc check bug for file names and comments
- Add deflateSetHeader() and gz_header structure for custom gzip headers
- Add inflateGetheader() to retrieve gzip headers
- Add crc32_combine() and adler32_combine() functions
- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list
- Use zstreamp consistently in zlib.h (inflate_back functions)
- Remove GUNZIP condition from definition of inflate_mode in inflate.h
and in contrib/inflate86/inffast.S [Truta, Anderson]
- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]
- Update projects/README.projects and projects/visualc6 [Truta]
- Update win32/DLL_FAQ.txt [Truta]
- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]
- Deprecate Z_ASCII; use Z_TEXT instead [Truta]
- Use a new algorithm for setting strm->data_type in trees.c [Truta]
- Do not define an exit() prototype in zutil.c unless DEBUG defined
- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]
- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()
- Fix Darwin build version identification [Peterson]
Changes in 1.2.2 (3 October 2004)
Changes in 1.2.2 (3 October 2004)
- Update zlib.h comments on gzip in-memory processing
- Update zlib.h comments on gzip in-memory processing
...
@@ -454,7 +540,7 @@ Changes in 1.0.7 (20 Jan 1998)
...
@@ -454,7 +540,7 @@ Changes in 1.0.7 (20 Jan 1998)
Changes in 1.0.6 (19 Jan 1998)
Changes in 1.0.6 (19 Jan 1998)
- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
- Fix a deflate bug occuring only with compression level 0 (thanks to
- Fix a deflate bug occur
r
ing only with compression level 0 (thanks to
Andy Buckler for finding this one).
Andy Buckler for finding this one).
- In minigzip, pass transparently also the first byte for .Z files.
- In minigzip, pass transparently also the first byte for .Z files.
- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
...
...
zlib/FAQ
View file @
f7aee86a
...
@@ -148,13 +148,6 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
...
@@ -148,13 +148,6 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
format using deflateInit2(). You can also request that inflate decode
format using deflateInit2(). You can also request that inflate decode
the gzip format using inflateInit2(). Read zlib.h for more details.
the gzip format using inflateInit2(). Read zlib.h for more details.
Note that you cannot specify special gzip header contents (e.g. a file
name or modification date), nor will inflate tell you what was in the
gzip header. If you need to customize the header or see what's in it,
you can use the raw deflate and inflate operations and the crc32()
function and roll your own gzip encoding and decoding. Read the gzip
RFC 1952 for details of the header and trailer format.
21. Is zlib thread-safe?
21. Is zlib thread-safe?
Yes. However any library routines that zlib uses and any application-
Yes. However any library routines that zlib uses and any application-
...
@@ -295,20 +288,29 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
...
@@ -295,20 +288,29 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
were downright silly. So now, we simply make sure that the code always
were downright silly. So now, we simply make sure that the code always
works.
works.
36. Will zlib read the (insert any ancient or arcane format here) compressed
36. Valgrind (or some similar memory access checker) says that deflate is
performing a conditional jump that depends on an uninitialized value.
Isn't that a bug?
No. That is intentional for performance reasons, and the output of
deflate is not affected. This only started showing up recently since
zlib 1.2.x uses malloc() by default for allocations, whereas earlier
versions used calloc(), which zeros out the allocated memory.
37. Will zlib read the (insert any ancient or arcane format here) compressed
data format?
data format?
Probably not. Look in the comp.compression FAQ for pointers to various
Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.
formats and associated software.
3
7
. How can I encrypt/decrypt zip files with zlib?
3
8
. How can I encrypt/decrypt zip files with zlib?
zlib doesn't support encryption. The original PKZIP encryption is very weak
zlib doesn't support encryption. The original PKZIP encryption is very weak
and can be broken with freely available programs. To get strong encryption,
and can be broken with freely available programs. To get strong encryption,
use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
For PKZIP compatible "encryption", look at http://www.info-zip.org/
For PKZIP compatible "encryption", look at http://www.info-zip.org/
3
8
. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
3
9
. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
"gzip" is the gzip format, and "deflate" is the zlib format. They should
"gzip" is the gzip format, and "deflate" is the zlib format. They should
probably have called the second one "zlib" instead to avoid confusion
probably have called the second one "zlib" instead to avoid confusion
...
@@ -324,14 +326,14 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
...
@@ -324,14 +326,14 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
Bottom line: use the gzip format for HTTP 1.1 encoding.
Bottom line: use the gzip format for HTTP 1.1 encoding.
39
. Does zlib support the new "Deflate64" format introduced by PKWare?
40
. Does zlib support the new "Deflate64" format introduced by PKWare?
No. PKWare has apparently decided to keep that format proprietary, since
No. PKWare has apparently decided to keep that format proprietary, since
they have not documented it as they have previous compression formats.
they have not documented it as they have previous compression formats.
In any case, the compression improvements are so modest compared to other
In any case, the compression improvements are so modest compared to other
more modern approaches, that it's not worth the effort to implement.
more modern approaches, that it's not worth the effort to implement.
4
0
. Can you please sign these lengthy legal documents and fax them back to us
4
1
. Can you please sign these lengthy legal documents and fax them back to us
so that we can use your software in our product?
so that we can use your software in our product?
No. Go away. Shoo.
No. Go away. Shoo.
zlib/README
View file @
f7aee86a
ZLIB DATA COMPRESSION LIBRARY
ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.
2
is a general purpose data compression library. All the code is
zlib 1.2.
3
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
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
...
@@ -16,9 +16,8 @@ minigzip.c.
...
@@ -16,9 +16,8 @@ minigzip.c.
To compile all files and run the test program, follow the instructions given at
To compile all files and run the test program, follow the instructions given at
the top of Makefile. In short "make test; make install" should work for most
the top of Makefile. In short "make test; make install" should work for most
machines. For Unix: "./configure; make test; make install" For MSDOS, use one
machines. For Unix: "./configure; make test; make install". For MSDOS, use one
of the special makefiles such as Makefile.msc. For VMS, use Make_vms.com or
of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
descrip.mms.
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
<info@winimage.com> for the Windows DLL version. The zlib home page is
<info@winimage.com> for the Windows DLL version. The zlib home page is
...
@@ -34,7 +33,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
...
@@ -34,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
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.2.
2
are documented in the file ChangeLog.
The changes made in version 1.2.
3
are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib".
Unsupported third party contributions are provided in directory "contrib".
...
...
zlib/README.MySQL
0 → 100644
View file @
f7aee86a
This an incomplete version of the zlib library -- it excludes some of the
platform-specific project files, contributed code, and examples from the
original zlib distribution. You can find the original distribution at
http://www.gzip.org/zlib/
or
http://www.zlib.net/
zlib/adler32.c
View file @
f7aee86a
/* adler32.c -- compute the Adler-32 checksum of a data stream
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-200
3
Mark Adler
* Copyright (C) 1995-200
4
Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -12,12 +12,13 @@
...
@@ -12,12 +12,13 @@
#define NMAX 5552
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define DO1(buf,i) {
s1 += buf[i]; s2 += s1
;}
#define DO1(buf,i) {
adler += (buf)[i]; sum2 += adler
;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
/* use NO_DIVIDE if your processor does not do division in hardware */
#ifdef NO_DIVIDE
#ifdef NO_DIVIDE
# define MOD(a) \
# define MOD(a) \
do { \
do { \
...
@@ -39,8 +40,17 @@
...
@@ -39,8 +40,17 @@
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
if (a >= BASE) a -= BASE; \
} while (0)
} while (0)
# define MOD4(a) \
do { \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
#else
#else
# define MOD(a) a %= BASE
# define MOD(a) a %= BASE
# define MOD4(a) a %= BASE
#endif
#endif
/* ========================================================================= */
/* ========================================================================= */
...
@@ -49,26 +59,91 @@ uLong ZEXPORT adler32(adler, buf, len)
...
@@ -49,26 +59,91 @@ uLong ZEXPORT adler32(adler, buf, len)
const
Bytef
*
buf
;
const
Bytef
*
buf
;
uInt
len
;
uInt
len
;
{
{
unsigned
long
s1
=
adler
&
0xffff
;
unsigned
long
sum2
;
unsigned
long
s2
=
(
adler
>>
16
)
&
0xffff
;
unsigned
n
;
int
k
;
/* split Adler-32 into component sums */
sum2
=
(
adler
>>
16
)
&
0xffff
;
adler
&=
0xffff
;
/* in case user likes doing a byte at a time, keep it fast */
if
(
len
==
1
)
{
adler
+=
buf
[
0
];
if
(
adler
>=
BASE
)
adler
-=
BASE
;
sum2
+=
adler
;
if
(
sum2
>=
BASE
)
sum2
-=
BASE
;
return
adler
|
(
sum2
<<
16
);
}
if
(
buf
==
Z_NULL
)
return
1L
;
/* initial Adler-32 value (deferred check for len == 1 speed) */
if
(
buf
==
Z_NULL
)
return
1L
;
while
(
len
>
0
)
{
/* in case short lengths are provided, keep it somewhat fast */
k
=
len
<
NMAX
?
(
int
)
len
:
NMAX
;
if
(
len
<
16
)
{
len
-=
k
;
while
(
len
--
)
{
while
(
k
>=
16
)
{
adler
+=
*
buf
++
;
sum2
+=
adler
;
}
if
(
adler
>=
BASE
)
adler
-=
BASE
;
MOD4
(
sum2
);
/* only added so many BASE's */
return
adler
|
(
sum2
<<
16
);
}
/* do length NMAX blocks -- requires just one modulo operation */
while
(
len
>=
NMAX
)
{
len
-=
NMAX
;
n
=
NMAX
/
16
;
/* NMAX is divisible by 16 */
do
{
DO16
(
buf
);
/* 16 sums unrolled */
buf
+=
16
;
}
while
(
--
n
);
MOD
(
adler
);
MOD
(
sum2
);
}
/* do remaining bytes (less than NMAX, still just one modulo) */
if
(
len
)
{
/* avoid modulos if none remaining */
while
(
len
>=
16
)
{
len
-=
16
;
DO16
(
buf
);
DO16
(
buf
);
buf
+=
16
;
buf
+=
16
;
k
-=
16
;
}
}
if
(
k
!=
0
)
do
{
while
(
len
--
)
{
s1
+=
*
buf
++
;
adler
+=
*
buf
++
;
s
2
+=
s1
;
s
um2
+=
adler
;
}
while
(
--
k
);
}
MOD
(
s1
);
MOD
(
adler
);
MOD
(
s2
);
MOD
(
s
um
2
);
}
}
return
(
s2
<<
16
)
|
s1
;
/* return recombined sums */
return
adler
|
(
sum2
<<
16
);
}
/* ========================================================================= */
uLong
ZEXPORT
adler32_combine
(
adler1
,
adler2
,
len2
)
uLong
adler1
;
uLong
adler2
;
z_off_t
len2
;
{
unsigned
long
sum1
;
unsigned
long
sum2
;
unsigned
rem
;
/* the derivation of this formula is left as an exercise for the reader */
rem
=
(
unsigned
)(
len2
%
BASE
);
sum1
=
adler1
&
0xffff
;
sum2
=
rem
*
sum1
;
MOD
(
sum2
);
sum1
+=
(
adler2
&
0xffff
)
+
BASE
-
1
;
sum2
+=
((
adler1
>>
16
)
&
0xffff
)
+
((
adler2
>>
16
)
&
0xffff
)
+
BASE
-
rem
;
if
(
sum1
>
BASE
)
sum1
-=
BASE
;
if
(
sum1
>
BASE
)
sum1
-=
BASE
;
if
(
sum2
>
(
BASE
<<
1
))
sum2
-=
(
BASE
<<
1
);
if
(
sum2
>
BASE
)
sum2
-=
BASE
;
return
sum1
|
(
sum2
<<
16
);
}
}
zlib/compress.c
View file @
f7aee86a
/* compress.c -- compress a memory buffer
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-200
2
Jean-loup Gailly.
* Copyright (C) 1995-200
3
Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
...
zlib/crc32.c
View file @
f7aee86a
/* crc32.c -- compute the CRC-32 of a data stream
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-200
3
Mark Adler
* Copyright (C) 1995-200
5
Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* tables for updating the shift register in one step with three exclusive-ors
* tables for updating the shift register in one step with three exclusive-ors
* instead of four steps with four exclusive-ors. This results
about a factor
* instead of four steps with four exclusive-ors. This results
in about a
* of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*
factor
of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
*/
/* @(#) $Id$ */
/* @(#) $Id$ */
...
@@ -64,6 +64,11 @@
...
@@ -64,6 +64,11 @@
# define TBLS 1
# define TBLS 1
#endif
/* BYFOUR */
#endif
/* BYFOUR */
/* Local functions for crc concatenation */
local
unsigned
long
gf2_matrix_times
OF
((
unsigned
long
*
mat
,
unsigned
long
vec
));
local
void
gf2_matrix_square
OF
((
unsigned
long
*
square
,
unsigned
long
*
mat
));
#ifdef DYNAMIC_CRC_TABLE
#ifdef DYNAMIC_CRC_TABLE
local
volatile
int
crc_table_empty
=
1
;
local
volatile
int
crc_table_empty
=
1
;
...
@@ -72,7 +77,6 @@ local void make_crc_table OF((void));
...
@@ -72,7 +77,6 @@ local void make_crc_table OF((void));
#ifdef MAKECRCH
#ifdef MAKECRCH
local
void
write_table
OF
((
FILE
*
,
const
unsigned
long
FAR
*
));
local
void
write_table
OF
((
FILE
*
,
const
unsigned
long
FAR
*
));
#endif
/* MAKECRCH */
#endif
/* MAKECRCH */
/*
/*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
...
@@ -270,7 +274,7 @@ local unsigned long crc32_little(crc, buf, len)
...
@@ -270,7 +274,7 @@ local unsigned long crc32_little(crc, buf, len)
len
--
;
len
--
;
}
}
buf4
=
(
const
u4
FAR
*
)
buf
;
buf4
=
(
const
u4
FAR
*
)
(
const
void
FAR
*
)
buf
;
while
(
len
>=
32
)
{
while
(
len
>=
32
)
{
DOLIT32
;
DOLIT32
;
len
-=
32
;
len
-=
32
;
...
@@ -310,7 +314,7 @@ local unsigned long crc32_big(crc, buf, len)
...
@@ -310,7 +314,7 @@ local unsigned long crc32_big(crc, buf, len)
len
--
;
len
--
;
}
}
buf4
=
(
const
u4
FAR
*
)
buf
;
buf4
=
(
const
u4
FAR
*
)
(
const
void
FAR
*
)
buf
;
buf4
--
;
buf4
--
;
while
(
len
>=
32
)
{
while
(
len
>=
32
)
{
DOBIG32
;
DOBIG32
;
...
@@ -331,3 +335,89 @@ local unsigned long crc32_big(crc, buf, len)
...
@@ -331,3 +335,89 @@ local unsigned long crc32_big(crc, buf, len)
}
}
#endif
/* BYFOUR */
#endif
/* BYFOUR */
#define GF2_DIM 32
/* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */
local
unsigned
long
gf2_matrix_times
(
mat
,
vec
)
unsigned
long
*
mat
;
unsigned
long
vec
;
{
unsigned
long
sum
;
sum
=
0
;
while
(
vec
)
{
if
(
vec
&
1
)
sum
^=
*
mat
;
vec
>>=
1
;
mat
++
;
}
return
sum
;
}
/* ========================================================================= */
local
void
gf2_matrix_square
(
square
,
mat
)
unsigned
long
*
square
;
unsigned
long
*
mat
;
{
int
n
;
for
(
n
=
0
;
n
<
GF2_DIM
;
n
++
)
square
[
n
]
=
gf2_matrix_times
(
mat
,
mat
[
n
]);
}
/* ========================================================================= */
uLong
ZEXPORT
crc32_combine
(
crc1
,
crc2
,
len2
)
uLong
crc1
;
uLong
crc2
;
z_off_t
len2
;
{
int
n
;
unsigned
long
row
;
unsigned
long
even
[
GF2_DIM
];
/* even-power-of-two zeros operator */
unsigned
long
odd
[
GF2_DIM
];
/* odd-power-of-two zeros operator */
/* degenerate case */
if
(
len2
==
0
)
return
crc1
;
/* put operator for one zero bit in odd */
odd
[
0
]
=
0xedb88320L
;
/* CRC-32 polynomial */
row
=
1
;
for
(
n
=
1
;
n
<
GF2_DIM
;
n
++
)
{
odd
[
n
]
=
row
;
row
<<=
1
;
}
/* put operator for two zero bits in even */
gf2_matrix_square
(
even
,
odd
);
/* put operator for four zero bits in odd */
gf2_matrix_square
(
odd
,
even
);
/* apply len2 zeros to crc1 (first square will put the operator for one
zero byte, eight zero bits, in even) */
do
{
/* apply zeros operator for this bit of len2 */
gf2_matrix_square
(
even
,
odd
);
if
(
len2
&
1
)
crc1
=
gf2_matrix_times
(
even
,
crc1
);
len2
>>=
1
;
/* if no more bits set, then done */
if
(
len2
==
0
)
break
;
/* another iteration of the loop with odd and even swapped */
gf2_matrix_square
(
odd
,
even
);
if
(
len2
&
1
)
crc1
=
gf2_matrix_times
(
odd
,
crc1
);
len2
>>=
1
;
/* if no more bits set, then done */
}
while
(
len2
!=
0
);
/* return combined crc */
crc1
^=
crc2
;
return
crc1
;
}
zlib/deflate.c
View file @
f7aee86a
This diff is collapsed.
Click to expand it.
zlib/deflate.h
View file @
f7aee86a
/* deflate.h -- internal compression state
/* deflate.h -- internal compression state
* Copyright (C) 1995-200
2
Jean-loup Gailly
* Copyright (C) 1995-200
4
Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -49,6 +49,10 @@
...
@@ -49,6 +49,10 @@
/* All codes must not exceed MAX_BITS bits */
/* All codes must not exceed MAX_BITS bits */
#define INIT_STATE 42
#define INIT_STATE 42
#define EXTRA_STATE 69
#define NAME_STATE 73
#define COMMENT_STATE 91
#define HCRC_STATE 103
#define BUSY_STATE 113
#define BUSY_STATE 113
#define FINISH_STATE 666
#define FINISH_STATE 666
/* Stream status */
/* Stream status */
...
@@ -93,8 +97,10 @@ typedef struct internal_state {
...
@@ -93,8 +97,10 @@ typedef struct internal_state {
Bytef
*
pending_buf
;
/* output still pending */
Bytef
*
pending_buf
;
/* output still pending */
ulg
pending_buf_size
;
/* size of pending_buf */
ulg
pending_buf_size
;
/* size of pending_buf */
Bytef
*
pending_out
;
/* next pending byte to output to the stream */
Bytef
*
pending_out
;
/* next pending byte to output to the stream */
int
pending
;
/* nb of bytes in the pending buffer */
uInt
pending
;
/* nb of bytes in the pending buffer */
int
wrap
;
/* bit 0 true for zlib, bit 1 true for gzip */
int
wrap
;
/* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp
gzhead
;
/* gzip header information to write */
uInt
gzindex
;
/* where in extra, name, or comment */
Byte
method
;
/* STORED (for zip only) or DEFLATED */
Byte
method
;
/* STORED (for zip only) or DEFLATED */
int
last_flush
;
/* value of flush param for previous deflate call */
int
last_flush
;
/* value of flush param for previous deflate call */
...
...
zlib/gzio.c
View file @
f7aee86a
/* gzio.c -- IO on .gz files
/* gzio.c -- IO on .gz files
* Copyright (C) 1995-200
3
Jean-loup Gailly.
* Copyright (C) 1995-200
5
Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*
*
* Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
* Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#include "zutil.h"
#include "zutil.h"
#ifdef NO_DEFLATE
/* for compatiblity with old definition */
#ifdef NO_DEFLATE
/* for compatib
i
lity with old definition */
# define NO_GZCOMPRESS
# define NO_GZCOMPRESS
#endif
#endif
...
@@ -220,7 +220,7 @@ gzFile ZEXPORT gzdopen (fd, mode)
...
@@ -220,7 +220,7 @@ gzFile ZEXPORT gzdopen (fd, mode)
int
fd
;
int
fd
;
const
char
*
mode
;
const
char
*
mode
;
{
{
char
name
[
20
];
char
name
[
46
];
/* allow for up to 128-bit integers */
if
(
fd
<
0
)
return
(
gzFile
)
Z_NULL
;
if
(
fd
<
0
)
return
(
gzFile
)
Z_NULL
;
sprintf
(
name
,
"<fd:%d>"
,
fd
);
/* for debugging */
sprintf
(
name
,
"<fd:%d>"
,
fd
);
/* for debugging */
...
@@ -264,7 +264,7 @@ local int get_byte(s)
...
@@ -264,7 +264,7 @@ local int get_byte(s)
if
(
s
->
z_eof
)
return
EOF
;
if
(
s
->
z_eof
)
return
EOF
;
if
(
s
->
stream
.
avail_in
==
0
)
{
if
(
s
->
stream
.
avail_in
==
0
)
{
errno
=
0
;
errno
=
0
;
s
->
stream
.
avail_in
=
fread
(
s
->
inbuf
,
1
,
Z_BUFSIZE
,
s
->
file
);
s
->
stream
.
avail_in
=
(
uInt
)
fread
(
s
->
inbuf
,
1
,
Z_BUFSIZE
,
s
->
file
);
if
(
s
->
stream
.
avail_in
==
0
)
{
if
(
s
->
stream
.
avail_in
==
0
)
{
s
->
z_eof
=
1
;
s
->
z_eof
=
1
;
if
(
ferror
(
s
->
file
))
s
->
z_err
=
Z_ERRNO
;
if
(
ferror
(
s
->
file
))
s
->
z_err
=
Z_ERRNO
;
...
@@ -300,7 +300,7 @@ local void check_header(s)
...
@@ -300,7 +300,7 @@ local void check_header(s)
if
(
len
<
2
)
{
if
(
len
<
2
)
{
if
(
len
)
s
->
inbuf
[
0
]
=
s
->
stream
.
next_in
[
0
];
if
(
len
)
s
->
inbuf
[
0
]
=
s
->
stream
.
next_in
[
0
];
errno
=
0
;
errno
=
0
;
len
=
fread
(
s
->
inbuf
+
len
,
1
,
Z_BUFSIZE
>>
len
,
s
->
file
);
len
=
(
uInt
)
fread
(
s
->
inbuf
+
len
,
1
,
Z_BUFSIZE
>>
len
,
s
->
file
);
if
(
len
==
0
&&
ferror
(
s
->
file
))
s
->
z_err
=
Z_ERRNO
;
if
(
len
==
0
&&
ferror
(
s
->
file
))
s
->
z_err
=
Z_ERRNO
;
s
->
stream
.
avail_in
+=
len
;
s
->
stream
.
avail_in
+=
len
;
s
->
stream
.
next_in
=
s
->
inbuf
;
s
->
stream
.
next_in
=
s
->
inbuf
;
...
@@ -415,6 +415,7 @@ int ZEXPORT gzread (file, buf, len)
...
@@ -415,6 +415,7 @@ int ZEXPORT gzread (file, buf, len)
s
->
stream
.
avail_out
--
;
s
->
stream
.
avail_out
--
;
s
->
back
=
EOF
;
s
->
back
=
EOF
;
s
->
out
++
;
s
->
out
++
;
start
++
;
if
(
s
->
last
)
{
if
(
s
->
last
)
{
s
->
z_err
=
Z_STREAM_END
;
s
->
z_err
=
Z_STREAM_END
;
return
1
;
return
1
;
...
@@ -436,8 +437,8 @@ int ZEXPORT gzread (file, buf, len)
...
@@ -436,8 +437,8 @@ int ZEXPORT gzread (file, buf, len)
s
->
stream
.
avail_in
-=
n
;
s
->
stream
.
avail_in
-=
n
;
}
}
if
(
s
->
stream
.
avail_out
>
0
)
{
if
(
s
->
stream
.
avail_out
>
0
)
{
s
->
stream
.
avail_out
-=
fread
(
next_out
,
1
,
s
->
stream
.
avail_out
,
s
->
stream
.
avail_out
-=
s
->
file
);
(
uInt
)
fread
(
next_out
,
1
,
s
->
stream
.
avail_out
,
s
->
file
);
}
}
len
-=
s
->
stream
.
avail_out
;
len
-=
s
->
stream
.
avail_out
;
s
->
in
+=
len
;
s
->
in
+=
len
;
...
@@ -448,17 +449,13 @@ int ZEXPORT gzread (file, buf, len)
...
@@ -448,17 +449,13 @@ int ZEXPORT gzread (file, buf, len)
if
(
s
->
stream
.
avail_in
==
0
&&
!
s
->
z_eof
)
{
if
(
s
->
stream
.
avail_in
==
0
&&
!
s
->
z_eof
)
{
errno
=
0
;
errno
=
0
;
s
->
stream
.
avail_in
=
fread
(
s
->
inbuf
,
1
,
Z_BUFSIZE
,
s
->
file
);
s
->
stream
.
avail_in
=
(
uInt
)
fread
(
s
->
inbuf
,
1
,
Z_BUFSIZE
,
s
->
file
);
if
(
s
->
stream
.
avail_in
==
0
)
{
if
(
s
->
stream
.
avail_in
==
0
)
{
s
->
z_eof
=
1
;
s
->
z_eof
=
1
;
if
(
ferror
(
s
->
file
))
{
if
(
ferror
(
s
->
file
))
{
s
->
z_err
=
Z_ERRNO
;
s
->
z_err
=
Z_ERRNO
;
break
;
break
;
}
}
if
(
feof
(
s
->
file
))
{
/* avoid error for empty file */
s
->
z_err
=
Z_STREAM_END
;
break
;
}
}
}
s
->
stream
.
next_in
=
s
->
inbuf
;
s
->
stream
.
next_in
=
s
->
inbuf
;
}
}
...
@@ -492,6 +489,9 @@ int ZEXPORT gzread (file, buf, len)
...
@@ -492,6 +489,9 @@ int ZEXPORT gzread (file, buf, len)
}
}
s
->
crc
=
crc32
(
s
->
crc
,
start
,
(
uInt
)(
s
->
stream
.
next_out
-
start
));
s
->
crc
=
crc32
(
s
->
crc
,
start
,
(
uInt
)(
s
->
stream
.
next_out
-
start
));
if
(
len
==
s
->
stream
.
avail_out
&&
(
s
->
z_err
==
Z_DATA_ERROR
||
s
->
z_err
==
Z_ERRNO
))
return
-
1
;
return
(
int
)(
len
-
s
->
stream
.
avail_out
);
return
(
int
)(
len
-
s
->
stream
.
avail_out
);
}
}
...
@@ -902,6 +902,18 @@ int ZEXPORT gzeof (file)
...
@@ -902,6 +902,18 @@ int ZEXPORT gzeof (file)
return
s
->
z_err
==
Z_STREAM_END
;
return
s
->
z_err
==
Z_STREAM_END
;
}
}
/* ===========================================================================
Returns 1 if reading and doing so transparently, otherwise zero.
*/
int
ZEXPORT
gzdirect
(
file
)
gzFile
file
;
{
gz_stream
*
s
=
(
gz_stream
*
)
file
;
if
(
s
==
NULL
||
s
->
mode
!=
'r'
)
return
0
;
return
s
->
transparent
;
}
/* ===========================================================================
/* ===========================================================================
Outputs a long in LSB order to the given file
Outputs a long in LSB order to the given file
*/
*/
...
@@ -941,7 +953,6 @@ local uLong getLong (s)
...
@@ -941,7 +953,6 @@ local uLong getLong (s)
int
ZEXPORT
gzclose
(
file
)
int
ZEXPORT
gzclose
(
file
)
gzFile
file
;
gzFile
file
;
{
{
int
err
;
gz_stream
*
s
=
(
gz_stream
*
)
file
;
gz_stream
*
s
=
(
gz_stream
*
)
file
;
if
(
s
==
NULL
)
return
Z_STREAM_ERROR
;
if
(
s
==
NULL
)
return
Z_STREAM_ERROR
;
...
@@ -950,8 +961,8 @@ int ZEXPORT gzclose (file)
...
@@ -950,8 +961,8 @@ int ZEXPORT gzclose (file)
#ifdef NO_GZCOMPRESS
#ifdef NO_GZCOMPRESS
return
Z_STREAM_ERROR
;
return
Z_STREAM_ERROR
;
#else
#else
err
=
do_flush
(
file
,
Z_FINISH
);
if
(
do_flush
(
file
,
Z_FINISH
)
!=
Z_OK
)
if
(
err
!=
Z_OK
)
return
destroy
((
gz_stream
*
)
file
);
return
destroy
((
gz_stream
*
)
file
);
putLong
(
s
->
file
,
s
->
crc
);
putLong
(
s
->
file
,
s
->
crc
);
putLong
(
s
->
file
,
(
uLong
)(
s
->
in
&
0xffffffff
));
putLong
(
s
->
file
,
(
uLong
)(
s
->
in
&
0xffffffff
));
...
@@ -960,10 +971,16 @@ int ZEXPORT gzclose (file)
...
@@ -960,10 +971,16 @@ int ZEXPORT gzclose (file)
return
destroy
((
gz_stream
*
)
file
);
return
destroy
((
gz_stream
*
)
file
);
}
}
#ifdef STDC
# define zstrerror(errnum) strerror(errnum)
#else
# define zstrerror(errnum) ""
#endif
/* ===========================================================================
/* ===========================================================================
Returns the error message for the last error which occured on the
Returns the error message for the last error which occur
r
ed on the
given compressed file. errnum is set to zlib error number. If an
given compressed file. errnum is set to zlib error number. If an
error occured in the file system and not in the compression library,
error occur
r
ed in the file system and not in the compression library,
errnum is set to Z_ERRNO and the application may consult errno
errnum is set to Z_ERRNO and the application may consult errno
to get the exact error code.
to get the exact error code.
*/
*/
...
...
zlib/infback.c
View file @
f7aee86a
/* infback.c -- inflate using a call-back interface
/* infback.c -- inflate using a call-back interface
* Copyright (C) 1995-200
3
Mark Adler
* Copyright (C) 1995-200
5
Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -26,7 +26,7 @@ local void fixedtables OF((struct inflate_state FAR *state));
...
@@ -26,7 +26,7 @@ local void fixedtables OF((struct inflate_state FAR *state));
window and output buffer that is 2**windowBits bytes.
window and output buffer that is 2**windowBits bytes.
*/
*/
int
ZEXPORT
inflateBackInit_
(
strm
,
windowBits
,
window
,
version
,
stream_size
)
int
ZEXPORT
inflateBackInit_
(
strm
,
windowBits
,
window
,
version
,
stream_size
)
z_stream
FAR
*
strm
;
z_stream
p
strm
;
int
windowBits
;
int
windowBits
;
unsigned
char
FAR
*
window
;
unsigned
char
FAR
*
window
;
const
char
*
version
;
const
char
*
version
;
...
@@ -50,7 +50,8 @@ int stream_size;
...
@@ -50,7 +50,8 @@ int stream_size;
sizeof
(
struct
inflate_state
));
sizeof
(
struct
inflate_state
));
if
(
state
==
Z_NULL
)
return
Z_MEM_ERROR
;
if
(
state
==
Z_NULL
)
return
Z_MEM_ERROR
;
Tracev
((
stderr
,
"inflate: allocated
\n
"
));
Tracev
((
stderr
,
"inflate: allocated
\n
"
));
strm
->
state
=
(
voidpf
)
state
;
strm
->
state
=
(
struct
internal_state
FAR
*
)
state
;
state
->
dmax
=
32768U
;
state
->
wbits
=
windowBits
;
state
->
wbits
=
windowBits
;
state
->
wsize
=
1U
<<
windowBits
;
state
->
wsize
=
1U
<<
windowBits
;
state
->
window
=
window
;
state
->
window
=
window
;
...
@@ -238,7 +239,7 @@ struct inflate_state FAR *state;
...
@@ -238,7 +239,7 @@ struct inflate_state FAR *state;
are not correct, i.e. strm is Z_NULL or the state was not initialized.
are not correct, i.e. strm is Z_NULL or the state was not initialized.
*/
*/
int
ZEXPORT
inflateBack
(
strm
,
in
,
in_desc
,
out
,
out_desc
)
int
ZEXPORT
inflateBack
(
strm
,
in
,
in_desc
,
out
,
out_desc
)
z_stream
FAR
*
strm
;
z_stream
p
strm
;
in_func
in
;
in_func
in
;
void
FAR
*
in_desc
;
void
FAR
*
in_desc
;
out_func
out
;
out_func
out
;
...
@@ -611,7 +612,7 @@ void FAR *out_desc;
...
@@ -611,7 +612,7 @@ void FAR *out_desc;
}
}
int
ZEXPORT
inflateBackEnd
(
strm
)
int
ZEXPORT
inflateBackEnd
(
strm
)
z_stream
FAR
*
strm
;
z_stream
p
strm
;
{
{
if
(
strm
==
Z_NULL
||
strm
->
state
==
Z_NULL
||
strm
->
zfree
==
(
free_func
)
0
)
if
(
strm
==
Z_NULL
||
strm
->
state
==
Z_NULL
||
strm
->
zfree
==
(
free_func
)
0
)
return
Z_STREAM_ERROR
;
return
Z_STREAM_ERROR
;
...
...
zlib/inffast.c
View file @
f7aee86a
...
@@ -74,6 +74,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
...
@@ -74,6 +74,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
unsigned
char
FAR
*
out
;
/* local strm->next_out */
unsigned
char
FAR
*
out
;
/* local strm->next_out */
unsigned
char
FAR
*
beg
;
/* inflate()'s initial strm->next_out */
unsigned
char
FAR
*
beg
;
/* inflate()'s initial strm->next_out */
unsigned
char
FAR
*
end
;
/* while out < end, enough space available */
unsigned
char
FAR
*
end
;
/* while out < end, enough space available */
#ifdef INFLATE_STRICT
unsigned
dmax
;
/* maximum distance from zlib header */
#endif
unsigned
wsize
;
/* window size or zero if not using window */
unsigned
wsize
;
/* window size or zero if not using window */
unsigned
whave
;
/* valid bytes in the window */
unsigned
whave
;
/* valid bytes in the window */
unsigned
write
;
/* window write index */
unsigned
write
;
/* window write index */
...
@@ -98,6 +101,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
...
@@ -98,6 +101,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
out
=
strm
->
next_out
-
OFF
;
out
=
strm
->
next_out
-
OFF
;
beg
=
out
-
(
start
-
strm
->
avail_out
);
beg
=
out
-
(
start
-
strm
->
avail_out
);
end
=
out
+
(
strm
->
avail_out
-
257
);
end
=
out
+
(
strm
->
avail_out
-
257
);
#ifdef INFLATE_STRICT
dmax
=
state
->
dmax
;
#endif
wsize
=
state
->
wsize
;
wsize
=
state
->
wsize
;
whave
=
state
->
whave
;
whave
=
state
->
whave
;
write
=
state
->
write
;
write
=
state
->
write
;
...
@@ -167,6 +173,13 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
...
@@ -167,6 +173,13 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
}
}
dist
+=
(
unsigned
)
hold
&
((
1U
<<
op
)
-
1
);
dist
+=
(
unsigned
)
hold
&
((
1U
<<
op
)
-
1
);
#ifdef INFLATE_STRICT
if
(
dist
>
dmax
)
{
strm
->
msg
=
(
char
*
)
"invalid distance too far back"
;
state
->
mode
=
BAD
;
break
;
}
#endif
hold
>>=
op
;
hold
>>=
op
;
bits
-=
op
;
bits
-=
op
;
Tracevv
((
stderr
,
"inflate: distance %u
\n
"
,
dist
));
Tracevv
((
stderr
,
"inflate: distance %u
\n
"
,
dist
));
...
...
zlib/inflate.c
View file @
f7aee86a
/* inflate.c -- zlib decompression
/* inflate.c -- zlib decompression
* Copyright (C) 1995-200
3
Mark Adler
* Copyright (C) 1995-200
5
Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -113,8 +113,11 @@ z_streamp strm;
...
@@ -113,8 +113,11 @@ z_streamp strm;
state
->
mode
=
HEAD
;
state
->
mode
=
HEAD
;
state
->
last
=
0
;
state
->
last
=
0
;
state
->
havedict
=
0
;
state
->
havedict
=
0
;
state
->
dmax
=
32768U
;
state
->
head
=
Z_NULL
;
state
->
wsize
=
0
;
state
->
wsize
=
0
;
state
->
whave
=
0
;
state
->
whave
=
0
;
state
->
write
=
0
;
state
->
hold
=
0
;
state
->
hold
=
0
;
state
->
bits
=
0
;
state
->
bits
=
0
;
state
->
lencode
=
state
->
distcode
=
state
->
next
=
state
->
codes
;
state
->
lencode
=
state
->
distcode
=
state
->
next
=
state
->
codes
;
...
@@ -122,6 +125,22 @@ z_streamp strm;
...
@@ -122,6 +125,22 @@ z_streamp strm;
return
Z_OK
;
return
Z_OK
;
}
}
int
ZEXPORT
inflatePrime
(
strm
,
bits
,
value
)
z_streamp
strm
;
int
bits
;
int
value
;
{
struct
inflate_state
FAR
*
state
;
if
(
strm
==
Z_NULL
||
strm
->
state
==
Z_NULL
)
return
Z_STREAM_ERROR
;
state
=
(
struct
inflate_state
FAR
*
)
strm
->
state
;
if
(
bits
>
16
||
state
->
bits
+
bits
>
32
)
return
Z_STREAM_ERROR
;
value
&=
(
1L
<<
bits
)
-
1
;
state
->
hold
+=
value
<<
state
->
bits
;
state
->
bits
+=
bits
;
return
Z_OK
;
}
int
ZEXPORT
inflateInit2_
(
strm
,
windowBits
,
version
,
stream_size
)
int
ZEXPORT
inflateInit2_
(
strm
,
windowBits
,
version
,
stream_size
)
z_streamp
strm
;
z_streamp
strm
;
int
windowBits
;
int
windowBits
;
...
@@ -144,7 +163,7 @@ int stream_size;
...
@@ -144,7 +163,7 @@ int stream_size;
ZALLOC
(
strm
,
1
,
sizeof
(
struct
inflate_state
));
ZALLOC
(
strm
,
1
,
sizeof
(
struct
inflate_state
));
if
(
state
==
Z_NULL
)
return
Z_MEM_ERROR
;
if
(
state
==
Z_NULL
)
return
Z_MEM_ERROR
;
Tracev
((
stderr
,
"inflate: allocated
\n
"
));
Tracev
((
stderr
,
"inflate: allocated
\n
"
));
strm
->
state
=
(
voidpf
)
state
;
strm
->
state
=
(
struct
internal_state
FAR
*
)
state
;
if
(
windowBits
<
0
)
{
if
(
windowBits
<
0
)
{
state
->
wrap
=
0
;
state
->
wrap
=
0
;
windowBits
=
-
windowBits
;
windowBits
=
-
windowBits
;
...
@@ -582,6 +601,8 @@ int flush;
...
@@ -582,6 +601,8 @@ int flush;
break
;
break
;
}
}
state
->
flags
=
0
;
/* expect zlib header */
state
->
flags
=
0
;
/* expect zlib header */
if
(
state
->
head
!=
Z_NULL
)
state
->
head
->
done
=
-
1
;
if
(
!
(
state
->
wrap
&
1
)
||
/* check if zlib header allowed */
if
(
!
(
state
->
wrap
&
1
)
||
/* check if zlib header allowed */
#else
#else
if
(
if
(
...
@@ -597,11 +618,13 @@ int flush;
...
@@ -597,11 +618,13 @@ int flush;
break
;
break
;
}
}
DROPBITS
(
4
);
DROPBITS
(
4
);
if
(
BITS
(
4
)
+
8
>
state
->
wbits
)
{
len
=
BITS
(
4
)
+
8
;
if
(
len
>
state
->
wbits
)
{
strm
->
msg
=
(
char
*
)
"invalid window size"
;
strm
->
msg
=
(
char
*
)
"invalid window size"
;
state
->
mode
=
BAD
;
state
->
mode
=
BAD
;
break
;
break
;
}
}
state
->
dmax
=
1U
<<
len
;
Tracev
((
stderr
,
"inflate: zlib header ok
\n
"
));
Tracev
((
stderr
,
"inflate: zlib header ok
\n
"
));
strm
->
adler
=
state
->
check
=
adler32
(
0L
,
Z_NULL
,
0
);
strm
->
adler
=
state
->
check
=
adler32
(
0L
,
Z_NULL
,
0
);
state
->
mode
=
hold
&
0x200
?
DICTID
:
TYPE
;
state
->
mode
=
hold
&
0x200
?
DICTID
:
TYPE
;
...
@@ -621,16 +644,24 @@ int flush;
...
@@ -621,16 +644,24 @@ int flush;
state
->
mode
=
BAD
;
state
->
mode
=
BAD
;
break
;
break
;
}
}
if
(
state
->
head
!=
Z_NULL
)
state
->
head
->
text
=
(
int
)((
hold
>>
8
)
&
1
);
if
(
state
->
flags
&
0x0200
)
CRC2
(
state
->
check
,
hold
);
if
(
state
->
flags
&
0x0200
)
CRC2
(
state
->
check
,
hold
);
INITBITS
();
INITBITS
();
state
->
mode
=
TIME
;
state
->
mode
=
TIME
;
case
TIME
:
case
TIME
:
NEEDBITS
(
32
);
NEEDBITS
(
32
);
if
(
state
->
head
!=
Z_NULL
)
state
->
head
->
time
=
hold
;
if
(
state
->
flags
&
0x0200
)
CRC4
(
state
->
check
,
hold
);
if
(
state
->
flags
&
0x0200
)
CRC4
(
state
->
check
,
hold
);
INITBITS
();
INITBITS
();
state
->
mode
=
OS
;
state
->
mode
=
OS
;
case
OS
:
case
OS
:
NEEDBITS
(
16
);
NEEDBITS
(
16
);
if
(
state
->
head
!=
Z_NULL
)
{
state
->
head
->
xflags
=
(
int
)(
hold
&
0xff
);
state
->
head
->
os
=
(
int
)(
hold
>>
8
);
}
if
(
state
->
flags
&
0x0200
)
CRC2
(
state
->
check
,
hold
);
if
(
state
->
flags
&
0x0200
)
CRC2
(
state
->
check
,
hold
);
INITBITS
();
INITBITS
();
state
->
mode
=
EXLEN
;
state
->
mode
=
EXLEN
;
...
@@ -638,15 +669,26 @@ int flush;
...
@@ -638,15 +669,26 @@ int flush;
if
(
state
->
flags
&
0x0400
)
{
if
(
state
->
flags
&
0x0400
)
{
NEEDBITS
(
16
);
NEEDBITS
(
16
);
state
->
length
=
(
unsigned
)(
hold
);
state
->
length
=
(
unsigned
)(
hold
);
if
(
state
->
head
!=
Z_NULL
)
state
->
head
->
extra_len
=
(
unsigned
)
hold
;
if
(
state
->
flags
&
0x0200
)
CRC2
(
state
->
check
,
hold
);
if
(
state
->
flags
&
0x0200
)
CRC2
(
state
->
check
,
hold
);
INITBITS
();
INITBITS
();
}
}
else
if
(
state
->
head
!=
Z_NULL
)
state
->
head
->
extra
=
Z_NULL
;
state
->
mode
=
EXTRA
;
state
->
mode
=
EXTRA
;
case
EXTRA
:
case
EXTRA
:
if
(
state
->
flags
&
0x0400
)
{
if
(
state
->
flags
&
0x0400
)
{
copy
=
state
->
length
;
copy
=
state
->
length
;
if
(
copy
>
have
)
copy
=
have
;
if
(
copy
>
have
)
copy
=
have
;
if
(
copy
)
{
if
(
copy
)
{
if
(
state
->
head
!=
Z_NULL
&&
state
->
head
->
extra
!=
Z_NULL
)
{
len
=
state
->
head
->
extra_len
-
state
->
length
;
zmemcpy
(
state
->
head
->
extra
+
len
,
next
,
len
+
copy
>
state
->
head
->
extra_max
?
state
->
head
->
extra_max
-
len
:
copy
);
}
if
(
state
->
flags
&
0x0200
)
if
(
state
->
flags
&
0x0200
)
state
->
check
=
crc32
(
state
->
check
,
next
,
copy
);
state
->
check
=
crc32
(
state
->
check
,
next
,
copy
);
have
-=
copy
;
have
-=
copy
;
...
@@ -655,6 +697,7 @@ int flush;
...
@@ -655,6 +697,7 @@ int flush;
}
}
if
(
state
->
length
)
goto
inf_leave
;
if
(
state
->
length
)
goto
inf_leave
;
}
}
state
->
length
=
0
;
state
->
mode
=
NAME
;
state
->
mode
=
NAME
;
case
NAME
:
case
NAME
:
if
(
state
->
flags
&
0x0800
)
{
if
(
state
->
flags
&
0x0800
)
{
...
@@ -662,13 +705,20 @@ int flush;
...
@@ -662,13 +705,20 @@ int flush;
copy
=
0
;
copy
=
0
;
do
{
do
{
len
=
(
unsigned
)(
next
[
copy
++
]);
len
=
(
unsigned
)(
next
[
copy
++
]);
if
(
state
->
head
!=
Z_NULL
&&
state
->
head
->
name
!=
Z_NULL
&&
state
->
length
<
state
->
head
->
name_max
)
state
->
head
->
name
[
state
->
length
++
]
=
len
;
}
while
(
len
&&
copy
<
have
);
}
while
(
len
&&
copy
<
have
);
if
(
state
->
flags
&
0x0200
0
)
if
(
state
->
flags
&
0x0200
)
state
->
check
=
crc32
(
state
->
check
,
next
,
copy
);
state
->
check
=
crc32
(
state
->
check
,
next
,
copy
);
have
-=
copy
;
have
-=
copy
;
next
+=
copy
;
next
+=
copy
;
if
(
len
)
goto
inf_leave
;
if
(
len
)
goto
inf_leave
;
}
}
else
if
(
state
->
head
!=
Z_NULL
)
state
->
head
->
name
=
Z_NULL
;
state
->
length
=
0
;
state
->
mode
=
COMMENT
;
state
->
mode
=
COMMENT
;
case
COMMENT
:
case
COMMENT
:
if
(
state
->
flags
&
0x1000
)
{
if
(
state
->
flags
&
0x1000
)
{
...
@@ -676,13 +726,19 @@ int flush;
...
@@ -676,13 +726,19 @@ int flush;
copy
=
0
;
copy
=
0
;
do
{
do
{
len
=
(
unsigned
)(
next
[
copy
++
]);
len
=
(
unsigned
)(
next
[
copy
++
]);
if
(
state
->
head
!=
Z_NULL
&&
state
->
head
->
comment
!=
Z_NULL
&&
state
->
length
<
state
->
head
->
comm_max
)
state
->
head
->
comment
[
state
->
length
++
]
=
len
;
}
while
(
len
&&
copy
<
have
);
}
while
(
len
&&
copy
<
have
);
if
(
state
->
flags
&
0x0200
0
)
if
(
state
->
flags
&
0x0200
)
state
->
check
=
crc32
(
state
->
check
,
next
,
copy
);
state
->
check
=
crc32
(
state
->
check
,
next
,
copy
);
have
-=
copy
;
have
-=
copy
;
next
+=
copy
;
next
+=
copy
;
if
(
len
)
goto
inf_leave
;
if
(
len
)
goto
inf_leave
;
}
}
else
if
(
state
->
head
!=
Z_NULL
)
state
->
head
->
comment
=
Z_NULL
;
state
->
mode
=
HCRC
;
state
->
mode
=
HCRC
;
case
HCRC
:
case
HCRC
:
if
(
state
->
flags
&
0x0200
)
{
if
(
state
->
flags
&
0x0200
)
{
...
@@ -694,6 +750,10 @@ int flush;
...
@@ -694,6 +750,10 @@ int flush;
}
}
INITBITS
();
INITBITS
();
}
}
if
(
state
->
head
!=
Z_NULL
)
{
state
->
head
->
hcrc
=
(
int
)((
state
->
flags
>>
9
)
&
1
);
state
->
head
->
done
=
1
;
}
strm
->
adler
=
state
->
check
=
crc32
(
0L
,
Z_NULL
,
0
);
strm
->
adler
=
state
->
check
=
crc32
(
0L
,
Z_NULL
,
0
);
state
->
mode
=
TYPE
;
state
->
mode
=
TYPE
;
break
;
break
;
...
@@ -969,6 +1029,13 @@ int flush;
...
@@ -969,6 +1029,13 @@ int flush;
state
->
offset
+=
BITS
(
state
->
extra
);
state
->
offset
+=
BITS
(
state
->
extra
);
DROPBITS
(
state
->
extra
);
DROPBITS
(
state
->
extra
);
}
}
#ifdef INFLATE_STRICT
if
(
state
->
offset
>
state
->
dmax
)
{
strm
->
msg
=
(
char
*
)
"invalid distance too far back"
;
state
->
mode
=
BAD
;
break
;
}
#endif
if
(
state
->
offset
>
state
->
whave
+
out
-
left
)
{
if
(
state
->
offset
>
state
->
whave
+
out
-
left
)
{
strm
->
msg
=
(
char
*
)
"invalid distance too far back"
;
strm
->
msg
=
(
char
*
)
"invalid distance too far back"
;
state
->
mode
=
BAD
;
state
->
mode
=
BAD
;
...
@@ -1110,12 +1177,16 @@ uInt dictLength;
...
@@ -1110,12 +1177,16 @@ uInt dictLength;
/* check state */
/* check state */
if
(
strm
==
Z_NULL
||
strm
->
state
==
Z_NULL
)
return
Z_STREAM_ERROR
;
if
(
strm
==
Z_NULL
||
strm
->
state
==
Z_NULL
)
return
Z_STREAM_ERROR
;
state
=
(
struct
inflate_state
FAR
*
)
strm
->
state
;
state
=
(
struct
inflate_state
FAR
*
)
strm
->
state
;
if
(
state
->
mode
!=
DICT
)
return
Z_STREAM_ERROR
;
if
(
state
->
wrap
!=
0
&&
state
->
mode
!=
DICT
)
return
Z_STREAM_ERROR
;
/* check for correct dictionary id */
/* check for correct dictionary id */
if
(
state
->
mode
==
DICT
)
{
id
=
adler32
(
0L
,
Z_NULL
,
0
);
id
=
adler32
(
0L
,
Z_NULL
,
0
);
id
=
adler32
(
id
,
dictionary
,
dictLength
);
id
=
adler32
(
id
,
dictionary
,
dictLength
);
if
(
id
!=
state
->
check
)
return
Z_DATA_ERROR
;
if
(
id
!=
state
->
check
)
return
Z_DATA_ERROR
;
}
/* copy dictionary to window */
/* copy dictionary to window */
if
(
updatewindow
(
strm
,
strm
->
avail_out
))
{
if
(
updatewindow
(
strm
,
strm
->
avail_out
))
{
...
@@ -1137,6 +1208,23 @@ uInt dictLength;
...
@@ -1137,6 +1208,23 @@ uInt dictLength;
return
Z_OK
;
return
Z_OK
;
}
}
int
ZEXPORT
inflateGetHeader
(
strm
,
head
)
z_streamp
strm
;
gz_headerp
head
;
{
struct
inflate_state
FAR
*
state
;
/* check state */
if
(
strm
==
Z_NULL
||
strm
->
state
==
Z_NULL
)
return
Z_STREAM_ERROR
;
state
=
(
struct
inflate_state
FAR
*
)
strm
->
state
;
if
((
state
->
wrap
&
2
)
==
0
)
return
Z_STREAM_ERROR
;
/* save header structure */
state
->
head
=
head
;
head
->
done
=
0
;
return
Z_OK
;
}
/*
/*
Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
or when out of input. When called, *have is the number of pattern bytes
or when out of input. When called, *have is the number of pattern bytes
...
@@ -1239,6 +1327,7 @@ z_streamp source;
...
@@ -1239,6 +1327,7 @@ z_streamp source;
struct
inflate_state
FAR
*
state
;
struct
inflate_state
FAR
*
state
;
struct
inflate_state
FAR
*
copy
;
struct
inflate_state
FAR
*
copy
;
unsigned
char
FAR
*
window
;
unsigned
char
FAR
*
window
;
unsigned
wsize
;
/* check input */
/* check input */
if
(
dest
==
Z_NULL
||
source
==
Z_NULL
||
source
->
state
==
Z_NULL
||
if
(
dest
==
Z_NULL
||
source
==
Z_NULL
||
source
->
state
==
Z_NULL
||
...
@@ -1261,14 +1350,19 @@ z_streamp source;
...
@@ -1261,14 +1350,19 @@ z_streamp source;
}
}
/* copy state */
/* copy state */
*
dest
=
*
source
;
zmemcpy
(
dest
,
source
,
sizeof
(
z_stream
));
*
copy
=
*
state
;
zmemcpy
(
copy
,
state
,
sizeof
(
struct
inflate_state
));
if
(
state
->
lencode
>=
state
->
codes
&&
state
->
lencode
<=
state
->
codes
+
ENOUGH
-
1
)
{
copy
->
lencode
=
copy
->
codes
+
(
state
->
lencode
-
state
->
codes
);
copy
->
lencode
=
copy
->
codes
+
(
state
->
lencode
-
state
->
codes
);
copy
->
distcode
=
copy
->
codes
+
(
state
->
distcode
-
state
->
codes
);
copy
->
distcode
=
copy
->
codes
+
(
state
->
distcode
-
state
->
codes
);
}
copy
->
next
=
copy
->
codes
+
(
state
->
next
-
state
->
codes
);
copy
->
next
=
copy
->
codes
+
(
state
->
next
-
state
->
codes
);
if
(
window
!=
Z_NULL
)
if
(
window
!=
Z_NULL
)
{
zmemcpy
(
window
,
state
->
window
,
1U
<<
state
->
wbits
);
wsize
=
1U
<<
state
->
wbits
;
zmemcpy
(
window
,
state
->
window
,
wsize
);
}
copy
->
window
=
window
;
copy
->
window
=
window
;
dest
->
state
=
(
voidpf
)
copy
;
dest
->
state
=
(
struct
internal_state
FAR
*
)
copy
;
return
Z_OK
;
return
Z_OK
;
}
}
zlib/inflate.h
View file @
f7aee86a
/* inflate.h -- internal inflate state definition
/* inflate.h -- internal inflate state definition
* Copyright (C) 1995-200
3
Mark Adler
* Copyright (C) 1995-200
4
Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
/* Possible inflate modes between inflate() calls */
/* Possible inflate modes between inflate() calls */
typedef
enum
{
typedef
enum
{
HEAD
,
/* i: waiting for magic header */
HEAD
,
/* i: waiting for magic header */
#ifdef GUNZIP
FLAGS
,
/* i: waiting for method and flags (gzip) */
FLAGS
,
/* i: waiting for method and flags (gzip) */
TIME
,
/* i: waiting for modification time (gzip) */
TIME
,
/* i: waiting for modification time (gzip) */
OS
,
/* i: waiting for extra flags and operating system (gzip) */
OS
,
/* i: waiting for extra flags and operating system (gzip) */
...
@@ -28,7 +27,6 @@ typedef enum {
...
@@ -28,7 +27,6 @@ typedef enum {
NAME
,
/* i: waiting for end of file name (gzip) */
NAME
,
/* i: waiting for end of file name (gzip) */
COMMENT
,
/* i: waiting for end of comment (gzip) */
COMMENT
,
/* i: waiting for end of comment (gzip) */
HCRC
,
/* i: waiting for header crc (gzip) */
HCRC
,
/* i: waiting for header crc (gzip) */
#endif
DICTID
,
/* i: waiting for dictionary check value */
DICTID
,
/* i: waiting for dictionary check value */
DICT
,
/* waiting for inflateSetDictionary() call */
DICT
,
/* waiting for inflateSetDictionary() call */
TYPE
,
/* i: waiting for type bits, including last-flag bit */
TYPE
,
/* i: waiting for type bits, including last-flag bit */
...
@@ -45,9 +43,7 @@ typedef enum {
...
@@ -45,9 +43,7 @@ typedef enum {
MATCH
,
/* o: waiting for output space to copy string */
MATCH
,
/* o: waiting for output space to copy string */
LIT
,
/* o: waiting for output space to write literal */
LIT
,
/* o: waiting for output space to write literal */
CHECK
,
/* i: waiting for 32-bit check value */
CHECK
,
/* i: waiting for 32-bit check value */
#ifdef GUNZIP
LENGTH
,
/* i: waiting for 32-bit length (gzip) */
LENGTH
,
/* i: waiting for 32-bit length (gzip) */
#endif
DONE
,
/* finished check, done -- remain here until reset */
DONE
,
/* finished check, done -- remain here until reset */
BAD
,
/* got a data error -- remain here until reset */
BAD
,
/* got a data error -- remain here until reset */
MEM
,
/* got an inflate() memory error -- remain here until reset */
MEM
,
/* got an inflate() memory error -- remain here until reset */
...
@@ -84,8 +80,10 @@ struct inflate_state {
...
@@ -84,8 +80,10 @@ struct inflate_state {
int
wrap
;
/* bit 0 true for zlib, bit 1 true for gzip */
int
wrap
;
/* bit 0 true for zlib, bit 1 true for gzip */
int
havedict
;
/* true if dictionary provided */
int
havedict
;
/* true if dictionary provided */
int
flags
;
/* gzip header method and flags (0 if zlib) */
int
flags
;
/* gzip header method and flags (0 if zlib) */
unsigned
dmax
;
/* zlib header max distance (INFLATE_STRICT) */
unsigned
long
check
;
/* protected copy of check value */
unsigned
long
check
;
/* protected copy of check value */
unsigned
long
total
;
/* protected copy of output count */
unsigned
long
total
;
/* protected copy of output count */
gz_headerp
head
;
/* where to save gzip header information */
/* sliding window */
/* sliding window */
unsigned
wbits
;
/* log base 2 of requested window size */
unsigned
wbits
;
/* log base 2 of requested window size */
unsigned
wsize
;
/* window size or zero if not using window */
unsigned
wsize
;
/* window size or zero if not using window */
...
...
zlib/inftrees.c
View file @
f7aee86a
/* inftrees.c -- generate Huffman trees for efficient decoding
/* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-200
4
Mark Adler
* Copyright (C) 1995-200
5
Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#define MAXBITS 15
#define MAXBITS 15
const
char
inflate_copyright
[]
=
const
char
inflate_copyright
[]
=
" inflate 1.2.
2 Copyright 1995-2004
Mark Adler "
;
" inflate 1.2.
3 Copyright 1995-2005
Mark Adler "
;
/*
/*
If you use the zlib library in a product, an acknowledgment is welcome
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
in the documentation of your product. If for some reason you cannot
...
@@ -62,7 +62,7 @@ unsigned short FAR *work;
...
@@ -62,7 +62,7 @@ unsigned short FAR *work;
35
,
43
,
51
,
59
,
67
,
83
,
99
,
115
,
131
,
163
,
195
,
227
,
258
,
0
,
0
};
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 */
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
,
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
,
199
,
198
};
19
,
19
,
19
,
19
,
20
,
20
,
20
,
20
,
21
,
21
,
21
,
21
,
16
,
201
,
196
};
static
const
unsigned
short
dbase
[
32
]
=
{
/* Distance codes 0..29 base */
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
,
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
,
257
,
385
,
513
,
769
,
1025
,
1537
,
2049
,
3073
,
4097
,
6145
,
...
@@ -232,6 +232,7 @@ unsigned short FAR *work;
...
@@ -232,6 +232,7 @@ unsigned short FAR *work;
/* replicate for those indices with low len bits equal to huff */
/* replicate for those indices with low len bits equal to huff */
incr
=
1U
<<
(
len
-
drop
);
incr
=
1U
<<
(
len
-
drop
);
fill
=
1U
<<
curr
;
fill
=
1U
<<
curr
;
min
=
fill
;
/* save offset to next table */
do
{
do
{
fill
-=
incr
;
fill
-=
incr
;
next
[(
huff
>>
drop
)
+
fill
]
=
this
;
next
[(
huff
>>
drop
)
+
fill
]
=
this
;
...
@@ -262,7 +263,7 @@ unsigned short FAR *work;
...
@@ -262,7 +263,7 @@ unsigned short FAR *work;
drop
=
root
;
drop
=
root
;
/* increment past last table */
/* increment past last table */
next
+=
1U
<<
curr
;
next
+=
min
;
/* here min is 1 << curr */
/* determine length of next table */
/* determine length of next table */
curr
=
len
-
drop
;
curr
=
len
-
drop
;
...
...
zlib/inftrees.h
View file @
f7aee86a
/* inftrees.h -- header to use inftrees.c
/* inftrees.h -- header to use inftrees.c
* Copyright (C) 1995-200
3
Mark Adler
* Copyright (C) 1995-200
5
Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -36,12 +36,12 @@ typedef struct {
...
@@ -36,12 +36,12 @@ typedef struct {
*/
*/
/* Maximum size of dynamic tree. The maximum found in a long but non-
/* Maximum size of dynamic tree. The maximum found in a long but non-
exhaustive search was 1
004 code structures (850
for length/literals
exhaustive search was 1
444 code structures (852
for length/literals
and
154
for distances, the latter actually the result of an
and
592
for distances, the latter actually the result of an
exhaustive search). The true maximum is not known, but the value
exhaustive search). The true maximum is not known, but the value
below is more than safe. */
below is more than safe. */
#define ENOUGH
1440
#define ENOUGH
2048
#define MAXD
154
#define MAXD
592
/* Type of code to build for inftable() */
/* Type of code to build for inftable() */
typedef
enum
{
typedef
enum
{
...
...
zlib/trees.c
View file @
f7aee86a
/* trees.c -- output deflated data using Huffman coding
/* trees.c -- output deflated data using Huffman coding
* Copyright (C) 1995-200
3
Jean-loup Gailly
* Copyright (C) 1995-200
5
Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -555,7 +555,7 @@ local void gen_bitlen(s, desc)
...
@@ -555,7 +555,7 @@ local void gen_bitlen(s, desc)
while
(
n
!=
0
)
{
while
(
n
!=
0
)
{
m
=
s
->
heap
[
--
h
];
m
=
s
->
heap
[
--
h
];
if
(
m
>
max_code
)
continue
;
if
(
m
>
max_code
)
continue
;
if
(
tree
[
m
].
Len
!=
(
unsigned
)
bits
)
{
if
(
(
unsigned
)
tree
[
m
].
Len
!=
(
unsigned
)
bits
)
{
Trace
((
stderr
,
"code %d bits %d->%d
\n
"
,
m
,
tree
[
m
].
Len
,
bits
));
Trace
((
stderr
,
"code %d bits %d->%d
\n
"
,
m
,
tree
[
m
].
Len
,
bits
));
s
->
opt_len
+=
((
long
)
bits
-
(
long
)
tree
[
m
].
Len
)
s
->
opt_len
+=
((
long
)
bits
-
(
long
)
tree
[
m
].
Len
)
*
(
long
)
tree
[
m
].
Freq
;
*
(
long
)
tree
[
m
].
Freq
;
...
@@ -930,8 +930,9 @@ void _tr_flush_block(s, buf, stored_len, eof)
...
@@ -930,8 +930,9 @@ void _tr_flush_block(s, buf, stored_len, eof)
/* Build the Huffman trees unless a stored block is forced */
/* Build the Huffman trees unless a stored block is forced */
if
(
s
->
level
>
0
)
{
if
(
s
->
level
>
0
)
{
/* Check if the file is ascii or binary */
/* Check if the file is binary or text */
if
(
s
->
strm
->
data_type
==
Z_UNKNOWN
)
set_data_type
(
s
);
if
(
stored_len
>
0
&&
s
->
strm
->
data_type
==
Z_UNKNOWN
)
set_data_type
(
s
);
/* Construct the literal and distance trees */
/* Construct the literal and distance trees */
build_tree
(
s
,
(
tree_desc
*
)(
&
(
s
->
l_desc
)));
build_tree
(
s
,
(
tree_desc
*
)(
&
(
s
->
l_desc
)));
...
@@ -982,7 +983,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
...
@@ -982,7 +983,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
#ifdef FORCE_STATIC
#ifdef FORCE_STATIC
}
else
if
(
static_lenb
>=
0
)
{
/* force static trees */
}
else
if
(
static_lenb
>=
0
)
{
/* force static trees */
#else
#else
}
else
if
(
static_lenb
==
opt_lenb
)
{
}
else
if
(
s
->
strategy
==
Z_FIXED
||
s
tatic_lenb
==
opt_lenb
)
{
#endif
#endif
send_bits
(
s
,
(
STATIC_TREES
<<
1
)
+
eof
,
3
);
send_bits
(
s
,
(
STATIC_TREES
<<
1
)
+
eof
,
3
);
compress_block
(
s
,
(
ct_data
*
)
static_ltree
,
(
ct_data
*
)
static_dtree
);
compress_block
(
s
,
(
ct_data
*
)
static_ltree
,
(
ct_data
*
)
static_dtree
);
...
@@ -1117,21 +1118,24 @@ local void compress_block(s, ltree, dtree)
...
@@ -1117,21 +1118,24 @@ local void compress_block(s, ltree, dtree)
}
}
/* ===========================================================================
/* ===========================================================================
* Set the data type to
ASCII or BINARY
, using a crude approximation:
* Set the data type to
BINARY or TEXT
, using a crude approximation:
*
binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
*
set it to Z_TEXT if all symbols are either printable characters (33 to 255)
*
IN assertion: the fields freq of dyn_ltree are set and the total of all
*
or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
*
frequencies does not exceed 64K (to fit in an int on 16 bit machines)
.
*
IN assertion: the fields Freq of dyn_ltree are set
.
*/
*/
local
void
set_data_type
(
s
)
local
void
set_data_type
(
s
)
deflate_state
*
s
;
deflate_state
*
s
;
{
{
int
n
=
0
;
int
n
;
unsigned
ascii_freq
=
0
;
unsigned
bin_freq
=
0
;
for
(
n
=
0
;
n
<
9
;
n
++
)
while
(
n
<
7
)
bin_freq
+=
s
->
dyn_ltree
[
n
++
].
Freq
;
if
(
s
->
dyn_ltree
[
n
].
Freq
!=
0
)
while
(
n
<
128
)
ascii_freq
+=
s
->
dyn_ltree
[
n
++
].
Freq
;
break
;
while
(
n
<
LITERALS
)
bin_freq
+=
s
->
dyn_ltree
[
n
++
].
Freq
;
if
(
n
==
9
)
s
->
strm
->
data_type
=
bin_freq
>
(
ascii_freq
>>
2
)
?
Z_BINARY
:
Z_ASCII
;
for
(
n
=
14
;
n
<
32
;
n
++
)
if
(
s
->
dyn_ltree
[
n
].
Freq
!=
0
)
break
;
s
->
strm
->
data_type
=
(
n
==
32
)
?
Z_TEXT
:
Z_BINARY
;
}
}
/* ===========================================================================
/* ===========================================================================
...
...
zlib/zconf.h
View file @
f7aee86a
/* zconf.h -- configuration of the zlib compression library
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-200
4
Jean-loup Gailly.
* Copyright (C) 1995-200
5
Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -43,6 +43,10 @@
...
@@ -43,6 +43,10 @@
# define get_crc_table z_get_crc_table
# define get_crc_table z_get_crc_table
# define zError z_zError
# define zError z_zError
# define alloc_func z_alloc_func
# define free_func z_free_func
# define in_func z_in_func
# define out_func z_out_func
# define Byte z_Byte
# define Byte z_Byte
# define uInt z_uInt
# define uInt z_uInt
# define uLong z_uLong
# define uLong z_uLong
...
@@ -64,8 +68,10 @@
...
@@ -64,8 +68,10 @@
#if defined(_WINDOWS) && !defined(WINDOWS)
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
# define WINDOWS
#endif
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
# ifndef WIN32
# define WIN32
# define WIN32
# endif
#endif
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
...
...
zlib/zlib.3
View file @
f7aee86a
.TH ZLIB 3 "
3 October 2004
"
.TH ZLIB 3 "
18 July 2005
"
.SH NAME
.SH NAME
zlib \- compression/decompression library
zlib \- compression/decompression library
.SH SYNOPSIS
.SH SYNOPSIS
...
@@ -133,8 +133,8 @@ before asking for help.
...
@@ -133,8 +133,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org,
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS
.SH AUTHORS
Version 1.2.
2
Version 1.2.
3
Copyright (C) 1995-200
4
Jean-loup Gailly (jloup@gzip.org)
Copyright (C) 1995-200
5
Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
and Mark Adler (madler@alumni.caltech.edu).
.LP
.LP
This software is provided "as-is,"
This software is provided "as-is,"
...
...
zlib/zlib.h
View file @
f7aee86a
This diff is collapsed.
Click to expand it.
zlib/zutil.c
View file @
f7aee86a
/* zutil.c -- target dependent utility functions for the compression library
/* zutil.c -- target dependent utility functions for the compression library
* Copyright (C) 1995-200
3
Jean-loup Gailly.
* Copyright (C) 1995-200
5
Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -11,10 +11,6 @@
...
@@ -11,10 +11,6 @@
struct
internal_state
{
int
dummy
;};
/* for buggy compilers */
struct
internal_state
{
int
dummy
;};
/* for buggy compilers */
#endif
#endif
#ifndef STDC
extern
void
exit
OF
((
int
));
#endif
const
char
*
const
z_errmsg
[
10
]
=
{
const
char
*
const
z_errmsg
[
10
]
=
{
"need dictionary"
,
/* Z_NEED_DICT 2 */
"need dictionary"
,
/* Z_NEED_DICT 2 */
"stream end"
,
/* Z_STREAM_END 1 */
"stream end"
,
/* Z_STREAM_END 1 */
...
@@ -78,38 +74,38 @@ uLong ZEXPORT zlibCompileFlags()
...
@@ -78,38 +74,38 @@ uLong ZEXPORT zlibCompileFlags()
flags
+=
1
<<
13
;
flags
+=
1
<<
13
;
#endif
#endif
#ifdef NO_GZCOMPRESS
#ifdef NO_GZCOMPRESS
flags
+=
1
<<
16
;
flags
+=
1
L
<<
16
;
#endif
#endif
#ifdef NO_GZIP
#ifdef NO_GZIP
flags
+=
1
<<
17
;
flags
+=
1
L
<<
17
;
#endif
#endif
#ifdef PKZIP_BUG_WORKAROUND
#ifdef PKZIP_BUG_WORKAROUND
flags
+=
1
<<
20
;
flags
+=
1
L
<<
20
;
#endif
#endif
#ifdef FASTEST
#ifdef FASTEST
flags
+=
1
<<
21
;
flags
+=
1
L
<<
21
;
#endif
#endif
#ifdef STDC
#ifdef STDC
# ifdef NO_vsnprintf
# ifdef NO_vsnprintf
flags
+=
1
<<
25
;
flags
+=
1
L
<<
25
;
# ifdef HAS_vsprintf_void
# ifdef HAS_vsprintf_void
flags
+=
1
<<
26
;
flags
+=
1
L
<<
26
;
# endif
# endif
# else
# else
# ifdef HAS_vsnprintf_void
# ifdef HAS_vsnprintf_void
flags
+=
1
<<
26
;
flags
+=
1
L
<<
26
;
# endif
# endif
# endif
# endif
#else
#else
flags
+=
1
<<
24
;
flags
+=
1
L
<<
24
;
# ifdef NO_snprintf
# ifdef NO_snprintf
flags
+=
1
<<
25
;
flags
+=
1
L
<<
25
;
# ifdef HAS_sprintf_void
# ifdef HAS_sprintf_void
flags
+=
1
<<
26
;
flags
+=
1
L
<<
26
;
# endif
# endif
# else
# else
# ifdef HAS_snprintf_void
# ifdef HAS_snprintf_void
flags
+=
1
<<
26
;
flags
+=
1
L
<<
26
;
# endif
# endif
# endif
# endif
#endif
#endif
...
@@ -141,7 +137,10 @@ const char * ZEXPORT zError(err)
...
@@ -141,7 +137,10 @@ const char * ZEXPORT zError(err)
}
}
#if defined(_WIN32_WCE)
#if defined(_WIN32_WCE)
/* does not exist on WCE */
/* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used.
*/
int
errno
=
0
;
int
errno
=
0
;
#endif
#endif
...
...
zlib/zutil.h
View file @
f7aee86a
/* zutil.h -- internal interface and configuration of the compression library
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-200
3
Jean-loup Gailly.
* Copyright (C) 1995-200
5
Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
* For conditions of distribution and use, see copyright notice in zlib.h
*/
*/
...
@@ -17,14 +17,26 @@
...
@@ -17,14 +17,26 @@
#include "zlib.h"
#include "zlib.h"
#ifdef STDC
#ifdef STDC
# ifndef _WIN32_WCE
# include <stddef.h>
# include <stddef.h>
# endif
# include <string.h>
# include <string.h>
# include <stdlib.h>
# include <stdlib.h>
#endif
#endif
#ifdef NO_ERRNO_H
#ifdef NO_ERRNO_H
# ifdef _WIN32_WCE
/* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used. We rename it to
* avoid conflict with other libraries that use the same workaround.
*/
# define errno z_errno
# endif
extern
int
errno
;
extern
int
errno
;
#else
#else
# ifndef _WIN32_WCE
# include <errno.h>
# include <errno.h>
# endif
#endif
#endif
#ifndef local
#ifndef local
...
@@ -105,6 +117,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
...
@@ -105,6 +117,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef OS2
#ifdef OS2
# define OS_CODE 0x06
# define OS_CODE 0x06
# ifdef M_I86
#include <malloc.h>
# endif
#endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
#if defined(MACOS) || defined(TARGET_OS_MAC)
...
@@ -193,15 +208,6 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
...
@@ -193,15 +208,6 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define NO_vsnprintf
# define NO_vsnprintf
#endif
#endif
#ifdef HAVE_STRERROR
# ifndef VMS
extern
char
*
strerror
OF
((
int
));
# endif
# define zstrerror(errnum) strerror(errnum)
#else
# define zstrerror(errnum) ""
#endif
#if defined(pyr)
#if defined(pyr)
# define NO_MEMCPY
# define NO_MEMCPY
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment