头文件:
#include "zlib.h"
编译:
需要加上 -lz
- #define CHUNK 100000
-
- int decodeZip(char *source,int len,char **dest)
- {
- int ret;
- unsigned have;
- z_stream strm;
- unsigned char out[CHUNK];
- int totalsize = 0;
-
- /* allocate inflate state */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
-
- ret = inflateInit2(&strm, 31);
-
- if (ret !