1 |
root |
1.1 |
#ifndef __CRC32_H__ |
2 |
|
|
#define __CRC32_H__ |
3 |
|
|
|
4 |
|
|
#ifndef _ANSI_ARGS_ |
5 |
|
|
#ifdef PROTOTYPES |
6 |
|
|
#define _ANSI_ARGS_(c) c |
7 |
|
|
#else |
8 |
|
|
#define _ANSI_ARGS_(c) () |
9 |
|
|
#endif |
10 |
|
|
#endif |
11 |
|
|
|
12 |
|
|
#ifdef __cplusplus |
13 |
|
|
extern "C" { |
14 |
|
|
#endif |
15 |
|
|
|
16 |
|
|
typedef unsigned long crc32_t; |
17 |
|
|
#define Z_NULL 0 |
18 |
|
|
|
19 |
|
|
crc32_t crc32 _ANSI_ARGS_((crc32_t crc, const unsigned char *buf, unsigned int len)); |
20 |
|
|
/* |
21 |
|
|
Update a running crc with the bytes buf[0..len-1] and return the updated |
22 |
|
|
crc. If buf is NULL, this function returns the required initial value |
23 |
|
|
for the crc. Pre- and post-conditioning (one's complement) is performed |
24 |
|
|
within this function so it shouldn't be done by the application. |
25 |
|
|
Usage example: |
26 |
|
|
|
27 |
|
|
uLong crc = crc32(0L, Z_NULL, 0); |
28 |
|
|
|
29 |
|
|
while (read_buffer(buffer, length) != EOF) { |
30 |
|
|
crc = crc32(crc, buffer, length); |
31 |
|
|
} |
32 |
|
|
if (crc != original_crc) error(); |
33 |
|
|
*/ |
34 |
|
|
|
35 |
|
|
#ifdef __cplusplus |
36 |
|
|
} |
37 |
|
|
#endif |
38 |
|
|
#endif |