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

Function gzread

freebsd/contrib/zstd/zlibWrapper/examples/minigzip.c:265–298  ·  view source on GitHub ↗
(gz, buf, len)

Source from the content-addressed store, hash-verified

263int gzread OF((gzFile, void *, unsigned));
264
265int gzread(gz, buf, len)
266 gzFile gz;
267 void *buf;
268 unsigned len;
269{
270 int ret;
271 unsigned got;
272 unsigned char in[1];
273 z_stream *strm;
274
275 if (gz == NULL || gz->write)
276 return 0;
277 if (gz->err)
278 return 0;
279 strm = &(gz->strm);
280 strm->next_out = (void *)buf;
281 strm->avail_out = len;
282 do {
283 got = fread(in, 1, 1, gz->file);
284 if (got == 0)
285 break;
286 strm->next_in = in;
287 strm->avail_in = 1;
288 ret = inflate(strm, Z_NO_FLUSH);
289 if (ret == Z_DATA_ERROR) {
290 gz->err = Z_DATA_ERROR;
291 gz->msg = strm->msg;
292 return 0;
293 }
294 if (ret == Z_STREAM_END)
295 inflateReset(strm);
296 } while (strm->avail_out);
297 return len - strm->avail_out;
298}
299
300int gzclose OF((gzFile));
301

Callers 3

test_gzioFunction · 0.70
gz_uncompressFunction · 0.70
test_gzioFunction · 0.70

Calls 1

inflateResetFunction · 0.85

Tested by 2

test_gzioFunction · 0.56
test_gzioFunction · 0.56