diff options
author | Dan McGee <dan@archlinux.org> | 2011-08-24 13:24:42 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-28 19:51:54 -0500 |
commit | de43d00db071a04653cff592607647bb9c01d025 (patch) | |
tree | 9ad6cc271d87124a6d8004a76e53f16f052d222c /src | |
parent | 12387ca4e5c16994bacad52c142ef94868ba545a (diff) | |
download | pacman-de43d00db071a04653cff592607647bb9c01d025.tar.xz |
Refactor signature result return format
I was trying to take a shortcut and not introduce a wrapper struct for
the signature results, so packed it all into alpm_sigresult_t in the
first iteration. However, this is painful when one wants to add new
fields or only return information regarding a single signature.
Refactor the type into a few components which are exposed to the end
user, and will allow a lot more future flexibility. This also exposes
more information regarding the key to the frontend than was previously
available.
The "private" void *data pointer is used by the library to store the
actual key object returned by gpgme; it is typed this way so the
frontend has no expectations of what is there, and so we don't have any
hard gpgme requirement in our public API.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/package.c | 8 | ||||
-rw-r--r-- | src/pacman/util.c | 15 | ||||
-rw-r--r-- | src/pacman/util.h | 2 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c index 80c6bf2f..a8c15eb8 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -149,17 +149,17 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra) alpm_pkg_get_base64_sig(pkg) ? _("Yes") : _("None")); } if(from == PKG_FROM_FILE) { - alpm_sigresult_t result; - int err = alpm_pkg_check_pgp_signature(pkg, &result); + alpm_siglist_t siglist; + int err = alpm_pkg_check_pgp_signature(pkg, &siglist); if(err && alpm_errno(config->handle) == ALPM_ERR_SIG_MISSING) { string_display(_("Signatures :"), _("None")); } else if(err) { string_display(_("Signatures :"), alpm_strerror(alpm_errno(config->handle))); } else { - signature_display(_("Signatures :"), &result); + signature_display(_("Signatures :"), &siglist); } - alpm_sigresult_cleanup(&result); + alpm_siglist_cleanup(&siglist); } string_display(_("Description :"), alpm_pkg_get_desc(pkg)); diff --git a/src/pacman/util.c b/src/pacman/util.c index cb62ec66..47fbaeb5 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -669,7 +669,7 @@ void list_display_linebreak(const char *title, const alpm_list_t *list) } } -void signature_display(const char *title, alpm_sigresult_t *result) +void signature_display(const char *title, alpm_siglist_t *siglist) { int len = 0; @@ -677,13 +677,14 @@ void signature_display(const char *title, alpm_sigresult_t *result) len = string_length(title) + 1; printf("%s ", title); } - if(result->count == 0) { + if(siglist->count == 0) { printf(_("None")); } else { - int i; - for(i = 0; i < result->count; i++) { + size_t i; + for(i = 0; i < siglist->count; i++) { char sigline[PATH_MAX]; const char *status, *validity, *name; + alpm_sigresult_t *result = siglist->results + i; /* Don't re-indent the first result */ if(i != 0) { int j; @@ -691,7 +692,7 @@ void signature_display(const char *title, alpm_sigresult_t *result) printf(" "); } } - switch(result->status[i]) { + switch(result->status) { case ALPM_SIGSTATUS_VALID: status = _("Valid"); break; @@ -711,7 +712,7 @@ void signature_display(const char *title, alpm_sigresult_t *result) status = _("Signature error"); break; } - switch(result->validity[i]) { + switch(result->validity) { case ALPM_SIGVALIDITY_FULL: validity = _("full trust"); break; @@ -726,7 +727,7 @@ void signature_display(const char *title, alpm_sigresult_t *result) validity = _("unknown trust"); break; } - name = result->uid[i] ? result->uid[i] : _("{Key Unknown}"); + name = result->key.uid ? result->key.uid : result->key.fingerprint; snprintf(sigline, PATH_MAX, _("%s, %s from \"%s\""), status, validity, name); indentprint(sigline, len); diff --git a/src/pacman/util.h b/src/pacman/util.h index f9f1485f..66698474 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -57,7 +57,7 @@ double humanize_size(off_t bytes, const char target_unit, const char **label); int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows); void list_display(const char *title, const alpm_list_t *list); void list_display_linebreak(const char *title, const alpm_list_t *list); -void signature_display(const char *title, alpm_sigresult_t *result); +void signature_display(const char *title, alpm_siglist_t *siglist); void display_targets(const alpm_list_t *pkgs, int install); int str_cmp(const void *s1, const void *s2); void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg); |