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 (20 months, 1 week 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

# User Rev Content
1 root 1.1 #ifndef __CRC32_H__
2     #define __CRC32_H__
3    
4 root 1.4 #include "ecb.h"
5 root 1.6 #include "uuint.h"
6 root 1.4
7 root 1.1 #ifdef __cplusplus
8     extern "C" {
9     #endif
10    
11 root 1.4 typedef uint32_t crc32_t;
12 root 1.1
13 root 1.4 #define CRC32_INIT ((crc32_t)0)
14 root 1.2
15 root 1.1 /*
16 root 1.6 * 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 root 1.1
31 root 1.6 /*
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 root 1.5
38 root 1.1 #ifdef __cplusplus
39     }
40     #endif
41     #endif