LLVM API Documentation

bzlib.c File Reference

#include "bzlib_private.h"

Include dependency graph for bzlib.c:

Go to the source code of this file.

Classes

struct  bzFile

Defines

#define ADD_CHAR_TO_BLOCK(zs, zchh0)
#define BZ_SETERR(eee)
#define SET_BINARY_MODE(file)

Functions

void BZ2_bz__AssertH__fail (int errcode)
static int bz_config_ok (void)
static void * default_bzalloc (void *opaque, Int32 items, Int32 size)
static void default_bzfree (void *opaque, void *addr)
static void prepare_new_block (EState *s)
static void init_RL (EState *s)
static Bool isempty_RL (EState *s)
int BZ_API() BZ2_bzCompressInit (bz_stream *strm, int blockSize100k, int verbosity, int workFactor)
static void add_pair_to_block (EState *s)
static void flush_RL (EState *s)
static Bool copy_input_until_stop (EState *s)
static Bool copy_output_until_stop (EState *s)
static Bool handle_compress (bz_stream *strm)
int BZ_API() BZ2_bzCompress (bz_stream *strm, int action)
int BZ_API() BZ2_bzCompressEnd (bz_stream *strm)
int BZ_API() BZ2_bzDecompressInit (bz_stream *strm, int verbosity, int small)
static void unRLE_obuf_to_output_FAST (DState *s)
__inline__ Int32 BZ2_indexIntoF (Int32 indx, Int32 *cftab)
static void unRLE_obuf_to_output_SMALL (DState *s)
int BZ_API() BZ2_bzDecompress (bz_stream *strm)
int BZ_API() BZ2_bzDecompressEnd (bz_stream *strm)
static Bool myfeof (FILE *f)
BZFILE *BZ_API() BZ2_bzWriteOpen (int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor)
void BZ_API() BZ2_bzWrite (int *bzerror, BZFILE *b, void *buf, int len)
void BZ_API() BZ2_bzWriteClose (int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in, unsigned int *nbytes_out)
void BZ_API() BZ2_bzWriteClose64 (int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in_lo32, unsigned int *nbytes_in_hi32, unsigned int *nbytes_out_lo32, unsigned int *nbytes_out_hi32)
BZFILE *BZ_API() BZ2_bzReadOpen (int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused)
void BZ_API() BZ2_bzReadClose (int *bzerror, BZFILE *b)
int BZ_API() BZ2_bzRead (int *bzerror, BZFILE *b, void *buf, int len)
void BZ_API() BZ2_bzReadGetUnused (int *bzerror, BZFILE *b, void **unused, int *nUnused)
int BZ_API() BZ2_bzBuffToBuffCompress (char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int blockSize100k, int verbosity, int workFactor)
int BZ_API() BZ2_bzBuffToBuffDecompress (char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int small, int verbosity)
const char *BZ_API() BZ2_bzlibVersion (void)
static BZFILEbzopen_or_bzdopen (const char *path, int fd, const char *mode, int open_mode)
BZFILE *BZ_API() BZ2_bzopen (const char *path, const char *mode)
BZFILE *BZ_API() BZ2_bzdopen (int fd, const char *mode)
int BZ_API() BZ2_bzread (BZFILE *b, void *buf, int len)
int BZ_API() BZ2_bzwrite (BZFILE *b, void *buf, int len)
int BZ_API() BZ2_bzflush (BZFILE *b)
void BZ_API() BZ2_bzclose (BZFILE *b)
const char *BZ_API() BZ2_bzerror (BZFILE *b, int *errnum)

Variables

static const char * bzerrorstrings []


Define Documentation

#define ADD_CHAR_TO_BLOCK ( zs,
zchh0   ) 

Value:

