libz提供了一套与gzip有关的API,libbz2提供了一套与bzip2有关的API。我们可以利用其中几个常用的函数,在自己的项目中实现压缩、解压缩功能。这两个库文件一般在linux系统中都会有,如果没有,可以分别到以下网址下载其源代码:
gzip: http://www.gzip.org/
bzip2: http://www.bzip.org/index.html
libz最有用的函数有四个:
gzFile gzopen(const char *path, const char *mode);
int gzclose(gzFile file);
int gzread(gzFile file, void *buf, unsigned len);
int gzwrite(gzFile file, const void *buf, unsigned len);
追踪其源代码的话,可以发现,gzFile也就是void *
libbz2最有用的函数也有四个: