2 * Helper routines to use Zlib
5 * Christopher Lahey (clahey@ximian.co)
7 * (C) 2004 Novell, Inc.
13 create_z_stream(int compress, unsigned char gzip)
18 z = malloc (sizeof (z_stream));
27 retval = deflateInit2 (z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, gzip ? 31 : -15, 8, Z_DEFAULT_STRATEGY);
29 retval = inflateInit2 (z, gzip ? 31 : -15);
40 free_z_stream(z_stream *z, int compress)
51 z_stream_set_next_in(z_stream *z, unsigned char *next_in)
57 z_stream_set_avail_in(z_stream *z, int avail_in)
59 z->avail_in = avail_in;
63 z_stream_get_avail_in(z_stream *z)
69 z_stream_set_next_out(z_stream *z, unsigned char *next_out)
71 z->next_out = next_out;
75 z_stream_set_avail_out(z_stream *z, int avail_out)
77 z->avail_out = avail_out;
81 z_stream_deflate (z_stream *z, int flush, unsigned char *next_out, int *avail_out)
85 z->next_out = next_out;
86 z->avail_out = *avail_out;
88 ret_val = deflate (z, flush);
90 *avail_out = z->avail_out;
96 z_stream_inflate (z_stream *z, int *avail_out)
100 z->avail_out = *avail_out;
102 ret_val = inflate (z, Z_NO_FLUSH);
104 *avail_out = z->avail_out;