{                                                 \
   UInt32 zchh = (UInt32)(zchh0);                 \
   /*-- fast track the common case --*/           \
   if (zchh != zs->state_in_ch &&                 \
       zs->state_in_len == 1) {                   \
      UChar ch = (UChar)(zs->state_in_ch);        \
      BZ_UPDATE_CRC( zs->blockCRC, ch );          \
      zs->inUse[zs->state_in_ch] = True;          \
      zs->block[zs->nblock] = (UChar)ch;          \
      zs->nblock++;                               \
      zs->state_in_ch = zchh;                     \
   }                                              \
   else                                           \
   /*-- general, uncommon cases --*/              \
   if (zchh != zs->state_in_ch ||                 \
      zs->state_in_len == 255) {                  \
      if (zs->state_in_ch < 256)                  \
         add_pair_to_block ( zs );                \
      zs->state_in_ch = zchh;                     \
      zs->state_in_len = 1;                       \
   } else {                                       \
      zs->state_in_len++;                         \
   }                                              \
}

Definition at line 309 of file bzlib.c.

Referenced by copy_input_until_stop().

#define BZ_SETERR ( eee   ) 

Value:

{                                         \
   if (bzerror != NULL) *bzerror = eee;   \
   if (bzf != NULL) bzf->lastErr = eee;   \
}

Definition at line 911 of file bzlib.c.

Referenced by BZ2_bzRead(), BZ2_bzReadClose(), BZ2_bzReadGetUnused(), BZ2_bzReadOpen(), BZ2_bzWrite(), BZ2_bzWriteClose64(), and BZ2_bzWriteOpen().

#define SET_BINARY_MODE ( file   ) 

Definition at line 1406 of file bzlib.c.

Referenced by bzopen_or_bzdopen().


Function Documentation

static void add_pair_to_block ( EState s  )  [static]

Definition at line 265 of file bzlib.c.

References EState::block, EState::blockCRC, BZ_UPDATE_CRC, EState::inUse, EState::nblock, EState::state_in_ch, EState::state_in_len, and True.

Referenced by flush_RL().

void BZ2_bz__AssertH__fail ( int  errcode  ) 

Definition at line 86 of file bzlib.c.

References BZ2_bzlibVersion().

int BZ_API() BZ2_bzBuffToBuffCompress ( char *  dest,
unsigned int *  destLen,
char *  source,
unsigned int  sourceLen,
int  blockSize100k,
int  verbosity,
int  workFactor 
)

Definition at line 1273 of file bzlib.c.

References bz_stream::avail_in, bz_stream::avail_out, BZ2_bzCompress(), BZ2_bzCompressEnd(), BZ2_bzCompressInit(), BZ_FINISH, BZ_FINISH_OK, BZ_OK, BZ_OUTBUFF_FULL, BZ_PARAM_ERROR, BZ_STREAM_END, bz_stream::bzalloc, bz_stream::bzfree, bz_stream::next_in, bz_stream::next_out, and bz_stream::opaque.

int BZ_API() BZ2_bzBuffToBuffDecompress ( char *  dest,
unsigned int *  destLen,
char *  source,
unsigned int  sourceLen,
int  small,
int  verbosity 
)

Definition at line 1325 of file bzlib.c.

References bz_stream::avail_in, bz_stream::avail_out, BZ2_bzDecompress(), BZ2_bzDecompressEnd(), BZ2_bzDecompressInit(), BZ_OK, BZ_OUTBUFF_FULL, BZ_PARAM_ERROR, BZ_STREAM_END, BZ_UNEXPECTED_EOF, bz_stream::bzalloc, bz_stream::bzfree, bz_stream::next_in, bz_stream::next_out, and bz_stream::opaque.

void BZ_API() BZ2_bzclose ( BZFILE b  ) 

Definition at line 1540 of file bzlib.c.

References BZ2_bzReadClose(), BZ2_bzWriteClose(), and BZ_OK.

int BZ_API() BZ2_bzCompress ( bz_stream strm,
int  action 
)

Definition at line 456 of file bzlib.c.

