version 1.13, 2001/02/08 19:30:51 |
version 1.14, 2001/04/05 10:39:01 |
|
|
|
|
static z_stream incoming_stream; |
static z_stream incoming_stream; |
static z_stream outgoing_stream; |
static z_stream outgoing_stream; |
|
static int compress_init_send_called = 0; |
|
static int compress_init_recv_called = 0; |
|
|
/* |
/* |
* Initializes compression; level is compression level from 1 to 9 |
* Initializes compression; level is compression level from 1 to 9 |
|
|
*/ |
*/ |
|
|
void |
void |
buffer_compress_init(int level) |
buffer_compress_init_send(int level) |
{ |
{ |
|
if (compress_init_send_called == 1) |
|
deflateEnd(&incoming_stream); |
|
compress_init_send_called = 1; |
debug("Enabling compression at level %d.", level); |
debug("Enabling compression at level %d.", level); |
if (level < 1 || level > 9) |
if (level < 1 || level > 9) |
fatal("Bad compression level %d.", level); |
fatal("Bad compression level %d.", level); |
inflateInit(&incoming_stream); |
|
deflateInit(&outgoing_stream, level); |
deflateInit(&outgoing_stream, level); |
} |
} |
|
void |
|
buffer_compress_init_recv(void) |
|
{ |
|
if (compress_init_recv_called == 1) |
|
inflateEnd(&incoming_stream); |
|
compress_init_recv_called = 1; |
|
inflateInit(&incoming_stream); |
|
} |
|
|
/* Frees any data structures allocated for compression. */ |
/* Frees any data structures allocated for compression. */ |
|
|
|
|
incoming_stream.total_out, incoming_stream.total_in, |
incoming_stream.total_out, incoming_stream.total_in, |
incoming_stream.total_out == 0 ? 0.0 : |
incoming_stream.total_out == 0 ? 0.0 : |
(double) incoming_stream.total_in / incoming_stream.total_out); |
(double) incoming_stream.total_in / incoming_stream.total_out); |
inflateEnd(&incoming_stream); |
if (compress_init_recv_called == 1) |
deflateEnd(&outgoing_stream); |
inflateEnd(&incoming_stream); |
|
if (compress_init_send_called == 1) |
|
deflateEnd(&outgoing_stream); |
} |
} |
|
|
/* |
/* |