Remove _alpm_csum

The enum alpm_pkgvalidation_t is essentially a more generic version
of _alpm_csum, so use it instead.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2012-02-20 14:24:35 +10:00 committed by Dan McGee
parent 5c404268d9
commit 4773c6b66e
5 changed files with 8 additions and 13 deletions

View File

@ -340,7 +340,7 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
if(syncpkg->md5sum && !syncpkg->sha256sum) {
_alpm_log(handle, ALPM_LOG_DEBUG, "md5sum: %s\n", syncpkg->md5sum);
_alpm_log(handle, ALPM_LOG_DEBUG, "checking md5sum for %s\n", pkgfile);
if(_alpm_test_checksum(pkgfile, syncpkg->md5sum, ALPM_CSUM_MD5) != 0) {
if(_alpm_test_checksum(pkgfile, syncpkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM) != 0) {
RET_ERR(handle, ALPM_ERR_PKG_INVALID_CHECKSUM, -1);
}
if(validation) {
@ -351,7 +351,7 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
if(syncpkg->sha256sum) {
_alpm_log(handle, ALPM_LOG_DEBUG, "sha256sum: %s\n", syncpkg->sha256sum);
_alpm_log(handle, ALPM_LOG_DEBUG, "checking sha256sum for %s\n", pkgfile);
if(_alpm_test_checksum(pkgfile, syncpkg->sha256sum, ALPM_CSUM_SHA256) != 0) {
if(_alpm_test_checksum(pkgfile, syncpkg->sha256sum, ALPM_PKG_VALIDATION_SHA256SUM) != 0) {
RET_ERR(handle, ALPM_ERR_PKG_INVALID_CHECKSUM, -1);
}
if(validation) {

View File

@ -67,7 +67,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
fpath = _alpm_filecache_find(pkg->handle, pkg->filename);
retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_CSUM_MD5);
retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM);
if(retval == 0) {
return 0;

View File

@ -780,7 +780,7 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas)
alpm_delta_t *d = i->data;
char *filepath = _alpm_filecache_find(handle, d->delta);
if(_alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5)) {
if(_alpm_test_checksum(filepath, d->delta_md5, ALPM_PKG_VALIDATION_MD5SUM)) {
errors = alpm_list_add(errors, filepath);
} else {
FREE(filepath);

View File

@ -909,14 +909,14 @@ char SYMEXPORT *alpm_compute_sha256sum(const char *filename)
* error
*/
int _alpm_test_checksum(const char *filepath, const char *expected,
enum _alpm_csum type)
alpm_pkgvalidation_t type)
{
char *computed;
int ret;
if(type == ALPM_CSUM_MD5) {
if(type == ALPM_PKG_VALIDATION_MD5SUM) {
computed = alpm_compute_md5sum(filepath);
} else if(type == ALPM_CSUM_SHA256) {
} else if(type == ALPM_PKG_VALIDATION_SHA256SUM) {
computed = alpm_compute_sha256sum(filepath);
} else {
return -1;

View File

@ -105,11 +105,6 @@ struct archive_read_buffer {
int ret;
};
enum _alpm_csum {
ALPM_CSUM_MD5,
ALPM_CSUM_SHA256,
};
int _alpm_makepath(const char *path);
int _alpm_makepath_mode(const char *path, mode_t mode);
int _alpm_copyfile(const char *src, const char *dest);
@ -130,7 +125,7 @@ int _alpm_str_cmp(const void *s1, const void *s2);
char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
const char *_alpm_filecache_setup(alpm_handle_t *handle);
int _alpm_lstat(const char *path, struct stat *buf);
int _alpm_test_checksum(const char *filepath, const char *expected, enum _alpm_csum type);
int _alpm_test_checksum(const char *filepath, const char *expected, alpm_pkgvalidation_t type);
int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b);
int _alpm_splitname(const char *target, char **name, char **version,
unsigned long *name_hash);