From de43d00db071a04653cff592607647bb9c01d025 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 24 Aug 2011 13:24:42 -0500 Subject: 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 --- src/pacman/util.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/pacman/util.c') 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); -- cgit v1.2.3-54-g00ecf