Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> --- src/pacman/package.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/pacman/util.c | 88 ---------------------------------------------------- src/pacman/util.h | 4 --- 3 files changed, 88 insertions(+), 92 deletions(-) diff --git a/src/pacman/package.c b/src/pacman/package.c index 3d1b108..ebbade1 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -36,6 +36,24 @@ #define CLBUF_SIZE 4096 +static void string_display(const char *title, const char *string, + unsigned short maxcols) +{ + unsigned short len = 0; + + if(title) { + len = (unsigned short)string_length(title) + 1; + printf("%s%s%s ", config->colstr.title, title, config->colstr.nocolor); + } + + if(string == NULL || string[0] == '\0') { + printf(_("None")); + } else { + indentprint(string, (unsigned short)len, maxcols); + } + printf("\n"); +} + /** Turn a depends list into a text list. * @param deps a list with items of type alpm_depend_t */ @@ -73,6 +91,76 @@ static void optdeplist_display(alpm_pkg_t *pkg, unsigned short maxcols) FREELIST(text); } +static void signature_display(const char *title, alpm_siglist_t *siglist, + unsigned short maxcols) +{ + unsigned short len = 0; + + if(title) { + len = (unsigned short)string_length(title) + 1; + printf("%s%s%s ", config->colstr.title, title, config->colstr.nocolor); + } + + if(siglist->count == 0) { + printf(_("None")); + } else { + size_t i; + for(i = 0; i < siglist->count; i++) { + char *sigline; + const char *status, *validity, *name; + alpm_sigresult_t *result = siglist->results + i; + /* Don't re-indent the first result */ + if(i != 0) { + printf("%-*s", (int)len, ""); + } + switch(result->status) { + case ALPM_SIGSTATUS_VALID: + status = _("Valid"); + break; + case ALPM_SIGSTATUS_KEY_EXPIRED: + status = _("Key expired"); + break; + case ALPM_SIGSTATUS_SIG_EXPIRED: + status = _("Expired"); + break; + case ALPM_SIGSTATUS_INVALID: + status = _("Invalid"); + break; + case ALPM_SIGSTATUS_KEY_UNKNOWN: + status = _("Key unknown"); + break; + case ALPM_SIGSTATUS_KEY_DISABLED: + status = _("Key disabled"); + break; + default: + status = _("Signature error"); + break; + } + switch(result->validity) { + case ALPM_SIGVALIDITY_FULL: + validity = _("full trust"); + break; + case ALPM_SIGVALIDITY_MARGINAL: + validity = _("marginal trust"); + break; + case ALPM_SIGVALIDITY_NEVER: + validity = _("never trust"); + break; + case ALPM_SIGVALIDITY_UNKNOWN: + default: + validity = _("unknown trust"); + break; + } + name = result->key.uid ? result->key.uid : result->key.fingerprint; + pm_asprintf(&sigline, _("%s, %s from \"%s\""), + status, validity, name); + indentprint(sigline, len, maxcols); + printf("\n"); + free(sigline); + } + } +} + /** * Display the details of a package. * Extra information entails 'required by' info for sync packages and backup diff --git a/src/pacman/util.c b/src/pacman/util.c index a5796bb..14e5ae4 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -424,24 +424,6 @@ static size_t string_length(const char *s) return len; } -void string_display(const char *title, const char *string, - unsigned short maxcols) -{ - unsigned short len = 0; - - if(title) { - len = (unsigned short)string_length(title) + 1; - printf("%s%s%s ", config->colstr.title, title, config->colstr.nocolor); - } - - if(string == NULL || string[0] == '\0') { - printf(_("None")); - } else { - indentprint(string, (unsigned short)len, maxcols); - } - printf("\n"); -} - static void table_print_line(const alpm_list_t *line, short col_padding, size_t colcount, size_t *widths, int *has_data) { @@ -682,76 +664,6 @@ void list_display_linebreak(const char *title, const alpm_list_t *list, } } -void signature_display(const char *title, alpm_siglist_t *siglist, - unsigned short maxcols) -{ - unsigned short len = 0; - - if(title) { - len = (unsigned short)string_length(title) + 1; - printf("%s%s%s ", config->colstr.title, title, config->colstr.nocolor); - } - - if(siglist->count == 0) { - printf(_("None")); - } else { - size_t i; - for(i = 0; i < siglist->count; i++) { - char *sigline; - const char *status, *validity, *name; - alpm_sigresult_t *result = siglist->results + i; - /* Don't re-indent the first result */ - if(i != 0) { - printf("%-*s", (int)len, ""); - } - switch(result->status) { - case ALPM_SIGSTATUS_VALID: - status = _("Valid"); - break; - case ALPM_SIGSTATUS_KEY_EXPIRED: - status = _("Key expired"); - break; - case ALPM_SIGSTATUS_SIG_EXPIRED: - status = _("Expired"); - break; - case ALPM_SIGSTATUS_INVALID: - status = _("Invalid"); - break; - case ALPM_SIGSTATUS_KEY_UNKNOWN: - status = _("Key unknown"); - break; - case ALPM_SIGSTATUS_KEY_DISABLED: - status = _("Key disabled"); - break; - default: - status = _("Signature error"); - break; - } - switch(result->validity) { - case ALPM_SIGVALIDITY_FULL: - validity = _("full trust"); - break; - case ALPM_SIGVALIDITY_MARGINAL: - validity = _("marginal trust"); - break; - case ALPM_SIGVALIDITY_NEVER: - validity = _("never trust"); - break; - case ALPM_SIGVALIDITY_UNKNOWN: - default: - validity = _("unknown trust"); - break; - } - name = result->key.uid ? result->key.uid : result->key.fingerprint; - pm_asprintf(&sigline, _("%s, %s from \"%s\""), - status, validity, name); - indentprint(sigline, len, maxcols); - printf("\n"); - free(sigline); - } - } -} - /* creates a header row for use with table_display */ static alpm_list_t *create_verbose_header(void) { diff --git a/src/pacman/util.h b/src/pacman/util.h index 690bc1d..7200591 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -55,16 +55,12 @@ void indentprint(const char *str, unsigned short indent, unsigned short cols); size_t strtrim(char *str); char *strreplace(const char *str, const char *needle, const char *replace); alpm_list_t *strsplit(const char *str, const char splitchar); -void string_display(const char *title, const char *string, - unsigned short maxcols); double humanize_size(off_t bytes, const char target_unit, int precision, const char **label); void list_display(const char *title, const alpm_list_t *list, unsigned short maxcols); void list_display_linebreak(const char *title, const alpm_list_t *list, unsigned short maxcols); -void signature_display(const char *title, alpm_siglist_t *siglist, - unsigned short maxcols); void display_targets(void); int str_cmp(const void *s1, const void *s2); void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg); -- 1.8.2