mirror of https://github.com/stella-emu/stella.git
After spending several hours converting the zlib C-style files to
proper C++, I find out there's a PERL script to do it in about 5 seconds. Yes, I feel like an idiot. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2069 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
fabc897b42
commit
8da0f4dbfe
|
@ -57,7 +57,10 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
|
|||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
|
||||
uLong ZEXPORT adler32(
|
||||
uLong adler,
|
||||
const Bytef *buf,
|
||||
uInt len)
|
||||
{
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
|
@ -125,7 +128,10 @@ uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
|
||||
local uLong adler32_combine_(
|
||||
uLong adler1,
|
||||
uLong adler2,
|
||||
z_off64_t len2)
|
||||
{
|
||||
unsigned long sum1;
|
||||
unsigned long sum2;
|
||||
|
@ -146,12 +152,18 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2)
|
||||
uLong ZEXPORT adler32_combine(
|
||||
uLong adler1,
|
||||
uLong adler2,
|
||||
z_off_t len2)
|
||||
{
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
||||
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off_t len2)
|
||||
uLong ZEXPORT adler32_combine64(
|
||||
uLong adler1,
|
||||
uLong adler2,
|
||||
z_off64_t len2)
|
||||
{
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
int ZEXPORT compress2 (Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen,
|
||||
int level)
|
||||
int ZEXPORT compress2 (
|
||||
Bytef *dest,
|
||||
uLongf *destLen,
|
||||
const Bytef *source,
|
||||
uLong sourceLen,
|
||||
int level)
|
||||
{
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
@ -56,8 +59,11 @@ int ZEXPORT compress2 (Bytef *dest, uLongf *destLen,
|
|||
|
||||
/* ===========================================================================
|
||||
*/
|
||||
int ZEXPORT compress (Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen)
|
||||
int ZEXPORT compress (
|
||||
Bytef *dest,
|
||||
uLongf *destLen,
|
||||
const Bytef *source,
|
||||
uLong sourceLen)
|
||||
{
|
||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||
}
|
||||
|
@ -66,7 +72,8 @@ int ZEXPORT compress (Bytef *dest, uLongf *destLen,
|
|||
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||
this function needs to be updated.
|
||||
*/
|
||||
uLong ZEXPORT compressBound (uLong sourceLen)
|
||||
uLong ZEXPORT compressBound (
|
||||
uLong sourceLen)
|
||||
{
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||
(sourceLen >> 25) + 13;
|
||||
|
|
|
@ -182,9 +182,9 @@ local void make_crc_table()
|
|||
}
|
||||
|
||||
#ifdef MAKECRCH
|
||||
local void write_table(out, table)
|
||||
FILE *out;
|
||||
const unsigned long FAR *table;
|
||||
local void write_table(
|
||||
FILE *out,
|
||||
const unsigned long FAR *table)
|
||||
{
|
||||
int n;
|
||||
|
||||
|
@ -218,7 +218,10 @@ const unsigned long FAR * ZEXPORT get_crc_table()
|
|||
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT crc32 (uLong crc, const Bytef *buf, uInt len)
|
||||
unsigned long ZEXPORT crc32(
|
||||
unsigned long crc,
|
||||
const unsigned char FAR *buf,
|
||||
uInt len)
|
||||
{
|
||||
if (buf == Z_NULL) return 0UL;
|
||||
|
||||
|
@ -258,8 +261,10 @@ uLong ZEXPORT crc32 (uLong crc, const Bytef *buf, uInt len)
|
|||
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
|
||||
|
||||
/* ========================================================================= */
|
||||
local unsigned long crc32_little(unsigned long crc,
|
||||
const unsigned char FAR *buf, unsigned len)
|
||||
local unsigned long crc32_little(
|
||||
unsigned long crc,
|
||||
const unsigned char FAR *buf,
|
||||
unsigned len)
|
||||
{
|
||||
register u4 c;
|
||||
register const u4 FAR *buf4;
|
||||
|
@ -296,8 +301,10 @@ local unsigned long crc32_little(unsigned long crc,
|
|||
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
|
||||
|
||||
/* ========================================================================= */
|
||||
local unsigned long crc32_big(unsigned long crc,
|
||||
const unsigned char FAR *buf, unsigned len)
|
||||
local unsigned long crc32_big(
|
||||
unsigned long crc,
|
||||
const unsigned char FAR *buf,
|
||||
unsigned len)
|
||||
{
|
||||
register u4 c;
|
||||
register const u4 FAR *buf4;
|
||||
|
@ -334,7 +341,9 @@ local unsigned long crc32_big(unsigned long crc,
|
|||
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
|
||||
|
||||
/* ========================================================================= */
|
||||
local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec)
|
||||
local unsigned long gf2_matrix_times(
|
||||
unsigned long *mat,
|
||||
unsigned long vec)
|
||||
{
|
||||
unsigned long sum;
|
||||
|
||||
|
@ -349,7 +358,9 @@ local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local void gf2_matrix_square(unsigned long *square, unsigned long *mat)
|
||||
local void gf2_matrix_square(
|
||||
unsigned long *square,
|
||||
unsigned long *mat)
|
||||
{
|
||||
int n;
|
||||
|
||||
|
@ -358,7 +369,10 @@ local void gf2_matrix_square(unsigned long *square, unsigned long *mat)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2)
|
||||
local uLong crc32_combine_(
|
||||
uLong crc1,
|
||||
uLong crc2,
|
||||
z_off64_t len2)
|
||||
{
|
||||
int n;
|
||||
unsigned long row;
|
||||
|
@ -411,12 +425,18 @@ local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2)
|
||||
uLong ZEXPORT crc32_combine(
|
||||
uLong crc1,
|
||||
uLong crc2,
|
||||
z_off_t len2)
|
||||
{
|
||||
return crc32_combine_(crc1, crc2, len2);
|
||||
}
|
||||
|
||||
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off_t len2)
|
||||
uLong ZEXPORT crc32_combine64(
|
||||
uLong crc1,
|
||||
uLong crc2,
|
||||
z_off64_t len2)
|
||||
{
|
||||
return crc32_combine_(crc1, crc2, len2);
|
||||
}
|
||||
|
|
|
@ -195,8 +195,11 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
|||
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateInit_(z_streamp strm, int level,
|
||||
const char *version, int stream_size)
|
||||
int ZEXPORT deflateInit_(
|
||||
z_streamp strm,
|
||||
int level,
|
||||
const char *version,
|
||||
int stream_size)
|
||||
{
|
||||
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
|
||||
Z_DEFAULT_STRATEGY, version, stream_size);
|
||||
|
@ -204,10 +207,15 @@ int ZEXPORT deflateInit_(z_streamp strm, int level,
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel,
|
||||
int strategy, const char *version,
|
||||
int stream_size)
|
||||
int ZEXPORT deflateInit2_(
|
||||
z_streamp strm,
|
||||
int level,
|
||||
int method,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char *version,
|
||||
int stream_size)
|
||||
{
|
||||
deflate_state *s;
|
||||
int wrap = 1;
|
||||
|
@ -299,9 +307,10 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateSetDictionary (z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength)
|
||||
int ZEXPORT deflateSetDictionary (
|
||||
z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength)
|
||||
{
|
||||
deflate_state *s;
|
||||
uInt length = dictLength;
|
||||
|
@ -340,7 +349,8 @@ int ZEXPORT deflateSetDictionary (z_streamp strm,
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateReset (z_streamp strm)
|
||||
int ZEXPORT deflateReset (
|
||||
z_streamp strm)
|
||||
{
|
||||
deflate_state *s;
|
||||
|
||||
|
@ -375,7 +385,9 @@ int ZEXPORT deflateReset (z_streamp strm)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head)
|
||||
int ZEXPORT deflateSetHeader (
|
||||
z_streamp strm,
|
||||
gz_headerp head)
|
||||
{
|
||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||
if (strm->state->wrap != 2) return Z_STREAM_ERROR;
|
||||
|
@ -384,7 +396,10 @@ int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
|
||||
int ZEXPORT deflatePrime (
|
||||
z_streamp strm,
|
||||
int bits,
|
||||
int value)
|
||||
{
|
||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||
strm->state->bi_valid = bits;
|
||||
|
@ -393,7 +408,10 @@ int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
|
||||
int ZEXPORT deflateParams(
|
||||
z_streamp strm,
|
||||
int level,
|
||||
int strategy)
|
||||
{
|
||||
deflate_state *s;
|
||||
compress_func func;
|
||||
|
@ -429,8 +447,12 @@ int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
|
||||
int nice_length, int max_chain)
|
||||
int ZEXPORT deflateTune(
|
||||
z_streamp strm,
|
||||
int good_length,
|
||||
int max_lazy,
|
||||
int nice_length,
|
||||
int max_chain)
|
||||
{
|
||||
deflate_state *s;
|
||||
|
||||
|
@ -460,7 +482,9 @@ int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
|
|||
* upper bound of about 14% expansion does not seem onerous for output buffer
|
||||
* allocation.
|
||||
*/
|
||||
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
|
||||
uLong ZEXPORT deflateBound(
|
||||
z_streamp strm,
|
||||
uLong sourceLen)
|
||||
{
|
||||
deflate_state *s;
|
||||
uLong complen, wraplen;
|
||||
|
@ -520,7 +544,9 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
|
|||
* IN assertion: the stream state is correct and there is enough room in
|
||||
* pending_buf.
|
||||
*/
|
||||
local void putShortMSB (deflate_state *s, uInt b)
|
||||
local void putShortMSB (
|
||||
deflate_state *s,
|
||||
uInt b)
|
||||
{
|
||||
put_byte(s, (Byte)(b >> 8));
|
||||
put_byte(s, (Byte)(b & 0xff));
|
||||
|
@ -532,7 +558,8 @@ local void putShortMSB (deflate_state *s, uInt b)
|
|||
* to avoid allocating a large strm->next_out buffer and copying into it.
|
||||
* (See also read_buf()).
|
||||
*/
|
||||
local void flush_pending(z_streamp strm)
|
||||
local void flush_pending(
|
||||
z_streamp strm)
|
||||
{
|
||||
unsigned len = strm->state->pending;
|
||||
|
||||
|
@ -551,7 +578,9 @@ local void flush_pending(z_streamp strm)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflate (z_streamp strm, int flush)
|
||||
int ZEXPORT deflate (
|
||||
z_streamp strm,
|
||||
int flush)
|
||||
{
|
||||
int old_flush; /* value of flush param for previous deflate call */
|
||||
deflate_state *s;
|
||||
|
@ -862,7 +891,8 @@ int ZEXPORT deflate (z_streamp strm, int flush)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateEnd (z_streamp strm)
|
||||
int ZEXPORT deflateEnd (
|
||||
z_streamp strm)
|
||||
{
|
||||
int status;
|
||||
|
||||
|
@ -896,7 +926,9 @@ int ZEXPORT deflateEnd (z_streamp strm)
|
|||
* To simplify the source, this is not supported for 16-bit MSDOS (which
|
||||
* doesn't have enough memory anyway to duplicate compression states).
|
||||
*/
|
||||
int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
|
||||
int ZEXPORT deflateCopy (
|
||||
z_streamp dest,
|
||||
z_streamp source)
|
||||
{
|
||||
#ifdef MAXSEG_64K
|
||||
return Z_STREAM_ERROR;
|
||||
|
@ -956,7 +988,10 @@ int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
|
|||
* allocating a large strm->next_in buffer and copying from it.
|
||||
* (See also flush_pending()).
|
||||
*/
|
||||
local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
|
||||
local int read_buf(
|
||||
z_streamp strm,
|
||||
Bytef *buf,
|
||||
unsigned size)
|
||||
{
|
||||
unsigned len = strm->avail_in;
|
||||
|
||||
|
@ -983,7 +1018,8 @@ local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
|
|||
/* ===========================================================================
|
||||
* Initialize the "longest match" routines for a new zlib stream
|
||||
*/
|
||||
local void lm_init (deflate_state *s)
|
||||
local void lm_init (
|
||||
deflate_state *s)
|
||||
{
|
||||
s->window_size = (ulg)2L*s->w_size;
|
||||
|
||||
|
@ -1023,8 +1059,9 @@ local void lm_init (deflate_state *s)
|
|||
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
||||
* match.S. The code will be functionally equivalent.
|
||||
*/
|
||||
local uInt longest_match(deflate_state *s,
|
||||
IPos cur_match) /* current match */
|
||||
local uInt longest_match(
|
||||
deflate_state *s,
|
||||
IPos cur_match)
|
||||
{
|
||||
unsigned chain_length = s->max_chain_length;/* max hash chain length */
|
||||
register Bytef *scan = s->window + s->strstart; /* current string */
|
||||
|
@ -1171,8 +1208,9 @@ local uInt longest_match(deflate_state *s,
|
|||
/* ---------------------------------------------------------------------------
|
||||
* Optimized version for FASTEST only
|
||||
*/
|
||||
local uInt longest_match(deflate_state *s,
|
||||
IPos cur_match) /* current match */
|
||||
local uInt longest_match(
|
||||
deflate_state *s,
|
||||
IPos cur_match)
|
||||
{
|
||||
register Bytef *scan = s->window + s->strstart; /* current string */
|
||||
register Bytef *match; /* matched string */
|
||||
|
@ -1229,10 +1267,11 @@ local uInt longest_match(deflate_state *s,
|
|||
/* ===========================================================================
|
||||
* Check that the match at match_start is indeed a match.
|
||||
*/
|
||||
local void check_match(s, start, match, length)
|
||||
deflate_state *s;
|
||||
IPos start, match;
|
||||
int length;
|
||||
local void check_match(
|
||||
deflate_state *s,
|
||||
IPos start,
|
||||
IPos match,
|
||||
int length)
|
||||
{
|
||||
/* check that the match is indeed a match */
|
||||
if (zmemcmp(s->window + match,
|
||||
|
@ -1263,7 +1302,8 @@ local void check_match(s, start, match, length)
|
|||
* performed for at least two bytes (required for the zip translate_eol
|
||||
* option -- not supported here).
|
||||
*/
|
||||
local void fill_window(deflate_state *s)
|
||||
local void fill_window(
|
||||
deflate_state *s)
|
||||
{
|
||||
register unsigned n, m;
|
||||
register Posf *p;
|
||||
|
@ -1419,7 +1459,9 @@ local void fill_window(deflate_state *s)
|
|||
* NOTE: this function should be optimized to avoid extra copying from
|
||||
* window to pending_buf.
|
||||
*/
|
||||
local block_state deflate_stored(deflate_state *s, int flush)
|
||||
local block_state deflate_stored(
|
||||
deflate_state *s,
|
||||
int flush)
|
||||
{
|
||||
/* Stored blocks are limited to 0xffff bytes, pending_buf is limited
|
||||
* to pending_buf_size, and each stored block has a 5 byte header:
|
||||
|
@ -1475,7 +1517,9 @@ local block_state deflate_stored(deflate_state *s, int flush)
|
|||
* new strings in the dictionary only for unmatched strings or for short
|
||||
* matches. It is used only for the fast compression options.
|
||||
*/
|
||||
local block_state deflate_fast(deflate_state *s, int flush)
|
||||
local block_state deflate_fast(
|
||||
deflate_state *s,
|
||||
int flush)
|
||||
{
|
||||
IPos hash_head; /* head of the hash chain */
|
||||
int bflush; /* set if current block must be flushed */
|
||||
|
@ -1569,7 +1613,9 @@ local block_state deflate_fast(deflate_state *s, int flush)
|
|||
* evaluation for matches: a match is finally adopted only if there is
|
||||
* no better match at the next window position.
|
||||
*/
|
||||
local block_state deflate_slow(deflate_state *s, int flush)
|
||||
local block_state deflate_slow(
|
||||
deflate_state *s,
|
||||
int flush)
|
||||
{
|
||||
IPos hash_head; /* head of hash chain */
|
||||
int bflush; /* set if current block must be flushed */
|
||||
|
@ -1692,7 +1738,9 @@ local block_state deflate_slow(deflate_state *s, int flush)
|
|||
* one. Do not maintain a hash table. (It will be regenerated if this run of
|
||||
* deflate switches away from Z_RLE.)
|
||||
*/
|
||||
local block_state deflate_rle(deflate_state *s, int flush)
|
||||
local block_state deflate_rle(
|
||||
deflate_state *s,
|
||||
int flush)
|
||||
{
|
||||
int bflush; /* set if current block must be flushed */
|
||||
uInt prev; /* byte at distance one to match */
|
||||
|
@ -1756,7 +1804,9 @@ local block_state deflate_rle(deflate_state *s, int flush)
|
|||
* For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
|
||||
* (It will be regenerated if this run of deflate switches away from Huffman.)
|
||||
*/
|
||||
local block_state deflate_huff(deflate_state *s, int flush)
|
||||
local block_state deflate_huff(
|
||||
deflate_state *s,
|
||||
int flush)
|
||||
{
|
||||
int bflush; /* set if current block must be flushed */
|
||||
|
||||
|
|
|
@ -56,8 +56,11 @@ int main OF((int argc, char *argv[]));
|
|||
/* ===========================================================================
|
||||
* Test compress() and uncompress()
|
||||
*/
|
||||
void test_compress(Byte *compr, uLong comprLen,
|
||||
Byte *uncompr, uLong uncomprLen)
|
||||
void test_compress(
|
||||
Byte *compr,
|
||||
uLong comprLen,
|
||||
Byte *uncompr,
|
||||
uLong uncomprLen)
|
||||
{
|
||||
int err;
|
||||
uLong len = (uLong)strlen(hello)+1;
|
||||
|
@ -81,7 +84,10 @@ void test_compress(Byte *compr, uLong comprLen,
|
|||
/* ===========================================================================
|
||||
* Test read/write of .gz files
|
||||
*/
|
||||
void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen)
|
||||
void test_gzio(
|
||||
const char *fname,
|
||||
Byte *uncompr,
|
||||
uLong uncomprLen)
|
||||
{
|
||||
#ifdef NO_GZCOMPRESS
|
||||
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
|
||||
|
@ -162,7 +168,9 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen)
|
|||
/* ===========================================================================
|
||||
* Test deflate() with small buffers
|
||||
*/
|
||||
void test_deflate(Byte *compr, uLong comprLen)
|
||||
void test_deflate(
|
||||
Byte *compr,
|
||||
uLong comprLen)
|
||||
{
|
||||
z_stream c_stream; /* compression stream */
|
||||
int err;
|
||||
|
@ -198,7 +206,11 @@ void test_deflate(Byte *compr, uLong comprLen)
|
|||
/* ===========================================================================
|
||||
* Test inflate() with small buffers
|
||||
*/
|
||||
void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
|
||||
void test_inflate(
|
||||
Byte *compr,
|
||||
uLong comprLen,
|
||||
Byte *uncompr,
|
||||
uLong uncomprLen)
|
||||
{
|
||||
int err;
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
@ -237,8 +249,11 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
|
|||
/* ===========================================================================
|
||||
* Test deflate() with large buffers and dynamic change of compression level
|
||||
*/
|
||||
void test_large_deflate(Byte *compr, uLong comprLen,
|
||||
Byte *uncompr, uLong uncomprLen)
|
||||
void test_large_deflate(
|
||||
Byte *compr,
|
||||
uLong comprLen,
|
||||
Byte *uncompr,
|
||||
uLong uncomprLen)
|
||||
{
|
||||
z_stream c_stream; /* compression stream */
|
||||
int err;
|
||||
|
@ -291,8 +306,11 @@ void test_large_deflate(Byte *compr, uLong comprLen,
|
|||
/* ===========================================================================
|
||||
* Test inflate() with large buffers
|
||||
*/
|
||||
void test_large_inflate(Byte *compr, uLong comprLen,
|
||||
Byte *uncompr, uLong uncomprLen)
|
||||
void test_large_inflate(
|
||||
Byte *compr,
|
||||
uLong comprLen,
|
||||
Byte *uncompr,
|
||||
uLong uncomprLen)
|
||||
{
|
||||
int err;
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
@ -331,7 +349,9 @@ void test_large_inflate(Byte *compr, uLong comprLen,
|
|||
/* ===========================================================================
|
||||
* Test deflate() with full flush
|
||||
*/
|
||||
void test_flush(Byte *compr, uLong *comprLen)
|
||||
void test_flush(
|
||||
Byte *compr,
|
||||
uLong *comprLen)
|
||||
{
|
||||
z_stream c_stream; /* compression stream */
|
||||
int err;
|
||||
|
@ -367,7 +387,11 @@ void test_flush(Byte *compr, uLong *comprLen)
|
|||
/* ===========================================================================
|
||||
* Test inflateSync()
|
||||
*/
|
||||
void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
|
||||
void test_sync(
|
||||
Byte *compr,
|
||||
uLong comprLen,
|
||||
Byte *uncompr,
|
||||
uLong uncomprLen)
|
||||
{
|
||||
int err;
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
@ -409,7 +433,9 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
|
|||
/* ===========================================================================
|
||||
* Test deflate() with preset dictionary
|
||||
*/
|
||||
void test_dict_deflate(Byte *compr, uLong comprLen)
|
||||
void test_dict_deflate(
|
||||
Byte *compr,
|
||||
uLong comprLen)
|
||||
{
|
||||
z_stream c_stream; /* compression stream */
|
||||
int err;
|
||||
|
@ -444,8 +470,11 @@ void test_dict_deflate(Byte *compr, uLong comprLen)
|
|||
/* ===========================================================================
|
||||
* Test inflate() with a preset dictionary
|
||||
*/
|
||||
void test_dict_inflate(Byte *compr, uLong comprLen,
|
||||
Byte *uncompr, uLong uncomprLen)
|
||||
void test_dict_inflate(
|
||||
Byte *compr,
|
||||
uLong comprLen,
|
||||
Byte *uncompr,
|
||||
uLong uncomprLen)
|
||||
{
|
||||
int err;
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
@ -494,7 +523,9 @@ void test_dict_inflate(Byte *compr, uLong comprLen,
|
|||
* Usage: example [output.gz [input.gz]]
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(
|
||||
int argc,
|
||||
char *argv[])
|
||||
{
|
||||
Byte *compr, *uncompr;
|
||||
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
/* 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
|
||||
unneeded compression or decompression routines. */
|
||||
int ZEXPORT gzclose(gzFile file)
|
||||
int ZEXPORT gzclose(
|
||||
gzFile file)
|
||||
{
|
||||
#ifndef NO_GZCOMPRESS
|
||||
gz_statep state;
|
||||
|
|
|
@ -26,7 +26,8 @@ local gzFile gz_open OF((const char *, int, const char *));
|
|||
|
||||
The gz_strwinerror function does not change the current setting of
|
||||
GetLastError. */
|
||||
char ZLIB_INTERNAL *gz_strwinerror (DWORD error)
|
||||
char ZLIB_INTERNAL *gz_strwinerror (
|
||||
DWORD error)
|
||||
{
|
||||
static char buf[1024];
|
||||
|
||||
|
@ -67,7 +68,8 @@ char ZLIB_INTERNAL *gz_strwinerror (DWORD error)
|
|||
#endif /* UNDER_CE */
|
||||
|
||||
/* Reset gzip file state */
|
||||
local void gz_reset(gz_statep state)
|
||||
local void gz_reset(
|
||||
gz_statep state)
|
||||
{
|
||||
if (state->mode == GZ_READ) { /* for reading ... */
|
||||
state->have = 0; /* no output data available */
|
||||
|
@ -82,7 +84,10 @@ local void gz_reset(gz_statep state)
|
|||
}
|
||||
|
||||
/* Open a gzip file either by name or file descriptor. */
|
||||
local gzFile gz_open(const char *path, int fd, const char *mode)
|
||||
local gzFile gz_open(
|
||||
const char *path,
|
||||
int fd,
|
||||
const char *mode)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -188,19 +193,25 @@ local gzFile gz_open(const char *path, int fd, const char *mode)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile ZEXPORT gzopen(const char *path, const char *mode)
|
||||
gzFile ZEXPORT gzopen(
|
||||
const char *path,
|
||||
const char *mode)
|
||||
{
|
||||
return gz_open(path, -1, mode);
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile ZEXPORT gzopen64(const char *path, const char *mode)
|
||||
gzFile ZEXPORT gzopen64(
|
||||
const char *path,
|
||||
const char *mode)
|
||||
{
|
||||
return gz_open(path, -1, mode);
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile ZEXPORT gzdopen(int fd, const char *mode)
|
||||
gzFile ZEXPORT gzdopen(
|
||||
int fd,
|
||||
const char *mode)
|
||||
{
|
||||
char *path; /* identifier for error messages */
|
||||
gzFile gz;
|
||||
|
@ -214,7 +225,9 @@ gzFile ZEXPORT gzdopen(int fd, const char *mode)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzbuffer(gzFile file, unsigned size)
|
||||
int ZEXPORT gzbuffer(
|
||||
gzFile file,
|
||||
unsigned size)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -237,7 +250,8 @@ int ZEXPORT gzbuffer(gzFile file, unsigned size)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzrewind(gzFile file)
|
||||
int ZEXPORT gzrewind(
|
||||
gzFile file)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -258,7 +272,10 @@ int ZEXPORT gzrewind(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
|
||||
z_off64_t ZEXPORT gzseek64(
|
||||
gzFile file,
|
||||
z_off64_t offset,
|
||||
int whence)
|
||||
{
|
||||
unsigned n;
|
||||
z_off64_t ret;
|
||||
|
@ -331,7 +348,10 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence)
|
||||
z_off_t ZEXPORT gzseek(
|
||||
gzFile file,
|
||||
z_off_t offset,
|
||||
int whence)
|
||||
{
|
||||
z_off64_t ret;
|
||||
|
||||
|
@ -340,7 +360,8 @@ z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t ZEXPORT gztell64(gzFile file)
|
||||
z_off64_t ZEXPORT gztell64(
|
||||
gzFile file)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -356,7 +377,8 @@ z_off64_t ZEXPORT gztell64(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off_t ZEXPORT gztell(gzFile file)
|
||||
z_off_t ZEXPORT gztell(
|
||||
gzFile file)
|
||||
{
|
||||
z_off64_t ret;
|
||||
|
||||
|
@ -365,7 +387,8 @@ z_off_t ZEXPORT gztell(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t ZEXPORT gzoffset64(gzFile file)
|
||||
z_off64_t ZEXPORT gzoffset64(
|
||||
gzFile file)
|
||||
{
|
||||
z_off64_t offset;
|
||||
gz_statep state;
|
||||
|
@ -387,7 +410,8 @@ z_off64_t ZEXPORT gzoffset64(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off_t ZEXPORT gzoffset(gzFile file)
|
||||
z_off_t ZEXPORT gzoffset(
|
||||
gzFile file)
|
||||
{
|
||||
z_off64_t ret;
|
||||
|
||||
|
@ -396,7 +420,8 @@ z_off_t ZEXPORT gzoffset(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzeof(gzFile file)
|
||||
int ZEXPORT gzeof(
|
||||
gzFile file)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -413,7 +438,9 @@ int ZEXPORT gzeof(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
const char * ZEXPORT gzerror(gzFile file, int *errnum)
|
||||
const char * ZEXPORT gzerror(
|
||||
gzFile file,
|
||||
int *errnum)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -431,7 +458,8 @@ const char * ZEXPORT gzerror(gzFile file, int *errnum)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
void ZEXPORT gzclearerr(gzFile file)
|
||||
void ZEXPORT gzclearerr(
|
||||
gzFile file)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -454,7 +482,10 @@ void ZEXPORT gzclearerr(gzFile file)
|
|||
memory). Simply save the error message as a static string. If there is an
|
||||
allocation failure constructing the error message, then convert the error to
|
||||
out of memory. */
|
||||
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
|
||||
void ZLIB_INTERNAL gz_error(
|
||||
gz_statep state,
|
||||
int err,
|
||||
const char *msg)
|
||||
{
|
||||
/* free previously allocated message and clear */
|
||||
if (state->msg != NULL) {
|
||||
|
|
|
@ -18,8 +18,11 @@ local int gz_skip OF((gz_statep, z_off64_t));
|
|||
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
|
||||
read the number of bytes requested, depending on the type of descriptor. */
|
||||
local int gz_load(gz_statep state, unsigned char *buf,
|
||||
unsigned len, unsigned *have)
|
||||
local int gz_load(
|
||||
gz_statep state,
|
||||
unsigned char *buf,
|
||||
unsigned len,
|
||||
unsigned *have)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -44,7 +47,8 @@ local int gz_load(gz_statep state, unsigned char *buf,
|
|||
file is reached, even though there may be unused data in the buffer. Once
|
||||
that data has been used, no more attempts will be made to read the file.
|
||||
gz_avail() assumes that strm->avail_in == 0. */
|
||||
local int gz_avail(gz_statep state)
|
||||
local int gz_avail(
|
||||
gz_statep state)
|
||||
{
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
|
@ -66,7 +70,9 @@ local int gz_avail(gz_statep state)
|
|||
|
||||
/* Get a four-byte little-endian integer and return 0 on success and the value
|
||||
in *ret. Otherwise -1 is returned and *ret is not modified. */
|
||||
local int gz_next4(gz_statep state, unsigned long *ret)
|
||||
local int gz_next4(
|
||||
gz_statep state,
|
||||
unsigned long *ret)
|
||||
{
|
||||
int ch;
|
||||
unsigned long val;
|
||||
|
@ -95,7 +101,8 @@ local int gz_next4(gz_statep state, unsigned long *ret)
|
|||
state and the check value will be initialized. gz_head() will return 0 on
|
||||
success or -1 on failure. Failures may include read errors or gzip header
|
||||
errors. */
|
||||
local int gz_head(gz_statep state)
|
||||
local int gz_head(
|
||||
gz_statep state)
|
||||
{
|
||||
z_streamp strm = &(state->strm);
|
||||
int flags;
|
||||
|
@ -223,7 +230,8 @@ local int gz_head(gz_statep state)
|
|||
stream or raw data, once state->have is depleted. Returns 0 on success, -1
|
||||
on failure. Failures may include invalid compressed data or a failed gzip
|
||||
trailer verification. */
|
||||
local int gz_decomp(gz_statep state)
|
||||
local int gz_decomp(
|
||||
gz_statep state)
|
||||
{
|
||||
int ret;
|
||||
unsigned had;
|
||||
|
@ -293,7 +301,8 @@ local int gz_decomp(gz_statep state)
|
|||
Returns -1 on error, otherwise 0. gz_make() will leave state->have as COPY
|
||||
or GZIP unless the end of the input file has been reached and all data has
|
||||
been processed. */
|
||||
local int gz_make(gz_statep state)
|
||||
local int gz_make(
|
||||
gz_statep state)
|
||||
{
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
|
@ -318,7 +327,9 @@ local int gz_make(gz_statep state)
|
|||
}
|
||||
|
||||
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
|
||||
local int gz_skip(gz_statep state, z_off64_t len)
|
||||
local int gz_skip(
|
||||
gz_statep state,
|
||||
z_off64_t len)
|
||||
{
|
||||
unsigned n;
|
||||
|
||||
|
@ -348,7 +359,10 @@ local int gz_skip(gz_statep state, z_off64_t len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
|
||||
int ZEXPORT gzread(
|
||||
gzFile file,
|
||||
voidp buf,
|
||||
unsigned len)
|
||||
{
|
||||
unsigned got, n;
|
||||
gz_statep state;
|
||||
|
@ -417,7 +431,7 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
|
|||
/* large len -- decompress directly into user buffer */
|
||||
else { /* state->how == GZIP */
|
||||
strm->avail_out = len;
|
||||
strm->next_out = (Bytef*) buf;
|
||||
strm->next_out = (unsigned char*) buf;
|
||||
if (gz_decomp(state) == -1)
|
||||
return -1;
|
||||
n = state->have;
|
||||
|
@ -436,7 +450,8 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzgetc(gzFile file)
|
||||
int ZEXPORT gzgetc(
|
||||
gzFile file)
|
||||
{
|
||||
int ret;
|
||||
unsigned char buf[1];
|
||||
|
@ -464,7 +479,9 @@ int ZEXPORT gzgetc(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzungetc(int c, gzFile file)
|
||||
int ZEXPORT gzungetc(
|
||||
int c,
|
||||
gzFile file)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -519,7 +536,10 @@ int ZEXPORT gzungetc(int c, gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
char * ZEXPORT gzgets(gzFile file, char *buf, int len)
|
||||
char * ZEXPORT gzgets(
|
||||
gzFile file,
|
||||
char *buf,
|
||||
int len)
|
||||
{
|
||||
unsigned left, n;
|
||||
char *str;
|
||||
|
@ -561,7 +581,7 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len)
|
|||
|
||||
/* look for end-of-line in current output buffer */
|
||||
n = state->have > left ? left : state->have;
|
||||
eol = (unsigned char *) memchr(state->next, '\n', n);
|
||||
eol = (unsigned char*) memchr(state->next, '\n', n);
|
||||
if (eol != NULL)
|
||||
n = (unsigned)(eol - state->next) + 1;
|
||||
|
||||
|
@ -580,7 +600,8 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzdirect(gzFile file)
|
||||
int ZEXPORT gzdirect(
|
||||
gzFile file)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -603,7 +624,8 @@ int ZEXPORT gzdirect(gzFile file)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzclose_r(gzFile file)
|
||||
int ZEXPORT gzclose_r(
|
||||
gzFile file)
|
||||
{
|
||||
int ret;
|
||||
gz_statep state;
|
||||
|
|
|
@ -12,14 +12,15 @@ local int gz_zero OF((gz_statep, z_off64_t));
|
|||
|
||||
/* Initialize state for writing a gzip file. Mark initialization by setting
|
||||
state->size to non-zero. Return -1 on failure or 0 on success. */
|
||||
local int gz_init(gz_statep state)
|
||||
local int gz_init(
|
||||
gz_statep state)
|
||||
{
|
||||
int ret;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
/* allocate input and output buffers */
|
||||
state->in = (unsigned char *) malloc(state->want);
|
||||
state->out = (unsigned char *) malloc(state->want);
|
||||
state->in = (unsigned char*) malloc(state->want);
|
||||
state->out = (unsigned char*) malloc(state->want);
|
||||
if (state->in == NULL || state->out == NULL) {
|
||||
if (state->out != NULL)
|
||||
free(state->out);
|
||||
|
@ -55,7 +56,9 @@ local int gz_init(gz_statep state)
|
|||
Return -1 if there is an error writing to the output file, otherwise 0.
|
||||
flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH,
|
||||
then the deflate() state is reset to start a new gzip stream. */
|
||||
local int gz_comp(gz_statep state, int flush)
|
||||
local int gz_comp(
|
||||
gz_statep state,
|
||||
int flush)
|
||||
{
|
||||
int ret, got;
|
||||
unsigned have;
|
||||
|
@ -105,7 +108,9 @@ local int gz_comp(gz_statep state, int flush)
|
|||
}
|
||||
|
||||
/* Compress len zeros to output. Return -1 on error, 0 on success. */
|
||||
local int gz_zero(gz_statep state, z_off64_t len)
|
||||
local int gz_zero(
|
||||
gz_statep state,
|
||||
z_off64_t len)
|
||||
{
|
||||
int first;
|
||||
unsigned n;
|
||||
|
@ -135,7 +140,10 @@ local int gz_zero(gz_statep state, z_off64_t len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
|
||||
int ZEXPORT gzwrite(
|
||||
gzFile file,
|
||||
voidpc buf,
|
||||
unsigned len)
|
||||
{
|
||||
unsigned put = len;
|
||||
unsigned n;
|
||||
|
@ -210,7 +218,9 @@ int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzputc(gzFile file, int c)
|
||||
int ZEXPORT gzputc(
|
||||
gzFile file,
|
||||
int c)
|
||||
{
|
||||
unsigned char buf[1];
|
||||
gz_statep state;
|
||||
|
@ -251,7 +261,9 @@ int ZEXPORT gzputc(gzFile file, int c)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzputs(gzFile file, const char *str)
|
||||
int ZEXPORT gzputs(
|
||||
gzFile file,
|
||||
const char *str)
|
||||
{
|
||||
int ret;
|
||||
unsigned len;
|
||||
|
@ -337,12 +349,29 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
|
|||
#else /* !STDC */
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
|
||||
gzFile file;
|
||||
const char *format;
|
||||
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
||||
int ZEXPORTVA gzprintf (
|
||||
gzFile file,
|
||||
const char *format,
|
||||
int a1,
|
||||
int a2,
|
||||
int a3,
|
||||
int a4,
|
||||
int a5,
|
||||
int a6,
|
||||
int a7,
|
||||
int a8,
|
||||
int a9,
|
||||
int a10,
|
||||
int a11,
|
||||
int a12,
|
||||
int a13,
|
||||
int a14,
|
||||
int a15,
|
||||
int a16,
|
||||
int a17,
|
||||
int a18,
|
||||
int a19,
|
||||
int a20)
|
||||
{
|
||||
int size, len;
|
||||
gz_statep state;
|
||||
|
@ -411,7 +440,9 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
|||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzflush(gzFile file, int flush)
|
||||
int ZEXPORT gzflush(
|
||||
gzFile file,
|
||||
int flush)
|
||||
{
|
||||
gz_statep state;
|
||||
|
||||
|
@ -441,7 +472,10 @@ int ZEXPORT gzflush(gzFile file, int flush)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
|
||||
int ZEXPORT gzsetparams(
|
||||
gzFile file,
|
||||
int level,
|
||||
int strategy)
|
||||
{
|
||||
gz_statep state;
|
||||
z_streamp strm;
|
||||
|
@ -480,7 +514,8 @@ int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
|
|||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzclose_w(gzFile file)
|
||||
int ZEXPORT gzclose_w(
|
||||
gzFile file)
|
||||
{
|
||||
int ret = 0;
|
||||
gz_statep state;
|
||||
|
|
|
@ -25,10 +25,12 @@ local void fixedtables OF((struct inflate_state FAR *state));
|
|||
windowBits is in the range 8..15, and window is a user-supplied
|
||||
window and output buffer that is 2**windowBits bytes.
|
||||
*/
|
||||
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
|
||||
unsigned char FAR *window,
|
||||
const char *version,
|
||||
int stream_size)
|
||||
int ZEXPORT inflateBackInit_(
|
||||
z_streamp strm,
|
||||
int windowBits,
|
||||
unsigned char FAR *window,
|
||||
const char *version,
|
||||
int stream_size)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -68,7 +70,8 @@ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
|
|||
used for threaded applications, since the rewriting of the tables and virgin
|
||||
may not be thread-safe.
|
||||
*/
|
||||
local void fixedtables(struct inflate_state FAR *state)
|
||||
local void fixedtables(
|
||||
struct inflate_state FAR *state)
|
||||
{
|
||||
#ifdef BUILDFIXED
|
||||
static int virgin = 1;
|
||||
|
@ -235,8 +238,12 @@ local void fixedtables(struct inflate_state FAR *state)
|
|||
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.
|
||||
*/
|
||||
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
|
||||
out_func out, void FAR *out_desc)
|
||||
int ZEXPORT inflateBack(
|
||||
z_streamp strm,
|
||||
in_func in,
|
||||
void FAR *in_desc,
|
||||
out_func out,
|
||||
void FAR *out_desc)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned char FAR *next; /* next input */
|
||||
|
@ -613,7 +620,8 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateBackEnd(z_streamp strm)
|
||||
int ZEXPORT inflateBackEnd(
|
||||
z_streamp strm)
|
||||
{
|
||||
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
||||
return Z_STREAM_ERROR;
|
||||
|
|
|
@ -65,9 +65,8 @@
|
|||
output space.
|
||||
*/
|
||||
void ZLIB_INTERNAL inflate_fast(
|
||||
z_streamp strm,
|
||||
unsigned start /* inflate()'s starting value for strm->avail_out */
|
||||
)
|
||||
z_streamp strm,
|
||||
unsigned start)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned char FAR *in; /* local strm->next_in */
|
||||
|
|
|
@ -100,7 +100,8 @@ local int updatewindow OF((z_streamp strm, unsigned out));
|
|||
local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
|
||||
unsigned len));
|
||||
|
||||
int ZEXPORT inflateReset(z_streamp strm)
|
||||
int ZEXPORT inflateReset(
|
||||
z_streamp strm)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -126,7 +127,9 @@ int ZEXPORT inflateReset(z_streamp strm)
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
|
||||
int ZEXPORT inflateReset2(
|
||||
z_streamp strm,
|
||||
int windowBits)
|
||||
{
|
||||
int wrap;
|
||||
struct inflate_state FAR *state;
|
||||
|
@ -162,8 +165,11 @@ int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
|
|||
return inflateReset(strm);
|
||||
}
|
||||
|
||||
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
|
||||
const char *version, int stream_size)
|
||||
int ZEXPORT inflateInit2_(
|
||||
z_streamp strm,
|
||||
int windowBits,
|
||||
const char *version,
|
||||
int stream_size)
|
||||
{
|
||||
int ret;
|
||||
struct inflate_state FAR *state;
|
||||
|
@ -192,13 +198,18 @@ int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateInit_(z_streamp strm,
|
||||
const char *version, int stream_size)
|
||||
int ZEXPORT inflateInit_(
|
||||
z_streamp strm,
|
||||
const char *version,
|
||||
int stream_size)
|
||||
{
|
||||
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
||||
}
|
||||
|
||||
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
|
||||
int ZEXPORT inflatePrime(
|
||||
z_streamp strm,
|
||||
int bits,
|
||||
int value)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -226,7 +237,8 @@ int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
|
|||
used for threaded applications, since the rewriting of the tables and virgin
|
||||
may not be thread-safe.
|
||||
*/
|
||||
local void fixedtables(struct inflate_state FAR *state)
|
||||
local void fixedtables(
|
||||
struct inflate_state FAR *state)
|
||||
{
|
||||
#ifdef BUILDFIXED
|
||||
static int virgin = 1;
|
||||
|
@ -343,7 +355,9 @@ void makefixed()
|
|||
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.
|
||||
*/
|
||||
local int updatewindow(z_streamp strm, unsigned out)
|
||||
local int updatewindow(
|
||||
z_streamp strm,
|
||||
unsigned out)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned copy, dist;
|
||||
|
@ -572,7 +586,9 @@ local int updatewindow(z_streamp strm, unsigned out)
|
|||
will return Z_BUF_ERROR if it has not reached the end of the stream.
|
||||
*/
|
||||
|
||||
int ZEXPORT inflate(z_streamp strm, int flush)
|
||||
int ZEXPORT inflate(
|
||||
z_streamp strm,
|
||||
int flush)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned char FAR *next; /* next input */
|
||||
|
@ -1219,7 +1235,8 @@ int ZEXPORT inflate(z_streamp strm, int flush)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateEnd(z_streamp strm)
|
||||
int ZEXPORT inflateEnd(
|
||||
z_streamp strm)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
||||
|
@ -1232,8 +1249,10 @@ int ZEXPORT inflateEnd(z_streamp strm)
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
||||
uInt dictLength)
|
||||
int ZEXPORT inflateSetDictionary(
|
||||
z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned long id;
|
||||
|
@ -1272,7 +1291,9 @@ int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
|
||||
int ZEXPORT inflateGetHeader(
|
||||
z_streamp strm,
|
||||
gz_headerp head)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -1298,8 +1319,10 @@ int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
|
|||
called again with more data and the *have state. *have is initialized to
|
||||
zero for the first call.
|
||||
*/
|
||||
local unsigned syncsearch(unsigned FAR *have, unsigned char FAR *buf,
|
||||
unsigned len)
|
||||
local unsigned syncsearch(
|
||||
unsigned FAR *have,
|
||||
unsigned char FAR *buf,
|
||||
unsigned len)
|
||||
{
|
||||
unsigned got;
|
||||
unsigned next;
|
||||
|
@ -1319,7 +1342,8 @@ local unsigned syncsearch(unsigned FAR *have, unsigned char FAR *buf,
|
|||
return next;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateSync(z_streamp strm)
|
||||
int ZEXPORT inflateSync(
|
||||
z_streamp strm)
|
||||
{
|
||||
unsigned len; /* number of bytes to look at or looked at */
|
||||
unsigned long in, out; /* temporary to save total_in and total_out */
|
||||
|
@ -1369,7 +1393,8 @@ int ZEXPORT inflateSync(z_streamp strm)
|
|||
block. When decompressing, PPP checks that at the end of input packet,
|
||||
inflate is waiting for these length bytes.
|
||||
*/
|
||||
int ZEXPORT inflateSyncPoint(z_streamp strm)
|
||||
int ZEXPORT inflateSyncPoint(
|
||||
z_streamp strm)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -1378,7 +1403,9 @@ int ZEXPORT inflateSyncPoint(z_streamp strm)
|
|||
return state->mode == STORED && state->bits == 0;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
|
||||
int ZEXPORT inflateCopy(
|
||||
z_streamp dest,
|
||||
z_streamp source)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
struct inflate_state FAR *copy;
|
||||
|
@ -1423,7 +1450,9 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
|
||||
int ZEXPORT inflateUndermine(
|
||||
z_streamp strm,
|
||||
int subvert)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -1438,7 +1467,8 @@ int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
|
|||
#endif
|
||||
}
|
||||
|
||||
long ZEXPORT inflateMark(z_streamp strm)
|
||||
long ZEXPORT inflateMark(
|
||||
z_streamp strm)
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
|
|
@ -29,9 +29,13 @@ const char inflate_copyright[] =
|
|||
table index bits. It will differ if the request is greater than the
|
||||
longest code or if it is less than the shortest code.
|
||||
*/
|
||||
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work)
|
||||
int ZLIB_INTERNAL inflate_table(
|
||||
codetype type,
|
||||
unsigned short FAR *lens,
|
||||
unsigned codes,
|
||||
code FAR * FAR *table,
|
||||
unsigned FAR *bits,
|
||||
unsigned short FAR *work)
|
||||
{
|
||||
unsigned len; /* a code's length in bits */
|
||||
unsigned sym; /* index of code symbols */
|
||||
|
|
|
@ -73,7 +73,8 @@
|
|||
The strwinerror function does not change the current setting
|
||||
of GetLastError. */
|
||||
|
||||
static char *strwinerror (DWORD error)
|
||||
static char *strwinerror (
|
||||
DWORD error)
|
||||
{
|
||||
static char buf[1024];
|
||||
|
||||
|
@ -111,7 +112,8 @@ static char *strwinerror (DWORD error)
|
|||
return buf;
|
||||
}
|
||||
|
||||
static void pwinerror (const char *s)
|
||||
static void pwinerror (
|
||||
const char *s)
|
||||
{
|
||||
if (s && *s)
|
||||
fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ()));
|
||||
|
@ -151,7 +153,8 @@ int main OF((int argc, char *argv[]));
|
|||
/* ===========================================================================
|
||||
* Display error message and exit
|
||||
*/
|
||||
void error(const char *msg)
|
||||
void error(
|
||||
const char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s: %s\n", prog, msg);
|
||||
exit(1);
|
||||
|
@ -161,7 +164,9 @@ void error(const char *msg)
|
|||
* Compress input to output then close both files.
|
||||
*/
|
||||
|
||||
void gz_compress(FILE *in, gzFile out)
|
||||
void gz_compress(
|
||||
FILE *in,
|
||||
gzFile out)
|
||||
{
|
||||
local char buf[BUFLEN];
|
||||
int len;
|
||||
|
@ -192,7 +197,9 @@ void gz_compress(FILE *in, gzFile out)
|
|||
/* Try compressing the input file at once using mmap. Return Z_OK if
|
||||
* if success, Z_ERRNO otherwise.
|
||||
*/
|
||||
int gz_compress_mmap(FILE *in, gzFile out)
|
||||
int gz_compress_mmap(
|
||||
FILE *in,
|
||||
gzFile out)
|
||||
{
|
||||
int len;
|
||||
int err;
|
||||
|
@ -225,7 +232,9 @@ int gz_compress_mmap(FILE *in, gzFile out)
|
|||
/* ===========================================================================
|
||||
* Uncompress input to output then close both files.
|
||||
*/
|
||||
void gz_uncompress(gzFile in, FILE *out)
|
||||
void gz_uncompress(
|
||||
gzFile in,
|
||||
FILE *out)
|
||||
{
|
||||
local char buf[BUFLEN];
|
||||
int len;
|
||||
|
@ -250,7 +259,9 @@ void gz_uncompress(gzFile in, FILE *out)
|
|||
* Compress the given file: create a corresponding .gz file and remove the
|
||||
* original.
|
||||
*/
|
||||
void file_compress(char *file, char *mode)
|
||||
void file_compress(
|
||||
char *file,
|
||||
char *mode)
|
||||
{
|
||||
local char outfile[MAX_NAME_LEN];
|
||||
FILE *in;
|
||||
|
@ -283,7 +294,8 @@ void file_compress(char *file, char *mode)
|
|||
/* ===========================================================================
|
||||
* Uncompress the given file and remove the original.
|
||||
*/
|
||||
void file_uncompress(char *file)
|
||||
void file_uncompress(
|
||||
char *file)
|
||||
{
|
||||
local char buf[MAX_NAME_LEN];
|
||||
char *infile, *outfile;
|
||||
|
@ -334,7 +346,9 @@ void file_uncompress(char *file)
|
|||
* -1 to -9 : compression level
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(
|
||||
int argc,
|
||||
char *argv[])
|
||||
{
|
||||
int copyout = 0;
|
||||
int uncompr = 0;
|
||||
|
|
|
@ -190,10 +190,10 @@ local void gen_trees_header OF((void));
|
|||
#ifdef DEBUG
|
||||
local void send_bits OF((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 */
|
||||
local void send_bits(
|
||||
deflate_state *s,
|
||||
int value,
|
||||
int length)
|
||||
{
|
||||
Tracevv((stderr," l %2d v %4x ", length, value));
|
||||
Assert(length > 0 && length <= 15, "invalid length");
|
||||
|
@ -383,7 +383,8 @@ void gen_trees_header()
|
|||
/* ===========================================================================
|
||||
* Initialize the tree data structures for a new zlib stream.
|
||||
*/
|
||||
void ZLIB_INTERNAL _tr_init(deflate_state *s)
|
||||
void ZLIB_INTERNAL _tr_init(
|
||||
deflate_state *s)
|
||||
{
|
||||
tr_static_init();
|
||||
|
||||
|
@ -411,7 +412,8 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s)
|
|||
/* ===========================================================================
|
||||
* Initialize a new block.
|
||||
*/
|
||||
local void init_block(deflate_state *s)
|
||||
local void init_block(
|
||||
deflate_state *s)
|
||||
{
|
||||
int n; /* iterates over tree elements */
|
||||
|
||||
|
@ -456,9 +458,8 @@ local void init_block(deflate_state *s)
|
|||
*/
|
||||
local void pqdownheap(
|
||||
deflate_state *s,
|
||||
ct_data *tree, /* the tree to restore */
|
||||
int k /* node to move down */
|
||||
)
|
||||
ct_data *tree,
|
||||
int k)
|
||||
{
|
||||
int v = s->heap[k];
|
||||
int j = k << 1; /* left son of k */
|
||||
|
@ -492,8 +493,7 @@ local void pqdownheap(
|
|||
*/
|
||||
local void gen_bitlen(
|
||||
deflate_state *s,
|
||||
tree_desc *desc /* the tree descriptor */
|
||||
)
|
||||
tree_desc *desc)
|
||||
{
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
int max_code = desc->max_code;
|
||||
|
@ -579,10 +579,9 @@ local void gen_bitlen(
|
|||
* zero code length.
|
||||
*/
|
||||
local void gen_codes (
|
||||
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 */
|
||||
)
|
||||
ct_data *tree,
|
||||
int max_code,
|
||||
ushf *bl_count)
|
||||
{
|
||||
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
||||
ush code = 0; /* running code value */
|
||||
|
@ -623,8 +622,7 @@ local void gen_codes (
|
|||
*/
|
||||
local void build_tree(
|
||||
deflate_state *s,
|
||||
tree_desc *desc /* the tree descriptor */
|
||||
)
|
||||
tree_desc *desc)
|
||||
{
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
const ct_data *stree = desc->stat_desc->static_tree;
|
||||
|
@ -712,9 +710,8 @@ local void build_tree(
|
|||
*/
|
||||
local void scan_tree (
|
||||
deflate_state *s,
|
||||
ct_data *tree, /* the tree to be scanned */
|
||||
int max_code /* and its largest code of non zero frequency */
|
||||
)
|
||||
ct_data *tree,
|
||||
int max_code)
|
||||
{
|
||||
int n; /* iterates over all tree elements */
|
||||
int prevlen = -1; /* last emitted length */
|
||||
|
@ -758,9 +755,8 @@ local void scan_tree (
|
|||
*/
|
||||
local void send_tree (
|
||||
deflate_state *s,
|
||||
ct_data *tree, /* the tree to be scanned */
|
||||
int max_code /* and its largest code of non zero frequency */
|
||||
)
|
||||
ct_data *tree,
|
||||
int max_code)
|
||||
{
|
||||
int n; /* iterates over all tree elements */
|
||||
int prevlen = -1; /* last emitted length */
|
||||
|
@ -808,7 +804,8 @@ local void send_tree (
|
|||
* Construct the Huffman tree for the bit lengths and return the index in
|
||||
* bl_order of the last bit length code to send.
|
||||
*/
|
||||
local int build_bl_tree(deflate_state *s)
|
||||
local int build_bl_tree(
|
||||
deflate_state *s)
|
||||
{
|
||||
int max_blindex; /* index of last bit length code of non zero freq */
|
||||
|
||||
|
@ -844,8 +841,9 @@ local int build_bl_tree(deflate_state *s)
|
|||
*/
|
||||
local void send_all_trees(
|
||||
deflate_state *s,
|
||||
int lcodes, int dcodes, int blcodes /* number of codes for each tree */
|
||||
)
|
||||
int lcodes,
|
||||
int dcodes,
|
||||
int blcodes)
|
||||
{
|
||||
int rank; /* index in bl_order */
|
||||
|
||||
|
@ -874,10 +872,9 @@ local void send_all_trees(
|
|||
*/
|
||||
void ZLIB_INTERNAL _tr_stored_block(
|
||||
deflate_state *s,
|
||||
charf *buf, /* input block */
|
||||
ulg stored_len, /* length of input block */
|
||||
int last /* one if this is the last block for a file */
|
||||
)
|
||||
charf *buf,
|
||||
ulg stored_len,
|
||||
int last)
|
||||
{
|
||||
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
|
||||
#ifdef DEBUG
|
||||
|
@ -898,7 +895,8 @@ void ZLIB_INTERNAL _tr_stored_block(
|
|||
* To simplify the code, we assume the worst case of last real code encoded
|
||||
* on one bit only.
|
||||
*/
|
||||
void ZLIB_INTERNAL _tr_align(deflate_state *s)
|
||||
void ZLIB_INTERNAL _tr_align(
|
||||
deflate_state *s)
|
||||
{
|
||||
send_bits(s, STATIC_TREES<<1, 3);
|
||||
send_code(s, END_BLOCK, static_ltree);
|
||||
|
@ -928,10 +926,9 @@ void ZLIB_INTERNAL _tr_align(deflate_state *s)
|
|||
*/
|
||||
void ZLIB_INTERNAL _tr_flush_block(
|
||||
deflate_state *s,
|
||||
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 */
|
||||
)
|
||||
charf *buf,
|
||||
ulg stored_len,
|
||||
int last)
|
||||
{
|
||||
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 */
|
||||
|
@ -1030,9 +1027,8 @@ void ZLIB_INTERNAL _tr_flush_block(
|
|||
*/
|
||||
int ZLIB_INTERNAL _tr_tally (
|
||||
deflate_state *s,
|
||||
unsigned dist, /* distance of matched string */
|
||||
unsigned lc /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
||||
)
|
||||
unsigned dist,
|
||||
unsigned lc)
|
||||
{
|
||||
s->d_buf[s->last_lit] = (ush)dist;
|
||||
s->l_buf[s->last_lit++] = (uch)lc;
|
||||
|
@ -1081,9 +1077,8 @@ int ZLIB_INTERNAL _tr_tally (
|
|||
*/
|
||||
local void compress_block(
|
||||
deflate_state *s,
|
||||
ct_data *ltree, /* literal tree */
|
||||
ct_data *dtree /* distance tree */
|
||||
)
|
||||
ct_data *ltree,
|
||||
ct_data *dtree)
|
||||
{
|
||||
unsigned dist; /* distance of matched string */
|
||||
int lc; /* match length or unmatched char (if dist == 0) */
|
||||
|
@ -1141,7 +1136,8 @@ local void compress_block(
|
|||
* (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)
|
||||
local int detect_data_type(
|
||||
deflate_state *s)
|
||||
{
|
||||
/* black_mask is the bit mask of black-listed bytes
|
||||
* set bits 0..6, 14..25, and 28..31
|
||||
|
@ -1175,9 +1171,8 @@ local int detect_data_type(deflate_state *s)
|
|||
* IN assertion: 1 <= len <= 15
|
||||
*/
|
||||
local unsigned bi_reverse(
|
||||
unsigned code, /* the value to invert */
|
||||
int len /* its bit length */
|
||||
)
|
||||
unsigned code,
|
||||
int len)
|
||||
{
|
||||
register unsigned res = 0;
|
||||
do {
|
||||
|
@ -1190,7 +1185,8 @@ local unsigned bi_reverse(
|
|||
/* ===========================================================================
|
||||
* Flush the bit buffer, keeping at most 7 bits in it.
|
||||
*/
|
||||
local void bi_flush(deflate_state *s)
|
||||
local void bi_flush(
|
||||
deflate_state *s)
|
||||
{
|
||||
if (s->bi_valid == 16) {
|
||||
put_short(s, s->bi_buf);
|
||||
|
@ -1206,7 +1202,8 @@ local void bi_flush(deflate_state *s)
|
|||
/* ===========================================================================
|
||||
* Flush the bit buffer and align the output on a byte boundary
|
||||
*/
|
||||
local void bi_windup(deflate_state *s)
|
||||
local void bi_windup(
|
||||
deflate_state *s)
|
||||
{
|
||||
if (s->bi_valid > 8) {
|
||||
put_short(s, s->bi_buf);
|
||||
|
@ -1226,10 +1223,9 @@ local void bi_windup(deflate_state *s)
|
|||
*/
|
||||
local void copy_block(
|
||||
deflate_state *s,
|
||||
charf *buf, /* the input data */
|
||||
unsigned len, /* its length */
|
||||
int header /* true if block header must be written */
|
||||
)
|
||||
charf *buf,
|
||||
unsigned len,
|
||||
int header)
|
||||
{
|
||||
bi_windup(s); /* align on byte boundary */
|
||||
s->last_eob_len = 8; /* enough lookahead for inflate */
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||
*/
|
||||
int ZEXPORT uncompress (Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen)
|
||||
int ZEXPORT uncompress (
|
||||
Bytef *dest,
|
||||
uLongf *destLen,
|
||||
const Bytef *source,
|
||||
uLong sourceLen)
|
||||
{
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
|
|
@ -356,7 +356,7 @@ typedef uLong FAR uLongf;
|
|||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||
#if 1 /* was set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
|
|
|
@ -119,7 +119,8 @@ uLong ZEXPORT zlibCompileFlags()
|
|||
# endif
|
||||
int ZLIB_INTERNAL z_verbose = verbose;
|
||||
|
||||
void ZLIB_INTERNAL z_error (char *m)
|
||||
void ZLIB_INTERNAL z_error (
|
||||
char *m)
|
||||
{
|
||||
fprintf(stderr, "%s\n", m);
|
||||
exit(1);
|
||||
|
@ -129,7 +130,8 @@ void ZLIB_INTERNAL z_error (char *m)
|
|||
/* exported to allow conversion of error code to string for compress() and
|
||||
* uncompress()
|
||||
*/
|
||||
const char * ZEXPORT zError(int err)
|
||||
const char * ZEXPORT zError(
|
||||
int err)
|
||||
{
|
||||
return ERR_MSG(err);
|
||||
}
|
||||
|
@ -144,7 +146,10 @@ const char * ZEXPORT zError(int err)
|
|||
|
||||
#ifndef HAVE_MEMCPY
|
||||
|
||||
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len)
|
||||
void ZLIB_INTERNAL zmemcpy(
|
||||
Bytef* dest,
|
||||
const Bytef* source,
|
||||
uInt len)
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
|
@ -152,7 +157,10 @@ void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len)
|
|||
} while (--len != 0);
|
||||
}
|
||||
|
||||
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len)
|
||||
int ZLIB_INTERNAL zmemcmp(
|
||||
const Bytef* s1,
|
||||
const Bytef* s2,
|
||||
uInt len)
|
||||
{
|
||||
uInt j;
|
||||
|
||||
|
@ -162,7 +170,9 @@ int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len)
|
||||
void ZLIB_INTERNAL zmemzero(
|
||||
Bytef* dest,
|
||||
uInt len)
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
|
@ -287,14 +297,19 @@ extern voidp calloc OF((uInt items, uInt size));
|
|||
extern void free OF((voidpf ptr));
|
||||
#endif
|
||||
|
||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||
voidpf ZLIB_INTERNAL zcalloc (
|
||||
voidpf opaque,
|
||||
unsigned items,
|
||||
unsigned size)
|
||||
{
|
||||
if (opaque) items += size - size; /* make compiler happy */
|
||||
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
||||
(voidpf)calloc(items, size);
|
||||
}
|
||||
|
||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||
void ZLIB_INTERNAL zcfree (
|
||||
voidpf opaque,
|
||||
voidpf ptr)
|
||||
{
|
||||
free(ptr);
|
||||
if (opaque) return; /* make compiler happy */
|
||||
|
|
Loading…
Reference in New Issue