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

Function gz_fetch

freebsd/contrib/zstd/zlibWrapper/gzread.c:241–268  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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. */
241local 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. */
271local 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