altEngine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Typedefs | Enumerations | Functions
deflate_tinfl.h File Reference
#include <stdlib.h>
#include <string.h>
Include dependency graph for deflate_tinfl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tinfl_huff_table
 
struct  tinfl_decompressor_tag
 

Macros

#define TINFL_HEADER_INCLUDED
 
#define MZ_MACRO_END   while (0)
 
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED   ((size_t)(-1))
 
#define TINFL_LZ_DICT_SIZE   32768
 
#define tinfl_init(r)   do { (r)->m_state = 0; } MZ_MACRO_END
 
#define tinfl_get_adler32(r)   (r)->m_check_adler32
 
#define TINFL_BITBUF_SIZE   (32)
 
#define MZ_MALLOC(x)   malloc(x)
 
#define MZ_FREE(x)   free(x)
 
#define MZ_REALLOC(p, x)   realloc(p, x)
 
#define MZ_MAX(a, b)   (((a)>(b))?(a):(b))
 
#define MZ_MIN(a, b)   (((a)<(b))?(a):(b))
 
#define MZ_CLEAR_OBJ(obj)   memset(&(obj), 0, sizeof(obj))
 
#define MZ_READ_LE16(p)   ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
 
#define MZ_READ_LE32(p)   ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
 
#define TINFL_MEMCPY(d, s, l)   memcpy(d, s, l)
 
#define TINFL_MEMSET(p, c, l)   memset(p, c, l)
 
#define TINFL_CR_BEGIN   switch(r->m_state) { case 0:
 
#define TINFL_CR_RETURN(state_index, result)   do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END
 
#define TINFL_CR_RETURN_FOREVER(state_index, result)   do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END
 
#define TINFL_CR_FINISH   }
 
#define TINFL_GET_BYTE(state_index, c)
 
#define TINFL_NEED_BITS(state_index, n)   do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n))
 
#define TINFL_SKIP_BITS(state_index, n)   do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END
 
#define TINFL_GET_BITS(state_index, b, n)   do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END
 
#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff)
 
#define TINFL_HUFF_DECODE(state_index, sym, pHuff)
 

Typedefs

typedef unsigned char mz_uint8
 
typedef signed short mz_int16
 
typedef unsigned short mz_uint16
 
typedef unsigned int mz_uint32
 
typedef unsigned int mz_uint
 
typedef unsigned long long mz_uint64
 
typedef int(* tinfl_put_buf_func_ptr )(const void *pBuf, int len, void *pUser)
 
typedef struct
tinfl_decompressor_tag 
tinfl_decompressor
 
typedef mz_uint32 tinfl_bit_buf_t
 

Enumerations

enum  { TINFL_FLAG_PARSE_ZLIB_HEADER = 1, TINFL_FLAG_HAS_MORE_INPUT = 2, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, TINFL_FLAG_COMPUTE_ADLER32 = 8 }
 
enum  tinfl_status {
  TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4, TINFL_STATUS_BAD_PARAM = -3, TINFL_STATUS_ADLER32_MISMATCH = -2, TINFL_STATUS_FAILED = -1,
  TINFL_STATUS_DONE = 0, TINFL_STATUS_NEEDS_MORE_INPUT = 1, TINFL_STATUS_HAS_MORE_OUTPUT = 2
}
 
enum  {
  TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19,
  TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS
}
 

Functions