References action, bz_stream::avail_in, EState::avail_in_expect, BZ_FINISH, BZ_FINISH_OK, BZ_FLUSH, BZ_FLUSH_OK, BZ_M_FINISHING, BZ_M_FLUSHING, BZ_M_IDLE, BZ_M_RUNNING, BZ_OK, BZ_PARAM_ERROR, BZ_RUN, BZ_RUN_OK, BZ_SEQUENCE_ERROR, BZ_STREAM_END, handle_compress(), isempty_RL(), EState::mode, EState::numZ, bz_stream::state, EState::state_out_pos, and EState::strm.

Referenced by BZ2_bzBuffToBuffCompress(), BZ2_bzWrite(), BZ2_bzWriteClose64(), and llvm::Compressor::compress().

int BZ_API() BZ2_bzCompressEnd ( bz_stream strm  ) 

Definition at line 517 of file bzlib.c.

References BZ_OK, BZ_PARAM_ERROR, BZFREE, and bz_stream::state.

Referenced by BZ2_bzBuffToBuffCompress(), BZ2_bzWriteClose64(), and llvm::Compressor::compress().

int BZ_API() BZ2_bzCompressInit ( bz_stream strm,
int  blockSize100k,
int  verbosity,
int  workFactor 
)

Definition at line 198 of file bzlib.c.

References EState::arr1, EState::arr2, EState::block, EState::blockNo, EState::blockSize100k, BZ_CONFIG_ERROR, bz_config_ok(), BZ_M_RUNNING, BZ_MEM_ERROR, BZ_N_OVERSHOOT, BZ_OK, BZ_PARAM_ERROR, BZ_S_INPUT, bz_stream::bzalloc, BZALLOC, bz_stream::bzfree, BZFREE, EState::combinedCRC, default_bzalloc(), default_bzfree(), EState::ftab, init_RL(), EState::mode, EState::mtfv, EState::nblockMAX, prepare_new_block(), EState::ptr, EState::state, bz_stream::state, EState::strm, bz_stream::total_in_hi32, bz_stream::total_in_lo32, bz_stream::total_out_hi32, bz_stream::total_out_lo32, EState::verbosity, EState::workFactor, and EState::zbits.

Referenced by BZ2_bzBuffToBuffCompress(), BZ2_bzWriteOpen(), and llvm::Compressor::compress().

int BZ_API() BZ2_bzDecompress ( bz_stream strm  ) 

Definition at line 835 of file bzlib.c.

References AssertH, BZ2_decompress(), BZ_DATA_ERROR, BZ_FINALISE_CRC, BZ_OK, BZ_PARAM_ERROR, BZ_SEQUENCE_ERROR, BZ_STREAM_END, BZ_X_BLKHDR_1, BZ_X_IDLE, BZ_X_MAGIC_1, BZ_X_OUTPUT, bz_stream::state, True, unRLE_obuf_to_output_FAST(), unRLE_obuf_to_output_SMALL(), VPrintf0, and VPrintf2.

Referenced by BZ2_bzBuffToBuffDecompress(), BZ2_bzRead(), and llvm::Compressor::decompress().

int BZ_API() BZ2_bzDecompressEnd ( bz_stream strm  ) 

Definition at line 887 of file bzlib.c.

References BZ_OK, BZ_PARAM_ERROR, BZFREE, and bz_stream::state.

Referenced by BZ2_bzBuffToBuffDecompress(), BZ2_bzReadClose(), and llvm::Compressor::decompress().

int BZ_API() BZ2_bzDecompressInit ( bz_stream strm,
int  verbosity,
int  small 
)

Definition at line 542 of file bzlib.c.

References BZ_CONFIG_ERROR, bz_config_ok(), BZ_MEM_ERROR, BZ_OK, BZ_PARAM_ERROR, BZ_X_MAGIC_1, bz_stream::bzalloc, BZALLOC, bz_stream::bzfree, default_bzalloc(), default_bzfree(), bz_stream::state, bz_stream::total_in_hi32, bz_stream::total_in_lo32, bz_stream::total_out_hi32, and bz_stream::total_out_lo32.

