XRootD
Loading...
Searching...
No Matches
XrdCksCalccrc32C.cc
Go to the documentation of this file.
2
3/*
4 C++ implementation of CRC-32C checksums based upon
5 unattributed library functions.
6
7 This file contains:
8 functions implementing the methods of the XrdCksCalc class
9
10 Provided by:
11 Anton Schwarz
12 University of Heidelberg
13 July 26, 2021
14
15 Status:
16 Public Domain
17
18*/
19
20/******************************************************************************/
21/* C o m b i n e V 1 */
22/******************************************************************************/
23
24const char* XrdCksCalccrc32C::Combine(const char* Cksum, int DLen)
25{
26 uint32_t crc2;
27 memcpy(&crc2, Cksum, sizeof(crc2));
28
29#ifndef Xrd_Big_Endian
30 crc2 = ntohl(crc2);
31#endif
32
33 C32CResult = XrdOucCRC::Combine32C(C32CResult, crc2, (size_t)DLen);
34 return Final();
35}
36
37/******************************************************************************/
38/* C o m b i n e V 2 */
39/******************************************************************************/
40
41const char* XrdCksCalccrc32C::Combine(const char* Cksum1, const char* Cksum2,
42 int DLen)
43{
44 uint32_t crc1, crc2;
45 memcpy(&crc1, Cksum1, sizeof(crc1));
46 memcpy(&crc2, Cksum2, sizeof(crc2));
47
48#ifndef Xrd_Big_Endian
49 crc1 = ntohl(crc1);
50 crc2 = ntohl(crc2);
51#endif
52
53 TheResult = XrdOucCRC::Combine32C(crc1, crc2, (size_t)DLen);
54
55#ifndef Xrd_Big_Endian
56 TheResult = htonl(TheResult);
57#endif
58 return (char *)&TheResult;
59}
60
61/******************************************************************************/
62/* F i n a l */
63/******************************************************************************/
64
66{
67 TheResult = C32CResult;
68#ifndef Xrd_Big_Endian
69 TheResult = htonl(TheResult);
70#endif
71 return (char *)&TheResult;
72}
73
74/******************************************************************************/
75/* N e w */
76/******************************************************************************/
77
80
81/******************************************************************************/
82/* U p d a t e */
83/******************************************************************************/
84
85void XrdCksCalccrc32C::Update(const char *Buff, int BLen)
86{
87 C32CResult = (unsigned int)XrdOucCRC::Calc32C(Buff, BLen, C32CResult);
88}
XrdCksCalc()
Constructor.
XrdCksCalc * New() override
void Update(const char *Buff, int BLen) override
char * Final() override
const char * Combine(const char *Cksum, int DLen) override
static uint32_t Combine32C(uint32_t Cksum1, uint32_t Cksum2, int DLen)
Definition XrdOucCRC.cc:222
static uint32_t Calc32C(const void *data, size_t count, uint32_t prevcs=0)
Definition XrdOucCRC.cc:190