2 * Header file for my independent implementation of Deflate
3 * (RFC1951) compression.
6 #ifndef DEFLATE_DEFLATE_H
7 #define DEFLATE_DEFLATE_H
14 /* ----------------------------------------------------------------------
15 * Compression functions. Create a compression context with
16 * deflate_compress_new(); feed it data with repeated calls to
17 * deflate_compress_data(); destroy it with
18 * deflate_compress_free().
21 typedef struct deflate_compress_ctx deflate_compress_ctx
;
24 * Create a new compression context. `type' indicates whether it's
25 * bare Deflate (as used in, say, zip files) or Zlib (as used in,
28 deflate_compress_ctx
*deflate_compress_new(int type
);
31 * Free a compression context previously allocated by
32 * deflate_compress_new().
34 void deflate_compress_free(deflate_compress_ctx
*ctx
);
37 * Give the compression context some data to compress. The input
38 * data is passed in `inblock', and has length `inlen'. This
39 * function may or may not produce some output data; if so, it is
40 * written to a dynamically allocated chunk of memory, a pointer to
41 * that memory is stored in `outblock', and the length of output
42 * data is stored in `outlen'. It is common for no data to be
43 * output, if the input data has merely been stored in internal
46 * `flushtype' indicates whether you want to force buffered data to
47 * be output. It can be one of the following values:
49 * - DEFLATE_NO_FLUSH: nothing is output if the compressor would
50 * rather not. Use this when the best compression is desired
51 * (i.e. most of the time).
53 * - DEFLATE_SYNC_FLUSH: all the buffered data is output, but the
54 * compressed data stream remains open and ready to continue
55 * compressing data. Use this in interactive protocols when a
56 * single compressed data stream is split across several network
59 * - DEFLATE_END_OF_DATA: all the buffered data is output and the
60 * compressed data stream is cleaned up. Any checksums required
61 * at the end of the stream are also output.
63 int deflate_compress_data(deflate_compress_ctx
*ctx
,
64 const void *inblock
, int inlen
, int flushtype
,
65 void **outblock
, int *outlen
);
73 /* ----------------------------------------------------------------------
74 * Decompression functions. Create a decompression context with
75 * deflate_decompress_new(); feed it data with repeated calls to
76 * deflate_decompress_data(); destroy it with
77 * deflate_decompress_free().
80 typedef struct deflate_decompress_ctx deflate_decompress_ctx
;
83 * Create a new decompression context. `type' means the same as it
84 * does in deflate_compress_new().
86 deflate_decompress_ctx
*deflate_decompress_new(int type
);
89 * Free a decompression context previously allocated by
90 * deflate_decompress_new().
92 void deflate_decompress_free(deflate_decompress_ctx
*ctx
);
95 * Give the decompression context some data to decompress. The
96 * input data is passed in `inblock', and has length `inlen'. This
97 * function may or may not produce some output data; if so, it is
98 * written to a dynamically allocated chunk of memory, a pointer to
99 * that memory is stored in `outblock', and the length of output
100 * data is stored in `outlen'.
102 * FIXME: error reporting?
104 int deflate_decompress_data(deflate_decompress_ctx
*ctx
,
105 const void *inblock
, int inlen
,
106 void **outblock
, int *outlen
);
108 #endif /* DEFLATE_DEFLATE_H */