************************************************************

NAME

librock_z_adler32 - Checksum function from zlib
librock_z_crc32 - Checksum function from zlib

SYNOPSIS

These functions do not perform compress/uncompress, but they are used for integrity checks.
#include <librock/zlib.h>

librock_z_uLong  
librock_z_adler32(librock_z_uLong adler,
                   const librock_z_Bytef *buf,
                   librock_z_uInt len);
Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster. Usage example:

     librock_z_uLong adler = librock_z_adler32(0L, librock_z_Z_NULL, 0);

     while (read_buffer(buffer, length) != EOF) {
       adler = librock_z_adler32(adler, buffer, length);
     }
     if (adler != original_adler) error();


librock_z_uLong  
librock_z_crc32(librock_z_uLong crc,
                   const librock_z_Bytef *buf,
                   librock_z_uInt len);
Update a running crc with the bytes buf[0..len-1] and return the updated crc. If buf is NULL, this function returns the required initial value for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. This means that the required initial value is 0, but the code below has the recommended initialization.

Note that librock already includes a function librock_CRC32, with a very similar implementation. Since the API is slightly different, they are not replacement compatible.

Usage example:


     librock_z_uLong crc = librock_z_crc32(0L, librock_Z_NULL, 0);

     while (read_buffer(buffer, length) != EOF) {
       crc = librock_z_crc32(crc, buffer, length);
     }
     if (crc != original_crc) error();



USES

//No external calls

MT Behavior

All functions are well-behaved in multi-threaded environments. The library does not install any signal handler, and returns error codes instead of exiting or throwing exceptions. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input.

LICENSE

    Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
  Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block.
  License, originals, details: http://www.mibsoftware.com/librock/

Source Code

./librock/zlib.h (source of this manual page)
./acquired/zlib/zlib-1.1.3/adler32.c
./data/compress/zlib/../../../acquired/zlib/zlib-1.1.3/crc32.c