Referenced by BZ2_bzBuffToBuffDecompress(), BZ2_bzReadOpen(), and llvm::Compressor::decompress().

BZFILE* BZ_API() BZ2_bzdopen ( int  fd,
const char *  mode 
)

Definition at line 1496 of file bzlib.c.

References bzopen_or_bzdopen().

const char* BZ_API() BZ2_bzerror ( BZFILE b,
int *  errnum 
)

Definition at line 1584 of file bzlib.c.

int BZ_API() BZ2_bzflush ( BZFILE b  ) 

Definition at line 1532 of file bzlib.c.

const char* BZ_API() BZ2_bzlibVersion ( void   ) 

Definition at line 1392 of file bzlib.c.

References BZ_VERSION.

Referenced by BZ2_bz__AssertH__fail().

BZFILE* BZ_API() BZ2_bzopen ( const char *  path,
const char *  mode 
)

Definition at line 1487 of file bzlib.c.

References bzopen_or_bzdopen().

int BZ_API() BZ2_bzread ( BZFILE b,
void *  buf,
int  len 
)

Definition at line 1504 of file bzlib.c.

References BZ2_bzRead(), BZ_OK, and BZ_STREAM_END.

int BZ_API() BZ2_bzRead ( int *  bzerror,
BZFILE b,
void *  buf,
int  len 
)

Definition at line 1187 of file bzlib.c.

References bz_stream::avail_in, bz_stream::avail_out, bzFile::buf, bzFile::bufN, BZ2_bzDecompress(), BZ_IO_ERROR, BZ_MAX_UNUSED, BZ_OK, BZ_PARAM_ERROR, BZ_SEQUENCE_ERROR, BZ_SETERR, BZ_STREAM_END, BZ_UNEXPECTED_EOF, bzFile::handle, myfeof(), bz_stream::next_in, bz_stream::next_out, bzFile::strm, True, and bzFile::writing.

Referenced by BZ2_bzread().

void BZ_API() BZ2_bzReadClose ( int *  bzerror,
BZFILE b 
)

Definition at line 1168 of file bzlib.c.

References BZ2_bzDecompressEnd(), BZ_OK, BZ_SEQUENCE_ERROR, and BZ_SETERR.

Referenced by BZ2_bzclose().

void BZ_API() BZ2_bzReadGetUnused ( int *  bzerror,
BZFILE b,
void **  unused,
int *  nUnused 
)

Definition at line 1247 of file bzlib.c.

References BZ_OK, BZ_PARAM_ERROR, BZ_SEQUENCE_ERROR, BZ_SETERR, and BZ_STREAM_END.

BZFILE* BZ_API() BZ2_bzReadOpen ( int *  bzerror,
FILE *  f,
int  verbosity,
int  small,
void *  unused,
int  nUnused 
)

Definition at line 1113 of file bzlib.c.

References BZ2_bzDecompressInit(), BZ_IO_ERROR, BZ_MAX_UNUSED, BZ_MEM_ERROR, BZ_OK, BZ_PARAM_ERROR, BZ_SETERR, False, and True.

Referenced by bzopen_or_bzdopen().

int BZ_API() BZ2_bzwrite ( BZFILE b,
void *  buf,
int  len 
)

Definition at line 1518 of file bzlib.c.

References BZ2_bzWrite(), and BZ_OK.

void BZ_API() BZ2_bzWrite ( int *  bzerror,
BZFILE b,
void *  buf,
int  len 
)

Definition at line 990 of file bzlib.c.

References bz_stream::avail_in, bz_stream::avail_out, bzFile::buf, BZ2_bzCompress(), BZ_IO_ERROR, BZ_MAX_UNUSED, BZ_OK, BZ_PARAM_ERROR, BZ_RUN, BZ_RUN_OK, BZ_SEQUENCE_ERROR, BZ_SETERR, bzFile::handle, bz_stream::next_in, bz_stream::next_out, bzFile::strm, True, and bzFile::writing.

