FreeBSD kernel kern code
inflate.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/inflate.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
Include dependency graph for inflate.c:

Go to the source code of this file.

Data Structures

struct  huft
 

Macros

#define uch   u_char
 
#define ush   u_short
 
#define ulg   u_long
 
#define memzero(dest, len)    bzero(dest,len)
 
#define NOMEMCPY
 
#define FPRINTF   printf
 
#define FLUSH(x, y)
 
#define PKZIP_BUG_WORKAROUND   /* PKZIP 1.93a problem--live with it */
 
#define INFMOD
 
#define NEEDBITS(glbl, n)
 
#define DUMPBITS(n)   {b>>=(n);k-=(n);}
 
#define BMAX
 
#define N_MAX   288 /* maximum number of codes in any set */
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_GZIP,"gzip_trees","Gzip trees")
 
static int huft_build (struct inflate *, unsigned *, unsigned, unsigned, const ush *, const ush *, struct huft **, int *)
 
static int huft_free (struct inflate *, struct huft *)
 
static int inflate_codes (struct inflate *, struct huft *, struct huft *, int, int)
 
static int inflate_stored (struct inflate *)
 
static int xinflate (struct inflate *)
 
static int inflate_fixed (struct inflate *)
 
static int inflate_dynamic (struct inflate *)
 
static int inflate_block (struct inflate *, int *)
 
static int huft_build (struct inflate *glbl, unsigned *b, unsigned n, unsigned s, const ush *d, const ush *e, struct huft **t, int *m)
 
static int huft_free (struct inflate *glbl, struct huft *t)
 
static int inflate_codes (struct inflate *glbl, struct huft *tl, struct huft *td, int bl, int bd)
 
static int inflate_block (struct inflate *glbl, int *e)
 
int inflate (struct inflate *glbl)
 

Variables

static const int qflag = 0
 
static const unsigned border []
 
static const ush cplens []
 
static const ush cplext []
 
static const ush cpdist []
 
static const ush cpdext []
 
static const ush mask []
 
static const int lbits = 9
 
static const int dbits = 6
 

Macro Definition Documentation

#define BMAX
Value:
16 /* maximum bit length of any code (16 for
* explode) */

Definition at line 402 of file inflate.c.

Referenced by huft_build().

#define DUMPBITS (   n)    {b>>=(n);k-=(n);}

Definition at line 363 of file inflate.c.

Referenced by inflate_block(), inflate_codes(), inflate_dynamic(), and inflate_stored().

#define FLUSH (   x,
 
)
Value:
{ \
int foo = (*x->gz_output)(x->gz_private,x->gz_slide,y); \
if (foo) \
return foo; \
}

Definition at line 43 of file inflate.c.

Referenced by inflate_codes(), inflate_stored(), and xinflate().

#define FPRINTF   printf

Definition at line 37 of file inflate.c.

Referenced by inflate_dynamic().

#define INFMOD
Value:
/* tell inflate.h to include code to be
* compiled */

Definition at line 254 of file inflate.c.

#define memzero (   dest,
  len 
)    bzero(dest,len)

Definition at line 33 of file inflate.c.

Referenced by huft_build().

#define N_MAX   288 /* maximum number of codes in any set */

Definition at line 404 of file inflate.c.

Referenced by huft_build().

#define NEEDBITS (   glbl,
 
)
Value:
{ \
while(k<(n)) { \
int c=(*glbl->gz_input)(glbl->gz_private); \
if(c==GZ_EOF) \
return 1; \
b|=((ulg)c)<<k; \
k+=8; \
} \
}
#define ulg
Definition: inflate.c:29

Definition at line 353 of file inflate.c.

Referenced by inflate_block(), inflate_codes(), inflate_dynamic(), and inflate_stored().

#define NOMEMCPY

Definition at line 35 of file inflate.c.

#define PKZIP_BUG_WORKAROUND   /* PKZIP 1.93a problem--live with it */

Definition at line 234 of file inflate.c.

#define uch   u_char

Definition at line 27 of file inflate.c.

Referenced by huft_build(), inflate_codes(), and inflate_stored().

#define ulg   u_long

Definition at line 29 of file inflate.c.

Referenced by inflate_block(), inflate_codes(), inflate_dynamic(), and inflate_stored().

#define ush   u_short

Definition at line 28 of file inflate.c.

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int huft_build ( struct inflate ,
unsigned *  ,
unsigned  ,
unsigned  ,
const ush ,
const ush ,
struct huft **  ,
int *   
)
static

Referenced by inflate_dynamic(), and inflate_fixed().

