Librepo library 1.18.0
C library for downloading linux repository metadata and packages
Loading...
Searching...
No Matches
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)
 
void lr_checksum_clear_cache (int fd)
 

Detailed Description

Enumeration Type Documentation

◆ LrChecksumType

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

◆ lr_checksum_clear_cache()

void lr_checksum_clear_cache ( int  fd)

Clear all checksums cached in extended file attributes

Parameters
fdFile descriptor

◆ lr_checksum_fd()

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.

◆ lr_checksum_fd_cmp()

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

◆ lr_checksum_fd_compare()

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

◆ lr_checksum_type()

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

◆ lr_checksum_type_to_str()

const char * lr_checksum_type_to_str ( LrChecksumType  type)

Convert LrChecksumType to string

Parameters
typeChecksum type
Returns
Constant string with name of the checksum