⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zlib函数列表.txt

📁 Zlib函数列表 We often get questions about how the deflate() and inflate() functions should be used. User
💻 TXT
📖 第 1 页 / 共 3 页
字号:
Zlib函数列表
实用函数
int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 
int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); 
int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 
typedef voidp gzFile; 
gzFile gzopen (const char *path, const char *mode); 
gzFile gzdopen (int fd, const char *mode); 
int gzsetparams (gzFile file, int level, int strategy); 
int gzread (gzFile file, voidp buf, unsigned len); 
int gzwrite (gzFile file, const voidp buf, unsigned len); 
int VA gzprintf (gzFile file, const char *format, ...); 
int gzputs (gzFile file, const char *s); 
char * gzgets (gzFile file, char *buf, int len); 
int gzputc (gzFile file, int c); 
int gzgetc (gzFile file); 
int gzflush (gzFile file, int flush); 
z_off_t gzseek (gzFile file, z_off_t offset, int whence); 
z_off_t gztell (gzFile file); 
int gzrewind (gzFile file); 
int gzeof (gzFile file); 
int gzclose (gzFile file); 
const char * gzerror (gzFile file, int *errnum); 
 
基本函数: 
const char * zlibVersion (void); 
int deflateInit (z_streamp strm, int level); 
int deflate (z_streamp strm, int flush); 
int deflateEnd (z_streamp strm); 
int inflateInit (z_streamp strm); 
int inflate (z_streamp strm, int flush); 
int inflateEnd (z_streamp strm); 
 
高级函数:
int deflateInit2 (z_streamp strm, 
int deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength); 
int deflateCopy (z_streamp dest, z_streamp source); 
int deflateReset (z_streamp strm); 
int deflateParams (z_streamp strm, int level, int strategy); 
int inflateInit2 (z_streamp strm, int windowBits); 
int inflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength); 
int inflateSync (z_streamp strm); 
int inflateReset (z_streamp strm); 
 
校验函数
uLong adler32 (uLong adler, const Bytef *buf, uInt len); 
uLong crc32 (uLong crc, const Bytef *buf, uInt len); 
struct z_stream_s 
typedef struct z_stream_s {
    Bytef    *next_in; /* next input byte */
    uInt     avail_in; /* number of bytes available at next_in */
    uLong    total_in; /* total nb of input bytes read so far */
    Bytef    *next_out; /* next output byte should be put there */
    uInt     avail_out; /* remaining free space at next_out */
    uLong    total_out; /* total nb of bytes output so far */
    char     *msg;      /* last error message, NULL if no error */
    struct internal_state FAR *state; /* not visible by applications */
    alloc_func zalloc; /* used to allocate the internal state */
    free_func zfree;   /* used to free the internal state */
    voidpf     opaque; /* private data object passed to zalloc and zfree */
   int     data_type; /* best guess about the data type: ascii or binary */
    uLong   adler;      /* adler32 value of the uncompressed data */
    uLong   reserved;   /* reserved for future use */
} z_stream ;
typedef z_stream FAR * z_streamp; 
常量:
#define Z_NO_FLUSH      0
#define Z_PARTIAL_FLUSH 1      /* 将要被删除, 使用Z_SYNC_FLUSH 代替他们 */
#define Z_SYNC_FLUSH    2
#define Z_FULL_FLUSH    3
#define Z_FINISH        4       /* Allowed flush values ; see deflate() below for details */
#define Z_OK            0
#define Z_STREAM_END    1
#define Z_NEED_DICT     2
#define Z_ERRNO        (-1)
#define Z_STREAM_ERROR (-2)
#define Z_DATA_ERROR   (-3)
#define Z_MEM_ERROR    (-4)
#define Z_BUF_ERROR    (-5)
#define Z_VERSION_ERROR (-6)    /* 压缩/解压缩的返回值.负值是错误,正值是特殊但是正常的值. */
#define Z_NO_COMPRESSION         0
#define Z_BEST_SPEED             1
#define Z_BEST_COMPRESSION       9
#define Z_DEFAULT_COMPRESSION (-1)     /* 压缩级别 */
#define Z_FILTERED            1
#define Z_HUFFMAN_ONLY        2
#define Z_DEFAULT_STRATEGY    0         /* 压缩策略; see deflateInit2() below for details */
#define Z_BINARY   0
#define Z_ASCII    1
#define Z_UNKNOWN 2                    /* Possible values of the data_type field */
#define Z_DEFLATED 8/* The deflate compression method (the only one supported in this version) */
#define Z_NULL 0                     /* 用于初始化zalloc, zfree, opaque */
#define zlib_version zlibVersion()      /* 用于和1.0.2以前的版本兼容*/
另外一些函数:
const char * zError (int err); 
int inflateSyncPoint (z_streamp z); 
const uLongf * get_crc_table (void); 
-------------------------------------------SecondPart ----------------------------------------------------------

