Ruby: ext/zlib/zlib-1.2.13/inflate.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
inflate.c File Reference
`#include "zutil.h"`
`#include "inftrees.h"`
`#include "inflate.h"`
`#include "inffast.h"`
`#include "inffixed.h"`

Go to the source code of this file.

## Macros
#define | UPDATE_CHECK(check, buf, len) (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
#define | CRC2(check, word)
#define | CRC4(check, word)
#define | LOAD()
#define | RESTORE()
#define | INITBITS()
#define | PULLBYTE()
#define | NEEDBITS(n)
#define | BITS(n) ((unsigned)hold & ((1U << (n)) - 1))
#define | DROPBITS(n)
#define | BYTEBITS()

## Functions
int inflateStateCheck | OF ((z_streamp strm))
void fixedtables | OF ((struct inflate_state FAR *state))
int updatewindow | OF ((z_streamp strm, const unsigned char FAR *end, unsigned copy))
unsigned syncsearch | OF ((unsigned FAR *have, const unsigned char FAR *buf, unsigned len))
int | inflateStateCheck (z_streamp strm)
int ZEXPORT | inflateResetKeep (z_streamp strm)
int ZEXPORT | inflateReset (z_streamp strm)
int ZEXPORT | inflateReset2 (z_streamp strm, int windowBits)
int ZEXPORT | inflateInit2_ (z_streamp strm, int windowBits, const char *version, int stream_size)
int ZEXPORT | inflateInit_ (z_streamp strm, const char *version, int stream_size)
int ZEXPORT | inflatePrime (z_streamp strm, int bits, int value)
void | fixedtables (struct inflate_state FAR *state)
int | updatewindow (z_streamp strm, const Bytef *end, unsigned copy)
int ZEXPORT | inflate (z_streamp strm, int flush)
int ZEXPORT | inflateEnd (z_streamp strm)
int ZEXPORT | inflateGetDictionary (z_streamp strm, Bytef *dictionary, uInt *dictLength)
int ZEXPORT | inflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
int ZEXPORT | inflateGetHeader (z_streamp strm, gz_headerp head)
unsigned | syncsearch (unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
int ZEXPORT | inflateSync (z_streamp strm)
int ZEXPORT | inflateSyncPoint (z_streamp strm)
int ZEXPORT | inflateCopy (z_streamp dest, z_streamp source)
int ZEXPORT | inflateUndermine (z_streamp strm, int subvert)
int ZEXPORT | inflateValidate (z_streamp strm, int check)
long ZEXPORT | inflateMark (z_streamp strm)
unsigned long ZEXPORT | inflateCodesUsed (z_streamp strm)

## Macro Definition Documentation

## ◆ BITS

#define BITS | ( |  | n | ) | ((unsigned)hold & ((1U << (n)) - 1))

Definition at line 526 of file inflate.c.

## ◆ BYTEBITS

#define BYTEBITS | ( |  | ) |

Value:
do { \
hold >>= bits & 7; \
bits -= bits & 7; \
} while (0)
bits
int bits(struct state *s, int need)
Definition: blast.c:72

Definition at line 537 of file inflate.c.

## ◆ CRC2

#define CRC2 | ( |  | check,
|  |  | word
| ) |  |

Value:
do { \
hbuf[0] = (unsigned char)(word); \
hbuf[1] = (unsigned char)((word) >> 8); \
check = crc32(check, hbuf, 2); \
} while (0)
crc32
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
Definition: crc32.c:1072

Definition at line 461 of file inflate.c.

## ◆ CRC4

#define CRC4 | ( |  | check,
|  |  | word
| ) |  |

Value:
do { \
hbuf[0] = (unsigned char)(word); \
hbuf[1] = (unsigned char)((word) >> 8); \
hbuf[2] = (unsigned char)((word) >> 16); \
hbuf[3] = (unsigned char)((word) >> 24); \
check = crc32(check, hbuf, 4); \
} while (0)

Definition at line 468 of file inflate.c.

## ◆ DROPBITS

#define DROPBITS | ( |  | n | ) |

