使用ZLib库压缩解压缩Demo

该博客展示了如何使用ZLib库进行数据压缩和解压缩操作。提供了`decodeZip`函数用于解压缩,`encodeZip`函数用于压缩内容,并通过示例代码详细解释了每个步骤。
摘要由CSDN通过智能技术生成
头文件:
#include "zlib.h"

编译:
需要加上 -lz

解压缩:
  1. #define CHUNK 100000

  2. int decodeZip(char *source,int len,char **dest)
  3. {
  4.     int ret; 
  5.     unsigned have; 
  6.     z_stream strm; 
  7.     unsigned char out[CHUNK]; 
  8.     int totalsize = 0; 
  9.     
  10.     /* allocate inflate state */ 
  11.     strm.zalloc = Z_NULL; 
  12.     strm.zfree = Z_NULL; 
  13.     strm.opaque = Z_NULL; 
  14.     strm.avail_in = 0; 
  15.     strm.next_in = Z_NULL; 

  16.     ret = inflateInit2(&strm, 31); 
  17.     
  18.     if (ret !
ZLIB.NET: README ================================================== Contents -------- Program information Company information Description Specification Other ComponentAce compression products Program information ------------------- Program Name: ZLIB.NET License Type: freeware Program Version: 1.04 Program Release Date: 03/28/2007 Program Purpose: version of ZLIB compression library for .NET framework Target Environment: Visual Studio 2003, Visual Studio 2005, Borland Developer Studio 2005, Borland Developer Studio 2006 and other Company information ------------------- Company Name: ComponentAce Contact E-mail Address: support@componentace.com Contact WWW URL: http://www.componentace.com Description ----------- 100% managed version of ZLIB compression library. Based on JZlib library (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. The zlib compression library was written by Jean-loup Gailly gzip@prep.ai.mit.edu and Mark Adler madler@alumni.caltech.edu. The primary site for the zlib compression library is http://www.zlib.org. Copyright and license --------------------- See "license.txt" file. Warranty and guarantee ---------------------- See "license.txt" file. Other ComponentAce compression products --------------------------------------- ZipForge.NET ------------ ZipForge.NET is an advanced ZIP compression library for .NET framework. ZipForge.NET features include streaming support, transaction system, ZIP encryption, repair, progress indication, Zip64 support, SFX (self-extracting) archives, unicode filenames, spanning support and much more. FlexCompress.NET ---------------- FlexCompress.NET is an advanced compression and encryption .NET component designed to provide archive functionality for your applications. This solution provides flexible compression and strong encryption algorithms that allows you to integrate archiving or backup features into your programs in a fast and easy way. FlexCompres.NET uses its
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值