Fetch data and put it in the output buffer. Assumes state.state->x.have is 0. Data is either copied from the input file or decompressed from the input file depending on state.state->how. If state.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.state->how as COPY or GZIP un
(state)
| 239 | otherwise 0. gz_fetch() will leave state.state->how as COPY or GZIP unless the |
| 240 | end of the input file has been reached and all data has been processed. */ |
| 241 | local int gz_fetch(state) |
| 242 | gz_statep state; |
| 243 | { |
| 244 | z_streamp strm = &(state.state->strm); |
| 245 | |
| 246 | do { |
| 247 | switch(state.state->how) { |
| 248 | case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ |
| 249 | if (gz_look(state) == -1) |
| 250 | return -1; |
| 251 | if (state.state->how == LOOK) |
| 252 | return 0; |
| 253 | break; |
| 254 | case COPY: /* -> COPY */ |
| 255 | if (gz_load(state, state.state->out, state.state->size << 1, &(state.state->x.have)) |
| 256 | == -1) |
| 257 | return -1; |
| 258 | state.state->x.next = state.state->out; |
| 259 | return 0; |
| 260 | case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ |
| 261 | strm->avail_out = state.state->size << 1; |
| 262 | strm->next_out = state.state->out; |
| 263 | if (gz_decomp(state) == -1) |
| 264 | return -1; |
| 265 | } |
| 266 | } while (state.state->x.have == 0 && (!state.state->eof || strm->avail_in)); |
| 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ |
| 271 | local int gz_skip(state, len) |