Cleaned up some more output

* Questions no longer start with "error:"
* downloaded size is output as a float now
This commit is contained in:
Aaron Griffin 2007-02-10 09:34:59 +00:00
parent 7cf6c88105
commit a382d33d45
4 changed files with 19 additions and 15 deletions

View File

@ -16,10 +16,10 @@ pacman_SOURCES = util.c log.c package.c downloadprog.c trans.c add.c \
pacman_static_SOURCES = $(pacman_SOURCES) pacman_static_SOURCES = $(pacman_SOURCES)
pacman_LDADD = -L$(top_builddir)/lib/libalpm/.libs \ pacman_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.so \
-ldownload -lalpm -ldownload
pacman_static_LDADD = -L$(top_builddir)/lib/libalpm/.libs/ \ pacman_static_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la \
-ldownload -lalpm -ldownload
pacman_static_LDFLAGS = $(LDFLAGS) -all-static pacman_static_LDFLAGS = $(LDFLAGS) -all-static

View File

@ -53,7 +53,7 @@ void log_progress(const char *filename, int xfered, int total)
const int infolen = 50; const int infolen = 50;
char *fname, *p; char *fname, *p;
float rate = 0.0, timediff = 0.0; float rate = 0.0, timediff = 0.0, f_xfered = 0.0;
unsigned int eta_h = 0, eta_m = 0, eta_s = 0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0;
int percent; int percent;
char rate_size = 'K', xfered_size = 'K'; char rate_size = 'K', xfered_size = 'K';
@ -112,11 +112,13 @@ void log_progress(const char *filename, int xfered, int total)
eta_s -= eta_m * 60; eta_s -= eta_m * 60;
fname = strdup(filename); fname = strdup(filename);
/* strip extension if it's there
* NOTE: in the case of package files, only the pkgname is sent now */
if((p = strstr(fname, PM_EXT_PKG)) || (p = strstr(fname, PM_EXT_DB))) { if((p = strstr(fname, PM_EXT_PKG)) || (p = strstr(fname, PM_EXT_DB))) {
*p = '\0'; *p = '\0';
} }
if(strlen(fname) > FILENAME_TRIM_LEN) { if(strlen(fname) > FILENAME_TRIM_LEN) {
fname[FILENAME_TRIM_LEN] = '\0'; strcpy(fname + FILENAME_TRIM_LEN -3,"...");
} }
/* Awesome formatting for progress bar. We need a mess of Kb->Mb->Gb stuff /* Awesome formatting for progress bar. We need a mess of Kb->Mb->Gb stuff
@ -132,13 +134,13 @@ void log_progress(const char *filename, int xfered, int total)
} }
} }
xfered /= 1024; /* convert to K by default */ f_xfered = (float) xfered / 1024.0; /* convert to K by default */
/* xfered_size = 'K'; was set above */ /* xfered_size = 'K'; was set above */
if(xfered > 2048) { if(f_xfered > 2048.0) {
xfered /= 1024; f_xfered /= 1024.0;
xfered_size = 'M'; xfered_size = 'M';
if(xfered > 2048) { if(f_xfered > 2048.0) {
xfered /= 1024; f_xfered /= 1024.0;
xfered_size = 'G'; xfered_size = 'G';
/* I should seriously hope that archlinux packages never break /* I should seriously hope that archlinux packages never break
* the 9999.9GB mark... we'd have more serious problems than the progress * the 9999.9GB mark... we'd have more serious problems than the progress
@ -146,8 +148,8 @@ void log_progress(const char *filename, int xfered, int total)
} }
} }
printf(" %-*s %6d%c %#6.1f%c/s %02u:%02u:%02u", FILENAME_TRIM_LEN, fname, printf(" %-*s %6.1f%c %#6.1f%c/s %02u:%02u:%02u", FILENAME_TRIM_LEN, fname,
xfered, xfered_size, rate, rate_size, eta_h, eta_m, eta_s); f_xfered, xfered_size, rate, rate_size, eta_h, eta_m, eta_s);
free(fname); free(fname);

View File

@ -175,7 +175,7 @@ int yesno(char *fmt, ...)
va_end(args); va_end(args);
/* Use stderr so questions are always displayed when redirecting output */ /* Use stderr so questions are always displayed when redirecting output */
ERR(NL, str); pm_fprintf(stderr, NL, str); \
if(fgets(response, 32, stdin)) { if(fgets(response, 32, stdin)) {
/* trim whitespace and newlines */ /* trim whitespace and newlines */

View File

@ -418,10 +418,12 @@ void fill_progress(const int percent, const int proglen)
printf("-"); printf("-");
} }
} }
printf("] %3d%%\r", percent); printf("] %3d%%", percent);
if(percent == 100) { if(percent == 100) {
printf("\n"); printf("\n");
} else {
printf("\r");
} }
fflush(stdout); fflush(stdout);
} }