-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb5b56c
commit 29e5874
Showing
3 changed files
with
92 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef FSAUTOPROC_PROG_H | ||
#define FSAUTOPROC_PROG_H | ||
|
||
void printprogbar(long curr, long max); | ||
|
||
#endif//FSAUTOPROC_PROG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "prog.h" | ||
|
||
#include <stdio.h> | ||
|
||
#define PROGBARLEN 15 | ||
|
||
void printprogbar(const long curr, const long max) { | ||
if (max == 0) return; | ||
const long barlen = (curr * PROGBARLEN) / max; | ||
static long lastbarlen = -1; | ||
if (lastbarlen >= 0 && barlen == lastbarlen) return; | ||
lastbarlen = barlen; | ||
static char progbar[PROGBARLEN + 3]; | ||
long i = 0; | ||
progbar[i++] = '['; | ||
for (long j = 0; j < PROGBARLEN; j++) progbar[i++] = j <= barlen ? '#' : ' '; | ||
progbar[i++] = ']'; | ||
printf("%s %ld\n", progbar, max - curr); | ||
fflush(stdout); | ||
} |