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

Function gzread

freebsd/contrib/zlib/gzread.c:378–411  ·  view source on GitHub ↗

-- see zlib.h -- */

(file, buf, len)

Source from the content-addressed store, hash-verified

376
377/* -- see zlib.h -- */
378int ZEXPORT gzread(file, buf, len)
379 gzFile file;
380 voidp buf;
381 unsigned len;
382{
383 gz_statep state;
384
385 /* get internal structure */
386 if (file == NULL)
387 return -1;
388 state = (gz_statep)file;
389
390 /* check that we're reading and that there's no (serious) error */
391 if (state->mode != GZ_READ ||
392 (state->err != Z_OK && state->err != Z_BUF_ERROR))
393 return -1;
394
395 /* since an int is returned, make sure len fits in one, otherwise return
396 with an error (this avoids a flaw in the interface) */
397 if ((int)len < 0) {
398 gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
399 return -1;
400 }
401
402 /* read len or fewer bytes to buf */
403 len = gz_read(state, buf, len);
404
405 /* check for an error */
406 if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
407 return -1;
408
409 /* return the number of bytes read (this is assured to fit in an int) */
410 return (int)len;
411}
412
413/* -- see zlib.h -- */
414z_size_t ZEXPORT gzfread(buf, size, nitems, file)

Callers 1

read_mapFunction · 0.50

Calls 2

gz_errorFunction · 0.70
gz_readFunction · 0.70

Tested by 1

read_mapFunction · 0.40