 |
Changeset 2557
- Timestamp:
- 09/07/07 14:08:43
(1 year ago)
- Author:
- sean
- Message:
* Reformatted a few lines in object.di.
* Replaced zlib.d (taken from Phobos) with a version merged directly from the zlib header. This version has the advantage of having far fewer diffs witht he zlib version, which should simplify future updates. It also fixes a few platform issues related to 32 vs. 64-bit types (long, off_t). This new version builds fine on my end and looks okay, but hasn't been tested thoroughly. Let me know if it has any problems.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2502 |
r2557 |
|
| 29 | 29 | ClassInfo classinfo; |
|---|
| 30 | 30 | void*[] vtbl; |
|---|
| 31 | | ptrdiff_t offset; // offset to Interface 'this' from Object 'this' |
|---|
| | 31 | ptrdiff_t offset; // offset to Interface 'this' from Object 'this' |
|---|
| 32 | 32 | } |
|---|
| 33 | 33 | |
|---|
| r2556 |
r2557 |
|
| 1 | | /* zlib.d: modified from zlib.h by Walter Bright */ |
|---|
| 2 | | /* updated from 1.2.1 to 1.2.3 by Thomas Kuehne */ |
|---|
| 3 | | |
|---|
| 4 | | module tango.io.compress.c.zlib; |
|---|
| 5 | | |
|---|
| 6 | 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
|---|
| 7 | | version 1.2.3, July 18th, 2005 |
|---|
| | 2 | version 1.2.3, July 18th, 2005 |
|---|
| 8 | 3 | |
|---|
| 9 | 4 | Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler |
|---|
| … | … | |
| 34 | 29 | */ |
|---|
| 35 | 30 | |
|---|
| | 31 | module tango.io.compress.c.zlib; |
|---|
| | 32 | |
|---|
| 36 | 33 | extern (C): |
|---|
| 37 | 34 | |
|---|
| 38 | | char[] ZLIB_VERSION = "1.2.3"; |
|---|
| 39 | | const ZLIB_VERNUM = 0x1230; |
|---|
| | 35 | const char* ZLIB_VERSION = "1.2.3"; |
|---|
| | 36 | const uint ZLIB_VERNUM = 0x1230; |
|---|
| 40 | 37 | |
|---|
| 41 | 38 | /* |
|---|
| … | … | |
| 73 | 70 | */ |
|---|
| 74 | 71 | |
|---|
| 75 | | alias void* (*alloc_func) (void* opaque, uint items, uint size); |
|---|
| 76 | | alias void (*free_func) (void* opaque, void* address); |
|---|
| | 72 | private |
|---|
| | 73 | { |
|---|
| | 74 | import tango.stdc.config : c_long, c_ulong; |
|---|
| | 75 | |
|---|
| | 76 | version( Posix ) |
|---|
| | 77 | { |
|---|
| | 78 | import tango.stdc.posix.types : z_off_t = off_t; |
|---|
| | 79 | } |
|---|
| | 80 | else |
|---|
| | 81 | { |
|---|
| | 82 | alias c_long z_off_t; |
|---|
| | 83 | } |
|---|
| | 84 | |
|---|
| | 85 | alias ubyte Byte; |
|---|
| | 86 | alias uint uInt; |
|---|
| | 87 | alias c_ulong uLong; |
|---|
| | 88 | |
|---|
| | 89 | alias Byte Bytef; |
|---|
| | 90 | alias char charf; |
|---|
| | 91 | alias int intf; |
|---|
| | 92 | alias uInt uIntf; |
|---|
| | 93 | alias uLong uLongf; |
|---|
| | 94 | |
|---|
| | 95 | alias void* voidpc; // TODO: normally const |
|---|
| | 96 | alias void* voidpf; |
|---|
| | 97 | alias void* voidp; |
|---|
| | 98 | |
|---|
| | 99 | alias voidpf function(voidpf opaque, uInt items, uInt size) alloc_func; |
|---|
| | 100 | alias void function(voidpf opaque, voidpf address) free_func; |
|---|
| | 101 | |
|---|
| | 102 | struct internal_state {} |
|---|
| | 103 | } |
|---|
| 77 | 104 | |
|---|
| 78 | 105 | struct z_stream |
|---|
| 79 | 106 | { |
|---|
| 80 | | ubyte *next_in; /* next input byte */ |
|---|
| 81 | | uint avail_in; /* number of bytes available at next_in */ |
|---|
| 82 | | uint total_in; /* total nb of input bytes read so far */ |
|---|
| 83 | | |
|---|
| 84 | | ubyte *next_out; /* next output byte should be put there */ |
|---|
| 85 | | uint avail_out; /* remaining free space at next_out */ |
|---|
| 86 | | uint total_out; /* total nb of bytes output so far */ |
|---|
| 87 | | |
|---|
| 88 | | char *msg; /* last error message, NULL if no error */ |
|---|
| 89 | | void* state; /* not visible by applications */ |
|---|
| 90 | | |
|---|
| 91 | | alloc_func zalloc; /* used to allocate the internal state */ |
|---|
| 92 | | free_func zfree; /* used to free the internal state */ |
|---|
| 93 | | void* opaque; /* private data object passed to zalloc and zfree */ |
|---|
| 94 | | |
|---|
| 95 | | int data_type; /* best guess about the data type: binary or text */ |
|---|
| 96 | | uint adler; /* adler32 value of the uncompressed data */ |
|---|
| 97 | | uint reserved; /* reserved for future use */ |
|---|
| | 107 | Bytef* next_in; /* next input byte */ |
|---|
| | 108 | uInt avail_in; /* number of bytes available at next_in */ |
|---|
| | 109 | uLong total_in; /* total nb of input bytes read so far */ |
|---|
| | 110 | |
|---|
| | 111 | Bytef* next_out; /* next output byte should be put there */ |
|---|
| | 112 | uInt avail_out; /* remaining free space at next_out */ |
|---|
| | 113 | uLong total_out; /* total nb of bytes output so far */ |
|---|
| | 114 | |
|---|
| | 115 | char* msg; /* last error message, NULL if no error */ |
|---|
| | 116 | internal_state* state; /* not visible by applications */ |
|---|
| | 117 | |
|---|
| | 118 | alloc_func zalloc; /* used to allocate the internal state */ |
|---|
| | 119 | free_func zfree; /* used to free the internal state */ |
|---|
| | 120 | voidpf opaque; /* private data object passed to zalloc and zfree */ |
|---|
| | 121 | |
|---|
| | 122 | int data_type; /* best guess about the data type: binary or text */ |
|---|
| | 123 | uLong adler; /* adler32 value of the uncompressed data */ |
|---|
| | 124 | uLong reserved; /* reserved for future use */ |
|---|
| 98 | 125 | } |
|---|
| 99 | 126 | |
|---|
| … | … | |
| 104 | 131 | for more details on the meanings of these fields. |
|---|
| 105 | 132 | */ |
|---|
| 106 | | struct gz_header { |
|---|
| | 133 | struct gz_header |
|---|
| | 134 | { |
|---|
| 107 | 135 | int text; /* true if compressed data believed to be text */ |
|---|
| 108 | | ulong time; /* modification time */ |
|---|
| | 136 | uLong time; /* modification time */ |
|---|
| 109 | 137 | int xflags; /* extra flags (not used when writing a gzip file) */ |
|---|
| 110 | 138 | int os; /* operating system */ |
|---|
| 111 | | byte *extra; /* pointer to extra field or Z_NULL if none */ |
|---|
| 112 | | uint extra_len; /* extra field length (valid if extra != Z_NULL) */ |
|---|
| 113 | | uint extra_max; /* space at extra (only when reading header) */ |
|---|
| 114 | | byte *name; /* pointer to zero-terminated file name or Z_NULL */ |
|---|
| 115 | | uint name_max; /* space at name (only when reading header) */ |
|---|
| 116 | | byte *comment; /* pointer to zero-terminated comment or Z_NULL */ |
|---|
| 117 | | uint comm_max; /* space at comment (only when reading header) */ |
|---|
| | 139 | Bytef* extra; /* pointer to extra field or Z_NULL if none */ |
|---|
| | 140 | uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ |
|---|
| | 141 | uInt extra_max; /* space at extra (only when reading header) */ |
|---|
| | 142 | Bytef* name; /* pointer to zero-terminated file name or Z_NULL */ |
|---|
| | 143 | uInt name_max; /* space at name (only when reading header) */ |
|---|
| | 144 | Bytef* comment; /* pointer to zero-terminated comment or Z_NULL */ |
|---|
| | 145 | uInt comm_max; /* space at comment (only when reading header) */ |
|---|
| 118 | 146 | int hcrc; /* true if there was or will be a header crc */ |
|---|
| 119 | 147 | int done; /* true when done reading gzip header (not used |
|---|
| … | … | |
| 124 | 152 | |
|---|
| 125 | 153 | /* |
|---|
| 126 | | The application must update next_in and avail_in when avail_in has |
|---|
| | 154 | The application must update next_in and avail_in when avail_in has |
|---|
| 127 | 155 | dropped to zero. It must update next_out and avail_out when avail_out |
|---|
| 128 | 156 | has dropped to zero. The application must initialize zalloc, zfree and |
|---|
| … | … | |
| 159 | 187 | enum |
|---|
| 160 | 188 | { |
|---|
| 161 | | Z_NO_FLUSH = 0, |
|---|
| 162 | | Z_PARTIAL_FLUSH = 1, /* will be removed, use Z_SYNC_FLUSH instead */ |
|---|
| 163 | | Z_SYNC_FLUSH = 2, |
|---|
| 164 | | Z_FULL_FLUSH = 3, |
|---|
| 165 | | Z_FINISH = 4, |
|---|
| 166 | | Z_BLOCK = 5 |
|---|
| | 189 | Z_NO_FLUSH = 0, |
|---|
| | 190 | Z_PARTIAL_FLUSH = 1, /* will be removed, use Z_SYNC_FLUSH instead */ |
|---|
| | 191 | Z_SYNC_FLUSH = 2, |
|---|
| | 192 | Z_FULL_FLUSH = 3, |
|---|
| | 193 | Z_FINISH = 4, |
|---|
| | 194 | Z_BLOCK = 5, |
|---|
| 167 | 195 | } |
|---|
| 168 | 196 | /* Allowed flush values; see deflate() and inflate() below for details */ |
|---|
| … | … | |
| 170 | 198 | enum |
|---|
| 171 | 199 | { |
|---|
| 172 | | Z_OK = 0, |
|---|
| 173 | | Z_STREAM_END = 1, |
|---|
| 174 | | Z_NEED_DICT = 2, |
|---|
| 175 | | Z_ERRNO = -1, |
|---|
| 176 | | Z_STREAM_ERROR = -2, |
|---|
| 177 | | Z_DATA_ERROR = -3, |
|---|
| 178 | | Z_MEM_ERROR = -4, |
|---|
| 179 | | Z_BUF_ERROR = -5, |
|---|
| 180 | | Z_VERSION_ERROR = -6, |
|---|
| | 200 | Z_OK = 0, |
|---|
| | 201 | Z_STREAM_END = 1, |
|---|
| | 202 | Z_NEED_DICT = 2, |
|---|
| | 203 | Z_ERRNO = -1, |
|---|
| | 204 | Z_STREAM_ERROR = -2, |
|---|
| | 205 | Z_DATA_ERROR = -3, |
|---|
| | 206 | Z_MEM_ERROR = -4, |
|---|
| | 207 | Z_BUF_ERROR = -5, |
|---|
| | 208 | Z_VERSION_ERROR = -6, |
|---|
| 181 | 209 | } |
|---|
| 182 | 210 | /* Return codes for the compression/decompression functions. Negative |
|---|
| … | … | |
| 186 | 214 | enum |
|---|
| 187 | 215 | { |
|---|
| 188 | | Z_NO_COMPRESSION = 0, |
|---|
| 189 | | Z_BEST_SPEED = 1, |
|---|
| 190 | | Z_BEST_COMPRESSION = 9, |
|---|
| 191 | | Z_DEFAULT_COMPRESSION = -1, |
|---|
| | 216 | Z_NO_COMPRESSION = 0, |
|---|
| | 217 | Z_BEST_SPEED = 1, |
|---|
| | 218 | Z_BEST_COMPRESSION = 9, |
|---|
| | 219 | Z_DEFAULT_COMPRESSION = -1, |
|---|
| 192 | 220 | } |
|---|
| 193 | 221 | /* compression levels */ |
|---|
| … | … | |
| 195 | 223 | enum |
|---|
| 196 | 224 | { |
|---|
| 197 | | Z_FILTERED = 1, |
|---|
| 198 | | Z_HUFFMAN_ONLY = 2, |
|---|
| 199 | | Z_RLE = 3, |
|---|
| 200 | | Z_FIXED = 4, |
|---|
| 201 | | Z_DEFAULT_STRATEGY = 0, |
|---|
| | 225 | Z_FILTERED = 1, |
|---|
| | 226 | Z_HUFFMAN_ONLY = 2, |
|---|
| | 227 | Z_RLE = 3, |
|---|
| | 228 | Z_FIXED = 4, |
|---|
| | 229 | Z_DEFAULT_STRATEGY = 0, |
|---|
| 202 | 230 | } |
|---|
| 203 | 231 | /* compression strategy; see deflateInit2() below for details */ |
|---|
| … | … | |
| 205 | 233 | enum |
|---|
| 206 | 234 | { |
|---|
| 207 | | Z_BINARY = 0, |
|---|
| 208 | | Z_TEXT = 1, |
|---|
| 209 | | Z_UNKNOWN = 2, |
|---|
| 210 | | |
|---|
| 211 | | Z_ASCII = Z_TEXT |
|---|
| | 235 | Z_BINARY = 0, |
|---|
| | 236 | Z_TEXT = 1, |
|---|
| | 237 | Z_ASCII = Z_TEXT, /* for compatibility with 1.2.2 and earlier */ |
|---|
| | 238 | Z_UNKNOWN = 2, |
|---|
| 212 | 239 | } |
|---|
| 213 | 240 | /* Possible values of the data_type field (though see inflate()) */ |
|---|
| … | … | |
| 215 | 242 | enum |
|---|
| 216 | 243 | { |
|---|
| 217 | | Z_DEFLATED = 8, |
|---|
| | 244 | Z_DEFLATED = 8, |
|---|
| 218 | 245 | } |
|---|
| 219 | 246 | /* The deflate compression method (the only one supported in this version) */ |
|---|
| 220 | 247 | |
|---|
| 221 | | const int Z_NULL = 0; /* for initializing zalloc, zfree, opaque */ |
|---|
| | 248 | const Z_NULL = null; /* for initializing zalloc, zfree, opaque */ |
|---|
| | 249 | |
|---|
| | 250 | alias zlibVersion zlib_version; |
|---|
| | 251 | /* for compatibility with versions < 1.0.2 */ |
|---|
| 222 | 252 | |
|---|
| 223 | 253 | /* basic functions */ |
|---|
| … | … | |
| 230 | 260 | */ |
|---|
| 231 | 261 | |
|---|
| 232 | | int deflateInit(z_streamp strm, int level) |
|---|
| 233 | | { |
|---|
| 234 | | return deflateInit_(strm, level, ZLIB_VERSION.ptr, z_stream.sizeof); |
|---|
| 235 | | } |
|---|
| 236 | | /* |
|---|
| | 262 | /* |
|---|
| | 263 | int deflateInit (z_streamp strm, int level); |
|---|
| | 264 | |
|---|
| 237 | 265 | Initializes the internal stream state for compression. The fields |
|---|
| 238 | 266 | zalloc, zfree and opaque must be initialized before by the caller. |
|---|
| … | … | |
| 355 | 383 | |
|---|
| 356 | 384 | |
|---|
| 357 | | int inflateInit(z_streamp strm) |
|---|
| 358 | | { |
|---|
| 359 | | return inflateInit_(strm, ZLIB_VERSION.ptr, z_stream.sizeof); |
|---|
| 360 | | } |
|---|
| 361 | | /* |
|---|
| | 385 | /* |
|---|
| | 386 | int inflateInit(z_streamp strm); |
|---|
| | 387 | |
|---|
| 362 | 388 | Initializes the internal stream state for decompression. The fields |
|---|
| 363 | 389 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by |
|---|
| … | … | |
| 494 | 520 | */ |
|---|
| 495 | 521 | |
|---|
| 496 | | int deflateInit2(z_streamp strm, |
|---|
| 497 | | int level, |
|---|
| 498 | | int method, |
|---|
| 499 | | int windowBits, |
|---|
| 500 | | int memLevel, |
|---|
| 501 | | int strategy) |
|---|
| 502 | | { |
|---|
| 503 | | return deflateInit2_(strm, level, method, windowBits, memLevel, |
|---|
| 504 | | strategy, ZLIB_VERSION.ptr, z_stream.sizeof); |
|---|
| 505 | | } |
|---|
| 506 | | /* |
|---|
| | 522 | /* |
|---|
| | 523 | int deflateInit2 (z_streamp strm, |
|---|
| | 524 | int level, |
|---|
| | 525 | int method, |
|---|
| | 526 | int windowBits, |
|---|
| | 527 | int memLevel, |
|---|
| | 528 | int strategy); |
|---|
| | 529 | |
|---|
| 507 | 530 | This is another version of deflateInit with more compression options. The |
|---|
| 508 | 531 | fields next_in, zalloc, zfree and opaque must be initialized before by |
|---|
| … | … | |
| 555 | 578 | not perform any compression: this will be done by deflate(). |
|---|
| 556 | 579 | */ |
|---|
| 557 | | |
|---|
| 558 | | int deflateSetDictionary(z_streamp strm, ubyte* dictionary, uint dictLength); |
|---|
| | 580 | |
|---|
| | 581 | int deflateSetDictionary(z_streamp strm, |
|---|
| | 582 | Bytef* dictionary, |
|---|
| | 583 | uInt dictLength); |
|---|
| 559 | 584 | /* |
|---|
| 560 | 585 | Initializes the compression dictionary from the given byte sequence |
|---|
| … | … | |
| 593 | 618 | */ |
|---|
| 594 | 619 | |
|---|
| 595 | | int deflateCopy(z_streamp dest, z_streamp source); |
|---|
| | 620 | int deflateCopy(z_streamp dest, |
|---|
| | 621 | z_streamp source); |
|---|
| 596 | 622 | /* |
|---|
| 597 | 623 | Sets the destination stream as a complete copy of the source stream. |
|---|
| … | … | |
| 621 | 647 | */ |
|---|
| 622 | 648 | |
|---|
| 623 | | int inflatePrime(z_streamp strm, int bits, int value); |
|---|
| | 649 | int deflateParams(z_streamp strm, |
|---|
| | 650 | int level, |
|---|
| | 651 | int strategy); |
|---|
| | 652 | /* |
|---|
| | 653 | Dynamically update the compression level and compression strategy. The |
|---|
| | 654 | interpretation of level and strategy is as in deflateInit2. This can be |
|---|
| | 655 | used to switch between compression and straight copy of the input data, or |
|---|
| | 656 | to switch to a different kind of input data requiring a different |
|---|
| | 657 | strategy. If the compression level is changed, the input available so far |
|---|
| | 658 | is compressed with the old level (and may be flushed); the new level will |
|---|
| | 659 | take effect only at the next call of deflate(). |
|---|
| | 660 | |
|---|
| | 661 | Before the call of deflateParams, the stream state must be set as for |
|---|
| | 662 | a call of deflate(), since the currently available input may have to |
|---|
| | 663 | be compressed and flushed. In particular, strm->avail_out must be non-zero. |
|---|
| | 664 | |
|---|
| | 665 | deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source |
|---|
| | 666 | stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR |
|---|
| | 667 | if strm->avail_out was zero. |
|---|
| | 668 | */ |
|---|
| | 669 | |
|---|
| | 670 | int deflateTune(z_streamp strm, |
|---|
| | 671 | int good_length, |
|---|
| | 672 | int max_lazy, |
|---|
| | 673 | int nice_length, |
|---|
| | 674 | int max_chain); |
|---|
| | 675 | /* |
|---|
| | 676 | Fine tune deflate's internal compression parameters. This should only be |
|---|
| | 677 | used by someone who understands the algorithm used by zlib's deflate for |
|---|
| | 678 | searching for the best matching string, and even then only by the most |
|---|
| | 679 | fanatic optimizer trying to squeeze out the last compressed bit for their |
|---|
| | 680 | specific input data. Read the deflate.c source code for the meaning of the |
|---|
| | 681 | max_lazy, good_length, nice_length, and max_chain parameters. |
|---|
| | 682 | |
|---|
| | 683 | deflateTune() can be called after deflateInit() or deflateInit2(), and |
|---|
| | 684 | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. |
|---|
| | 685 | */ |
|---|
| | 686 | |
|---|
| | 687 | uLong deflateBound(z_streamp strm, |
|---|
| | 688 | uLong sourceLen); |
|---|
| | 689 | /* |
|---|
| | 690 | deflateBound() returns an upper bound on the compressed size after |
|---|
| | 691 | deflation of sourceLen bytes. It must be called after deflateInit() |
|---|
| | 692 | or deflateInit2(). This would be used to allocate an output buffer |
|---|
| | 693 | for deflation in a single pass, and so would be called before deflate(). |
|---|
| | 694 | */ |
|---|
| | 695 | |
|---|
| | 696 | int deflatePrime(z_streamp strm, |
|---|
| | 697 | int bits, |
|---|
| | 698 | int value); |
|---|
| | 699 | /* |
|---|
| | 700 | deflatePrime() inserts bits in the deflate output stream. The intent |
|---|
| | 701 | is that this function is used to start off the deflate output with the |
|---|
| | 702 | bits leftover from a previous deflate stream when appending to it. As such, |
|---|
| | 703 | this function can only be used for raw deflate, and must be used before the |
|---|
| | 704 | first deflate() call after a deflateInit2() or deflateReset(). bits must be |
|---|
| | 705 | less than or equal to 16, and that many of the least significant bits of |
|---|
| | 706 | value will be inserted in the output. |
|---|
| | 707 | |
|---|
| | 708 | deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source |
|---|
| | 709 | stream state was inconsistent. |
|---|
| | 710 | */ |
|---|
| | 711 | |
|---|
| | 712 | int deflateSetHeader(z_streamp strm, |
|---|
| | 713 | gz_headerp head); |
|---|
| | 714 | /* |
|---|
| | 715 | deflateSetHeader() provides gzip header information for when a gzip |
|---|
| | 716 | stream is requested by deflateInit2(). deflateSetHeader() may be called |
|---|
| | 717 | after deflateInit2() or deflateReset() and before the first call of |
|---|
| | 718 | deflate(). The text, time, os, extra field, name, and comment information |
|---|
| | 719 | in the provided gz_header structure are written to the gzip header (xflag is |
|---|
| | 720 | ignored -- the extra flags are set according to the compression level). The |
|---|
| | 721 | caller must assure that, if not Z_NULL, name and comment are terminated with |
|---|
| | 722 | a zero byte, and that if extra is not Z_NULL, that extra_len bytes are |
|---|
| | 723 | available there. If hcrc is true, a gzip header crc is included. Note that |
|---|
| | 724 | the current versions of the command-line version of gzip (up through version |
|---|
| | 725 | 1.3.x) do not support header crc's, and will report that it is a "multi-part |
|---|
| | 726 | gzip file" and give up. |
|---|
| | 727 | |
|---|
| | 728 | If deflateSetHeader is not used, the default gzip header has text false, |
|---|
| | 729 | the time set to zero, and os set to 255, with no extra, name, or comment |
|---|
| | 730 | fields. The gzip header is returned to the default state by deflateReset(). |
|---|
| | 731 | |
|---|
| | 732 | deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
|---|
| | 733 | stream state was inconsistent. |
|---|
| | 734 | */ |
|---|
| | 735 | |
|---|
| | 736 | /* |
|---|
| | 737 | int inflateInit2(z_streamp strm, |
|---|
| | 738 | int windowBits); |
|---|
| | 739 | |
|---|
| | 740 | This is another version of inflateInit with an extra parameter. The |
|---|
| | 741 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized |
|---|
| | 742 | before by the caller. |
|---|
| | 743 | |
|---|
| | 744 | The windowBits parameter is the base two logarithm of the maximum window |
|---|
| | 745 | size (the size of the history buffer). It should be in the range 8..15 for |
|---|
| | 746 | this version of the library. The default value is 15 if inflateInit is used |
|---|
| | 747 | instead. windowBits must be greater than or equal to the windowBits value |
|---|
| | 748 | provided to deflateInit2() while compressing, or it must be equal to 15 if |
|---|
| | 749 | deflateInit2() was not used. If a compressed stream with a larger window |
|---|
| | 750 | size is given as input, inflate() will return with the error code |
|---|
| | 751 | Z_DATA_ERROR instead of trying to allocate a larger window. |
|---|
| | 752 | |
|---|
| | 753 | windowBits can also be -8..-15 for raw inflate. In this case, -windowBits |
|---|
| | 754 | determines the window size. inflate() will then process raw deflate data, |
|---|
| | 755 | not looking for a zlib or gzip header, not generating a check value, and not |
|---|
| | 756 | looking for any check values for comparison at the end of the stream. This |
|---|
| | 757 | is for use with other formats that use the deflate compressed data format |
|---|
| | 758 | such as zip. Those formats provide their own check values. If a custom |
|---|
| | 759 | format is developed using the raw deflate format for compressed data, it is |
|---|
| | 760 | recommended that a check value such as an adler32 or a crc32 be applied to |
|---|
| | 761 | the uncompressed data as is done in the zlib, gzip, and zip formats. For |
|---|
| | 762 | most applications, the zlib format should be used as is. Note that comments |
|---|
| | 763 | above on the use in deflateInit2() applies to the magnitude of windowBits. |
|---|
| | 764 | |
|---|
| | 765 | windowBits can also be greater than 15 for optional gzip decoding. Add |
|---|
| | 766 | 32 to windowBits to enable zlib and gzip decoding with automatic header |
|---|
| | 767 | detection, or add 16 to decode only the gzip format (the zlib format will |
|---|
| | 768 | return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is |
|---|
| | 769 | a crc32 instead of an adler32. |
|---|
| | 770 | |
|---|
| | 771 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|---|
| | 772 | memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg |
|---|
| | 773 | is set to null if there is no error message. inflateInit2 does not perform |
|---|
| | 774 | any decompression apart from reading the zlib header if present: this will |
|---|
| | 775 | be done by inflate(). (So next_in and avail_in may be modified, but next_out |
|---|
| | 776 | and avail_out are unchanged.) |
|---|
| | 777 | */ |
|---|
| | 778 | |
|---|
| | 779 | int inflateSetDictionary(z_streamp strm, |
|---|
| | 780 | Bytef* dictionary, |
|---|
| | 781 | uInt dictLength); |
|---|
| | 782 | /* |
|---|
| | 783 | Initializes the decompression dictionary from the given uncompressed byte |
|---|
| | 784 | sequence. This function must be called immediately after a call of inflate, |
|---|
| | 785 | if that call returned Z_NEED_DICT. The dictionary chosen by the compressor |
|---|
| | 786 | can be determined from the adler32 value returned by that call of inflate. |
|---|
| | 787 | The compressor and decompressor must use exactly the same dictionary (see |
|---|
| | 788 | deflateSetDictionary). For raw inflate, this function can be called |
|---|
| | 789 | immediately after inflateInit2() or inflateReset() and before any call of |
|---|
| | 790 | inflate() to set the dictionary. The application must insure that the |
|---|
| | 791 | dictionary that was used for compression is provided. |
|---|
| | 792 | |
|---|
| | 793 | inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a |
|---|
| | 794 | parameter is invalid (such as NULL dictionary) or the stream state is |
|---|
| | 795 | inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the |
|---|
| | 796 | expected one (incorrect adler32 value). inflateSetDictionary does not |
|---|
| | 797 | perform any decompression: this will be done by subsequent calls of |
|---|
| | 798 | inflate(). |
|---|
| | 799 | */ |
|---|
| | 800 | |
|---|
| | 801 | int inflateSync(z_streamp strm); |
|---|
| | 802 | /* |
|---|
| | 803 | Skips invalid compressed data until a full flush point (see above the |
|---|
| | 804 | description of deflate with Z_FULL_FLUSH) can be found, or until all |
|---|
| | 805 | available input is skipped. No output is provided. |
|---|
| | 806 | |
|---|
| | 807 | inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR |
|---|
| | 808 | if no more input was provided, Z_DATA_ERROR if no flush point has been found, |
|---|
| | 809 | or Z_STREAM_ERROR if the stream structure was inconsistent. In the success |
|---|
| | 810 | case, the application may save the current current value of total_in which |
|---|
| | 811 | indicates where valid compressed data was found. In the error case, the |
|---|
| | 812 | application may repeatedly call inflateSync, providing more input each time, |
|---|
| | 813 | until success or end of the input data. |
|---|
| | 814 | */ |
|---|
| | 815 | |
|---|
| | 816 | int inflateCopy(z_streamp dest, |
|---|
| | 817 | z_streamp source); |
|---|
| | 818 | /* |
|---|
| | 819 | Sets the destination stream as a complete copy of the source stream. |
|---|
| | 820 | |
|---|
| | 821 | This function can be useful when randomly accessing a large stream. The |
|---|
| | 822 | first pass through the stream can periodically record the inflate state, |
|---|
| | 823 | allowing restarting inflate at those points when randomly accessing the |
|---|
| | 824 | stream. |
|---|
| | 825 | |
|---|
| | 826 | inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not |
|---|
| | 827 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
|---|
| | 828 | (such as zalloc being NULL). msg is left unchanged in both source and |
|---|
| | 829 | destination. |
|---|
| | 830 | */ |
|---|
| | 831 | |
|---|
| | 832 | int inflateReset(z_streamp strm); |
|---|
| | 833 | /* |
|---|
| | 834 | This function is equivalent to inflateEnd followed by inflateInit, |
|---|
| | 835 | but does not free and reallocate all the internal decompression state. |
|---|
| | 836 | The stream will keep attributes that may have been set by inflateInit2. |
|---|
| | 837 | |
|---|
| | 838 | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
|---|
| | 839 | stream state was inconsistent (such as zalloc or state being NULL). |
|---|
| | 840 | */ |
|---|
| | 841 | |
|---|
| | 842 | int inflatePrime(z_streamp strm, |
|---|
| | 843 | int bits, |
|---|
| | 844 | int value); |
|---|
| 624 | 845 | /* |
|---|
| 625 | 846 | This function inserts bits in the inflate input stream. The intent is |
|---|
| … | … | |
| 635 | 856 | */ |
|---|
| 636 | 857 | |
|---|
| 637 | | int inflateGetHeader(z_streamp strm, gz_headerp head); |
|---|
| | 858 | int inflateGetHeader(z_streamp strm, |
|---|
| | 859 | gz_headerp head); |
|---|
| 638 | 860 | /* |
|---|
| 639 | 861 | inflateGetHeader() requests that gzip header information be stored in the |
|---|
| … | … | |
| 674 | 896 | */ |
|---|
| 675 | 897 | |
|---|
| 676 | | int deflateParams(z_streamp strm, int level, int strategy); |
|---|
| 677 | | /* |
|---|
| 678 | | Dynamically update the compression level and compression strategy. The |
|---|
| 679 | | interpretation of level and strategy is as in deflateInit2. This can be |
|---|
| 680 | | used to switch between compression and straight copy of the input data, or |
|---|
| 681 | | to switch to a different kind of input data requiring a different |
|---|
| 682 | | strategy. If the compression level is changed, the input available so far |
|---|
| 683 | | is compressed with the old level (and may be flushed); the new level will |
|---|
| 684 | | take effect only at the next call of deflate(). |
|---|
| 685 | | |
|---|
| 686 | | Before the call of deflateParams, the stream state must be set as for |
|---|
| 687 | | a call of deflate(), since the currently available input may have to |
|---|
| 688 | | be compressed and flushed. In particular, strm->avail_out must be non-zero. |
|---|
| 689 | | |
|---|
| 690 | | deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source |
|---|
| 691 | | stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR |
|---|
| 692 | | if strm->avail_out was zero. |
|---|
| 693 | | */ |
|---|
| 694 | | |
|---|
| 695 | | int deflateTune(z_streamp strm, int good_length, int max_lazy, int nice_length, |
|---|
| 696 | | int max_chain); |
|---|
| 697 | | /* |
|---|
| 698 | | Fine tune deflate's internal compression parameters. This should only be |
|---|
| 699 | | used by someone who understands the algorithm used by zlib's deflate for |
|---|
| 700 | | searching for the best matching string, and even then only by the most |
|---|
| 701 | | fanatic optimizer trying to squeeze out the last compressed bit for their |
|---|
| 702 | | specific input data. Read the deflate.c source code for the meaning of the |
|---|
| 703 | | max_lazy, good_length, nice_length, and max_chain parameters. |
|---|
| 704 | | |
|---|
| 705 | | deflateTune() can be called after deflateInit() or deflateInit2(), and |
|---|
| 706 | | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. |
|---|
| 707 | | */ |
|---|
| 708 | | |
|---|
| 709 | | int deflateBound(z_streamp strm, uint sourceLen); |
|---|
| 710 | | /* |
|---|
| 711 | | deflateBound() returns an upper bound on the compressed size after |
|---|
| 712 | | deflation of sourceLen bytes. It must be called after deflateInit() |
|---|
| 713 | | or deflateInit2(). This would be used to allocate an output buffer |
|---|
| 714 | | for deflation in a single pass, and so would be called before deflate(). |
|---|
| 715 | | */ |
|---|
| 716 | | |
|---|
| 717 | | int deflatePrime(z_streamp strm, int bits, int value); |
|---|
| 718 | | /* |
|---|
| 719 | | deflatePrime() inserts bits in the deflate output stream. The intent |
|---|
| 720 | | is that this function is used to start off the deflate output with the |
|---|
| 721 | | bits leftover from a previous deflate stream when appending to it. As such, |
|---|
| 722 | | this function can only be used for raw deflate, and must be used before the |
|---|
| 723 | | first deflate() call after a deflateInit2() or deflateReset(). bits must be |
|---|
| 724 | | less than or equal to 16, and that many of the least significant bits of |
|---|
| 725 | | value will be inserted in the output. |
|---|
| 726 | | |
|---|
| 727 | | deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source |
|---|
| 728 | | stream state was inconsistent. |
|---|
| 729 | | */ |
|---|
| 730 | | |
|---|
| 731 | | int deflateSetHeader(z_streamp strm, gz_headerp head); |
|---|
| 732 | | /* |
|---|
| 733 | | deflateSetHeader() provides gzip header information for when a gzip |
|---|
| 734 | | stream is requested by deflateInit2(). deflateSetHeader() may be called |
|---|
| 735 | | after deflateInit2() or deflateReset() and before the first call of |
|---|
| 736 | | deflate(). The text, time, os, extra field, name, and comment information |
|---|
| 737 | | in the provided gz_header structure are written to the gzip header (xflag is |
|---|
| 738 | | ignored -- the extra flags are set according to the compression level). The |
|---|
| 739 | | caller must assure that, if not Z_NULL, name and comment are terminated with |
|---|
| 740 | | a zero byte, and that if extra is not Z_NULL, that extra_len bytes are |
|---|
| 741 | | available there. If hcrc is true, a gzip header crc is included. Note that |
|---|
| 742 | | the current versions of the command-line version of gzip (up through version |
|---|
| 743 | | 1.3.x) do not support header crc's, and will report that it is a "multi-part |
|---|
| 744 | | gzip file" and give up. |
|---|
| 745 | | |
|---|
| 746 | | If deflateSetHeader is not used, the default gzip header has text false, |
|---|
| 747 | | the time set to zero, and os set to 255, with no extra, name, or comment |
|---|
| 748 | | fields. The gzip header is returned to the default state by deflateReset(). |
|---|
| 749 | | |
|---|
| 750 | | deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
|---|
| 751 | | stream state was inconsistent. |
|---|
| 752 | | */ |
|---|
| 753 | | |
|---|
| 754 | | int inflateInit2(z_streamp strm, int windowBits) |
|---|
| 755 | | { |
|---|
| 756 | | return inflateInit2_(strm, windowBits, ZLIB_VERSION.ptr, z_stream.sizeof); |
|---|
| 757 | | } |
|---|
| 758 | | /* |
|---|
| 759 | | This is another version of inflateInit with an extra parameter. The |
|---|
| 760 | | fields next_in, avail_in, zalloc, zfree and opaque must be initialized |
|---|
| 761 | | before by the caller. |
|---|
| 762 | | |
|---|
| 763 | | The windowBits parameter is the base two logarithm of the maximum window |
|---|
| 764 | | size (the size of the history buffer). It should be in the range 8..15 for |
|---|
| 765 | | this version of the library. The default value is 15 if inflateInit is used |
|---|
| 766 | | instead. windowBits must be greater than or equal to the windowBits value |
|---|
| 767 | | provided to deflateInit2() while compressing, or it must be equal to 15 if |
|---|
| 768 | | deflateInit2() was not used. If a compressed stream with a larger window |
|---|
| 769 | | size is given as input, inflate() will return with the error code |
|---|
| 770 | | Z_DATA_ERROR instead of trying to allocate a larger window. |
|---|
| 771 | | |
|---|
| 772 | | windowBits can also be -8..-15 for raw inflate. In this case, -windowBits |
|---|
| 773 | | determines the window size. inflate() will then process raw deflate data, |
|---|
| 774 | | not looking for a zlib or gzip header, not generating a check value, and not |
|---|
| 775 | | looking for any check values for comparison at the end of the stream. This |
|---|
| 776 | | is for use with other formats that use the deflate compressed data format |
|---|
| 777 | | such as zip. Those formats provide their own check values. If a custom |
|---|
| 778 | | format is developed using the raw deflate format for compressed data, it is |
|---|
| 779 | | recommended that a check value such as an adler32 or a crc32 be applied to |
|---|
| 780 | | the uncompressed data as is done in the zlib, gzip, and zip formats. For |
|---|
| 781 | | most applications, the zlib format should be used as is. Note that comments |
|---|
| 782 | | above on the use in deflateInit2() applies to the magnitude of windowBits. |
|---|
| 783 | | |
|---|
| 784 | | windowBits can also be greater than 15 for optional gzip decoding. Add |
|---|
| 785 | | 32 to windowBits to enable zlib and gzip decoding with automatic header |
|---|
| 786 | | detection, or add 16 to decode only the gzip format (the zlib format will |
|---|
| 787 | | return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is |
|---|
| 788 | | a crc32 instead of an adler32. |
|---|
| 789 | | |
|---|
| 790 | | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
|---|
| 791 | | memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg |
|---|
| 792 | | is set to null if there is no error message. inflateInit2 does not perform |
|---|
| 793 | | any decompression apart from reading the zlib header if present: this will |
|---|
| 794 | | be done by inflate(). (So next_in and avail_in may be modified, but next_out |
|---|
| 795 | | and avail_out are unchanged.) |
|---|
| 796 | | */ |
|---|
| 797 | | |
|---|
| 798 | | int inflateSetDictionary(z_streamp strm, ubyte* dictionary, uint dictLength); |
|---|
| 799 | | /* |
|---|
| 800 | | Initializes the decompression dictionary from the given uncompressed byte |
|---|
| 801 | | sequence. This function must be called immediately after a call of inflate, |
|---|
| 802 | | if that call returned Z_NEED_DICT. The dictionary chosen by the compressor |
|---|
| 803 | | can be determined from the adler32 value returned by that call of inflate. |
|---|
| 804 | | The compressor and decompressor must use exactly the same dictionary (see |
|---|
| 805 | | deflateSetDictionary). For raw inflate, this function can be called |
|---|
| 806 | | immediately after inflateInit2() or inflateReset() and before any call of |
|---|
| 807 | | inflate() to set the dictionary. The application must insure that the |
|---|
| 808 | | dictionary that was used for compression is provided. |
|---|
| 809 | | |
|---|
| 810 | | inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a |
|---|
| 811 | | parameter is invalid (such as NULL dictionary) or the stream state is |
|---|
| 812 | | inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the |
|---|
| 813 | | expected one (incorrect adler32 value). inflateSetDictionary does not |
|---|
| 814 | | perform any decompression: this will be done by subsequent calls of |
|---|
| 815 | | inflate(). |
|---|
| 816 | | */ |
|---|
| 817 | | |
|---|
| 818 | | int inflateSync(z_streamp strm); |
|---|
| 819 | | /* |
|---|
| 820 | | Skips invalid compressed data until a full flush point (see above the |
|---|
| 821 | | description of deflate with Z_FULL_FLUSH) can be found, or until all |
|---|
| 822 | | available input is skipped. No output is provided. |
|---|
| 823 | | |
|---|
| 824 | | inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR |
|---|
| 825 | | if no more input was provided, Z_DATA_ERROR if no flush point has been found, |
|---|
| 826 | | or Z_STREAM_ERROR if the stream structure was inconsistent. In the success |
|---|
| 827 | | case, the application may save the current current value of total_in which |
|---|
| 828 | | indicates where valid compressed data was found. In the error case, the |
|---|
| 829 | | application may repeatedly call inflateSync, providing more input each time, |
|---|
| 830 | | until success or end of the input data. |
|---|
| 831 | | */ |
|---|
| 832 | | |
|---|
| 833 | | int inflateCopy (z_streamp dest, z_streamp source); |
|---|
| 834 | | /* |
|---|
| 835 | | Sets the destination stream as a complete copy of the source stream. |
|---|
| 836 | | |
|---|
| 837 | | This function can be useful when randomly accessing a large stream. The |
|---|
| 838 | | first pass through the stream can periodically record the inflate state, |
|---|
| 839 | | allowing restarting inflate at those points when randomly accessing the |
|---|
| 840 | | stream. |
|---|
| 841 | | |
|---|
| 842 | | inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not |
|---|
| 843 | | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
|---|
| 844 | | (such as zalloc being NULL). msg is left unchanged in both source and |
|---|
| 845 | | destination. |
|---|
| 846 | | */ |
|---|
| 847 | | |
|---|
| 848 | | int inflateReset(z_streamp strm); |
|---|
| 849 | | /* |
|---|
| 850 | | This function is equivalent to inflateEnd followed by inflateInit, |
|---|
| 851 | | but does not free and reallocate all the internal decompression state. |
|---|
| 852 | | The stream will keep attributes that may have been set by inflateInit2. |
|---|
| 853 | | |
|---|
| 854 | | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
|---|
| 855 | | stream state was inconsistent (such as zalloc or state being NULL). |
|---|
| 856 | | */ |
|---|
| 857 | | |
|---|
| 858 | | |
|---|
| 859 | | int inflateBackInit(z_stream* strm, int windowBits, ubyte* window) |
|---|
| 860 | | { |
|---|
| 861 | | return inflateBackInit_(strm, windowBits, window, ZLIB_VERSION.ptr, z_stream.sizeof); |
|---|
| 862 | | } |
|---|
| 863 | | /* |
|---|
| | 898 | /* |
|---|
| | 899 | int inflateBackInit(z_streamp strm, |
|---|
| | 900 | int windowBits, |
|---|
| | 901 | ubyte* window); |
|---|
| | 902 | |
|---|
| 864 | 903 | Initialize the internal stream state for decompression using inflateBack() |
|---|
| 865 | 904 | calls. The fields zalloc, zfree and opaque in strm must be initialized |
|---|
| … | … | |
| 880 | 919 | */ |
|---|
| 881 | 920 | |
|---|
| 882 | | alias uint function(void*, ubyte**) in_func; |
|---|
| 883 | | alias int function(void*, ubyte*, uint) out_func; |
|---|
| 884 | | |
|---|
| 885 | | int inflateBack(z_stream* strm, |
|---|
| 886 | | in_func f_in, |
|---|
| 887 | | void* in_desc, |
|---|
| 888 | | out_func f_out, |
|---|
| 889 | | void* out_desc); |
|---|
| | 921 | alias uint function(void*, ubyte**) in_func; |
|---|
| | 922 | alias int function(void*, ubyte*, uint) out_func; |
|---|
| | 923 | |
|---|
| | 924 | int inflateBack(z_streamp strm, |
|---|
| | 925 | in_func in_fn, |
|---|
| | 926 | void* in_desc, |
|---|
| | 927 | out_func out_fn, |
|---|
| | 928 | void* out_desc); |
|---|
| 890 | 929 | /* |
|---|
| 891 | 930 | inflateBack() does a raw inflate with a single call using a call-back |
|---|
| … | … | |
| 954 | 993 | */ |
|---|
| 955 | 994 | |
|---|
| 956 | | int inflateBackEnd(z_stream* strm); |
|---|
| | 995 | int inflateBackEnd(z_streamp strm); |
|---|
| 957 | 996 | /* |
|---|
| 958 | 997 | All memory allocated by inflateBackInit() is freed. |
|---|
| … | … | |
| 962 | 1001 | */ |
|---|
| 963 | 1002 | |
|---|
| 964 | | uint zlibCompileFlags(); |
|---|
| | 1003 | uLong zlibCompileFlags(); |
|---|
| 965 | 1004 | /* Return flags indicating compile-time options. |
|---|
| 966 | 1005 | |
|---|
| … | … | |
| 1003 | 1042 | */ |
|---|
| 1004 | 1043 | |
|---|
| | 1044 | |
|---|
| 1005 | 1045 | /* utility functions */ |
|---|
| 1006 | 1046 | |
|---|
| … | … | |
| 1013 | 1053 | */ |
|---|
| 1014 | 1054 | |
|---|
| 1015 | | int compress(ubyte* dest, |
|---|
| 1016 | | uint* destLen, |
|---|
| 1017 | | ubyte* source, |
|---|
| 1018 | | uint sourceLen); |
|---|
| | 1055 | int compress(Bytef* dest, |
|---|
| | 1056 | uLongf* destLen, |
|---|
| | 1057 | Bytef* source, |
|---|
| | 1058 | uLong sourceLen); |
|---|
| 1019 | 1059 | /* |
|---|
| 1020 | 1060 | Compresses the source buffer into the destination buffer. sourceLen is |
|---|
| … | … | |
| 1030 | 1070 | */ |
|---|
| 1031 | 1071 | |
|---|
| 1032 | | int compress2(ubyte* dest, |
|---|
| 1033 | | uint* destLen, |
|---|
| 1034 | | ubyte* source, |
|---|
| 1035 | | uint sourceLen, |
|---|
| 1036 | | int level); |
|---|
| | 1072 | int compress2(Bytef* dest, |
|---|
| | 1073 | uLongf* destLen, |
|---|
| | 1074 | Bytef* source, |
|---|
| | 1075 | uLong sourceLen, |
|---|
| | 1076 | int level); |
|---|
| 1037 | 1077 | /* |
|---|
| 1038 | 1078 | Compresses the source buffer into the destination buffer. The level |
|---|
| … | … | |
| 1048 | 1088 | */ |
|---|
| 1049 | 1089 | |
|---|
| 1050 | | uint compressBound(uint sourceLen); |
|---|
| | 1090 | uLong compressBound(uLong sourceLen); |
|---|
| 1051 | 1091 | /* |
|---|
| 1052 | 1092 | compressBound() returns an upper bound on the compressed size after |
|---|
| … | … | |
| 1055 | 1095 | */ |
|---|
| 1056 | 1096 | |
|---|
| 1057 | | int uncompress(ubyte* dest, |
|---|
| 1058 | | uint* destLen, |
|---|
| 1059 | | ubyte* source, |
|---|
| 1060 | | uint sourceLen); |
|---|
| | 1097 | int uncompress(Bytef* dest, |
|---|
| | 1098 | uLongf* destLen, |
|---|
| | 1099 | Bytef* source, |
|---|
| | 1100 | uLong sourceLen); |
|---|
| 1061 | 1101 | /* |
|---|
| 1062 | 1102 | Decompresses the source buffer into the destination buffer. sourceLen is |
|---|
| … | … | |
| 1076 | 1116 | |
|---|
| 1077 | 1117 | |
|---|
| 1078 | | typedef void* gzFile; |
|---|
| 1079 | | alias int z_off_t; // file offset |
|---|
| | 1118 | typedef voidp gzFile; |
|---|
| 1080 | 1119 | |
|---|
| 1081 | 1120 | gzFile gzopen(char* path, char* mode); |
|---|
| … | … | |
| 1117 | 1156 | */ |
|---|
| 1118 | 1157 | |
|---|
| 1119 | | int gzread(gzFile file, void* buf, uint len); |
|---|
| | 1158 | int gzread(gzFile file, voidp buf, uint len); |
|---|
| 1120 | 1159 | /* |
|---|
| 1121 | 1160 | Reads the given number of uncompressed bytes from the compressed file. |
|---|
| … | … | |
| 1125 | 1164 | end of file, -1 for error). */ |
|---|
| 1126 | 1165 | |
|---|
| 1127 | | int gzwrite(gzFile file, void* buf, uint len); |
|---|
| | 1166 | int gzwrite(gzFile file, voidpc buf, uint len); |
|---|
| 1128 | 1167 | /* |
|---|
| 1129 | 1168 | Writes the given number of uncompressed bytes into the compressed file. |
|---|
| … | … | |
| 1132 | 1171 | */ |
|---|
| 1133 | 1172 | |
|---|
| 1134 | | int gzprintf(gzFile file, char* format, ...); |
|---|
| | 1173 | int gzprintf (gzFile file, char* format, ...); |
|---|
| 1135 | 1174 | /* |
|---|
| 1136 | 1175 | Converts, formats, and writes the args to the compressed file under |
|---|
| … | … | |
| 1167 | 1206 | */ |
|---|
| 1168 | 1207 | |
|---|
| 1169 | | int gzgetc(gzFile file); |
|---|
| | 1208 | int gzgetc (gzFile file); |
|---|
| 1170 | 1209 | /* |
|---|
| 1171 | 1210 | Reads one byte from the compressed file. gzgetc returns this byte |
|---|
| … | … | |
| 1193 | 1232 | */ |
|---|
| 1194 | 1233 | |
|---|
| 1195 | | z_off_t gzseek(gzFile file, z_off_t offset, int whence); |
|---|
| 1196 | | /* |
|---|
| | 1234 | z_off_t gzseek (gzFile file, z_off_t offset, int whence); |
|---|
| | 1235 | /* |
|---|
| 1197 | 1236 | Sets the starting position for the next gzread or gzwrite on the |
|---|
| 1198 | 1237 | given compressed file. The offset represents a number of bytes in the |
|---|
| … | … | |
| 1217 | 1256 | */ |
|---|
| 1218 | 1257 | |
|---|
| 1219 | | z_off_t gztell(gzFile file); |
|---|
| | 1258 | z_off_t gztell (gzFile file); |
|---|
| 1220 | 1259 | /* |
|---|
| 1221 | 1260 | Returns the starting position for the next gzread or gzwrite on the |
|---|
| … | … | |
| 1245 | 1284 | */ |
|---|
| 1246 | 1285 | |
|---|
| 1247 | | char* gzerror(gzFile file, int *errnum); |
|---|
| | 1286 | char* gzerror(gzFile file, int* errnum); |
|---|
| 1248 | 1287 | /* |
|---|
| 1249 | 1288 | Returns the error message for the last error which occurred on the |
|---|
| … | … | |
| 1254 | 1293 | */ |
|---|
| 1255 | 1294 | |
|---|
| 1256 | | void gzclearerr (gzFile file); |
|---|
| | 1295 | void gzclearerr(gzFile file); |
|---|
| 1257 | 1296 | /* |
|---|
| 1258 | 1297 | Clears the error and end-of-file flags for file. This is analogous to the |
|---|
| … | … | |
| 1269 | 1308 | */ |
|---|
| 1270 | 1309 | |
|---|
| 1271 | | uint adler32 (uint adler, ubyte *buf, uint len); |
|---|
| 1272 | | |
|---|
| | 1310 | uLong adler32(uLong adler, Bytef* buf, uInt len); |
|---|
| 1273 | 1311 | /* |
|---|
| 1274 | 1312 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
|---|
| … | … | |
| 1278 | 1316 | much faster. Usage example: |
|---|
| 1279 | 1317 | |
|---|
| 1280 | | uint adler = adler32(0L, Z_NULL, 0); |
|---|
| | 1318 | uLong adler = adler32(0L, Z_NULL, 0); |
|---|
| 1281 | 1319 | |
|---|
| 1282 | 1320 | while (read_buffer(buffer, length) != EOF) { |
|---|
| … | … | |
| 1286 | 1324 | */ |
|---|
| 1287 | 1325 | |
|---|
| 1288 | | uint adler32_combine(uint adler1, uint adler2, z_off_t len2); |
|---|
| | 1326 | uLong adler32_combine(uLong adler1, uLong adler2, z_off_t len2); |
|---|
| 1289 | 1327 | /* |
|---|
| 1290 | 1328 | Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 |
|---|
| … | … | |
| 1294 | 1332 | */ |
|---|
| 1295 | 1333 | |
|---|
| 1296 | | uint crc32(uint crc, ubyte *buf, uint len); |
|---|
| | 1334 | uLong crc32(uLong crc, Bytef* buf, uInt len); |
|---|
| 1297 | 1335 | /* |
|---|
| 1298 | 1336 | Update a running CRC-32 with the bytes buf[0..len-1] and return the |
|---|
| … | … | |
| 1302 | 1340 | Usage example: |
|---|
| 1303 | 1341 | |
|---|
| 1304 | | uint crc = crc32(0L, Z_NULL, 0); |
|---|
| | 1342 | uLong crc = crc32(0L, Z_NULL, 0); |
|---|
| 1305 | 1343 | |
|---|
| 1306 | 1344 | while (read_buffer(buffer, length) != EOF) { |
|---|
| … | … | |
| 1310 | 1348 | */ |
|---|
| 1311 | 1349 | |
|---|
| 1312 | | uint crc32_combine (uint crc1, uint crc2, z_off_t len2); |
|---|
| | 1350 | uLong crc32_combine(uLong crc1, uLong crc2, z_off_t len2); |
|---|
| 1313 | 1351 | |
|---|
| 1314 | 1352 | /* |
|---|
| … | … | |
| 1319 | 1357 | len2. |
|---|
| 1320 | 1358 | */ |
|---|
| 1321 | | |
|---|
| | 1359 | |
|---|
| 1322 | 1360 | |
|---|
| 1323 | 1361 | /* various hacks, don't look :) */ |
|---|
| … | … | |
| 1326 | 1364 | * and the compiler's view of z_stream: |
|---|
| 1327 | 1365 | */ |
|---|
| 1328 | | int deflateInit_(z_streamp strm, |
|---|
| 1329 | | int level, |
|---|
| 1330 | | char* versionx, |
|---|
| 1331 | | int stream_size); |
|---|
| 1332 | | |
|---|
| 1333 | | int inflateInit_(z_streamp strm, |
|---|
| 1334 | | char* versionx, |
|---|
| 1335 | | int stream_size); |
|---|
| 1336 | | |
|---|
| | 1366 | int deflateInit_(z_streamp strm, |
|---|
| | 1367 | int level, |
|---|
| | 1368 | char* ver, |
|---|
| | 1369 | int stream_size); |
|---|
| | 1370 | int inflateInit_(z_streamp strm, |
|---|
| | 1371 | char* ver, |
|---|
| | 1372 | int stream_size); |
|---|
| 1337 | 1373 | int deflateInit2_(z_streamp strm, |
|---|
| 1338 | | int level, |
|---|
| 1339 | | int method, |
|---|
| 1340 | | int windowBits, |
|---|
| 1341 | | int memLevel, |
|---|
| 1342 | | int strategy, |
|---|
| 1343 | | char* versionx, |
|---|
| 1344 | | int stream_size); |
|---|
| 1345 | | |
|---|
| 1346 | | int inflateBackInit_(z_stream* strm, |
|---|
| 1347 | | int windowBits, |
|---|
| 1348 | | ubyte* window, |
|---|
| 1349 | | char* z_version, |
|---|
| 1350 | | int stream_size); |
|---|
| 1351 | | |
|---|
| | 1374 | int level, |
|---|
| | 1375 | int method, |
|---|
| | 1376 | int windowBits, |
|---|
| | 1377 | int memLevel, |
|---|
| | 1378 | int strategy, |
|---|
| | 1379 | char* ver, |
|---|
| | 1380 | int stream_size); |
|---|
| 1352 | 1381 | int inflateInit2_(z_streamp strm, |
|---|
| 1353 | | int windowBits, |
|---|
| 1354 | | char* versionx, |
|---|
| 1355 | | int stream_size); |
|---|
| 1356 | | |
|---|
| 1357 | | char* zError(int err); |
|---|
| 1358 | | int inflateSyncPoint(z_streamp z); |
|---|
| 1359 | | uint* get_crc_table(); |
|---|
| | 1382 | int windowBits, |
|---|
| | 1383 | char* ver, |
|---|
| | 1384 | int stream_size); |
|---|
| | 1385 | int inflateBackInit_(z_streamp strm, |
|---|
| | 1386 | int windowBits, |
|---|
| | 1387 | ubyte* window, |
|---|
| | 1388 | char* ver, |
|---|
| | 1389 | int stream_size); |
|---|
| | 1390 | |
|---|
| | 1391 | extern (D) int deflateInit(z_streamp strm, |
|---|
| | 1392 | int level) |
|---|
| | 1393 | { |
|---|
| | 1394 | return deflateInit_(strm, |
|---|
| | 1395 | level, |
|---|
| | 1396 | ZLIB_VERSION, |
|---|
| | 1397 | z_stream.sizeof); |
|---|
| | 1398 | } |
|---|
| | 1399 | |
|---|
| | 1400 | extern (D) int inflateInit(z_streamp strm) |
|---|
| | 1401 | { |
|---|
| | 1402 | return inflateInit_(strm, |
|---|
| | 1403 | ZLIB_VERSION, |
|---|
| | 1 |
|---|
|