Librepo library  1.7.13
C library for downloading linux repository metadata and packages
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules
Checksum calculation and checking

Enumerations

enum  LrChecksumType {
  LR_CHECKSUM_UNKNOWN, LR_CHECKSUM_MD5, LR_CHECKSUM_SHA1, LR_CHECKSUM_SHA224,
  LR_CHECKSUM_SHA256, LR_CHECKSUM_SHA384, LR_CHECKSUM_SHA512
}
 

Functions

LrChecksumType lr_checksum_type (const char *type)
 
const char * lr_checksum_type_to_str (LrChecksumType type)
 
char * lr_checksum_fd (LrChecksumType type, int fd, GError **err)
 
gboolean lr_checksum_fd_cmp (LrChecksumType type, int fd, const char *expected, gboolean caching, gboolean *matches, GError **err)
 
gboolean lr_checksum_fd_compare (LrChecksumType type, int fd, const char *expected, gboolean caching, gboolean *matches, gchar **calculated, GError **err)
 

Detailed Description

Enumeration Type Documentation

Enum of supported checksum types. NOTE! This enum guarantee to be sorted by "hash quality"

Definition at line 36 of file checksum.h.

Function Documentation

char* lr_checksum_fd ( LrChecksumType  type,
int  fd,
GError **  err 
)

Calculate checksum for data pointed by file descriptor.

Parameters
typeChecksum type
fdOpened file descriptor. Function seeks to the begin of the file.
errGError **
Returns
Malloced checksum string or NULL on error.
gboolean lr_checksum_fd_cmp ( LrChecksumType  type,
int  fd,
const char *  expected,
gboolean  caching,
gboolean *  matches,
GError **  err 
)

Calculate checksum for data pointed by file descriptor and compare it to the expected checksum value.

Parameters
typeChecksum type
fdFile descriptor
expectedString with expected checksum value
cachingCache/Use cached checksum value as extended file attr.
matchesSet pointed variable to TRUE if checksum matches.
errGError **
Returns
returns TRUE if error is not set and FALSE if it is
gboolean lr_checksum_fd_compare ( LrChecksumType  type,
int  fd,
const char *  expected,
gboolean  caching,
gboolean *  matches,
gchar **  calculated,
GError **  err 
)

Calculate checksum for data pointed by file descriptor and compare it to the expected checksum value.

Parameters
typeChecksum type
fdFile descriptor
expectedString with expected checksum value
cachingCache/Use cached checksum value as extended file attr.
matchesSet pointed variable to TRUE if checksum matches.
calculatedIf not NULL, the calculated checksum will be pointed here, the pointed string must be freed by caller.
errGError **
Returns
returns TRUE if error is not set and FALSE if it is
LrChecksumType lr_checksum_type ( const char *  type)

Convert checksum name (string) to LrChecksumType.

Parameters
typeString with a checksum name (e.g. "sha1", "SHA256", ...)
Returns
LrChecksumType value representing the checksum or LR_CHECKSUM_UNKNOWN
const char* lr_checksum_type_to_str ( LrChecksumType  type)

Convert LrChecksumType to string

Parameters
typeChecksum type
Returns
Constant string with name of the checksum