Value:
do { \
hold >>= (n); \
bits -= (unsigned)(n); \
} while (0)

Definition at line 530 of file inflate.c.

## ◆ INITBITS

#define INITBITS | ( |  | ) |

Value:
do { \
hold = 0; \
bits = 0; \
} while (0)

Definition at line 501 of file inflate.c.

## ◆ LOAD

#define LOAD | ( |  | ) |

Value:
do { \
put = strm->next_out; \
left = strm->avail_out; \
next = strm->next_in; \
have = strm->avail_in; \
hold = state->hold; \
bits = state->bits; \
} while (0)
state
Definition: blast.c:41

Definition at line 479 of file inflate.c.

## ◆ NEEDBITS

#define NEEDBITS | ( |  | n | ) |

Value:
do { \
while (bits < (unsigned)(n)) \
PULLBYTE(); \
} while (0)

Definition at line 519 of file inflate.c.

## ◆ PULLBYTE

#define PULLBYTE | ( |  | ) |

Value:
do { \
if (have == 0) goto inf_leave; \
have--; \
hold += (unsigned long)(*next++) << bits; \
bits += 8; \
} while (0)

Definition at line 509 of file inflate.c.

## ◆ RESTORE

#define RESTORE | ( |  | ) |

Value:
do { \
strm->next_out = put; \
strm->avail_out = left; \
strm->next_in = next; \
strm->avail_in = have; \
state->hold = hold; \
state->bits = bits; \
} while (0)

Definition at line 490 of file inflate.c.

## ◆ UPDATE_CHECK

#define UPDATE_CHECK | ( |  | check,
|  |  | buf,
|  |  | len
| ) |  | (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))

Definition at line 453 of file inflate.c.

## Function Documentation

## ◆ fixedtables()

void fixedtables | ( | struct inflate_state FAR * | state | ) |

Definition at line 281 of file inflate.c.

References bits(), DISTS, fixed(), inflate_table(), LENS, inflate_state::next, and sym.

Referenced by inflate().

## ◆ inflate()

int ZEXPORT inflate | ( | z_streamp | strm,
|  | int | flush
| ) |  |

Definition at line 625 of file inflate.c.

References adler32(), BAD, BITS, bits(), code::bits, BYTEBITS, CHECK, CODELENS, CODES, COMMENT, COPY, COPY_, CRC2, crc32(), CRC4, DICT, DICTID, DIST, DISTEXT, DISTS, DONE, DROPBITS, EXLEN, EXTRA, FAR, fixedtables(), FLAGS, GUNZIP, inflate_state::have, HCRC, HEAD, inflate_state::hold, if(), in(), inflate_fast(), inflate_table(), inflateStateCheck(), INITBITS, int(), L, last, len, LEN, LEN_, LENEXT, LENGTH, LENLENS, LENS, LIT, LOAD, MATCH, MEM, NAME, NEEDBITS, state::next, inflate_state::next, code::op, OS, out, PULLBYTE, RESTORE, STORED, inflate_state::strm, SYNC, TABLE, TIME, Trace, Tracev, Tracevv, TYPE, TYPEDO, UPDATE_CHECK, updatewindow(), code::val, Z_BLOCK, Z_BUF_ERROR, z_const, Z_DATA_ERROR, Z_DEFLATED, Z_FINISH, Z_MEM_ERROR, Z_NEED_DICT, Z_NULL, Z_OK, Z_STREAM_END, Z_STREAM_ERROR, Z_TREES, zmemcpy, and ZSWAP32.

Referenced by deflate_index_build(), deflate_index_extract(), gz_decomp(), gzcopy(), gzip_normalize(), gzscan(), inf(), main(), recompress(), uncompress2(), and unzReadCurrentFile().

## ◆ inflateCodesUsed()

unsigned long ZEXPORT inflateCodesUsed | ( | z_streamp | strm | ) |

Definition at line 1588 of file inflate.c.

References FAR, inflateStateCheck(), state::next, and inflate_state::strm.

## ◆ inflateCopy()

int ZEXPORT inflateCopy | ( | z_streamp | dest,
|  | z_streamp | source
| ) |  |

