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
(strm, in, in_desc, out, out_desc)
| 251 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
| 252 | */ |
| 253 | int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) |
| 254 | z_streamp strm; |
| 255 | in_func in; |
| 256 | void FAR * in_desc; |
| 257 | out_func out; |
| 258 | |
| 259 | void FAR * out_desc; |
| 260 | { |
| 261 | struct inflate_state FAR * state; |
| 262 | z_const unsigned char FAR * next; /* next input */ |
| 263 | unsigned char FAR * put; /* next output */ |
| 264 | unsigned have, left; /* available input and output */ |
| 265 | unsigned long hold; /* bit buffer */ |
| 266 | unsigned bits; /* bits in bit buffer */ |
| 267 | unsigned copy; /* number of stored or match bytes to copy */ |
| 268 | unsigned char FAR * from; /* where to copy match bytes from */ |
| 269 | code here; /* current decoding table entry */ |
| 270 | code last; /* parent table entry */ |
| 271 | unsigned len; /* length to copy for repeats, bits to drop */ |
| 272 | int ret; /* return code */ |
| 273 | static const unsigned short order[19] = /* permutation of code lengths */ |
| 274 | {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; |
| 275 | |
| 276 | /* Check that the strm exists and that the state was initialized */ |
| 277 | if (strm == Z_NULL || strm->state == Z_NULL) |
| 278 | return Z_STREAM_ERROR; |
| 279 | state = (struct inflate_state FAR *)strm->state; |
| 280 | |
| 281 | /* Reset the state */ |
| 282 | strm->msg = Z_NULL; |
| 283 | state->mode = TYPE; |
| 284 | state->last = 0; |
| 285 | state->whave = 0; |
| 286 | next = strm->next_in; |
| 287 | have = next != Z_NULL ? strm->avail_in : 0; |
| 288 | hold = 0; |
| 289 | bits = 0; |
| 290 | put = state->window; |
| 291 | left = state->wsize; |
| 292 | |
| 293 | /* Inflate until end of block marked as last */ |
| 294 | for (;;) |
| 295 | switch (state->mode) |
| 296 | { |
| 297 | case TYPE: |
| 298 | /* determine and dispatch block type */ |
| 299 | if (state->last) |
| 300 | { |
| 301 | BYTEBITS(); |
| 302 | state->mode = DONE; |
| 303 | break; |
| 304 | } |
| 305 | NEEDBITS(3); |
| 306 | state->last = BITS(1); |
| 307 | DROPBITS(1); |
| 308 | switch (BITS(2)) |
| 309 | { |
| 310 | case 0: /* stored block */ |
nothing calls this directly
no test coverage detected