8 int main(int argc
, char **argv
);
11 prettyprogress(long b
, long maxb
, time_t starttime
)
13 /* print progress indication */
17 spent
= now
- starttime
;
18 printf("\r"); /* Make sure progress bar starts at beginning of line */
19 if(spent
> 0 && (bpsec
= (double)b
/ spent
) > 0) {
21 long secremain
, minremain
, hremain
;
22 secremain
= (maxb
- b
) / bpsec
;
23 minremain
= (secremain
/ 60) % 60;
24 hremain
= secremain
/ 3600;
25 len
= printf("Remaining: %ld files. ", maxb
-b
);
28 len
+= printf("ETA: %d:%02d:%02d ",
29 hremain
, minremain
, secremain
% 60);
36 for(i
= 0; i
< (b
* (len
-1) / maxb
); i
++)
51 long i
= 0, count
= 0;
55 if(argc
< 2) return 1;
56 count
= atol(argv
[1]);
57 if(count
< 0) return 1;
61 for(l
= 1; l
<= LINES
+1; l
++) printf("\n");
63 while(fgets(line
, sizeof(line
), stdin
)) {
66 for(l
= 0; l
<= LINES
; l
++) printf("\e[A");
67 if(i
<= count
) prettyprogress(i
, count
, start
);
70 for(l
= 0; l
< LINES
; l
++) printf("\e[B");
71 if((nl
= strchr(line
, '\n'))) *nl
= '\0';
73 printf("\r%s\r", line
);
76 printf("\nDone.\e[K\n");