MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / inflateBack

Function inflateBack

extern/zlib/src/infback.c:242–619  ·  view source on GitHub ↗

strm provides the memory allocation functions and window buffer on input, and provides information on the unused input on return. For Z_DATA_ERROR returns, strm will also provide an error message. in() and out() are the call-back input and output functions. When inflateBack() needs more input, it calls in(). When inflateBack() has filled the window with output, or when it comple

Source from the content-addressed store, hash-verified

240 are not correct, i.e. strm is Z_NULL or the state was not initialized.
241 */
242int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
243 out_func out, void FAR *out_desc) {
244 struct inflate_state FAR *state;
245 z_const unsigned char FAR *next; /* next input */
246 unsigned char FAR *put; /* next output */
247 unsigned have, left; /* available input and output */
248 unsigned long hold; /* bit buffer */
249 unsigned bits; /* bits in bit buffer */
250 unsigned copy; /* number of stored or match bytes to copy */
251 unsigned char FAR *from; /* where to copy match bytes from */
252 code here; /* current decoding table entry */
253 code last; /* parent table entry */
254 unsigned len; /* length to copy for repeats, bits to drop */
255 int ret; /* return code */
256 static const unsigned short order[19] = /* permutation of code lengths */
257 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
258
259 /* Check that the strm exists and that the state was initialized */
260 if (strm == Z_NULL || strm->state == Z_NULL)
261 return Z_STREAM_ERROR;
262 state = (struct inflate_state FAR *)strm->state;
263
264 /* Reset the state */
265 strm->msg = Z_NULL;
266 state->mode = TYPE;
267 state->last = 0;
268 state->whave = 0;
269 next = strm->next_in;
270 have = next != Z_NULL ? strm->avail_in : 0;
271 hold = 0;
272 bits = 0;
273 put = state->window;
274 left = state->wsize;
275
276 /* Inflate until end of block marked as last */
277 for (;;)
278 switch (state->mode) {
279 case TYPE:
280 /* determine and dispatch block type */
281 if (state->last) {
282 BYTEBITS();
283 state->mode = DONE;
284 break;
285 }
286 NEEDBITS(3);
287 state->last = BITS(1);
288 DROPBITS(1);
289 switch (BITS(2)) {
290 case 0: /* stored block */
291 Tracev((stderr, "inflate: stored block%s\n",
292 state->last ? " (last)" : ""));
293 state->mode = STORED;
294 break;
295 case 1: /* fixed block */
296 fixedtables(state);
297 Tracev((stderr, "inflate: fixed codes block%s\n",
298 state->last ? " (last)" : ""));
299 state->mode = LEN; /* decode codes */

Callers

nothing calls this directly

Calls 4

zmemcpyFunction · 0.85
inflate_tableFunction · 0.85
inflate_fastFunction · 0.85
fixedtablesFunction · 0.70

Tested by

no test coverage detected