Definition at line 1495 of file inflate.c.

References inflate_state::codes, inflate_state::distcode, ENOUGH, FAR, inflateStateCheck(), inflate_state::lencode, state::next, inflate_state::next, inflate_state::strm, inflate_state::window, inflate_state::wsize, Z_MEM_ERROR, Z_NULL, Z_OK, Z_STREAM_ERROR, ZALLOC, ZFREE, and zmemcpy.

## ◆ inflateEnd()

int ZEXPORT inflateEnd | ( | z_streamp | strm | ) |

Definition at line 1304 of file inflate.c.

References FAR, if(), inflateStateCheck(), inflate_state::strm, Tracev, Z_NULL, Z_OK, Z_STREAM_ERROR, and ZFREE.

Referenced by deflate_index_build(), deflate_index_extract(), gzclose_r(), gzcopy(), gzip_normalize(), gzscan(), inf(), main(), uncompress2(), and unzCloseCurrentFile().

## ◆ inflateGetDictionary()

int ZEXPORT inflateGetDictionary | ( | z_streamp | strm,
|  | Bytef * | dictionary,
|  | uInt * | dictLength
| ) |  |

Definition at line 1318 of file inflate.c.

References FAR, if(), inflateStateCheck(), inflate_state::strm, Z_NULL, Z_OK, Z_STREAM_ERROR, and zmemcpy.

## ◆ inflateGetHeader()

int ZEXPORT inflateGetHeader | ( | z_streamp | strm,
|  | gz_headerp | head
| ) |  |

Definition at line 1376 of file inflate.c.

References FAR, inflate_state::head, if(), inflateStateCheck(), inflate_state::strm, Z_OK, and Z_STREAM_ERROR.

## ◆ inflateInit2_()

int ZEXPORT inflateInit2_ | ( | z_streamp | strm,
|  | int | windowBits,
|  | const char * | version,
|  | int | stream_size
| ) |  |

Definition at line 198 of file inflate.c.

References FAR, HEAD, inflateReset2(), internal_state::strm, inflate_state::strm, Tracev, Z_MEM_ERROR, Z_NULL, Z_OK, Z_STREAM_ERROR, Z_VERSION_ERROR, ZALLOC, zcalloc(), zcfree(), ZFREE, and ZLIB_VERSION.

Referenced by inflateInit_().

## ◆ inflateInit_()

int ZEXPORT inflateInit_ | ( | z_streamp | strm,
|  | const char * | version,
|  | int | stream_size
| ) |  |

Definition at line 242 of file inflate.c.

References DEF_WBITS, inflateInit2_(), and internal_state::strm.

## ◆ inflateMark()

long ZEXPORT inflateMark | ( | z_streamp | strm | ) |

Definition at line 1575 of file inflate.c.

References COPY, FAR, inflateStateCheck(), long(), MATCH, and inflate_state::strm.

## ◆ inflatePrime()

int ZEXPORT inflatePrime | ( | z_streamp | strm,
|  | int | bits,
|  | int | value
| ) |  |

Definition at line 250 of file inflate.c.

References bits(), FAR, if(), inflateStateCheck(), inflate_state::strm, Z_OK, and Z_STREAM_ERROR.

Referenced by deflate_index_extract().

## ◆ inflateReset()

int ZEXPORT inflateReset | ( | z_streamp | strm | ) |

Definition at line 145 of file inflate.c.

References FAR, inflateResetKeep(), inflateStateCheck(), inflate_state::strm, and Z_STREAM_ERROR.

Referenced by deflate_index_build(), gz_look(), gzip_normalize(), inflateReset2(), inflateSync(), and main().

## ◆ inflateReset2()

int ZEXPORT inflateReset2 | ( | z_streamp | strm,
|  | int | windowBits
| ) |  |

Definition at line 158 of file inflate.c.

References FAR, if(), inflateReset(), inflateStateCheck(), inflate_state::strm, inflate_state::wrap, Z_NULL, Z_STREAM_ERROR, and ZFREE.

Referenced by deflate_index_extract(), and inflateInit2_().

## ◆ inflateResetKeep()

