mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-13 06:34:42 -04:00
Update built-in zlib to 1.3.1
This commit is contained in:
parent
0af36bdcd9
commit
dcf21fa50a
29 changed files with 13567 additions and 2568 deletions
1618
common/zlib/ChangeLog
Normal file
1618
common/zlib/ChangeLog
Normal file
File diff suppressed because it is too large
Load diff
22
common/zlib/LICENSE
Normal file
22
common/zlib/LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright notice:
|
||||||
|
|
||||||
|
(C) 1995-2022 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Jean-loup Gailly Mark Adler
|
||||||
|
jloup@gzip.org madler@alumni.caltech.edu
|
117
common/zlib/README
Normal file
117
common/zlib/README
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
ZLIB DATA COMPRESSION LIBRARY
|
||||||
|
|
||||||
|
zlib 1.3.1 is a general purpose data compression library. All the code is
|
||||||
|
thread safe. The data format used by the zlib library is described by RFCs
|
||||||
|
(Request for Comments) 1950 to 1952 in the files
|
||||||
|
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
|
||||||
|
rfc1952 (gzip format).
|
||||||
|
|
||||||
|
All functions of the compression library are documented in the file zlib.h
|
||||||
|
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
|
||||||
|
of the library is given in the file test/example.c which also tests that
|
||||||
|
the library is working correctly. Another example is given in the file
|
||||||
|
test/minigzip.c. The compression library itself is composed of all source
|
||||||
|
files in the root directory.
|
||||||
|
|
||||||
|
To compile all files and run the test program, follow the instructions given at
|
||||||
|
the top of Makefile.in. In short "./configure; make test", and if that goes
|
||||||
|
well, "make install" should work for most flavors of Unix. For Windows, use
|
||||||
|
one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
|
||||||
|
make_vms.com.
|
||||||
|
|
||||||
|
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
|
||||||
|
http://zlib.net/ . Before reporting a problem, please check this site to
|
||||||
|
verify that you have the latest version of zlib; otherwise get the latest
|
||||||
|
version and check whether the problem still exists or not.
|
||||||
|
|
||||||
|
PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
|
||||||
|
|
||||||
|
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 at
|
||||||
|
https://marknelson.us/posts/1997/01/01/zlib-engine.html .
|
||||||
|
|
||||||
|
The changes made in version 1.3.1 are documented in the file ChangeLog.
|
||||||
|
|
||||||
|
Unsupported third party contributions are provided in directory contrib/ .
|
||||||
|
|
||||||
|
zlib is available in Java using the java.util.zip package. Follow the API
|
||||||
|
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
|
||||||
|
|
||||||
|
A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
|
||||||
|
can be found at https://github.com/pmqs/IO-Compress .
|
||||||
|
|
||||||
|
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
|
||||||
|
available in Python 1.5 and later versions, see
|
||||||
|
http://docs.python.org/library/zlib.html .
|
||||||
|
|
||||||
|
zlib is built into tcl: http://wiki.tcl.tk/4610 .
|
||||||
|
|
||||||
|
An experimental package to read and write files in .zip format, written on top
|
||||||
|
of zlib by Gilles Vollant <info@winimage.com>, is available in the
|
||||||
|
contrib/minizip directory of zlib.
|
||||||
|
|
||||||
|
|
||||||
|
Notes for some targets:
|
||||||
|
|
||||||
|
- For Windows DLL versions, please see win32/DLL_FAQ.txt
|
||||||
|
|
||||||
|
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
|
||||||
|
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
|
||||||
|
compiler flag). The compiler bug has been reported to SGI.
|
||||||
|
|
||||||
|
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
|
||||||
|
when compiled with cc.
|
||||||
|
|
||||||
|
- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
|
||||||
|
necessary to get gzprintf working correctly. This is done by configure.
|
||||||
|
|
||||||
|
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
||||||
|
other compilers. Use "make test" to check your compiler.
|
||||||
|
|
||||||
|
- gzdopen is not supported on RISCOS or BEOS.
|
||||||
|
|
||||||
|
- For PalmOs, see http://palmzlib.sourceforge.net/
|
||||||
|
|
||||||
|
|
||||||
|
Acknowledgments:
|
||||||
|
|
||||||
|
The deflate format used by zlib was defined by Phil Katz. The deflate and
|
||||||
|
zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||||
|
people who reported problems and suggested various improvements in zlib; they
|
||||||
|
are too numerous to cite here.
|
||||||
|
|
||||||
|
Copyright notice:
|
||||||
|
|
||||||
|
(C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Jean-loup Gailly Mark Adler
|
||||||
|
jloup@gzip.org madler@alumni.caltech.edu
|
||||||
|
|
||||||
|
If you use the zlib library in a product, we would appreciate *not* receiving
|
||||||
|
lengthy legal documents to sign. The sources are provided for free but without
|
||||||
|
warranty of any kind. The library has been entirely written by Jean-loup
|
||||||
|
Gailly and Mark Adler; it does not include third-party code. We make all
|
||||||
|
contributions to and distributions of this project solely in our personal
|
||||||
|
capacity, and are not conveying any rights to any intellectual property of
|
||||||
|
any third parties.
|
||||||
|
|
||||||
|
If you redistribute modified sources, we would appreciate that you include in
|
||||||
|
the file ChangeLog history information documenting your changes. Please read
|
||||||
|
the FAQ for more information on the distribution of modified source versions.
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#include "zutil.h"
|
#include "zutil.h"
|
||||||
|
|
||||||
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
|
||||||
|
|
||||||
#define BASE 65521U /* largest prime smaller than 65536 */
|
#define BASE 65521U /* largest prime smaller than 65536 */
|
||||||
#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 */
|
||||||
|
@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT adler32_z(adler, buf, len)
|
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
||||||
uLong adler;
|
|
||||||
const Bytef *buf;
|
|
||||||
z_size_t len;
|
|
||||||
{
|
|
||||||
unsigned long sum2;
|
unsigned long sum2;
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
|
@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT adler32(adler, buf, len)
|
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
||||||
uLong adler;
|
|
||||||
const Bytef *buf;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
return adler32_z(adler, buf, len);
|
return adler32_z(adler, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
local uLong adler32_combine_(adler1, adler2, len2)
|
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||||
uLong adler1;
|
|
||||||
uLong adler2;
|
|
||||||
z_off64_t len2;
|
|
||||||
{
|
|
||||||
unsigned long sum1;
|
unsigned long sum1;
|
||||||
unsigned long sum2;
|
unsigned long sum2;
|
||||||
unsigned rem;
|
unsigned rem;
|
||||||
|
@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
|
||||||
uLong adler1;
|
|
||||||
uLong adler2;
|
|
||||||
z_off_t len2;
|
|
||||||
{
|
|
||||||
return adler32_combine_(adler1, adler2, len2);
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
}
|
}
|
||||||
|
|
||||||
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
|
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||||
uLong adler1;
|
|
||||||
uLong adler2;
|
|
||||||
z_off64_t len2;
|
|
||||||
{
|
|
||||||
return adler32_combine_(adler1, adler2, len2);
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,8 @@
|
||||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||||
Z_STREAM_ERROR if the level parameter is invalid.
|
Z_STREAM_ERROR if the level parameter is invalid.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||||
Bytef *dest;
|
uLong sourceLen, int level) {
|
||||||
uLongf *destLen;
|
|
||||||
const Bytef *source;
|
|
||||||
uLong sourceLen;
|
|
||||||
int level;
|
|
||||||
{
|
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int err;
|
int err;
|
||||||
const uInt max = (uInt)-1;
|
const uInt max = (uInt)-1;
|
||||||
|
@ -65,12 +60,8 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
*/
|
*/
|
||||||
int ZEXPORT compress (dest, destLen, source, sourceLen)
|
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||||
Bytef *dest;
|
uLong sourceLen) {
|
||||||
uLongf *destLen;
|
|
||||||
const Bytef *source;
|
|
||||||
uLong sourceLen;
|
|
||||||
{
|
|
||||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,9 +69,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
|
||||||
If the default memLevel or windowBits for deflateInit() is changed, then
|
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||||
this function needs to be updated.
|
this function needs to be updated.
|
||||||
*/
|
*/
|
||||||
uLong ZEXPORT compressBound (sourceLen)
|
uLong ZEXPORT compressBound(uLong sourceLen) {
|
||||||
uLong sourceLen;
|
|
||||||
{
|
|
||||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||||
(sourceLen >> 25) + 13;
|
(sourceLen >> 25) + 13;
|
||||||
}
|
}
|
||||||
|
|
1269
common/zlib/crc32.c
Executable file → Normal file
1269
common/zlib/crc32.c
Executable file → Normal file
File diff suppressed because it is too large
Load diff
9877
common/zlib/crc32.h
Executable file → Normal file
9877
common/zlib/crc32.h
Executable file → Normal file
File diff suppressed because it is too large
Load diff
812
common/zlib/deflate.c
Executable file → Normal file
812
common/zlib/deflate.c
Executable file → Normal file
File diff suppressed because it is too large
Load diff
74
common/zlib/deflate.h
Executable file → Normal file
74
common/zlib/deflate.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.h -- internal compression state
|
/* deflate.h -- internal compression state
|
||||||
* Copyright (C) 1995-2016 Jean-loup Gailly
|
* Copyright (C) 1995-2024 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
||||||
# define GZIP
|
# define GZIP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
|
||||||
|
the cost of a larger memory footprint */
|
||||||
|
/* #define LIT_MEM */
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Internal compression state.
|
* Internal compression state.
|
||||||
*/
|
*/
|
||||||
|
@ -217,7 +221,14 @@ typedef struct internal_state {
|
||||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uchf *l_buf; /* buffer for literals or lengths */
|
#ifdef LIT_MEM
|
||||||
|
# define LIT_BUFS 5
|
||||||
|
ushf *d_buf; /* buffer for distances */
|
||||||
|
uchf *l_buf; /* buffer for literals/lengths */
|
||||||
|
#else
|
||||||
|
# define LIT_BUFS 4
|
||||||
|
uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||||
|
#endif
|
||||||
|
|
||||||
uInt lit_bufsize;
|
uInt lit_bufsize;
|
||||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||||
|
@ -239,13 +250,8 @@ typedef struct internal_state {
|
||||||
* - I can't count above 4
|
* - I can't count above 4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uInt last_lit; /* running index in l_buf */
|
uInt sym_next; /* running index in symbol buffer */
|
||||||
|
uInt sym_end; /* symbol table full when sym_next reaches this */
|
||||||
ushf *d_buf;
|
|
||||||
/* Buffer for distances. To simplify the code, d_buf and l_buf have
|
|
||||||
* the same number of elements. To use different lengths, an extra flag
|
|
||||||
* array would be necessary.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ulg opt_len; /* bit length of current block with optimal trees */
|
ulg opt_len; /* bit length of current block with optimal trees */
|
||||||
ulg static_len; /* bit length of current block with static trees */
|
ulg static_len; /* bit length of current block with static trees */
|
||||||
|
@ -296,14 +302,14 @@ typedef struct internal_state {
|
||||||
memory checker errors from longest match routines */
|
memory checker errors from longest match routines */
|
||||||
|
|
||||||
/* in trees.c */
|
/* in trees.c */
|
||||||
void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_init(deflate_state *s);
|
||||||
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
|
||||||
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
|
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
|
||||||
ulg stored_len, int last));
|
ulg stored_len, int last);
|
||||||
void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
|
||||||
void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_align(deflate_state *s);
|
||||||
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
|
||||||
ulg stored_len, int last));
|
ulg stored_len, int last);
|
||||||
|
|
||||||
#define d_code(dist) \
|
#define d_code(dist) \
|
||||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||||
|
@ -323,24 +329,46 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
||||||
extern const uch ZLIB_INTERNAL _dist_code[];
|
extern const uch ZLIB_INTERNAL _dist_code[];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIT_MEM
|
||||||
# define _tr_tally_lit(s, c, flush) \
|
# define _tr_tally_lit(s, c, flush) \
|
||||||
{ uch cc = (c); \
|
{ uch cc = (c); \
|
||||||
s->d_buf[s->last_lit] = 0; \
|
s->d_buf[s->sym_next] = 0; \
|
||||||
s->l_buf[s->last_lit++] = cc; \
|
s->l_buf[s->sym_next++] = cc; \
|
||||||
s->dyn_ltree[cc].Freq++; \
|
s->dyn_ltree[cc].Freq++; \
|
||||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
flush = (s->sym_next == s->sym_end); \
|
||||||
}
|
}
|
||||||
# define _tr_tally_dist(s, distance, length, flush) \
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
{ uch len = (uch)(length); \
|
{ uch len = (uch)(length); \
|
||||||
ush dist = (ush)(distance); \
|
ush dist = (ush)(distance); \
|
||||||
s->d_buf[s->last_lit] = dist; \
|
s->d_buf[s->sym_next] = dist; \
|
||||||
s->l_buf[s->last_lit++] = len; \
|
s->l_buf[s->sym_next++] = len; \
|
||||||
dist--; \
|
dist--; \
|
||||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
flush = (s->sym_next == s->sym_end); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
# define _tr_tally_lit(s, c, flush) \
|
||||||
|
{ uch cc = (c); \
|
||||||
|
s->sym_buf[s->sym_next++] = 0; \
|
||||||
|
s->sym_buf[s->sym_next++] = 0; \
|
||||||
|
s->sym_buf[s->sym_next++] = cc; \
|
||||||
|
s->dyn_ltree[cc].Freq++; \
|
||||||
|
flush = (s->sym_next == s->sym_end); \
|
||||||
|
}
|
||||||
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
|
{ uch len = (uch)(length); \
|
||||||
|
ush dist = (ush)(distance); \
|
||||||
|
s->sym_buf[s->sym_next++] = (uch)dist; \
|
||||||
|
s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
|
||||||
|
s->sym_buf[s->sym_next++] = len; \
|
||||||
|
dist--; \
|
||||||
|
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||||
|
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||||
|
flush = (s->sym_next == s->sym_end); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||||
# define _tr_tally_dist(s, distance, length, flush) \
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
flush = _tr_tally(s, distance, length)
|
flush = _tr_tally(s, distance, length)
|
||||||
|
|
4
common/zlib/gzclose.c
Executable file → Normal file
4
common/zlib/gzclose.c
Executable file → Normal file
|
@ -8,9 +8,7 @@
|
||||||
/* gzclose() is in a separate file so that it is linked in only if it is used.
|
/* gzclose() is in a separate file so that it is linked in only if it is used.
|
||||||
That way the other gzclose functions can be used instead to avoid linking in
|
That way the other gzclose functions can be used instead to avoid linking in
|
||||||
unneeded compression or decompression routines. */
|
unneeded compression or decompression routines. */
|
||||||
int ZEXPORT gzclose(file)
|
int ZEXPORT gzclose(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
#ifndef NO_GZCOMPRESS
|
#ifndef NO_GZCOMPRESS
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
|
|
35
common/zlib/gzguts.h
Executable file → Normal file
35
common/zlib/gzguts.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* gzguts.h -- zlib internal header definitions for gz* operations
|
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
|
* Copyright (C) 2004-2024 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -7,9 +7,8 @@
|
||||||
# ifndef _LARGEFILE_SOURCE
|
# ifndef _LARGEFILE_SOURCE
|
||||||
# define _LARGEFILE_SOURCE 1
|
# define _LARGEFILE_SOURCE 1
|
||||||
# endif
|
# endif
|
||||||
# ifdef _FILE_OFFSET_BITS
|
|
||||||
# undef _FILE_OFFSET_BITS
|
# undef _FILE_OFFSET_BITS
|
||||||
# endif
|
# undef _TIME_BITS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_HIDDEN
|
#ifdef HAVE_HIDDEN
|
||||||
|
@ -39,7 +38,7 @@
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32)
|
||||||
# define WIDECHAR
|
# define WIDECHAR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -119,8 +118,8 @@
|
||||||
|
|
||||||
/* gz* functions always use library allocation functions */
|
/* gz* functions always use library allocation functions */
|
||||||
#ifndef STDC
|
#ifndef STDC
|
||||||
extern voidp malloc OF((uInt size));
|
extern voidp malloc(uInt size);
|
||||||
extern void free OF((voidpf ptr));
|
extern void free(voidpf ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get errno and strerror definition */
|
/* get errno and strerror definition */
|
||||||
|
@ -138,10 +137,10 @@
|
||||||
|
|
||||||
/* provide prototypes for these when building zlib without LFS */
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||||
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||||
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
|
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
|
||||||
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
|
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
|
||||||
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* default memLevel */
|
/* default memLevel */
|
||||||
|
@ -190,6 +189,7 @@ typedef struct {
|
||||||
/* just for writing */
|
/* just for writing */
|
||||||
int level; /* compression level */
|
int level; /* compression level */
|
||||||
int strategy; /* compression strategy */
|
int strategy; /* compression strategy */
|
||||||
|
int reset; /* true if a reset is pending after a Z_FINISH */
|
||||||
/* seek request */
|
/* seek request */
|
||||||
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
||||||
int seek; /* true if seek request pending */
|
int seek; /* true if seek request pending */
|
||||||
|
@ -202,22 +202,13 @@ typedef struct {
|
||||||
typedef gz_state FAR *gz_statep;
|
typedef gz_state FAR *gz_statep;
|
||||||
|
|
||||||
/* shared functions */
|
/* shared functions */
|
||||||
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
|
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
|
||||||
#if defined UNDER_CE
|
#if defined UNDER_CE
|
||||||
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
|
char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
||||||
value -- needed when comparing unsigned to z_off64_t, which is signed
|
value -- needed when comparing unsigned to z_off64_t, which is signed
|
||||||
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||||
#ifdef INT_MAX
|
unsigned ZLIB_INTERNAL gz_intmax(void);
|
||||||
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
|
|
||||||
#else
|
|
||||||
unsigned ZLIB_INTERNAL gz_intmax OF((void));
|
|
||||||
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||||
#endif
|
|
||||||
|
|
||||||
/* UEFITool change, fixes undefined lseek, open, read prototypes. */
|
|
||||||
#ifndef _WIN32
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
119
common/zlib/gzlib.c
Executable file → Normal file
119
common/zlib/gzlib.c
Executable file → Normal file
|
@ -1,11 +1,11 @@
|
||||||
/* gzlib.c -- zlib functions common to reading and writing gzip files
|
/* gzlib.c -- zlib functions common to reading and writing gzip files
|
||||||
* Copyright (C) 2004-2017 Mark Adler
|
* Copyright (C) 2004-2024 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gzguts.h"
|
#include "gzguts.h"
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
|
#if defined(_WIN32) && !defined(__BORLANDC__)
|
||||||
# define LSEEK _lseeki64
|
# define LSEEK _lseeki64
|
||||||
#else
|
#else
|
||||||
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
||||||
|
@ -15,10 +15,6 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Local functions */
|
|
||||||
local void gz_reset OF((gz_statep));
|
|
||||||
local gzFile gz_open OF((const void *, int, const char *));
|
|
||||||
|
|
||||||
#if defined UNDER_CE
|
#if defined UNDER_CE
|
||||||
|
|
||||||
/* Map the Windows error number in ERROR to a locale-dependent error message
|
/* Map the Windows error number in ERROR to a locale-dependent error message
|
||||||
|
@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *));
|
||||||
|
|
||||||
The gz_strwinerror function does not change the current setting of
|
The gz_strwinerror function does not change the current setting of
|
||||||
GetLastError. */
|
GetLastError. */
|
||||||
char ZLIB_INTERNAL *gz_strwinerror (error)
|
char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
|
||||||
DWORD error;
|
|
||||||
{
|
|
||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
|
|
||||||
wchar_t *msgbuf;
|
wchar_t *msgbuf;
|
||||||
|
@ -72,15 +66,15 @@ char ZLIB_INTERNAL *gz_strwinerror (error)
|
||||||
#endif /* UNDER_CE */
|
#endif /* UNDER_CE */
|
||||||
|
|
||||||
/* Reset gzip file state */
|
/* Reset gzip file state */
|
||||||
local void gz_reset(state)
|
local void gz_reset(gz_statep state) {
|
||||||
gz_statep state;
|
|
||||||
{
|
|
||||||
state->x.have = 0; /* no output data available */
|
state->x.have = 0; /* no output data available */
|
||||||
if (state->mode == GZ_READ) { /* for reading ... */
|
if (state->mode == GZ_READ) { /* for reading ... */
|
||||||
state->eof = 0; /* not at end of file */
|
state->eof = 0; /* not at end of file */
|
||||||
state->past = 0; /* have not read past end yet */
|
state->past = 0; /* have not read past end yet */
|
||||||
state->how = LOOK; /* look for gzip header */
|
state->how = LOOK; /* look for gzip header */
|
||||||
}
|
}
|
||||||
|
else /* for writing ... */
|
||||||
|
state->reset = 0; /* no deflateReset pending */
|
||||||
state->seek = 0; /* no seek request pending */
|
state->seek = 0; /* no seek request pending */
|
||||||
gz_error(state, Z_OK, NULL); /* clear error */
|
gz_error(state, Z_OK, NULL); /* clear error */
|
||||||
state->x.pos = 0; /* no uncompressed data yet */
|
state->x.pos = 0; /* no uncompressed data yet */
|
||||||
|
@ -88,11 +82,7 @@ local void gz_reset(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open a gzip file either by name or file descriptor. */
|
/* Open a gzip file either by name or file descriptor. */
|
||||||
local gzFile gz_open(path, fd, mode)
|
local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||||
const void *path;
|
|
||||||
int fd;
|
|
||||||
const char *mode;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
z_size_t len;
|
z_size_t len;
|
||||||
int oflag;
|
int oflag;
|
||||||
|
@ -267,26 +257,17 @@ local gzFile gz_open(path, fd, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
gzFile ZEXPORT gzopen(path, mode)
|
gzFile ZEXPORT gzopen(const char *path, const char *mode) {
|
||||||
const char *path;
|
|
||||||
const char *mode;
|
|
||||||
{
|
|
||||||
return gz_open(path, -1, mode);
|
return gz_open(path, -1, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
gzFile ZEXPORT gzopen64(path, mode)
|
gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
|
||||||
const char *path;
|
|
||||||
const char *mode;
|
|
||||||
{
|
|
||||||
return gz_open(path, -1, mode);
|
return gz_open(path, -1, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
gzFile ZEXPORT gzdopen(fd, mode)
|
gzFile ZEXPORT gzdopen(int fd, const char *mode) {
|
||||||
int fd;
|
|
||||||
const char *mode;
|
|
||||||
{
|
|
||||||
char *path; /* identifier for error messages */
|
char *path; /* identifier for error messages */
|
||||||
gzFile gz;
|
gzFile gz;
|
||||||
|
|
||||||
|
@ -304,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
#ifdef WIDECHAR
|
#ifdef WIDECHAR
|
||||||
gzFile ZEXPORT gzopen_w(path, mode)
|
gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
|
||||||
const wchar_t *path;
|
|
||||||
const char *mode;
|
|
||||||
{
|
|
||||||
return gz_open(path, -2, mode);
|
return gz_open(path, -2, mode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzbuffer(file, size)
|
int ZEXPORT gzbuffer(gzFile file, unsigned size) {
|
||||||
gzFile file;
|
|
||||||
unsigned size;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure and check integrity */
|
/* get internal structure and check integrity */
|
||||||
|
@ -333,16 +308,14 @@ int ZEXPORT gzbuffer(file, size)
|
||||||
/* check and set requested size */
|
/* check and set requested size */
|
||||||
if ((size << 1) < size)
|
if ((size << 1) < size)
|
||||||
return -1; /* need to be able to double it */
|
return -1; /* need to be able to double it */
|
||||||
if (size < 2)
|
if (size < 8)
|
||||||
size = 2; /* need two bytes to check magic header */
|
size = 8; /* needed to behave well with flushing */
|
||||||
state->want = size;
|
state->want = size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzrewind(file)
|
int ZEXPORT gzrewind(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
|
@ -363,11 +336,7 @@ int ZEXPORT gzrewind(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_off64_t ZEXPORT gzseek64(file, offset, whence)
|
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
|
||||||
gzFile file;
|
|
||||||
z_off64_t offset;
|
|
||||||
int whence;
|
|
||||||
{
|
|
||||||
unsigned n;
|
unsigned n;
|
||||||
z_off64_t ret;
|
z_off64_t ret;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
@ -397,7 +366,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
|
||||||
/* if within raw area while reading, just go there */
|
/* if within raw area while reading, just go there */
|
||||||
if (state->mode == GZ_READ && state->how == COPY &&
|
if (state->mode == GZ_READ && state->how == COPY &&
|
||||||
state->x.pos + offset >= 0) {
|
state->x.pos + offset >= 0) {
|
||||||
ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
|
ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return -1;
|
return -1;
|
||||||
state->x.have = 0;
|
state->x.have = 0;
|
||||||
|
@ -440,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_off_t ZEXPORT gzseek(file, offset, whence)
|
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
|
||||||
gzFile file;
|
|
||||||
z_off_t offset;
|
|
||||||
int whence;
|
|
||||||
{
|
|
||||||
z_off64_t ret;
|
z_off64_t ret;
|
||||||
|
|
||||||
ret = gzseek64(file, (z_off64_t)offset, whence);
|
ret = gzseek64(file, (z_off64_t)offset, whence);
|
||||||
|
@ -452,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_off64_t ZEXPORT gztell64(file)
|
z_off64_t ZEXPORT gztell64(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure and check integrity */
|
/* get internal structure and check integrity */
|
||||||
|
@ -469,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_off_t ZEXPORT gztell(file)
|
z_off_t ZEXPORT gztell(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
z_off64_t ret;
|
z_off64_t ret;
|
||||||
|
|
||||||
ret = gztell64(file);
|
ret = gztell64(file);
|
||||||
|
@ -479,9 +440,7 @@ z_off_t ZEXPORT gztell(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_off64_t ZEXPORT gzoffset64(file)
|
z_off64_t ZEXPORT gzoffset64(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
z_off64_t offset;
|
z_off64_t offset;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
|
@ -502,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_off_t ZEXPORT gzoffset(file)
|
z_off_t ZEXPORT gzoffset(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
z_off64_t ret;
|
z_off64_t ret;
|
||||||
|
|
||||||
ret = gzoffset64(file);
|
ret = gzoffset64(file);
|
||||||
|
@ -512,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzeof(file)
|
int ZEXPORT gzeof(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure and check integrity */
|
/* get internal structure and check integrity */
|
||||||
|
@ -529,10 +484,7 @@ int ZEXPORT gzeof(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
const char * ZEXPORT gzerror(file, errnum)
|
const char * ZEXPORT gzerror(gzFile file, int *errnum) {
|
||||||
gzFile file;
|
|
||||||
int *errnum;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure and check integrity */
|
/* get internal structure and check integrity */
|
||||||
|
@ -550,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
void ZEXPORT gzclearerr(file)
|
void ZEXPORT gzclearerr(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure and check integrity */
|
/* get internal structure and check integrity */
|
||||||
|
@ -576,11 +526,7 @@ void ZEXPORT gzclearerr(file)
|
||||||
memory). Simply save the error message as a static string. If there is an
|
memory). Simply save the error message as a static string. If there is an
|
||||||
allocation failure constructing the error message, then convert the error to
|
allocation failure constructing the error message, then convert the error to
|
||||||
out of memory. */
|
out of memory. */
|
||||||
void ZLIB_INTERNAL gz_error(state, err, msg)
|
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
|
||||||
gz_statep state;
|
|
||||||
int err;
|
|
||||||
const char *msg;
|
|
||||||
{
|
|
||||||
/* free previously allocated message and clear */
|
/* free previously allocated message and clear */
|
||||||
if (state->msg != NULL) {
|
if (state->msg != NULL) {
|
||||||
if (state->err != Z_MEM_ERROR)
|
if (state->err != Z_MEM_ERROR)
|
||||||
|
@ -617,21 +563,20 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef INT_MAX
|
|
||||||
/* portably return maximum value for an int (when limits.h presumed not
|
/* portably return maximum value for an int (when limits.h presumed not
|
||||||
available) -- we need to do this to cover cases where 2's complement not
|
available) -- we need to do this to cover cases where 2's complement not
|
||||||
used, since C standard permits 1's complement and sign-bit representations,
|
used, since C standard permits 1's complement and sign-bit representations,
|
||||||
otherwise we could just use ((unsigned)-1) >> 1 */
|
otherwise we could just use ((unsigned)-1) >> 1 */
|
||||||
unsigned ZLIB_INTERNAL gz_intmax()
|
unsigned ZLIB_INTERNAL gz_intmax(void) {
|
||||||
{
|
#ifdef INT_MAX
|
||||||
unsigned p, q;
|
return INT_MAX;
|
||||||
|
#else
|
||||||
p = 1;
|
unsigned p = 1, q;
|
||||||
do {
|
do {
|
||||||
q = p;
|
q = p;
|
||||||
p <<= 1;
|
p <<= 1;
|
||||||
p++;
|
p++;
|
||||||
} while (p > q);
|
} while (p > q);
|
||||||
return q >> 1;
|
return q >> 1;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
105
common/zlib/gzread.c
Executable file → Normal file
105
common/zlib/gzread.c
Executable file → Normal file
|
@ -1,29 +1,16 @@
|
||||||
/* gzread.c -- zlib functions for reading gzip files
|
/* gzread.c -- zlib functions for reading gzip files
|
||||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
|
* Copyright (C) 2004-2017 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gzguts.h"
|
#include "gzguts.h"
|
||||||
|
|
||||||
/* Local functions */
|
|
||||||
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
|
|
||||||
local int gz_avail OF((gz_statep));
|
|
||||||
local int gz_look OF((gz_statep));
|
|
||||||
local int gz_decomp OF((gz_statep));
|
|
||||||
local int gz_fetch OF((gz_statep));
|
|
||||||
local int gz_skip OF((gz_statep, z_off64_t));
|
|
||||||
local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
|
|
||||||
|
|
||||||
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
|
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
|
||||||
state->fd, and update state->eof, state->err, and state->msg as appropriate.
|
state->fd, and update state->eof, state->err, and state->msg as appropriate.
|
||||||
This function needs to loop on read(), since read() is not guaranteed to
|
This function needs to loop on read(), since read() is not guaranteed to
|
||||||
read the number of bytes requested, depending on the type of descriptor. */
|
read the number of bytes requested, depending on the type of descriptor. */
|
||||||
local int gz_load(state, buf, len, have)
|
local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
|
||||||
gz_statep state;
|
unsigned *have) {
|
||||||
unsigned char *buf;
|
|
||||||
unsigned len;
|
|
||||||
unsigned *have;
|
|
||||||
{
|
|
||||||
int ret;
|
int ret;
|
||||||
unsigned get, max = ((unsigned)-1 >> 2) + 1;
|
unsigned get, max = ((unsigned)-1 >> 2) + 1;
|
||||||
|
|
||||||
|
@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have)
|
||||||
If strm->avail_in != 0, then the current data is moved to the beginning of
|
If strm->avail_in != 0, then the current data is moved to the beginning of
|
||||||
the input buffer, and then the remainder of the buffer is loaded with the
|
the input buffer, and then the remainder of the buffer is loaded with the
|
||||||
available data from the input file. */
|
available data from the input file. */
|
||||||
local int gz_avail(state)
|
local int gz_avail(gz_statep state) {
|
||||||
gz_statep state;
|
|
||||||
{
|
|
||||||
unsigned got;
|
unsigned got;
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
|
||||||
|
@ -88,9 +73,7 @@ local int gz_avail(state)
|
||||||
case, all further file reads will be directly to either the output buffer or
|
case, all further file reads will be directly to either the output buffer or
|
||||||
a user buffer. If decompressing, the inflate state will be initialized.
|
a user buffer. If decompressing, the inflate state will be initialized.
|
||||||
gz_look() will return 0 on success or -1 on failure. */
|
gz_look() will return 0 on success or -1 on failure. */
|
||||||
local int gz_look(state)
|
local int gz_look(gz_statep state) {
|
||||||
gz_statep state;
|
|
||||||
{
|
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
|
||||||
/* allocate read buffers and inflate memory */
|
/* allocate read buffers and inflate memory */
|
||||||
|
@ -157,11 +140,9 @@ local int gz_look(state)
|
||||||
the output buffer is larger than the input buffer, which also assures
|
the output buffer is larger than the input buffer, which also assures
|
||||||
space for gzungetc() */
|
space for gzungetc() */
|
||||||
state->x.next = state->out;
|
state->x.next = state->out;
|
||||||
if (strm->avail_in) {
|
|
||||||
memcpy(state->x.next, strm->next_in, strm->avail_in);
|
memcpy(state->x.next, strm->next_in, strm->avail_in);
|
||||||
state->x.have = strm->avail_in;
|
state->x.have = strm->avail_in;
|
||||||
strm->avail_in = 0;
|
strm->avail_in = 0;
|
||||||
}
|
|
||||||
state->how = COPY;
|
state->how = COPY;
|
||||||
state->direct = 1;
|
state->direct = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -172,9 +153,7 @@ local int gz_look(state)
|
||||||
data. If the gzip stream completes, state->how is reset to LOOK to look for
|
data. If the gzip stream completes, state->how is reset to LOOK to look for
|
||||||
the next gzip stream or raw data, once state->x.have is depleted. Returns 0
|
the next gzip stream or raw data, once state->x.have is depleted. Returns 0
|
||||||
on success, -1 on failure. */
|
on success, -1 on failure. */
|
||||||
local int gz_decomp(state)
|
local int gz_decomp(gz_statep state) {
|
||||||
gz_statep state;
|
|
||||||
{
|
|
||||||
int ret = Z_OK;
|
int ret = Z_OK;
|
||||||
unsigned had;
|
unsigned had;
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
@ -226,9 +205,7 @@ local int gz_decomp(state)
|
||||||
looked for to determine whether to copy or decompress. Returns -1 on error,
|
looked for to determine whether to copy or decompress. Returns -1 on error,
|
||||||
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
|
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
|
||||||
end of the input file has been reached and all data has been processed. */
|
end of the input file has been reached and all data has been processed. */
|
||||||
local int gz_fetch(state)
|
local int gz_fetch(gz_statep state) {
|
||||||
gz_statep state;
|
|
||||||
{
|
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -256,10 +233,7 @@ local int gz_fetch(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
|
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
|
||||||
local int gz_skip(state, len)
|
local int gz_skip(gz_statep state, z_off64_t len) {
|
||||||
gz_statep state;
|
|
||||||
z_off64_t len;
|
|
||||||
{
|
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
/* skip over len bytes or reach end-of-file, whichever comes first */
|
/* skip over len bytes or reach end-of-file, whichever comes first */
|
||||||
|
@ -291,11 +265,7 @@ local int gz_skip(state, len)
|
||||||
input. Return the number of bytes read. If zero is returned, either the
|
input. Return the number of bytes read. If zero is returned, either the
|
||||||
end of file was reached, or there was an error. state->err must be
|
end of file was reached, or there was an error. state->err must be
|
||||||
consulted in that case to determine which. */
|
consulted in that case to determine which. */
|
||||||
local z_size_t gz_read(state, buf, len)
|
local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
|
||||||
gz_statep state;
|
|
||||||
voidp buf;
|
|
||||||
z_size_t len;
|
|
||||||
{
|
|
||||||
z_size_t got;
|
z_size_t got;
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
|
@ -314,9 +284,9 @@ local z_size_t gz_read(state, buf, len)
|
||||||
got = 0;
|
got = 0;
|
||||||
do {
|
do {
|
||||||
/* set n to the maximum amount of len that fits in an unsigned int */
|
/* set n to the maximum amount of len that fits in an unsigned int */
|
||||||
n = -1;
|
n = (unsigned)-1;
|
||||||
if (n > len)
|
if (n > len)
|
||||||
n = len;
|
n = (unsigned)len;
|
||||||
|
|
||||||
/* first just try copying data from the output buffer */
|
/* first just try copying data from the output buffer */
|
||||||
if (state->x.have) {
|
if (state->x.have) {
|
||||||
|
@ -372,11 +342,7 @@ local z_size_t gz_read(state, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzread(file, buf, len)
|
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
|
||||||
gzFile file;
|
|
||||||
voidp buf;
|
|
||||||
unsigned len;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
|
@ -397,7 +363,7 @@ int ZEXPORT gzread(file, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read len or fewer bytes to buf */
|
/* read len or fewer bytes to buf */
|
||||||
len = gz_read(state, buf, len);
|
len = (unsigned)gz_read(state, buf, len);
|
||||||
|
|
||||||
/* check for an error */
|
/* check for an error */
|
||||||
if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
|
if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
|
||||||
|
@ -408,18 +374,10 @@ int ZEXPORT gzread(file, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_size_t ZEXPORT gzfread(buf, size, nitems, file)
|
z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
|
||||||
voidp buf;
|
|
||||||
z_size_t size;
|
|
||||||
z_size_t nitems;
|
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
z_size_t len;
|
z_size_t len;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
if (nitems == 0 || size == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -447,10 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
|
||||||
#else
|
#else
|
||||||
# undef gzgetc
|
# undef gzgetc
|
||||||
#endif
|
#endif
|
||||||
int ZEXPORT gzgetc(file)
|
int ZEXPORT gzgetc(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
unsigned char buf[1];
|
unsigned char buf[1];
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
|
@ -472,21 +427,15 @@ int ZEXPORT gzgetc(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nothing there -- try gz_read() */
|
/* nothing there -- try gz_read() */
|
||||||
ret = gz_read(state, buf, 1);
|
return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
|
||||||
return ret < 1 ? -1 : buf[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT gzgetc_(file)
|
int ZEXPORT gzgetc_(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
return gzgetc(file);
|
return gzgetc(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzungetc(c, file)
|
int ZEXPORT gzungetc(int c, gzFile file) {
|
||||||
int c;
|
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
|
@ -494,6 +443,10 @@ int ZEXPORT gzungetc(c, file)
|
||||||
return -1;
|
return -1;
|
||||||
state = (gz_statep)file;
|
state = (gz_statep)file;
|
||||||
|
|
||||||
|
/* in case this was just opened, set up the input buffer */
|
||||||
|
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
|
||||||
|
(void)gz_look(state);
|
||||||
|
|
||||||
/* check that we're reading and that there's no (serious) error */
|
/* check that we're reading and that there's no (serious) error */
|
||||||
if (state->mode != GZ_READ ||
|
if (state->mode != GZ_READ ||
|
||||||
(state->err != Z_OK && state->err != Z_BUF_ERROR))
|
(state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||||
|
@ -543,11 +496,7 @@ int ZEXPORT gzungetc(c, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
char * ZEXPORT gzgets(file, buf, len)
|
char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
|
||||||
gzFile file;
|
|
||||||
char *buf;
|
|
||||||
int len;
|
|
||||||
{
|
|
||||||
unsigned left, n;
|
unsigned left, n;
|
||||||
char *str;
|
char *str;
|
||||||
unsigned char *eol;
|
unsigned char *eol;
|
||||||
|
@ -607,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzdirect(file)
|
int ZEXPORT gzdirect(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
|
@ -627,9 +574,7 @@ int ZEXPORT gzdirect(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzclose_r(file)
|
int ZEXPORT gzclose_r(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
int ret, err;
|
int ret, err;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
|
|
121
common/zlib/gzwrite.c
Executable file → Normal file
121
common/zlib/gzwrite.c
Executable file → Normal file
|
@ -1,22 +1,14 @@
|
||||||
/* gzwrite.c -- zlib functions for writing gzip files
|
/* gzwrite.c -- zlib functions for writing gzip files
|
||||||
* Copyright (C) 2004-2017 Mark Adler
|
* Copyright (C) 2004-2019 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gzguts.h"
|
#include "gzguts.h"
|
||||||
|
|
||||||
/* Local functions */
|
|
||||||
local int gz_init OF((gz_statep));
|
|
||||||
local int gz_comp OF((gz_statep, int));
|
|
||||||
local int gz_zero OF((gz_statep, z_off64_t));
|
|
||||||
local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
|
|
||||||
|
|
||||||
/* Initialize state for writing a gzip file. Mark initialization by setting
|
/* Initialize state for writing a gzip file. Mark initialization by setting
|
||||||
state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
|
state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
|
||||||
success. */
|
success. */
|
||||||
local int gz_init(state)
|
local int gz_init(gz_statep state) {
|
||||||
gz_statep state;
|
|
||||||
{
|
|
||||||
int ret;
|
int ret;
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
|
||||||
|
@ -70,10 +62,7 @@ local int gz_init(state)
|
||||||
deflate() flush value. If flush is Z_FINISH, then the deflate() state is
|
deflate() flush value. If flush is Z_FINISH, then the deflate() state is
|
||||||
reset to start a new gzip stream. If gz->direct is true, then simply write
|
reset to start a new gzip stream. If gz->direct is true, then simply write
|
||||||
to the output file without compressing, and ignore flush. */
|
to the output file without compressing, and ignore flush. */
|
||||||
local int gz_comp(state, flush)
|
local int gz_comp(gz_statep state, int flush) {
|
||||||
gz_statep state;
|
|
||||||
int flush;
|
|
||||||
{
|
|
||||||
int ret, writ;
|
int ret, writ;
|
||||||
unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
|
unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
@ -97,6 +86,15 @@ local int gz_comp(state, flush)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check for a pending reset */
|
||||||
|
if (state->reset) {
|
||||||
|
/* don't start a new gzip member unless there is data to write */
|
||||||
|
if (strm->avail_in == 0)
|
||||||
|
return 0;
|
||||||
|
deflateReset(strm);
|
||||||
|
state->reset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* run deflate() on provided input until it produces no more output */
|
/* run deflate() on provided input until it produces no more output */
|
||||||
ret = Z_OK;
|
ret = Z_OK;
|
||||||
do {
|
do {
|
||||||
|
@ -134,7 +132,7 @@ local int gz_comp(state, flush)
|
||||||
|
|
||||||
/* if that completed a deflate stream, allow another to start */
|
/* if that completed a deflate stream, allow another to start */
|
||||||
if (flush == Z_FINISH)
|
if (flush == Z_FINISH)
|
||||||
deflateReset(strm);
|
state->reset = 1;
|
||||||
|
|
||||||
/* all done, no errors */
|
/* all done, no errors */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -142,10 +140,7 @@ local int gz_comp(state, flush)
|
||||||
|
|
||||||
/* Compress len zeros to output. Return -1 on a write error or memory
|
/* Compress len zeros to output. Return -1 on a write error or memory
|
||||||
allocation failure by gz_comp(), or 0 on success. */
|
allocation failure by gz_comp(), or 0 on success. */
|
||||||
local int gz_zero(state, len)
|
local int gz_zero(gz_statep state, z_off64_t len) {
|
||||||
gz_statep state;
|
|
||||||
z_off64_t len;
|
|
||||||
{
|
|
||||||
int first;
|
int first;
|
||||||
unsigned n;
|
unsigned n;
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
@ -175,11 +170,7 @@ local int gz_zero(state, len)
|
||||||
|
|
||||||
/* Write len bytes from buf to file. Return the number of bytes written. If
|
/* Write len bytes from buf to file. Return the number of bytes written. If
|
||||||
the returned value is less than len, then there was an error. */
|
the returned value is less than len, then there was an error. */
|
||||||
local z_size_t gz_write(state, buf, len)
|
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
|
||||||
gz_statep state;
|
|
||||||
voidpc buf;
|
|
||||||
z_size_t len;
|
|
||||||
{
|
|
||||||
z_size_t put = len;
|
z_size_t put = len;
|
||||||
|
|
||||||
/* if len is zero, avoid unnecessary operations */
|
/* if len is zero, avoid unnecessary operations */
|
||||||
|
@ -209,7 +200,7 @@ local z_size_t gz_write(state, buf, len)
|
||||||
state->in);
|
state->in);
|
||||||
copy = state->size - have;
|
copy = state->size - have;
|
||||||
if (copy > len)
|
if (copy > len)
|
||||||
copy = len;
|
copy = (unsigned)len;
|
||||||
memcpy(state->in + have, buf, copy);
|
memcpy(state->in + have, buf, copy);
|
||||||
state->strm.avail_in += copy;
|
state->strm.avail_in += copy;
|
||||||
state->x.pos += copy;
|
state->x.pos += copy;
|
||||||
|
@ -229,7 +220,7 @@ local z_size_t gz_write(state, buf, len)
|
||||||
do {
|
do {
|
||||||
unsigned n = (unsigned)-1;
|
unsigned n = (unsigned)-1;
|
||||||
if (n > len)
|
if (n > len)
|
||||||
n = len;
|
n = (unsigned)len;
|
||||||
state->strm.avail_in = n;
|
state->strm.avail_in = n;
|
||||||
state->x.pos += n;
|
state->x.pos += n;
|
||||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
|
@ -243,11 +234,7 @@ local z_size_t gz_write(state, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzwrite(file, buf, len)
|
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
|
||||||
gzFile file;
|
|
||||||
voidpc buf;
|
|
||||||
unsigned len;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
|
@ -271,18 +258,11 @@ int ZEXPORT gzwrite(file, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
|
z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
|
||||||
voidpc buf;
|
gzFile file) {
|
||||||
z_size_t size;
|
|
||||||
z_size_t nitems;
|
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
z_size_t len;
|
z_size_t len;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
if (nitems == 0 || size == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -304,10 +284,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzputc(file, c)
|
int ZEXPORT gzputc(gzFile file, int c) {
|
||||||
gzFile file;
|
|
||||||
int c;
|
|
||||||
{
|
|
||||||
unsigned have;
|
unsigned have;
|
||||||
unsigned char buf[1];
|
unsigned char buf[1];
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
@ -352,12 +329,8 @@ int ZEXPORT gzputc(file, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzputs(file, str)
|
int ZEXPORT gzputs(gzFile file, const char *s) {
|
||||||
gzFile file;
|
z_size_t len, put;
|
||||||
const char *str;
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
z_size_t len;
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
|
@ -370,17 +343,20 @@ int ZEXPORT gzputs(file, str)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* write string */
|
/* write string */
|
||||||
len = strlen(str);
|
len = strlen(s);
|
||||||
ret = gz_write(state, str, len);
|
if ((int)len < 0 || (unsigned)len != len) {
|
||||||
return ret == 0 && len != 0 ? -1 : ret;
|
gz_error(state, Z_STREAM_ERROR, "string length does not fit in int");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
put = gz_write(state, s, len);
|
||||||
|
return put < len ? -1 : (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
|
||||||
{
|
|
||||||
int len;
|
int len;
|
||||||
unsigned left;
|
unsigned left;
|
||||||
char *next;
|
char *next;
|
||||||
|
@ -444,15 +420,14 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
||||||
strm->avail_in = state->size;
|
strm->avail_in = state->size;
|
||||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
return state->err;
|
return state->err;
|
||||||
memcpy(state->in, state->in + state->size, left);
|
memmove(state->in, state->in + state->size, left);
|
||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
strm->avail_in = left;
|
strm->avail_in = left;
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
|
||||||
{
|
|
||||||
va_list va;
|
va_list va;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -465,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
||||||
#else /* !STDC && !Z_HAVE_STDARG_H */
|
#else /* !STDC && !Z_HAVE_STDARG_H */
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
|
||||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
|
int a4, int a5, int a6, int a7, int a8, int a9, int a10,
|
||||||
gzFile file;
|
int a11, int a12, int a13, int a14, int a15, int a16,
|
||||||
const char *format;
|
int a17, int a18, int a19, int a20) {
|
||||||
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
|
||||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
|
||||||
{
|
|
||||||
unsigned len, left;
|
unsigned len, left;
|
||||||
char *next;
|
char *next;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
@ -543,7 +515,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||||
strm->avail_in = state->size;
|
strm->avail_in = state->size;
|
||||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
return state->err;
|
return state->err;
|
||||||
memcpy(state->in, state->in + state->size, left);
|
memmove(state->in, state->in + state->size, left);
|
||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
strm->avail_in = left;
|
strm->avail_in = left;
|
||||||
}
|
}
|
||||||
|
@ -553,10 +525,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzflush(file, flush)
|
int ZEXPORT gzflush(gzFile file, int flush) {
|
||||||
gzFile file;
|
|
||||||
int flush;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
|
@ -585,11 +554,7 @@ int ZEXPORT gzflush(file, flush)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzsetparams(file, level, strategy)
|
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
|
||||||
gzFile file;
|
|
||||||
int level;
|
|
||||||
int strategy;
|
|
||||||
{
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
|
|
||||||
|
@ -600,7 +565,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
|
||||||
strm = &(state->strm);
|
strm = &(state->strm);
|
||||||
|
|
||||||
/* check that we're writing and that there's no error */
|
/* check that we're writing and that there's no error */
|
||||||
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct)
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
|
|
||||||
/* if no change is requested, then do nothing */
|
/* if no change is requested, then do nothing */
|
||||||
|
@ -627,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzclose_w(file)
|
int ZEXPORT gzclose_w(gzFile file) {
|
||||||
gzFile file;
|
|
||||||
{
|
|
||||||
int ret = Z_OK;
|
int ret = Z_OK;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
|
|
51
common/zlib/infback.c
Executable file → Normal file
51
common/zlib/infback.c
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* infback.c -- inflate using a call-back interface
|
/* infback.c -- inflate using a call-back interface
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2022 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -15,9 +15,6 @@
|
||||||
#include "inflate.h"
|
#include "inflate.h"
|
||||||
#include "inffast.h"
|
#include "inffast.h"
|
||||||
|
|
||||||
/* function prototypes */
|
|
||||||
local void fixedtables OF((struct inflate_state FAR *state));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
strm provides memory allocation functions in zalloc and zfree, or
|
strm provides memory allocation functions in zalloc and zfree, or
|
||||||
Z_NULL to use the library memory allocation functions.
|
Z_NULL to use the library memory allocation functions.
|
||||||
|
@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state));
|
||||||
windowBits is in the range 8..15, and window is a user-supplied
|
windowBits is in the range 8..15, and window is a user-supplied
|
||||||
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_(z_streamp strm, int windowBits,
|
||||||
z_streamp strm;
|
unsigned char FAR *window, const char *version,
|
||||||
int windowBits;
|
int stream_size) {
|
||||||
unsigned char FAR *window;
|
|
||||||
const char *version;
|
|
||||||
int stream_size;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||||
|
@ -66,6 +59,7 @@ int stream_size;
|
||||||
state->window = window;
|
state->window = window;
|
||||||
state->wnext = 0;
|
state->wnext = 0;
|
||||||
state->whave = 0;
|
state->whave = 0;
|
||||||
|
state->sane = 1;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,9 +73,7 @@ int stream_size;
|
||||||
used for threaded applications, since the rewriting of the tables and virgin
|
used for threaded applications, since the rewriting of the tables and virgin
|
||||||
may not be thread-safe.
|
may not be thread-safe.
|
||||||
*/
|
*/
|
||||||
local void fixedtables(state)
|
local void fixedtables(struct inflate_state FAR *state) {
|
||||||
struct inflate_state FAR *state;
|
|
||||||
{
|
|
||||||
#ifdef BUILDFIXED
|
#ifdef BUILDFIXED
|
||||||
static int virgin = 1;
|
static int virgin = 1;
|
||||||
static code *lenfix, *distfix;
|
static code *lenfix, *distfix;
|
||||||
|
@ -247,13 +239,8 @@ struct inflate_state FAR *state;
|
||||||
inflateBack() can also return Z_STREAM_ERROR if the input parameters
|
inflateBack() can also return Z_STREAM_ERROR if the input parameters
|
||||||
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(z_streamp strm, in_func in, void FAR *in_desc,
|
||||||
z_streamp strm;
|
out_func out, void FAR *out_desc) {
|
||||||
in_func in;
|
|
||||||
void FAR *in_desc;
|
|
||||||
out_func out;
|
|
||||||
void FAR *out_desc;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
z_const unsigned char FAR *next; /* next input */
|
z_const unsigned char FAR *next; /* next input */
|
||||||
unsigned char FAR *put; /* next output */
|
unsigned char FAR *put; /* next output */
|
||||||
|
@ -477,7 +464,7 @@ void FAR *out_desc;
|
||||||
}
|
}
|
||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
|
|
||||||
case LEN:
|
case LEN:
|
||||||
/* use inflate_fast() if we have enough input and output */
|
/* use inflate_fast() if we have enough input and output */
|
||||||
|
@ -605,33 +592,33 @@ void FAR *out_desc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DONE:
|
case DONE:
|
||||||
/* inflate stream terminated properly -- write leftover output */
|
/* inflate stream terminated properly */
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
if (left < state->wsize) {
|
|
||||||
if (out(out_desc, state->window, state->wsize - left))
|
|
||||||
ret = Z_BUF_ERROR;
|
|
||||||
}
|
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
|
||||||
case BAD:
|
case BAD:
|
||||||
ret = Z_DATA_ERROR;
|
ret = Z_DATA_ERROR;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
|
||||||
default: /* can't happen, but makes compilers happy */
|
default:
|
||||||
|
/* can't happen, but makes compilers happy */
|
||||||
ret = Z_STREAM_ERROR;
|
ret = Z_STREAM_ERROR;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return unused input */
|
/* Write leftover output and return unused input */
|
||||||
inf_leave:
|
inf_leave:
|
||||||
|
if (left < state->wsize) {
|
||||||
|
if (out(out_desc, state->window, state->wsize - left) &&
|
||||||
|
ret == Z_STREAM_END)
|
||||||
|
ret = Z_BUF_ERROR;
|
||||||
|
}
|
||||||
strm->next_in = next;
|
strm->next_in = next;
|
||||||
strm->avail_in = have;
|
strm->avail_in = have;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateBackEnd(strm)
|
int ZEXPORT inflateBackEnd(z_streamp strm) {
|
||||||
z_streamp 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;
|
||||||
ZFREE(strm, strm->state);
|
ZFREE(strm, strm->state);
|
||||||
|
|
33
common/zlib/inffast.c
Executable file → Normal file
33
common/zlib/inffast.c
Executable file → Normal file
|
@ -47,10 +47,7 @@
|
||||||
requires strm->avail_out >= 258 for each loop to avoid checking for
|
requires strm->avail_out >= 258 for each loop to avoid checking for
|
||||||
output space.
|
output space.
|
||||||
*/
|
*/
|
||||||
void ZLIB_INTERNAL inflate_fast(strm, start)
|
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
|
||||||
z_streamp strm;
|
|
||||||
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
z_const unsigned char FAR *in; /* local strm->next_in */
|
z_const unsigned char FAR *in; /* local strm->next_in */
|
||||||
z_const unsigned char FAR *last; /* have enough input while in < last */
|
z_const unsigned char FAR *last; /* have enough input while in < last */
|
||||||
|
@ -70,7 +67,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
code const FAR *dcode; /* local strm->distcode */
|
code const FAR *dcode; /* local strm->distcode */
|
||||||
unsigned lmask; /* mask for first level of length codes */
|
unsigned lmask; /* mask for first level of length codes */
|
||||||
unsigned dmask; /* mask for first level of distance codes */
|
unsigned dmask; /* mask for first level of distance codes */
|
||||||
code here; /* retrieved table entry */
|
code const *here; /* retrieved table entry */
|
||||||
unsigned op; /* code bits, operation, extra bits, or */
|
unsigned op; /* code bits, operation, extra bits, or */
|
||||||
/* window position, window bytes to copy */
|
/* window position, window bytes to copy */
|
||||||
unsigned len; /* match length, unused bytes */
|
unsigned len; /* match length, unused bytes */
|
||||||
|
@ -107,20 +104,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
hold += (unsigned long)(*in++) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
here = lcode[hold & lmask];
|
here = lcode + (hold & lmask);
|
||||||
dolen:
|
dolen:
|
||||||
op = (unsigned)(here.bits);
|
op = (unsigned)(here->bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(here.op);
|
op = (unsigned)(here->op);
|
||||||
if (op == 0) { /* literal */
|
if (op == 0) { /* literal */
|
||||||
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", here.val));
|
"inflate: literal 0x%02x\n", here->val));
|
||||||
*out++ = (unsigned char)(here.val);
|
*out++ = (unsigned char)(here->val);
|
||||||
}
|
}
|
||||||
else if (op & 16) { /* length base */
|
else if (op & 16) { /* length base */
|
||||||
len = (unsigned)(here.val);
|
len = (unsigned)(here->val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (op) {
|
if (op) {
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
|
@ -138,14 +135,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
hold += (unsigned long)(*in++) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
here = dcode[hold & dmask];
|
here = dcode + (hold & dmask);
|
||||||
dodist:
|
dodist:
|
||||||
op = (unsigned)(here.bits);
|
op = (unsigned)(here->bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(here.op);
|
op = (unsigned)(here->op);
|
||||||
if (op & 16) { /* distance base */
|
if (op & 16) { /* distance base */
|
||||||
dist = (unsigned)(here.val);
|
dist = (unsigned)(here->val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += (unsigned long)(*in++) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
|
@ -264,7 +261,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||||
here = dcode[here.val + (hold & ((1U << op) - 1))];
|
here = dcode + here->val + (hold & ((1U << op) - 1));
|
||||||
goto dodist;
|
goto dodist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -274,7 +271,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level length code */
|
else if ((op & 64) == 0) { /* 2nd level length code */
|
||||||
here = lcode[here.val + (hold & ((1U << op) - 1))];
|
here = lcode + here->val + (hold & ((1U << op) - 1));
|
||||||
goto dolen;
|
goto dolen;
|
||||||
}
|
}
|
||||||
else if (op & 32) { /* end-of-block */
|
else if (op & 32) { /* end-of-block */
|
||||||
|
|
2
common/zlib/inffast.h
Executable file → Normal file
2
common/zlib/inffast.h
Executable file → Normal file
|
@ -8,4 +8,4 @@
|
||||||
subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
|
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
|
||||||
|
|
0
common/zlib/inffixed.h
Executable file → Normal file
0
common/zlib/inffixed.h
Executable file → Normal file
211
common/zlib/inflate.c
Executable file → Normal file
211
common/zlib/inflate.c
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.c -- zlib decompression
|
/* inflate.c -- zlib decompression
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2022 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -91,20 +91,7 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* function prototypes */
|
local int inflateStateCheck(z_streamp strm) {
|
||||||
local int inflateStateCheck OF((z_streamp strm));
|
|
||||||
local void fixedtables OF((struct inflate_state FAR *state));
|
|
||||||
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
|
|
||||||
unsigned copy));
|
|
||||||
#ifdef BUILDFIXED
|
|
||||||
void makefixed OF((void));
|
|
||||||
#endif
|
|
||||||
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
|
|
||||||
unsigned len));
|
|
||||||
|
|
||||||
local int inflateStateCheck(strm)
|
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
if (strm == Z_NULL ||
|
if (strm == Z_NULL ||
|
||||||
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
|
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
|
||||||
|
@ -116,9 +103,7 @@ z_streamp strm;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateResetKeep(strm)
|
int ZEXPORT inflateResetKeep(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
|
@ -130,6 +115,7 @@ z_streamp strm;
|
||||||
state->mode = HEAD;
|
state->mode = HEAD;
|
||||||
state->last = 0;
|
state->last = 0;
|
||||||
state->havedict = 0;
|
state->havedict = 0;
|
||||||
|
state->flags = -1;
|
||||||
state->dmax = 32768U;
|
state->dmax = 32768U;
|
||||||
state->head = Z_NULL;
|
state->head = Z_NULL;
|
||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
|
@ -141,9 +127,7 @@ z_streamp strm;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateReset(strm)
|
int ZEXPORT inflateReset(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
|
@ -154,10 +138,7 @@ z_streamp strm;
|
||||||
return inflateResetKeep(strm);
|
return inflateResetKeep(strm);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateReset2(strm, windowBits)
|
int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
|
||||||
z_streamp strm;
|
|
||||||
int windowBits;
|
|
||||||
{
|
|
||||||
int wrap;
|
int wrap;
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
@ -167,6 +148,8 @@ int windowBits;
|
||||||
|
|
||||||
/* extract wrap request from windowBits parameter */
|
/* extract wrap request from windowBits parameter */
|
||||||
if (windowBits < 0) {
|
if (windowBits < 0) {
|
||||||
|
if (windowBits < -15)
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
wrap = 0;
|
wrap = 0;
|
||||||
windowBits = -windowBits;
|
windowBits = -windowBits;
|
||||||
}
|
}
|
||||||
|
@ -192,12 +175,8 @@ int windowBits;
|
||||||
return inflateReset(strm);
|
return inflateReset(strm);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
|
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
|
||||||
z_streamp strm;
|
const char *version, int stream_size) {
|
||||||
int windowBits;
|
|
||||||
const char *version;
|
|
||||||
int stream_size;
|
|
||||||
{
|
|
||||||
int ret;
|
int ret;
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
@ -236,22 +215,17 @@ int stream_size;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateInit_(strm, version, stream_size)
|
int ZEXPORT inflateInit_(z_streamp strm, const char *version,
|
||||||
z_streamp strm;
|
int stream_size) {
|
||||||
const char *version;
|
|
||||||
int stream_size;
|
|
||||||
{
|
|
||||||
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflatePrime(strm, bits, value)
|
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
|
||||||
z_streamp strm;
|
|
||||||
int bits;
|
|
||||||
int value;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
|
if (bits == 0)
|
||||||
|
return Z_OK;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
if (bits < 0) {
|
if (bits < 0) {
|
||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
|
@ -275,9 +249,7 @@ int value;
|
||||||
used for threaded applications, since the rewriting of the tables and virgin
|
used for threaded applications, since the rewriting of the tables and virgin
|
||||||
may not be thread-safe.
|
may not be thread-safe.
|
||||||
*/
|
*/
|
||||||
local void fixedtables(state)
|
local void fixedtables(struct inflate_state FAR *state) {
|
||||||
struct inflate_state FAR *state;
|
|
||||||
{
|
|
||||||
#ifdef BUILDFIXED
|
#ifdef BUILDFIXED
|
||||||
static int virgin = 1;
|
static int virgin = 1;
|
||||||
static code *lenfix, *distfix;
|
static code *lenfix, *distfix;
|
||||||
|
@ -339,7 +311,7 @@ struct inflate_state FAR *state;
|
||||||
|
|
||||||
a.out > inffixed.h
|
a.out > inffixed.h
|
||||||
*/
|
*/
|
||||||
void makefixed()
|
void makefixed(void)
|
||||||
{
|
{
|
||||||
unsigned low, size;
|
unsigned low, size;
|
||||||
struct inflate_state state;
|
struct inflate_state state;
|
||||||
|
@ -393,11 +365,7 @@ void makefixed()
|
||||||
output will fall in the output data, making match copies simpler and faster.
|
output will fall in the output data, making match copies simpler and faster.
|
||||||
The advantage may be dependent on the size of the processor's data caches.
|
The advantage may be dependent on the size of the processor's data caches.
|
||||||
*/
|
*/
|
||||||
local int updatewindow(strm, end, copy)
|
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
|
||||||
z_streamp strm;
|
|
||||||
const Bytef *end;
|
|
||||||
unsigned copy;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned dist;
|
unsigned dist;
|
||||||
|
|
||||||
|
@ -447,10 +415,10 @@ unsigned copy;
|
||||||
|
|
||||||
/* check function to use adler32() for zlib or crc32() for gzip */
|
/* check function to use adler32() for zlib or crc32() for gzip */
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
# define UPDATE(check, buf, len) \
|
# define UPDATE_CHECK(check, buf, len) \
|
||||||
(state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
|
(state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
|
||||||
#else
|
#else
|
||||||
# define UPDATE(check, buf, len) adler32(check, buf, len)
|
# define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check macros for header crc */
|
/* check macros for header crc */
|
||||||
|
@ -619,10 +587,7 @@ unsigned copy;
|
||||||
will return Z_BUF_ERROR if it has not reached the end of the stream.
|
will return Z_BUF_ERROR if it has not reached the end of the stream.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int ZEXPORT inflate(strm, flush)
|
int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||||
z_streamp strm;
|
|
||||||
int flush;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
z_const unsigned char FAR *next; /* next input */
|
z_const unsigned char FAR *next; /* next input */
|
||||||
unsigned char FAR *put; /* next output */
|
unsigned char FAR *put; /* next output */
|
||||||
|
@ -670,7 +635,6 @@ int flush;
|
||||||
state->mode = FLAGS;
|
state->mode = FLAGS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->flags = 0; /* expect zlib header */
|
|
||||||
if (state->head != Z_NULL)
|
if (state->head != Z_NULL)
|
||||||
state->head->done = -1;
|
state->head->done = -1;
|
||||||
if (!(state->wrap & 1) || /* check if zlib header allowed */
|
if (!(state->wrap & 1) || /* check if zlib header allowed */
|
||||||
|
@ -697,6 +661,7 @@ int flush;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->dmax = 1U << len;
|
state->dmax = 1U << len;
|
||||||
|
state->flags = 0; /* indicate zlib header */
|
||||||
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;
|
||||||
|
@ -722,7 +687,7 @@ int flush;
|
||||||
CRC2(state->check, hold);
|
CRC2(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = TIME;
|
state->mode = TIME;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case TIME:
|
case TIME:
|
||||||
NEEDBITS(32);
|
NEEDBITS(32);
|
||||||
if (state->head != Z_NULL)
|
if (state->head != Z_NULL)
|
||||||
|
@ -731,7 +696,7 @@ int flush;
|
||||||
CRC4(state->check, hold);
|
CRC4(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = OS;
|
state->mode = OS;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case OS:
|
case OS:
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
if (state->head != Z_NULL) {
|
if (state->head != Z_NULL) {
|
||||||
|
@ -742,7 +707,7 @@ int flush;
|
||||||
CRC2(state->check, hold);
|
CRC2(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = EXLEN;
|
state->mode = EXLEN;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case EXLEN:
|
case EXLEN:
|
||||||
if (state->flags & 0x0400) {
|
if (state->flags & 0x0400) {
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
|
@ -756,15 +721,16 @@ int flush;
|
||||||
else if (state->head != Z_NULL)
|
else if (state->head != Z_NULL)
|
||||||
state->head->extra = Z_NULL;
|
state->head->extra = Z_NULL;
|
||||||
state->mode = EXTRA;
|
state->mode = EXTRA;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
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 &&
|
if (state->head != Z_NULL &&
|
||||||
state->head->extra != Z_NULL) {
|
state->head->extra != Z_NULL &&
|
||||||
len = state->head->extra_len - state->length;
|
(len = state->head->extra_len - state->length) <
|
||||||
|
state->head->extra_max) {
|
||||||
zmemcpy(state->head->extra + len, next,
|
zmemcpy(state->head->extra + len, next,
|
||||||
len + copy > state->head->extra_max ?
|
len + copy > state->head->extra_max ?
|
||||||
state->head->extra_max - len : copy);
|
state->head->extra_max - len : copy);
|
||||||
|
@ -779,7 +745,7 @@ int flush;
|
||||||
}
|
}
|
||||||
state->length = 0;
|
state->length = 0;
|
||||||
state->mode = NAME;
|
state->mode = NAME;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case NAME:
|
case NAME:
|
||||||
if (state->flags & 0x0800) {
|
if (state->flags & 0x0800) {
|
||||||
if (have == 0) goto inf_leave;
|
if (have == 0) goto inf_leave;
|
||||||
|
@ -801,7 +767,7 @@ int flush;
|
||||||
state->head->name = Z_NULL;
|
state->head->name = Z_NULL;
|
||||||
state->length = 0;
|
state->length = 0;
|
||||||
state->mode = COMMENT;
|
state->mode = COMMENT;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case COMMENT:
|
case COMMENT:
|
||||||
if (state->flags & 0x1000) {
|
if (state->flags & 0x1000) {
|
||||||
if (have == 0) goto inf_leave;
|
if (have == 0) goto inf_leave;
|
||||||
|
@ -822,7 +788,7 @@ int flush;
|
||||||
else if (state->head != Z_NULL)
|
else if (state->head != Z_NULL)
|
||||||
state->head->comment = Z_NULL;
|
state->head->comment = Z_NULL;
|
||||||
state->mode = HCRC;
|
state->mode = HCRC;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case HCRC:
|
case HCRC:
|
||||||
if (state->flags & 0x0200) {
|
if (state->flags & 0x0200) {
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
|
@ -846,7 +812,7 @@ int flush;
|
||||||
strm->adler = state->check = ZSWAP32(hold);
|
strm->adler = state->check = ZSWAP32(hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = DICT;
|
state->mode = DICT;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case DICT:
|
case DICT:
|
||||||
if (state->havedict == 0) {
|
if (state->havedict == 0) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -854,10 +820,10 @@ int flush;
|
||||||
}
|
}
|
||||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case TYPE:
|
case TYPE:
|
||||||
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case TYPEDO:
|
case TYPEDO:
|
||||||
if (state->last) {
|
if (state->last) {
|
||||||
BYTEBITS();
|
BYTEBITS();
|
||||||
|
@ -908,10 +874,10 @@ int flush;
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = COPY_;
|
state->mode = COPY_;
|
||||||
if (flush == Z_TREES) goto inf_leave;
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case COPY_:
|
case COPY_:
|
||||||
state->mode = COPY;
|
state->mode = COPY;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case COPY:
|
case COPY:
|
||||||
copy = state->length;
|
copy = state->length;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
|
@ -947,7 +913,7 @@ int flush;
|
||||||
Tracev((stderr, "inflate: table sizes ok\n"));
|
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = LENLENS;
|
state->mode = LENLENS;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case LENLENS:
|
case LENLENS:
|
||||||
while (state->have < state->ncode) {
|
while (state->have < state->ncode) {
|
||||||
NEEDBITS(3);
|
NEEDBITS(3);
|
||||||
|
@ -969,7 +935,7 @@ int flush;
|
||||||
Tracev((stderr, "inflate: code lengths ok\n"));
|
Tracev((stderr, "inflate: code lengths ok\n"));
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = CODELENS;
|
state->mode = CODELENS;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case CODELENS:
|
case CODELENS:
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -1053,10 +1019,10 @@ int flush;
|
||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
state->mode = LEN_;
|
state->mode = LEN_;
|
||||||
if (flush == Z_TREES) goto inf_leave;
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case LEN_:
|
case LEN_:
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case LEN:
|
case LEN:
|
||||||
if (have >= 6 && left >= 258) {
|
if (have >= 6 && left >= 258) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -1106,7 +1072,7 @@ int flush;
|
||||||
}
|
}
|
||||||
state->extra = (unsigned)(here.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = LENEXT;
|
state->mode = LENEXT;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case LENEXT:
|
case LENEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -1117,7 +1083,7 @@ int flush;
|
||||||
Tracevv((stderr, "inflate: length %u\n", state->length));
|
Tracevv((stderr, "inflate: length %u\n", state->length));
|
||||||
state->was = state->length;
|
state->was = state->length;
|
||||||
state->mode = DIST;
|
state->mode = DIST;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case DIST:
|
case DIST:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
here = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
|
@ -1145,7 +1111,7 @@ int flush;
|
||||||
state->offset = (unsigned)here.val;
|
state->offset = (unsigned)here.val;
|
||||||
state->extra = (unsigned)(here.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = DISTEXT;
|
state->mode = DISTEXT;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case DISTEXT:
|
case DISTEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -1162,7 +1128,7 @@ int flush;
|
||||||
#endif
|
#endif
|
||||||
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
||||||
state->mode = MATCH;
|
state->mode = MATCH;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case MATCH:
|
case MATCH:
|
||||||
if (left == 0) goto inf_leave;
|
if (left == 0) goto inf_leave;
|
||||||
copy = out - left;
|
copy = out - left;
|
||||||
|
@ -1222,7 +1188,7 @@ int flush;
|
||||||
state->total += out;
|
state->total += out;
|
||||||
if ((state->wrap & 4) && out)
|
if ((state->wrap & 4) && out)
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, put - out, out);
|
UPDATE_CHECK(state->check, put - out, out);
|
||||||
out = left;
|
out = left;
|
||||||
if ((state->wrap & 4) && (
|
if ((state->wrap & 4) && (
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
|
@ -1238,11 +1204,11 @@ int flush;
|
||||||
}
|
}
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
state->mode = LENGTH;
|
state->mode = LENGTH;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case LENGTH:
|
case LENGTH:
|
||||||
if (state->wrap && state->flags) {
|
if (state->wrap && state->flags) {
|
||||||
NEEDBITS(32);
|
NEEDBITS(32);
|
||||||
if (hold != (state->total & 0xffffffffUL)) {
|
if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
|
||||||
strm->msg = (char *)"incorrect length check";
|
strm->msg = (char *)"incorrect length check";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
|
@ -1252,7 +1218,7 @@ int flush;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
state->mode = DONE;
|
state->mode = DONE;
|
||||||
/* FALLTHROUGH */
|
/* fallthrough */
|
||||||
case DONE:
|
case DONE:
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
@ -1262,6 +1228,7 @@ int flush;
|
||||||
case MEM:
|
case MEM:
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
case SYNC:
|
case SYNC:
|
||||||
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1287,7 +1254,7 @@ int flush;
|
||||||
state->total += out;
|
state->total += out;
|
||||||
if ((state->wrap & 4) && out)
|
if ((state->wrap & 4) && out)
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, strm->next_out - out, out);
|
UPDATE_CHECK(state->check, strm->next_out - out, out);
|
||||||
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
||||||
(state->mode == TYPE ? 128 : 0) +
|
(state->mode == TYPE ? 128 : 0) +
|
||||||
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
||||||
|
@ -1296,9 +1263,7 @@ int flush;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateEnd(strm)
|
int ZEXPORT inflateEnd(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
if (inflateStateCheck(strm))
|
if (inflateStateCheck(strm))
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
|
@ -1310,11 +1275,8 @@ z_streamp strm;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
|
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
|
||||||
z_streamp strm;
|
uInt *dictLength) {
|
||||||
Bytef *dictionary;
|
|
||||||
uInt *dictLength;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
/* check state */
|
/* check state */
|
||||||
|
@ -1333,11 +1295,8 @@ uInt *dictLength;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
||||||
z_streamp strm;
|
uInt dictLength) {
|
||||||
const Bytef *dictionary;
|
|
||||||
uInt dictLength;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned long dictid;
|
unsigned long dictid;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1368,10 +1327,7 @@ uInt dictLength;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateGetHeader(strm, head)
|
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
|
||||||
z_streamp strm;
|
|
||||||
gz_headerp head;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
/* check state */
|
/* check state */
|
||||||
|
@ -1396,11 +1352,8 @@ gz_headerp head;
|
||||||
called again with more data and the *have state. *have is initialized to
|
called again with more data and the *have state. *have is initialized to
|
||||||
zero for the first call.
|
zero for the first call.
|
||||||
*/
|
*/
|
||||||
local unsigned syncsearch(have, buf, len)
|
local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
|
||||||
unsigned FAR *have;
|
unsigned len) {
|
||||||
const unsigned char FAR *buf;
|
|
||||||
unsigned len;
|
|
||||||
{
|
|
||||||
unsigned got;
|
unsigned got;
|
||||||
unsigned next;
|
unsigned next;
|
||||||
|
|
||||||
|
@ -1419,10 +1372,9 @@ unsigned len;
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateSync(strm)
|
int ZEXPORT inflateSync(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
unsigned len; /* number of bytes to look at or looked at */
|
unsigned len; /* number of bytes to look at or looked at */
|
||||||
|
int flags; /* temporary to save header status */
|
||||||
unsigned long in, out; /* temporary to save total_in and total_out */
|
unsigned long in, out; /* temporary to save total_in and total_out */
|
||||||
unsigned char buf[4]; /* to restore bit buffer to byte string */
|
unsigned char buf[4]; /* to restore bit buffer to byte string */
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
@ -1435,7 +1387,7 @@ z_streamp strm;
|
||||||
/* if first time, start search in bit buffer */
|
/* if first time, start search in bit buffer */
|
||||||
if (state->mode != SYNC) {
|
if (state->mode != SYNC) {
|
||||||
state->mode = SYNC;
|
state->mode = SYNC;
|
||||||
state->hold <<= state->bits & 7;
|
state->hold >>= state->bits & 7;
|
||||||
state->bits -= state->bits & 7;
|
state->bits -= state->bits & 7;
|
||||||
len = 0;
|
len = 0;
|
||||||
while (state->bits >= 8) {
|
while (state->bits >= 8) {
|
||||||
|
@ -1455,9 +1407,15 @@ z_streamp strm;
|
||||||
|
|
||||||
/* return no joy or set up to restart inflate() on a new block */
|
/* return no joy or set up to restart inflate() on a new block */
|
||||||
if (state->have != 4) return Z_DATA_ERROR;
|
if (state->have != 4) return Z_DATA_ERROR;
|
||||||
|
if (state->flags == -1)
|
||||||
|
state->wrap = 0; /* if no header yet, treat as raw */
|
||||||
|
else
|
||||||
|
state->wrap &= ~4; /* no point in computing a check value now */
|
||||||
|
flags = state->flags;
|
||||||
in = strm->total_in; out = strm->total_out;
|
in = strm->total_in; out = strm->total_out;
|
||||||
inflateReset(strm);
|
inflateReset(strm);
|
||||||
strm->total_in = in; strm->total_out = out;
|
strm->total_in = in; strm->total_out = out;
|
||||||
|
state->flags = flags;
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
@ -1470,9 +1428,7 @@ z_streamp strm;
|
||||||
block. When decompressing, PPP checks that at the end of input packet,
|
block. When decompressing, PPP checks that at the end of input packet,
|
||||||
inflate is waiting for these length bytes.
|
inflate is waiting for these length bytes.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT inflateSyncPoint(strm)
|
int ZEXPORT inflateSyncPoint(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
|
@ -1480,10 +1436,7 @@ z_streamp strm;
|
||||||
return state->mode == STORED && state->bits == 0;
|
return state->mode == STORED && state->bits == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateCopy(dest, source)
|
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
|
||||||
z_streamp dest;
|
|
||||||
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;
|
||||||
|
@ -1509,8 +1462,8 @@ z_streamp source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy state */
|
/* copy state */
|
||||||
zmemcpy((Bytef*)dest, (const Bytef*)source, sizeof(z_stream));
|
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
|
||||||
zmemcpy((Bytef*)copy, (const Bytef*)state, sizeof(struct inflate_state));
|
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
|
||||||
copy->strm = dest;
|
copy->strm = dest;
|
||||||
if (state->lencode >= state->codes &&
|
if (state->lencode >= state->codes &&
|
||||||
state->lencode <= state->codes + ENOUGH - 1) {
|
state->lencode <= state->codes + ENOUGH - 1) {
|
||||||
|
@ -1527,10 +1480,7 @@ z_streamp source;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateUndermine(strm, subvert)
|
int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
|
||||||
z_streamp strm;
|
|
||||||
int subvert;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
|
@ -1545,24 +1495,19 @@ int subvert;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateValidate(strm, check)
|
int ZEXPORT inflateValidate(z_streamp strm, int check) {
|
||||||
z_streamp strm;
|
|
||||||
int check;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
if (check)
|
if (check && state->wrap)
|
||||||
state->wrap |= 4;
|
state->wrap |= 4;
|
||||||
else
|
else
|
||||||
state->wrap &= ~4;
|
state->wrap &= ~4;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
long ZEXPORT inflateMark(strm)
|
long ZEXPORT inflateMark(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (inflateStateCheck(strm))
|
if (inflateStateCheck(strm))
|
||||||
|
@ -1573,9 +1518,7 @@ z_streamp strm;
|
||||||
(state->mode == MATCH ? state->was - state->length : 0));
|
(state->mode == MATCH ? state->was - state->length : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long ZEXPORT inflateCodesUsed(strm)
|
unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
if (inflateStateCheck(strm)) return (unsigned long)-1;
|
if (inflateStateCheck(strm)) return (unsigned long)-1;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
|
5
common/zlib/inflate.h
Executable file → Normal file
5
common/zlib/inflate.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.h -- internal inflate state definition
|
/* inflate.h -- internal inflate state definition
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2019 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ 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,
|
||||||
bit 2 true to validate check value */
|
bit 2 true to validate check value */
|
||||||
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, or
|
||||||
|
-1 if raw or no header yet */
|
||||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
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 */
|
||||||
|
|
17
common/zlib/inftrees.c
Executable file → Normal file
17
common/zlib/inftrees.c
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2017 Mark Adler
|
* Copyright (C) 1995-2024 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 @@
|
||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
|
" inflate 1.3.1 Copyright 1995-2024 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
|
||||||
|
@ -29,14 +29,9 @@ const char inflate_copyright[] =
|
||||||
table index bits. It will differ if the request is greater than the
|
table index bits. It will differ if the request is greater than the
|
||||||
longest code or if it is less than the shortest code.
|
longest code or if it is less than the shortest code.
|
||||||
*/
|
*/
|
||||||
int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
|
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||||
codetype type;
|
unsigned codes, code FAR * FAR *table,
|
||||||
unsigned short FAR *lens;
|
unsigned FAR *bits, unsigned short FAR *work) {
|
||||||
unsigned codes;
|
|
||||||
code FAR * FAR *table;
|
|
||||||
unsigned FAR *bits;
|
|
||||||
unsigned short FAR *work;
|
|
||||||
{
|
|
||||||
unsigned len; /* a code's length in bits */
|
unsigned len; /* a code's length in bits */
|
||||||
unsigned sym; /* index of code symbols */
|
unsigned sym; /* index of code symbols */
|
||||||
unsigned min, max; /* minimum and maximum code lengths */
|
unsigned min, max; /* minimum and maximum code lengths */
|
||||||
|
@ -62,7 +57,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, 77, 202};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
|
||||||
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,
|
||||||
|
|
10
common/zlib/inftrees.h
Executable file → Normal file
10
common/zlib/inftrees.h
Executable file → Normal file
|
@ -38,11 +38,11 @@ typedef struct {
|
||||||
/* Maximum size of the dynamic table. The maximum number of code structures is
|
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||||
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||||
codes. These values were found by exhaustive searches using the program
|
codes. These values were found by exhaustive searches using the program
|
||||||
examples/enough.c found in the zlib distribtution. The arguments to that
|
examples/enough.c found in the zlib distribution. The arguments to that
|
||||||
program are the number of symbols, the initial root table size, and the
|
program are the number of symbols, the initial root table size, and the
|
||||||
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||||
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
|
returns 852, and "enough 30 6 15" for distance codes returns 592. The
|
||||||
The initial root table size (9 or 6) is found in the fifth argument of the
|
initial root table size (9 or 6) is found in the fifth argument of the
|
||||||
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
||||||
changed, then these maximum sizes would be need to be recalculated and
|
changed, then these maximum sizes would be need to be recalculated and
|
||||||
updated. */
|
updated. */
|
||||||
|
@ -57,6 +57,6 @@ typedef enum {
|
||||||
DISTS
|
DISTS
|
||||||
} codetype;
|
} codetype;
|
||||||
|
|
||||||
int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
|
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||||
unsigned codes, code FAR * FAR *table,
|
unsigned codes, code FAR * FAR *table,
|
||||||
unsigned FAR *bits, unsigned short FAR *work));
|
unsigned FAR *bits, unsigned short FAR *work);
|
||||||
|
|
612
common/zlib/trees.c
Executable file → Normal file
612
common/zlib/trees.c
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* trees.c -- output deflated data using Huffman coding
|
/* trees.c -- output deflated data using Huffman coding
|
||||||
* Copyright (C) 1995-2017 Jean-loup Gailly
|
* Copyright (C) 1995-2024 Jean-loup Gailly
|
||||||
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
@ -122,39 +122,116 @@ struct static_tree_desc_s {
|
||||||
int max_length; /* max bit length for the codes */
|
int max_length; /* max bit length for the codes */
|
||||||
};
|
};
|
||||||
|
|
||||||
local const static_tree_desc static_l_desc =
|
#ifdef NO_INIT_GLOBAL_POINTERS
|
||||||
|
# define TCONST
|
||||||
|
#else
|
||||||
|
# define TCONST const
|
||||||
|
#endif
|
||||||
|
|
||||||
|
local TCONST static_tree_desc static_l_desc =
|
||||||
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
|
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
|
||||||
|
|
||||||
local const static_tree_desc static_d_desc =
|
local TCONST static_tree_desc static_d_desc =
|
||||||
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
|
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
|
||||||
|
|
||||||
local const static_tree_desc static_bl_desc =
|
local TCONST static_tree_desc static_bl_desc =
|
||||||
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
|
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Local (static) routines in this file.
|
* Output a short LSB first on the stream.
|
||||||
|
* IN assertion: there is enough room in pendingBuf.
|
||||||
*/
|
*/
|
||||||
|
#define put_short(s, w) { \
|
||||||
|
put_byte(s, (uch)((w) & 0xff)); \
|
||||||
|
put_byte(s, (uch)((ush)(w) >> 8)); \
|
||||||
|
}
|
||||||
|
|
||||||
local void tr_static_init OF((void));
|
/* ===========================================================================
|
||||||
local void init_block OF((deflate_state *s));
|
* Reverse the first len bits of a code, using straightforward code (a faster
|
||||||
local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
|
* method would use a table)
|
||||||
local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
|
* IN assertion: 1 <= len <= 15
|
||||||
local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
|
*/
|
||||||
local void build_tree OF((deflate_state *s, tree_desc *desc));
|
local unsigned bi_reverse(unsigned code, int len) {
|
||||||
local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
register unsigned res = 0;
|
||||||
local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
do {
|
||||||
local int build_bl_tree OF((deflate_state *s));
|
res |= code & 1;
|
||||||
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
code >>= 1, res <<= 1;
|
||||||
int blcodes));
|
} while (--len > 0);
|
||||||
local void compress_block OF((deflate_state *s, const ct_data *ltree,
|
return res >> 1;
|
||||||
const ct_data *dtree));
|
}
|
||||||
local int detect_data_type OF((deflate_state *s));
|
|
||||||
local unsigned bi_reverse OF((unsigned value, int length));
|
/* ===========================================================================
|
||||||
local void bi_windup OF((deflate_state *s));
|
* Flush the bit buffer, keeping at most 7 bits in it.
|
||||||
local void bi_flush OF((deflate_state *s));
|
*/
|
||||||
|
local void bi_flush(deflate_state *s) {
|
||||||
|
if (s->bi_valid == 16) {
|
||||||
|
put_short(s, s->bi_buf);
|
||||||
|
s->bi_buf = 0;
|
||||||
|
s->bi_valid = 0;
|
||||||
|
} else if (s->bi_valid >= 8) {
|
||||||
|
put_byte(s, (Byte)s->bi_buf);
|
||||||
|
s->bi_buf >>= 8;
|
||||||
|
s->bi_valid -= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Flush the bit buffer and align the output on a byte boundary
|
||||||
|
*/
|
||||||
|
local void bi_windup(deflate_state *s) {
|
||||||
|
if (s->bi_valid > 8) {
|
||||||
|
put_short(s, s->bi_buf);
|
||||||
|
} else if (s->bi_valid > 0) {
|
||||||
|
put_byte(s, (Byte)s->bi_buf);
|
||||||
|
}
|
||||||
|
s->bi_buf = 0;
|
||||||
|
s->bi_valid = 0;
|
||||||
|
#ifdef ZLIB_DEBUG
|
||||||
|
s->bits_sent = (s->bits_sent + 7) & ~7;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Generate the codes for a given tree and bit counts (which need not be
|
||||||
|
* optimal).
|
||||||
|
* IN assertion: the array bl_count contains the bit length statistics for
|
||||||
|
* the given tree and the field len is set for all tree elements.
|
||||||
|
* OUT assertion: the field code is set for all tree elements of non
|
||||||
|
* zero code length.
|
||||||
|
*/
|
||||||
|
local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) {
|
||||||
|
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
||||||
|
unsigned code = 0; /* running code value */
|
||||||
|
int bits; /* bit index */
|
||||||
|
int n; /* code index */
|
||||||
|
|
||||||
|
/* The distribution counts are first used to generate the code values
|
||||||
|
* without bit reversal.
|
||||||
|
*/
|
||||||
|
for (bits = 1; bits <= MAX_BITS; bits++) {
|
||||||
|
code = (code + bl_count[bits - 1]) << 1;
|
||||||
|
next_code[bits] = (ush)code;
|
||||||
|
}
|
||||||
|
/* Check that the bit counts in bl_count are consistent. The last code
|
||||||
|
* must be all ones.
|
||||||
|
*/
|
||||||
|
Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
|
||||||
|
"inconsistent bit counts");
|
||||||
|
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
||||||
|
|
||||||
|
for (n = 0; n <= max_code; n++) {
|
||||||
|
int len = tree[n].Len;
|
||||||
|
if (len == 0) continue;
|
||||||
|
/* Now reverse the bits */
|
||||||
|
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
||||||
|
|
||||||
|
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
||||||
|
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef GEN_TREES_H
|
#ifdef GEN_TREES_H
|
||||||
local void gen_trees_header OF((void));
|
local void gen_trees_header(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ZLIB_DEBUG
|
#ifndef ZLIB_DEBUG
|
||||||
|
@ -167,27 +244,12 @@ local void gen_trees_header OF((void));
|
||||||
send_bits(s, tree[c].Code, tree[c].Len); }
|
send_bits(s, tree[c].Code, tree[c].Len); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Output a short LSB first on the stream.
|
|
||||||
* IN assertion: there is enough room in pendingBuf.
|
|
||||||
*/
|
|
||||||
#define put_short(s, w) { \
|
|
||||||
put_byte(s, (uch)((w) & 0xff)); \
|
|
||||||
put_byte(s, (uch)((ush)(w) >> 8)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Send a value on a given number of bits.
|
* Send a value on a given number of bits.
|
||||||
* IN assertion: length <= 16 and value fits in length bits.
|
* IN assertion: length <= 16 and value fits in length bits.
|
||||||
*/
|
*/
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
local void send_bits OF((deflate_state *s, int value, int length));
|
local void send_bits(deflate_state *s, int value, int length) {
|
||||||
|
|
||||||
local void send_bits(s, value, length)
|
|
||||||
deflate_state *s;
|
|
||||||
int value; /* value to send */
|
|
||||||
int length; /* number of bits */
|
|
||||||
{
|
|
||||||
Tracevv((stderr," l %2d v %4x ", length, value));
|
Tracevv((stderr," l %2d v %4x ", length, value));
|
||||||
Assert(length > 0 && length <= 15, "invalid length");
|
Assert(length > 0 && length <= 15, "invalid length");
|
||||||
s->bits_sent += (ulg)length;
|
s->bits_sent += (ulg)length;
|
||||||
|
@ -229,8 +291,7 @@ local void send_bits(s, value, length)
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Initialize the various 'constant' tables.
|
* Initialize the various 'constant' tables.
|
||||||
*/
|
*/
|
||||||
local void tr_static_init()
|
local void tr_static_init(void) {
|
||||||
{
|
|
||||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||||
static int static_init_done = 0;
|
static int static_init_done = 0;
|
||||||
int n; /* iterates over tree elements */
|
int n; /* iterates over tree elements */
|
||||||
|
@ -312,7 +373,7 @@ local void tr_static_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Genererate the file trees.h describing the static trees.
|
* Generate the file trees.h describing the static trees.
|
||||||
*/
|
*/
|
||||||
#ifdef GEN_TREES_H
|
#ifdef GEN_TREES_H
|
||||||
# ifndef ZLIB_DEBUG
|
# ifndef ZLIB_DEBUG
|
||||||
|
@ -323,8 +384,7 @@ local void tr_static_init()
|
||||||
((i) == (last)? "\n};\n\n" : \
|
((i) == (last)? "\n};\n\n" : \
|
||||||
((i) % (width) == (width) - 1 ? ",\n" : ", "))
|
((i) % (width) == (width) - 1 ? ",\n" : ", "))
|
||||||
|
|
||||||
void gen_trees_header()
|
void gen_trees_header(void) {
|
||||||
{
|
|
||||||
FILE *header = fopen("trees.h", "w");
|
FILE *header = fopen("trees.h", "w");
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -373,12 +433,26 @@ void gen_trees_header()
|
||||||
}
|
}
|
||||||
#endif /* GEN_TREES_H */
|
#endif /* GEN_TREES_H */
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Initialize a new block.
|
||||||
|
*/
|
||||||
|
local void init_block(deflate_state *s) {
|
||||||
|
int n; /* iterates over tree elements */
|
||||||
|
|
||||||
|
/* Initialize the trees. */
|
||||||
|
for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
|
||||||
|
for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
|
||||||
|
for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
|
||||||
|
|
||||||
|
s->dyn_ltree[END_BLOCK].Freq = 1;
|
||||||
|
s->opt_len = s->static_len = 0L;
|
||||||
|
s->sym_next = s->matches = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Initialize the tree data structures for a new zlib stream.
|
* Initialize the tree data structures for a new zlib stream.
|
||||||
*/
|
*/
|
||||||
void ZLIB_INTERNAL _tr_init(s)
|
void ZLIB_INTERNAL _tr_init(deflate_state *s) {
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
tr_static_init();
|
tr_static_init();
|
||||||
|
|
||||||
s->l_desc.dyn_tree = s->dyn_ltree;
|
s->l_desc.dyn_tree = s->dyn_ltree;
|
||||||
|
@ -401,24 +475,6 @@ void ZLIB_INTERNAL _tr_init(s)
|
||||||
init_block(s);
|
init_block(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Initialize a new block.
|
|
||||||
*/
|
|
||||||
local void init_block(s)
|
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
int n; /* iterates over tree elements */
|
|
||||||
|
|
||||||
/* Initialize the trees. */
|
|
||||||
for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
|
|
||||||
for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
|
|
||||||
for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
|
|
||||||
|
|
||||||
s->dyn_ltree[END_BLOCK].Freq = 1;
|
|
||||||
s->opt_len = s->static_len = 0L;
|
|
||||||
s->last_lit = s->matches = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SMALLEST 1
|
#define SMALLEST 1
|
||||||
/* Index within the heap array of least frequent node in the Huffman tree */
|
/* Index within the heap array of least frequent node in the Huffman tree */
|
||||||
|
|
||||||
|
@ -448,11 +504,7 @@ local void init_block(s)
|
||||||
* when the heap property is re-established (each father smaller than its
|
* when the heap property is re-established (each father smaller than its
|
||||||
* two sons).
|
* two sons).
|
||||||
*/
|
*/
|
||||||
local void pqdownheap(s, tree, k)
|
local void pqdownheap(deflate_state *s, ct_data *tree, int k) {
|
||||||
deflate_state *s;
|
|
||||||
ct_data *tree; /* the tree to restore */
|
|
||||||
int k; /* node to move down */
|
|
||||||
{
|
|
||||||
int v = s->heap[k];
|
int v = s->heap[k];
|
||||||
int j = k << 1; /* left son of k */
|
int j = k << 1; /* left son of k */
|
||||||
while (j <= s->heap_len) {
|
while (j <= s->heap_len) {
|
||||||
|
@ -483,10 +535,7 @@ local void pqdownheap(s, tree, k)
|
||||||
* The length opt_len is updated; static_len is also updated if stree is
|
* The length opt_len is updated; static_len is also updated if stree is
|
||||||
* not null.
|
* not null.
|
||||||
*/
|
*/
|
||||||
local void gen_bitlen(s, desc)
|
local void gen_bitlen(deflate_state *s, tree_desc *desc) {
|
||||||
deflate_state *s;
|
|
||||||
tree_desc *desc; /* the tree descriptor */
|
|
||||||
{
|
|
||||||
ct_data *tree = desc->dyn_tree;
|
ct_data *tree = desc->dyn_tree;
|
||||||
int max_code = desc->max_code;
|
int max_code = desc->max_code;
|
||||||
const ct_data *stree = desc->stat_desc->static_tree;
|
const ct_data *stree = desc->stat_desc->static_tree;
|
||||||
|
@ -510,7 +559,7 @@ local void gen_bitlen(s, desc)
|
||||||
for (h = s->heap_max + 1; h < HEAP_SIZE; h++) {
|
for (h = s->heap_max + 1; h < HEAP_SIZE; h++) {
|
||||||
n = s->heap[h];
|
n = s->heap[h];
|
||||||
bits = tree[tree[n].Dad].Len + 1;
|
bits = tree[tree[n].Dad].Len + 1;
|
||||||
if (bits > max_length) {bits = max_length; overflow++;}
|
if (bits > max_length) bits = max_length, overflow++;
|
||||||
tree[n].Len = (ush)bits;
|
tree[n].Len = (ush)bits;
|
||||||
/* We overwrite tree[n].Dad which is no longer needed */
|
/* We overwrite tree[n].Dad which is no longer needed */
|
||||||
|
|
||||||
|
@ -561,48 +610,9 @@ local void gen_bitlen(s, desc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
#ifdef DUMP_BL_TREE
|
||||||
* Generate the codes for a given tree and bit counts (which need not be
|
# include <stdio.h>
|
||||||
* optimal).
|
#endif
|
||||||
* IN assertion: the array bl_count contains the bit length statistics for
|
|
||||||
* the given tree and the field len is set for all tree elements.
|
|
||||||
* OUT assertion: the field code is set for all tree elements of non
|
|
||||||
* zero code length.
|
|
||||||
*/
|
|
||||||
local void gen_codes (tree, max_code, bl_count)
|
|
||||||
ct_data *tree; /* the tree to decorate */
|
|
||||||
int max_code; /* largest code with non zero frequency */
|
|
||||||
ushf *bl_count; /* number of codes at each bit length */
|
|
||||||
{
|
|
||||||
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
|
||||||
unsigned code = 0; /* running code value */
|
|
||||||
int bits; /* bit index */
|
|
||||||
int n; /* code index */
|
|
||||||
|
|
||||||
/* The distribution counts are first used to generate the code values
|
|
||||||
* without bit reversal.
|
|
||||||
*/
|
|
||||||
for (bits = 1; bits <= MAX_BITS; bits++) {
|
|
||||||
code = (code + bl_count[bits-1]) << 1;
|
|
||||||
next_code[bits] = (ush)code;
|
|
||||||
}
|
|
||||||
/* Check that the bit counts in bl_count are consistent. The last code
|
|
||||||
* must be all ones.
|
|
||||||
*/
|
|
||||||
Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
|
|
||||||
"inconsistent bit counts");
|
|
||||||
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
|
||||||
|
|
||||||
for (n = 0; n <= max_code; n++) {
|
|
||||||
int len = tree[n].Len;
|
|
||||||
if (len == 0) continue;
|
|
||||||
/* Now reverse the bits */
|
|
||||||
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
|
||||||
|
|
||||||
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
|
||||||
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Construct one Huffman tree and assigns the code bit strings and lengths.
|
* Construct one Huffman tree and assigns the code bit strings and lengths.
|
||||||
|
@ -612,10 +622,7 @@ local void gen_codes (tree, max_code, bl_count)
|
||||||
* and corresponding code. The length opt_len is updated; static_len is
|
* and corresponding code. The length opt_len is updated; static_len is
|
||||||
* also updated if stree is not null. The field max_code is set.
|
* also updated if stree is not null. The field max_code is set.
|
||||||
*/
|
*/
|
||||||
local void build_tree(s, desc)
|
local void build_tree(deflate_state *s, tree_desc *desc) {
|
||||||
deflate_state *s;
|
|
||||||
tree_desc *desc; /* the tree descriptor */
|
|
||||||
{
|
|
||||||
ct_data *tree = desc->dyn_tree;
|
ct_data *tree = desc->dyn_tree;
|
||||||
const ct_data *stree = desc->stat_desc->static_tree;
|
const ct_data *stree = desc->stat_desc->static_tree;
|
||||||
int elems = desc->stat_desc->elems;
|
int elems = desc->stat_desc->elems;
|
||||||
|
@ -627,7 +634,7 @@ local void build_tree(s, desc)
|
||||||
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1].
|
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1].
|
||||||
* heap[0] is not used.
|
* heap[0] is not used.
|
||||||
*/
|
*/
|
||||||
s->heap_len = 0; s->heap_max = HEAP_SIZE;
|
s->heap_len = 0, s->heap_max = HEAP_SIZE;
|
||||||
|
|
||||||
for (n = 0; n < elems; n++) {
|
for (n = 0; n < elems; n++) {
|
||||||
if (tree[n].Freq != 0) {
|
if (tree[n].Freq != 0) {
|
||||||
|
@ -700,11 +707,7 @@ local void build_tree(s, desc)
|
||||||
* Scan a literal or distance tree to determine the frequencies of the codes
|
* Scan a literal or distance tree to determine the frequencies of the codes
|
||||||
* in the bit length tree.
|
* in the bit length tree.
|
||||||
*/
|
*/
|
||||||
local void scan_tree (s, tree, max_code)
|
local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
|
||||||
deflate_state *s;
|
|
||||||
ct_data *tree; /* the tree to be scanned */
|
|
||||||
int max_code; /* and its largest code of non zero frequency */
|
|
||||||
{
|
|
||||||
int n; /* iterates over all tree elements */
|
int n; /* iterates over all tree elements */
|
||||||
int prevlen = -1; /* last emitted length */
|
int prevlen = -1; /* last emitted length */
|
||||||
int curlen; /* length of current code */
|
int curlen; /* length of current code */
|
||||||
|
@ -713,7 +716,7 @@ local void scan_tree (s, tree, max_code)
|
||||||
int max_count = 7; /* max repeat count */
|
int max_count = 7; /* max repeat count */
|
||||||
int min_count = 4; /* min repeat count */
|
int min_count = 4; /* min repeat count */
|
||||||
|
|
||||||
if (nextlen == 0) {max_count = 138; min_count = 3;}
|
if (nextlen == 0) max_count = 138, min_count = 3;
|
||||||
tree[max_code + 1].Len = (ush)0xffff; /* guard */
|
tree[max_code + 1].Len = (ush)0xffff; /* guard */
|
||||||
|
|
||||||
for (n = 0; n <= max_code; n++) {
|
for (n = 0; n <= max_code; n++) {
|
||||||
|
@ -732,11 +735,11 @@ local void scan_tree (s, tree, max_code)
|
||||||
}
|
}
|
||||||
count = 0; prevlen = curlen;
|
count = 0; prevlen = curlen;
|
||||||
if (nextlen == 0) {
|
if (nextlen == 0) {
|
||||||
max_count = 138; min_count = 3;
|
max_count = 138, min_count = 3;
|
||||||
} else if (curlen == nextlen) {
|
} else if (curlen == nextlen) {
|
||||||
max_count = 6; min_count = 3;
|
max_count = 6, min_count = 3;
|
||||||
} else {
|
} else {
|
||||||
max_count = 7; min_count = 4;
|
max_count = 7, min_count = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -745,11 +748,7 @@ local void scan_tree (s, tree, max_code)
|
||||||
* Send a literal or distance tree in compressed form, using the codes in
|
* Send a literal or distance tree in compressed form, using the codes in
|
||||||
* bl_tree.
|
* bl_tree.
|
||||||
*/
|
*/
|
||||||
local void send_tree (s, tree, max_code)
|
local void send_tree(deflate_state *s, ct_data *tree, int max_code) {
|
||||||
deflate_state *s;
|
|
||||||
ct_data *tree; /* the tree to be scanned */
|
|
||||||
int max_code; /* and its largest code of non zero frequency */
|
|
||||||
{
|
|
||||||
int n; /* iterates over all tree elements */
|
int n; /* iterates over all tree elements */
|
||||||
int prevlen = -1; /* last emitted length */
|
int prevlen = -1; /* last emitted length */
|
||||||
int curlen; /* length of current code */
|
int curlen; /* length of current code */
|
||||||
|
@ -759,7 +758,7 @@ local void send_tree (s, tree, max_code)
|
||||||
int min_count = 4; /* min repeat count */
|
int min_count = 4; /* min repeat count */
|
||||||
|
|
||||||
/* tree[max_code + 1].Len = -1; */ /* guard already set */
|
/* tree[max_code + 1].Len = -1; */ /* guard already set */
|
||||||
if (nextlen == 0) {max_count = 138; min_count = 3;}
|
if (nextlen == 0) max_count = 138, min_count = 3;
|
||||||
|
|
||||||
for (n = 0; n <= max_code; n++) {
|
for (n = 0; n <= max_code; n++) {
|
||||||
curlen = nextlen; nextlen = tree[n + 1].Len;
|
curlen = nextlen; nextlen = tree[n + 1].Len;
|
||||||
|
@ -783,11 +782,11 @@ local void send_tree (s, tree, max_code)
|
||||||
}
|
}
|
||||||
count = 0; prevlen = curlen;
|
count = 0; prevlen = curlen;
|
||||||
if (nextlen == 0) {
|
if (nextlen == 0) {
|
||||||
max_count = 138; min_count = 3;
|
max_count = 138, min_count = 3;
|
||||||
} else if (curlen == nextlen) {
|
} else if (curlen == nextlen) {
|
||||||
max_count = 6; min_count = 3;
|
max_count = 6, min_count = 3;
|
||||||
} else {
|
} else {
|
||||||
max_count = 7; min_count = 4;
|
max_count = 7, min_count = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,9 +795,7 @@ local void send_tree (s, tree, max_code)
|
||||||
* Construct the Huffman tree for the bit lengths and return the index in
|
* Construct the Huffman tree for the bit lengths and return the index in
|
||||||
* bl_order of the last bit length code to send.
|
* bl_order of the last bit length code to send.
|
||||||
*/
|
*/
|
||||||
local int build_bl_tree(s)
|
local int build_bl_tree(deflate_state *s) {
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
int max_blindex; /* index of last bit length code of non zero freq */
|
int max_blindex; /* index of last bit length code of non zero freq */
|
||||||
|
|
||||||
/* Determine the bit length frequencies for literal and distance trees */
|
/* Determine the bit length frequencies for literal and distance trees */
|
||||||
|
@ -807,8 +804,8 @@ local int build_bl_tree(s)
|
||||||
|
|
||||||
/* Build the bit length tree: */
|
/* Build the bit length tree: */
|
||||||
build_tree(s, (tree_desc *)(&(s->bl_desc)));
|
build_tree(s, (tree_desc *)(&(s->bl_desc)));
|
||||||
/* opt_len now includes the length of the tree representations, except
|
/* opt_len now includes the length of the tree representations, except the
|
||||||
* the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
|
* lengths of the bit lengths codes and the 5 + 5 + 4 bits for the counts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Determine the number of bit length codes to send. The pkzip format
|
/* Determine the number of bit length codes to send. The pkzip format
|
||||||
|
@ -831,10 +828,8 @@ local int build_bl_tree(s)
|
||||||
* lengths of the bit length codes, the literal tree and the distance tree.
|
* lengths of the bit length codes, the literal tree and the distance tree.
|
||||||
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
|
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
|
||||||
*/
|
*/
|
||||||
local void send_all_trees(s, lcodes, dcodes, blcodes)
|
local void send_all_trees(deflate_state *s, int lcodes, int dcodes,
|
||||||
deflate_state *s;
|
int blcodes) {
|
||||||
int lcodes, dcodes, blcodes; /* number of codes for each tree */
|
|
||||||
{
|
|
||||||
int rank; /* index in bl_order */
|
int rank; /* index in bl_order */
|
||||||
|
|
||||||
Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
|
Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
|
||||||
|
@ -860,16 +855,13 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Send a stored block
|
* Send a stored block
|
||||||
*/
|
*/
|
||||||
void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
|
||||||
deflate_state *s;
|
ulg stored_len, int last) {
|
||||||
charf *buf; /* input block */
|
|
||||||
ulg stored_len; /* length of input block */
|
|
||||||
int last; /* one if this is the last block for a file */
|
|
||||||
{
|
|
||||||
send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */
|
send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */
|
||||||
bi_windup(s); /* align on byte boundary */
|
bi_windup(s); /* align on byte boundary */
|
||||||
put_short(s, (ush)stored_len);
|
put_short(s, (ush)stored_len);
|
||||||
put_short(s, (ush)~stored_len);
|
put_short(s, (ush)~stored_len);
|
||||||
|
if (stored_len)
|
||||||
zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
|
zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
|
||||||
s->pending += stored_len;
|
s->pending += stored_len;
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
|
@ -883,9 +875,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
|
* Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
|
||||||
*/
|
*/
|
||||||
void ZLIB_INTERNAL _tr_flush_bits(s)
|
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) {
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
bi_flush(s);
|
bi_flush(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,9 +883,7 @@ void ZLIB_INTERNAL _tr_flush_bits(s)
|
||||||
* Send one empty static block to give enough lookahead for inflate.
|
* Send one empty static block to give enough lookahead for inflate.
|
||||||
* This takes 10 bits, of which 7 may remain in the bit buffer.
|
* This takes 10 bits, of which 7 may remain in the bit buffer.
|
||||||
*/
|
*/
|
||||||
void ZLIB_INTERNAL _tr_align(s)
|
void ZLIB_INTERNAL _tr_align(deflate_state *s) {
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
send_bits(s, STATIC_TREES<<1, 3);
|
send_bits(s, STATIC_TREES<<1, 3);
|
||||||
send_code(s, END_BLOCK, static_ltree);
|
send_code(s, END_BLOCK, static_ltree);
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
|
@ -904,16 +892,108 @@ void ZLIB_INTERNAL _tr_align(s)
|
||||||
bi_flush(s);
|
bi_flush(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Send the block data compressed using the given Huffman trees
|
||||||
|
*/
|
||||||
|
local void compress_block(deflate_state *s, const ct_data *ltree,
|
||||||
|
const ct_data *dtree) {
|
||||||
|
unsigned dist; /* distance of matched string */
|
||||||
|
int lc; /* match length or unmatched char (if dist == 0) */
|
||||||
|
unsigned sx = 0; /* running index in symbol buffers */
|
||||||
|
unsigned code; /* the code to send */
|
||||||
|
int extra; /* number of extra bits to send */
|
||||||
|
|
||||||
|
if (s->sym_next != 0) do {
|
||||||
|
#ifdef LIT_MEM
|
||||||
|
dist = s->d_buf[sx];
|
||||||
|
lc = s->l_buf[sx++];
|
||||||
|
#else
|
||||||
|
dist = s->sym_buf[sx++] & 0xff;
|
||||||
|
dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
|
||||||
|
lc = s->sym_buf[sx++];
|
||||||
|
#endif
|
||||||
|
if (dist == 0) {
|
||||||
|
send_code(s, lc, ltree); /* send a literal byte */
|
||||||
|
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
||||||
|
} else {
|
||||||
|
/* Here, lc is the match length - MIN_MATCH */
|
||||||
|
code = _length_code[lc];
|
||||||
|
send_code(s, code + LITERALS + 1, ltree); /* send length code */
|
||||||
|
extra = extra_lbits[code];
|
||||||
|
if (extra != 0) {
|
||||||
|
lc -= base_length[code];
|
||||||
|
send_bits(s, lc, extra); /* send the extra length bits */
|
||||||
|
}
|
||||||
|
dist--; /* dist is now the match distance - 1 */
|
||||||
|
code = d_code(dist);
|
||||||
|
Assert (code < D_CODES, "bad d_code");
|
||||||
|
|
||||||
|
send_code(s, code, dtree); /* send the distance code */
|
||||||
|
extra = extra_dbits[code];
|
||||||
|
if (extra != 0) {
|
||||||
|
dist -= (unsigned)base_dist[code];
|
||||||
|
send_bits(s, dist, extra); /* send the extra distance bits */
|
||||||
|
}
|
||||||
|
} /* literal or match pair ? */
|
||||||
|
|
||||||
|
/* Check for no overlay of pending_buf on needed symbols */
|
||||||
|
#ifdef LIT_MEM
|
||||||
|
Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
|
||||||
|
#else
|
||||||
|
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} while (sx < s->sym_next);
|
||||||
|
|
||||||
|
send_code(s, END_BLOCK, ltree);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
||||||
|
* - TEXT if the two conditions below are satisfied:
|
||||||
|
* a) There are no non-portable control characters belonging to the
|
||||||
|
* "block list" (0..6, 14..25, 28..31).
|
||||||
|
* b) There is at least one printable character belonging to the
|
||||||
|
* "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||||
|
* - BINARY otherwise.
|
||||||
|
* - The following partially-portable control characters form a
|
||||||
|
* "gray list" that is ignored in this detection algorithm:
|
||||||
|
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
|
||||||
|
* IN assertion: the fields Freq of dyn_ltree are set.
|
||||||
|
*/
|
||||||
|
local int detect_data_type(deflate_state *s) {
|
||||||
|
/* block_mask is the bit mask of block-listed bytes
|
||||||
|
* set bits 0..6, 14..25, and 28..31
|
||||||
|
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
||||||
|
*/
|
||||||
|
unsigned long block_mask = 0xf3ffc07fUL;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* Check for non-textual ("block-listed") bytes. */
|
||||||
|
for (n = 0; n <= 31; n++, block_mask >>= 1)
|
||||||
|
if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
||||||
|
return Z_BINARY;
|
||||||
|
|
||||||
|
/* Check for textual ("allow-listed") bytes. */
|
||||||
|
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
||||||
|
|| s->dyn_ltree[13].Freq != 0)
|
||||||
|
return Z_TEXT;
|
||||||
|
for (n = 32; n < LITERALS; n++)
|
||||||
|
if (s->dyn_ltree[n].Freq != 0)
|
||||||
|
return Z_TEXT;
|
||||||
|
|
||||||
|
/* There are no "block-listed" or "allow-listed" bytes:
|
||||||
|
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
||||||
|
*/
|
||||||
|
return Z_BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Determine the best encoding for the current block: dynamic trees, static
|
* Determine the best encoding for the current block: dynamic trees, static
|
||||||
* trees or store, and write out the encoded block.
|
* trees or store, and write out the encoded block.
|
||||||
*/
|
*/
|
||||||
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
|
||||||
deflate_state *s;
|
ulg stored_len, int last) {
|
||||||
charf *buf; /* input block, or NULL if too old */
|
|
||||||
ulg stored_len; /* length of input block */
|
|
||||||
int last; /* one if this is the last block for a file */
|
|
||||||
{
|
|
||||||
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
||||||
int max_blindex = 0; /* index of last bit length code of non zero freq */
|
int max_blindex = 0; /* index of last bit length code of non zero freq */
|
||||||
|
|
||||||
|
@ -947,9 +1027,12 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
|
|
||||||
Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
|
Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
|
||||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
||||||
s->last_lit));
|
s->sym_next / 3));
|
||||||
|
|
||||||
if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
|
#ifndef FORCE_STATIC
|
||||||
|
if (static_lenb <= opt_lenb || s->strategy == Z_FIXED)
|
||||||
|
#endif
|
||||||
|
opt_lenb = static_lenb;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Assert(buf != (char*)0, "lost buf");
|
Assert(buf != (char*)0, "lost buf");
|
||||||
|
@ -970,11 +1053,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
*/
|
*/
|
||||||
_tr_stored_block(s, buf, stored_len, last);
|
_tr_stored_block(s, buf, stored_len, last);
|
||||||
|
|
||||||
#ifdef FORCE_STATIC
|
} else if (static_lenb == opt_lenb) {
|
||||||
} else if (static_lenb >= 0) { /* force static trees */
|
|
||||||
#else
|
|
||||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
|
||||||
#endif
|
|
||||||
send_bits(s, (STATIC_TREES<<1) + last, 3);
|
send_bits(s, (STATIC_TREES<<1) + last, 3);
|
||||||
compress_block(s, (const ct_data *)static_ltree,
|
compress_block(s, (const ct_data *)static_ltree,
|
||||||
(const ct_data *)static_dtree);
|
(const ct_data *)static_dtree);
|
||||||
|
@ -1011,13 +1090,15 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
* Save the match info and tally the frequency counts. Return true if
|
* Save the match info and tally the frequency counts. Return true if
|
||||||
* the current block must be flushed.
|
* the current block must be flushed.
|
||||||
*/
|
*/
|
||||||
int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
|
||||||
deflate_state *s;
|
#ifdef LIT_MEM
|
||||||
unsigned dist; /* distance of matched string */
|
s->d_buf[s->sym_next] = (ush)dist;
|
||||||
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
s->l_buf[s->sym_next++] = (uch)lc;
|
||||||
{
|
#else
|
||||||
s->d_buf[s->last_lit] = (ush)dist;
|
s->sym_buf[s->sym_next++] = (uch)dist;
|
||||||
s->l_buf[s->last_lit++] = (uch)lc;
|
s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
|
||||||
|
s->sym_buf[s->sym_next++] = (uch)lc;
|
||||||
|
#endif
|
||||||
if (dist == 0) {
|
if (dist == 0) {
|
||||||
/* lc is the unmatched char */
|
/* lc is the unmatched char */
|
||||||
s->dyn_ltree[lc].Freq++;
|
s->dyn_ltree[lc].Freq++;
|
||||||
|
@ -1032,172 +1113,5 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||||
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++;
|
s->dyn_dtree[d_code(dist)].Freq++;
|
||||||
}
|
}
|
||||||
|
return (s->sym_next == s->sym_end);
|
||||||
#ifdef TRUNCATE_BLOCK
|
|
||||||
/* Try to guess if it is profitable to stop the current block here */
|
|
||||||
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
|
|
||||||
/* Compute an upper bound for the compressed length */
|
|
||||||
ulg out_length = (ulg)s->last_lit*8L;
|
|
||||||
ulg in_length = (ulg)((long)s->strstart - s->block_start);
|
|
||||||
int dcode;
|
|
||||||
for (dcode = 0; dcode < D_CODES; dcode++) {
|
|
||||||
out_length += (ulg)s->dyn_dtree[dcode].Freq *
|
|
||||||
(5L+extra_dbits[dcode]);
|
|
||||||
}
|
|
||||||
out_length >>= 3;
|
|
||||||
Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
|
|
||||||
s->last_lit, in_length, out_length,
|
|
||||||
100L - out_length*100L/in_length));
|
|
||||||
if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return (s->last_lit == s->lit_bufsize-1);
|
|
||||||
/* We avoid equality with lit_bufsize because of wraparound at 64K
|
|
||||||
* on 16 bit machines and because stored blocks are restricted to
|
|
||||||
* 64K-1 bytes.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Send the block data compressed using the given Huffman trees
|
|
||||||
*/
|
|
||||||
local void compress_block(s, ltree, dtree)
|
|
||||||
deflate_state *s;
|
|
||||||
const ct_data *ltree; /* literal tree */
|
|
||||||
const ct_data *dtree; /* distance tree */
|
|
||||||
{
|
|
||||||
unsigned dist; /* distance of matched string */
|
|
||||||
int lc; /* match length or unmatched char (if dist == 0) */
|
|
||||||
unsigned lx = 0; /* running index in l_buf */
|
|
||||||
unsigned code; /* the code to send */
|
|
||||||
int extra; /* number of extra bits to send */
|
|
||||||
|
|
||||||
if (s->last_lit != 0) do {
|
|
||||||
dist = s->d_buf[lx];
|
|
||||||
lc = s->l_buf[lx++];
|
|
||||||
if (dist == 0) {
|
|
||||||
send_code(s, lc, ltree); /* send a literal byte */
|
|
||||||
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
|
||||||
} else {
|
|
||||||
/* Here, lc is the match length - MIN_MATCH */
|
|
||||||
code = _length_code[lc];
|
|
||||||
send_code(s, code+LITERALS+1, ltree); /* send the length code */
|
|
||||||
extra = extra_lbits[code];
|
|
||||||
if (extra != 0) {
|
|
||||||
lc -= base_length[code];
|
|
||||||
send_bits(s, lc, extra); /* send the extra length bits */
|
|
||||||
}
|
|
||||||
dist--; /* dist is now the match distance - 1 */
|
|
||||||
code = d_code(dist);
|
|
||||||
Assert (code < D_CODES, "bad d_code");
|
|
||||||
|
|
||||||
send_code(s, code, dtree); /* send the distance code */
|
|
||||||
extra = extra_dbits[code];
|
|
||||||
if (extra != 0) {
|
|
||||||
dist -= (unsigned)base_dist[code];
|
|
||||||
send_bits(s, dist, extra); /* send the extra distance bits */
|
|
||||||
}
|
|
||||||
} /* literal or match pair ? */
|
|
||||||
|
|
||||||
/* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
|
|
||||||
Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
|
|
||||||
"pendingBuf overflow");
|
|
||||||
|
|
||||||
} while (lx < s->last_lit);
|
|
||||||
|
|
||||||
send_code(s, END_BLOCK, ltree);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
|
||||||
* - TEXT if the two conditions below are satisfied:
|
|
||||||
* a) There are no non-portable control characters belonging to the
|
|
||||||
* "black list" (0..6, 14..25, 28..31).
|
|
||||||
* b) There is at least one printable character belonging to the
|
|
||||||
* "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
|
||||||
* - BINARY otherwise.
|
|
||||||
* - The following partially-portable control characters form a
|
|
||||||
* "gray list" that is ignored in this detection algorithm:
|
|
||||||
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
|
|
||||||
* IN assertion: the fields Freq of dyn_ltree are set.
|
|
||||||
*/
|
|
||||||
local int detect_data_type(s)
|
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
/* black_mask is the bit mask of black-listed bytes
|
|
||||||
* set bits 0..6, 14..25, and 28..31
|
|
||||||
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
|
||||||
*/
|
|
||||||
unsigned long black_mask = 0xf3ffc07fUL;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
/* Check for non-textual ("black-listed") bytes. */
|
|
||||||
for (n = 0; n <= 31; n++, black_mask >>= 1)
|
|
||||||
if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
|
||||||
return Z_BINARY;
|
|
||||||
|
|
||||||
/* Check for textual ("white-listed") bytes. */
|
|
||||||
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
|
||||||
|| s->dyn_ltree[13].Freq != 0)
|
|
||||||
return Z_TEXT;
|
|
||||||
for (n = 32; n < LITERALS; n++)
|
|
||||||
if (s->dyn_ltree[n].Freq != 0)
|
|
||||||
return Z_TEXT;
|
|
||||||
|
|
||||||
/* There are no "black-listed" or "white-listed" bytes:
|
|
||||||
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
|
||||||
*/
|
|
||||||
return Z_BINARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Reverse the first len bits of a code, using straightforward code (a faster
|
|
||||||
* method would use a table)
|
|
||||||
* IN assertion: 1 <= len <= 15
|
|
||||||
*/
|
|
||||||
local unsigned bi_reverse(code, len)
|
|
||||||
unsigned code; /* the value to invert */
|
|
||||||
int len; /* its bit length */
|
|
||||||
{
|
|
||||||
register unsigned res = 0;
|
|
||||||
do {
|
|
||||||
res |= code & 1;
|
|
||||||
code >>= 1; res <<= 1;
|
|
||||||
} while (--len > 0);
|
|
||||||
return res >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Flush the bit buffer, keeping at most 7 bits in it.
|
|
||||||
*/
|
|
||||||
local void bi_flush(s)
|
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
if (s->bi_valid == 16) {
|
|
||||||
put_short(s, s->bi_buf);
|
|
||||||
s->bi_buf = 0;
|
|
||||||
s->bi_valid = 0;
|
|
||||||
} else if (s->bi_valid >= 8) {
|
|
||||||
put_byte(s, (Byte)s->bi_buf);
|
|
||||||
s->bi_buf >>= 8;
|
|
||||||
s->bi_valid -= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Flush the bit buffer and align the output on a byte boundary
|
|
||||||
*/
|
|
||||||
local void bi_windup(s)
|
|
||||||
deflate_state *s;
|
|
||||||
{
|
|
||||||
if (s->bi_valid > 8) {
|
|
||||||
put_short(s, s->bi_buf);
|
|
||||||
} else if (s->bi_valid > 0) {
|
|
||||||
put_byte(s, (Byte)s->bi_buf);
|
|
||||||
}
|
|
||||||
s->bi_buf = 0;
|
|
||||||
s->bi_valid = 0;
|
|
||||||
#ifdef ZLIB_DEBUG
|
|
||||||
s->bits_sent = (s->bits_sent+7) & ~7;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
0
common/zlib/trees.h
Executable file → Normal file
0
common/zlib/trees.h
Executable file → Normal file
16
common/zlib/uncompr.c
Executable file → Normal file
16
common/zlib/uncompr.c
Executable file → Normal file
|
@ -24,12 +24,8 @@
|
||||||
Z_DATA_ERROR if the input data was corrupted, including if the input data is
|
Z_DATA_ERROR if the input data was corrupted, including if the input data is
|
||||||
an incomplete zlib stream.
|
an incomplete zlib stream.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
|
int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||||
Bytef *dest;
|
uLong *sourceLen) {
|
||||||
uLongf *destLen;
|
|
||||||
const Bytef *source;
|
|
||||||
uLong *sourceLen;
|
|
||||||
{
|
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int err;
|
int err;
|
||||||
const uInt max = (uInt)-1;
|
const uInt max = (uInt)-1;
|
||||||
|
@ -83,11 +79,7 @@ int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
|
||||||
err;
|
err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||||
Bytef *dest;
|
uLong sourceLen) {
|
||||||
uLongf *destLen;
|
|
||||||
const Bytef *source;
|
|
||||||
uLong sourceLen;
|
|
||||||
{
|
|
||||||
return uncompress2(dest, destLen, source, &sourceLen);
|
return uncompress2(dest, destLen, source, &sourceLen);
|
||||||
}
|
}
|
||||||
|
|
33
common/zlib/zconf.h
Executable file → Normal file
33
common/zlib/zconf.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* zconf.h -- configuration of the zlib compression library
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
* Copyright (C) 1995-2024 Jean-loup Gailly, 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@
|
||||||
# define crc32 z_crc32
|
# define crc32 z_crc32
|
||||||
# define crc32_combine z_crc32_combine
|
# define crc32_combine z_crc32_combine
|
||||||
# define crc32_combine64 z_crc32_combine64
|
# define crc32_combine64 z_crc32_combine64
|
||||||
|
# define crc32_combine_gen z_crc32_combine_gen
|
||||||
|
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||||
|
# define crc32_combine_op z_crc32_combine_op
|
||||||
# define crc32_z z_crc32_z
|
# define crc32_z z_crc32_z
|
||||||
# define deflate z_deflate
|
# define deflate z_deflate
|
||||||
# define deflateBound z_deflateBound
|
# define deflateBound z_deflateBound
|
||||||
|
@ -238,7 +241,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Z_SOLO
|
#ifdef Z_SOLO
|
||||||
|
# ifdef _WIN64
|
||||||
|
typedef unsigned long long z_size_t;
|
||||||
|
# else
|
||||||
typedef unsigned long z_size_t;
|
typedef unsigned long z_size_t;
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
# define z_longlong long long
|
# define z_longlong long long
|
||||||
# if defined(NO_SIZE_T)
|
# if defined(NO_SIZE_T)
|
||||||
|
@ -293,14 +300,6 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Z_ARG /* function prototypes for stdarg */
|
|
||||||
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
|
||||||
# define Z_ARG(args) args
|
|
||||||
# else
|
|
||||||
# define Z_ARG(args) ()
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||||
* model programming (small or medium model with some far allocations).
|
* model programming (small or medium model with some far allocations).
|
||||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||||
|
@ -349,6 +348,9 @@
|
||||||
# ifdef FAR
|
# ifdef FAR
|
||||||
# undef FAR
|
# undef FAR
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
/* No need for _export, use ZLIB.DEF instead. */
|
/* No need for _export, use ZLIB.DEF instead. */
|
||||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||||
|
@ -467,11 +469,18 @@ typedef uLong FAR uLongf;
|
||||||
# undef _LARGEFILE64_SOURCE
|
# undef _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
|
# ifdef __WATCOMC__
|
||||||
# define Z_HAVE_UNISTD_H
|
# define Z_HAVE_UNISTD_H
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
|
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
#ifndef Z_SOLO
|
#ifndef Z_SOLO
|
||||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
# if defined(Z_HAVE_UNISTD_H)
|
||||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||||
# ifdef VMS
|
# ifdef VMS
|
||||||
# include <unixio.h> /* for off_t */
|
# include <unixio.h> /* for off_t */
|
||||||
|
@ -507,7 +516,7 @@ typedef uLong FAR uLongf;
|
||||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||||
# define z_off64_t off64_t
|
# define z_off64_t off64_t
|
||||||
#else
|
#else
|
||||||
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
# if defined(_WIN32) && !defined(__GNUC__)
|
||||||
# define z_off64_t __int64
|
# define z_off64_t __int64
|
||||||
# else
|
# else
|
||||||
# define z_off64_t z_off_t
|
# define z_off64_t z_off_t
|
||||||
|
|
550
common/zlib/zlib.h
Executable file → Normal file
550
common/zlib/zlib.h
Executable file → Normal file
File diff suppressed because it is too large
Load diff
66
common/zlib/zutil.c
Executable file → Normal file
66
common/zlib/zutil.c
Executable file → Normal file
|
@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const char * ZEXPORT zlibVersion()
|
const char * ZEXPORT zlibVersion(void) {
|
||||||
{
|
|
||||||
return ZLIB_VERSION;
|
return ZLIB_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
uLong ZEXPORT zlibCompileFlags()
|
uLong ZEXPORT zlibCompileFlags(void) {
|
||||||
{
|
|
||||||
uLong flags;
|
uLong flags;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
@ -61,9 +59,11 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
flags += 1 << 8;
|
flags += 1 << 8;
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
#if defined(ASMV) || defined(ASMINF)
|
#if defined(ASMV) || defined(ASMINF)
|
||||||
flags += 1 << 9;
|
flags += 1 << 9;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
#ifdef ZLIB_WINAPI
|
#ifdef ZLIB_WINAPI
|
||||||
flags += 1 << 10;
|
flags += 1 << 10;
|
||||||
#endif
|
#endif
|
||||||
|
@ -119,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
# endif
|
# endif
|
||||||
int ZLIB_INTERNAL z_verbose = verbose;
|
int ZLIB_INTERNAL z_verbose = verbose;
|
||||||
|
|
||||||
void ZLIB_INTERNAL z_error (m)
|
void ZLIB_INTERNAL z_error(char *m) {
|
||||||
char *m;
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s\n", m);
|
fprintf(stderr, "%s\n", m);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -130,14 +128,12 @@ void ZLIB_INTERNAL z_error (m)
|
||||||
/* exported to allow conversion of error code to string for compress() and
|
/* exported to allow conversion of error code to string for compress() and
|
||||||
* uncompress()
|
* uncompress()
|
||||||
*/
|
*/
|
||||||
const char * ZEXPORT zError(err)
|
const char * ZEXPORT zError(int err) {
|
||||||
int err;
|
|
||||||
{
|
|
||||||
return ERR_MSG(err);
|
return ERR_MSG(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
|
||||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
/* The older Microsoft C Run-Time Library for Windows CE doesn't have
|
||||||
* errno. We define it as a global variable to simplify porting.
|
* errno. We define it as a global variable to simplify porting.
|
||||||
* Its value is always 0 and should not be used.
|
* Its value is always 0 and should not be used.
|
||||||
*/
|
*/
|
||||||
|
@ -146,22 +142,14 @@ const char * ZEXPORT zError(err)
|
||||||
|
|
||||||
#ifndef HAVE_MEMCPY
|
#ifndef HAVE_MEMCPY
|
||||||
|
|
||||||
void ZLIB_INTERNAL zmemcpy(dest, source, len)
|
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) {
|
||||||
Bytef* dest;
|
|
||||||
const Bytef* source;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
if (len == 0) return;
|
if (len == 0) return;
|
||||||
do {
|
do {
|
||||||
*dest++ = *source++; /* ??? to be unrolled */
|
*dest++ = *source++; /* ??? to be unrolled */
|
||||||
} while (--len != 0);
|
} while (--len != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZLIB_INTERNAL zmemcmp(s1, s2, len)
|
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
|
||||||
const Bytef* s1;
|
|
||||||
const Bytef* s2;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
uInt j;
|
uInt j;
|
||||||
|
|
||||||
for (j = 0; j < len; j++) {
|
for (j = 0; j < len; j++) {
|
||||||
|
@ -170,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zmemzero(dest, len)
|
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
|
||||||
Bytef* dest;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
if (len == 0) return;
|
if (len == 0) return;
|
||||||
do {
|
do {
|
||||||
*dest++ = 0; /* ??? to be unrolled */
|
*dest++ = 0; /* ??? to be unrolled */
|
||||||
|
@ -214,8 +199,7 @@ local ptr_table table[MAX_PTR];
|
||||||
* a protected system like OS/2. Use Microsoft C instead.
|
* a protected system like OS/2. Use Microsoft C instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||||
{
|
|
||||||
voidpf buf;
|
voidpf buf;
|
||||||
ulg bsize = (ulg)items*size;
|
ulg bsize = (ulg)items*size;
|
||||||
|
|
||||||
|
@ -240,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
|
@ -277,14 +260,12 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||||
# define _hfree hfree
|
# define _hfree hfree
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
|
||||||
{
|
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
return _halloc((long)items, size);
|
return _halloc((long)items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||||
{
|
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
_hfree(ptr);
|
_hfree(ptr);
|
||||||
}
|
}
|
||||||
|
@ -297,25 +278,18 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||||
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
||||||
|
|
||||||
#ifndef STDC
|
#ifndef STDC
|
||||||
extern voidp malloc OF((uInt size));
|
extern voidp malloc(uInt size);
|
||||||
extern voidp calloc OF((uInt items, uInt size));
|
extern voidp calloc(uInt items, uInt size);
|
||||||
extern void free OF((voidpf ptr));
|
extern void free(voidpf ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||||
voidpf opaque;
|
|
||||||
unsigned items;
|
|
||||||
unsigned size;
|
|
||||||
{
|
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
||||||
(voidpf)calloc(items, size);
|
(voidpf)calloc(items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (opaque, ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||||
voidpf opaque;
|
|
||||||
voidpf ptr;
|
|
||||||
{
|
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
65
common/zlib/zutil.h
Executable file → Normal file
65
common/zlib/zutil.h
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
* Copyright (C) 1995-2024 Jean-loup Gailly, 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -29,10 +29,6 @@
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Z_SOLO
|
|
||||||
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
# define local static
|
# define local static
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,10 +42,21 @@ typedef unsigned short ush;
|
||||||
typedef ush FAR ushf;
|
typedef ush FAR ushf;
|
||||||
typedef unsigned long ulg;
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
|
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
|
||||||
|
# include <limits.h>
|
||||||
|
# if (ULONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long
|
||||||
|
# elif (ULLONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long long
|
||||||
|
# elif (UINT_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
/* (size given to avoid silly warnings with Visual C++) */
|
/* (size given to avoid silly warnings with Visual C++) */
|
||||||
|
|
||||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
|
||||||
|
|
||||||
#define ERR_RETURN(strm,err) \
|
#define ERR_RETURN(strm,err) \
|
||||||
return (strm->msg = ERR_MSG(err), (err))
|
return (strm->msg = ERR_MSG(err), (err))
|
||||||
|
@ -130,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
#if defined(MACOS)
|
||||||
# define OS_CODE 7
|
# define OS_CODE 7
|
||||||
# ifndef Z_SOLO
|
|
||||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
|
||||||
# include <unix.h> /* for fdopen */
|
|
||||||
# else
|
|
||||||
# ifndef fdopen
|
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __acorn
|
#ifdef __acorn
|
||||||
|
@ -163,22 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# define OS_CODE 19
|
# define OS_CODE 19
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_BEOS_) || defined(RISCOS)
|
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
|
||||||
# if defined(_WIN32_WCE)
|
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
|
||||||
# ifndef _PTRDIFF_T_DEFINED
|
|
||||||
typedef int ptrdiff_t;
|
|
||||||
# define _PTRDIFF_T_DEFINED
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define fdopen(fd,type) _fdopen(fd,type)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__BORLANDC__) && !defined(MSDOS)
|
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||||
#pragma warn -8004
|
#pragma warn -8004
|
||||||
#pragma warn -8008
|
#pragma warn -8008
|
||||||
|
@ -188,8 +170,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
/* provide prototypes for these when building zlib without LFS */
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
#if !defined(_WIN32) && \
|
#if !defined(_WIN32) && \
|
||||||
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* common defaults */
|
/* common defaults */
|
||||||
|
@ -228,16 +211,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
|
||||||
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
|
||||||
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
|
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Diagnostic functions */
|
/* Diagnostic functions */
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
extern int ZLIB_INTERNAL z_verbose;
|
extern int ZLIB_INTERNAL z_verbose;
|
||||||
extern void ZLIB_INTERNAL z_error OF((char *m));
|
extern void ZLIB_INTERNAL z_error(char *m);
|
||||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||||
|
@ -254,9 +237,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Z_SOLO
|
#ifndef Z_SOLO
|
||||||
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
|
||||||
unsigned size));
|
unsigned size);
|
||||||
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZALLOC(strm, items, size) \
|
#define ZALLOC(strm, items, size) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue