zlib.h

来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 893 行 · 第 1/3 页

H
893
字号
   a call of inflate if this call returned Z_NEED_DICT. The dictionary chosen   by the compressor can be determined from the Adler32 value returned by this   call of inflate. The compressor and decompressor must use exactly the same   dictionary (see deflateSetDictionary).     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a   parameter is invalid (such as NULL dictionary) or the stream state is   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the   expected one (incorrect Adler32 value). inflateSetDictionary does not   perform any decompression: this will be done by subsequent calls of   inflate().*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int) inflateSync (z_streamp strm);#elseextern int EXPORT inflateSync OF((z_streamp strm));#endif/*     Skips invalid compressed data until the special marker (see deflate()  above) can be found, or until all available input is skipped. No output  is provided.    inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR  if no more input was provided, Z_DATA_ERROR if no marker has been found,  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success  case, the application may save the current current value of total_in which  indicates where valid compressed data was found. In the error case, the  application may repeatedly call inflateSync, providing more input each time,  until success or end of the input data.*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int) inflateReset (z_streamp strm);#elseextern int EXPORT inflateReset OF((z_streamp strm));#endif/*     This function is equivalent to inflateEnd followed by inflateInit,   but does not free and reallocate all the internal decompression state.   The stream will keep attributes that may have been set by inflateInit2.      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source   stream state was inconsistent (such as zalloc or state being NULL).*/                        /* utility functions *//*     The following utility functions are implemented on top of the   basic stream-oriented functions. To simplify the interface, some   default options are assumed (compression level, window size,   standard memory allocation functions). The source code of these   utility functions can easily be modified if you need special options.*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int) compress (Bytef *dest,   uLongf *destLen,			       const Bytef *source, uLong sourceLen);#elseextern int EXPORT compress OF((Bytef *dest,   uLongf *destLen,			       const Bytef *source, uLong sourceLen));#endif/*     Compresses the source buffer into the destination buffer.  sourceLen is   the byte length of the source buffer. Upon entry, destLen is the total   size of the destination buffer, which must be at least 0.1% larger than   sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the   compressed buffer.     This function can be used to compress a whole file at once if the   input file is mmap'ed.     compress returns Z_OK if success, Z_MEM_ERROR if there was not   enough memory, Z_BUF_ERROR if there was not enough room in the output   buffer.*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int) uncompress (Bytef *dest,   uLongf *destLen,				 const Bytef *source, uLong sourceLen);#elseextern int EXPORT uncompress OF((Bytef *dest,   uLongf *destLen,				 const Bytef *source, uLong sourceLen));#endif/*     Decompresses the source buffer into the destination buffer.  sourceLen is   the byte length of the source buffer. Upon entry, destLen is the total   size of the destination buffer, which must be large enough to hold the   entire uncompressed data. (The size of the uncompressed data must have   been saved previously by the compressor and transmitted to the decompressor   by some mechanism outside the scope of this compression library.)   Upon exit, destLen is the actual size of the compressed buffer.     This function can be used to decompress a whole file at once if the   input file is mmap'ed.     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not   enough memory, Z_BUF_ERROR if there was not enough room in the output   buffer, or Z_DATA_ERROR if the input data was corrupted.*/typedef voidp gzFile;#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern gzFile) gzopen  (const char *path, const char *mode);#elseextern gzFile EXPORT gzopen  OF((const char *path, const char *mode));#endif/*     Opens a gzip (.gz) file for reading or writing. The mode parameter   is as in fopen ("rb" or "wb") but can also include a compression level   ("wb9").  gzopen can be used to read a file which is not in gzip format;   in this case gzread will directly read from the file without decompression.     gzopen returns NULL if the file could not be opened or if there was   insufficient memory to allocate the (de)compression state; errno   can be checked to distinguish the two cases (if errno is zero, the   zlib error is Z_MEM_ERROR).*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern gzFile) gzdopen  (int fd, const char *mode);#elseextern gzFile EXPORT gzdopen  OF((int fd, const char *mode));#endif/*     gzdopen() associates a gzFile with the file descriptor fd.  File   descriptors are obtained from calls like open, dup, creat, pipe or   fileno (in the file has been previously opened with fopen).   The mode parameter is as in gzopen.     The next call of gzclose on the returned gzFile will also close the   file descriptor fd, just like fclose(fdopen(fd), mode) closes the file   descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).     gzdopen returns NULL if there was insufficient memory to allocate   the (de)compression state.*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int)    gzread  (gzFile file, voidp buf, unsigned len);#elseextern int EXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));#endif/*     Reads the given number of uncompressed bytes from the compressed file.   If the input file was not in gzip format, gzread copies the given number   of bytes into the buffer.     gzread returns the number of uncompressed bytes actually read (0 for   end of file, -1 for error). */#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int)    gzwrite (gzFile file, const voidp buf, unsigned len);#elseextern int EXPORT    gzwrite OF((gzFile file, const voidp buf, unsigned len));#endif/*     Writes the given number of uncompressed bytes into the compressed file.   gzwrite returns the number of uncompressed bytes actually written   (0 in case of error).*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int)    gzflush (gzFile file, int flush);#elseextern int EXPORT    gzflush OF((gzFile file, int flush));#endif/*     Flushes all pending output into the compressed file. The parameter   flush is as in the deflate() function. The return value is the zlib   error number (see function gzerror below). gzflush returns Z_OK if   the flush parameter is Z_FINISH and all output could be flushed.     gzflush should be called only when strictly necessary because it can   degrade compression.*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int)    gzclose (gzFile file);#elseextern int EXPORT    gzclose OF((gzFile file));#endif/*     Flushes all pending output if necessary, closes the compressed file   and deallocates all the (de)compression state. The return value is the zlib   error number (see function gzerror below).*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern const char *) gzerror (gzFile file, int *errnum);#elseextern const char * EXPORT gzerror OF((gzFile file, int *errnum));#endif/*     Returns the error message for the last error which occurred on the   given compressed file. errnum is set to zlib error number. If an   error occurred in the file system and not in the compression library,   errnum is set to Z_ERRNO and the application may consult errno   to get the exact error code.*/                        /* checksum functions *//*     These functions are not related to compression but are exported   anyway because they might be useful in applications using the   compression library.*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern uLong) adler32 (uLong adler, const Bytef *buf, uInt len);#elseextern uLong EXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));#endif/*     Update a running Adler-32 checksum with the bytes buf[0..len-1] and   return the updated checksum. If buf is NULL, this function returns   the required initial value for the checksum.   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed   much faster. Usage example:     uLong adler = adler32(0L, Z_NULL, 0);     while (read_buffer(buffer, length) != EOF) {       adler = adler32(adler, buffer, length);     }     if (adler != original_adler) error();*/#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern uLong) crc32   (uLong crc, const Bytef *buf, uInt len);#elseextern uLong EXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));#endif/*     Update a running crc with the bytes buf[0..len-1] and return the updated   crc. If buf is NULL, this function returns the required initial value   for the crc. Pre- and post-conditioning (one's complement) is performed   within this function so it shouldn't be done by the application.   Usage example:     uLong crc = crc32(0L, Z_NULL, 0);     while (read_buffer(buffer, length) != EOF) {       crc = crc32(crc, buffer, length);     }     if (crc != original_crc) error();*/                        /* various hacks, don't look :) *//* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */#ifdef MOZILLA_CLIENTPR_PUBLIC_API(extern int) deflateInit_ (z_streamp strm, int level, const char *version, 					int stream_size);PR_PUBLIC_API(extern int) inflateInit_ (z_streamp strm, const char *version, 					int stream_size);PR_PUBLIC_API(extern int) deflateInit2_ (z_streamp strm, int  level, int  method, 					 int windowBits, int memLevel, int strategy, 					 const char *version, int stream_size);PR_PUBLIC_API(extern int) inflateInit2_ (z_streamp strm, int  windowBits, 					 const char *version, int stream_size);#elseextern int EXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, 				   int stream_size));extern int EXPORT inflateInit_ OF((z_streamp strm, const char *version, 				   int stream_size));extern int EXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method, 				    int windowBits, int memLevel, int strategy, 				    const char *version, int stream_size));extern int EXPORT inflateInit2_ OF((z_streamp strm, int  windowBits, 				    const char *version, int stream_size));#endif /* MOZILLA_CLIENT */#define deflateInit(strm, level) \        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))#define inflateInit(strm) \        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\		      (strategy),           ZLIB_VERSION, sizeof(z_stream))#define inflateInit2(strm, windowBits) \        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)    struct internal_state {int dummy;}; /* hack for buggy compilers */#endifuLongf *get_crc_table OF((void)); /* can be used by asm versions of crc32() */#ifdef __cplusplus}#endif#endif /* _ZLIB_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?