Fetch data and put it in the output buffer. Assumes state->x.have is 0. Data is either copied from the input file or decompressed from the input file depending on state->how. If state->how is LOOK, then a gzip header is looked for to determine whether to copy or decompress. Returns -1 on error, otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the end of the i
(state)
| 251 | otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the |
| 252 | end of the input file has been reached and all data has been processed. */ |
| 253 | local int gz_fetch(state) |
| 254 | |
| 255 | gz_statep state; |
| 256 | { |
| 257 | z_streamp strm = &(state->strm); |
| 258 | |
| 259 | do |
| 260 | { |
| 261 | switch (state->how) |
| 262 | { |
| 263 | case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ |
| 264 | if (gz_look(state) == -1) |
| 265 | return -1; |
| 266 | if (state->how == LOOK) |
| 267 | return 0; |
| 268 | break; |
| 269 | case COPY: /* -> COPY */ |
| 270 | if (gz_load(state, state->out, state->size << 1, &(state->x.have)) |
| 271 | == -1) |
| 272 | return -1; |
| 273 | state->x.next = state->out; |
| 274 | return 0; |
| 275 | case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ |
| 276 | strm->avail_out = state->size << 1; |
| 277 | strm->next_out = state->out; |
| 278 | if (gz_decomp(state) == -1) |
| 279 | return -1; |
| 280 | } |
| 281 | } |
| 282 | while (state->x.have == 0 && (!state->eof || strm->avail_in)); |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ |
| 287 | local int gz_skip(state, len) |