This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-goldedplus/goldlib/uulib/crc32.h

32 lines
588 B
C
Raw Normal View History

2002-06-10 06:13:37 +00:00
#ifndef __crc32_h
#define __crc32_h
/* crc32.h */
/* wrapper for gall library */
typedef unsigned long crc32_t;
#define Z_NULL 0
#define byte(a) ((unsigned char)(a))
extern crc32_t __crc32_table[256];
static crc32_t updCrc32(unsigned char ch, crc32_t crc)
{
return (crc32_t)(__crc32_table[byte(crc) ^ byte(ch)] ^ (crc >> 8));
}
static crc32_t crc32(crc32_t crc, const unsigned char *buf, unsigned int len)
{
if (buf == Z_NULL) return 0L;
crc = crc ^ 0xffffffffL;
while (len--)
{
crc = updCrc32(*buf++, crc);
}
return crc ^ 0xffffffffL;
}
#endif /* __crc32_h */