Here is the caller graph for this function:

static int huft_build ( struct inflate glbl,
unsigned *  b,
unsigned  n,
unsigned  s,
const ush d,
const ush e,
struct huft **  t,
int *  m 
)
static

Definition at line 415 of file inflate.c.

References huft::b, BMAX, huft::e, huft_free(), malloc(), memzero, huft::n, N_MAX, huft::t, uch, and huft::v.

Here is the call graph for this function:

static int huft_free ( struct inflate ,
struct huft  
)
static

Referenced by huft_build(), inflate(), inflate_dynamic(), and inflate_fixed().

Here is the caller graph for this function:

static int huft_free ( struct inflate glbl,
struct huft t 
)
static

Definition at line 618 of file inflate.c.

References free(), huft::t, and huft::v.

Here is the call graph for this function:

int inflate ( struct inflate *  glbl)

Definition at line 1043 of file inflate.c.

References free(), huft_free(), malloc(), and xinflate().

Referenced by exec_gzip_imgact(), and link_elf_ctf_get().

Here is the call graph for this function:

Here is the caller graph for this function:

static int inflate_block ( struct inflate ,
int *   
)
static

Referenced by xinflate().

Here is the caller graph for this function:

static int inflate_block ( struct inflate glbl,
int *  e 
)
static

Definition at line 971 of file inflate.c.

References huft::b, DUMPBITS, inflate_dynamic(), inflate_fixed(), inflate_stored(), NEEDBITS, huft::t, and ulg.

Here is the call graph for this function:

static int inflate_codes ( struct inflate ,
struct huft ,
struct huft ,
int  ,
int   
)
static

Referenced by inflate_fixed().

Here is the caller graph for this function:

static int inflate_codes ( struct inflate glbl,
struct huft tl,
struct huft td,
int  bl,
int  bd 
)
static

Definition at line 640 of file inflate.c.

References huft::b, DUMPBITS, huft::e, FLUSH, mask, huft::n, NEEDBITS, huft::t, uch, ulg, and huft::v.

static int inflate_dynamic ( struct inflate glbl)
static

Definition at line 825 of file inflate.c.

References huft::b, border, cpdext, cpdist, cplens, cplext, dbits, DUMPBITS, FPRINTF, huft_build(), huft_free(), lbits, mask, huft::n, NEEDBITS, qflag, ulg, and huft::v.

Referenced by inflate_block().

Here is the call graph for this function:

Here is the caller graph for this function:

static int inflate_fixed ( struct inflate glbl)
static

Definition at line 783 of file inflate.c.

References cpdext, cpdist, cplens, cplext, huft_build(), huft_free(), and inflate_codes().

Referenced by inflate_block().

Here is the call graph for this function:

Here is the caller graph for this function:

static int inflate_stored ( struct inflate glbl)
static

Definition at line 736 of file inflate.c.

References huft::b, DUMPBITS, FLUSH, huft::n, NEEDBITS, uch, and ulg.

Referenced by inflate_block().

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_GZIP  ,
"gzip_trees"  ,
"Gzip trees"   
)
static
static int xinflate ( struct inflate glbl)
static

Definition at line 1010 of file inflate.c.

References huft::e, FLUSH, and inflate_block().

Referenced by inflate().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const unsigned border[]
static
Initial value:
= {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}

Definition at line 298 of file inflate.c.

Referenced by inflate_dynamic().

const ush cpdext[]
static
Initial value:
= {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13}

Definition at line 315 of file inflate.c.

Referenced by inflate_dynamic(), and inflate_fixed().

const ush cpdist[]
static
Initial value:
= {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577}

Definition at line 310 of file inflate.c.

Referenced by inflate_dynamic(), and inflate_fixed().

const ush cplens[]
static
Initial value:
= {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}

Definition at line 301 of file inflate.c.

Referenced by inflate_dynamic(), and inflate_fixed().

const ush cplext[]
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}

Definition at line 306 of file inflate.c.

Referenced by inflate_dynamic(), and inflate_fixed().

const int dbits = 6
static

Definition at line 398 of file inflate.c.

Referenced by inflate_dynamic().

const int lbits = 9
static

Definition at line 397 of file inflate.c.

Referenced by inflate_dynamic().

const ush mask[]
static
Initial value:
= {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
}

Definition at line 321 of file inflate.c.

Referenced by inflate_codes(), and inflate_dynamic().

const int qflag = 0
static

Definition at line 49 of file inflate.c.

Referenced by inflate_dynamic(), and kvprintf().