XRootD
XrdCl::CheckSumHelper Class Reference

Check sum helper for stdio. More...

#include <XrdClCheckSumHelper.hh>

+ Collaboration diagram for XrdCl::CheckSumHelper:

Public Member Functions

 CheckSumHelper (const std::string &name, const std::string &ckSumType)
 Constructor. More...
 
virtual ~CheckSumHelper ()
 Destructor. More...
 
XRootDStatus GetCheckSum (std::string &checkSum, std::string &checkSumType)
 
template<typename T >
XRootDStatus GetRawCheckSum (const std::string &checkSumType, T &value)
 
const std::string & GetType ()
 
XRootDStatus Initialize ()
 Initialize. More...
 
void Update (const void *buffer, uint32_t size)
 

Detailed Description

Check sum helper for stdio.

Definition at line 25 of file XrdClCheckSumHelper.hh.

Constructor & Destructor Documentation

◆ CheckSumHelper()

XrdCl::CheckSumHelper::CheckSumHelper ( const std::string &  name,
const std::string &  ckSumType 
)
inline

Constructor.

Definition at line 31 of file XrdClCheckSumHelper.hh.

32  :
33  pName( name ),
34  pCkSumType( ckSumType ),
35  pCksCalcObj( 0 )
36  {};

◆ ~CheckSumHelper()

virtual XrdCl::CheckSumHelper::~CheckSumHelper ( )
inlinevirtual

Destructor.

Definition at line 41 of file XrdClCheckSumHelper.hh.

42  {
43  delete pCksCalcObj;
44  }

Member Function Documentation

◆ GetCheckSum()

XRootDStatus XrdCl::CheckSumHelper::GetCheckSum ( std::string &  checkSum,
std::string &  checkSumType 
)
inline

Definition at line 86 of file XrdClCheckSumHelper.hh.

88  {
89  using namespace XrdCl;
90  Log *log = DefaultEnv::GetLog();
91 
92  int calcSize = 0;
93  auto st = GetCheckSumImpl( checkSumType, calcSize );
94  if( !st.IsOK() ) return st;
95 
96  //----------------------------------------------------------------------
97  // Response
98  //----------------------------------------------------------------------
99  XrdCksData ckSum;
100  ckSum.Set( checkSumType.c_str() );
101  ckSum.Set( (void*)pCksCalcObj->Final(), calcSize );
102  char *cksBuffer = new char[265];
103  ckSum.Get( cksBuffer, 256 );
104  checkSum = checkSumType + ":";
105  checkSum += Utils::NormalizeChecksum( checkSumType, cksBuffer );
106  delete [] cksBuffer;
107 
108  log->Dump( UtilityMsg, "Checksum for %s is: %s", pName.c_str(),
109  checkSum.c_str() );
110  return XRootDStatus();
111  }
int Set(const char *csName)
Definition: XrdCksData.hh:81
int Get(char *Buff, int Blen)
Definition: XrdCksData.hh:69
static Log * GetLog()
Get default log.
Handle diagnostics.
Definition: XrdClLog.hh:101
void Dump(uint64_t topic, const char *format,...)
Print a dump message.
Definition: XrdClLog.cc:299
static std::string NormalizeChecksum(const std::string &name, const std::string &checksum)
Normalize checksum.
Definition: XrdClUtils.cc:648
const uint64_t UtilityMsg

References XrdCl::Log::Dump(), XrdCksData::Get(), XrdCl::DefaultEnv::GetLog(), XrdCl::Utils::NormalizeChecksum(), XrdCksData::Set(), and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

◆ GetRawCheckSum()

template<typename T >
XRootDStatus XrdCl::CheckSumHelper::GetRawCheckSum ( const std::string &  checkSumType,
T &  value 
)
inline

Definition at line 114 of file XrdClCheckSumHelper.hh.

115  {
116  int calcSize = 0;
117  auto st = GetCheckSumImpl( checkSumType, calcSize );
118  if( !st.IsOK() ) return st;
119  if( sizeof( T ) != calcSize )
120  return XRootDStatus( stError, errInvalidArgs, 0,
121  "checksum size mismatch" );
122  value = *reinterpret_cast<T*>( pCksCalcObj->Final() );
123  return XRootDStatus();
124  }
virtual char * Final()=0
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errInvalidArgs
Definition: XrdClStatus.hh:58

References XrdCl::errInvalidArgs, XrdCksCalc::Final(), and XrdCl::stError.

+ Here is the call graph for this function:

◆ GetType()

const std::string& XrdCl::CheckSumHelper::GetType ( )
inline

Definition at line 126 of file XrdClCheckSumHelper.hh.

127  {
128  return pCkSumType;
129  }

◆ Initialize()

XRootDStatus XrdCl::CheckSumHelper::Initialize ( )
inline

Initialize.

Definition at line 49 of file XrdClCheckSumHelper.hh.

50  {
51  if( pCkSumType.empty() )
52  return XRootDStatus();
53 
54  Log *log = DefaultEnv::GetLog();
56 
57  if( !cksMan )
58  {
59  log->Error( UtilityMsg, "Unable to get the checksum manager" );
60  return XRootDStatus( stError, errInternal );
61  }
62 
63  pCksCalcObj = cksMan->GetCalculator( pCkSumType );
64  if( !pCksCalcObj )
65  {
66  log->Error( UtilityMsg, "Unable to get a calculator for %s",
67  pCkSumType.c_str() );
69  }
70 
71  return XRootDStatus();
72  }
Manage the checksum calc objects.
XrdCksCalc * GetCalculator(const std::string &algName)
static CheckSumManager * GetCheckSumManager()
Get checksum manager.
void Error(uint64_t topic, const char *format,...)
Report an error.
Definition: XrdClLog.cc:231
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:56
const uint16_t errCheckSumError
Definition: XrdClStatus.hh:101

References XrdCl::errCheckSumError, XrdCl::errInternal, XrdCl::Log::Error(), XrdCl::CheckSumManager::GetCalculator(), XrdCl::DefaultEnv::GetCheckSumManager(), XrdCl::DefaultEnv::GetLog(), XrdCl::stError, and XrdCl::UtilityMsg.

+ Here is the call graph for this function:

◆ Update()

void XrdCl::CheckSumHelper::Update ( const void *  buffer,
uint32_t  size 
)
inline

Definition at line 77 of file XrdClCheckSumHelper.hh.

78  {
79  if( pCksCalcObj )
80  pCksCalcObj->Update( (const char *)buffer, size );
81  }
virtual void Update(const char *Buff, int BLen)=0

References XrdCksCalc::Update().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: