ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/crc32.h
(Generate patch)

Comparing Convert-UUlib/uulib/crc32.h (file contents):
Revision 1.5 by root, Thu Feb 27 16:17:16 2020 UTC vs.
Revision 1.6 by root, Sat Sep 24 10:55:41 2022 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines