summaryrefslogtreecommitdiff
path: root/src/pacman/callback.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/callback.c')
-rw-r--r--src/pacman/callback.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index c7c16949..2d989ba9 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <sys/time.h>
#include <sys/types.h> /* off_t */
+#include <time.h>
#include <unistd.h>
#include <wchar.h>
#include <limits.h> /* UINT_MAX */
@@ -95,41 +96,41 @@ static void fill_progress(const int bar_percent, const int disp_percent,
}
if(hashlen > 0) {
- printf(" [");
+ fputs(" [", stdout);
for(i = hashlen; i > 0; --i) {
/* if special progress bar enabled */
if(config->chomp) {
if(i > hashlen - hash) {
- printf("-");
+ putchar('-');
} else if(i == hashlen - hash) {
if(lasthash == hash) {
if(mouth) {
- printf("\033[1;33mC\033[m");
+ fputs("\033[1;33mC\033[m", stdout);
} else {
- printf("\033[1;33mc\033[m");
+ fputs("\033[1;33mc\033[m", stdout);
}
} else {
lasthash = hash;
mouth = mouth == 1 ? 0 : 1;
if(mouth) {
- printf("\033[1;33mC\033[m");
+ fputs("\033[1;33mC\033[m", stdout);
} else {
- printf("\033[1;33mc\033[m");
+ fputs("\033[1;33mc\033[m", stdout);
}
}
- } else if(i%3 == 0) {
- printf("\033[0;37mo\033[m");
+ } else if(i % 3 == 0) {
+ fputs("\033[0;37mo\033[m", stdout);
} else {
- printf("\033[0;37m \033[m");
+ fputs("\033[0;37m \033[m", stdout);
}
} /* else regular progress bar */
else if(i > hashlen - hash) {
- printf("#");
+ putchar('#');
} else {
- printf("-");
+ putchar('-');
}
}
- printf("]");
+ putchar(']');
}
/* print display percent after progress bar */
/* 5 = 1 space + 3 digits + 1 % */
@@ -138,9 +139,9 @@ static void fill_progress(const int bar_percent, const int disp_percent,
}
if(bar_percent == 100) {
- printf("\n");
+ putchar('\n');
} else {
- printf("\r");
+ putchar('\r');
}
fflush(stdout);
}
@@ -196,9 +197,9 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
break;
case ALPM_EVENT_UPGRADE_DONE:
alpm_logaction(config->handle, "upgraded %s (%s -> %s)\n",
- (char *)alpm_pkg_get_name(data1),
- (char *)alpm_pkg_get_version(data2),
- (char *)alpm_pkg_get_version(data1));
+ alpm_pkg_get_name(data1),
+ alpm_pkg_get_version(data2),
+ alpm_pkg_get_version(data1));
display_new_optdepends(data2,data1);
break;
case ALPM_EVENT_INTEGRITY_START:
@@ -227,10 +228,10 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
printf(_("failed.\n"));
break;
case ALPM_EVENT_SCRIPTLET_INFO:
- printf("%s", (char *)data1);
+ fputs((const char *)data1, stdout);
break;
case ALPM_EVENT_RETRIEVE_START:
- printf(_(":: Retrieving packages from %s...\n"), (char *)data1);
+ printf(_(":: Retrieving packages ...\n"));
break;
case ALPM_EVENT_DISKSPACE_START:
if(config->noprogressbar) {
@@ -294,7 +295,7 @@ void cb_question(alpm_question_t event, void *data1, void *data2,
break;
case ALPM_QUESTION_REMOVE_PKGS:
{
- alpm_list_t *unresolved = (alpm_list_t *) data1;
+ alpm_list_t *unresolved = data1;
alpm_list_t *namelist = NULL, *i;
size_t count = 0;
for (i = unresolved; i; i = i->next) {
@@ -317,7 +318,7 @@ void cb_question(alpm_question_t event, void *data1, void *data2,
break;
case ALPM_QUESTION_SELECT_PROVIDER:
{
- alpm_list_t *providers = (alpm_list_t *)data1;
+ alpm_list_t *providers = data1;
size_t count = alpm_list_count(providers);
char *depstring = alpm_dep_compute_string((alpm_depend_t *)data2);
printf(_(":: There are %zd providers available for %s:\n"), count,
@@ -340,15 +341,22 @@ void cb_question(alpm_question_t event, void *data1, void *data2,
*response = yesno(_(":: File %s is corrupted (%s).\n"
"Do you want to delete it?"),
(char *)data1,
- alpm_strerror(*(enum _alpm_errno_t *)data2));
+ alpm_strerror(*(alpm_errno_t *)data2));
break;
case ALPM_QUESTION_IMPORT_KEY:
{
alpm_pgpkey_t *key = data1;
char created[12];
- strftime(created, 12, "%Y-%m-%d", localtime(&(key->created)));
- *response = yesno(_(":: Import PGP key %s, \"%s\", created %s?"),
- key->fingerprint, key->uid, created);
+ const char *revoked = "";
+ time_t time = (time_t)key->created;
+ strftime(created, 12, "%Y-%m-%d", localtime(&time));
+
+ if (key->revoked) {
+ revoked = " (revoked)";
+ }
+
+ *response = yesno(_(":: Import PGP key %d%c/%s, \"%s\", created: %s%s?"),
+ key->length, key->pubkey_algo, key->fingerprint, key->uid, created, revoked);
}
break;
}
@@ -493,7 +501,7 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent,
alpm_list_t *i = NULL;
on_progress = 0;
for(i = output; i; i = i->next) {
- printf("%s", (char *)i->data);
+ fputs((const char *)i->data, stdout);
}
fflush(stdout);
FREELIST(output);
@@ -713,7 +721,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
} else if(eta_h < 100) {
printf("%02u:%02u:%02u", eta_h, eta_m, eta_s);
} else {
- printf("--:--");
+ fputs("--:--", stdout);
}
free(fname);