misc/libfreetype/src/gzip/infutil.h
author nemo
Sun, 11 Sep 2011 21:32:49 -0400
changeset 5872 454f246fe4c5
parent 5172 88f2e05288ba
permissions -rw-r--r--
uh, that was just so I could look at the flame more closely, wasn't supposed to be checked in
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/* infutil.h -- types and macros common to blocks and codes
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
 * Copyright (C) 1995-2002 Mark Adler
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
 * For conditions of distribution and use, see copyright notice in zlib.h
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/* WARNING: this file should *not* be used by applications. It is
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
   part of the implementation of the compression library and is
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
   subject to change. Applications should only use zlib.h.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
#ifndef _INFUTIL_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
#define _INFUTIL_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
typedef enum {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
      TYPE,     /* get type bits (3, including end bit) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
      LENS,     /* get lengths for stored */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
      STORED,   /* processing stored block */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
      TABLE,    /* get table lengths */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
      BTREE,    /* get bit lengths tree for a dynamic block */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
      DTREE,    /* get length, distance trees for a dynamic block */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
      CODES,    /* processing fixed or dynamic block */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
      DRY,      /* output remaining window bytes */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
      DONE,     /* finished last block, done */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
      BAD}      /* got a data error--stuck here */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
inflate_block_mode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
/* inflate blocks semi-private state */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
struct inflate_blocks_state {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /* mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  inflate_block_mode  mode;     /* current inflate_block mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /* mode dependent information */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  union {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
    uInt left;          /* if STORED, bytes left to copy */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
    struct {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
      uInt table;               /* table lengths (14 bits) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
      uInt index;               /* index into blens (or border) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
      uIntf *blens;             /* bit lengths of codes */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
      uInt bb;                  /* bit length tree depth */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
      inflate_huft *tb;         /* bit length decoding tree */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
    } trees;            /* if DTREE, decoding info for trees */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
    struct {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
      inflate_codes_statef
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
         *codes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    } decode;           /* if CODES, current state */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  } sub;                /* submode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  uInt last;            /* true if this block is the last block */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  /* mode independent information */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
  uInt bitk;            /* bits in bit buffer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
  uLong bitb;           /* bit buffer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  inflate_huft *hufts;  /* single malloc for tree space */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  Bytef *window;        /* sliding window */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  Bytef *end;           /* one byte after sliding window */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  Bytef *read;          /* window read pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  Bytef *write;         /* window write pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  check_func checkfn;   /* check function */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
  uLong check;          /* check on output */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
};
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
/* defines for inflate input/output */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
/*   update pointers and return */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
#define UPDBITS {s->bitb=b;s->bitk=k;}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
#define UPDOUT {s->write=q;}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
#define UPDATE {UPDBITS UPDIN UPDOUT}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
#define LEAVE {UPDATE return inflate_flush(s,z,r);}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
/*   get bytes and bits */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
#define NEXTBYTE (n--,*p++)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
#define DUMPBITS(j) {b>>=(j);k-=(j);}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
/*   output bytes */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
/*   load local pointers */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
#define LOAD {LOADIN LOADOUT}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
/* masks for lower bits (size given to avoid silly warnings with Visual C++) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
#ifndef NO_INFLATE_MASK
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
local uInt inflate_mask[17];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
/* copy as much as possible from the sliding window to the output area */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
local int inflate_flush OF((
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
    inflate_blocks_statef *,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    z_streamp ,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    int));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
#endif