]>
Commit | Line | Data |
---|---|---|
012771d8 WD |
1 | /*------------------------------------------------------------------------- |
2 | * Filename: mini_inflate.h | |
3 | * Version: $Id: mini_inflate.h,v 1.2 2002/01/17 00:53:20 nyet Exp $ | |
4 | * Copyright: Copyright (C) 2001, Russ Dill | |
5 | * Author: Russ Dill <Russ.Dill@asu.edu> | |
6 | * Description: Mini deflate implementation | |
7 | *-----------------------------------------------------------------------*/ | |
8 | /* | |
1a459660 | 9 | * SPDX-License-Identifier: GPL-2.0+ |
012771d8 WD |
10 | */ |
11 | ||
12 | typedef __SIZE_TYPE__ size; | |
13 | ||
14 | #define NO_ERROR 0 | |
15 | #define COMP_UNKNOWN 1 /* The specififed bytype is invalid */ | |
16 | #define CODE_NOT_FOUND 2 /* a huffman code in the stream could not be decoded */ | |
17 | #define TOO_MANY_BITS 3 /* pull_bits was passed an argument that is too | |
18 | * large */ | |
19 | ||
20 | /* This struct represents an entire huffman code set. It has various lookup | |
21 | * tables to speed decoding */ | |
22 | struct huffman_set { | |
23 | int bits; /* maximum bit length */ | |
24 | int num_symbols; /* Number of symbols this code can represent */ | |
25 | int *lengths; /* The bit length of symbols */ | |
26 | int *symbols; /* All of the symbols, sorted by the huffman code */ | |
27 | int *count; /* the number of codes of this bit length */ | |
28 | int *first; /* the first code of this bit length */ | |
29 | int *pos; /* the symbol that first represents (in the symbols | |
30 | * array) */ | |
31 | }; | |
32 | ||
33 | struct bitstream { | |
34 | unsigned char *data; /* increments as we move from byte to byte */ | |
35 | unsigned char bit; /* 0 to 7 */ | |
36 | void *(*memcpy)(void *, const void *, size); | |
37 | unsigned long decoded; /* The number of bytes decoded */ | |
38 | int error; | |
39 | ||
40 | int distance_count[16]; | |
41 | int distance_first[16]; | |
42 | int distance_pos[16]; | |
43 | int distance_lengths[32]; | |
44 | int distance_symbols[32]; | |
45 | ||
46 | int code_count[8]; | |
47 | int code_first[8]; | |
48 | int code_pos[8]; | |
49 | int code_lengths[19]; | |
50 | int code_symbols[19]; | |
51 | ||
52 | int length_count[16]; | |
53 | int length_first[16]; | |
54 | int length_pos[16]; | |
55 | int length_lengths[288]; | |
56 | int length_symbols[288]; | |
57 | ||
58 | struct huffman_set codes; | |
59 | struct huffman_set lengths; | |
60 | struct huffman_set distance; | |
61 | }; | |
62 | ||
63 | #define NO_COMP 0 | |
64 | #define FIXED_COMP 1 | |
65 | #define DYNAMIC_COMP 2 | |
66 | ||
67 | long decompress_block(unsigned char *dest, unsigned char *source, | |
68 | void *(*inflate_memcpy)(void *dest, const void *src, size n)); |