void * tinfl_decompress_mem_to_heap (const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
 
size_t tinfl_decompress_mem_to_mem (void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags)
 
int tinfl_decompress_mem_to_callback (const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
 
tinfl_status tinfl_decompress (tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags)
 

Macro Definition Documentation

#define MZ_CLEAR_OBJ (   obj)    memset(&(obj), 0, sizeof(obj))
#define MZ_FREE (   x)    free(x)
#define MZ_MACRO_END   while (0)
#define MZ_MALLOC (   x)    malloc(x)
#define MZ_MAX (   a,
 
)    (((a)>(b))?(a):(b))
#define MZ_MIN (   a,
 
)    (((a)<(b))?(a):(b))
#define MZ_READ_LE16 (   p)    ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
#define MZ_READ_LE32 (   p)    ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
#define MZ_REALLOC (   p,
 
)    realloc(p, x)
#define TINFL_BITBUF_SIZE   (32)
#define TINFL_CR_BEGIN   switch(r->m_state) { case 0:
#define TINFL_CR_FINISH   }
#define TINFL_CR_RETURN (   state_index,
  result 
)    do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END
#define TINFL_CR_RETURN_FOREVER (   state_index,
  result 
)    do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED   ((size_t)(-1))
#define tinfl_get_adler32 (   r)    (r)->m_check_adler32
#define TINFL_GET_BITS (   state_index,
  b,
 
)    do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END
#define TINFL_GET_BYTE (   state_index,
 
)
Value:
do { \
while (pIn_buf_cur >= pIn_buf_end) { \
} c = *pIn_buf_cur++; } MZ_MACRO_END
#define TINFL_HEADER_INCLUDED
#define TINFL_HUFF_BITBUF_FILL (   state_index,
  pHuff 
)
Value:
do { \
temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \
if (temp >= 0) { \
code_len = temp >> 9; \
if ((code_len) && (num_bits >= code_len)) \
break; \
} else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \
code_len = TINFL_FAST_LOOKUP_BITS; \
do { \
temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
} while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \
} TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \
} while (num_bits < 15);
#define TINFL_HUFF_DECODE (   state_index,
  sym,
  pHuff 
)
Value:
do { \
int temp; mz_uint code_len, c; \
if (num_bits < 15) { \
if ((pIn_buf_end - pIn_buf_cur) < 2) { \
TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \
} else { \
bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; \
} \
} \
if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \
code_len = temp >> 9, temp &= 511; \
else { \
code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \
} sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END
#define tinfl_init (   r)    do { (r)->m_state = 0; } MZ_MACRO_END
#define TINFL_LZ_DICT_SIZE   32768
#define TINFL_MEMCPY (   d,
  s,
 
)    memcpy(d, s, l)
#define TINFL_MEMSET (   p,
  c,
 
)    memset(p, c, l)
#define TINFL_NEED_BITS (   state_index,
 
)    do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n))
#define TINFL_SKIP_BITS (   state_index,
 
)    do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END

Typedef Documentation

typedef signed short mz_int16
typedef unsigned int mz_uint
typedef unsigned short mz_uint16
typedef unsigned int mz_uint32
typedef unsigned long long mz_uint64
typedef unsigned char mz_uint8
typedef int(* tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser)

Enumeration Type Documentation

anonymous enum
Enumerator:
TINFL_FLAG_PARSE_ZLIB_HEADER 
TINFL_FLAG_HAS_MORE_INPUT 
TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF 
TINFL_FLAG_COMPUTE_ADLER32 
anonymous enum
Enumerator:
TINFL_MAX_HUFF_TABLES 
TINFL_MAX_HUFF_SYMBOLS_0 
TINFL_MAX_HUFF_SYMBOLS_1 
TINFL_MAX_HUFF_SYMBOLS_2 
TINFL_FAST_LOOKUP_BITS 
TINFL_FAST_LOOKUP_SIZE 
Enumerator:
TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS 
TINFL_STATUS_BAD_PARAM 
TINFL_STATUS_ADLER32_MISMATCH 
TINFL_STATUS_FAILED 
TINFL_STATUS_DONE 
TINFL_STATUS_NEEDS_MORE_INPUT 
TINFL_STATUS_HAS_MORE_OUTPUT 

Function Documentation

tinfl_status tinfl_decompress ( tinfl_decompressor r,
const mz_uint8 pIn_buf_next,
size_t *  pIn_buf_size,
mz_uint8 pOut_buf_start,
mz_uint8 pOut_buf_next,
size_t *  pOut_buf_size,
const mz_uint32  decomp_flags 
)

Here is the caller graph for this function:

int tinfl_decompress_mem_to_callback ( const void *  pIn_buf,
size_t *  pIn_buf_size,
tinfl_put_buf_func_ptr  pPut_buf_func,
void *  pPut_buf_user,
int  flags 
)

Here is the call graph for this function:

void * tinfl_decompress_mem_to_heap ( const void *  pSrc_buf,
size_t  src_buf_len,
size_t *  pOut_len,
int  flags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

size_t tinfl_decompress_mem_to_mem ( void *  pOut_buf,
size_t  out_buf_len,
const void *  pSrc_buf,
size_t  src_buf_len,
int  flags 
)

Here is the call graph for this function: