src/utilfuns/zlib/adler32.c File Reference

#include "zlib.h"
Include dependency graph for adler32.c:

Go to the source code of this file.

Defines

#define BASE   65521L
#define DO1(buf, i)   {s1 += buf[i]; s2 += s1;}
#define DO16(buf)   DO8(buf,0); DO8(buf,8);
#define DO2(buf, i)   DO1(buf,i); DO1(buf,i+1);
#define DO4(buf, i)   DO2(buf,i); DO2(buf,i+2);
#define DO8(buf, i)   DO4(buf,i); DO4(buf,i+4);
#define NMAX   5552

Functions

uLong ZEXPORT adler32 (uLong adler, const Bytef *buf, uInt len)

Define Documentation

#define BASE   65521L

Definition at line 10 of file adler32.c.

#define DO1 ( buf,
 )     {s1 += buf[i]; s2 += s1;}

Definition at line 14 of file adler32.c.

#define DO16 ( buf   )     DO8(buf,0); DO8(buf,8);

Definition at line 18 of file adler32.c.

#define DO2 ( buf,
 )     DO1(buf,i); DO1(buf,i+1);

Definition at line 15 of file adler32.c.

#define DO4 ( buf,
 )     DO2(buf,i); DO2(buf,i+2);

Definition at line 16 of file adler32.c.

#define DO8 ( buf,
 )     DO4(buf,i); DO4(buf,i+4);

Definition at line 17 of file adler32.c.

#define NMAX   5552

Definition at line 11 of file adler32.c.


Function Documentation

uLong ZEXPORT adler32 ( uLong  adler,
const Bytef buf,
uInt  len 
)

Definition at line 21 of file adler32.c.

00025 {
00026     unsigned long s1 = adler & 0xffff;
00027     unsigned long s2 = (adler >> 16) & 0xffff;
00028     int k;
00029 
00030     if (buf == Z_NULL) return 1L;
00031 
00032     while (len > 0) {
00033         k = len < NMAX ? len : NMAX;
00034         len -= k;
00035         while (k >= 16) {
00036             DO16(buf);
00037         buf += 16;
00038             k -= 16;
00039         }
00040         if (k != 0) do {
00041             s1 += *buf++;
00042         s2 += s1;
00043         } while (--k);
00044         s1 %= BASE;
00045         s2 %= BASE;
00046     }
00047     return (s2 << 16) | s1;
00048 }


Generated on 18 Mar 2013 for The SWORD Project by  doxygen 1.6.1