Loading...
Searching...
No Matches
XrdCksCalczcrc32.cc
Go to the documentation of this file.
/******************************************************************************/
/* */
/* X r d C k s C a l c z c r c 3 2 . h h */
/* */
/* Copyright (c) 2012 by European Organization of Nuclear Research (CERN) */
/* Produced by Lukasz Janyst <ljanyst@cern.ch> */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#ifndef __XRDCKSCALCZCRC32_HH__
#define __XRDCKSCALCZCRC32_HH__
#include "XrdCks/XrdCksCalc.hh"
#include "XrdSys/XrdSysError.hh"
#include "XrdVersion.hh"
#include <cstdint>
#include <zlib.h>
//------------------------------------------------------------------------------
// CRC32 checkum according to the algorithm implemented in zlib
//------------------------------------------------------------------------------
class XrdCksCalczcrc32: public XrdCksCalc
{
public:
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
XrdCksCalczcrc32()
{
Init();
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
virtual ~XrdCksCalczcrc32()
{
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
char *Final()
{
return (char *)&pCheckSum;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
void Init()
{
pCheckSum = crc32( 0L, Z_NULL, 0 );
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
XrdCksCalc *New()
{
return new XrdCksCalczcrc32();
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
void Update( const char *Buff, int BLen )
{
pCheckSum = crc32( pCheckSum, (const Bytef*)Buff, BLen );
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
const char *Type(int &csSz)
{
csSz = 4; return "zcrc32";
}
private:
uint32_t pCheckSum;
};
//------------------------------------------------------------------------------
// Plugin callback
//------------------------------------------------------------------------------
extern "C" XrdCksCalc *XrdCksCalcInit(XrdSysError *eDest,
const char *csName,
const char *cFN,
const char *Parms)
{
return new XrdCksCalczcrc32();
}
XrdVERSIONINFO(XrdCksCalcInit, zcrc32);
#endif // __XRDCKSCALCZCRC32_HH__
XrdCksCalc.hh
XrdVERSIONINFO
XrdVERSIONINFO(XrdCksCalcInit, zcrc32)
XrdCksCalcInit
XrdCksCalc * XrdCksCalcInit(XrdSysError *eDest, const char *csName, const char *cFN, const char *Parms)
Definition XrdCksCalczcrc32.cc:107
eDest
static XrdSysError eDest(0,"crypto_")
XrdSysError.hh
XrdCksCalc
Definition XrdCksCalc.hh:40
XrdCksCalc::XrdCksCalc
XrdCksCalc()
Constructor.
Definition XrdCksCalc.hh:123
XrdCksCalczcrc32
Definition XrdCksCalczcrc32.cc:42
XrdCksCalczcrc32::New
XrdCksCalc * New()
Virtual constructor.
Definition XrdCksCalczcrc32.cc:79
XrdCksCalczcrc32::XrdCksCalczcrc32
XrdCksCalczcrc32()
Constructor.
Definition XrdCksCalczcrc32.cc:48
XrdCksCalczcrc32::Init
void Init()
Initialize.
Definition XrdCksCalczcrc32.cc:71
XrdCksCalczcrc32::Type
const char * Type(int &csSz)
Checksum algorithm name.
Definition XrdCksCalczcrc32.cc:95
XrdCksCalczcrc32::Update
void Update(const char *Buff, int BLen)
Update current checksum.
Definition XrdCksCalczcrc32.cc:87
XrdCksCalczcrc32::~XrdCksCalczcrc32
virtual ~XrdCksCalczcrc32()
Destructor.
Definition XrdCksCalczcrc32.cc:56
XrdCksCalczcrc32::Final
char * Final()
Final checksum.
Definition XrdCksCalczcrc32.cc:63
XrdSysError
Definition XrdSysError.hh:90