#include <librock/zlib.h> librock_z_uLong librock_z_adler32(librock_z_uLong adler, const librock_z_Bytef *buf, librock_z_uInt len);
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);
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();
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/