| Q D E V _ H L P _ F N V 3 2 C S U M ( )
| | | | | SOURCE: qdev_macros.txt 1.16 (12/09/2014) English INDEP - PUBLIC
----------------------------------------------------------------------------
NAME
QDEV_HLP_FNV32CSUM() - Allows to compute FNV1a 32 bit
checksum.
SYNOPSIS
csum = QDEV_HLP_FNV32CSUM(ics, ptr, size);
[ULONG] QDEV_HLP_FNV32CSUM(ULONG, [UBYTE *], [LONG]);
FUNCTION
This macro allows to checksum memory region using FNV
alogorithm. Checksum is 32bit wide.
INPUTS
ics - Hash base initlizer. This can be either FNV own
prime or result from previous macro instance so
that memory can be checksummed in blocks.
ptr - Memory address to start at.
size - Size of that memory region.
RETURNS
Returns 32 bit FNV checksum or the initializer in the
worst case.
BASES
None.
NOTES
None.
SEE ALSO
QDEV_HLP_FNV32HASH()
EXAMPLE
...
#include <proto/dos.h>
#include <qdev.h>
ULONG checksumfnv32(UBYTE *file)
{
UBYTE buf[1024];
ULONG csum = QDEV_HLP_FNV32PRIME;
LONG read;
LONG fd;
if ((fd = Open(file, MODE_OLDFILE)))
{
while ((read = Read(fd, buf, sizeof buf)) > 0)
{
csum = QDEV_HLP_FNV32CSUM(csum, buf, read);
}
Close(fd);
}
return csum;
}
...
BUGS
None known.
----------------------------------------------------------------------------
| |
| |