version 1.3, 1999/11/24 00:26:01 |
version 1.4, 1999/11/24 19:53:46 |
|
|
static z_stream incoming_stream; |
static z_stream incoming_stream; |
static z_stream outgoing_stream; |
static z_stream outgoing_stream; |
|
|
/* Initializes compression; level is compression level from 1 to 9 |
/* |
(as in gzip). */ |
* Initializes compression; level is compression level from 1 to 9 |
|
* (as in gzip). |
|
*/ |
|
|
void |
void |
buffer_compress_init(int level) |
buffer_compress_init(int level) |
|
|
deflateEnd(&outgoing_stream); |
deflateEnd(&outgoing_stream); |
} |
} |
|
|
/* Compresses the contents of input_buffer into output_buffer. All |
/* |
packets compressed using this function will form a single |
* Compresses the contents of input_buffer into output_buffer. All packets |
compressed data stream; however, data will be flushed at the end of |
* compressed using this function will form a single compressed data stream; |
every call so that each output_buffer can be decompressed |
* however, data will be flushed at the end of every call so that each |
independently (but in the appropriate order since they together |
* output_buffer can be decompressed independently (but in the appropriate |
form a single compression stream) by the receiver. This appends |
* order since they together form a single compression stream) by the |
the compressed data to the output buffer. */ |
* receiver. This appends the compressed data to the output buffer. |
|
*/ |
|
|
void |
void |
buffer_compress(Buffer * input_buffer, Buffer * output_buffer) |
buffer_compress(Buffer * input_buffer, Buffer * output_buffer) |
|
|
while (outgoing_stream.avail_out == 0); |
while (outgoing_stream.avail_out == 0); |
} |
} |
|
|
/* Uncompresses the contents of input_buffer into output_buffer. All |
/* |
packets uncompressed using this function will form a single |
* Uncompresses the contents of input_buffer into output_buffer. All packets |
compressed data stream; however, data will be flushed at the end of |
* uncompressed using this function will form a single compressed data |
every call so that each output_buffer. This must be called for the |
* stream; however, data will be flushed at the end of every call so that |
same size units that the buffer_compress was called, and in the |
* each output_buffer. This must be called for the same size units that the |
same order that buffers compressed with that. This appends the |
* buffer_compress was called, and in the same order that buffers compressed |
uncompressed data to the output buffer. */ |
* with that. This appends the uncompressed data to the output buffer. |
|
*/ |
|
|
void |
void |
buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer) |
buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer) |
|
|
fatal("buffer_uncompress: inflate returned Z_STREAM_ERROR"); |
fatal("buffer_uncompress: inflate returned Z_STREAM_ERROR"); |
/* NOTREACHED */ |
/* NOTREACHED */ |
case Z_BUF_ERROR: |
case Z_BUF_ERROR: |
/* Comments in zlib.h say that we should keep |
/* |
calling inflate() until we get an error. This |
* Comments in zlib.h say that we should keep calling |
appears to be the error that we get. */ |
* inflate() until we get an error. This appears to |
|
* be the error that we get. |
|
*/ |
return; |
return; |
case Z_MEM_ERROR: |
case Z_MEM_ERROR: |
fatal("buffer_uncompress: inflate returned Z_MEM_ERROR"); |
fatal("buffer_uncompress: inflate returned Z_MEM_ERROR"); |