ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/crc32.h
Revision: 1.6
Committed: Sat Sep 24 10:55:41 2022 UTC (19 months, 3 weeks ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +21 -23 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #ifndef __CRC32_H__
2 #define __CRC32_H__
3
4 #include "ecb.h"
5 #include "uuint.h"
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 typedef uint32_t crc32_t;
12
13 #define CRC32_INIT ((crc32_t)0)
14
15 /*
16 * Update a running crc with the bytes buf[0..len-1] and return the updated
17 * crc. If buf is NULL, this function returns the required initial value
18 * for the crc. Pre- and post-conditioning (one's complement) is performed
19 * within this function so it shouldn't be done by the application.
20 * Usage example:
21 *
22 * uLong crc = CRC32_INIT;
23 *
24 * while (read_buffer (buffer, length) != EOF) {
25 * crc = crc32 (crc, buffer, length);
26 * }
27 * if (crc != original_crc) error ();
28 */
29 UULIBINT_FUNC crc32_t uu_crc32 (crc32_t prev, const void *data, unsigned int len);
30
31 /*
32 * This calculates the crc of a block of data consisting of two
33 * parts, using only their CRCs. This is used to quickly combine
34 * part CRCs into a full file CRC.
35 */
36 UULIBINT_FUNC uint32_t uu_crc32_combine (uint32_t crcA, uint32_t crcB, size_t lengthB);
37
38 #ifdef __cplusplus
39 }
40 #endif
41 #endif