| 1 | /* deflate.h -- internal compression state
|
|---|
| 2 | * Copyright (C) 1995-2004 Jean-loup Gailly
|
|---|
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /* WARNING: this file should *not* be used by applications. It is
|
|---|
| 7 | part of the implementation of the compression library and is
|
|---|
| 8 | subject to change. Applications should only use zlib.h.
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | /* @(#) $Id$ */
|
|---|
| 12 |
|
|---|
| 13 | #ifndef DEFLATE_H
|
|---|
| 14 | #define DEFLATE_H
|
|---|
| 15 |
|
|---|
| 16 | #include "zutil.h"
|
|---|
| 17 |
|
|---|
| 18 | /* define NO_GZIP when compiling if you want to disable gzip header and
|
|---|
| 19 | trailer creation by deflate(). NO_GZIP would be used to avoid linking in
|
|---|
| 20 | the crc code when it is not needed. For shared libraries, gzip encoding
|
|---|
| 21 | should be left enabled. */
|
|---|
| 22 | #ifndef NO_GZIP
|
|---|
| 23 | # define GZIP
|
|---|
| 24 | #endif
|
|---|
| 25 |
|
|---|
| 26 | /* ===========================================================================
|
|---|
| 27 | * Internal compression state.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | #define LENGTH_CODES 29
|
|---|
| 31 | /* number of length codes, not counting the special END_BLOCK code */
|
|---|
| 32 |
|
|---|
| 33 | #define LITERALS 256
|
|---|
| 34 | /* number of literal bytes 0..255 */
|
|---|
| 35 |
|
|---|
| 36 | #define L_CODES (LITERALS+1+LENGTH_CODES)
|
|---|
| 37 | /* number of Literal or Length codes, including the END_BLOCK code */
|
|---|
| 38 |
|
|---|
| 39 | #define D_CODES 30
|
|---|
| 40 | /* number of distance codes */
|
|---|
| 41 |
|
|---|
| 42 | #define BL_CODES 19
|
|---|
| 43 | /* number of codes used to transfer the bit lengths */
|
|---|
| 44 |
|
|---|
| 45 | #define HEAP_SIZE (2*L_CODES+1)
|
|---|
| 46 | /* maximum heap size */
|
|---|
| 47 |
|
|---|
| 48 | #define MAX_BITS 15
|
|---|
| 49 | /* All codes must not exceed MAX_BITS bits */
|
|---|
| 50 |
|
|---|
| 51 | #define INIT_STATE 42
|
|---|
| 52 | #define EXTRA_STATE 69
|
|---|
| 53 | #define NAME_STATE 73
|
|---|
| 54 | #define COMMENT_STATE 91
|
|---|
| 55 | #define HCRC_STATE 103
|
|---|
| 56 | #define BUSY_STATE 113
|
|---|
| 57 | #define FINISH_STATE 666
|
|---|
| 58 | /* Stream status */
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | /* Data structure describing a single value and its code string. */
|
|---|
| 62 | typedef struct ct_data_s {
|
|---|
| 63 | union {
|
|---|
| 64 | ush freq; /* frequency count */
|
|---|
| 65 | ush code; /* bit string */
|
|---|
| 66 | } fc;
|
|---|
| 67 | union {
|
|---|
| 68 | ush dad; /* father node in Huffman tree */
|
|---|
| 69 | ush len; /* length of bit string */
|
|---|
| 70 | } dl;
|
|---|
| 71 | } FAR ct_data;
|
|---|
| 72 |
|
|---|
| 73 | #define Freq fc.freq
|
|---|
| 74 | #define Code fc.code
|
|---|
| 75 | #define Dad dl.dad
|
|---|
| 76 | #define Len dl.len
|
|---|
| 77 |
|
|---|
| 78 | typedef struct static_tree_desc_s static_tree_desc;
|
|---|
| 79 |
|
|---|
| 80 | typedef struct tree_desc_s {
|
|---|
| 81 | ct_data *dyn_tree; /* the dynamic tree */
|
|---|
| 82 | int max_code; /* largest code with non zero frequency */
|
|---|
| 83 | static_tree_desc *stat_desc; /* the corresponding static tree */
|
|---|
| 84 | } FAR tree_desc;
|
|---|
| 85 |
|
|---|
| 86 | typedef ush Pos;
|
|---|
| 87 | typedef Pos FAR Posf;
|
|---|
| 88 | typedef unsigned IPos;
|
|---|
| 89 |
|
|---|
| 90 | /* A Pos is an index in the character window. We use short instead of int to
|
|---|
| 91 | * save space in the various tables. IPos is used only for parameter passing.
|
|---|
| 92 | */
|
|---|
| 93 |
|
|---|
| 94 | typedef struct internal_state {
|
|---|
| 95 | z_streamp strm; /* pointer back to this zlib stream */
|
|---|
| 96 | int status; /* as the name implies */
|
|---|
| 97 | Bytef *pending_buf; /* output still pending */
|
|---|
| 98 | ulg pending_buf_size; /* size of pending_buf */
|
|---|
| 99 | Bytef *pending_out; /* next pending byte to output to the stream */
|
|---|
| 100 | uInt pending; /* nb of bytes in the pending buffer */
|
|---|
| 101 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
|---|
| 102 | gz_headerp gzhead; /* gzip header information to write */
|
|---|
| 103 | uInt gzindex; /* where in extra, name, or comment */
|
|---|
| 104 | Byte method; /* STORED (for zip only) or DEFLATED */
|
|---|
|
|---|