Linux程式设计入门 - zlib的运用
发布于2005-05-28 被读1104次 【字体:大 中 小】 |
gzip(*.gz)档案格式几乎是Linux下的标准格式了,有人认为bzip2的压缩率比gzip来得高。一般来说,这个说法大致正确,不过根据我个人的经验,有一半以上的档案,bzip2没有比gzip的压缩率来得高,有少数状况下,gzip压缩率反 使用范例 : showgz.c #include void main(int argc,char **argv) if (argc<2) return; zip = gzopen(argv[1],"rb"); 编译 gcc -o showgz showgz.c -lz 检验 gzip -9 < showgz.c > showgz.c.gz 将会把这个程式内容显示出来,showgz的作用可说等於gzip -dc。 函数宣告 gzFile gzopen (const char *path, const char *mode); int gzread (gzFile file, voidp buf, unsigned len); int gzwrite (gzFile file, const voidp buf, unsigned len); int gzprintf (gzFile file, const char *format, ...); 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); int gzrewind (gzFile file); z_off_t gztell (gzFile file); int gzeof (gzFile file); int gzclose (gzFile file); OK STATION, Webmaster, Brian Lin --
|