1 | /* lzw.h -- define the lzw functions.
|
---|
2 |
|
---|
3 | Copyright (C) 1992-1993 Jean-loup Gailly.
|
---|
4 |
|
---|
5 | This program is free software; you can redistribute it and/or modify
|
---|
6 | it under the terms of the GNU General Public License as published by
|
---|
7 | the Free Software Foundation; either version 2, or (at your option)
|
---|
8 | any later version.
|
---|
9 |
|
---|
10 | This program is distributed in the hope that it will be useful,
|
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | GNU General Public License for more details.
|
---|
14 |
|
---|
15 | You should have received a copy of the GNU General Public License
|
---|
16 | along with this program; if not, write to the Free Software Foundation,
|
---|
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
---|
18 |
|
---|
19 | #if !defined(OF) && defined(lint)
|
---|
20 | # include "gzip.h"
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #ifndef BITS
|
---|
24 | # define BITS 16
|
---|
25 | #endif
|
---|
26 | #define INIT_BITS 9 /* Initial number of bits per code */
|
---|
27 |
|
---|
28 | #define LZW_MAGIC "\037\235" /* Magic header for lzw files, 1F 9D */
|
---|
29 |
|
---|
30 | #define BIT_MASK 0x1f /* Mask for 'number of compression bits' */
|
---|
31 | /* Mask 0x20 is reserved to mean a fourth header byte, and 0x40 is free.
|
---|
32 | * It's a pity that old uncompress does not check bit 0x20. That makes
|
---|
33 | * extension of the format actually undesirable because old compress
|
---|
34 | * would just crash on the new format instead of giving a meaningful
|
---|
35 | * error message. It does check the number of bits, but it's more
|
---|
36 | * helpful to say "unsupported format, get a new version" than
|
---|
37 | * "can only handle 16 bits".
|
---|
38 | */
|
---|
39 |
|
---|
40 | #define BLOCK_MODE 0x80
|
---|
41 | /* Block compression: if table is full and compression rate is dropping,
|
---|
42 | * clear the dictionary.
|
---|
43 | */
|
---|
44 |
|
---|
45 | #define LZW_RESERVED 0x60 /* reserved bits */
|
---|
46 |
|
---|
47 | #define CLEAR 256 /* flush the dictionary */
|
---|
48 | #define FIRST (CLEAR+1) /* first free entry */
|
---|
49 |
|
---|
50 | extern int maxbits; /* max bits per code for LZW */
|
---|
51 | extern int block_mode; /* block compress mode -C compatible with 2.0 */
|
---|
52 |
|
---|
53 | extern int lzw OF((int in, int out));
|
---|
54 | extern int unlzw OF((int in, int out));
|
---|