mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
zlib: Update to version 1.3.1.2 and use context in decompression
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2025 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
|
||||
/* #undef Z_PREFIX */
|
||||
/* #undef Z_HAVE_UNISTD_H */
|
||||
#define HAVE_STDARG_H 1
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
ZCONF_H
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
@@ -61,6 +64,7 @@
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateSetHeader z_deflateSetHeader
|
||||
# define deflateTune z_deflateTune
|
||||
# define deflateUsed z_deflateUsed
|
||||
# define deflate_copyright z_deflate_copyright
|
||||
# define get_crc_table z_get_crc_table
|
||||
# ifndef Z_SOLO
|
||||
@@ -236,27 +240,29 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#ifndef z_const
|
||||
# ifdef ZLIB_CONST
|
||||
# define z_const const
|
||||
# else
|
||||
# define z_const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
# ifdef _WIN64
|
||||
typedef unsigned long long z_size_t;
|
||||
typedef unsigned long long z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
#else
|
||||
# define z_longlong long long
|
||||
# if defined(NO_SIZE_T)
|
||||
typedef unsigned NO_SIZE_T z_size_t;
|
||||
typedef unsigned NO_SIZE_T z_size_t;
|
||||
# elif defined(STDC)
|
||||
# include <stddef.h>
|
||||
typedef size_t z_size_t;
|
||||
typedef size_t z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
# undef z_longlong
|
||||
#endif
|
||||
@@ -292,7 +298,7 @@ typedef unsigned long z_size_t;
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
@@ -310,7 +316,7 @@ typedef unsigned long z_size_t;
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
@@ -319,7 +325,7 @@ typedef unsigned long z_size_t;
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
@@ -330,9 +336,9 @@ typedef unsigned long z_size_t;
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
@@ -342,10 +348,10 @@ typedef unsigned long z_size_t;
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
@@ -354,8 +360,8 @@ typedef unsigned long z_size_t;
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
@@ -398,10 +404,10 @@ typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
@@ -409,13 +415,13 @@ typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||
@@ -430,16 +436,16 @@ typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||
#if HAVE_UNISTD_H-0 /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||
#if HAVE_STDARG_H-0 /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_STDARG_H
|
||||
#endif
|
||||
|
||||
@@ -472,12 +478,8 @@ typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifndef Z_HAVE_UNISTD_H
|
||||
# ifdef __WATCOMC__
|
||||
# define Z_HAVE_UNISTD_H
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Z_HAVE_UNISTD_H
|
||||
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
|
||||
# if defined(__WATCOMC__) || defined(__GO32__) || \
|
||||
(defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
|
||||
# define Z_HAVE_UNISTD_H
|
||||
# endif
|
||||
#endif
|
||||
@@ -512,34 +514,36 @@ typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
# define z_off_t long long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#elif defined(__MINGW32__)
|
||||
# define z_off64_t long long
|
||||
#elif defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
#elif defined(__GO32__)
|
||||
# define z_off64_t offset_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
# endif
|
||||
# define z_off64_t z_off_t
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.3.1, January 22nd, 2024
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.3.1.2, December 8th, 2025
|
||||
|
||||
Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
Copyright (C) 1995-2025 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
|
||||
@@ -24,25 +24,29 @@
|
||||
|
||||
|
||||
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
|
||||
Comments) 1950 to 1952 at https://datatracker.ietf.org/doc/html/rfc1950
|
||||
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
|
||||
*/
|
||||
|
||||
#ifndef ZLIB_H
|
||||
#define ZLIB_H
|
||||
|
||||
#include "zconf.h"
|
||||
#ifdef ZLIB_BUILD
|
||||
# include <zconf.h>
|
||||
#else
|
||||
# include "zconf.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ZLIB_VERSION "1.3.1"
|
||||
#define ZLIB_VERNUM 0x1310
|
||||
#define ZLIB_VERSION "1.3.1.2-audit"
|
||||
#define ZLIB_VERNUM 0x1312
|
||||
#define ZLIB_VER_MAJOR 1
|
||||
#define ZLIB_VER_MINOR 3
|
||||
#define ZLIB_VER_REVISION 1
|
||||
#define ZLIB_VER_SUBREVISION 0
|
||||
#define ZLIB_VER_SUBREVISION 2
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
@@ -163,7 +167,7 @@ typedef gz_header FAR *gz_headerp;
|
||||
if the decompressor wants to decompress everything in a single step).
|
||||
*/
|
||||
|
||||
/* constants */
|
||||
/* constants */
|
||||
|
||||
#define Z_NO_FLUSH 0
|
||||
#define Z_PARTIAL_FLUSH 1
|
||||
@@ -215,7 +219,7 @@ typedef gz_header FAR *gz_headerp;
|
||||
/* for compatibility with versions < 1.0.2 */
|
||||
|
||||
|
||||
/* basic functions */
|
||||
/* basic functions */
|
||||
|
||||
ZEXTERN const char * ZEXPORT zlibVersion(void);
|
||||
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
|
||||
@@ -441,7 +445,7 @@ ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush);
|
||||
|
||||
The Z_BLOCK option assists in appending to or combining deflate streams.
|
||||
To assist in this, on return inflate() always sets strm->data_type to the
|
||||
number of unused bits in the last byte taken from strm->next_in, plus 64 if
|
||||
number of unused bits in the input taken from strm->next_in, plus 64 if
|
||||
inflate() is currently decoding the last block in the deflate stream, plus
|
||||
128 if inflate() returned immediately after decoding an end-of-block code or
|
||||
decoding the complete header up to just before the first byte of the deflate
|
||||
@@ -529,7 +533,7 @@ ZEXTERN int ZEXPORT inflateEnd(z_streamp strm);
|
||||
*/
|
||||
|
||||
|
||||
/* Advanced functions */
|
||||
/* Advanced functions */
|
||||
|
||||
/*
|
||||
The following functions are needed only in some special applications.
|
||||
@@ -587,18 +591,21 @@ ZEXTERN int ZEXPORT deflateInit2(z_streamp strm,
|
||||
|
||||
The strategy parameter is used to tune the compression algorithm. Use the
|
||||
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
|
||||
filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
|
||||
string match), or Z_RLE to limit match distances to one (run-length
|
||||
encoding). Filtered data consists mostly of small values with a somewhat
|
||||
random distribution. In this case, the compression algorithm is tuned to
|
||||
compress them better. The effect of Z_FILTERED is to force more Huffman
|
||||
coding and less string matching; it is somewhat intermediate between
|
||||
Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as
|
||||
fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The
|
||||
strategy parameter only affects the compression ratio but not the
|
||||
correctness of the compressed output even if it is not set appropriately.
|
||||
Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
|
||||
decoder for special applications.
|
||||
filter (or predictor), Z_RLE to limit match distances to one (run-length
|
||||
encoding), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string
|
||||
matching). Filtered data consists mostly of small values with a somewhat
|
||||
random distribution, as produced by the PNG filters. In this case, the
|
||||
compression algorithm is tuned to compress them better. The effect of
|
||||
Z_FILTERED is to force more Huffman coding and less string matching than the
|
||||
default; it is intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.
|
||||
Z_RLE is almost as fast as Z_HUFFMAN_ONLY, but should give better
|
||||
compression for PNG image data than Huffman only. The degree of string
|
||||
matching from most to none is: Z_DEFAULT_STRATEGY, Z_FILTERED, Z_RLE, then
|
||||
Z_HUFFMAN_ONLY. The strategy parameter affects the compression ratio but
|
||||
never the correctness of the compressed output, even if it is not set
|
||||
optimally for the given data. Z_FIXED uses the default string matching, but
|
||||
prevents the use of dynamic Huffman codes, allowing for a simpler decoder
|
||||
for special applications.
|
||||
|
||||
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
|
||||
@@ -609,8 +616,8 @@ ZEXTERN int ZEXPORT deflateInit2(z_streamp strm,
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength);
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength);
|
||||
/*
|
||||
Initializes the compression dictionary from the given byte sequence
|
||||
without producing any compressed output. When using the zlib format, this
|
||||
@@ -653,8 +660,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm,
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm,
|
||||
Bytef *dictionary,
|
||||
uInt *dictLength);
|
||||
Bytef *dictionary,
|
||||
uInt *dictLength);
|
||||
/*
|
||||
Returns the sliding dictionary being maintained by deflate. dictLength is
|
||||
set to the number of bytes in the dictionary, and that many bytes are copied
|
||||
@@ -788,6 +795,18 @@ ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
|
||||
stream state was inconsistent.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateUsed(z_streamp strm,
|
||||
int *bits);
|
||||
/*
|
||||
deflateUsed() returns in *bits the most recent number of deflate bits used
|
||||
in the last byte when flushing to a byte boundary. The result is in 1..8, or
|
||||
0 if there has not yet been a flush. This helps determine the location of
|
||||
the last bit of a deflate stream.
|
||||
|
||||
deflateUsed returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
|
||||
int bits,
|
||||
int value);
|
||||
@@ -886,8 +905,8 @@ ZEXTERN int ZEXPORT inflateInit2(z_streamp strm,
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength);
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength);
|
||||
/*
|
||||
Initializes the decompression dictionary from the given uncompressed byte
|
||||
sequence. This function must be called immediately after a call of inflate,
|
||||
@@ -909,8 +928,8 @@ ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm,
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm,
|
||||
Bytef *dictionary,
|
||||
uInt *dictLength);
|
||||
Bytef *dictionary,
|
||||
uInt *dictLength);
|
||||
/*
|
||||
Returns the sliding dictionary being maintained by inflate. dictLength is
|
||||
set to the number of bytes in the dictionary, and that many bytes are copied
|
||||
@@ -987,13 +1006,15 @@ ZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
|
||||
int bits,
|
||||
int value);
|
||||
/*
|
||||
This function inserts bits in the inflate input stream. The intent is
|
||||
that this function is used to start inflating at a bit position in the
|
||||
middle of a byte. The provided bits will be used before any bytes are used
|
||||
from next_in. This function should only be used with raw inflate, and
|
||||
should be used before the first inflate() call after inflateInit2() or
|
||||
inflateReset(). bits must be less than or equal to 16, and that many of the
|
||||
least significant bits of value will be inserted in the input.
|
||||
This function inserts bits in the inflate input stream. The intent is to
|
||||
use inflatePrime() to start inflating at a bit position in the middle of a
|
||||
byte. The provided bits will be used before any bytes are used from
|
||||
next_in. This function should be used with raw inflate, before the first
|
||||
inflate() call, after inflateInit2() or inflateReset(). It can also be used
|
||||
after an inflate() return indicates the end of a deflate block or header
|
||||
when using Z_BLOCK. bits must be less than or equal to 16, and that many of
|
||||
the least significant bits of value will be inserted in the input. The
|
||||
other bits in value can be non-zero, and will be ignored.
|
||||
|
||||
If bits is negative, then the input stream bit buffer is emptied. Then
|
||||
inflatePrime() can be called again to put bits in the buffer. This is used
|
||||
@@ -1001,7 +1022,15 @@ ZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
|
||||
to feeding inflate codes.
|
||||
|
||||
inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent.
|
||||
stream state was inconsistent, or if bits is out of range. If inflate was
|
||||
in the middle of processing a header, trailer, or stored block lengths, then
|
||||
it is possible for there to be only eight bits available in the bit buffer.
|
||||
In that case, bits > 8 is considered out of range. However, when used as
|
||||
outlined above, there will always be 16 bits available in the buffer for
|
||||
insertion. As noted in its documentation above, inflate records the number
|
||||
of bits in the bit buffer on return in data_type. 32 minus that is the
|
||||
number of bits available for insertion. inflatePrime does not update
|
||||
data_type with the new number of bits in buffer.
|
||||
*/
|
||||
|
||||
ZEXTERN long ZEXPORT inflateMark(z_streamp strm);
|
||||
@@ -1047,20 +1076,22 @@ ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm,
|
||||
|
||||
The text, time, xflags, and os fields are filled in with the gzip header
|
||||
contents. hcrc is set to true if there is a header CRC. (The header CRC
|
||||
was valid if done is set to one.) If extra is not Z_NULL, then extra_max
|
||||
contains the maximum number of bytes to write to extra. Once done is true,
|
||||
extra_len contains the actual extra field length, and extra contains the
|
||||
extra field, or that field truncated if extra_max is less than extra_len.
|
||||
If name is not Z_NULL, then up to name_max characters are written there,
|
||||
terminated with a zero unless the length is greater than name_max. If
|
||||
comment is not Z_NULL, then up to comm_max characters are written there,
|
||||
terminated with a zero unless the length is greater than comm_max. When any
|
||||
of extra, name, or comment are not Z_NULL and the respective field is not
|
||||
present in the header, then that field is set to Z_NULL to signal its
|
||||
absence. This allows the use of deflateSetHeader() with the returned
|
||||
structure to duplicate the header. However if those fields are set to
|
||||
allocated memory, then the application will need to save those pointers
|
||||
elsewhere so that they can be eventually freed.
|
||||
was valid if done is set to one.) The extra, name, and comment pointers
|
||||
much each be either Z_NULL or point to space to store that information from
|
||||
the header. If extra is not Z_NULL, then extra_max contains the maximum
|
||||
number of bytes that can be written to extra. Once done is true, extra_len
|
||||
contains the actual extra field length, and extra contains the extra field,
|
||||
or that field truncated if extra_max is less than extra_len. If name is not
|
||||
Z_NULL, then up to name_max characters, including the terminating zero, are
|
||||
written there. If comment is not Z_NULL, then up to comm_max characters,
|
||||
including the terminating zero, are written there. The application can tell
|
||||
that the name or comment did not fit in the provided space by the absence of
|
||||
a terminating zero. If any of extra, name, or comment are not present in
|
||||
the header, then that field's pointer is set to Z_NULL. This allows the use
|
||||
of deflateSetHeader() with the returned structure to duplicate the header.
|
||||
Note that if those fields initially pointed to allocated memory, then the
|
||||
application will need to save them elsewhere so that they can be eventually
|
||||
freed.
|
||||
|
||||
If inflateGetHeader is not used, then the header information is simply
|
||||
discarded. The header is always checked for validity, including the header
|
||||
@@ -1219,7 +1250,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags(void);
|
||||
|
||||
#ifndef Z_SOLO
|
||||
|
||||
/* utility functions */
|
||||
/* utility functions */
|
||||
|
||||
/*
|
||||
The following utility functions are implemented on top of the basic
|
||||
@@ -1293,7 +1324,7 @@ ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen,
|
||||
source bytes consumed.
|
||||
*/
|
||||
|
||||
/* gzip file access functions */
|
||||
/* gzip file access functions */
|
||||
|
||||
/*
|
||||
This library supports reading and writing files in gzip (.gz) format with
|
||||
@@ -1314,13 +1345,17 @@ ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
|
||||
'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
|
||||
as in "wb9F". (See the description of deflateInit2 for more information
|
||||
about the strategy parameter.) 'T' will request transparent writing or
|
||||
appending with no compression and not using the gzip format.
|
||||
appending with no compression and not using the gzip format. 'T' cannot be
|
||||
used to force transparent reading. Transparent reading is automatically
|
||||
performed if there is no gzip header at the start. Transparent reading can
|
||||
be disabled with the 'G' option, which will instead return an error if there
|
||||
is no gzip header. 'N' will open the file in non-blocking mode.
|
||||
|
||||
"a" can be used instead of "w" to request that the gzip stream that will
|
||||
be written be appended to the file. "+" will result in an error, since
|
||||
'a' can be used instead of 'w' to request that the gzip stream that will
|
||||
be written be appended to the file. '+' will result in an error, since
|
||||
reading and writing to the same gzip file is not supported. The addition of
|
||||
"x" when writing will create the file exclusively, which fails if the file
|
||||
already exists. On systems that support it, the addition of "e" when
|
||||
'x' when writing will create the file exclusively, which fails if the file
|
||||
already exists. On systems that support it, the addition of 'e' when
|
||||
reading or writing will set the flag to close the file on an execve() call.
|
||||
|
||||
These functions, as well as gzip, will read and decode a sequence of gzip
|
||||
@@ -1339,14 +1374,22 @@ ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
|
||||
insufficient memory to allocate the gzFile state, or if an invalid mode was
|
||||
specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
|
||||
errno can be checked to determine if the reason gzopen failed was that the
|
||||
file could not be opened.
|
||||
file could not be opened. Note that if 'N' is in mode for non-blocking, the
|
||||
open() itself can fail in order to not block. In that case gzopen() will
|
||||
return NULL and errno will be EAGAIN or ENONBLOCK. The call to gzopen() can
|
||||
then be re-tried. If the application would like to block on opening the
|
||||
file, then it can use open() without O_NONBLOCK, and then gzdopen() with the
|
||||
resulting file descriptor and 'N' in the mode, which will set it to non-
|
||||
blocking.
|
||||
*/
|
||||
|
||||
ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode);
|
||||
/*
|
||||
Associate a gzFile with the file descriptor fd. File descriptors are
|
||||
obtained from calls like open, dup, creat, pipe or fileno (if the file has
|
||||
been previously opened with fopen). The mode parameter is as in gzopen.
|
||||
been previously opened with fopen). The mode parameter is as in gzopen. An
|
||||
'e' in mode will set fd's flag to close the file on an execve() call. An 'N'
|
||||
in mode will set fd's non-blocking flag.
|
||||
|
||||
The next call of gzclose on the returned gzFile will also close the file
|
||||
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
|
||||
@@ -1416,10 +1459,16 @@ ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len);
|
||||
stream. Alternatively, gzerror can be used before gzclose to detect this
|
||||
case.
|
||||
|
||||
gzread can be used to read a gzip file on a non-blocking device. If the
|
||||
input stalls and there is no uncompressed data to return, then gzread() will
|
||||
return -1, and errno will be EAGAIN or EWOULDBLOCK. gzread() can then be
|
||||
called again.
|
||||
|
||||
gzread returns the number of uncompressed bytes actually read, less than
|
||||
len for end of file, or -1 for error. If len is too large to fit in an int,
|
||||
then nothing is read, -1 is returned, and the error state is set to
|
||||
Z_STREAM_ERROR.
|
||||
Z_STREAM_ERROR. If some data was read before an error, then that data is
|
||||
returned until exhausted, after which the next call will signal the error.
|
||||
*/
|
||||
|
||||
ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
|
||||
@@ -1443,15 +1492,20 @@ ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
|
||||
multiple of size, then the final partial item is nevertheless read into buf
|
||||
and the end-of-file flag is set. The length of the partial item read is not
|
||||
provided, but could be inferred from the result of gztell(). This behavior
|
||||
is the same as the behavior of fread() implementations in common libraries,
|
||||
but it prevents the direct use of gzfread() to read a concurrently written
|
||||
file, resetting and retrying on end-of-file, when size is not 1.
|
||||
is the same as that of fread() implementations in common libraries. This
|
||||
could result in data loss if used with size != 1 when reading a concurrently
|
||||
written file or a non-blocking file. In that case, use size == 1 or gzread()
|
||||
instead.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len);
|
||||
/*
|
||||
Compress and write the len uncompressed bytes at buf to file. gzwrite
|
||||
returns the number of uncompressed bytes written or 0 in case of error.
|
||||
returns the number of uncompressed bytes written, or 0 in case of error or
|
||||
if len is 0. If the write destination is non-blocking, then gzwrite() may
|
||||
return a number of bytes written that is not 0 and less than len.
|
||||
|
||||
If len does not fit in an int, then 0 is returned and nothing is written.
|
||||
*/
|
||||
|
||||
ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
|
||||
@@ -1466,6 +1520,11 @@ ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
|
||||
if there was an error. If the multiplication of size and nitems overflows,
|
||||
i.e. the product does not fit in a z_size_t, then nothing is written, zero
|
||||
is returned, and the error state is set to Z_STREAM_ERROR.
|
||||
|
||||
If writing a concurrently read file or a non-blocking file with size != 1,
|
||||
a partial item could be written, with no way of knowing how much of it was
|
||||
not written, resulting in data loss. In that case, use size == 1 or
|
||||
gzwrite() instead.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...);
|
||||
@@ -1481,6 +1540,9 @@ ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...);
|
||||
zlib was compiled with the insecure functions sprintf() or vsprintf(),
|
||||
because the secure snprintf() or vsnprintf() functions were not available.
|
||||
This can be determined using zlibCompileFlags().
|
||||
|
||||
If a Z_BUF_ERROR is returned, then nothing was written due to a stall on
|
||||
the non-blocking write destination.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
|
||||
@@ -1489,6 +1551,11 @@ ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
|
||||
the terminating null character.
|
||||
|
||||
gzputs returns the number of characters written, or -1 in case of error.
|
||||
The number of characters written may be less than the length of the string
|
||||
if the write destination is non-blocking.
|
||||
|
||||
If the length of the string does not fit in an int, then -1 is returned
|
||||
and nothing is written.
|
||||
*/
|
||||
|
||||
ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len);
|
||||
@@ -1501,8 +1568,13 @@ ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len);
|
||||
left untouched.
|
||||
|
||||
gzgets returns buf which is a null-terminated string, or it returns NULL
|
||||
for end-of-file or in case of error. If there was an error, the contents at
|
||||
buf are indeterminate.
|
||||
for end-of-file or in case of error. If some data was read before an error,
|
||||
then that data is returned until exhausted, after which the next call will
|
||||
return NULL to signal the error.
|
||||
|
||||
gzgets can be used on a file being concurrently written, and on a non-
|
||||
blocking device, both as for gzread(). However lines may be broken in the
|
||||
middle, leaving it up to the application to reassemble them as needed.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputc(gzFile file, int c);
|
||||
@@ -1513,11 +1585,19 @@ ZEXTERN int ZEXPORT gzputc(gzFile file, int c);
|
||||
|
||||
ZEXTERN int ZEXPORT gzgetc(gzFile file);
|
||||
/*
|
||||
Read and decompress one byte from file. gzgetc returns this byte or -1
|
||||
in case of end of file or error. This is implemented as a macro for speed.
|
||||
As such, it does not do all of the checking the other functions do. I.e.
|
||||
it does not check to see if file is NULL, nor whether the structure file
|
||||
points to has been clobbered or not.
|
||||
Read and decompress one byte from file. gzgetc returns this byte or -1 in
|
||||
case of end of file or error. If some data was read before an error, then
|
||||
that data is returned until exhausted, after which the next call will return
|
||||
-1 to signal the error.
|
||||
|
||||
This is implemented as a macro for speed. As such, it does not do all of
|
||||
the checking the other functions do. I.e. it does not check to see if file
|
||||
is NULL, nor whether the structure file points to has been clobbered or not.
|
||||
|
||||
gzgetc can be used to read a gzip file on a non-blocking device. If the
|
||||
input stalls and there is no uncompressed data to return, then gzgetc() will
|
||||
return -1, and errno will be EAGAIN or EWOULDBLOCK. gzread() can then be
|
||||
called again.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzungetc(int c, gzFile file);
|
||||
@@ -1530,6 +1610,11 @@ ZEXTERN int ZEXPORT gzungetc(int c, gzFile file);
|
||||
output buffer size of pushed characters is allowed. (See gzbuffer above.)
|
||||
The pushed character will be discarded if the stream is repositioned with
|
||||
gzseek() or gzrewind().
|
||||
|
||||
gzungetc(-1, file) will force any pending seek to execute. Then gztell()
|
||||
will report the position, even if the requested seek reached end of file.
|
||||
This can be used to determine the number of uncompressed bytes in a gzip
|
||||
file without having to read it into a buffer.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzflush(gzFile file, int flush);
|
||||
@@ -1559,7 +1644,8 @@ ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
|
||||
If the file is opened for reading, this function is emulated but can be
|
||||
extremely slow. If the file is opened for writing, only forward seeks are
|
||||
supported; gzseek then compresses a sequence of zeroes up to the new
|
||||
starting position.
|
||||
starting position. For reading or writing, any actual seeking is deferred
|
||||
until the next read or write operation, or close operation when writing.
|
||||
|
||||
gzseek returns the resulting offset location as measured in bytes from
|
||||
the beginning of the uncompressed stream, or -1 in case of error, in
|
||||
@@ -1567,7 +1653,7 @@ ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
|
||||
would be before the current position.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzrewind(gzFile file);
|
||||
ZEXTERN int ZEXPORT gzrewind(gzFile file);
|
||||
/*
|
||||
Rewind file. This function is supported only for reading.
|
||||
|
||||
@@ -1575,7 +1661,7 @@ ZEXTERN int ZEXPORT gzrewind(gzFile file);
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN z_off_t ZEXPORT gztell(gzFile file);
|
||||
ZEXTERN z_off_t ZEXPORT gztell(gzFile file);
|
||||
|
||||
Return the starting position for the next gzread or gzwrite on file.
|
||||
This position represents a number of bytes in the uncompressed data stream,
|
||||
@@ -1620,8 +1706,11 @@ ZEXTERN int ZEXPORT gzdirect(gzFile file);
|
||||
|
||||
If gzdirect() is used immediately after gzopen() or gzdopen() it will
|
||||
cause buffers to be allocated to allow reading the file to determine if it
|
||||
is a gzip file. Therefore if gzbuffer() is used, it should be called before
|
||||
gzdirect().
|
||||
is a gzip file. Therefore if gzbuffer() is used, it should be called before
|
||||
gzdirect(). If the input is being written concurrently or the device is non-
|
||||
blocking, then gzdirect() may give a different answer once four bytes of
|
||||
input have been accumulated, which is what is needed to confirm or deny a
|
||||
gzip header. Before this, gzdirect() will return true (1).
|
||||
|
||||
When writing, gzdirect() returns true (1) if transparent writing was
|
||||
requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
|
||||
@@ -1631,7 +1720,7 @@ ZEXTERN int ZEXPORT gzdirect(gzFile file);
|
||||
gzip file reading and decompression, which may not be desired.)
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzclose(gzFile file);
|
||||
ZEXTERN int ZEXPORT gzclose(gzFile file);
|
||||
/*
|
||||
Flush all pending output for file, if necessary, close file and
|
||||
deallocate the (de)compression state. Note that once file is closed, you
|
||||
@@ -1659,9 +1748,10 @@ ZEXTERN int ZEXPORT gzclose_w(gzFile file);
|
||||
ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
|
||||
/*
|
||||
Return the error message for the last error which occurred on file.
|
||||
errnum is set to zlib error number. If an error occurred in the file system
|
||||
and not in the compression library, errnum is set to Z_ERRNO and the
|
||||
application may consult errno to get the exact error code.
|
||||
If errnum is not NULL, *errnum is set to zlib error number. If an error
|
||||
occurred in the file system and not in the compression library, *errnum is
|
||||
set to Z_ERRNO and the application may consult errno to get the exact error
|
||||
code.
|
||||
|
||||
The application must not modify the returned string. Future calls to
|
||||
this function may invalidate the previously returned string. If file is
|
||||
@@ -1681,7 +1771,7 @@ ZEXTERN void ZEXPORT gzclearerr(gzFile file);
|
||||
|
||||
#endif /* !Z_SOLO */
|
||||
|
||||
/* checksum functions */
|
||||
/* checksum functions */
|
||||
|
||||
/*
|
||||
These functions are not related to compression but are exported
|
||||
@@ -1776,7 +1866,7 @@ ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);
|
||||
*/
|
||||
|
||||
|
||||
/* various hacks, don't look :) */
|
||||
/* various hacks, don't look :) */
|
||||
|
||||
/* deflateInit and inflateInit are macros to allow checking the zlib version
|
||||
* and the compiler's view of z_stream:
|
||||
@@ -1856,13 +1946,13 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */
|
||||
* without large file support, _LFS64_LARGEFILE must also be true
|
||||
*/
|
||||
#ifdef Z_LARGE64
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
|
||||
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
|
||||
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
|
||||
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
|
||||
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
|
||||
#endif
|
||||
|
||||
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
|
||||
@@ -1884,29 +1974,29 @@ ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
|
||||
# define crc32_combine_gen crc32_combine_gen64
|
||||
# endif
|
||||
# ifndef Z_LARGE64
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
|
||||
ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
|
||||
ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
|
||||
ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
|
||||
ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
|
||||
# endif
|
||||
#else
|
||||
ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *);
|
||||
ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int);
|
||||
ZEXTERN z_off_t ZEXPORT gztell(gzFile);
|
||||
ZEXTERN z_off_t ZEXPORT gzoffset(gzFile);
|
||||
ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
|
||||
ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *);
|
||||
ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int);
|
||||
ZEXTERN z_off_t ZEXPORT gztell(gzFile);
|
||||
ZEXTERN z_off_t ZEXPORT gzoffset(gzFile);
|
||||
ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
|
||||
#endif
|
||||
|
||||
#else /* Z_SOLO */
|
||||
|
||||
ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
|
||||
ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
|
||||
|
||||
#endif /* !Z_SOLO */
|
||||
|
||||
@@ -1926,8 +2016,8 @@ ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path,
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifndef Z_SOLO
|
||||
ZEXTERN int ZEXPORTVA gzvprintf(gzFile file,
|
||||
const char *format,
|
||||
va_list va);
|
||||
const char *format,
|
||||
va_list va);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user