summaryrefslogtreecommitdiff
path: root/src/pacman
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-16 13:15:11 -0500
committerDan McGee <dan@archlinux.org>2011-06-22 12:31:12 -0500
commit54ef162a1a9e27e362732d873f0739bc0a2cf1bf (patch)
treee4ec6ba0ab94965c754a40d52a680f9fd69c4e37 /src/pacman
parent886a31ef205923fd5b29012ee75932a2e2dec4bd (diff)
Convert backup list to new pmbackup_t type
This allows us to separate the name and hash elements in one place and not scatter different parsing code all over the place, including both the frontend and backend. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman')
-rw-r--r--src/pacman/package.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 9cdb4877..32156c53 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -151,12 +151,12 @@ void dump_pkg_full(pmpkg_t *pkg, enum pkg_from from, int extra)
}
static const char *get_backup_file_status(const char *root,
- const char *filename, const char *expected_md5)
+ const pmbackup_t *backup)
{
char path[PATH_MAX];
const char *ret;
- snprintf(path, PATH_MAX, "%s%s", root, filename);
+ snprintf(path, PATH_MAX, "%s%s", root, backup->name);
/* if we find the file, calculate checksums, otherwise it is missing */
if(access(path, R_OK) == 0) {
@@ -169,7 +169,7 @@ static const char *get_backup_file_status(const char *root,
}
/* if checksums don't match, file has been modified */
- if(strcmp(md5sum, expected_md5) != 0) {
+ if(strcmp(md5sum, backup->hash) != 0) {
ret = "MODIFIED";
} else {
ret = "UNMODIFIED";
@@ -200,18 +200,13 @@ void dump_pkg_backups(pmpkg_t *pkg)
if(alpm_pkg_get_backup(pkg)) {
/* package has backup files, so print them */
for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
+ const pmbackup_t *backup = alpm_list_getdata(i);
const char *value;
- char *str = strdup(alpm_list_getdata(i));
- char *ptr = strchr(str, '\t');
- if(ptr == NULL) {
- free(str);
+ if(!backup->hash) {
continue;
}
- *ptr = '\0';
- ptr++;
- value = get_backup_file_status(root, str, ptr);
- printf("%s\t%s%s\n", value, root, str);
- free(str);
+ value = get_backup_file_status(root, backup);
+ printf("%s\t%s%s\n", value, root, backup->name);
}
} else {
/* package had no backup files */