1 #ifndef __XRDCKSCALCADLER32_HH__
2 #define __XRDCKSCALCADLER32_HH__
33 #include <sys/types.h>
34 #include <netinet/in.h>
75 #define DO1(buf) {unSum1 += *buf++; unSum2 += unSum1;}
76 #define DO2(buf) DO1(buf); DO1(buf);
77 #define DO4(buf) DO2(buf); DO2(buf);
78 #define DO8(buf) DO4(buf); DO4(buf);
79 #define DO16(buf) DO8(buf); DO8(buf);
86 {AdlerValue = (unSum2 << 16) | unSum1;
87 #ifndef Xrd_Big_Endian
88 AdlerValue = htonl(AdlerValue);
90 return (
char *)&AdlerValue;
93 void Init() {unSum1 = AdlerStart; unSum2 = 0;}
97 void Update(
const char *Buff,
int BLen)
99 unsigned char *buff = (
unsigned char *)Buff;
101 {k = (BLen < AdlerNMax ? BLen : AdlerNMax);
103 while(k >= 16) {
DO16(buff); k -= 16;}
104 if (k != 0)
do {
DO1(buff);}
while (--k);
105 unSum1 %= AdlerBase; unSum2 %= AdlerBase;
109 const char *
Type(
int &csSize) {csSize =
sizeof(AdlerValue);
return "adler32";}
116 static const unsigned int AdlerBase = 0xFFF1;
117 static const unsigned int AdlerStart = 0x0001;
118 static const int AdlerNMax = 5552;
122 unsigned int AdlerValue;
void Update(const char *Buff, int BLen)
virtual ~XrdCksCalcadler32()
const char * Type(int &csSize)