Referenced by BZ2_bzwrite().

void BZ_API() BZ2_bzWriteClose ( int *  bzerror,
BZFILE b,
int  abandon,
unsigned int *  nbytes_in,
unsigned int *  nbytes_out 
)

Definition at line 1035 of file bzlib.c.

References BZ2_bzWriteClose64().

Referenced by BZ2_bzclose().

void BZ_API() BZ2_bzWriteClose64 ( int *  bzerror,
BZFILE b,
int  abandon,
unsigned int *  nbytes_in_lo32,
unsigned int *  nbytes_in_hi32,
unsigned int *  nbytes_out_lo32,
unsigned int *  nbytes_out_hi32 
)

Definition at line 1047 of file bzlib.c.

References bz_stream::avail_out, bzFile::buf, BZ2_bzCompress(), BZ2_bzCompressEnd(), BZ_FINISH, BZ_FINISH_OK, BZ_IO_ERROR, BZ_MAX_UNUSED, BZ_OK, BZ_SEQUENCE_ERROR, BZ_SETERR, BZ_STREAM_END, bzFile::handle, bzFile::lastErr, bz_stream::next_out, bzFile::strm, bz_stream::total_in_hi32, bz_stream::total_in_lo32, bz_stream::total_out_hi32, bz_stream::total_out_lo32, True, and bzFile::writing.

Referenced by BZ2_bzWriteClose().

BZFILE* BZ_API() BZ2_bzWriteOpen ( int *  bzerror,
FILE *  f,
int  blockSize100k,
int  verbosity,
int  workFactor 
)

Definition at line 942 of file bzlib.c.

References bz_stream::avail_in, bzFile::bufN, BZ2_bzCompressInit(), BZ_IO_ERROR, BZ_MEM_ERROR, BZ_OK, BZ_PARAM_ERROR, BZ_SETERR, bz_stream::bzalloc, bz_stream::bzfree, False, bzFile::handle, bzFile::initialisedOk, bz_stream::opaque, bzFile::strm, True, and bzFile::writing.

Referenced by bzopen_or_bzdopen().

__inline__ Int32 BZ2_indexIntoF ( Int32  indx,
Int32 cftab 
)

Definition at line 724 of file bzlib.c.

static int bz_config_ok ( void   )  [static]

Definition at line 140 of file bzlib.c.

Referenced by BZ2_bzCompressInit(), and BZ2_bzDecompressInit().

static BZFILE* bzopen_or_bzdopen ( const char *  path,
int  fd,
const char *  mode,
int  open_mode 
) [static]

Definition at line 1410 of file bzlib.c.

References BZ2_bzReadOpen(), BZ2_bzWriteOpen(), BZ_HDR_0, BZ_MAX_UNUSED, and SET_BINARY_MODE.

Referenced by BZ2_bzdopen(), and BZ2_bzopen().

static Bool copy_input_until_stop ( EState s  )  [static]

Definition at line 338 of file bzlib.c.

References ADD_CHAR_TO_BLOCK, bz_stream::avail_in, EState::avail_in_expect, BZ_M_RUNNING, False, EState::mode, EState::nblock, EState::nblockMAX, bz_stream::next_in, EState::strm, bz_stream::total_in_hi32, bz_stream::total_in_lo32, and True.

Referenced by handle_compress().

static Bool copy_output_until_stop ( EState s  )  [static]

Definition at line 383 of file bzlib.c.

References bz_stream::avail_out, False, bz_stream::next_out, EState::numZ, EState::state_out_pos, EState::strm, bz_stream::total_out_hi32, bz_stream::total_out_lo32, True, and EState::zbits.

Referenced by handle_compress().

static void* default_bzalloc ( void *  opaque,
Int32  items,
Int32  size 
) [static]

Definition at line 151 of file bzlib.c.

Referenced by BZ2_bzCompressInit(), and BZ2_bzDecompressInit().

