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 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

  fd | File descriptor

## lr_checksum_fd()

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

Calculate checksum for data pointed by file descriptor.

Parameters

  type | Checksum type
  fd | Opened file descriptor. Function seeks to the begin of the file.
  err | GError **

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

  type | Checksum type
  fd | File descriptor
  expected | String with expected checksum value
  caching | Cache/Use cached checksum value as extended file attr.
  matches | Set pointed variable to TRUE if checksum matches.
  err | GError **

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

  type | Checksum type
  fd | File descriptor
  expected | String with expected checksum value
  caching | Cache/Use cached checksum value as extended file attr.
  matches | Set pointed variable to TRUE if checksum matches.
  calculated | If not NULL, the calculated checksum will be pointed here, the pointed string must be freed by caller.
  err | GError **

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

  type | String 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

  type | Checksum type

Returns
  Constant string with name of the checksum