aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/utils.c b/src/utils.c
index faf78502..4f5f7da3 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -53,19 +53,20 @@ void chomp(char *s)
}
-void progress_bar(int val, int total)
+void progress_bar(int val, int total, const char *text)
{
double frac;
int n, i;
char s[1024];
+ const int width = 50;
frac = (double)val/total;
- n = (int)(frac*80);
+ n = (int)(frac*width);
for ( i=0; i<n; i++ ) s[i] = '=';
- for ( i=n; i<80; i++ ) s[i] = '.';
- s[80] = '\0';
- printf("\r|%s|", s);
+ for ( i=n; i<width; i++ ) s[i] = '.';
+ s[width] = '\0';
+ printf("\r%s: |%s|", text, s);
if ( val == total ) printf("\n");