[pacman-dev] [PATCH 3/4] make some *_display functions static
Simon Gomizelj
simongmzlj at gmail.com
Tue Mar 26 13:39:31 EDT 2013
Signed-off-by: Simon Gomizelj <simongmzlj at gmail.com>
---
src/pacman/package.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/pacman/util.c | 95 +---------------------------------------------------
src/pacman/util.h | 5 +--
3 files changed, 94 insertions(+), 98 deletions(-)
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 3d1b108..403896a 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,80 @@ static void optdeplist_display(alpm_pkg_t *pkg, unsigned short maxcols)
FREELIST(text);
}
+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;
+ int ret;
+ 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;
+ ret = pm_asprintf(&sigline, _("%s, %s from \"%s\""),
+ status, validity, name);
+ if(ret == -1) {
+ continue;
+ }
+ 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 daffffd..c2f0669 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -406,7 +406,7 @@ alpm_list_t *strsplit(const char *str, const char splitchar)
return list;
}
-static size_t string_length(const char *s)
+size_t string_length(const char *s)
{
int len;
wchar_t *wcstr;
@@ -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,81 +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;
- int ret;
- 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;
- ret = pm_asprintf(&sigline, _("%s, %s from \"%s\""),
- status, validity, name);
- if(ret == -1) {
- continue;
- }
- 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)
{
alpm_list_t *res = NULL;
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 690bc1d..2566913 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -55,16 +55,13 @@ 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);
+size_t string_length(const char *s);
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
More information about the pacman-dev
mailing list