diff options
Diffstat (limited to 'zlib.h')
-rw-r--r-- | zlib.h | 99 |
1 files changed, 76 insertions, 23 deletions
@@ -1,7 +1,7 @@ | |||
1 | /* zlib.h -- interface of the 'zlib' general purpose compression library | 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
2 | version 1.2.3.4, December 21st, 2009 | 2 | version 1.2.3.5, Jan 8th, 2010 |
3 | 3 | ||
4 | Copyright (C) 1995-2009 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler |
5 | 5 | ||
6 | This software is provided 'as-is', without any express or implied | 6 | This software is provided 'as-is', without any express or implied |
7 | warranty. In no event will the authors be held liable for any damages | 7 | warranty. In no event will the authors be held liable for any damages |
@@ -37,8 +37,8 @@ | |||
37 | extern "C" { | 37 | extern "C" { |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #define ZLIB_VERSION "1.2.3.4" | 40 | #define ZLIB_VERSION "1.2.3.5" |
41 | #define ZLIB_VERNUM 0x1234 | 41 | #define ZLIB_VERNUM 0x1235 |
42 | #define ZLIB_VER_MAJOR 1 | 42 | #define ZLIB_VER_MAJOR 1 |
43 | #define ZLIB_VER_MINOR 2 | 43 | #define ZLIB_VER_MINOR 2 |
44 | #define ZLIB_VER_REVISION 3 | 44 | #define ZLIB_VER_REVISION 3 |
@@ -744,6 +744,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | |||
744 | size is given as input, inflate() will return with the error code | 744 | size is given as input, inflate() will return with the error code |
745 | Z_DATA_ERROR instead of trying to allocate a larger window. | 745 | Z_DATA_ERROR instead of trying to allocate a larger window. |
746 | 746 | ||
747 | windowBits can also be zero to request that inflate use the window size in | ||
748 | the zlib header of the compressed stream. | ||
749 | |||
747 | windowBits can also be -8..-15 for raw inflate. In this case, -windowBits | 750 | windowBits can also be -8..-15 for raw inflate. In this case, -windowBits |
748 | determines the window size. inflate() will then process raw deflate data, | 751 | determines the window size. inflate() will then process raw deflate data, |
749 | not looking for a zlib or gzip header, not generating a check value, and not | 752 | not looking for a zlib or gzip header, not generating a check value, and not |
@@ -1148,11 +1151,18 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, | |||
1148 | buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. | 1151 | buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. |
1149 | */ | 1152 | */ |
1150 | 1153 | ||
1154 | /* | ||
1155 | This library supports reading and writing files in gzip (.gz) format | ||
1156 | with an interface similar to that of stdio using the functions that start | ||
1157 | with "gz". The gzip format is different from the zlib format. gzip is a | ||
1158 | gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. | ||
1159 | |||
1160 | */ | ||
1151 | 1161 | ||
1152 | typedef voidp gzFile; | 1162 | typedef voidp gzFile; |
1153 | 1163 | ||
1154 | /* | 1164 | /* |
1155 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); | 1165 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); |
1156 | 1166 | ||
1157 | Opens a gzip (.gz) file for reading or writing. The mode parameter | 1167 | Opens a gzip (.gz) file for reading or writing. The mode parameter |
1158 | is as in fopen ("rb" or "wb") but can also include a compression level | 1168 | is as in fopen ("rb" or "wb") but can also include a compression level |
@@ -1169,7 +1179,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); | |||
1169 | can be checked to distinguish the two cases (if errno is zero, the | 1179 | can be checked to distinguish the two cases (if errno is zero, the |
1170 | zlib error is Z_MEM_ERROR). */ | 1180 | zlib error is Z_MEM_ERROR). */ |
1171 | 1181 | ||
1172 | ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | 1182 | ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); |
1173 | /* | 1183 | /* |
1174 | gzdopen() associates a gzFile with the file descriptor fd. File | 1184 | gzdopen() associates a gzFile with the file descriptor fd. File |
1175 | descriptors are obtained from calls like open, dup, creat, pipe or | 1185 | descriptors are obtained from calls like open, dup, creat, pipe or |
@@ -1182,6 +1192,20 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | |||
1182 | the (de)compression state. | 1192 | the (de)compression state. |
1183 | */ | 1193 | */ |
1184 | 1194 | ||
1195 | ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); | ||
1196 | /* | ||
1197 | Set the internal buffer size used by this library's functions. The default | ||
1198 | buffer size is 8192 bytes. This function must be called after gz_open() or | ||
1199 | gz_dopen(), and before any other calls that read or write the file. The | ||
1200 | buffer memory allocation is always deferred to the first read or write. Two | ||
1201 | buffers are allocated, either both of the specified size when writing, or | ||
1202 | one of the specified size and the other twice that size when reading. A | ||
1203 | larger buffer size of, for example, 64K or 128K bytes will noticeably | ||
1204 | increase the speed of decompression (reading). | ||
1205 | gz_buffer() returns 0 on success, or -1 on failure, such as being called | ||
1206 | too late. | ||
1207 | */ | ||
1208 | |||
1185 | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | 1209 | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); |
1186 | /* | 1210 | /* |
1187 | Dynamically update the compression level or strategy. See the description | 1211 | Dynamically update the compression level or strategy. See the description |
@@ -1190,7 +1214,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | |||
1190 | opened for writing. | 1214 | opened for writing. |
1191 | */ | 1215 | */ |
1192 | 1216 | ||
1193 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | 1217 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); |
1194 | /* | 1218 | /* |
1195 | Reads the given number of uncompressed bytes from the compressed file. | 1219 | Reads the given number of uncompressed bytes from the compressed file. |
1196 | If the input file was not in gzip format, gzread copies the given number | 1220 | If the input file was not in gzip format, gzread copies the given number |
@@ -1198,25 +1222,26 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | |||
1198 | gzread returns the number of uncompressed bytes actually read (0 for | 1222 | gzread returns the number of uncompressed bytes actually read (0 for |
1199 | end of file, -1 for error). */ | 1223 | end of file, -1 for error). */ |
1200 | 1224 | ||
1201 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, | 1225 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, |
1202 | voidpc buf, unsigned len)); | 1226 | voidpc buf, unsigned len)); |
1203 | /* | 1227 | /* |
1204 | Writes the given number of uncompressed bytes into the compressed file. | 1228 | Writes the given number of uncompressed bytes into the compressed file. |
1205 | gzwrite returns the number of uncompressed bytes actually written | 1229 | gzwrite returns the number of uncompressed bytes actually written |
1206 | (0 in case of error). | 1230 | (0 in case of error). |
1207 | */ | 1231 | */ |
1208 | 1232 | ||
1209 | ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); | 1233 | ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); |
1210 | /* | 1234 | /* |
1211 | Converts, formats, and writes the args to the compressed file under | 1235 | Converts, formats, and writes the arguments to the compressed file under |
1212 | control of the format string, as in fprintf. gzprintf returns the number of | 1236 | control of the format string, as in fprintf. gzprintf returns the number of |
1213 | uncompressed bytes actually written (0 in case of error). The number of | 1237 | uncompressed bytes actually written, or 0 in case of error. The number of |
1214 | uncompressed bytes written is limited to 4095. The caller should assure that | 1238 | uncompressed bytes written is limited to 8191, or one less than the buffer |
1215 | this limit is not exceeded. If it is exceeded, then gzprintf() will return | 1239 | size given to gz_buffer(). The caller should assure that this limit is not |
1216 | return an error (0) with nothing written. In this case, there may also be a | 1240 | exceeded. If it is exceeded, then gzprintf() will return an error (0) with |
1217 | buffer overflow with unpredictable consequences, which is possible only if | 1241 | nothing written. In this case, there may also be a buffer overflow with |
1218 | zlib was compiled with the insecure functions sprintf() or vsprintf() | 1242 | unpredictable consequences, which is possible only if zlib was compiled |
1219 | because the secure snprintf() or vsnprintf() functions were not available. | 1243 | with the insecure functions sprintf() or vsprintf() because the secure |
1244 | snprintf() or vsnprintf() functions were not available. | ||
1220 | */ | 1245 | */ |
1221 | 1246 | ||
1222 | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | 1247 | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); |
@@ -1257,7 +1282,7 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); | |||
1257 | or gzrewind(). | 1282 | or gzrewind(). |
1258 | */ | 1283 | */ |
1259 | 1284 | ||
1260 | ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | 1285 | ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); |
1261 | /* | 1286 | /* |
1262 | Flushes all pending output into the compressed file. The parameter | 1287 | Flushes all pending output into the compressed file. The parameter |
1263 | flush is as in the deflate() function. The return value is the zlib | 1288 | flush is as in the deflate() function. The return value is the zlib |
@@ -1268,8 +1293,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | |||
1268 | */ | 1293 | */ |
1269 | 1294 | ||
1270 | /* | 1295 | /* |
1271 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, | 1296 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, |
1272 | z_off_t offset, int whence)); | 1297 | z_off_t offset, int whence)); |
1273 | 1298 | ||
1274 | Sets the starting position for the next gzread or gzwrite on the | 1299 | Sets the starting position for the next gzread or gzwrite on the |
1275 | given compressed file. The offset represents a number of bytes in the | 1300 | given compressed file. The offset represents a number of bytes in the |
@@ -1298,11 +1323,23 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); | |||
1298 | 1323 | ||
1299 | Returns the starting position for the next gzread or gzwrite on the | 1324 | Returns the starting position for the next gzread or gzwrite on the |
1300 | given compressed file. This position represents a number of bytes in the | 1325 | given compressed file. This position represents a number of bytes in the |
1301 | uncompressed data stream. | 1326 | uncompressed data stream, and is zero when starting, even if appending |
1327 | or reading a gzip stream from the middle of a file using gz_dopen(). | ||
1302 | 1328 | ||
1303 | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) | 1329 | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) |
1304 | */ | 1330 | */ |
1305 | 1331 | ||
1332 | /* | ||
1333 | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); | ||
1334 | |||
1335 | Returns the current offset in the file being read or written. This offset | ||
1336 | includes the count of bytes that precede the gzip stream, for example when | ||
1337 | appending or when using gz_dopen() for reading. When reading, the offset | ||
1338 | includes data that has been used to generate what has been provided as | ||
1339 | uncompressed data so far, but does not include as yet unused buffered input. | ||
1340 | On error, gz_offset() returns -1. | ||
1341 | */ | ||
1342 | |||
1306 | ZEXTERN int ZEXPORT gzeof OF((gzFile file)); | 1343 | ZEXTERN int ZEXPORT gzeof OF((gzFile file)); |
1307 | /* | 1344 | /* |
1308 | Returns 1 when EOF has previously been detected reading the given | 1345 | Returns 1 when EOF has previously been detected reading the given |
@@ -1319,10 +1356,22 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | |||
1319 | /* | 1356 | /* |
1320 | Flushes all pending output if necessary, closes the compressed file | 1357 | Flushes all pending output if necessary, closes the compressed file |
1321 | and deallocates all the (de)compression state. The return value is the zlib | 1358 | and deallocates all the (de)compression state. The return value is the zlib |
1322 | error number. Note that once file is close, you cannot call gzerror with | 1359 | error number. Note that once file is closed, you cannot call gzerror with |
1323 | file, since its structures have been deallocated. | 1360 | file, since its structures have been deallocated. |
1324 | */ | 1361 | */ |
1325 | 1362 | ||
1363 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); | ||
1364 | ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); | ||
1365 | /* | ||
1366 | Same as gz_close(), but gz_close_r() is only for use when reading, and | ||
1367 | gz_close_w() is only for use when writing. The advantage to using these | ||
1368 | instead of gz_close() is that they avoid linking in zlib compression or | ||
1369 | decompression code that is not used when only reading or only writing | ||
1370 | respectively. If gz_close() is used, then both compression and | ||
1371 | decompression code will be included the application when linking to a | ||
1372 | static zlib library. | ||
1373 | */ | ||
1374 | |||
1326 | ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | 1375 | ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); |
1327 | /* | 1376 | /* |
1328 | Returns the error message for the last error which occurred on the | 1377 | Returns the error message for the last error which occurred on the |
@@ -1439,6 +1488,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, | |||
1439 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | 1488 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
1440 | ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int)); | 1489 | ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int)); |
1441 | ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile)); | 1490 | ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile)); |
1491 | ZEXTERN off64_t ZEXPORT gzoffset64 OF((gzFile)); | ||
1442 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off64_t)); | 1492 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off64_t)); |
1443 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t)); | 1493 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t)); |
1444 | #endif | 1494 | #endif |
@@ -1447,12 +1497,14 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, | |||
1447 | # define gzopen gzopen64 | 1497 | # define gzopen gzopen64 |
1448 | # define gzseek gzseek64 | 1498 | # define gzseek gzseek64 |
1449 | # define gztell gztell64 | 1499 | # define gztell gztell64 |
1500 | # define gzoffset gzoffset64 | ||
1450 | # define adler32_combine adler32_combine64 | 1501 | # define adler32_combine adler32_combine64 |
1451 | # define crc32_combine crc32_combine64 | 1502 | # define crc32_combine crc32_combine64 |
1452 | # ifndef _LARGEFILE64_SOURCE | 1503 | # ifndef _LARGEFILE64_SOURCE |
1453 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | 1504 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
1454 | ZEXTERN off_t ZEXPORT gzseek64 OF((gzFile, off_t, int)); | 1505 | ZEXTERN off_t ZEXPORT gzseek64 OF((gzFile, off_t, int)); |
1455 | ZEXTERN off_t ZEXPORT gztell64 OF((gzFile)); | 1506 | ZEXTERN off_t ZEXPORT gztell64 OF((gzFile)); |
1507 | ZEXTERN off_t ZEXPORT gzoffset64 OF((gzFile)); | ||
1456 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off_t)); | 1508 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off_t)); |
1457 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off_t)); | 1509 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off_t)); |
1458 | # endif | 1510 | # endif |
@@ -1460,6 +1512,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, | |||
1460 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); | 1512 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); |
1461 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); | 1513 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); |
1462 | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); | 1514 | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); |
1515 | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); | ||
1463 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); | 1516 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); |
1464 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); | 1517 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); |
1465 | #endif | 1518 | #endif |