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
| 206 | otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the |
| 207 | end of the input file has been reached and all data has been processed. */ |
| 208 | local int gz_fetch(gz_statep state) { |
| 209 | z_streamp strm = &(state->strm); |
| 210 | |
| 211 | do { |
| 212 | switch(state->how) { |
| 213 | case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ |
| 214 | if (gz_look(state) == -1) |
| 215 | return -1; |
| 216 | if (state->how == LOOK) |
| 217 | return 0; |
| 218 | break; |
| 219 | case COPY: /* -> COPY */ |
| 220 | if (gz_load(state, state->out, state->size << 1, &(state->x.have)) |
| 221 | == -1) |
| 222 | return -1; |
| 223 | state->x.next = state->out; |
| 224 | return 0; |
| 225 | case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ |
| 226 | strm->avail_out = state->size << 1; |
| 227 | strm->next_out = state->out; |
| 228 | if (gz_decomp(state) == -1) |
| 229 | return -1; |
| 230 | } |
| 231 | } while (state->x.have == 0 && (!state->eof || strm->avail_in)); |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ |
| 236 | local int gz_skip(gz_statep state, z_off64_t len) { |