diff options
author | Joel Stanley <joel@jms.id.au> | 2018-08-14 13:38:06 +0930 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2018-09-07 13:42:16 +1000 |
commit | 7be30ef70a4964b6dc199a207b57d62799987a3f (patch) | |
tree | 836368c47b8897d9c4b5be5e159bc192d2c5bcaa /src/progress.c | |
parent | b65867d84267a0f85d127507d1be512361ef04ae (diff) | |
download | pdbg-7be30ef70a4964b6dc199a207b57d62799987a3f.tar.gz pdbg-7be30ef70a4964b6dc199a207b57d62799987a3f.zip |
progress: No more progress
This adds an option to suppress progress:
-S, --shutup
Shut up those annoying progress bars
Signed-off-by: Joel Stanley <joel@jms.id.au>
Diffstat (limited to 'src/progress.c')
-rw-r--r-- | src/progress.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/progress.c b/src/progress.c index 648596d..4baee12 100644 --- a/src/progress.c +++ b/src/progress.c @@ -20,6 +20,7 @@ #include <string.h> #include <time.h> #include <assert.h> +#include <stdbool.h> #include "progress.h" @@ -27,6 +28,7 @@ static uint64_t progress_pcent; static uint64_t progress_n_upd; static time_t progress_prevsec; static struct timespec progress_start; +static bool shutup; #define PROGRESS_CHARS 50 @@ -36,6 +38,9 @@ static void progress_bar(unsigned int percent) assert(percent <= 100); + if (shutup) + return; + progress = (percent * PROGRESS_CHARS) / 101; fprintf(stderr, "\r["); @@ -47,6 +52,11 @@ static void progress_bar(unsigned int percent) fflush(stderr); } +void progress_shutup(void) +{ + shutup = true; +} + void progress_init(void) { progress_pcent = 0; @@ -64,6 +74,9 @@ void progress_tick(uint64_t cur, uint64_t end) unsigned int pcent; double sec; + if (shutup) + return; + pcent = (unsigned int)((cur * 100) / end); if (progress_pcent == pcent && cur < progress_n_upd && cur < end) @@ -100,5 +113,8 @@ void progress_tick(uint64_t cur, uint64_t end) void progress_end(void) { + if (shutup) + return; + fprintf(stderr, "\n"); } |