mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 10:13:51 +01:00
* update(zlib): Version 1.3.1 in module PDF (#4582) * update(zlib): remove gzio from VS project files and Makefile
This commit is contained in:
parent
94a693dff5
commit
b85b49643e
@ -72,7 +72,7 @@ else()
|
|||||||
POCO_HEADERS(SRCS zlib
|
POCO_HEADERS(SRCS zlib
|
||||||
include/Poco/zconf.h
|
include/Poco/zconf.h
|
||||||
include/Poco/zlib.h
|
include/Poco/zlib.h
|
||||||
)
|
)
|
||||||
|
|
||||||
POCO_SOURCES(SRCS zlib
|
POCO_SOURCES(SRCS zlib
|
||||||
src/adler32.c
|
src/adler32.c
|
||||||
|
@ -17,7 +17,6 @@ else()
|
|||||||
src/compress.c
|
src/compress.c
|
||||||
src/crc32.c
|
src/crc32.c
|
||||||
src/deflate.c
|
src/deflate.c
|
||||||
src/gzio.c
|
|
||||||
src/infback.c
|
src/infback.c
|
||||||
src/inffast.c
|
src/inffast.c
|
||||||
src/inflate.c
|
src/inflate.c
|
||||||
|
@ -21,7 +21,7 @@ objects = AttributedString Cell Destination Document Encoder Font Image Outline
|
|||||||
hpdf_image_png hpdf_info hpdf_list hpdf_mmgr hpdf_name hpdf_namedict hpdf_null \
|
hpdf_image_png hpdf_info hpdf_list hpdf_mmgr hpdf_name hpdf_namedict hpdf_null \
|
||||||
hpdf_number hpdf_objects hpdf_outline hpdf_page_label hpdf_page_operator \
|
hpdf_number hpdf_objects hpdf_outline hpdf_page_label hpdf_page_operator \
|
||||||
hpdf_pages hpdf_pdfa hpdf_real hpdf_streams hpdf_string hpdf_u3d hpdf_utils hpdf_xref \
|
hpdf_pages hpdf_pdfa hpdf_real hpdf_streams hpdf_string hpdf_u3d hpdf_utils hpdf_xref \
|
||||||
adler32 compress crc32 deflate gzio \
|
adler32 compress crc32 deflate \
|
||||||
infback inffast inflate inftrees trees zutil \
|
infback inffast inflate inftrees trees zutil \
|
||||||
png pngerror pnggccrd pngget pngmem pngpread \
|
png pngerror pnggccrd pngget pngmem pngpread \
|
||||||
pngread pngrio pngrtran pngrutil pngset pngtest \
|
pngread pngrio pngrtran pngrutil pngset pngtest \
|
||||||
|
@ -635,11 +635,6 @@
|
|||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\gzio.c">
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
|
||||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\hpdf_3dmeasure.c">
|
<ClCompile Include="src\hpdf_3dmeasure.c">
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -147,9 +147,6 @@
|
|||||||
<ClCompile Include="src\deflate.c">
|
<ClCompile Include="src\deflate.c">
|
||||||
<Filter>3rd Party\zlib\Source Files</Filter>
|
<Filter>3rd Party\zlib\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\gzio.c">
|
|
||||||
<Filter>3rd Party\zlib\Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\infback.c">
|
<ClCompile Include="src\infback.c">
|
||||||
<Filter>3rd Party\zlib\Source Files</Filter>
|
<Filter>3rd Party\zlib\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -919,11 +919,6 @@
|
|||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\gzio.c">
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
|
||||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\hpdf_3dmeasure.c">
|
<ClCompile Include="src\hpdf_3dmeasure.c">
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -147,9 +147,6 @@
|
|||||||
<ClCompile Include="src\deflate.c">
|
<ClCompile Include="src\deflate.c">
|
||||||
<Filter>3rd Party\zlib\Source Files</Filter>
|
<Filter>3rd Party\zlib\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\gzio.c">
|
|
||||||
<Filter>3rd Party\zlib\Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\infback.c">
|
<ClCompile Include="src\infback.c">
|
||||||
<Filter>3rd Party\zlib\Source Files</Filter>
|
<Filter>3rd Party\zlib\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -766,10 +766,6 @@
|
|||||||
RelativePath=".\src\deflate.c"
|
RelativePath=".\src\deflate.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\gzio.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\infback.c"
|
RelativePath=".\src\infback.c"
|
||||||
>
|
>
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
|
||||||
|
|
||||||
#define ZLIB_INTERNAL
|
|
||||||
#include "zlib.h"
|
|
||||||
|
|
||||||
#define BASE 65521UL /* largest prime smaller than 65536 */
|
|
||||||
#define NMAX 5552
|
|
||||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
|
||||||
|
|
||||||
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
|
||||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
|
||||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
|
||||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
|
||||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
|
||||||
|
|
||||||
/* use NO_DIVIDE if your processor does not do division in hardware */
|
|
||||||
#ifdef NO_DIVIDE
|
|
||||||
# define MOD(a) \
|
|
||||||
do { \
|
|
||||||
if (a >= (BASE << 16)) a -= (BASE << 16); \
|
|
||||||
if (a >= (BASE << 15)) a -= (BASE << 15); \
|
|
||||||
if (a >= (BASE << 14)) a -= (BASE << 14); \
|
|
||||||
if (a >= (BASE << 13)) a -= (BASE << 13); \
|
|
||||||
if (a >= (BASE << 12)) a -= (BASE << 12); \
|
|
||||||
if (a >= (BASE << 11)) a -= (BASE << 11); \
|
|
||||||
if (a >= (BASE << 10)) a -= (BASE << 10); \
|
|
||||||
if (a >= (BASE << 9)) a -= (BASE << 9); \
|
|
||||||
if (a >= (BASE << 8)) a -= (BASE << 8); \
|
|
||||||
if (a >= (BASE << 7)) a -= (BASE << 7); \
|
|
||||||
if (a >= (BASE << 6)) a -= (BASE << 6); \
|
|
||||||
if (a >= (BASE << 5)) a -= (BASE << 5); \
|
|
||||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
|
||||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
|
||||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
|
||||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
|
||||||
if (a >= BASE) a -= BASE; \
|
|
||||||
} while (0)
|
|
||||||
# define MOD4(a) \
|
|
||||||
do { \
|
|
||||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
|
||||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
|
||||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
|
||||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
|
||||||
if (a >= BASE) a -= BASE; \
|
|
||||||
} while (0)
|
|
||||||
#else
|
|
||||||
# define MOD(a) a %= BASE
|
|
||||||
# define MOD4(a) a %= BASE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ========================================================================= */
|
|
||||||
uLong ZEXPORT adler32(adler, buf, len)
|
|
||||||
uLong adler;
|
|
||||||
const Bytef *buf;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
unsigned long sum2;
|
|
||||||
unsigned n;
|
|
||||||
|
|
||||||
/* split Adler-32 into component sums */
|
|
||||||
sum2 = (adler >> 16) & 0xffff;
|
|
||||||
adler &= 0xffff;
|
|
||||||
|
|
||||||
/* in case user likes doing a byte at a time, keep it fast */
|
|
||||||
if (len == 1) {
|
|
||||||
adler += buf[0];
|
|
||||||
if (adler >= BASE)
|
|
||||||
adler -= BASE;
|
|
||||||
sum2 += adler;
|
|
||||||
if (sum2 >= BASE)
|
|
||||||
sum2 -= BASE;
|
|
||||||
return adler | (sum2 << 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
|
||||||
if (buf == Z_NULL)
|
|
||||||
return 1L;
|
|
||||||
|
|
||||||
/* in case short lengths are provided, keep it somewhat fast */
|
|
||||||
if (len < 16) {
|
|
||||||
while (len--) {
|
|
||||||
adler += *buf++;
|
|
||||||
sum2 += adler;
|
|
||||||
}
|
|
||||||
if (adler >= BASE)
|
|
||||||
adler -= BASE;
|
|
||||||
MOD4(sum2); /* only added so many BASE's */
|
|
||||||
return adler | (sum2 << 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do length NMAX blocks -- requires just one modulo operation */
|
|
||||||
while (len >= NMAX) {
|
|
||||||
len -= NMAX;
|
|
||||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
|
||||||
do {
|
|
||||||
DO16(buf); /* 16 sums unrolled */
|
|
||||||
buf += 16;
|
|
||||||
} while (--n);
|
|
||||||
MOD(adler);
|
|
||||||
MOD(sum2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
|
||||||
if (len) { /* avoid modulos if none remaining */
|
|
||||||
while (len >= 16) {
|
|
||||||
len -= 16;
|
|
||||||
DO16(buf);
|
|
||||||
buf += 16;
|
|
||||||
}
|
|
||||||
while (len--) {
|
|
||||||
adler += *buf++;
|
|
||||||
sum2 += adler;
|
|
||||||
}
|
|
||||||
MOD(adler);
|
|
||||||
MOD(sum2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return recombined sums */
|
|
||||||
return adler | (sum2 << 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========================================================================= */
|
|
||||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
|
||||||
uLong adler1;
|
|
||||||
uLong adler2;
|
|
||||||
z_off_t len2;
|
|
||||||
{
|
|
||||||
unsigned long sum1;
|
|
||||||
unsigned long sum2;
|
|
||||||
unsigned rem;
|
|
||||||
|
|
||||||
/* the derivation of this formula is left as an exercise for the reader */
|
|
||||||
rem = (unsigned)(len2 % BASE);
|
|
||||||
sum1 = adler1 & 0xffff;
|
|
||||||
sum2 = rem * sum1;
|
|
||||||
MOD(sum2);
|
|
||||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
|
||||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
|
||||||
if (sum1 > BASE) sum1 -= BASE;
|
|
||||||
if (sum1 > BASE) sum1 -= BASE;
|
|
||||||
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
|
|
||||||
if (sum2 > BASE) sum2 -= BASE;
|
|
||||||
return sum1 | (sum2 << 16);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/* deflate.h -- internal compression state
|
/* deflate.h -- internal compression state
|
||||||
* Copyright (C) 1995-2004 Jean-loup Gailly
|
* Copyright (C) 1995-2024 Jean-loup Gailly
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -8,7 +8,7 @@
|
|||||||
subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id: //poco/Main/Foundation/src/deflate.h#8 $ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#ifndef DEFLATE_H
|
#ifndef DEFLATE_H
|
||||||
#define DEFLATE_H
|
#define DEFLATE_H
|
||||||
@ -23,6 +23,10 @@
|
|||||||
# define GZIP
|
# define GZIP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
|
||||||
|
the cost of a larger memory footprint */
|
||||||
|
/* #define LIT_MEM */
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Internal compression state.
|
* Internal compression state.
|
||||||
*/
|
*/
|
||||||
@ -48,13 +52,19 @@
|
|||||||
#define MAX_BITS 15
|
#define MAX_BITS 15
|
||||||
/* All codes must not exceed MAX_BITS bits */
|
/* All codes must not exceed MAX_BITS bits */
|
||||||
|
|
||||||
#define INIT_STATE 42
|
#define Buf_size 16
|
||||||
#define EXTRA_STATE 69
|
/* size of bit buffer in bi_buf */
|
||||||
#define NAME_STATE 73
|
|
||||||
#define COMMENT_STATE 91
|
#define INIT_STATE 42 /* zlib header -> BUSY_STATE */
|
||||||
#define HCRC_STATE 103
|
#ifdef GZIP
|
||||||
#define BUSY_STATE 113
|
# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */
|
||||||
#define FINISH_STATE 666
|
#endif
|
||||||
|
#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */
|
||||||
|
#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */
|
||||||
|
#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */
|
||||||
|
#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */
|
||||||
|
#define BUSY_STATE 113 /* deflate -> FINISH_STATE */
|
||||||
|
#define FINISH_STATE 666 /* stream complete */
|
||||||
/* Stream status */
|
/* Stream status */
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +90,7 @@ typedef struct static_tree_desc_s static_tree_desc;
|
|||||||
typedef struct tree_desc_s {
|
typedef struct tree_desc_s {
|
||||||
ct_data *dyn_tree; /* the dynamic tree */
|
ct_data *dyn_tree; /* the dynamic tree */
|
||||||
int max_code; /* largest code with non zero frequency */
|
int max_code; /* largest code with non zero frequency */
|
||||||
static_tree_desc *stat_desc; /* the corresponding static tree */
|
const static_tree_desc *stat_desc; /* the corresponding static tree */
|
||||||
} FAR tree_desc;
|
} FAR tree_desc;
|
||||||
|
|
||||||
typedef ush Pos;
|
typedef ush Pos;
|
||||||
@ -97,11 +107,11 @@ typedef struct internal_state {
|
|||||||
Bytef *pending_buf; /* output still pending */
|
Bytef *pending_buf; /* output still pending */
|
||||||
ulg pending_buf_size; /* size of pending_buf */
|
ulg pending_buf_size; /* size of pending_buf */
|
||||||
Bytef *pending_out; /* next pending byte to output to the stream */
|
Bytef *pending_out; /* next pending byte to output to the stream */
|
||||||
uInt pending; /* nb of bytes in the pending buffer */
|
ulg pending; /* nb of bytes in the pending buffer */
|
||||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||||
gz_headerp gzhead; /* gzip header information to write */
|
gz_headerp gzhead; /* gzip header information to write */
|
||||||
uInt gzindex; /* where in extra, name, or comment */
|
ulg gzindex; /* where in extra, name, or comment */
|
||||||
Byte method; /* STORED (for zip only) or DEFLATED */
|
Byte method; /* can only be DEFLATED */
|
||||||
int last_flush; /* value of flush param for previous deflate call */
|
int last_flush; /* value of flush param for previous deflate call */
|
||||||
|
|
||||||
/* used by deflate.c: */
|
/* used by deflate.c: */
|
||||||
@ -188,7 +198,7 @@ typedef struct internal_state {
|
|||||||
int nice_match; /* Stop searching when current match exceeds this */
|
int nice_match; /* Stop searching when current match exceeds this */
|
||||||
|
|
||||||
/* used by trees.c: */
|
/* used by trees.c: */
|
||||||
/* Didn't use ct_data typedef below to supress compiler warning */
|
/* Didn't use ct_data typedef below to suppress compiler warning */
|
||||||
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
||||||
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
|
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
|
||||||
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
|
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
|
||||||
@ -211,7 +221,14 @@ typedef struct internal_state {
|
|||||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uchf *l_buf; /* buffer for literals or lengths */
|
#ifdef LIT_MEM
|
||||||
|
# define LIT_BUFS 5
|
||||||
|
ushf *d_buf; /* buffer for distances */
|
||||||
|
uchf *l_buf; /* buffer for literals/lengths */
|
||||||
|
#else
|
||||||
|
# define LIT_BUFS 4
|
||||||
|
uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||||
|
#endif
|
||||||
|
|
||||||
uInt lit_bufsize;
|
uInt lit_bufsize;
|
||||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||||
@ -233,18 +250,13 @@ typedef struct internal_state {
|
|||||||
* - I can't count above 4
|
* - I can't count above 4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uInt last_lit; /* running index in l_buf */
|
uInt sym_next; /* running index in symbol buffer */
|
||||||
|
uInt sym_end; /* symbol table full when sym_next reaches this */
|
||||||
ushf *d_buf;
|
|
||||||
/* Buffer for distances. To simplify the code, d_buf and l_buf have
|
|
||||||
* the same number of elements. To use different lengths, an extra flag
|
|
||||||
* array would be necessary.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ulg opt_len; /* bit length of current block with optimal trees */
|
ulg opt_len; /* bit length of current block with optimal trees */
|
||||||
ulg static_len; /* bit length of current block with static trees */
|
ulg static_len; /* bit length of current block with static trees */
|
||||||
uInt matches; /* number of string matches in current block */
|
uInt matches; /* number of string matches in current block */
|
||||||
int last_eob_len; /* bit length of EOB code for last block */
|
uInt insert; /* bytes at end of window left to insert */
|
||||||
|
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
||||||
@ -260,12 +272,19 @@ typedef struct internal_state {
|
|||||||
* are always zero.
|
* are always zero.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ulg high_water;
|
||||||
|
/* High water mark offset in window for initialized bytes -- bytes above
|
||||||
|
* this are set to zero in order to avoid memory check warnings when
|
||||||
|
* longest match routines access bytes past the input. This is then
|
||||||
|
* updated to the new high water mark.
|
||||||
|
*/
|
||||||
|
|
||||||
} FAR deflate_state;
|
} FAR deflate_state;
|
||||||
|
|
||||||
/* Output a byte on the stream.
|
/* Output a byte on the stream.
|
||||||
* IN assertion: there is enough room in pending_buf.
|
* IN assertion: there is enough room in pending_buf.
|
||||||
*/
|
*/
|
||||||
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
|
#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
|
||||||
|
|
||||||
|
|
||||||
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
||||||
@ -278,14 +297,19 @@ typedef struct internal_state {
|
|||||||
* distances are limited to MAX_DIST instead of WSIZE.
|
* distances are limited to MAX_DIST instead of WSIZE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define WIN_INIT MAX_MATCH
|
||||||
|
/* Number of bytes after end of data in window to initialize in order to avoid
|
||||||
|
memory checker errors from longest match routines */
|
||||||
|
|
||||||
/* in trees.c */
|
/* in trees.c */
|
||||||
void _tr_init OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_init(deflate_state *s);
|
||||||
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
|
||||||
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
|
||||||
int eof));
|
ulg stored_len, int last);
|
||||||
void _tr_align OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
|
||||||
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
void ZLIB_INTERNAL _tr_align(deflate_state *s);
|
||||||
int eof));
|
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
|
||||||
|
ulg stored_len, int last);
|
||||||
|
|
||||||
#define d_code(dist) \
|
#define d_code(dist) \
|
||||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||||
@ -298,31 +322,53 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
|||||||
/* Inline versions of _tr_tally for speed: */
|
/* Inline versions of _tr_tally for speed: */
|
||||||
|
|
||||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||||
extern uch _length_code[];
|
extern uch ZLIB_INTERNAL _length_code[];
|
||||||
extern uch _dist_code[];
|
extern uch ZLIB_INTERNAL _dist_code[];
|
||||||
#else
|
#else
|
||||||
extern const uch _length_code[];
|
extern const uch ZLIB_INTERNAL _length_code[];
|
||||||
extern const uch _dist_code[];
|
extern const uch ZLIB_INTERNAL _dist_code[];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIT_MEM
|
||||||
# define _tr_tally_lit(s, c, flush) \
|
# define _tr_tally_lit(s, c, flush) \
|
||||||
{ uch cc = (c); \
|
{ uch cc = (c); \
|
||||||
s->d_buf[s->last_lit] = 0; \
|
s->d_buf[s->sym_next] = 0; \
|
||||||
s->l_buf[s->last_lit++] = cc; \
|
s->l_buf[s->sym_next++] = cc; \
|
||||||
s->dyn_ltree[cc].Freq++; \
|
s->dyn_ltree[cc].Freq++; \
|
||||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
flush = (s->sym_next == s->sym_end); \
|
||||||
}
|
}
|
||||||
# define _tr_tally_dist(s, distance, length, flush) \
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
{ uch len = (length); \
|
{ uch len = (uch)(length); \
|
||||||
ush dist = (distance); \
|
ush dist = (ush)(distance); \
|
||||||
s->d_buf[s->last_lit] = dist; \
|
s->d_buf[s->sym_next] = dist; \
|
||||||
s->l_buf[s->last_lit++] = len; \
|
s->l_buf[s->sym_next++] = len; \
|
||||||
dist--; \
|
dist--; \
|
||||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
flush = (s->sym_next == s->sym_end); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
# define _tr_tally_lit(s, c, flush) \
|
||||||
|
{ uch cc = (c); \
|
||||||
|
s->sym_buf[s->sym_next++] = 0; \
|
||||||
|
s->sym_buf[s->sym_next++] = 0; \
|
||||||
|
s->sym_buf[s->sym_next++] = cc; \
|
||||||
|
s->dyn_ltree[cc].Freq++; \
|
||||||
|
flush = (s->sym_next == s->sym_end); \
|
||||||
|
}
|
||||||
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
|
{ uch len = (uch)(length); \
|
||||||
|
ush dist = (ush)(distance); \
|
||||||
|
s->sym_buf[s->sym_next++] = (uch)dist; \
|
||||||
|
s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
|
||||||
|
s->sym_buf[s->sym_next++] = len; \
|
||||||
|
dist--; \
|
||||||
|
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||||
|
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||||
|
flush = (s->sym_next == s->sym_end); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||||
# define _tr_tally_dist(s, distance, length, flush) \
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
flush = _tr_tally(s, distance, length)
|
flush = _tr_tally(s, distance, length)
|
||||||
|
214
PDF/include/Poco/PDF/gzguts.h
Normal file
214
PDF/include/Poco/PDF/gzguts.h
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||||
|
* Copyright (C) 2004-2024 Mark Adler
|
||||||
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
# ifndef _LARGEFILE_SOURCE
|
||||||
|
# define _LARGEFILE_SOURCE 1
|
||||||
|
# endif
|
||||||
|
# undef _FILE_OFFSET_BITS
|
||||||
|
# undef _TIME_BITS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_HIDDEN
|
||||||
|
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||||
|
#else
|
||||||
|
# define ZLIB_INTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "zlib.h"
|
||||||
|
#ifdef STDC
|
||||||
|
# include <string.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <limits.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _POSIX_SOURCE
|
||||||
|
# define _POSIX_SOURCE
|
||||||
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
# define WIDECHAR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WINAPI_FAMILY
|
||||||
|
# define open _open
|
||||||
|
# define read _read
|
||||||
|
# define write _write
|
||||||
|
# define close _close
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||||
|
# define NO_GZCOMPRESS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
||||||
|
# ifndef HAVE_VSNPRINTF
|
||||||
|
# define HAVE_VSNPRINTF
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__CYGWIN__)
|
||||||
|
# ifndef HAVE_VSNPRINTF
|
||||||
|
# define HAVE_VSNPRINTF
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
|
||||||
|
# ifndef HAVE_VSNPRINTF
|
||||||
|
# define HAVE_VSNPRINTF
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_VSNPRINTF
|
||||||
|
# ifdef MSDOS
|
||||||
|
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
|
||||||
|
but for now we just assume it doesn't. */
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef __TURBOC__
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef WIN32
|
||||||
|
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
||||||
|
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
||||||
|
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
||||||
|
# define vsnprintf _vsnprintf
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifdef __SASC
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef VMS
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef __OS400__
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef __MVS__
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* unlike snprintf (which is required in C99), _snprintf does not guarantee
|
||||||
|
null termination of the result -- however this is only used in gzlib.c where
|
||||||
|
the result is assured to fit in the space provided */
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
|
# define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef local
|
||||||
|
# define local static
|
||||||
|
#endif
|
||||||
|
/* since "static" is used to mean two completely different things in C, we
|
||||||
|
define "local" for the non-static meaning of "static", for readability
|
||||||
|
(compile with -Dlocal if your debugger can't find static symbols) */
|
||||||
|
|
||||||
|
/* gz* functions always use library allocation functions */
|
||||||
|
#ifndef STDC
|
||||||
|
extern voidp malloc(uInt size);
|
||||||
|
extern void free(voidpf ptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* get errno and strerror definition */
|
||||||
|
#if defined UNDER_CE
|
||||||
|
# include <windows.h>
|
||||||
|
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
|
||||||
|
#else
|
||||||
|
# ifndef NO_STRERROR
|
||||||
|
# include <errno.h>
|
||||||
|
# define zstrerror() strerror(errno)
|
||||||
|
# else
|
||||||
|
# define zstrerror() "stdio error (consult errno)"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
|
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* default memLevel */
|
||||||
|
#if MAX_MEM_LEVEL >= 8
|
||||||
|
# define DEF_MEM_LEVEL 8
|
||||||
|
#else
|
||||||
|
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* default i/o buffer size -- double this for output when reading (this and
|
||||||
|
twice this must be able to fit in an unsigned type) */
|
||||||
|
#define GZBUFSIZE 8192
|
||||||
|
|
||||||
|
/* gzip modes, also provide a little integrity check on the passed structure */
|
||||||
|
#define GZ_NONE 0
|
||||||
|
#define GZ_READ 7247
|
||||||
|
#define GZ_WRITE 31153
|
||||||
|
#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
|
||||||
|
|
||||||
|
/* values for gz_state how */
|
||||||
|
#define LOOK 0 /* look for a gzip header */
|
||||||
|
#define COPY 1 /* copy input directly */
|
||||||
|
#define GZIP 2 /* decompress a gzip stream */
|
||||||
|
|
||||||
|
/* internal gzip file state data structure */
|
||||||
|
typedef struct {
|
||||||
|
/* exposed contents for gzgetc() macro */
|
||||||
|
struct gzFile_s x; /* "x" for exposed */
|
||||||
|
/* x.have: number of bytes available at x.next */
|
||||||
|
/* x.next: next output data to deliver or write */
|
||||||
|
/* x.pos: current position in uncompressed data */
|
||||||
|
/* used for both reading and writing */
|
||||||
|
int mode; /* see gzip modes above */
|
||||||
|
int fd; /* file descriptor */
|
||||||
|
char *path; /* path or fd for error messages */
|
||||||
|
unsigned size; /* buffer size, zero if not allocated yet */
|
||||||
|
unsigned want; /* requested buffer size, default is GZBUFSIZE */
|
||||||
|
unsigned char *in; /* input buffer (double-sized when writing) */
|
||||||
|
unsigned char *out; /* output buffer (double-sized when reading) */
|
||||||
|
int direct; /* 0 if processing gzip, 1 if transparent */
|
||||||
|
/* just for reading */
|
||||||
|
int how; /* 0: get header, 1: copy, 2: decompress */
|
||||||
|
z_off64_t start; /* where the gzip data started, for rewinding */
|
||||||
|
int eof; /* true if end of input file reached */
|
||||||
|
int past; /* true if read requested past end */
|
||||||
|
/* just for writing */
|
||||||
|
int level; /* compression level */
|
||||||
|
int strategy; /* compression strategy */
|
||||||
|
int reset; /* true if a reset is pending after a Z_FINISH */
|
||||||
|
/* seek request */
|
||||||
|
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
||||||
|
int seek; /* true if seek request pending */
|
||||||
|
/* error information */
|
||||||
|
int err; /* error code */
|
||||||
|
char *msg; /* error message */
|
||||||
|
/* zlib inflate or deflate stream */
|
||||||
|
z_stream strm; /* stream structure in-place (not a pointer) */
|
||||||
|
} gz_state;
|
||||||
|
typedef gz_state FAR *gz_statep;
|
||||||
|
|
||||||
|
/* shared functions */
|
||||||
|
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
|
||||||
|
#if defined UNDER_CE
|
||||||
|
char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
||||||
|
value -- needed when comparing unsigned to z_off64_t, which is signed
|
||||||
|
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||||
|
unsigned ZLIB_INTERNAL gz_intmax(void);
|
||||||
|
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
@ -1,5 +1,5 @@
|
|||||||
/* inffast.h -- header to use inffast.c
|
/* inffast.h -- header to use inffast.c
|
||||||
* Copyright (C) 1995-2003 Mark Adler
|
* Copyright (C) 1995-2003, 2010 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -8,4 +8,4 @@
|
|||||||
subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void inflate_fast OF((z_streamp strm, unsigned start));
|
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* Generated automatically by makefixed().
|
* Generated automatically by makefixed().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* WARNING: this file should *not* be used by applications. It
|
/* WARNING: this file should *not* be used by applications.
|
||||||
is part of the implementation of the compression library and
|
It is part of the implementation of this library and is
|
||||||
is subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const code lenfix[512] = {
|
static const code lenfix[512] = {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* inflate.h -- internal inflate state definition
|
/* inflate.h -- internal inflate state definition
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2019 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
/* Possible inflate modes between inflate() calls */
|
/* Possible inflate modes between inflate() calls */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HEAD, /* i: waiting for magic header */
|
HEAD = 16180, /* i: waiting for magic header */
|
||||||
FLAGS, /* i: waiting for method and flags (gzip) */
|
FLAGS, /* i: waiting for method and flags (gzip) */
|
||||||
TIME, /* i: waiting for modification time (gzip) */
|
TIME, /* i: waiting for modification time (gzip) */
|
||||||
OS, /* i: waiting for extra flags and operating system (gzip) */
|
OS, /* i: waiting for extra flags and operating system (gzip) */
|
||||||
@ -32,11 +32,13 @@ typedef enum {
|
|||||||
TYPE, /* i: waiting for type bits, including last-flag bit */
|
TYPE, /* i: waiting for type bits, including last-flag bit */
|
||||||
TYPEDO, /* i: same, but skip check to exit inflate on new block */
|
TYPEDO, /* i: same, but skip check to exit inflate on new block */
|
||||||
STORED, /* i: waiting for stored size (length and complement) */
|
STORED, /* i: waiting for stored size (length and complement) */
|
||||||
|
COPY_, /* i/o: same as COPY below, but only first time in */
|
||||||
COPY, /* i/o: waiting for input or output to copy stored block */
|
COPY, /* i/o: waiting for input or output to copy stored block */
|
||||||
TABLE, /* i: waiting for dynamic block table lengths */
|
TABLE, /* i: waiting for dynamic block table lengths */
|
||||||
LENLENS, /* i: waiting for code length code lengths */
|
LENLENS, /* i: waiting for code length code lengths */
|
||||||
CODELENS, /* i: waiting for length/lit and distance code lengths */
|
CODELENS, /* i: waiting for length/lit and distance code lengths */
|
||||||
LEN, /* i: waiting for length/lit code */
|
LEN_, /* i: same as LEN below, but only first time in */
|
||||||
|
LEN, /* i: waiting for length/lit/eob code */
|
||||||
LENEXT, /* i: waiting for length extra bits */
|
LENEXT, /* i: waiting for length extra bits */
|
||||||
DIST, /* i: waiting for distance code */
|
DIST, /* i: waiting for distance code */
|
||||||
DISTEXT, /* i: waiting for distance extra bits */
|
DISTEXT, /* i: waiting for distance extra bits */
|
||||||
@ -53,19 +55,21 @@ typedef enum {
|
|||||||
/*
|
/*
|
||||||
State transitions between above modes -
|
State transitions between above modes -
|
||||||
|
|
||||||
(most modes can go to the BAD or MEM mode -- not shown for clarity)
|
(most modes can go to BAD or MEM on error -- not shown for clarity)
|
||||||
|
|
||||||
Process header:
|
Process header:
|
||||||
HEAD -> (gzip) or (zlib)
|
HEAD -> (gzip) or (zlib) or (raw)
|
||||||
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
|
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
|
||||||
NAME -> COMMENT -> HCRC -> TYPE
|
HCRC -> TYPE
|
||||||
(zlib) -> DICTID or TYPE
|
(zlib) -> DICTID or TYPE
|
||||||
DICTID -> DICT -> TYPE
|
DICTID -> DICT -> TYPE
|
||||||
|
(raw) -> TYPEDO
|
||||||
Read deflate blocks:
|
Read deflate blocks:
|
||||||
TYPE -> STORED or TABLE or LEN or CHECK
|
TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
|
||||||
STORED -> COPY -> TYPE
|
STORED -> COPY_ -> COPY -> TYPE
|
||||||
TABLE -> LENLENS -> CODELENS -> LEN
|
TABLE -> LENLENS -> CODELENS -> LEN_
|
||||||
Read deflate codes:
|
LEN_ -> LEN
|
||||||
|
Read deflate codes in fixed or dynamic block:
|
||||||
LEN -> LENEXT or LIT or TYPE
|
LEN -> LENEXT or LIT or TYPE
|
||||||
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
|
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
|
||||||
LIT -> LEN
|
LIT -> LEN
|
||||||
@ -73,13 +77,17 @@ typedef enum {
|
|||||||
CHECK -> LENGTH -> DONE
|
CHECK -> LENGTH -> DONE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* state maintained between inflate() calls. Approximately 7K bytes. */
|
/* State maintained between inflate() calls -- approximately 7K bytes, not
|
||||||
|
including the allocated sliding window, which is up to 32K bytes. */
|
||||||
struct inflate_state {
|
struct inflate_state {
|
||||||
|
z_streamp strm; /* pointer back to this zlib stream */
|
||||||
inflate_mode mode; /* current inflate mode */
|
inflate_mode mode; /* current inflate mode */
|
||||||
int last; /* true if processing last block */
|
int last; /* true if processing last block */
|
||||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
||||||
|
bit 2 true to validate check value */
|
||||||
int havedict; /* true if dictionary provided */
|
int havedict; /* true if dictionary provided */
|
||||||
int flags; /* gzip header method and flags (0 if zlib) */
|
int flags; /* gzip header method and flags, 0 if zlib, or
|
||||||
|
-1 if raw or no header yet */
|
||||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||||
unsigned long check; /* protected copy of check value */
|
unsigned long check; /* protected copy of check value */
|
||||||
unsigned long total; /* protected copy of output count */
|
unsigned long total; /* protected copy of output count */
|
||||||
@ -88,7 +96,7 @@ struct inflate_state {
|
|||||||
unsigned wbits; /* log base 2 of requested window size */
|
unsigned wbits; /* log base 2 of requested window size */
|
||||||
unsigned wsize; /* window size or zero if not using window */
|
unsigned wsize; /* window size or zero if not using window */
|
||||||
unsigned whave; /* valid bytes in the window */
|
unsigned whave; /* valid bytes in the window */
|
||||||
unsigned write; /* window write index */
|
unsigned wnext; /* window write index */
|
||||||
unsigned char FAR *window; /* allocated sliding window, if needed */
|
unsigned char FAR *window; /* allocated sliding window, if needed */
|
||||||
/* bit accumulator */
|
/* bit accumulator */
|
||||||
unsigned long hold; /* input bit accumulator */
|
unsigned long hold; /* input bit accumulator */
|
||||||
@ -112,4 +120,7 @@ struct inflate_state {
|
|||||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||||
unsigned short work[288]; /* work area for code table building */
|
unsigned short work[288]; /* work area for code table building */
|
||||||
code codes[ENOUGH]; /* space for code tables */
|
code codes[ENOUGH]; /* space for code tables */
|
||||||
|
int sane; /* if false, allow invalid distance too far */
|
||||||
|
int back; /* bits back of last unprocessed length/lit */
|
||||||
|
unsigned was; /* initial length of match */
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* inftrees.h -- header to use inftrees.c
|
/* inftrees.h -- header to use inftrees.c
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2005, 2010 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,21 +35,28 @@ typedef struct {
|
|||||||
01000000 - invalid code
|
01000000 - invalid code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Maximum size of dynamic tree. The maximum found in a long but non-
|
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||||
exhaustive search was 1444 code structures (852 for length/literals
|
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||||
and 592 for distances, the latter actually the result of an
|
codes. These values were found by exhaustive searches using the program
|
||||||
exhaustive search). The true maximum is not known, but the value
|
examples/enough.c found in the zlib distribution. The arguments to that
|
||||||
below is more than safe. */
|
program are the number of symbols, the initial root table size, and the
|
||||||
#define ENOUGH 2048
|
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||||
#define MAXD 592
|
returns 852, and "enough 30 6 15" for distance codes returns 592. The
|
||||||
|
initial root table size (9 or 6) is found in the fifth argument of the
|
||||||
|
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
||||||
|
changed, then these maximum sizes would be need to be recalculated and
|
||||||
|
updated. */
|
||||||
|
#define ENOUGH_LENS 852
|
||||||
|
#define ENOUGH_DISTS 592
|
||||||
|
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
|
||||||
|
|
||||||
/* Type of code to build for inftable() */
|
/* Type of code to build for inflate_table() */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CODES,
|
CODES,
|
||||||
LENS,
|
LENS,
|
||||||
DISTS
|
DISTS
|
||||||
} codetype;
|
} codetype;
|
||||||
|
|
||||||
extern int inflate_table OF((codetype type, unsigned short FAR *lens,
|
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||||
unsigned codes, code FAR * FAR *table,
|
unsigned codes, code FAR * FAR *table,
|
||||||
unsigned FAR *bits, unsigned short FAR *work));
|
unsigned FAR *bits, unsigned short FAR *work);
|
||||||
|
@ -70,7 +70,7 @@ local const ct_data static_dtree[D_CODES] = {
|
|||||||
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const uch _dist_code[DIST_CODE_LEN] = {
|
const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
|
||||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
||||||
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||||
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||||
@ -99,7 +99,7 @@ const uch _dist_code[DIST_CODE_LEN] = {
|
|||||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||||
};
|
};
|
||||||
|
|
||||||
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
||||||
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/* zconf.h -- configuration of the zlib compression library
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id: //poco/Main/Foundation/src/zconf.h#9 $ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#ifndef ZCONF_H
|
#ifndef ZCONF_H
|
||||||
#define ZCONF_H
|
#define ZCONF_H
|
||||||
@ -11,52 +11,161 @@
|
|||||||
/*
|
/*
|
||||||
* If you *really* need a unique prefix for all types and library functions,
|
* If you *really* need a unique prefix for all types and library functions,
|
||||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||||
|
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||||
|
* this permanently in zconf.h using "./configure --zprefix".
|
||||||
*/
|
*/
|
||||||
#ifdef Z_PREFIX
|
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||||
# define deflateInit_ z_deflateInit_
|
# define Z_PREFIX_SET
|
||||||
|
|
||||||
|
/* all linked symbols and init macros */
|
||||||
|
# define _dist_code z__dist_code
|
||||||
|
# define _length_code z__length_code
|
||||||
|
# define _tr_align z__tr_align
|
||||||
|
# define _tr_flush_bits z__tr_flush_bits
|
||||||
|
# define _tr_flush_block z__tr_flush_block
|
||||||
|
# define _tr_init z__tr_init
|
||||||
|
# define _tr_stored_block z__tr_stored_block
|
||||||
|
# define _tr_tally z__tr_tally
|
||||||
|
# define adler32 z_adler32
|
||||||
|
# define adler32_combine z_adler32_combine
|
||||||
|
# define adler32_combine64 z_adler32_combine64
|
||||||
|
# define adler32_z z_adler32_z
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define compress z_compress
|
||||||
|
# define compress2 z_compress2
|
||||||
|
# define compressBound z_compressBound
|
||||||
|
# endif
|
||||||
|
# define crc32 z_crc32
|
||||||
|
# define crc32_combine z_crc32_combine
|
||||||
|
# define crc32_combine64 z_crc32_combine64
|
||||||
|
# define crc32_combine_gen z_crc32_combine_gen
|
||||||
|
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||||
|
# define crc32_combine_op z_crc32_combine_op
|
||||||
|
# define crc32_z z_crc32_z
|
||||||
# define deflate z_deflate
|
# define deflate z_deflate
|
||||||
# define deflateEnd z_deflateEnd
|
|
||||||
# define inflateInit_ z_inflateInit_
|
|
||||||
# define inflate z_inflate
|
|
||||||
# define inflateEnd z_inflateEnd
|
|
||||||
# define deflateInit2_ z_deflateInit2_
|
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
|
||||||
# define deflateCopy z_deflateCopy
|
|
||||||
# define deflateReset z_deflateReset
|
|
||||||
# define deflateParams z_deflateParams
|
|
||||||
# define deflateBound z_deflateBound
|
# define deflateBound z_deflateBound
|
||||||
|
# define deflateCopy z_deflateCopy
|
||||||
|
# define deflateEnd z_deflateEnd
|
||||||
|
# define deflateGetDictionary z_deflateGetDictionary
|
||||||
|
# define deflateInit z_deflateInit
|
||||||
|
# define deflateInit2 z_deflateInit2
|
||||||
|
# define deflateInit2_ z_deflateInit2_
|
||||||
|
# define deflateInit_ z_deflateInit_
|
||||||
|
# define deflateParams z_deflateParams
|
||||||
|
# define deflatePending z_deflatePending
|
||||||
# define deflatePrime z_deflatePrime
|
# define deflatePrime z_deflatePrime
|
||||||
|
# define deflateReset z_deflateReset
|
||||||
|
# define deflateResetKeep z_deflateResetKeep
|
||||||
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflate_copyright z_deflate_copyright
|
||||||
|
# define get_crc_table z_get_crc_table
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define gz_error z_gz_error
|
||||||
|
# define gz_intmax z_gz_intmax
|
||||||
|
# define gz_strwinerror z_gz_strwinerror
|
||||||
|
# define gzbuffer z_gzbuffer
|
||||||
|
# define gzclearerr z_gzclearerr
|
||||||
|
# define gzclose z_gzclose
|
||||||
|
# define gzclose_r z_gzclose_r
|
||||||
|
# define gzclose_w z_gzclose_w
|
||||||
|
# define gzdirect z_gzdirect
|
||||||
|
# define gzdopen z_gzdopen
|
||||||
|
# define gzeof z_gzeof
|
||||||
|
# define gzerror z_gzerror
|
||||||
|
# define gzflush z_gzflush
|
||||||
|
# define gzfread z_gzfread
|
||||||
|
# define gzfwrite z_gzfwrite
|
||||||
|
# define gzgetc z_gzgetc
|
||||||
|
# define gzgetc_ z_gzgetc_
|
||||||
|
# define gzgets z_gzgets
|
||||||
|
# define gzoffset z_gzoffset
|
||||||
|
# define gzoffset64 z_gzoffset64
|
||||||
|
# define gzopen z_gzopen
|
||||||
|
# define gzopen64 z_gzopen64
|
||||||
|
# ifdef _WIN32
|
||||||
|
# define gzopen_w z_gzopen_w
|
||||||
|
# endif
|
||||||
|
# define gzprintf z_gzprintf
|
||||||
|
# define gzputc z_gzputc
|
||||||
|
# define gzputs z_gzputs
|
||||||
|
# define gzread z_gzread
|
||||||
|
# define gzrewind z_gzrewind
|
||||||
|
# define gzseek z_gzseek
|
||||||
|
# define gzseek64 z_gzseek64
|
||||||
|
# define gzsetparams z_gzsetparams
|
||||||
|
# define gztell z_gztell
|
||||||
|
# define gztell64 z_gztell64
|
||||||
|
# define gzungetc z_gzungetc
|
||||||
|
# define gzvprintf z_gzvprintf
|
||||||
|
# define gzwrite z_gzwrite
|
||||||
|
# endif
|
||||||
|
# define inflate z_inflate
|
||||||
|
# define inflateBack z_inflateBack
|
||||||
|
# define inflateBackEnd z_inflateBackEnd
|
||||||
|
# define inflateBackInit z_inflateBackInit
|
||||||
|
# define inflateBackInit_ z_inflateBackInit_
|
||||||
|
# define inflateCodesUsed z_inflateCodesUsed
|
||||||
|
# define inflateCopy z_inflateCopy
|
||||||
|
# define inflateEnd z_inflateEnd
|
||||||
|
# define inflateGetDictionary z_inflateGetDictionary
|
||||||
|
# define inflateGetHeader z_inflateGetHeader
|
||||||
|
# define inflateInit z_inflateInit
|
||||||
|
# define inflateInit2 z_inflateInit2
|
||||||
# define inflateInit2_ z_inflateInit2_
|
# define inflateInit2_ z_inflateInit2_
|
||||||
|
# define inflateInit_ z_inflateInit_
|
||||||
|
# define inflateMark z_inflateMark
|
||||||
|
# define inflatePrime z_inflatePrime
|
||||||
|
# define inflateReset z_inflateReset
|
||||||
|
# define inflateReset2 z_inflateReset2
|
||||||
|
# define inflateResetKeep z_inflateResetKeep
|
||||||
# define inflateSetDictionary z_inflateSetDictionary
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
# define inflateSync z_inflateSync
|
# define inflateSync z_inflateSync
|
||||||
# define inflateSyncPoint z_inflateSyncPoint
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
# define inflateCopy z_inflateCopy
|
# define inflateUndermine z_inflateUndermine
|
||||||
# define inflateReset z_inflateReset
|
# define inflateValidate z_inflateValidate
|
||||||
# define inflateBack z_inflateBack
|
# define inflate_copyright z_inflate_copyright
|
||||||
# define inflateBackEnd z_inflateBackEnd
|
# define inflate_fast z_inflate_fast
|
||||||
# define compress z_compress
|
# define inflate_table z_inflate_table
|
||||||
# define compress2 z_compress2
|
# ifndef Z_SOLO
|
||||||
# define compressBound z_compressBound
|
# define uncompress z_uncompress
|
||||||
# define uncompress z_uncompress
|
# define uncompress2 z_uncompress2
|
||||||
# define adler32 z_adler32
|
# endif
|
||||||
# define crc32 z_crc32
|
|
||||||
# define get_crc_table z_get_crc_table
|
|
||||||
# define zError z_zError
|
# define zError z_zError
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define zcalloc z_zcalloc
|
||||||
|
# define zcfree z_zcfree
|
||||||
|
# endif
|
||||||
|
# define zlibCompileFlags z_zlibCompileFlags
|
||||||
|
# define zlibVersion z_zlibVersion
|
||||||
|
|
||||||
# define alloc_func z_alloc_func
|
/* all zlib typedefs in zlib.h and zconf.h */
|
||||||
# define free_func z_free_func
|
|
||||||
# define in_func z_in_func
|
|
||||||
# define out_func z_out_func
|
|
||||||
# define Byte z_Byte
|
# define Byte z_Byte
|
||||||
# define uInt z_uInt
|
|
||||||
# define uLong z_uLong
|
|
||||||
# define Bytef z_Bytef
|
# define Bytef z_Bytef
|
||||||
|
# define alloc_func z_alloc_func
|
||||||
# define charf z_charf
|
# define charf z_charf
|
||||||
|
# define free_func z_free_func
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# define gzFile z_gzFile
|
||||||
|
# endif
|
||||||
|
# define gz_header z_gz_header
|
||||||
|
# define gz_headerp z_gz_headerp
|
||||||
|
# define in_func z_in_func
|
||||||
# define intf z_intf
|
# define intf z_intf
|
||||||
|
# define out_func z_out_func
|
||||||
|
# define uInt z_uInt
|
||||||
# define uIntf z_uIntf
|
# define uIntf z_uIntf
|
||||||
|
# define uLong z_uLong
|
||||||
# define uLongf z_uLongf
|
# define uLongf z_uLongf
|
||||||
# define voidpf z_voidpf
|
|
||||||
# define voidp z_voidp
|
# define voidp z_voidp
|
||||||
|
# define voidpc z_voidpc
|
||||||
|
# define voidpf z_voidpf
|
||||||
|
|
||||||
|
/* all zlib structs in zlib.h and zconf.h */
|
||||||
|
# define gz_header_s z_gz_header_s
|
||||||
|
# define internal_state z_internal_state
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||||
@ -125,9 +234,29 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Some Mac compilers merge all .h files incorrectly: */
|
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||||
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
# define z_const const
|
||||||
# define NO_DUMMY_DECL
|
#else
|
||||||
|
# define z_const
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
# ifdef _WIN64
|
||||||
|
typedef unsigned long long z_size_t;
|
||||||
|
# else
|
||||||
|
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;
|
||||||
|
# elif defined(STDC)
|
||||||
|
# include <stddef.h>
|
||||||
|
typedef size_t z_size_t;
|
||||||
|
# else
|
||||||
|
typedef unsigned long z_size_t;
|
||||||
|
# endif
|
||||||
|
# undef z_longlong
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Maximum value for memLevel in deflateInit2 */
|
/* Maximum value for memLevel in deflateInit2 */
|
||||||
@ -157,7 +286,7 @@
|
|||||||
Of course this will generally degrade compression (there's no free lunch).
|
Of course this will generally degrade compression (there's no free lunch).
|
||||||
|
|
||||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
|
||||||
for small objects.
|
for small objects.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -219,7 +348,10 @@
|
|||||||
# ifdef FAR
|
# ifdef FAR
|
||||||
# undef FAR
|
# undef FAR
|
||||||
# endif
|
# endif
|
||||||
# include "Poco/UnWindows.h"
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
/* No need for _export, use ZLIB.DEF instead. */
|
/* No need for _export, use ZLIB.DEF instead. */
|
||||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||||
# define ZEXPORT WINAPI
|
# define ZEXPORT WINAPI
|
||||||
@ -284,49 +416,128 @@ typedef uLong FAR uLongf;
|
|||||||
typedef Byte *voidp;
|
typedef Byte *voidp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
|
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||||
# include <sys/types.h> /* for off_t */
|
# include <limits.h>
|
||||||
# include <unistd.h> /* for SEEK_* and off_t */
|
# if (UINT_MAX == 0xffffffffUL)
|
||||||
# ifdef VMS
|
# define Z_U4 unsigned
|
||||||
# include <unixio.h> /* for off_t */
|
# elif (ULONG_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned long
|
||||||
|
# elif (USHRT_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned short
|
||||||
# endif
|
# endif
|
||||||
# define z_off_t off_t
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef SEEK_SET
|
|
||||||
|
#ifdef Z_U4
|
||||||
|
typedef Z_U4 z_crc_t;
|
||||||
|
#else
|
||||||
|
typedef unsigned long z_crc_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H /* 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 */
|
||||||
|
# define Z_HAVE_STDARG_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STDC
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <sys/types.h> /* for off_t */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stdarg.h> /* for va_list */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stddef.h> /* for wchar_t */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||||
|
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||||
|
* though the former does not conform to the LFS document), but considering
|
||||||
|
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||||
|
* equivalently requesting no 64-bit operations
|
||||||
|
*/
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||||
|
# undef _LARGEFILE64_SOURCE
|
||||||
|
#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)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
# if defined(Z_HAVE_UNISTD_H)
|
||||||
|
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||||
|
# ifdef VMS
|
||||||
|
# include <unixio.h> /* for off_t */
|
||||||
|
# endif
|
||||||
|
# ifndef z_off_t
|
||||||
|
# define z_off_t off_t
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||||
|
# define Z_LFS64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||||
|
# define Z_LARGE64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||||
|
# define Z_WANT64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||||
# define SEEK_CUR 1 /* Seek from current position. */
|
# define SEEK_CUR 1 /* Seek from current position. */
|
||||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef z_off_t
|
#ifndef z_off_t
|
||||||
# define z_off_t long
|
# define z_off_t long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__OS400__)
|
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||||
# define NO_vsnprintf
|
# define z_off64_t off64_t
|
||||||
#endif
|
#else
|
||||||
|
# if defined(_WIN32) && !defined(__GNUC__)
|
||||||
#if defined(__MVS__)
|
# define z_off64_t __int64
|
||||||
# define NO_vsnprintf
|
# else
|
||||||
# ifdef FAR
|
# define z_off64_t z_off_t
|
||||||
# undef FAR
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* MVS linker does not support external names larger than 8 bytes */
|
/* MVS linker does not support external names larger than 8 bytes */
|
||||||
#if defined(__MVS__)
|
#if defined(__MVS__)
|
||||||
# pragma map(deflateInit_,"DEIN")
|
#pragma map(deflateInit_,"DEIN")
|
||||||
# pragma map(deflateInit2_,"DEIN2")
|
#pragma map(deflateInit2_,"DEIN2")
|
||||||
# pragma map(deflateEnd,"DEEND")
|
#pragma map(deflateEnd,"DEEND")
|
||||||
# pragma map(deflateBound,"DEBND")
|
#pragma map(deflateBound,"DEBND")
|
||||||
# pragma map(inflateInit_,"ININ")
|
#pragma map(inflateInit_,"ININ")
|
||||||
# pragma map(inflateInit2_,"ININ2")
|
#pragma map(inflateInit2_,"ININ2")
|
||||||
# pragma map(inflateEnd,"INEND")
|
#pragma map(inflateEnd,"INEND")
|
||||||
# pragma map(inflateSync,"INSY")
|
#pragma map(inflateSync,"INSY")
|
||||||
# pragma map(inflateSetDictionary,"INSEDI")
|
#pragma map(inflateSetDictionary,"INSEDI")
|
||||||
# pragma map(compressBound,"CMBND")
|
#pragma map(compressBound,"CMBND")
|
||||||
# pragma map(inflate_table,"INTABL")
|
#pragma map(inflate_table,"INTABL")
|
||||||
# pragma map(inflate_fast,"INFA")
|
#pragma map(inflate_fast,"INFA")
|
||||||
# pragma map(inflate_copyright,"INCOPY")
|
#pragma map(inflate_copyright,"INCOPY")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ZCONF_H */
|
#endif /* ZCONF_H */
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -8,41 +8,33 @@
|
|||||||
subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id: //poco/Main/Foundation/src/zutil.h#8 $ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#ifndef ZUTIL_H
|
#ifndef ZUTIL_H
|
||||||
#define ZUTIL_H
|
#define ZUTIL_H
|
||||||
|
|
||||||
#define ZLIB_INTERNAL
|
#ifdef HAVE_HIDDEN
|
||||||
|
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||||
|
#else
|
||||||
|
# define ZLIB_INTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
#ifdef STDC
|
#if defined(STDC) && !defined(Z_SOLO)
|
||||||
# ifndef _WIN32_WCE
|
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# endif
|
# endif
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_ERRNO_H
|
|
||||||
# ifdef _WIN32_WCE
|
|
||||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
|
||||||
* errno. We define it as a global variable to simplify porting.
|
|
||||||
* Its value is always 0 and should not be used. We rename it to
|
|
||||||
* avoid conflict with other libraries that use the same workaround.
|
|
||||||
*/
|
|
||||||
# define errno z_errno
|
|
||||||
# endif
|
|
||||||
extern int errno;
|
|
||||||
#else
|
|
||||||
# ifndef _WIN32_WCE
|
|
||||||
# include <errno.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
# define local static
|
# define local static
|
||||||
#endif
|
#endif
|
||||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
/* since "static" is used to mean two completely different things in C, we
|
||||||
|
define "local" for the non-static meaning of "static", for readability
|
||||||
|
(compile with -Dlocal if your debugger can't find static symbols) */
|
||||||
|
|
||||||
typedef unsigned char uch;
|
typedef unsigned char uch;
|
||||||
typedef uch FAR uchf;
|
typedef uch FAR uchf;
|
||||||
@ -50,13 +42,24 @@ typedef unsigned short ush;
|
|||||||
typedef ush FAR ushf;
|
typedef ush FAR ushf;
|
||||||
typedef unsigned long ulg;
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
|
||||||
|
# include <limits.h>
|
||||||
|
# if (ULONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long
|
||||||
|
# elif (ULLONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long long
|
||||||
|
# elif (UINT_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
/* (size given to avoid silly warnings with Visual C++) */
|
/* (size given to avoid silly warnings with Visual C++) */
|
||||||
|
|
||||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
|
||||||
|
|
||||||
#define ERR_RETURN(strm,err) \
|
#define ERR_RETURN(strm,err) \
|
||||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
return (strm->msg = ERR_MSG(err), (err))
|
||||||
/* To be used only when the state is known to be valid */
|
/* To be used only when the state is known to be valid */
|
||||||
|
|
||||||
/* common constants */
|
/* common constants */
|
||||||
@ -88,85 +91,94 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||||||
|
|
||||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||||
# define OS_CODE 0x00
|
# define OS_CODE 0x00
|
||||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
# ifndef Z_SOLO
|
||||||
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||||
/* Allow compilation with ANSI keywords only enabled */
|
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||||
void _Cdecl farfree( void *block );
|
/* Allow compilation with ANSI keywords only enabled */
|
||||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
void _Cdecl farfree( void *block );
|
||||||
# else
|
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||||
# include <alloc.h>
|
# else
|
||||||
|
# include <alloc.h>
|
||||||
|
# endif
|
||||||
|
# else /* MSC or DJGPP */
|
||||||
|
# include <malloc.h>
|
||||||
# endif
|
# endif
|
||||||
# else /* MSC or DJGPP */
|
|
||||||
# include <malloc.h>
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef AMIGA
|
#ifdef AMIGA
|
||||||
# define OS_CODE 0x01
|
# define OS_CODE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VAXC) || defined(VMS)
|
#if defined(VAXC) || defined(VMS)
|
||||||
# define OS_CODE 0x02
|
# define OS_CODE 2
|
||||||
# define F_OPEN(name, mode) \
|
# define F_OPEN(name, mode) \
|
||||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __370__
|
||||||
|
# if __TARGET_LIB__ < 0x20000000
|
||||||
|
# define OS_CODE 4
|
||||||
|
# elif __TARGET_LIB__ < 0x40000000
|
||||||
|
# define OS_CODE 11
|
||||||
|
# else
|
||||||
|
# define OS_CODE 8
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ATARI) || defined(atarist)
|
#if defined(ATARI) || defined(atarist)
|
||||||
# define OS_CODE 0x05
|
# define OS_CODE 5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OS2
|
#ifdef OS2
|
||||||
# define OS_CODE 0x06
|
# define OS_CODE 6
|
||||||
# ifdef M_I86
|
# if defined(M_I86) && !defined(Z_SOLO)
|
||||||
#include <malloc.h>
|
# include <malloc.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
#if defined(MACOS)
|
||||||
# define OS_CODE 0x07
|
# define OS_CODE 7
|
||||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
|
||||||
# include <unix.h> /* for fdopen */
|
|
||||||
# else
|
|
||||||
# ifndef fdopen
|
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TOPS20
|
#ifdef __acorn
|
||||||
# define OS_CODE 0x0a
|
# define OS_CODE 13
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||||
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
|
# define OS_CODE 10
|
||||||
# define OS_CODE 0x0b
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __50SERIES /* Prime/PRIMOS */
|
#ifdef _BEOS_
|
||||||
# define OS_CODE 0x0f
|
# define OS_CODE 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_BEOS_) || defined(RISCOS)
|
#ifdef __TOS_OS400__
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define OS_CODE 18
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
#ifdef __APPLE__
|
||||||
# if defined(_WIN32_WCE)
|
# define OS_CODE 19
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
#endif
|
||||||
# ifndef _PTRDIFF_T_DEFINED
|
|
||||||
typedef int ptrdiff_t;
|
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||||
# define _PTRDIFF_T_DEFINED
|
#pragma warn -8004
|
||||||
# endif
|
#pragma warn -8008
|
||||||
# else
|
#pragma warn -8066
|
||||||
# define fdopen(fd,type) _fdopen(fd,type)
|
#endif
|
||||||
# endif
|
|
||||||
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
|
#if !defined(_WIN32) && \
|
||||||
|
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||||
|
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);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* common defaults */
|
/* common defaults */
|
||||||
|
|
||||||
#ifndef OS_CODE
|
#ifndef OS_CODE
|
||||||
# define OS_CODE 0x03 /* assume Unix */
|
# define OS_CODE 3 /* assume Unix */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef F_OPEN
|
#ifndef F_OPEN
|
||||||
@ -175,40 +187,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
#if defined(pyr) || defined(Z_SOLO)
|
||||||
# ifndef HAVE_VSNPRINTF
|
|
||||||
# define HAVE_VSNPRINTF
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if defined(__CYGWIN__)
|
|
||||||
# ifndef HAVE_VSNPRINTF
|
|
||||||
# define HAVE_VSNPRINTF
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifndef HAVE_VSNPRINTF
|
|
||||||
# ifdef MSDOS
|
|
||||||
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
|
|
||||||
but for now we just assume it doesn't. */
|
|
||||||
# define NO_vsnprintf
|
|
||||||
# endif
|
|
||||||
# ifdef __TURBOC__
|
|
||||||
# define NO_vsnprintf
|
|
||||||
# endif
|
|
||||||
# ifdef WIN32
|
|
||||||
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
|
||||||
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
|
||||||
# define vsnprintf _vsnprintf
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# ifdef __SASC
|
|
||||||
# define NO_vsnprintf
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef VMS
|
|
||||||
# define NO_vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(pyr)
|
|
||||||
# define NO_MEMCPY
|
# define NO_MEMCPY
|
||||||
#endif
|
#endif
|
||||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||||
@ -232,16 +211,16 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
|
||||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
|
||||||
extern void zmemzero OF((Bytef* dest, uInt len));
|
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Diagnostic functions */
|
/* Diagnostic functions */
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
extern int z_verbose;
|
extern int ZLIB_INTERNAL z_verbose;
|
||||||
extern void z_error OF((char *m));
|
extern void ZLIB_INTERNAL z_error(char *m);
|
||||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||||
@ -257,13 +236,19 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||||||
# define Tracecv(c,x)
|
# define Tracecv(c,x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Z_SOLO
|
||||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
|
||||||
void zcfree OF((voidpf opaque, voidpf ptr));
|
unsigned size);
|
||||||
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ZALLOC(strm, items, size) \
|
#define ZALLOC(strm, items, size) \
|
||||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||||
|
|
||||||
|
/* Reverse the bytes in a 32-bit value */
|
||||||
|
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||||
|
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||||
|
|
||||||
#endif /* ZUTIL_H */
|
#endif /* ZUTIL_H */
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2011, 2016 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#define ZLIB_INTERNAL
|
#include "zutil.h"
|
||||||
#include "zlib.h"
|
|
||||||
|
|
||||||
#define BASE 65521UL /* largest prime smaller than 65536 */
|
#define BASE 65521U /* largest prime smaller than 65536 */
|
||||||
#define NMAX 5552
|
#define NMAX 5552
|
||||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||||
|
|
||||||
@ -18,47 +17,48 @@
|
|||||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||||
|
|
||||||
/* use NO_DIVIDE if your processor does not do division in hardware */
|
/* use NO_DIVIDE if your processor does not do division in hardware --
|
||||||
|
try it both ways to see which is faster */
|
||||||
#ifdef NO_DIVIDE
|
#ifdef NO_DIVIDE
|
||||||
# define MOD(a) \
|
/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
|
||||||
|
(thank you to John Reiser for pointing this out) */
|
||||||
|
# define CHOP(a) \
|
||||||
do { \
|
do { \
|
||||||
if (a >= (BASE << 16)) a -= (BASE << 16); \
|
unsigned long tmp = a >> 16; \
|
||||||
if (a >= (BASE << 15)) a -= (BASE << 15); \
|
a &= 0xffffUL; \
|
||||||
if (a >= (BASE << 14)) a -= (BASE << 14); \
|
a += (tmp << 4) - tmp; \
|
||||||
if (a >= (BASE << 13)) a -= (BASE << 13); \
|
} while (0)
|
||||||
if (a >= (BASE << 12)) a -= (BASE << 12); \
|
# define MOD28(a) \
|
||||||
if (a >= (BASE << 11)) a -= (BASE << 11); \
|
do { \
|
||||||
if (a >= (BASE << 10)) a -= (BASE << 10); \
|
CHOP(a); \
|
||||||
if (a >= (BASE << 9)) a -= (BASE << 9); \
|
|
||||||
if (a >= (BASE << 8)) a -= (BASE << 8); \
|
|
||||||
if (a >= (BASE << 7)) a -= (BASE << 7); \
|
|
||||||
if (a >= (BASE << 6)) a -= (BASE << 6); \
|
|
||||||
if (a >= (BASE << 5)) a -= (BASE << 5); \
|
|
||||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
|
||||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
|
||||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
|
||||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
|
||||||
if (a >= BASE) a -= BASE; \
|
if (a >= BASE) a -= BASE; \
|
||||||
} while (0)
|
} while (0)
|
||||||
# define MOD4(a) \
|
# define MOD(a) \
|
||||||
do { \
|
do { \
|
||||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
CHOP(a); \
|
||||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
MOD28(a); \
|
||||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
} while (0)
|
||||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
# define MOD63(a) \
|
||||||
|
do { /* this assumes a is not negative */ \
|
||||||
|
z_off64_t tmp = a >> 32; \
|
||||||
|
a &= 0xffffffffL; \
|
||||||
|
a += (tmp << 8) - (tmp << 5) + tmp; \
|
||||||
|
tmp = a >> 16; \
|
||||||
|
a &= 0xffffL; \
|
||||||
|
a += (tmp << 4) - tmp; \
|
||||||
|
tmp = a >> 16; \
|
||||||
|
a &= 0xffffL; \
|
||||||
|
a += (tmp << 4) - tmp; \
|
||||||
if (a >= BASE) a -= BASE; \
|
if (a >= BASE) a -= BASE; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
# define MOD(a) a %= BASE
|
# define MOD(a) a %= BASE
|
||||||
# define MOD4(a) a %= BASE
|
# define MOD28(a) a %= BASE
|
||||||
|
# define MOD63(a) a %= BASE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT adler32(adler, buf, len)
|
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
||||||
uLong adler;
|
|
||||||
const Bytef *buf;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
unsigned long sum2;
|
unsigned long sum2;
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ uLong ZEXPORT adler32(adler, buf, len)
|
|||||||
}
|
}
|
||||||
if (adler >= BASE)
|
if (adler >= BASE)
|
||||||
adler -= BASE;
|
adler -= BASE;
|
||||||
MOD4(sum2); /* only added so many BASE's */
|
MOD28(sum2); /* only added so many BASE's */
|
||||||
return adler | (sum2 << 16);
|
return adler | (sum2 << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,25 +125,40 @@ uLong ZEXPORT adler32(adler, buf, len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
||||||
uLong adler1;
|
return adler32_z(adler, buf, len);
|
||||||
uLong adler2;
|
}
|
||||||
z_off_t len2;
|
|
||||||
{
|
/* ========================================================================= */
|
||||||
|
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||||
unsigned long sum1;
|
unsigned long sum1;
|
||||||
unsigned long sum2;
|
unsigned long sum2;
|
||||||
unsigned rem;
|
unsigned rem;
|
||||||
|
|
||||||
|
/* for negative len, return invalid adler32 as a clue for debugging */
|
||||||
|
if (len2 < 0)
|
||||||
|
return 0xffffffffUL;
|
||||||
|
|
||||||
/* the derivation of this formula is left as an exercise for the reader */
|
/* the derivation of this formula is left as an exercise for the reader */
|
||||||
rem = (unsigned)(len2 % BASE);
|
MOD63(len2); /* assumes len2 >= 0 */
|
||||||
|
rem = (unsigned)len2;
|
||||||
sum1 = adler1 & 0xffff;
|
sum1 = adler1 & 0xffff;
|
||||||
sum2 = rem * sum1;
|
sum2 = rem * sum1;
|
||||||
MOD(sum2);
|
MOD(sum2);
|
||||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||||
if (sum1 > BASE) sum1 -= BASE;
|
if (sum1 >= BASE) sum1 -= BASE;
|
||||||
if (sum1 > BASE) sum1 -= BASE;
|
if (sum1 >= BASE) sum1 -= BASE;
|
||||||
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
|
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
|
||||||
if (sum2 > BASE) sum2 -= BASE;
|
if (sum2 >= BASE) sum2 -= BASE;
|
||||||
return sum1 | (sum2 << 16);
|
return sum1 | (sum2 << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
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_off64_t len2) {
|
||||||
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/* compress.c -- compress a memory buffer
|
/* compress.c -- compress a memory buffer
|
||||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id: //poco/Main/Foundation/src/compress.c#8 $ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#define ZLIB_INTERNAL
|
#define ZLIB_INTERNAL
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
@ -19,25 +19,15 @@
|
|||||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||||
Z_STREAM_ERROR if the level parameter is invalid.
|
Z_STREAM_ERROR if the level parameter is invalid.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||||
Bytef *dest;
|
uLong sourceLen, int level) {
|
||||||
uLongf *destLen;
|
|
||||||
const Bytef *source;
|
|
||||||
uLong sourceLen;
|
|
||||||
int level;
|
|
||||||
{
|
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int err;
|
int err;
|
||||||
|
const uInt max = (uInt)-1;
|
||||||
|
uLong left;
|
||||||
|
|
||||||
stream.next_in = (Bytef*)source;
|
left = *destLen;
|
||||||
stream.avail_in = (uInt)sourceLen;
|
*destLen = 0;
|
||||||
#ifdef MAXSEG_64K
|
|
||||||
/* Check for source > 64K on 16-bit machine: */
|
|
||||||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
|
||||||
#endif
|
|
||||||
stream.next_out = dest;
|
|
||||||
stream.avail_out = (uInt)*destLen;
|
|
||||||
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
|
|
||||||
|
|
||||||
stream.zalloc = (alloc_func)0;
|
stream.zalloc = (alloc_func)0;
|
||||||
stream.zfree = (free_func)0;
|
stream.zfree = (free_func)0;
|
||||||
@ -46,25 +36,32 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
|||||||
err = deflateInit(&stream, level);
|
err = deflateInit(&stream, level);
|
||||||
if (err != Z_OK) return err;
|
if (err != Z_OK) return err;
|
||||||
|
|
||||||
err = deflate(&stream, Z_FINISH);
|
stream.next_out = dest;
|
||||||
if (err != Z_STREAM_END) {
|
stream.avail_out = 0;
|
||||||
deflateEnd(&stream);
|
stream.next_in = (z_const Bytef *)source;
|
||||||
return err == Z_OK ? Z_BUF_ERROR : err;
|
stream.avail_in = 0;
|
||||||
}
|
|
||||||
*destLen = stream.total_out;
|
|
||||||
|
|
||||||
err = deflateEnd(&stream);
|
do {
|
||||||
return err;
|
if (stream.avail_out == 0) {
|
||||||
|
stream.avail_out = left > (uLong)max ? max : (uInt)left;
|
||||||
|
left -= stream.avail_out;
|
||||||
|
}
|
||||||
|
if (stream.avail_in == 0) {
|
||||||
|
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
|
||||||
|
sourceLen -= stream.avail_in;
|
||||||
|
}
|
||||||
|
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
|
||||||
|
} while (err == Z_OK);
|
||||||
|
|
||||||
|
*destLen = stream.total_out;
|
||||||
|
deflateEnd(&stream);
|
||||||
|
return err == Z_STREAM_END ? Z_OK : err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
*/
|
*/
|
||||||
int ZEXPORT compress (dest, destLen, source, sourceLen)
|
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||||
Bytef *dest;
|
uLong sourceLen) {
|
||||||
uLongf *destLen;
|
|
||||||
const Bytef *source;
|
|
||||||
uLong sourceLen;
|
|
||||||
{
|
|
||||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +69,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
|
|||||||
If the default memLevel or windowBits for deflateInit() is changed, then
|
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||||
this function needs to be updated.
|
this function needs to be updated.
|
||||||
*/
|
*/
|
||||||
uLong ZEXPORT compressBound (sourceLen)
|
uLong ZEXPORT compressBound(uLong sourceLen) {
|
||||||
uLong sourceLen;
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||||
{
|
(sourceLen >> 25) + 13;
|
||||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
|
|
||||||
}
|
}
|
||||||
|
1276
PDF/src/crc32.c
1276
PDF/src/crc32.c
File diff suppressed because it is too large
Load Diff
1957
PDF/src/deflate.c
1957
PDF/src/deflate.c
File diff suppressed because it is too large
Load Diff
1026
PDF/src/gzio.c
1026
PDF/src/gzio.c
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/* infback.c -- inflate using a call-back interface
|
/* infback.c -- inflate using a call-back interface
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2022 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -15,9 +15,6 @@
|
|||||||
#include "inflate.h"
|
#include "inflate.h"
|
||||||
#include "inffast.h"
|
#include "inffast.h"
|
||||||
|
|
||||||
/* function prototypes */
|
|
||||||
local void fixedtables OF((struct inflate_state FAR *state));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
strm provides memory allocation functions in zalloc and zfree, or
|
strm provides memory allocation functions in zalloc and zfree, or
|
||||||
Z_NULL to use the library memory allocation functions.
|
Z_NULL to use the library memory allocation functions.
|
||||||
@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state));
|
|||||||
windowBits is in the range 8..15, and window is a user-supplied
|
windowBits is in the range 8..15, and window is a user-supplied
|
||||||
window and output buffer that is 2**windowBits bytes.
|
window and output buffer that is 2**windowBits bytes.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
|
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
|
||||||
z_streamp strm;
|
unsigned char FAR *window, const char *version,
|
||||||
int windowBits;
|
int stream_size) {
|
||||||
unsigned char FAR *window;
|
|
||||||
const char *version;
|
|
||||||
int stream_size;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||||
@ -42,21 +35,31 @@ int stream_size;
|
|||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
strm->msg = Z_NULL; /* in case we return an error */
|
strm->msg = Z_NULL; /* in case we return an error */
|
||||||
if (strm->zalloc == (alloc_func)0) {
|
if (strm->zalloc == (alloc_func)0) {
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
strm->zalloc = zcalloc;
|
strm->zalloc = zcalloc;
|
||||||
strm->opaque = (voidpf)0;
|
strm->opaque = (voidpf)0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (strm->zfree == (free_func)0) strm->zfree = zcfree;
|
if (strm->zfree == (free_func)0)
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
|
strm->zfree = zcfree;
|
||||||
|
#endif
|
||||||
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
|
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
|
||||||
sizeof(struct inflate_state));
|
sizeof(struct inflate_state));
|
||||||
if (state == Z_NULL) return Z_MEM_ERROR;
|
if (state == Z_NULL) return Z_MEM_ERROR;
|
||||||
Tracev((stderr, "inflate: allocated\n"));
|
Tracev((stderr, "inflate: allocated\n"));
|
||||||
strm->state = (struct internal_state FAR *)state;
|
strm->state = (struct internal_state FAR *)state;
|
||||||
state->dmax = 32768U;
|
state->dmax = 32768U;
|
||||||
state->wbits = windowBits;
|
state->wbits = (uInt)windowBits;
|
||||||
state->wsize = 1U << windowBits;
|
state->wsize = 1U << windowBits;
|
||||||
state->window = window;
|
state->window = window;
|
||||||
state->write = 0;
|
state->wnext = 0;
|
||||||
state->whave = 0;
|
state->whave = 0;
|
||||||
|
state->sane = 1;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +73,7 @@ int stream_size;
|
|||||||
used for threaded applications, since the rewriting of the tables and virgin
|
used for threaded applications, since the rewriting of the tables and virgin
|
||||||
may not be thread-safe.
|
may not be thread-safe.
|
||||||
*/
|
*/
|
||||||
local void fixedtables(state)
|
local void fixedtables(struct inflate_state FAR *state) {
|
||||||
struct inflate_state FAR *state;
|
|
||||||
{
|
|
||||||
#ifdef BUILDFIXED
|
#ifdef BUILDFIXED
|
||||||
static int virgin = 1;
|
static int virgin = 1;
|
||||||
static code *lenfix, *distfix;
|
static code *lenfix, *distfix;
|
||||||
@ -238,22 +239,17 @@ struct inflate_state FAR *state;
|
|||||||
inflateBack() can also return Z_STREAM_ERROR if the input parameters
|
inflateBack() can also return Z_STREAM_ERROR if the input parameters
|
||||||
are not correct, i.e. strm is Z_NULL or the state was not initialized.
|
are not correct, i.e. strm is Z_NULL or the state was not initialized.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
|
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
|
||||||
z_streamp strm;
|
out_func out, void FAR *out_desc) {
|
||||||
in_func in;
|
|
||||||
void FAR *in_desc;
|
|
||||||
out_func out;
|
|
||||||
void FAR *out_desc;
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *next; /* next input */
|
z_const unsigned char FAR *next; /* next input */
|
||||||
unsigned char FAR *put; /* next output */
|
unsigned char FAR *put; /* next output */
|
||||||
unsigned have, left; /* available input and output */
|
unsigned have, left; /* available input and output */
|
||||||
unsigned long hold; /* bit buffer */
|
unsigned long hold; /* bit buffer */
|
||||||
unsigned bits; /* bits in bit buffer */
|
unsigned bits; /* bits in bit buffer */
|
||||||
unsigned copy; /* number of stored or match bytes to copy */
|
unsigned copy; /* number of stored or match bytes to copy */
|
||||||
unsigned char FAR *from; /* where to copy match bytes from */
|
unsigned char FAR *from; /* where to copy match bytes from */
|
||||||
code this; /* current decoding table entry */
|
code here; /* current decoding table entry */
|
||||||
code last; /* parent table entry */
|
code last; /* parent table entry */
|
||||||
unsigned len; /* length to copy for repeats, bits to drop */
|
unsigned len; /* length to copy for repeats, bits to drop */
|
||||||
int ret; /* return code */
|
int ret; /* return code */
|
||||||
@ -389,19 +385,18 @@ void FAR *out_desc;
|
|||||||
state->have = 0;
|
state->have = 0;
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.val < 16) {
|
if (here.val < 16) {
|
||||||
NEEDBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
DROPBITS(this.bits);
|
state->lens[state->have++] = here.val;
|
||||||
state->lens[state->have++] = this.val;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.val == 16) {
|
if (here.val == 16) {
|
||||||
NEEDBITS(this.bits + 2);
|
NEEDBITS(here.bits + 2);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (state->have == 0) {
|
if (state->have == 0) {
|
||||||
strm->msg = (char *)"invalid bit length repeat";
|
strm->msg = (char *)"invalid bit length repeat";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
@ -411,16 +406,16 @@ void FAR *out_desc;
|
|||||||
copy = 3 + BITS(2);
|
copy = 3 + BITS(2);
|
||||||
DROPBITS(2);
|
DROPBITS(2);
|
||||||
}
|
}
|
||||||
else if (this.val == 17) {
|
else if (here.val == 17) {
|
||||||
NEEDBITS(this.bits + 3);
|
NEEDBITS(here.bits + 3);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 3 + BITS(3);
|
copy = 3 + BITS(3);
|
||||||
DROPBITS(3);
|
DROPBITS(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NEEDBITS(this.bits + 7);
|
NEEDBITS(here.bits + 7);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 11 + BITS(7);
|
copy = 11 + BITS(7);
|
||||||
DROPBITS(7);
|
DROPBITS(7);
|
||||||
@ -438,7 +433,16 @@ void FAR *out_desc;
|
|||||||
/* handle error breaks in while */
|
/* handle error breaks in while */
|
||||||
if (state->mode == BAD) break;
|
if (state->mode == BAD) break;
|
||||||
|
|
||||||
/* build code tables */
|
/* check for end-of-block code (better have one) */
|
||||||
|
if (state->lens[256] == 0) {
|
||||||
|
strm->msg = (char *)"invalid code -- missing end-of-block";
|
||||||
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build code tables -- note: do not change the lenbits or distbits
|
||||||
|
values here (9 and 6) without reading the comments in inftrees.h
|
||||||
|
concerning the ENOUGH constants, which depend on those values */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
state->lencode = (code const FAR *)(state->next);
|
state->lencode = (code const FAR *)(state->next);
|
||||||
state->lenbits = 9;
|
state->lenbits = 9;
|
||||||
@ -460,6 +464,7 @@ void FAR *out_desc;
|
|||||||
}
|
}
|
||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
|
/* fallthrough */
|
||||||
|
|
||||||
case LEN:
|
case LEN:
|
||||||
/* use inflate_fast() if we have enough input and output */
|
/* use inflate_fast() if we have enough input and output */
|
||||||
@ -474,28 +479,28 @@ void FAR *out_desc;
|
|||||||
|
|
||||||
/* get a literal, length, or end-of-block code */
|
/* get a literal, length, or end-of-block code */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.op && (this.op & 0xf0) == 0) {
|
if (here.op && (here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[last.val +
|
here = state->lencode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->length = (unsigned)this.val;
|
state->length = (unsigned)here.val;
|
||||||
|
|
||||||
/* process literal */
|
/* process literal */
|
||||||
if (this.op == 0) {
|
if (here.op == 0) {
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here.val));
|
||||||
ROOM();
|
ROOM();
|
||||||
*put++ = (unsigned char)(state->length);
|
*put++ = (unsigned char)(state->length);
|
||||||
left--;
|
left--;
|
||||||
@ -504,21 +509,21 @@ void FAR *out_desc;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* process end of block */
|
/* process end of block */
|
||||||
if (this.op & 32) {
|
if (here.op & 32) {
|
||||||
Tracevv((stderr, "inflate: end of block\n"));
|
Tracevv((stderr, "inflate: end of block\n"));
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invalid code */
|
/* invalid code */
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid literal/length code";
|
strm->msg = (char *)"invalid literal/length code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* length code -- get extra bits, if any */
|
/* length code -- get extra bits, if any */
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
if (state->extra != 0) {
|
if (state->extra != 0) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->length += BITS(state->extra);
|
state->length += BITS(state->extra);
|
||||||
@ -528,30 +533,30 @@ void FAR *out_desc;
|
|||||||
|
|
||||||
/* get distance code */
|
/* get distance code */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if ((this.op & 0xf0) == 0) {
|
if ((here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[last.val +
|
here = state->distcode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid distance code";
|
strm->msg = (char *)"invalid distance code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->offset = (unsigned)this.val;
|
state->offset = (unsigned)here.val;
|
||||||
|
|
||||||
/* get distance extra bits, if any */
|
/* get distance extra bits, if any */
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
if (state->extra != 0) {
|
if (state->extra != 0) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->offset += BITS(state->extra);
|
state->offset += BITS(state->extra);
|
||||||
@ -587,33 +592,33 @@ void FAR *out_desc;
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DONE:
|
case DONE:
|
||||||
/* inflate stream terminated properly -- write leftover output */
|
/* inflate stream terminated properly */
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
if (left < state->wsize) {
|
|
||||||
if (out(out_desc, state->window, state->wsize - left))
|
|
||||||
ret = Z_BUF_ERROR;
|
|
||||||
}
|
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
|
||||||
case BAD:
|
case BAD:
|
||||||
ret = Z_DATA_ERROR;
|
ret = Z_DATA_ERROR;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
|
||||||
default: /* can't happen, but makes compilers happy */
|
default:
|
||||||
|
/* can't happen, but makes compilers happy */
|
||||||
ret = Z_STREAM_ERROR;
|
ret = Z_STREAM_ERROR;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return unused input */
|
/* Write leftover output and return unused input */
|
||||||
inf_leave:
|
inf_leave:
|
||||||
|
if (left < state->wsize) {
|
||||||
|
if (out(out_desc, state->window, state->wsize - left) &&
|
||||||
|
ret == Z_STREAM_END)
|
||||||
|
ret = Z_BUF_ERROR;
|
||||||
|
}
|
||||||
strm->next_in = next;
|
strm->next_in = next;
|
||||||
strm->avail_in = have;
|
strm->avail_in = have;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateBackEnd(strm)
|
int ZEXPORT inflateBackEnd(z_streamp strm) {
|
||||||
z_streamp strm;
|
|
||||||
{
|
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
ZFREE(strm, strm->state);
|
ZFREE(strm, strm->state);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* inffast.c -- fast decoding
|
/* inffast.c -- fast decoding
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2017 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -8,26 +8,9 @@
|
|||||||
#include "inflate.h"
|
#include "inflate.h"
|
||||||
#include "inffast.h"
|
#include "inffast.h"
|
||||||
|
|
||||||
#ifndef ASMINF
|
#ifdef ASMINF
|
||||||
|
# pragma message("Assembler code may have bugs -- use at your own risk")
|
||||||
/* Allow machine dependent optimization for post-increment or pre-increment.
|
|
||||||
Based on testing to date,
|
|
||||||
Pre-increment preferred for:
|
|
||||||
- PowerPC G3 (Adler)
|
|
||||||
- MIPS R5000 (Randers-Pehrson)
|
|
||||||
Post-increment preferred for:
|
|
||||||
- none
|
|
||||||
No measurable difference:
|
|
||||||
- Pentium III (Anderson)
|
|
||||||
- M68060 (Nikl)
|
|
||||||
*/
|
|
||||||
#ifdef POSTINC
|
|
||||||
# define OFF 0
|
|
||||||
# define PUP(a) *(a)++
|
|
||||||
#else
|
#else
|
||||||
# define OFF 1
|
|
||||||
# define PUP(a) *++(a)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Decode literal, length, and distance codes and write out the resulting
|
Decode literal, length, and distance codes and write out the resulting
|
||||||
@ -64,13 +47,10 @@
|
|||||||
requires strm->avail_out >= 258 for each loop to avoid checking for
|
requires strm->avail_out >= 258 for each loop to avoid checking for
|
||||||
output space.
|
output space.
|
||||||
*/
|
*/
|
||||||
void inflate_fast(strm, start)
|
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
|
||||||
z_streamp strm;
|
|
||||||
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|
||||||
{
|
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *in; /* local strm->next_in */
|
z_const unsigned char FAR *in; /* local strm->next_in */
|
||||||
unsigned char FAR *last; /* while in < last, enough input available */
|
z_const unsigned char FAR *last; /* have enough input while in < last */
|
||||||
unsigned char FAR *out; /* local strm->next_out */
|
unsigned char FAR *out; /* local strm->next_out */
|
||||||
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
||||||
unsigned char FAR *end; /* while out < end, enough space available */
|
unsigned char FAR *end; /* while out < end, enough space available */
|
||||||
@ -79,7 +59,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
#endif
|
#endif
|
||||||
unsigned wsize; /* window size or zero if not using window */
|
unsigned wsize; /* window size or zero if not using window */
|
||||||
unsigned whave; /* valid bytes in the window */
|
unsigned whave; /* valid bytes in the window */
|
||||||
unsigned write; /* window write index */
|
unsigned wnext; /* window write index */
|
||||||
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
|
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
|
||||||
unsigned long hold; /* local strm->hold */
|
unsigned long hold; /* local strm->hold */
|
||||||
unsigned bits; /* local strm->bits */
|
unsigned bits; /* local strm->bits */
|
||||||
@ -87,7 +67,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
code const FAR *dcode; /* local strm->distcode */
|
code const FAR *dcode; /* local strm->distcode */
|
||||||
unsigned lmask; /* mask for first level of length codes */
|
unsigned lmask; /* mask for first level of length codes */
|
||||||
unsigned dmask; /* mask for first level of distance codes */
|
unsigned dmask; /* mask for first level of distance codes */
|
||||||
code this; /* retrieved table entry */
|
code const *here; /* retrieved table entry */
|
||||||
unsigned op; /* code bits, operation, extra bits, or */
|
unsigned op; /* code bits, operation, extra bits, or */
|
||||||
/* window position, window bytes to copy */
|
/* window position, window bytes to copy */
|
||||||
unsigned len; /* match length, unused bytes */
|
unsigned len; /* match length, unused bytes */
|
||||||
@ -96,9 +76,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
|
|
||||||
/* copy state to local variables */
|
/* copy state to local variables */
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
in = strm->next_in - OFF;
|
in = strm->next_in;
|
||||||
last = in + (strm->avail_in - 5);
|
last = in + (strm->avail_in - 5);
|
||||||
out = strm->next_out - OFF;
|
out = strm->next_out;
|
||||||
beg = out - (start - strm->avail_out);
|
beg = out - (start - strm->avail_out);
|
||||||
end = out + (strm->avail_out - 257);
|
end = out + (strm->avail_out - 257);
|
||||||
#ifdef INFLATE_STRICT
|
#ifdef INFLATE_STRICT
|
||||||
@ -106,7 +86,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
#endif
|
#endif
|
||||||
wsize = state->wsize;
|
wsize = state->wsize;
|
||||||
whave = state->whave;
|
whave = state->whave;
|
||||||
write = state->write;
|
wnext = state->wnext;
|
||||||
window = state->window;
|
window = state->window;
|
||||||
hold = state->hold;
|
hold = state->hold;
|
||||||
bits = state->bits;
|
bits = state->bits;
|
||||||
@ -119,29 +99,29 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
input data or output space */
|
input data or output space */
|
||||||
do {
|
do {
|
||||||
if (bits < 15) {
|
if (bits < 15) {
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
this = lcode[hold & lmask];
|
here = lcode + (hold & lmask);
|
||||||
dolen:
|
dolen:
|
||||||
op = (unsigned)(this.bits);
|
op = (unsigned)(here->bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(this.op);
|
op = (unsigned)(here->op);
|
||||||
if (op == 0) { /* literal */
|
if (op == 0) { /* literal */
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here->val));
|
||||||
PUP(out) = (unsigned char)(this.val);
|
*out++ = (unsigned char)(here->val);
|
||||||
}
|
}
|
||||||
else if (op & 16) { /* length base */
|
else if (op & 16) { /* length base */
|
||||||
len = (unsigned)(this.val);
|
len = (unsigned)(here->val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (op) {
|
if (op) {
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
len += (unsigned)hold & ((1U << op) - 1);
|
len += (unsigned)hold & ((1U << op) - 1);
|
||||||
@ -150,25 +130,25 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
}
|
}
|
||||||
Tracevv((stderr, "inflate: length %u\n", len));
|
Tracevv((stderr, "inflate: length %u\n", len));
|
||||||
if (bits < 15) {
|
if (bits < 15) {
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
this = dcode[hold & dmask];
|
here = dcode + (hold & dmask);
|
||||||
dodist:
|
dodist:
|
||||||
op = (unsigned)(this.bits);
|
op = (unsigned)(here->bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(this.op);
|
op = (unsigned)(here->op);
|
||||||
if (op & 16) { /* distance base */
|
if (op & 16) { /* distance base */
|
||||||
dist = (unsigned)(this.val);
|
dist = (unsigned)(here->val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,79 +167,101 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
if (dist > op) { /* see if copy from window */
|
if (dist > op) { /* see if copy from window */
|
||||||
op = dist - op; /* distance back in window */
|
op = dist - op; /* distance back in window */
|
||||||
if (op > whave) {
|
if (op > whave) {
|
||||||
strm->msg = (char *)"invalid distance too far back";
|
if (state->sane) {
|
||||||
state->mode = BAD;
|
strm->msg =
|
||||||
break;
|
(char *)"invalid distance too far back";
|
||||||
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
if (len <= op - whave) {
|
||||||
|
do {
|
||||||
|
*out++ = 0;
|
||||||
|
} while (--len);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
len -= op - whave;
|
||||||
|
do {
|
||||||
|
*out++ = 0;
|
||||||
|
} while (--op > whave);
|
||||||
|
if (op == 0) {
|
||||||
|
from = out - dist;
|
||||||
|
do {
|
||||||
|
*out++ = *from++;
|
||||||
|
} while (--len);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
from = window - OFF;
|
from = window;
|
||||||
if (write == 0) { /* very common case */
|
if (wnext == 0) { /* very common case */
|
||||||
from += wsize - op;
|
from += wsize - op;
|
||||||
if (op < len) { /* some from window */
|
if (op < len) { /* some from window */
|
||||||
len -= op;
|
len -= op;
|
||||||
do {
|
do {
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
} while (--op);
|
} while (--op);
|
||||||
from = out - dist; /* rest from output */
|
from = out - dist; /* rest from output */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (write < op) { /* wrap around window */
|
else if (wnext < op) { /* wrap around window */
|
||||||
from += wsize + write - op;
|
from += wsize + wnext - op;
|
||||||
op -= write;
|
op -= wnext;
|
||||||
if (op < len) { /* some from end of window */
|
if (op < len) { /* some from end of window */
|
||||||
len -= op;
|
len -= op;
|
||||||
do {
|
do {
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
} while (--op);
|
} while (--op);
|
||||||
from = window - OFF;
|
from = window;
|
||||||
if (write < len) { /* some from start of window */
|
if (wnext < len) { /* some from start of window */
|
||||||
op = write;
|
op = wnext;
|
||||||
len -= op;
|
len -= op;
|
||||||
do {
|
do {
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
} while (--op);
|
} while (--op);
|
||||||
from = out - dist; /* rest from output */
|
from = out - dist; /* rest from output */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* contiguous in window */
|
else { /* contiguous in window */
|
||||||
from += write - op;
|
from += wnext - op;
|
||||||
if (op < len) { /* some from window */
|
if (op < len) { /* some from window */
|
||||||
len -= op;
|
len -= op;
|
||||||
do {
|
do {
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
} while (--op);
|
} while (--op);
|
||||||
from = out - dist; /* rest from output */
|
from = out - dist; /* rest from output */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (len > 2) {
|
while (len > 2) {
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
len -= 3;
|
len -= 3;
|
||||||
}
|
}
|
||||||
if (len) {
|
if (len) {
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
if (len > 1)
|
if (len > 1)
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
from = out - dist; /* copy direct from output */
|
from = out - dist; /* copy direct from output */
|
||||||
do { /* minimum length is three */
|
do { /* minimum length is three */
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
len -= 3;
|
len -= 3;
|
||||||
} while (len > 2);
|
} while (len > 2);
|
||||||
if (len) {
|
if (len) {
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
if (len > 1)
|
if (len > 1)
|
||||||
PUP(out) = PUP(from);
|
*out++ = *from++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||||
this = dcode[this.val + (hold & ((1U << op) - 1))];
|
here = dcode + here->val + (hold & ((1U << op) - 1));
|
||||||
goto dodist;
|
goto dodist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -269,7 +271,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level length code */
|
else if ((op & 64) == 0) { /* 2nd level length code */
|
||||||
this = lcode[this.val + (hold & ((1U << op) - 1))];
|
here = lcode + here->val + (hold & ((1U << op) - 1));
|
||||||
goto dolen;
|
goto dolen;
|
||||||
}
|
}
|
||||||
else if (op & 32) { /* end-of-block */
|
else if (op & 32) { /* end-of-block */
|
||||||
@ -291,8 +293,8 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
hold &= (1U << bits) - 1;
|
hold &= (1U << bits) - 1;
|
||||||
|
|
||||||
/* update state and return */
|
/* update state and return */
|
||||||
strm->next_in = in + OFF;
|
strm->next_in = in;
|
||||||
strm->next_out = out + OFF;
|
strm->next_out = out;
|
||||||
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
|
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
|
||||||
strm->avail_out = (unsigned)(out < end ?
|
strm->avail_out = (unsigned)(out < end ?
|
||||||
257 + (end - out) : 257 - (out - end));
|
257 + (end - out) : 257 - (out - end));
|
||||||
@ -305,7 +307,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
|
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
|
||||||
- Using bit fields for code structure
|
- Using bit fields for code structure
|
||||||
- Different op definition to avoid & for extra bits (do & for table bits)
|
- Different op definition to avoid & for extra bits (do & for table bits)
|
||||||
- Three separate decoding do-loops for direct, window, and write == 0
|
- Three separate decoding do-loops for direct, window, and wnext == 0
|
||||||
- Special case for distance > 1 copies to do overlapped load and store copy
|
- Special case for distance > 1 copies to do overlapped load and store copy
|
||||||
- Explicit branch predictions (based on measured branch probabilities)
|
- Explicit branch predictions (based on measured branch probabilities)
|
||||||
- Deferring match copy and interspersed it with decoding subsequent codes
|
- Deferring match copy and interspersed it with decoding subsequent codes
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2024 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
|
" inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
@ -29,14 +29,9 @@ const char inflate_copyright[] =
|
|||||||
table index bits. It will differ if the request is greater than the
|
table index bits. It will differ if the request is greater than the
|
||||||
longest code or if it is less than the shortest code.
|
longest code or if it is less than the shortest code.
|
||||||
*/
|
*/
|
||||||
int inflate_table(type, lens, codes, table, bits, work)
|
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||||
codetype type;
|
unsigned codes, code FAR * FAR *table,
|
||||||
unsigned short FAR *lens;
|
unsigned FAR *bits, unsigned short FAR *work) {
|
||||||
unsigned codes;
|
|
||||||
code FAR * FAR *table;
|
|
||||||
unsigned FAR *bits;
|
|
||||||
unsigned short FAR *work;
|
|
||||||
{
|
|
||||||
unsigned len; /* a code's length in bits */
|
unsigned len; /* a code's length in bits */
|
||||||
unsigned sym; /* index of code symbols */
|
unsigned sym; /* index of code symbols */
|
||||||
unsigned min, max; /* minimum and maximum code lengths */
|
unsigned min, max; /* minimum and maximum code lengths */
|
||||||
@ -50,11 +45,11 @@ unsigned short FAR *work;
|
|||||||
unsigned fill; /* index for replicating entries */
|
unsigned fill; /* index for replicating entries */
|
||||||
unsigned low; /* low bits for current root entry */
|
unsigned low; /* low bits for current root entry */
|
||||||
unsigned mask; /* mask for low root bits */
|
unsigned mask; /* mask for low root bits */
|
||||||
code this; /* table entry for duplication */
|
code here; /* table entry for duplication */
|
||||||
code FAR *next; /* next available space in table */
|
code FAR *next; /* next available space in table */
|
||||||
const unsigned short FAR *base; /* base value table to use */
|
const unsigned short FAR *base; /* base value table to use */
|
||||||
const unsigned short FAR *extra; /* extra bits table to use */
|
const unsigned short FAR *extra; /* extra bits table to use */
|
||||||
int end; /* use base and extra for symbol > end */
|
unsigned match; /* use base and extra for symbol >= match */
|
||||||
unsigned short count[MAXBITS+1]; /* number of codes of each length */
|
unsigned short count[MAXBITS+1]; /* number of codes of each length */
|
||||||
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
|
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
|
||||||
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
|
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
|
||||||
@ -62,7 +57,7 @@ unsigned short FAR *work;
|
|||||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||||
@ -115,15 +110,15 @@ unsigned short FAR *work;
|
|||||||
if (count[max] != 0) break;
|
if (count[max] != 0) break;
|
||||||
if (root > max) root = max;
|
if (root > max) root = max;
|
||||||
if (max == 0) { /* no symbols to code at all */
|
if (max == 0) { /* no symbols to code at all */
|
||||||
this.op = (unsigned char)64; /* invalid code marker */
|
here.op = (unsigned char)64; /* invalid code marker */
|
||||||
this.bits = (unsigned char)1;
|
here.bits = (unsigned char)1;
|
||||||
this.val = (unsigned short)0;
|
here.val = (unsigned short)0;
|
||||||
*(*table)++ = this; /* make a table to force an error */
|
*(*table)++ = here; /* make a table to force an error */
|
||||||
*(*table)++ = this;
|
*(*table)++ = here;
|
||||||
*bits = 1;
|
*bits = 1;
|
||||||
return 0; /* no symbols, but wait for decoding to report error */
|
return 0; /* no symbols, but wait for decoding to report error */
|
||||||
}
|
}
|
||||||
for (min = 1; min <= MAXBITS; min++)
|
for (min = 1; min < max; min++)
|
||||||
if (count[min] != 0) break;
|
if (count[min] != 0) break;
|
||||||
if (root < min) root = min;
|
if (root < min) root = min;
|
||||||
|
|
||||||
@ -166,11 +161,10 @@ unsigned short FAR *work;
|
|||||||
entered in the tables.
|
entered in the tables.
|
||||||
|
|
||||||
used keeps track of how many table entries have been allocated from the
|
used keeps track of how many table entries have been allocated from the
|
||||||
provided *table space. It is checked when a LENS table is being made
|
provided *table space. It is checked for LENS and DIST tables against
|
||||||
against the space in *table, ENOUGH, minus the maximum space needed by
|
the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
|
||||||
the worst case distance code, MAXD. This should never happen, but the
|
the initial root table size constants. See the comments in inftrees.h
|
||||||
sufficiency of ENOUGH has not been proven exhaustively, hence the check.
|
for more information.
|
||||||
This assumes that when type == LENS, bits == 9.
|
|
||||||
|
|
||||||
sym increments through all symbols, and the loop terminates when
|
sym increments through all symbols, and the loop terminates when
|
||||||
all codes of length max, i.e. all codes, have been processed. This
|
all codes of length max, i.e. all codes, have been processed. This
|
||||||
@ -182,19 +176,17 @@ unsigned short FAR *work;
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case CODES:
|
case CODES:
|
||||||
base = extra = work; /* dummy value--not used */
|
base = extra = work; /* dummy value--not used */
|
||||||
end = 19;
|
match = 20;
|
||||||
break;
|
break;
|
||||||
case LENS:
|
case LENS:
|
||||||
base = lbase;
|
base = lbase;
|
||||||
base -= 257;
|
|
||||||
extra = lext;
|
extra = lext;
|
||||||
extra -= 257;
|
match = 257;
|
||||||
end = 256;
|
|
||||||
break;
|
break;
|
||||||
default: /* DISTS */
|
default: /* DISTS */
|
||||||
base = dbase;
|
base = dbase;
|
||||||
extra = dext;
|
extra = dext;
|
||||||
end = -1;
|
match = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize state for loop */
|
/* initialize state for loop */
|
||||||
@ -209,24 +201,25 @@ unsigned short FAR *work;
|
|||||||
mask = used - 1; /* mask for comparing low */
|
mask = used - 1; /* mask for comparing low */
|
||||||
|
|
||||||
/* check available table space */
|
/* check available table space */
|
||||||
if (type == LENS && used >= ENOUGH - MAXD)
|
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||||
|
(type == DISTS && used > ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* process all codes and make table entries */
|
/* process all codes and make table entries */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* create table entry */
|
/* create table entry */
|
||||||
this.bits = (unsigned char)(len - drop);
|
here.bits = (unsigned char)(len - drop);
|
||||||
if ((int)(work[sym]) < end) {
|
if (work[sym] + 1U < match) {
|
||||||
this.op = (unsigned char)0;
|
here.op = (unsigned char)0;
|
||||||
this.val = work[sym];
|
here.val = work[sym];
|
||||||
}
|
}
|
||||||
else if ((int)(work[sym]) > end) {
|
else if (work[sym] >= match) {
|
||||||
this.op = (unsigned char)(extra[work[sym]]);
|
here.op = (unsigned char)(extra[work[sym] - match]);
|
||||||
this.val = base[work[sym]];
|
here.val = base[work[sym] - match];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.op = (unsigned char)(32 + 64); /* end of block */
|
here.op = (unsigned char)(32 + 64); /* end of block */
|
||||||
this.val = 0;
|
here.val = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replicate for those indices with low len bits equal to huff */
|
/* replicate for those indices with low len bits equal to huff */
|
||||||
@ -235,7 +228,7 @@ unsigned short FAR *work;
|
|||||||
min = fill; /* save offset to next table */
|
min = fill; /* save offset to next table */
|
||||||
do {
|
do {
|
||||||
fill -= incr;
|
fill -= incr;
|
||||||
next[(huff >> drop) + fill] = this;
|
next[(huff >> drop) + fill] = here;
|
||||||
} while (fill != 0);
|
} while (fill != 0);
|
||||||
|
|
||||||
/* backwards increment the len-bit code huff */
|
/* backwards increment the len-bit code huff */
|
||||||
@ -277,7 +270,8 @@ unsigned short FAR *work;
|
|||||||
|
|
||||||
/* check for enough space */
|
/* check for enough space */
|
||||||
used += 1U << curr;
|
used += 1U << curr;
|
||||||
if (type == LENS && used >= ENOUGH - MAXD)
|
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||||
|
(type == DISTS && used > ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* point entry in root table to sub-table */
|
/* point entry in root table to sub-table */
|
||||||
@ -288,38 +282,14 @@ unsigned short FAR *work;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* fill in remaining table entry if code is incomplete (guaranteed to have
|
||||||
Fill in rest of table for incomplete codes. This loop is similar to the
|
at most one remaining entry, since if the code is incomplete, the
|
||||||
loop above in incrementing huff for table indices. It is assumed that
|
maximum code length that was allowed to get this far is one bit) */
|
||||||
len is equal to curr + drop, so there is no loop needed to increment
|
if (huff != 0) {
|
||||||
through high index bits. When the current sub-table is filled, the loop
|
here.op = (unsigned char)64; /* invalid code marker */
|
||||||
drops back to the root table to fill in any remaining entries there.
|
here.bits = (unsigned char)(len - drop);
|
||||||
*/
|
here.val = (unsigned short)0;
|
||||||
this.op = (unsigned char)64; /* invalid code marker */
|
next[huff] = here;
|
||||||
this.bits = (unsigned char)(len - drop);
|
|
||||||
this.val = (unsigned short)0;
|
|
||||||
while (huff != 0) {
|
|
||||||
/* when done with sub-table, drop back to root table */
|
|
||||||
if (drop != 0 && (huff & mask) != low) {
|
|
||||||
drop = 0;
|
|
||||||
len = root;
|
|
||||||
next = *table;
|
|
||||||
this.bits = (unsigned char)len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* put invalid code marker in table */
|
|
||||||
next[huff >> drop] = this;
|
|
||||||
|
|
||||||
/* backwards increment the len-bit code huff */
|
|
||||||
incr = 1U << (len - 1);
|
|
||||||
while (huff & incr)
|
|
||||||
incr >>= 1;
|
|
||||||
if (incr != 0) {
|
|
||||||
huff &= incr - 1;
|
|
||||||
huff += incr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
huff = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set return parameters */
|
/* set return parameters */
|
||||||
|
788
PDF/src/trees.c
788
PDF/src/trees.c
File diff suppressed because it is too large
Load Diff
145
PDF/src/zutil.c
145
PDF/src/zutil.c
@ -1,58 +1,56 @@
|
|||||||
/* zutil.c -- target dependent utility functions for the compression library
|
/* zutil.c -- target dependent utility functions for the compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2017 Jean-loup Gailly
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id: //poco/Main/Foundation/src/zutil.c#8 $ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#include "zutil.h"
|
#include "zutil.h"
|
||||||
|
#ifndef Z_SOLO
|
||||||
#ifndef NO_DUMMY_DECL
|
# include "gzguts.h"
|
||||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char * const z_errmsg[10] = {
|
z_const char * const z_errmsg[10] = {
|
||||||
"need dictionary", /* Z_NEED_DICT 2 */
|
(z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
|
||||||
"stream end", /* Z_STREAM_END 1 */
|
(z_const char *)"stream end", /* Z_STREAM_END 1 */
|
||||||
"", /* Z_OK 0 */
|
(z_const char *)"", /* Z_OK 0 */
|
||||||
"file error", /* Z_ERRNO (-1) */
|
(z_const char *)"file error", /* Z_ERRNO (-1) */
|
||||||
"stream error", /* Z_STREAM_ERROR (-2) */
|
(z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */
|
||||||
"data error", /* Z_DATA_ERROR (-3) */
|
(z_const char *)"data error", /* Z_DATA_ERROR (-3) */
|
||||||
"insufficient memory", /* Z_MEM_ERROR (-4) */
|
(z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
|
||||||
"buffer error", /* Z_BUF_ERROR (-5) */
|
(z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */
|
||||||
"incompatible version",/* Z_VERSION_ERROR (-6) */
|
(z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
|
||||||
""};
|
(z_const char *)""
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const char * ZEXPORT zlibVersion()
|
const char * ZEXPORT zlibVersion(void) {
|
||||||
{
|
|
||||||
return ZLIB_VERSION;
|
return ZLIB_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
uLong ZEXPORT zlibCompileFlags()
|
uLong ZEXPORT zlibCompileFlags(void) {
|
||||||
{
|
|
||||||
uLong flags;
|
uLong flags;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
switch (sizeof(uInt)) {
|
switch ((int)(sizeof(uInt))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1; break;
|
case 4: flags += 1; break;
|
||||||
case 8: flags += 2; break;
|
case 8: flags += 2; break;
|
||||||
default: flags += 3;
|
default: flags += 3;
|
||||||
}
|
}
|
||||||
switch (sizeof(uLong)) {
|
switch ((int)(sizeof(uLong))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1 << 2; break;
|
case 4: flags += 1 << 2; break;
|
||||||
case 8: flags += 2 << 2; break;
|
case 8: flags += 2 << 2; break;
|
||||||
default: flags += 3 << 2;
|
default: flags += 3 << 2;
|
||||||
}
|
}
|
||||||
switch (sizeof(voidpf)) {
|
switch ((int)(sizeof(voidpf))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1 << 4; break;
|
case 4: flags += 1 << 4; break;
|
||||||
case 8: flags += 2 << 4; break;
|
case 8: flags += 2 << 4; break;
|
||||||
default: flags += 3 << 4;
|
default: flags += 3 << 4;
|
||||||
}
|
}
|
||||||
switch (sizeof(z_off_t)) {
|
switch ((int)(sizeof(z_off_t))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1 << 6; break;
|
case 4: flags += 1 << 6; break;
|
||||||
case 8: flags += 2 << 6; break;
|
case 8: flags += 2 << 6; break;
|
||||||
@ -61,9 +59,11 @@ uLong ZEXPORT zlibCompileFlags()
|
|||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
flags += 1 << 8;
|
flags += 1 << 8;
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
#if defined(ASMV) || defined(ASMINF)
|
#if defined(ASMV) || defined(ASMINF)
|
||||||
flags += 1 << 9;
|
flags += 1 << 9;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
#ifdef ZLIB_WINAPI
|
#ifdef ZLIB_WINAPI
|
||||||
flags += 1 << 10;
|
flags += 1 << 10;
|
||||||
#endif
|
#endif
|
||||||
@ -85,27 +85,27 @@ uLong ZEXPORT zlibCompileFlags()
|
|||||||
#ifdef FASTEST
|
#ifdef FASTEST
|
||||||
flags += 1L << 21;
|
flags += 1L << 21;
|
||||||
#endif
|
#endif
|
||||||
#ifdef STDC
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
# ifdef NO_vsnprintf
|
# ifdef NO_vsnprintf
|
||||||
flags += 1L << 25;
|
flags += 1L << 25;
|
||||||
# ifdef HAS_vsprintf_void
|
# ifdef HAS_vsprintf_void
|
||||||
flags += 1L << 26;
|
flags += 1L << 26;
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# ifdef HAS_vsnprintf_void
|
# ifdef HAS_vsnprintf_void
|
||||||
flags += 1L << 26;
|
flags += 1L << 26;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
flags += 1L << 24;
|
flags += 1L << 24;
|
||||||
# ifdef NO_snprintf
|
# ifdef NO_snprintf
|
||||||
flags += 1L << 25;
|
flags += 1L << 25;
|
||||||
# ifdef HAS_sprintf_void
|
# ifdef HAS_sprintf_void
|
||||||
flags += 1L << 26;
|
flags += 1L << 26;
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# ifdef HAS_snprintf_void
|
# ifdef HAS_snprintf_void
|
||||||
flags += 1L << 26;
|
flags += 1L << 26;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@ -113,15 +113,13 @@ uLong ZEXPORT zlibCompileFlags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
|
#include <stdlib.h>
|
||||||
# ifndef verbose
|
# ifndef verbose
|
||||||
# define verbose 0
|
# define verbose 0
|
||||||
# endif
|
# endif
|
||||||
int z_verbose = verbose;
|
int ZLIB_INTERNAL z_verbose = verbose;
|
||||||
|
|
||||||
void z_error (m)
|
void ZLIB_INTERNAL z_error(char *m) {
|
||||||
char *m;
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s\n", m);
|
fprintf(stderr, "%s\n", m);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -130,14 +128,12 @@ void z_error (m)
|
|||||||
/* exported to allow conversion of error code to string for compress() and
|
/* exported to allow conversion of error code to string for compress() and
|
||||||
* uncompress()
|
* uncompress()
|
||||||
*/
|
*/
|
||||||
const char * ZEXPORT zError(err)
|
const char * ZEXPORT zError(int err) {
|
||||||
int err;
|
|
||||||
{
|
|
||||||
return ERR_MSG(err);
|
return ERR_MSG(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
|
||||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
/* The older Microsoft C Run-Time Library for Windows CE doesn't have
|
||||||
* errno. We define it as a global variable to simplify porting.
|
* errno. We define it as a global variable to simplify porting.
|
||||||
* Its value is always 0 and should not be used.
|
* Its value is always 0 and should not be used.
|
||||||
*/
|
*/
|
||||||
@ -146,22 +142,14 @@ const char * ZEXPORT zError(err)
|
|||||||
|
|
||||||
#ifndef HAVE_MEMCPY
|
#ifndef HAVE_MEMCPY
|
||||||
|
|
||||||
void zmemcpy(dest, source, len)
|
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) {
|
||||||
Bytef* dest;
|
|
||||||
const Bytef* source;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
if (len == 0) return;
|
if (len == 0) return;
|
||||||
do {
|
do {
|
||||||
*dest++ = *source++; /* ??? to be unrolled */
|
*dest++ = *source++; /* ??? to be unrolled */
|
||||||
} while (--len != 0);
|
} while (--len != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmemcmp(s1, s2, len)
|
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
|
||||||
const Bytef* s1;
|
|
||||||
const Bytef* s2;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
uInt j;
|
uInt j;
|
||||||
|
|
||||||
for (j = 0; j < len; j++) {
|
for (j = 0; j < len; j++) {
|
||||||
@ -170,10 +158,7 @@ int zmemcmp(s1, s2, len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmemzero(dest, len)
|
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
|
||||||
Bytef* dest;
|
|
||||||
uInt len;
|
|
||||||
{
|
|
||||||
if (len == 0) return;
|
if (len == 0) return;
|
||||||
do {
|
do {
|
||||||
*dest++ = 0; /* ??? to be unrolled */
|
*dest++ = 0; /* ??? to be unrolled */
|
||||||
@ -181,6 +166,7 @@ void zmemzero(dest, len)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
|
||||||
#ifdef SYS16BIT
|
#ifdef SYS16BIT
|
||||||
|
|
||||||
@ -213,11 +199,12 @@ local ptr_table table[MAX_PTR];
|
|||||||
* a protected system like OS/2. Use Microsoft C instead.
|
* a protected system like OS/2. Use Microsoft C instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||||
{
|
voidpf buf;
|
||||||
voidpf buf = opaque; /* just to make some compilers happy */
|
|
||||||
ulg bsize = (ulg)items*size;
|
ulg bsize = (ulg)items*size;
|
||||||
|
|
||||||
|
(void)opaque;
|
||||||
|
|
||||||
/* If we allocate less than 65520 bytes, we assume that farmalloc
|
/* If we allocate less than 65520 bytes, we assume that farmalloc
|
||||||
* will return a usable pointer which doesn't have to be normalized.
|
* will return a usable pointer which doesn't have to be normalized.
|
||||||
*/
|
*/
|
||||||
@ -237,9 +224,11 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
(void)opaque;
|
||||||
|
|
||||||
if (*(ush*)&ptr != 0) { /* object < 64K */
|
if (*(ush*)&ptr != 0) { /* object < 64K */
|
||||||
farfree(ptr);
|
farfree(ptr);
|
||||||
return;
|
return;
|
||||||
@ -255,7 +244,6 @@ void zcfree (voidpf opaque, voidpf ptr)
|
|||||||
next_ptr--;
|
next_ptr--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ptr = opaque; /* just to make some compilers happy */
|
|
||||||
Assert(0, "zcfree: ptr not found");
|
Assert(0, "zcfree: ptr not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,15 +260,13 @@ void zcfree (voidpf opaque, voidpf ptr)
|
|||||||
# define _hfree hfree
|
# define _hfree hfree
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
|
||||||
{
|
(void)opaque;
|
||||||
if (opaque) opaque = 0; /* to make compiler happy */
|
|
||||||
return _halloc((long)items, size);
|
return _halloc((long)items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||||
{
|
(void)opaque;
|
||||||
if (opaque) opaque = 0; /* to make compiler happy */
|
|
||||||
_hfree(ptr);
|
_hfree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,27 +278,22 @@ void zcfree (voidpf opaque, voidpf ptr)
|
|||||||
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
||||||
|
|
||||||
#ifndef STDC
|
#ifndef STDC
|
||||||
extern voidp malloc OF((uInt size));
|
extern voidp malloc(uInt size);
|
||||||
extern voidp calloc OF((uInt items, uInt size));
|
extern voidp calloc(uInt items, uInt size);
|
||||||
extern void free OF((voidpf ptr));
|
extern void free(voidpf ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf zcalloc (opaque, items, size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||||
voidpf opaque;
|
(void)opaque;
|
||||||
unsigned items;
|
|
||||||
unsigned size;
|
|
||||||
{
|
|
||||||
if (opaque) items += size - size; /* make compiler happy */
|
|
||||||
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
||||||
(voidpf)calloc(items, size);
|
(voidpf)calloc(items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zcfree (opaque, ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
||||||
voidpf opaque;
|
(void)opaque;
|
||||||
voidpf ptr;
|
|
||||||
{
|
|
||||||
free(ptr);
|
free(ptr);
|
||||||
if (opaque) return; /* make compiler happy */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MY_ZCALLOC */
|
#endif /* MY_ZCALLOC */
|
||||||
|
|
||||||
|
#endif /* !Z_SOLO */
|
||||||
|
Loading…
Reference in New Issue
Block a user