diff options
Diffstat (limited to 'zlib.h')
-rw-r--r-- | zlib.h | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -1388,7 +1388,35 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | |||
1388 | case. | 1388 | case. |
1389 | 1389 | ||
1390 | gzread returns the number of uncompressed bytes actually read, less than | 1390 | gzread returns the number of uncompressed bytes actually read, less than |
1391 | len for end of file, or -1 for error. | 1391 | len for end of file, or -1 for error. If len is too large to fit in an int, |
1392 | then nothing is read, -1 is returned, and the error state is set to | ||
1393 | Z_STREAM_ERROR. | ||
1394 | */ | ||
1395 | |||
1396 | ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, | ||
1397 | gzFile file)); | ||
1398 | /* | ||
1399 | Read up to nitems items of size size from file to buf, otherwise operating | ||
1400 | as gzread() does. This duplicates the interface of stdio's fread(), with | ||
1401 | size_t request and return types. If the library defines size_t, then | ||
1402 | z_size_t is identical to size_t. If not, then z_size_t is an unsigned | ||
1403 | integer type that can contain a pointer. | ||
1404 | |||
1405 | gzfread() returns the number of full items read of size size, or zero if | ||
1406 | the end of the file was reached and a full item could not be read, or if | ||
1407 | there was an error. gzerror() must be consulted if zero is returned in | ||
1408 | order to determine if there was an error. If the multiplication of size and | ||
1409 | nitems overflows, i.e. the product does not fit in a z_size_t, then nothing | ||
1410 | is read, zero is returned, and the error state is set to Z_STREAM_ERROR. | ||
1411 | |||
1412 | In the event that the end of file is reached and only a partial item is | ||
1413 | available at the end, i.e. the remaining uncompressed data length is not a | ||
1414 | multiple of size, then the final partial item is nevetheless read into buf | ||
1415 | and the end-of-file flag is set. The length of the partial item read is not | ||
1416 | provided, but could be inferred from the result of gztell(). This behavior | ||
1417 | is the same as the behavior of fread() implementations in common libraries, | ||
1418 | but it prevents the direct use of gzfread() to read a concurrently written | ||
1419 | file, reseting and retrying on end-of-file, when size is not 1. | ||
1392 | */ | 1420 | */ |
1393 | 1421 | ||
1394 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, | 1422 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, |