diff options
author | Thomas White <taw@bitwiz.org.uk> | 2009-11-18 15:22:25 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2009-11-18 15:22:25 +0100 |
commit | 7f004b45f39c9207a6a233217f983c9b269bca45 (patch) | |
tree | 7a03f7d670eae4f6e62498686901afac6071171f /src/utils.c | |
parent | 99569f2f6cf574e88441d3de888f825b6d7b2ed7 (diff) |
Add progress bar
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c index fa239f90..d58f4db8 100644 --- a/src/utils.c +++ b/src/utils.c @@ -156,3 +156,21 @@ void mapping_rotate(double x, double y, double z, *ddy = ny; *ddz = nz; } + + +void progress_bar(int val, int total) +{ + double frac; + int n, i; + char s[1024]; + + frac = (double)val/total; + n = frac*80; + + for ( i=0; i<n; i++ ) s[i] = '='; + for ( i=n; i<80; i++ ) s[i] = '.'; + s[n] = '\0'; + printf("\r|%s|", s); + + if ( val == total ) printf("\n"); +} |