Skip to content

Commit

Permalink
add solv_chksum_cmp()
Browse files Browse the repository at this point in the history
To compare two checksums.
  • Loading branch information
mlschroe committed Aug 28, 2015
1 parent d7d634f commit 8b0605a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/chksum.c
Expand Up @@ -259,3 +259,16 @@ solv_chksum_free(Chksum *chk, unsigned char *cp)
return 0;
}

int
solv_chksum_cmp(Chksum *chk, Chksum *chk2)
{
int len;
const unsigned char *res1, *res2;
if (chk == chk2)
return 1;
if (!chk || !chk2 || chk->type != chk2->type)
return 0;
res1 = solv_chksum_get(chk, &len);
res2 = solv_chksum_get(chk2, 0);
return memcmp(res1, res2, len) == 0 ? 1 : 0;
}
1 change: 1 addition & 0 deletions src/chksum.h
Expand Up @@ -28,6 +28,7 @@ void *solv_chksum_free(Chksum *chk, unsigned char *cp);
const char *solv_chksum_type2str(Id type);
Id solv_chksum_str2type(const char *str);
int solv_chksum_len(Id type);
int solv_chksum_cmp(Chksum *chk, Chksum *chk2);

#ifdef LIBSOLV_INTERNAL

Expand Down

0 comments on commit 8b0605a

Please sign in to comment.