xref: /netbsd-src/common/dist/zlib/contrib/infback9/inflate9.h (revision c34236556bea94afcaca1782d7d228301edc3ea0)
1*aaf4ece6Schristos /* inflate9.h -- internal inflate state definition
2*aaf4ece6Schristos  * Copyright (C) 1995-2003 Mark Adler
3*aaf4ece6Schristos  * For conditions of distribution and use, see copyright notice in zlib.h
4*aaf4ece6Schristos  */
5*aaf4ece6Schristos 
6*aaf4ece6Schristos /* WARNING: this file should *not* be used by applications. It is
7*aaf4ece6Schristos    part of the implementation of the compression library and is
8*aaf4ece6Schristos    subject to change. Applications should only use zlib.h.
9*aaf4ece6Schristos  */
10*aaf4ece6Schristos 
11*aaf4ece6Schristos /* Possible inflate modes between inflate() calls */
12*aaf4ece6Schristos typedef enum {
13*aaf4ece6Schristos         TYPE,       /* i: waiting for type bits, including last-flag bit */
14*aaf4ece6Schristos         STORED,     /* i: waiting for stored size (length and complement) */
15*aaf4ece6Schristos         TABLE,      /* i: waiting for dynamic block table lengths */
16*aaf4ece6Schristos             LEN,        /* i: waiting for length/lit code */
17*aaf4ece6Schristos     DONE,       /* finished check, done -- remain here until reset */
18*aaf4ece6Schristos     BAD         /* got a data error -- remain here until reset */
19*aaf4ece6Schristos } inflate_mode;
20*aaf4ece6Schristos 
21*aaf4ece6Schristos /*
22*aaf4ece6Schristos     State transitions between above modes -
23*aaf4ece6Schristos 
24*aaf4ece6Schristos     (most modes can go to the BAD mode -- not shown for clarity)
25*aaf4ece6Schristos 
26*aaf4ece6Schristos     Read deflate blocks:
27*aaf4ece6Schristos             TYPE -> STORED or TABLE or LEN or DONE
28*aaf4ece6Schristos             STORED -> TYPE
29*aaf4ece6Schristos             TABLE -> LENLENS -> CODELENS -> LEN
30*aaf4ece6Schristos     Read deflate codes:
31*aaf4ece6Schristos                 LEN -> LEN or TYPE
32*aaf4ece6Schristos  */
33*aaf4ece6Schristos 
34*aaf4ece6Schristos /* state maintained between inflate() calls.  Approximately 7K bytes. */
35*aaf4ece6Schristos struct inflate_state {
36*aaf4ece6Schristos         /* sliding window */
37*aaf4ece6Schristos     unsigned char FAR *window;  /* allocated sliding window, if needed */
38*aaf4ece6Schristos         /* dynamic table building */
39*aaf4ece6Schristos     unsigned ncode;             /* number of code length code lengths */
40*aaf4ece6Schristos     unsigned nlen;              /* number of length code lengths */
41*aaf4ece6Schristos     unsigned ndist;             /* number of distance code lengths */
42*aaf4ece6Schristos     unsigned have;              /* number of code lengths in lens[] */
43*aaf4ece6Schristos     code FAR *next;             /* next available space in codes[] */
44*aaf4ece6Schristos     unsigned short lens[320];   /* temporary storage for code lengths */
45*aaf4ece6Schristos     unsigned short work[288];   /* work area for code table building */
46*aaf4ece6Schristos     code codes[ENOUGH];         /* space for code tables */
47*aaf4ece6Schristos };
48