]> mj.ucw.cz Git - libucw.git/blob - lib/lizard.h
interface of lizard_decompress_safe() has been simplified
[libucw.git] / lib / lizard.h
1 /*
2  *      LiZaRd -- Fast compression method based on Lempel-Ziv 77
3  *
4  *      (c) 2004, Robert Spalek <robert@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #define LIZARD_NEEDS_CHARS      8
11   /* The compression routine needs input buffer 8 characters longer, because it
12    * does not check the input bounds all the time.  */
13 #define LIZARD_MAX_MULTIPLY     23./22
14 #define LIZARD_MAX_ADD          4
15   /* In the worst case, the compressed file will not be longer than its
16    * original length * 23/22 + 4.
17    *
18    * The additive constant is for EOF and the header of the file.
19    *
20    * The multiplicative constant comes from 19-byte incompressible string
21    * followed by a 3-sequence that can be compressed into 2-byte link.  This
22    * breaks the copy-mode and it needs to be restarted with a new header.  The
23    * total length is 2(header) + 19(string) + 2(link) = 23.
24    */
25
26 /* lizard.c */
27 int lizard_compress(byte *in, uns in_len, byte *out);
28 int lizard_decompress(byte *in, byte *out);
29
30 /* lizard-safe.c */
31 struct lizard_buffer;
32
33 struct lizard_buffer *lizard_alloc(void);
34 void lizard_free(struct lizard_buffer *buf);
35 byte *lizard_decompress_safe(byte *in, struct lizard_buffer *buf, uns expected_length);