michael@0: /* zlib.h -- interface of the 'zlib' general purpose compression library michael@0: version 1.0.4, Jul 24th, 1996. michael@0: michael@0: Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler michael@0: michael@0: This software is provided 'as-is', without any express or implied michael@0: warranty. In no event will the authors be held liable for any damages michael@0: arising from the use of this software. michael@0: michael@0: Permission is granted to anyone to use this software for any purpose, michael@0: including commercial applications, and to alter it and redistribute it michael@0: freely, subject to the following restrictions: michael@0: michael@0: 1. The origin of this software must not be misrepresented; you must not michael@0: claim that you wrote the original software. If you use this software michael@0: in a product, an acknowledgment in the product documentation would be michael@0: appreciated but is not required. michael@0: 2. Altered source versions must be plainly marked as such, and must not be michael@0: misrepresented as being the original software. michael@0: 3. This notice may not be removed or altered from any source distribution. michael@0: michael@0: Jean-loup Gailly Mark Adler michael@0: gzip@prep.ai.mit.edu madler@alumni.caltech.edu michael@0: michael@0: michael@0: The data format used by the zlib library is described by RFCs (Request for michael@0: Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt michael@0: (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). michael@0: */ michael@0: /* This file was modified since it was taken from the zlib distribution */ michael@0: michael@0: #ifndef _ZLIB_H michael@0: #define _ZLIB_H michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: #include "jzconf.h" michael@0: #else michael@0: #include "zconf.h" michael@0: #endif michael@0: michael@0: #define ZLIB_VERSION "1.0.4" michael@0: michael@0: /* michael@0: The 'zlib' compression library provides in-memory compression and michael@0: decompression functions, including integrity checks of the uncompressed michael@0: data. This version of the library supports only one compression method michael@0: (deflation) but other algorithms may be added later and will have the same michael@0: stream interface. michael@0: michael@0: For compression the application must provide the output buffer and michael@0: may optionally provide the input buffer for optimization. For decompression, michael@0: the application must provide the input buffer and may optionally provide michael@0: the output buffer for optimization. michael@0: michael@0: Compression can be done in a single step if the buffers are large michael@0: enough (for example if an input file is mmap'ed), or can be done by michael@0: repeated calls of the compression function. In the latter case, the michael@0: application must provide more input and/or consume the output michael@0: (providing more output space) before each call. michael@0: michael@0: The library does not install any signal handler. It is recommended to michael@0: add at least a handler for SIGSEGV when decompressing; the library checks michael@0: the consistency of the input data whenever possible but may go nuts michael@0: for some forms of corrupted input. michael@0: */ michael@0: michael@0: typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); michael@0: typedef void (*free_func) OF((voidpf opaque, voidpf address)); michael@0: michael@0: struct internal_state; michael@0: michael@0: typedef struct z_stream_s { michael@0: Bytef *next_in; /* next input byte */ michael@0: uInt avail_in; /* number of bytes available at next_in */ michael@0: uLong total_in; /* total nb of input bytes read so far */ michael@0: michael@0: Bytef *next_out; /* next output byte should be put there */ michael@0: uInt avail_out; /* remaining free space at next_out */ michael@0: uLong total_out; /* total nb of bytes output so far */ michael@0: michael@0: char *msg; /* last error message, NULL if no error */ michael@0: struct internal_state FAR *state; /* not visible by applications */ michael@0: michael@0: alloc_func zalloc; /* used to allocate the internal state */ michael@0: free_func zfree; /* used to free the internal state */ michael@0: voidpf opaque; /* private data object passed to zalloc and zfree */ michael@0: michael@0: int data_type; /* best guess about the data type: ascii or binary */ michael@0: uLong adler; /* adler32 value of the uncompressed data */ michael@0: uLong reserved; /* reserved for future use */ michael@0: } z_stream; michael@0: michael@0: typedef z_stream FAR *z_streamp; michael@0: michael@0: /* michael@0: The application must update next_in and avail_in when avail_in has michael@0: dropped to zero. It must update next_out and avail_out when avail_out michael@0: has dropped to zero. The application must initialize zalloc, zfree and michael@0: opaque before calling the init function. All other fields are set by the michael@0: compression library and must not be updated by the application. michael@0: michael@0: The opaque value provided by the application will be passed as the first michael@0: parameter for calls of zalloc and zfree. This can be useful for custom michael@0: memory management. The compression library attaches no meaning to the michael@0: opaque value. michael@0: michael@0: zalloc must return Z_NULL if there is not enough memory for the object. michael@0: On 16-bit systems, the functions zalloc and zfree must be able to allocate michael@0: exactly 65536 bytes, but will not be required to allocate more than this michael@0: if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, michael@0: pointers returned by zalloc for objects of exactly 65536 bytes *must* michael@0: have their offset normalized to zero. The default allocation function michael@0: provided by this library ensures this (see zutil.c). To reduce memory michael@0: requirements and avoid any allocation of 64K objects, at the expense of michael@0: compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). michael@0: michael@0: The fields total_in and total_out can be used for statistics or michael@0: progress reports. After compression, total_in holds the total size of michael@0: the uncompressed data and may be saved for use in the decompressor michael@0: (particularly if the decompressor wants to decompress everything in michael@0: a single step). michael@0: */ michael@0: michael@0: /* constants */ michael@0: michael@0: #define Z_NO_FLUSH 0 michael@0: #define Z_PARTIAL_FLUSH 1 michael@0: #define Z_SYNC_FLUSH 2 michael@0: #define Z_FULL_FLUSH 3 michael@0: #define Z_FINISH 4 michael@0: /* Allowed flush values; see deflate() below for details */ michael@0: michael@0: #define Z_OK 0 michael@0: #define Z_STREAM_END 1 michael@0: #define Z_NEED_DICT 2 michael@0: #define Z_ERRNO (-1) michael@0: #define Z_STREAM_ERROR (-2) michael@0: #define Z_DATA_ERROR (-3) michael@0: #define Z_MEM_ERROR (-4) michael@0: #define Z_BUF_ERROR (-5) michael@0: #define Z_VERSION_ERROR (-6) michael@0: /* Return codes for the compression/decompression functions. Negative michael@0: * values are errors, positive values are used for special but normal events. michael@0: */ michael@0: michael@0: #define Z_NO_COMPRESSION 0 michael@0: #define Z_BEST_SPEED 1 michael@0: #define Z_BEST_COMPRESSION 9 michael@0: #define Z_DEFAULT_COMPRESSION (-1) michael@0: /* compression levels */ michael@0: michael@0: #define Z_FILTERED 1 michael@0: #define Z_HUFFMAN_ONLY 2 michael@0: #define Z_DEFAULT_STRATEGY 0 michael@0: /* compression strategy; see deflateInit2() below for details */ michael@0: michael@0: #define Z_BINARY 0 michael@0: #define Z_ASCII 1 michael@0: #define Z_UNKNOWN 2 michael@0: /* Possible values of the data_type field */ michael@0: michael@0: #define Z_DEFLATED 8 michael@0: /* The deflate compression method (the only one supported in this version) */ michael@0: michael@0: #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ michael@0: michael@0: #define zlib_version zlibVersion() michael@0: /* for compatibility with versions < 1.0.2 */ michael@0: michael@0: /* basic functions */ michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(const char *) zlibVersion (void); michael@0: #else michael@0: extern const char * EXPORT zlibVersion OF((void)); michael@0: #endif michael@0: /* The application can compare zlibVersion and ZLIB_VERSION for consistency. michael@0: If the first character differs, the library code actually used is michael@0: not compatible with the zlib.h header file used by the application. michael@0: This check is automatically made by deflateInit and inflateInit. michael@0: */ michael@0: michael@0: /* michael@0: extern int EXPORT deflateInit OF((z_streamp strm, int level)); michael@0: michael@0: Initializes the internal stream state for compression. The fields michael@0: zalloc, zfree and opaque must be initialized before by the caller. michael@0: If zalloc and zfree are set to Z_NULL, deflateInit updates them to michael@0: use default allocation functions. michael@0: michael@0: The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: michael@0: 1 gives best speed, 9 gives best compression, 0 gives no compression at michael@0: all (the input data is simply copied a block at a time). michael@0: Z_DEFAULT_COMPRESSION requests a default compromise between speed and michael@0: compression (currently equivalent to level 6). michael@0: michael@0: deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not michael@0: enough memory, Z_STREAM_ERROR if level is not a valid compression level, michael@0: Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible michael@0: with the version assumed by the caller (ZLIB_VERSION). michael@0: msg is set to null if there is no error message. deflateInit does not michael@0: perform any compression: this will be done by deflate(). michael@0: */ michael@0: michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) deflate (z_streamp strm, int flush); michael@0: #else michael@0: extern int EXPORT deflate OF((z_streamp strm, int flush)); michael@0: #endif michael@0: /* michael@0: Performs one or both of the following actions: michael@0: michael@0: - Compress more input starting at next_in and update next_in and avail_in michael@0: accordingly. If not all input can be processed (because there is not michael@0: enough room in the output buffer), next_in and avail_in are updated and michael@0: processing will resume at this point for the next call of deflate(). michael@0: michael@0: - Provide more output starting at next_out and update next_out and avail_out michael@0: accordingly. This action is forced if the parameter flush is non zero. michael@0: Forcing flush frequently degrades the compression ratio, so this parameter michael@0: should be set only when necessary (in interactive applications). michael@0: Some output may be provided even if flush is not set. michael@0: michael@0: Before the call of deflate(), the application should ensure that at least michael@0: one of the actions is possible, by providing more input and/or consuming michael@0: more output, and updating avail_in or avail_out accordingly; avail_out michael@0: should never be zero before the call. The application can consume the michael@0: compressed output when it wants, for example when the output buffer is full michael@0: (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK michael@0: and with zero avail_out, it must be called again after making room in the michael@0: output buffer because there might be more output pending. michael@0: michael@0: If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression michael@0: block is terminated and flushed to the output buffer so that the michael@0: decompressor can get all input data available so far. For method 9, a future michael@0: variant on method 8, the current block will be flushed but not terminated. michael@0: Z_SYNC_FLUSH has the same effect as partial flush except that the compressed michael@0: output is byte aligned (the compressor can clear its internal bit buffer) michael@0: and the current block is always terminated; this can be useful if the michael@0: compressor has to be restarted from scratch after an interruption (in which michael@0: case the internal state of the compressor may be lost). michael@0: If flush is set to Z_FULL_FLUSH, the compression block is terminated, a michael@0: special marker is output and the compression dictionary is discarded; this michael@0: is useful to allow the decompressor to synchronize if one compressed block michael@0: has been damaged (see inflateSync below). Flushing degrades compression and michael@0: so should be used only when necessary. Using Z_FULL_FLUSH too often can michael@0: seriously degrade the compression. If deflate returns with avail_out == 0, michael@0: this function must be called again with the same value of the flush michael@0: parameter and more output space (updated avail_out), until the flush is michael@0: complete (deflate returns with non-zero avail_out). michael@0: michael@0: If the parameter flush is set to Z_FINISH, pending input is processed, michael@0: pending output is flushed and deflate returns with Z_STREAM_END if there michael@0: was enough output space; if deflate returns with Z_OK, this function must be michael@0: called again with Z_FINISH and more output space (updated avail_out) but no michael@0: more input data, until it returns with Z_STREAM_END or an error. After michael@0: deflate has returned Z_STREAM_END, the only possible operations on the michael@0: stream are deflateReset or deflateEnd. michael@0: michael@0: Z_FINISH can be used immediately after deflateInit if all the compression michael@0: is to be done in a single step. In this case, avail_out must be at least michael@0: 0.1% larger than avail_in plus 12 bytes. If deflate does not return michael@0: Z_STREAM_END, then it must be called again as described above. michael@0: michael@0: deflate() may update data_type if it can make a good guess about michael@0: the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered michael@0: binary. This field is only for information purposes and does not affect michael@0: the compression algorithm in any manner. michael@0: michael@0: deflate() returns Z_OK if some progress has been made (more input michael@0: processed or more output produced), Z_STREAM_END if all input has been michael@0: consumed and all output has been produced (only when flush is set to michael@0: Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example michael@0: if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible. michael@0: */ michael@0: michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) deflateEnd (z_streamp strm); michael@0: #else michael@0: extern int EXPORT deflateEnd OF((z_streamp strm)); michael@0: #endif michael@0: /* michael@0: All dynamically allocated data structures for this stream are freed. michael@0: This function discards any unprocessed input and does not flush any michael@0: pending output. michael@0: michael@0: deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the michael@0: stream state was inconsistent, Z_DATA_ERROR if the stream was freed michael@0: prematurely (some input or output was discarded). In the error case, michael@0: msg may be set but then points to a static string (which must not be michael@0: deallocated). michael@0: */ michael@0: michael@0: michael@0: /* michael@0: extern int EXPORT inflateInit OF((z_streamp strm)); michael@0: michael@0: Initializes the internal stream state for decompression. The fields michael@0: zalloc, zfree and opaque must be initialized before by the caller. If michael@0: zalloc and zfree are set to Z_NULL, inflateInit updates them to use default michael@0: allocation functions. michael@0: michael@0: inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not michael@0: enough memory, Z_VERSION_ERROR if the zlib library version is incompatible michael@0: with the version assumed by the caller. msg is set to null if there is no michael@0: error message. inflateInit does not perform any decompression: this will be michael@0: done by inflate(). michael@0: */ michael@0: michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) inflate (z_streamp strm, int flush); michael@0: #else michael@0: extern int EXPORT inflate OF((z_streamp strm, int flush)); michael@0: #endif michael@0: /* michael@0: Performs one or both of the following actions: michael@0: michael@0: - Decompress more input starting at next_in and update next_in and avail_in michael@0: accordingly. If not all input can be processed (because there is not michael@0: enough room in the output buffer), next_in is updated and processing michael@0: will resume at this point for the next call of inflate(). michael@0: michael@0: - Provide more output starting at next_out and update next_out and avail_out michael@0: accordingly. inflate() provides as much output as possible, until there michael@0: is no more input data or no more space in the output buffer (see below michael@0: about the flush parameter). michael@0: michael@0: Before the call of inflate(), the application should ensure that at least michael@0: one of the actions is possible, by providing more input and/or consuming michael@0: more output, and updating the next_* and avail_* values accordingly. michael@0: The application can consume the uncompressed output when it wants, for michael@0: example when the output buffer is full (avail_out == 0), or after each michael@0: call of inflate(). If inflate returns Z_OK and with zero avail_out, it michael@0: must be called again after making room in the output buffer because there michael@0: might be more output pending. michael@0: michael@0: If the parameter flush is set to Z_PARTIAL_FLUSH, inflate flushes as much michael@0: output as possible to the output buffer. The flushing behavior of inflate is michael@0: not specified for values of the flush parameter other than Z_PARTIAL_FLUSH michael@0: and Z_FINISH, but the current implementation actually flushes as much output michael@0: as possible anyway. michael@0: michael@0: inflate() should normally be called until it returns Z_STREAM_END or an michael@0: error. However if all decompression is to be performed in a single step michael@0: (a single call of inflate), the parameter flush should be set to michael@0: Z_FINISH. In this case all pending input is processed and all pending michael@0: output is flushed; avail_out must be large enough to hold all the michael@0: uncompressed data. (The size of the uncompressed data may have been saved michael@0: by the compressor for this purpose.) The next operation on this stream must michael@0: be inflateEnd to deallocate the decompression state. The use of Z_FINISH michael@0: is never required, but can be used to inform inflate that a faster routine michael@0: may be used for the single inflate() call. michael@0: michael@0: inflate() returns Z_OK if some progress has been made (more input michael@0: processed or more output produced), Z_STREAM_END if the end of the michael@0: compressed data has been reached and all uncompressed output has been michael@0: produced, Z_NEED_DICT if a preset dictionary is needed at this point (see michael@0: inflateSetDictionary below), Z_DATA_ERROR if the input data was corrupted, michael@0: Z_STREAM_ERROR if the stream structure was inconsistent (for example if michael@0: next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, michael@0: Z_BUF_ERROR if no progress is possible or if there was not enough room in michael@0: the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the michael@0: application may then call inflateSync to look for a good compression block. michael@0: In the Z_NEED_DICT case, strm->adler is set to the Adler32 value of the michael@0: dictionary chosen by the compressor. michael@0: */ michael@0: michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) inflateEnd (z_streamp strm); michael@0: #else michael@0: extern int EXPORT inflateEnd OF((z_streamp strm)); michael@0: #endif michael@0: /* michael@0: All dynamically allocated data structures for this stream are freed. michael@0: This function discards any unprocessed input and does not flush any michael@0: pending output. michael@0: michael@0: inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state michael@0: was inconsistent. In the error case, msg may be set but then points to a michael@0: static string (which must not be deallocated). michael@0: */ michael@0: michael@0: /* Advanced functions */ michael@0: michael@0: /* michael@0: The following functions are needed only in some special applications. michael@0: */ michael@0: michael@0: /* michael@0: extern int EXPORT deflateInit2 OF((z_streamp strm, michael@0: int level, michael@0: int method, michael@0: int windowBits, michael@0: int memLevel, michael@0: int strategy)); michael@0: michael@0: This is another version of deflateInit with more compression options. The michael@0: fields next_in, zalloc, zfree and opaque must be initialized before by michael@0: the caller. michael@0: michael@0: The method parameter is the compression method. It must be Z_DEFLATED in michael@0: this version of the library. (Method 9 will allow a 64K history buffer and michael@0: partial block flushes.) michael@0: michael@0: The windowBits parameter is the base two logarithm of the window size michael@0: (the size of the history buffer). It should be in the range 8..15 for this michael@0: version of the library (the value 16 will be allowed for method 9). Larger michael@0: values of this parameter result in better compression at the expense of michael@0: memory usage. The default value is 15 if deflateInit is used instead. michael@0: michael@0: The memLevel parameter specifies how much memory should be allocated michael@0: for the internal compression state. memLevel=1 uses minimum memory but michael@0: is slow and reduces compression ratio; memLevel=9 uses maximum memory michael@0: for optimal speed. The default value is 8. See zconf.h for total memory michael@0: usage as a function of windowBits and memLevel. michael@0: michael@0: The strategy parameter is used to tune the compression algorithm. Use the michael@0: value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a michael@0: filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no michael@0: string match). Filtered data consists mostly of small values with a michael@0: somewhat random distribution. In this case, the compression algorithm is michael@0: tuned to compress them better. The effect of Z_FILTERED is to force more michael@0: Huffman coding and less string matching; it is somewhat intermediate michael@0: between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects michael@0: the compression ratio but not the correctness of the compressed output even michael@0: if it is not set appropriately. michael@0: michael@0: If next_in is not null, the library will use this buffer to hold also michael@0: some history information; the buffer must either hold the entire input michael@0: data, or have at least 1<<(windowBits+1) bytes and be writable. If next_in michael@0: is null, the library will allocate its own history buffer (and leave next_in michael@0: null). next_out need not be provided here but must be provided by the michael@0: application for the next call of deflate(). michael@0: michael@0: If the history buffer is provided by the application, next_in must michael@0: must never be changed by the application since the compressor maintains michael@0: information inside this buffer from call to call; the application michael@0: must provide more input only by increasing avail_in. next_in is always michael@0: reset by the library in this case. michael@0: michael@0: deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was michael@0: not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as michael@0: an invalid method). msg is set to null if there is no error message. michael@0: deflateInit2 does not perform any compression: this will be done by michael@0: deflate(). michael@0: */ michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) deflateSetDictionary (z_streamp strm, michael@0: const Bytef *dictionary, michael@0: uInt dictLength); michael@0: #else michael@0: extern int EXPORT deflateSetDictionary OF((z_streamp strm, michael@0: const Bytef *dictionary, michael@0: uInt dictLength)); michael@0: #endif michael@0: /* michael@0: Initializes the compression dictionary (history buffer) from the given michael@0: byte sequence without producing any compressed output. This function must michael@0: be called immediately after deflateInit or deflateInit2, before any call michael@0: of deflate. The compressor and decompressor must use exactly the same michael@0: dictionary (see inflateSetDictionary). michael@0: The dictionary should consist of strings (byte sequences) that are likely michael@0: to be encountered later in the data to be compressed, with the most commonly michael@0: used strings preferably put towards the end of the dictionary. Using a michael@0: dictionary is most useful when the data to be compressed is short and michael@0: can be predicted with good accuracy; the data can then be compressed better michael@0: than with the default empty dictionary. In this version of the library, michael@0: only the last 32K bytes of the dictionary are used. michael@0: Upon return of this function, strm->adler is set to the Adler32 value michael@0: of the dictionary; the decompressor may later use this value to determine michael@0: which dictionary has been used by the compressor. (The Adler32 value michael@0: applies to the whole dictionary even if only a subset of the dictionary is michael@0: actually used by the compressor.) michael@0: michael@0: deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a michael@0: parameter is invalid (such as NULL dictionary) or the stream state michael@0: is inconsistent (for example if deflate has already been called for this michael@0: stream). deflateSetDictionary does not perform any compression: this will michael@0: be done by deflate(). michael@0: */ michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) deflateCopy (z_streamp dest, z_streamp source); michael@0: #else michael@0: extern int EXPORT deflateCopy OF((z_streamp dest, z_streamp source)); michael@0: #endif michael@0: /* michael@0: Sets the destination stream as a complete copy of the source stream. If michael@0: the source stream is using an application-supplied history buffer, a new michael@0: buffer is allocated for the destination stream. The compressed output michael@0: buffer is always application-supplied. It's the responsibility of the michael@0: application to provide the correct values of next_out and avail_out for the michael@0: next call of deflate. michael@0: michael@0: This function can be useful when several compression strategies will be michael@0: tried, for example when there are several ways of pre-processing the input michael@0: data with a filter. The streams that will be discarded should then be freed michael@0: by calling deflateEnd. Note that deflateCopy duplicates the internal michael@0: compression state which can be quite large, so this strategy is slow and michael@0: can consume lots of memory. michael@0: michael@0: deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not michael@0: enough memory, Z_STREAM_ERROR if the source stream state was inconsistent michael@0: (such as zalloc being NULL). msg is left unchanged in both source and michael@0: destination. michael@0: */ michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) deflateReset (z_streamp strm); michael@0: #else michael@0: extern int EXPORT deflateReset OF((z_streamp strm)); michael@0: #endif michael@0: /* michael@0: This function is equivalent to deflateEnd followed by deflateInit, michael@0: but does not free and reallocate all the internal compression state. michael@0: The stream will keep the same compression level and any other attributes michael@0: that may have been set by deflateInit2. michael@0: michael@0: deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source michael@0: stream state was inconsistent (such as zalloc or state being NULL). michael@0: */ michael@0: michael@0: #ifdef MOZILLA_CLIENT michael@0: PR_EXTERN(int) deflateParams (z_streamp strm, int level, int strategy); michael@0: #else michael@0: extern int EXPORT deflateParams OF((z_streamp strm, int level, int strategy)); michael@0: #endif michael@0: /* michael@0: Dynamically update the compression level and compression strategy. michael@0: This can be used to switch between compression and straight copy of michael@0: the input data, or to switch to a different kind of input data requiring michael@0: a different strategy. If the compression level is changed, the input michael@0: available so far is compressed with the old level (and may be flushed); michael@0: the new level will take effect only at the next call of deflate(). michael@0: michael@0: Before the call of deflateParams, the stream state must be set as for michael@0: a call of deflate(), since the currently available input may have to michael@0: be compressed and flushed. In particular, strm->avail_out must be non-zero. michael@0: michael@0: deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source michael@0: stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR michael@0: if strm->avail_out was zero. michael@0: */ michael@0: michael@0: /* michael@0: extern int EXPORT inflateInit2 OF((z_streamp strm, michael@0: int windowBits)); michael@0: michael@0: This is another version of inflateInit with more compression options. The michael@0: fields next_out, zalloc, zfree and opaque must be initialized before by michael@0: the caller. michael@0: michael@0: The windowBits parameter is the base two logarithm of the maximum window michael@0: size (the size of the history buffer). It should be in the range 8..15 for michael@0: this version of the library (the value 16 will be allowed soon). The michael@0: default value is 15 if inflateInit is used instead. If a compressed stream michael@0: with a larger window size is given as input, inflate() will return with michael@0: the error code Z_DATA_ERROR instead of trying to allocate a larger window. michael@0: michael@0: If next_out is not null, the library will use this buffer for the history michael@0: buffer; the buffer must either be large enough to hold the entire output michael@0: data, or have at least 1<