int ZEXPORT inflateResetKeep | ( | z_streamp | strm | ) |

Definition at line 119 of file inflate.c.

References FAR, HEAD, if(), inflateStateCheck(), state::next, inflate_state::strm, Tracev, Z_NULL, Z_OK, and Z_STREAM_ERROR.

Referenced by inflateReset().

## ◆ inflateSetDictionary()

int ZEXPORT inflateSetDictionary | ( | z_streamp | strm,
|  | const Bytef * | dictionary,
|  | uInt | dictLength
| ) |  |

Definition at line 1341 of file inflate.c.

References adler32(), DICT, FAR, if(), inflateStateCheck(), L, MEM, inflate_state::strm, Tracev, updatewindow(), Z_DATA_ERROR, Z_MEM_ERROR, Z_NULL, Z_OK, and Z_STREAM_ERROR.

Referenced by deflate_index_extract().

## ◆ inflateStateCheck()

int inflateStateCheck | ( | z_streamp | strm | ) |

Definition at line 105 of file inflate.c.

References FAR, HEAD, if(), inflate_state::strm, SYNC, and Z_NULL.

Referenced by inflate(), inflateCodesUsed(), inflateCopy(), inflateEnd(), inflateGetDictionary(), inflateGetHeader(), inflateMark(), inflatePrime(), inflateReset(), inflateReset2(), inflateResetKeep(), inflateSetDictionary(), inflateSync(), inflateSyncPoint(), inflateUndermine(), and inflateValidate().

## ◆ inflateSync()

int ZEXPORT inflateSync | ( | z_streamp | strm | ) |

Definition at line 1427 of file inflate.c.

References FAR, inflate_state::flags, if(), in(), inflateReset(), inflateStateCheck(), len, out, inflate_state::strm, SYNC, syncsearch(), TYPE, Z_BUF_ERROR, Z_DATA_ERROR, Z_OK, and Z_STREAM_ERROR.

## ◆ inflateSyncPoint()

int ZEXPORT inflateSyncPoint | ( | z_streamp | strm | ) |

Definition at line 1485 of file inflate.c.

References FAR, inflateStateCheck(), STORED, inflate_state::strm, and Z_STREAM_ERROR.

## ◆ inflateUndermine()

int ZEXPORT inflateUndermine | ( | z_streamp | strm,
|  | int | subvert
| ) |  |

Definition at line 1542 of file inflate.c.

References FAR, inflateStateCheck(), inflate_state::strm, Z_DATA_ERROR, Z_OK, and Z_STREAM_ERROR.

## ◆ inflateValidate()

int ZEXPORT inflateValidate | ( | z_streamp | strm,
|  | int | check
| ) |  |

Definition at line 1560 of file inflate.c.

References inflate_state::check, FAR, if(), inflateStateCheck(), inflate_state::strm, Z_OK, and Z_STREAM_ERROR.

## ◆ OF() [1/4]

void fixedtables OF | ( | (struct inflate_state FAR *state) |  | ) |

## ◆ OF() [2/4]

unsigned syncsearch OF | ( | (unsigned FAR *have, const unsigned char FAR *buf, unsigned len) |  | ) |

## ◆ OF() [3/4]

int inflateStateCheck OF | ( | (z_streamp strm) |  | ) |

## ◆ OF() [4/4]

int updatewindow OF | ( | (z_streamp strm, const unsigned char FAR *end, unsigned copy) |  | ) |

## ◆ syncsearch()

unsigned syncsearch | ( | unsigned FAR * | have,
|  | const unsigned char FAR * | buf,
|  | unsigned | len
| ) |  |

Definition at line 1404 of file inflate.c.

References inflate_state::have, len, and inflate_state::next.

Referenced by inflateSync().

## ◆ updatewindow()

int updatewindow | ( | z_streamp | strm,
|  | const Bytef * | end,
|  | unsigned | copy
| ) |  |

Definition at line 399 of file inflate.c.

References FAR, if(), inflate_state::strm, Z_NULL, ZALLOC, and zmemcpy.

Referenced by inflate(), and inflateSetDictionary().