Back to index

plt-scheme  4.2.1
Defines | Functions
adler32.c File Reference
#include "zlib.h"

Go to the source code of this file.

Defines

#define BASE   65521L /* largest prime smaller than 65536 */
#define NMAX   5552
#define DO1(buf, i)   {s1 += buf[i]; s2 += s1;}
#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 DO16(buf)   DO8(buf,0); DO8(buf,8);

Functions

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

Define Documentation

#define BASE   65521L /* largest prime smaller than 65536 */

Definition at line 10 of file adler32.c.

#define DO1 (   buf,
  i 
)    {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,
  i 
)    DO1(buf,i); DO1(buf,i+1);

Definition at line 15 of file adler32.c.

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

Definition at line 16 of file adler32.c.

#define DO8 (   buf,
  i 
)    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.

{
    unsigned long s1 = adler & 0xffff;
    unsigned long s2 = (adler >> 16) & 0xffff;
    int k;

    if (buf == Z_NULL) return 1L;

    while (len > 0) {
        k = len < NMAX ? len : NMAX;
        len -= k;
        while (k >= 16) {
            DO16(buf);
           buf += 16;
            k -= 16;
        }
        if (k != 0) do {
            s1 += *buf++;
           s2 += s1;
        } while (--k);
        s1 %= BASE;
        s2 %= BASE;
    }
    return (s2 << 16) | s1;
}

Here is the caller graph for this function: