dmlite  0.6
Functions
dmlite::checksums Namespace Reference

Functions

std::string fullChecksumName (const std::string &cs)
 
std::string shortChecksumName (const std::string &cs)
 
bool isChecksumFullName (const std::string &ckey)
 Tells if the given key looks like the name of a checksum. More...
 
int fillChecksumInXattr (ExtendedStat &xstat)
 
std::string md5 (IOHandler *io, off_t offset=0, off_t size=0)
 
std::string crc32 (IOHandler *io, off_t offset=0, off_t size=0)
 
std::string adler32 (IOHandler *io, off_t offset=0, off_t size=0)
 
std::string hexPrinter (const unsigned char *data, size_t nbytes)
 
std::string decPrinter (const unsigned char *data, size_t nbytes)
 

Function Documentation

std::string dmlite::checksums::adler32 ( IOHandler *  io,
off_t  offset = 0,
off_t  size = 0 
)

Returns the Adler32 checksum of the data contained on the IO handler in hexadecimal format.

Parameters
ioThe IO handler to be digested. The read/write possition will be moved!
offsetWhere to start to digest.
sizeThe number of bytes to digest. 0 means the whole file.
Returns
The Adler32 checkum in base 16
std::string dmlite::checksums::crc32 ( IOHandler *  io,
off_t  offset = 0,
off_t  size = 0 
)

Returns the CRC checksum of the data contained on the IO handler (as zlib crc32) in base 10 format.

Parameters
ioThe IO handler to be digested. The read/write possition will be moved!
offsetWhere to start to digest.
sizeThe number of bytes to digest. 0 means the whole file.
Returns
The CRC checkum in base 10
std::string dmlite::checksums::decPrinter ( const unsigned char *  data,
size_t  nbytes 
)

Returns the decimal representation of the data, separated by spaces (num1 num2 num3)

Parameters
dataThe data to dump to decimal representation.
nbytesThe number of bytes in data
Note
It assumes data is an array of 'unsigned long'
int dmlite::checksums::fillChecksumInXattr ( ExtendedStat &  xstat)

Makes sure that the extended attributes contain the legacy checksum.

Parameters
xstatThe stat information to be modified
Returns
Zero if the xattrs were not modified
std::string dmlite::checksums::fullChecksumName ( const std::string &  cs)

To be used internally by the plug-ins that need to deal with the legacy-style stored checksums.

Note
AD => ADLER32
CS => CRC32
MD => MD5 (RFC 3230)
Any other is left as is
std::string dmlite::checksums::hexPrinter ( const unsigned char *  data,
size_t  nbytes 
)

Returns the hexadecimal representation of the data

Parameters
dataThe data to dump to hexadecimal representation.
nbytesThe number of bytes in data
bool dmlite::checksums::isChecksumFullName ( const std::string &  ckey)

Tells if the given key looks like the name of a checksum.

std::string dmlite::checksums::md5 ( IOHandler *  io,
off_t  offset = 0,
off_t  size = 0 
)

Returns the MD5 checksum of the data contained on the IO handler in hexadecimal format.

Parameters
ioThe IO handler to be digested. The read/write possition will be moved!
offsetWhere to start to digest.
sizeThe number of bytes to digest. 0 means the whole file.
Returns
The MD5 checkum in base 16
std::string dmlite::checksums::shortChecksumName ( const std::string &  cs)

Inverse of fullChecksumName This should eventually disappear, once the backends can deal with full checksum names.