diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2016-12-03 08:18:56 -0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2016-12-04 07:48:47 -0800 |
commit | 123f9cfaf7730dcc52c380eaf04c15dc3e0b15f8 (patch) | |
tree | e5f159d765beaba71aa9d0493f7fd4e179fa06fe /zlib.h | |
parent | 9dc5a8585f429109ef1948ab71b6b71bfa7181e2 (diff) | |
download | zlib-123f9cfaf7730dcc52c380eaf04c15dc3e0b15f8.tar.gz zlib-123f9cfaf7730dcc52c380eaf04c15dc3e0b15f8.tar.bz2 zlib-123f9cfaf7730dcc52c380eaf04c15dc3e0b15f8.zip |
Clean up gz* function return values.
In some cases the return values did not match the documentation,
or the documentation did not document all of the return values.
gzprintf() now consistently returns negative values on error,
which matches the behavior of the stdio fprintf() function.
Diffstat (limited to 'zlib.h')
-rw-r--r-- | zlib.h | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -1355,10 +1355,12 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); | |||
1355 | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | 1355 | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); |
1356 | /* | 1356 | /* |
1357 | Dynamically update the compression level or strategy. See the description | 1357 | Dynamically update the compression level or strategy. See the description |
1358 | of deflateInit2 for the meaning of these parameters. | 1358 | of deflateInit2 for the meaning of these parameters. Previously provided |
1359 | data is flushed before the parameter change. | ||
1359 | 1360 | ||
1360 | gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not | 1361 | gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not |
1361 | opened for writing. | 1362 | opened for writing, Z_ERRNO if there is an error writing the flushed data, |
1363 | or Z_MEM_ERROR if there is a memory allocation error. | ||
1362 | */ | 1364 | */ |
1363 | 1365 | ||
1364 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | 1366 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); |
@@ -1401,15 +1403,15 @@ ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); | |||
1401 | /* | 1403 | /* |
1402 | Converts, formats, and writes the arguments to the compressed file under | 1404 | Converts, formats, and writes the arguments to the compressed file under |
1403 | control of the format string, as in fprintf. gzprintf returns the number of | 1405 | control of the format string, as in fprintf. gzprintf returns the number of |
1404 | uncompressed bytes actually written, or 0 in case of error. The number of | 1406 | uncompressed bytes actually written, or a negative zlib error code in case |
1405 | uncompressed bytes written is limited to 8191, or one less than the buffer | 1407 | of error. The number of uncompressed bytes written is limited to 8191, or |
1406 | size given to gzbuffer(). The caller should assure that this limit is not | 1408 | one less than the buffer size given to gzbuffer(). The caller should assure |
1407 | exceeded. If it is exceeded, then gzprintf() will return an error (0) with | 1409 | that this limit is not exceeded. If it is exceeded, then gzprintf() will |
1408 | nothing written. In this case, there may also be a buffer overflow with | 1410 | return an error (0) with nothing written. In this case, there may also be a |
1409 | unpredictable consequences, which is possible only if zlib was compiled with | 1411 | buffer overflow with unpredictable consequences, which is possible only if |
1410 | the insecure functions sprintf() or vsprintf() because the secure snprintf() | 1412 | zlib was compiled with the insecure functions sprintf() or vsprintf() |
1411 | or vsnprintf() functions were not available. This can be determined using | 1413 | because the secure snprintf() or vsnprintf() functions were not available. |
1412 | zlibCompileFlags(). | 1414 | This can be determined using zlibCompileFlags(). |
1413 | */ | 1415 | */ |
1414 | 1416 | ||
1415 | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | 1417 | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); |