diff options
| -rw-r--r-- | compress.c | 29 | ||||
| -rw-r--r-- | contrib/vstudio/vc10/zlibvc.def | 4 | ||||
| -rw-r--r-- | contrib/vstudio/vc11/zlibvc.def | 4 | ||||
| -rw-r--r-- | contrib/vstudio/vc12/zlibvc.def | 4 | ||||
| -rw-r--r-- | contrib/vstudio/vc14/zlibvc.def | 4 | ||||
| -rw-r--r-- | contrib/vstudio/vc17/zlibvc.def | 4 | ||||
| -rw-r--r-- | contrib/vstudio/vc9/zlibvc.def | 4 | ||||
| -rw-r--r-- | os400/bndsrc | 4 | ||||
| -rw-r--r-- | os400/zlib.inc | 25 | ||||
| -rw-r--r-- | uncompr.c | 56 | ||||
| -rw-r--r-- | win32/zlib.def | 4 | ||||
| -rw-r--r-- | zconf.h | 4 | ||||
| -rw-r--r-- | zconf.h.in | 4 | ||||
| -rw-r--r-- | zlib.h | 37 | ||||
| -rw-r--r-- | zlib.map | 4 |
15 files changed, 148 insertions, 43 deletions
| @@ -18,13 +18,15 @@ | |||
| 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, | 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 20 | Z_STREAM_ERROR if the level parameter is invalid. | 20 | Z_STREAM_ERROR if the level parameter is invalid. |
| 21 | |||
| 22 | The _z versions of the functions take size_t length arguments. | ||
| 21 | */ | 23 | */ |
| 22 | int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, | 24 | int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source, |
| 23 | uLong sourceLen, int level) { | 25 | z_size_t sourceLen, int level) { |
| 24 | z_stream stream; | 26 | z_stream stream; |
| 25 | int err; | 27 | int err; |
| 26 | const uInt max = (uInt)-1; | 28 | const uInt max = (uInt)-1; |
| 27 | uLong left; | 29 | z_size_t left; |
| 28 | 30 | ||
| 29 | left = *destLen; | 31 | left = *destLen; |
| 30 | *destLen = 0; | 32 | *destLen = 0; |
| @@ -43,23 +45,36 @@ int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, | |||
| 43 | 45 | ||
| 44 | do { | 46 | do { |
| 45 | if (stream.avail_out == 0) { | 47 | if (stream.avail_out == 0) { |
| 46 | stream.avail_out = left > (uLong)max ? max : (uInt)left; | 48 | stream.avail_out = left > (z_size_t)max ? max : (uInt)left; |
| 47 | left -= stream.avail_out; | 49 | left -= stream.avail_out; |
| 48 | } | 50 | } |
| 49 | if (stream.avail_in == 0) { | 51 | if (stream.avail_in == 0) { |
| 50 | stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; | 52 | stream.avail_in = sourceLen > (z_size_t)max ? max : |
| 53 | (uInt)sourceLen; | ||
| 51 | sourceLen -= stream.avail_in; | 54 | sourceLen -= stream.avail_in; |
| 52 | } | 55 | } |
| 53 | err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); | 56 | err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); |
| 54 | } while (err == Z_OK); | 57 | } while (err == Z_OK); |
| 55 | 58 | ||
| 56 | *destLen = stream.total_out; | 59 | *destLen = stream.next_out - dest; |
| 57 | deflateEnd(&stream); | 60 | deflateEnd(&stream); |
| 58 | return err == Z_STREAM_END ? Z_OK : err; | 61 | return err == Z_STREAM_END ? Z_OK : err; |
| 59 | } | 62 | } |
| 60 | 63 | int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, | |
| 64 | uLong sourceLen, int level) { | ||
| 65 | int ret; | ||
| 66 | z_size_t got = *destLen; | ||
| 67 | ret = compress2_z(dest, &got, source, sourceLen, level); | ||
| 68 | *destLen = (uLong)got; | ||
| 69 | return ret; | ||
| 70 | } | ||
| 61 | /* =========================================================================== | 71 | /* =========================================================================== |
| 62 | */ | 72 | */ |
| 73 | int ZEXPORT compress_z(Bytef *dest, z_size_t *destLen, const Bytef *source, | ||
| 74 | z_size_t sourceLen) { | ||
| 75 | return compress2_z(dest, destLen, source, sourceLen, | ||
| 76 | Z_DEFAULT_COMPRESSION); | ||
| 77 | } | ||
| 63 | int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, | 78 | int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, |
| 64 | uLong sourceLen) { | 79 | uLong sourceLen) { |
| 65 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); | 80 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); |
diff --git a/contrib/vstudio/vc10/zlibvc.def b/contrib/vstudio/vc10/zlibvc.def index e7fdebf1..e7fe0a32 100644 --- a/contrib/vstudio/vc10/zlibvc.def +++ b/contrib/vstudio/vc10/zlibvc.def | |||
| @@ -163,3 +163,7 @@ EXPORTS | |||
| 163 | ; zlib1 v1.3.2 added: | 163 | ; zlib1 v1.3.2 added: |
| 164 | compressBound_z @180 | 164 | compressBound_z @180 |
| 165 | deflateBound_z @181 | 165 | deflateBound_z @181 |
| 166 | compress_z @182 | ||
| 167 | compress2_z @183 | ||
| 168 | uncompress_z @184 | ||
| 169 | uncompress2_z @185 | ||
diff --git a/contrib/vstudio/vc11/zlibvc.def b/contrib/vstudio/vc11/zlibvc.def index e7fdebf1..e7fe0a32 100644 --- a/contrib/vstudio/vc11/zlibvc.def +++ b/contrib/vstudio/vc11/zlibvc.def | |||
| @@ -163,3 +163,7 @@ EXPORTS | |||
| 163 | ; zlib1 v1.3.2 added: | 163 | ; zlib1 v1.3.2 added: |
| 164 | compressBound_z @180 | 164 | compressBound_z @180 |
| 165 | deflateBound_z @181 | 165 | deflateBound_z @181 |
| 166 | compress_z @182 | ||
| 167 | compress2_z @183 | ||
| 168 | uncompress_z @184 | ||
| 169 | uncompress2_z @185 | ||
diff --git a/contrib/vstudio/vc12/zlibvc.def b/contrib/vstudio/vc12/zlibvc.def index e7fdebf1..e7fe0a32 100644 --- a/contrib/vstudio/vc12/zlibvc.def +++ b/contrib/vstudio/vc12/zlibvc.def | |||
| @@ -163,3 +163,7 @@ EXPORTS | |||
| 163 | ; zlib1 v1.3.2 added: | 163 | ; zlib1 v1.3.2 added: |
| 164 | compressBound_z @180 | 164 | compressBound_z @180 |
| 165 | deflateBound_z @181 | 165 | deflateBound_z @181 |
| 166 | compress_z @182 | ||
| 167 | compress2_z @183 | ||
| 168 | uncompress_z @184 | ||
| 169 | uncompress2_z @185 | ||
diff --git a/contrib/vstudio/vc14/zlibvc.def b/contrib/vstudio/vc14/zlibvc.def index e7fdebf1..e7fe0a32 100644 --- a/contrib/vstudio/vc14/zlibvc.def +++ b/contrib/vstudio/vc14/zlibvc.def | |||
| @@ -163,3 +163,7 @@ EXPORTS | |||
| 163 | ; zlib1 v1.3.2 added: | 163 | ; zlib1 v1.3.2 added: |
| 164 | compressBound_z @180 | 164 | compressBound_z @180 |
| 165 | deflateBound_z @181 | 165 | deflateBound_z @181 |
| 166 | compress_z @182 | ||
| 167 | compress2_z @183 | ||
| 168 | uncompress_z @184 | ||
| 169 | uncompress2_z @185 | ||
diff --git a/contrib/vstudio/vc17/zlibvc.def b/contrib/vstudio/vc17/zlibvc.def index e7fdebf1..e7fe0a32 100644 --- a/contrib/vstudio/vc17/zlibvc.def +++ b/contrib/vstudio/vc17/zlibvc.def | |||
| @@ -163,3 +163,7 @@ EXPORTS | |||
| 163 | ; zlib1 v1.3.2 added: | 163 | ; zlib1 v1.3.2 added: |
| 164 | compressBound_z @180 | 164 | compressBound_z @180 |
| 165 | deflateBound_z @181 | 165 | deflateBound_z @181 |
| 166 | compress_z @182 | ||
| 167 | compress2_z @183 | ||
| 168 | uncompress_z @184 | ||
| 169 | uncompress2_z @185 | ||
diff --git a/contrib/vstudio/vc9/zlibvc.def b/contrib/vstudio/vc9/zlibvc.def index e7fdebf1..e7fe0a32 100644 --- a/contrib/vstudio/vc9/zlibvc.def +++ b/contrib/vstudio/vc9/zlibvc.def | |||
| @@ -163,3 +163,7 @@ EXPORTS | |||
| 163 | ; zlib1 v1.3.2 added: | 163 | ; zlib1 v1.3.2 added: |
| 164 | compressBound_z @180 | 164 | compressBound_z @180 |
| 165 | deflateBound_z @181 | 165 | deflateBound_z @181 |
| 166 | compress_z @182 | ||
| 167 | compress2_z @183 | ||
| 168 | uncompress_z @184 | ||
| 169 | uncompress2_z @185 | ||
diff --git a/os400/bndsrc b/os400/bndsrc index ce48ff4d..6b0d297a 100644 --- a/os400/bndsrc +++ b/os400/bndsrc | |||
| @@ -136,5 +136,9 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') | |||
| 136 | 136 | ||
| 137 | EXPORT SYMBOL("compressBound_z") | 137 | EXPORT SYMBOL("compressBound_z") |
| 138 | EXPORT SYMBOL("deflateBound_z") | 138 | EXPORT SYMBOL("deflateBound_z") |
| 139 | EXPORT SYMBOL("compress_z") | ||
| 140 | EXPORT SYMBOL("compress2_z") | ||
| 141 | EXPORT SYMBOL("uncompress_z") | ||
| 142 | EXPORT SYMBOL("uncompress2_z") | ||
| 139 | 143 | ||
| 140 | ENDPGMEXP | 144 | ENDPGMEXP |
diff --git a/os400/zlib.inc b/os400/zlib.inc index 031ff3ec..f884f8f0 100644 --- a/os400/zlib.inc +++ b/os400/zlib.inc | |||
| @@ -124,6 +124,19 @@ | |||
| 124 | D sourceLen 10U 0 value Source length | 124 | D sourceLen 10U 0 value Source length |
| 125 | D level 10I 0 value Compression level | 125 | D level 10I 0 value Compression level |
| 126 | * | 126 | * |
| 127 | D compress_z PR 10I 0 extproc('compress') | ||
| 128 | D dest 65535 options(*varsize) Destination buffer | ||
| 129 | D destLen 20U 0 Destination length | ||
| 130 | D source 65535 const options(*varsize) Source buffer | ||
| 131 | D sourceLen 20u 0 value Source length | ||
| 132 | * | ||
| 133 | D compress2_z PR 10I 0 extproc('compress2') | ||
| 134 | D dest 65535 options(*varsize) Destination buffer | ||
| 135 | D destLen 20U 0 Destination length | ||
| 136 | D source 65535 const options(*varsize) Source buffer | ||
| 137 | D sourceLen 20U 0 value Source length | ||
| 138 | D level 10I 0 value Compression level | ||
| 139 | * | ||
| 127 | D compressBound PR 10U 0 extproc('compressBound') | 140 | D compressBound PR 10U 0 extproc('compressBound') |
| 128 | D sourceLen 10U 0 value | 141 | D sourceLen 10U 0 value |
| 129 | * | 142 | * |
| @@ -142,6 +155,18 @@ | |||
| 142 | D source 65535 const options(*varsize) Source buffer | 155 | D source 65535 const options(*varsize) Source buffer |
| 143 | D sourceLen 10U 0 Source length | 156 | D sourceLen 10U 0 Source length |
| 144 | * | 157 | * |
| 158 | D uncompress_z PR 10I 0 extproc('uncompress') | ||
| 159 | D dest 65535 options(*varsize) Destination buffer | ||
| 160 | D destLen 20U 0 Destination length | ||
| 161 | D source 65535 const options(*varsize) Source buffer | ||
| 162 | D sourceLen 20U 0 value Source length | ||
| 163 | * | ||
| 164 | D uncompress2_z PR 10I 0 extproc('uncompress2') | ||
| 165 | D dest 65535 options(*varsize) Destination buffer | ||
| 166 | D destLen 20U 0 Destination length | ||
| 167 | D source 65535 const options(*varsize) Source buffer | ||
| 168 | D sourceLen 20U 0 Source length | ||
| 169 | * | ||
| 145 | /if not defined(LARGE_FILES) | 170 | /if not defined(LARGE_FILES) |
| 146 | D gzopen PR extproc('gzopen') | 171 | D gzopen PR extproc('gzopen') |
| 147 | D like(gzFile) | 172 | D like(gzFile) |
| @@ -23,24 +23,20 @@ | |||
| 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or | 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or |
| 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is | 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is |
| 25 | an incomplete zlib stream. | 25 | an incomplete zlib stream. |
| 26 | |||
| 27 | The _z versions of the functions take size_t length arguments. | ||
| 26 | */ | 28 | */ |
| 27 | int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, | 29 | int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source, |
| 28 | uLong *sourceLen) { | 30 | z_size_t *sourceLen) { |
| 29 | z_stream stream; | 31 | z_stream stream; |
| 30 | int err; | 32 | int err; |
| 31 | const uInt max = (uInt)-1; | 33 | const uInt max = (uInt)-1; |
| 32 | uLong len, left; | 34 | z_size_t len, left; |
| 33 | Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ | ||
| 34 | 35 | ||
| 35 | len = *sourceLen; | 36 | len = *sourceLen; |
| 36 | if (*destLen) { | 37 | left = *destLen; |
| 37 | left = *destLen; | 38 | if (left == 0 && dest == Z_NULL) |
| 38 | *destLen = 0; | 39 | dest = (Bytef *)&stream.reserved; /* next_out cannot be NULL */ |
| 39 | } | ||
| 40 | else { | ||
| 41 | left = 1; | ||
| 42 | dest = buf; | ||
| 43 | } | ||
| 44 | 40 | ||
| 45 | stream.next_in = (z_const Bytef *)source; | 41 | stream.next_in = (z_const Bytef *)source; |
| 46 | stream.avail_in = 0; | 42 | stream.avail_in = 0; |
| @@ -56,30 +52,46 @@ int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, | |||
| 56 | 52 | ||
| 57 | do { | 53 | do { |
| 58 | if (stream.avail_out == 0) { | 54 | if (stream.avail_out == 0) { |
| 59 | stream.avail_out = left > (uLong)max ? max : (uInt)left; | 55 | stream.avail_out = left > (z_size_t)max ? max : (uInt)left; |
| 60 | left -= stream.avail_out; | 56 | left -= stream.avail_out; |
| 61 | } | 57 | } |
| 62 | if (stream.avail_in == 0) { | 58 | if (stream.avail_in == 0) { |
| 63 | stream.avail_in = len > (uLong)max ? max : (uInt)len; | 59 | stream.avail_in = len > (z_size_t)max ? max : (uInt)len; |
| 64 | len -= stream.avail_in; | 60 | len -= stream.avail_in; |
| 65 | } | 61 | } |
| 66 | err = inflate(&stream, Z_NO_FLUSH); | 62 | err = inflate(&stream, Z_NO_FLUSH); |
| 67 | } while (err == Z_OK); | 63 | } while (err == Z_OK); |
| 68 | 64 | ||
| 69 | *sourceLen -= len + stream.avail_in; | 65 | /* Set len and left to the unused input data and unused output space. Set |
| 70 | if (dest != buf) | 66 | *sourceLen to the amount of input consumed. Set *destLen to the amount |
| 71 | *destLen = stream.total_out; | 67 | of data produced. */ |
| 72 | else if (stream.total_out && err == Z_BUF_ERROR) | 68 | len += stream.avail_in; |
| 73 | left = 1; | 69 | left += stream.avail_out; |
| 70 | *sourceLen -= len; | ||
| 71 | *destLen -= left; | ||
| 74 | 72 | ||
| 75 | inflateEnd(&stream); | 73 | inflateEnd(&stream); |
| 76 | return err == Z_STREAM_END ? Z_OK : | 74 | return err == Z_STREAM_END ? Z_OK : |
| 77 | err == Z_NEED_DICT ? Z_DATA_ERROR : | 75 | err == Z_NEED_DICT ? Z_DATA_ERROR : |
| 78 | err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : | 76 | err == Z_BUF_ERROR && len == 0 ? Z_DATA_ERROR : |
| 79 | err; | 77 | err; |
| 80 | } | 78 | } |
| 81 | 79 | int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, | |
| 80 | uLong *sourceLen) { | ||
| 81 | int ret; | ||
| 82 | z_size_t got = *destLen, used = *sourceLen; | ||
| 83 | ret = uncompress2_z(dest, &got, source, &used); | ||
| 84 | *sourceLen = (uLong)used; | ||
| 85 | *destLen = (uLong)got; | ||
| 86 | return ret; | ||
| 87 | } | ||
| 88 | int ZEXPORT uncompress_z(Bytef *dest, z_size_t *destLen, const Bytef *source, | ||
| 89 | z_size_t sourceLen) { | ||
| 90 | z_size_t used = sourceLen; | ||
| 91 | return uncompress2_z(dest, destLen, source, &used); | ||
| 92 | } | ||
| 82 | int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, | 93 | int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, |
| 83 | uLong sourceLen) { | 94 | uLong sourceLen) { |
| 84 | return uncompress2(dest, destLen, source, &sourceLen); | 95 | uLong used = sourceLen; |
| 96 | return uncompress2(dest, destLen, source, &used); | ||
| 85 | } | 97 | } |
diff --git a/win32/zlib.def b/win32/zlib.def index dc44e7c0..25da22d3 100644 --- a/win32/zlib.def +++ b/win32/zlib.def | |||
| @@ -34,10 +34,14 @@ EXPORTS | |||
| 34 | ; utility functions | 34 | ; utility functions |
| 35 | compress | 35 | compress |
| 36 | compress2 | 36 | compress2 |
| 37 | compress_z | ||
| 38 | compress2_z | ||
| 37 | compressBound | 39 | compressBound |
| 38 | compressBound_z | 40 | compressBound_z |
| 39 | uncompress | 41 | uncompress |
| 40 | uncompress2 | 42 | uncompress2 |
| 43 | uncompress_z | ||
| 44 | uncompress2_z | ||
| 41 | gzopen | 45 | gzopen |
| 42 | gzdopen | 46 | gzdopen |
| 43 | gzbuffer | 47 | gzbuffer |
| @@ -33,6 +33,8 @@ | |||
| 33 | # ifndef Z_SOLO | 33 | # ifndef Z_SOLO |
| 34 | # define compress z_compress | 34 | # define compress z_compress |
| 35 | # define compress2 z_compress2 | 35 | # define compress2 z_compress2 |
| 36 | # define compress_z z_compress_z | ||
| 37 | # define compress2_z z_compress2_z | ||
| 36 | # define compressBound z_compressBound | 38 | # define compressBound z_compressBound |
| 37 | # define compressBound_z z_compressBound_z | 39 | # define compressBound_z z_compressBound_z |
| 38 | # endif | 40 | # endif |
| @@ -135,6 +137,8 @@ | |||
| 135 | # ifndef Z_SOLO | 137 | # ifndef Z_SOLO |
| 136 | # define uncompress z_uncompress | 138 | # define uncompress z_uncompress |
| 137 | # define uncompress2 z_uncompress2 | 139 | # define uncompress2 z_uncompress2 |
| 140 | # define uncompress_z z_uncompress_z | ||
| 141 | # define uncompress2_z z_uncompress2_z | ||
| 138 | # endif | 142 | # endif |
| 139 | # define zError z_zError | 143 | # define zError z_zError |
| 140 | # ifndef Z_SOLO | 144 | # ifndef Z_SOLO |
| @@ -33,6 +33,8 @@ | |||
| 33 | # ifndef Z_SOLO | 33 | # ifndef Z_SOLO |
| 34 | # define compress z_compress | 34 | # define compress z_compress |
| 35 | # define compress2 z_compress2 | 35 | # define compress2 z_compress2 |
| 36 | # define compress_z z_compress_z | ||
| 37 | # define compress2_z z_compress2_z | ||
| 36 | # define compressBound z_compressBound | 38 | # define compressBound z_compressBound |
| 37 | # define compressBound_z z_compressBound_z | 39 | # define compressBound_z z_compressBound_z |
| 38 | # endif | 40 | # endif |
| @@ -135,6 +137,8 @@ | |||
| 135 | # ifndef Z_SOLO | 137 | # ifndef Z_SOLO |
| 136 | # define uncompress z_uncompress | 138 | # define uncompress z_uncompress |
| 137 | # define uncompress2 z_uncompress2 | 139 | # define uncompress2 z_uncompress2 |
| 140 | # define uncompress_z z_uncompress_z | ||
| 141 | # define uncompress2_z z_uncompress2_z | ||
| 138 | # endif | 142 | # endif |
| 139 | # define zError z_zError | 143 | # define zError z_zError |
| 140 | # ifndef Z_SOLO | 144 | # ifndef Z_SOLO |
| @@ -779,8 +779,8 @@ ZEXTERN z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen); | |||
| 779 | be larger than the value returned by deflateBound() if flush options other | 779 | be larger than the value returned by deflateBound() if flush options other |
| 780 | than Z_FINISH or Z_NO_FLUSH are used. | 780 | than Z_FINISH or Z_NO_FLUSH are used. |
| 781 | 781 | ||
| 782 | delfateBound_z() is the same, but takes and returns a size_t length for | 782 | delfateBound_z() is the same, but takes and returns a size_t length. Note |
| 783 | those systems on which a long is 32 bits. | 783 | that a long is 32 bits on Windows. |
| 784 | */ | 784 | */ |
| 785 | 785 | ||
| 786 | ZEXTERN int ZEXPORT deflatePending(z_streamp strm, | 786 | ZEXTERN int ZEXPORT deflatePending(z_streamp strm, |
| @@ -1261,11 +1261,14 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags(void); | |||
| 1261 | stream-oriented functions. To simplify the interface, some default options | 1261 | stream-oriented functions. To simplify the interface, some default options |
| 1262 | are assumed (compression level and memory usage, standard memory allocation | 1262 | are assumed (compression level and memory usage, standard memory allocation |
| 1263 | functions). The source code of these utility functions can be modified if | 1263 | functions). The source code of these utility functions can be modified if |
| 1264 | you need special options. | 1264 | you need special options. The _z versions of the functions use the size_t |
| 1265 | type for lengths. Note that a long is 32 bits on Windows. | ||
| 1265 | */ | 1266 | */ |
| 1266 | 1267 | ||
| 1267 | ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, | 1268 | ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, |
| 1268 | const Bytef *source, uLong sourceLen); | 1269 | const Bytef *source, uLong sourceLen); |
| 1270 | ZEXTERN int ZEXPORT compress_z(Bytef *dest, z_size_t *destLen, | ||
| 1271 | const Bytef *source, z_size_t sourceLen); | ||
| 1269 | /* | 1272 | /* |
| 1270 | Compresses the source buffer into the destination buffer. sourceLen is | 1273 | Compresses the source buffer into the destination buffer. sourceLen is |
| 1271 | the byte length of the source buffer. Upon entry, destLen is the total size | 1274 | the byte length of the source buffer. Upon entry, destLen is the total size |
| @@ -1279,9 +1282,12 @@ ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, | |||
| 1279 | buffer. | 1282 | buffer. |
| 1280 | */ | 1283 | */ |
| 1281 | 1284 | ||
| 1282 | ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, | 1285 | ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, |
| 1283 | const Bytef *source, uLong sourceLen, | 1286 | const Bytef *source, uLong sourceLen, |
| 1284 | int level); | 1287 | int level); |
| 1288 | ZEXTERN int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, | ||
| 1289 | const Bytef *source, z_size_t sourceLen, | ||
| 1290 | int level); | ||
| 1285 | /* | 1291 | /* |
| 1286 | Compresses the source buffer into the destination buffer. The level | 1292 | Compresses the source buffer into the destination buffer. The level |
| 1287 | parameter has the same meaning as in deflateInit. sourceLen is the byte | 1293 | parameter has the same meaning as in deflateInit. sourceLen is the byte |
| @@ -1301,20 +1307,19 @@ ZEXTERN z_size_t ZEXPORT compressBound_z(z_size_t sourceLen); | |||
| 1301 | compressBound() returns an upper bound on the compressed size after | 1307 | compressBound() returns an upper bound on the compressed size after |
| 1302 | compress() or compress2() on sourceLen bytes. It would be used before a | 1308 | compress() or compress2() on sourceLen bytes. It would be used before a |
| 1303 | compress() or compress2() call to allocate the destination buffer. | 1309 | compress() or compress2() call to allocate the destination buffer. |
| 1304 | |||
| 1305 | compressBound_z() is the same, but takes and returns a size_t length for | ||
| 1306 | those systems on which a long is 32 bits. | ||
| 1307 | */ | 1310 | */ |
| 1308 | 1311 | ||
| 1309 | ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, | 1312 | ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, |
| 1310 | const Bytef *source, uLong sourceLen); | 1313 | const Bytef *source, uLong sourceLen); |
| 1314 | ZEXTERN int ZEXPORT uncompress_z(Bytef *dest, z_size_t *destLen, | ||
| 1315 | const Bytef *source, z_size_t sourceLen); | ||
| 1311 | /* | 1316 | /* |
| 1312 | Decompresses the source buffer into the destination buffer. sourceLen is | 1317 | Decompresses the source buffer into the destination buffer. sourceLen is |
| 1313 | the byte length of the source buffer. Upon entry, destLen is the total size | 1318 | the byte length of the source buffer. On entry, *destLen is the total size |
| 1314 | of the destination buffer, which must be large enough to hold the entire | 1319 | of the destination buffer, which must be large enough to hold the entire |
| 1315 | uncompressed data. (The size of the uncompressed data must have been saved | 1320 | uncompressed data. (The size of the uncompressed data must have been saved |
| 1316 | previously by the compressor and transmitted to the decompressor by some | 1321 | previously by the compressor and transmitted to the decompressor by some |
| 1317 | mechanism outside the scope of this compression library.) Upon exit, destLen | 1322 | mechanism outside the scope of this compression library.) On exit, *destLen |
| 1318 | is the actual size of the uncompressed data. | 1323 | is the actual size of the uncompressed data. |
| 1319 | 1324 | ||
| 1320 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not | 1325 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not |
| @@ -1324,8 +1329,10 @@ ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, | |||
| 1324 | buffer with the uncompressed data up to that point. | 1329 | buffer with the uncompressed data up to that point. |
| 1325 | */ | 1330 | */ |
| 1326 | 1331 | ||
| 1327 | ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, | 1332 | ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, |
| 1328 | const Bytef *source, uLong *sourceLen); | 1333 | const Bytef *source, uLong *sourceLen); |
| 1334 | ZEXTERN int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, | ||
| 1335 | const Bytef *source, z_size_t *sourceLen); | ||
| 1329 | /* | 1336 | /* |
| 1330 | Same as uncompress, except that sourceLen is a pointer, where the | 1337 | Same as uncompress, except that sourceLen is a pointer, where the |
| 1331 | length of the source is *sourceLen. On return, *sourceLen is the number of | 1338 | length of the source is *sourceLen. On return, *sourceLen is the number of |
| @@ -1819,7 +1826,8 @@ ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); | |||
| 1819 | ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, | 1826 | ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, |
| 1820 | z_size_t len); | 1827 | z_size_t len); |
| 1821 | /* | 1828 | /* |
| 1822 | Same as adler32(), but with a size_t length. | 1829 | Same as adler32(), but with a size_t length. Note that a long is 32 bits |
| 1830 | on Windows. | ||
| 1823 | */ | 1831 | */ |
| 1824 | 1832 | ||
| 1825 | /* | 1833 | /* |
| @@ -1855,7 +1863,8 @@ ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); | |||
| 1855 | ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, | 1863 | ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, |
| 1856 | z_size_t len); | 1864 | z_size_t len); |
| 1857 | /* | 1865 | /* |
| 1858 | Same as crc32(), but with a size_t length. | 1866 | Same as crc32(), but with a size_t length. Note that a long is 32 bits on |
| 1867 | Windows. | ||
| 1859 | */ | 1868 | */ |
| 1860 | 1869 | ||
| 1861 | /* | 1870 | /* |
| @@ -108,4 +108,8 @@ ZLIB_1.3.1.2 { | |||
| 108 | ZLIB_1.3.2 { | 108 | ZLIB_1.3.2 { |
| 109 | compressBound_z; | 109 | compressBound_z; |
| 110 | deflateBound_z; | 110 | deflateBound_z; |
| 111 | compress_z; | ||
| 112 | compress2_z; | ||
| 113 | uncompress_z; | ||
| 114 | uncompress2_z; | ||
| 111 | } ZLIB_1.3.1.2; \ No newline at end of file | 115 | } ZLIB_1.3.1.2; \ No newline at end of file |