zlib 1.1.4 手册 

--------------------------------------------------------------------------------

目录
序言 
介绍 
实用函数
基本函数
高级函数
常量 
结构 z_stream_s 
校验函数
Misc 

--------------------------------------------------------------------------------

序言 
'zlib'常用的流行的压缩库 。版本:1.1.4。
Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler 
本软件对在使用中所产生的任何问题,不承担任何的责任。

许可任何人使用本软件用于任何目的,包括商业程序,或修改它,从新自由发布。
不过以下行为被限制:
1。本软件的起源不能被更改。
2。修改的版本必须被标记,不能搅乱原始版本。
3。本声明不能被移除,或修改。
/*
The origin of this software must not be misrepresented ; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 
Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 
This notice may not be removed or altered from any source distribution. 
*/
--------------------------------------------------------------------------------

介绍
zlib压缩库提供内存内压缩/解压缩函数。包括解压验证。
这个版本只有一种压缩方式,但是以后其他的算法也会被加入进来,并且接口是一样的。

如果缓存区足够大,压缩被一次完成,否则就重复调用压缩。在后一种情况,程序必须在每次调用时提供更多的输入或更多输出空间。

本压缩库也支持gzip(.gz)格式的读写操作。接口也和stdio相似。

本压缩库不安装任何信号处理,解码器检查压缩数据的一致性,所以,本压缩库决不会使输入崩溃。


--------------------------------------------------------------------------------

实用函数
以下实用函数的实现建立在basic stream-oriented 函数上。
为了了简化接口,设置了一些默认选项(压缩级别,内存使用,标准内存分配器功能)这些实用函数的源代码很容易被修改,如果你要实现有些特殊选项。
函数列表:
int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 
int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); 
int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 

typedef voidp gzFile; 

gzFile gzopen (const char *path, const char *mode); 
gzFile gzdopen (int fd, const char *mode); 

int gzsetparams (gzFile file, int level, int strategy); 

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

int VA gzprintf (gzFile file, const char *format, ...); 
int gzputs (gzFile file, const char *s); 
char * gzgets (gzFile file, char *buf, int len); 
int gzputc (gzFile file, int c); 
int gzgetc (gzFile file); 
int gzflush (gzFile file, int flush); 
z_off_t gzseek (gzFile file, z_off_t offset, int whence); 
z_off_t gztell (gzFile file); 
int gzrewind (gzFile file); 
int gzeof (gzFile file); 
int gzclose (gzFile file); 
const char * gzerror (gzFile file, int *errnum); 

函数说明:
int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 

压缩source buffer到destination buffer。
sourceLen是source buffer的长度(byte)。
destLen是destination buffer的总共长度(byte)。调用前 destLen的长度必须至少sourceLen长度的0.1%再加上12个byte.调用后。destLen是实际的compressed buffer长度。
如果输入文件是mmap'ed,这个函数可以用于压缩整个文件。
如果压缩成功返回Z_OK, 如果没有足够的内存返回Z_MEM_ERROR,如果没有足够的空间输出文件返回Z_BUF_ERROR.

int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); 

压缩source buffer到destination buffer。
参数级level和defalteInit一样。
destLen是destination buffer的总共长度(byte)。调用前 destLen的长度必须至少sourceLen长度的0.1%再加上12个byte.调用后。destLen是实际的compressed buffer长度。
如果压缩成功返回Z_OK, 如果没有足够的内存返回Z_MEM_ERROR,如果没有足够的空间输出文件返回Z_BUF_ERROR.
如果level是无效的,返回Z_STREAM_ERROR.

int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 
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. 

⌨️ 快捷键说明

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