static void default_bzfree ( void *  opaque,
void *  addr 
) [static]

Definition at line 158 of file bzlib.c.

Referenced by BZ2_bzCompressInit(), and BZ2_bzDecompressInit().

static void flush_RL ( EState s  )  [static]

Definition at line 301 of file bzlib.c.

References add_pair_to_block(), init_RL(), and EState::state_in_ch.

Referenced by handle_compress().

static Bool handle_compress ( bz_stream strm  )  [static]

Definition at line 410 of file bzlib.c.

References bz_stream::avail_in, EState::avail_in_expect, BZ2_compressBlock(), BZ_M_FINISHING, BZ_M_FLUSHING, BZ_M_RUNNING, BZ_S_INPUT, BZ_S_OUTPUT, copy_input_until_stop(), copy_output_until_stop(), False, flush_RL(), isempty_RL(), EState::mode, EState::nblock, EState::nblockMAX, EState::numZ, prepare_new_block(), EState::state, bz_stream::state, EState::state_out_pos, EState::strm, and True.

Referenced by BZ2_bzCompress().

static void init_RL ( EState s  )  [static]

Definition at line 180 of file bzlib.c.

References EState::state_in_ch, and EState::state_in_len.

Referenced by BZ2_bzCompressInit(), and flush_RL().

static Bool isempty_RL ( EState s  )  [static]

Definition at line 188 of file bzlib.c.

References False, EState::state_in_ch, EState::state_in_len, and True.

Referenced by BZ2_bzCompress(), and handle_compress().

static Bool myfeof ( FILE *  f  )  [static]

Definition at line 931 of file bzlib.c.

References c, False, and True.

Referenced by BZ2_bzRead().

static void prepare_new_block ( EState s  )  [static]

Definition at line 166 of file bzlib.c.

References EState::blockCRC, EState::blockNo, BZ_INITIALISE_CRC, False, EState::inUse, EState::nblock, EState::numZ, and EState::state_out_pos.

Referenced by BZ2_bzCompressInit(), and handle_compress().

static void unRLE_obuf_to_output_FAST ( DState s  )  [static]

Definition at line 582 of file bzlib.c.

References bz_stream::avail_out, DState::blockRandomised, BZ_GET_FAST, BZ_GET_FAST_C, BZ_RAND_MASK, BZ_RAND_UPD_MASK, BZ_UPDATE_CRC, DState::calculatedBlockCRC, DState::k0, DState::nblock_used, bz_stream::next_out, DState::save_nblock, DState::state_out_ch, DState::state_out_len, DState::strm, bz_stream::total_out_hi32, bz_stream::total_out_lo32, DState::tPos, True, and DState::tt.

Referenced by BZ2_bzDecompress().

static void unRLE_obuf_to_output_SMALL ( DState s  )  [static]

Definition at line 740 of file bzlib.c.

References bz_stream::avail_out, DState::blockRandomised, BZ_GET_SMALL, BZ_RAND_MASK, BZ_RAND_UPD_MASK, BZ_UPDATE_CRC, DState::calculatedBlockCRC, DState::k0, DState::nblock_used, bz_stream::next_out, DState::save_nblock, DState::state_out_ch, DState::state_out_len, DState::strm, bz_stream::total_out_hi32, bz_stream::total_out_lo32, and True.

Referenced by BZ2_bzDecompress().


Variable Documentation

const char* bzerrorstrings[] [static]

Initial value:

 {
       "OK"
      ,"SEQUENCE_ERROR"
      ,"PARAM_ERROR"
      ,"MEM_ERROR"
      ,"DATA_ERROR"
      ,"DATA_ERROR_MAGIC"
      ,"IO_ERROR"
      ,"UNEXPECTED_EOF"
      ,"OUTBUFF_FULL"
      ,"CONFIG_ERROR"
      ,"???"   
      ,"???"   
      ,"???"   
      ,"???"   
      ,"???"   
      ,"???"   
}

Definition at line 1564 of file bzlib.c.