MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gz_fetch

Function gz_fetch

freebsd/contrib/zlib/gzread.c:232–259  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

230 otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
231 end of the input file has been reached and all data has been processed. */
232local int gz_fetch(state)
233 gz_statep state;
234{
235 z_streamp strm = &(state->strm);
236
237 do {
238 switch(state->how) {
239 case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */
240 if (gz_look(state) == -1)
241 return -1;
242 if (state->how == LOOK)
243 return 0;
244 break;
245 case COPY: /* -> COPY */
246 if (gz_load(state, state->out, state->size << 1, &(state->x.have))
247 == -1)
248 return -1;
249 state->x.next = state->out;
250 return 0;
251 case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */
252 strm->avail_out = state->size << 1;
253 strm->next_out = state->out;
254 if (gz_decomp(state) == -1)
255 return -1;
256 }
257 } while (state->x.have == 0 && (!state->eof || strm->avail_in));
258 return 0;
259}
260
261/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
262local int gz_skip(state, len)

Callers 3

gz_skipFunction · 0.70
gz_readFunction · 0.70
gzread.cFile · 0.70

Calls 3

gz_lookFunction · 0.70
gz_loadFunction · 0.70
gz_decompFunction · 0.70

Tested by

no test coverage detected