资源简介
基于zlib-1.2.5源代码整理的代码,实现了zip文件的解压、压缩功能,直接把代码用vs编译以后即可使用。
代码片段和文件信息
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2007 Mark Adler
* For conditions of distribution and use see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#include “zutil.h“
#define local static
local uLong adler32_combine_(uLong adler1 uLong adler2 z_off64_t len2);
#define base 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(base-1) <= 2^32-1 */
#define DO1(bufi) {adler += (buf)[i]; sum2 += adler;}
#define DO2(bufi) DO1(bufi); DO1(bufi+1);
#define DO4(bufi) DO2(bufi); DO2(bufi+2);
#define DO8(bufi) DO4(bufi); DO4(bufi+4);
#define DO16(buf) DO8(buf0); DO8(buf8);
/* use NO_DIVIDE if your processor does not do division in hardware */
#ifdef NO_DIVIDE
# define MOD(a) \
do { \
if (a >= (base << 16)) a -= (base << 16); \
if (a >= (base << 15)) a -= (base << 15); \
if (a >= (base << 14)) a -= (base << 14); \
if (a >= (base << 13)) a -= (base << 13); \
if (a >= (base << 12)) a -= (base << 12); \
if (a >= (base << 11)) a -= (base << 11); \
if (a >= (base << 10)) a -= (base << 10); \
if (a >= (base << 9)) a -= (base << 9); \
if (a >= (base << 8)) a -= (base << 8); \
if (a >= (base << 7)) a -= (base << 7); \
if (a >= (base << 6)) a -= (base << 6); \
if (a >= (base << 5)) a -= (base << 5); \
if (a >= (base << 4)) a -= (base << 4); \
if (a >= (base << 3)) a -= (base << 3); \
if (a >= (base << 2)) a -= (base << 2); \
if (a >= (base << 1)) a -= (base << 1); \
if (a >= base) a -= base; \
} while (0)
# define MOD4(a) \
do { \
if (a >= (base << 4)) a -= (base << 4); \
if (a >= (base << 3)) a -= (base << 3); \
if (a >= (base << 2)) a -= (base << 2); \
if (a >= (base << 1)) a -= (base << 1); \
if (a >= base) a -= base; \
} while (0)
#else
# define MOD(a) a %= base
# define MOD4(a) a %= base
#endif
/* ========================================================================= */
uLong ZEXPORT adler32(adler buf len)
uLong adler;
const Bytef *buf;
uInt len;
{
unsigned long sum2;
unsigned n;
/* split Adler-32 into component sums */
sum2 = (adler >> 16) & 0xffff;
adler &= 0xffff;
/* in case user likes doing a byte at a time keep it fast */
if (len == 1) {
adler += buf[0];
if (adler >= base)
adler -= base;
sum2 += adler;
if (sum2 >= base)
sum2 -= base;
return adler | (sum2 << 16);
}
/* initial Adler-32 value (deferred check for len == 1 speed) */
if (buf == Z_NULL)
return 1L;
/* in case short lengths are provided keep it somewhat fast */
if (len < 16) {
while (len--) {
adler += *buf++;
sum2 += adler;
}
if (adler >= base)
adler -= base;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-08-08 11:38 ziplib\
文件 5048 2007-08-06 14:16 ziplib\adler32.c
文件 2520 2005-12-12 02:27 ziplib\compress.c
文件 13681 2010-04-19 12:10 ziplib\crc32.c
文件 30568 2003-01-06 00:53 ziplib\crc32.h
文件 4759 2009-10-26 13:49 ziplib\crypt.h
文件 67992 2010-04-20 12:12 ziplib\deflate.c
文件 12672 2010-04-19 12:00 ziplib\deflate.h
文件 678 2010-02-14 08:12 ziplib\gzclose.c
文件 4677 2010-04-19 03:28 ziplib\gzguts.h
文件 14071 2010-04-19 01:53 ziplib\gzlib.c
文件 20574 2010-03-28 23:19 ziplib\gzread.c
文件 14602 2010-03-13 10:27 ziplib\gzwrite.c
文件 22622 2009-12-26 08:34 ziplib\infback.c
文件 13439 2010-04-19 12:16 ziplib\inffast.c
文件 427 2010-04-19 12:16 ziplib\inffast.h
文件 6343 2002-11-25 07:44 ziplib\inffixed.h
文件 52623 2010-01-24 16:27 ziplib\inflate.c
文件 6399 2009-12-26 08:32 ziplib\inflate.h
文件 13769 2010-04-20 12:12 ziplib\inftrees.c
文件 2928 2010-04-19 12:15 ziplib\inftrees.h
文件 7651 2010-01-05 01:31 ziplib\ioapi.c
文件 6837 2010-02-15 19:59 ziplib\ioapi.h
文件 11903 2010-02-15 19:58 ziplib\iowin32.c
文件 851 2010-02-15 19:58 ziplib\iowin32.h
文件 7859 2010-01-02 13:46 ziplib\mztools.c
文件 677 2005-07-13 18:08 ziplib\mztools.h
文件 1147 2016-08-03 11:04 ziplib\ReadMe.txt
文件 45242 2010-04-19 12:03 ziplib\trees.c
文件 8472 2010-04-19 01:32 ziplib\trees.h
文件 1994 2010-01-18 01:34 ziplib\uncompr.c
............此处省略10个文件信息
评论
共有 条评论