From f9b89552c45241e11b69a6108053e347a5d4beb8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 30 Mar 2005 06:49:56 +0000 Subject: cosmetic improvement --- lib/update.c | 25 ++++++++++++++++++++----- src/main.c | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/update.c b/lib/update.c index 5d0a497..88fd27b 100644 --- a/lib/update.c +++ b/lib/update.c @@ -39,6 +39,7 @@ const char *TGebGET = "GET /downloads/tgeb/tarife_%.4i%.2i%.2i.zip HTTP/1.0\n\n" extern char *__progname; static void unzip(void); +static void twiddle(void); void tgeb_update(struct tm * tm) @@ -89,10 +90,9 @@ tgeb_update(struct tm * tm) offset += block; if (!(buf = realloc(buf, offset + BUF_SIZ))) err(1, "malloc"); - putchar('.'); - fflush(stdout); + twiddle(); } - putchar('\n'); + printf(" \tdone\n"); close(sockfd); file = strstr(buf, "\r\n\r\n") + 4; filelen = offset + buf - file; @@ -127,16 +127,17 @@ unzip(void) for (i = 0; i < gi.number_entry; i++) { unzGetCurrentFileInfo(unzfd, &fi, FileName, sizeof(FileName), NULL, 0, NULL, 0); - printf("extract %s ...", FileName); + printf("%s: extracting %s ", __progname, FileName); fflush(stdout); unzOpenCurrentFile(unzfd); if (!(fd = fopen(FileName, "wb"))) err(1, "fopen %s", FileName); while ((len = unzReadCurrentFile(unzfd, buf, BUF_SIZ))) { fwrite(buf, len, 1, fd); + twiddle(); } fclose(fd); - printf(" done\n"); + printf(" \tdone\n"); unzGoToNextFile(unzfd); } free(buf); @@ -144,3 +145,17 @@ unzip(void) unlink(DATFILE); return; } + +static const char twiddle_chars[] = "|/-\\"; +static int twiddle_index = 0; + +void +twiddle(void) +{ + putchar(twiddle_chars[twiddle_index++]); + putchar('\b'); + fflush(stdout); + twiddle_index &= 3; +} + + diff --git a/src/main.c b/src/main.c index cb104ad..6f0fbd0 100644 --- a/src/main.c +++ b/src/main.c @@ -29,7 +29,7 @@ #include extern char *__progname; -const char *copyright = "TGeb parasite 0.3 - " +const char *copyright = "TGeb parasite 0.3.1 - " "Copyright (c) 2004 demon "; void usage(void); -- cgit v1.2.3