gzread

Name

gzread -- read from a compressed file

Synopsis

#include <zlib.h>

int gzread (gzFile file, voidp buf, unsigned int len);

Description

The gzread() function shall read data from the compressed file referenced by file, which shall have been opened in a read mode (see gzopen() and gzdopen()). The gzread() function shall read data from file, and uncompress it into buf. At most, len bytes of uncompressed data shall be copied to buf. If the file is not compressed, gzread() shall simply copy data from file to buf without alteration.

Return Value

On success, gzread() shall return the number of bytes decompressed into buf. If gzread() returns 0, either the end-of-file has been reached or an underlying read error has occurred. Applications should use gzerror() or gzeof() to determine which occurred. On other errors, gzread() shall return a value less than 0 and applications may examine the cause using gzerror().

Errors

On error, gzread() shall set the error number associated with the stream identified by file to indicate the error. Applications should use gzerror() to access this error value.

Z_ERRNO 

An underlying base library function has indicated an error. The global variable errno may be examined for further information.

Z_STREAM_END 

End of file has been reached on input.

Z_DATA_ERROR 

A CRC error occurred when reading data; the file is corrupt.

Z_STREAM_ERROR 

The stream is invalid, or is in an invalid state.

Z_NEED_DICT 

A dictionary is needed (see inflateSetDictionary()).

Z_MEM_ERROR 

Insufficient memory available to decompress.