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.3 by root, Mon Aug 24 04:38:23 2009 UTC vs.
Revision 1.4 by root, Thu Feb 27 06:14:28 2020 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines