1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | enum { I4_STAT_LEN=70 };
|
---|
10 |
|
---|
11 | #include "status/status.hh"
|
---|
12 | #include <stdlib.h>
|
---|
13 |
|
---|
14 | class i4_linux_status_class : public i4_status_class
|
---|
15 | {
|
---|
16 | public:
|
---|
17 | int last_percent;
|
---|
18 | i4_linux_status_class() { last_percent=0; }
|
---|
19 |
|
---|
20 | virtual i4_bool update(float per)
|
---|
21 | {
|
---|
22 | while (per*I4_STAT_LEN > last_percent)
|
---|
23 | {
|
---|
24 | fprintf(stderr,".");
|
---|
25 | last_percent++;
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | virtual ~i4_linux_status_class()
|
---|
30 | {
|
---|
31 | int i;
|
---|
32 | while (last_percent<I4_STAT_LEN)
|
---|
33 | {
|
---|
34 | fprintf(stderr,".");
|
---|
35 | last_percent++;
|
---|
36 | }
|
---|
37 |
|
---|
38 | for (i=0; i<=I4_STAT_LEN; i++) // backup
|
---|
39 | fprintf(stderr,"%c",'\b');
|
---|
40 | for (i=0; i<=I4_STAT_LEN+1; i++) // erase
|
---|
41 | fprintf(stderr,"%c",' ');
|
---|
42 | for (i=0; i<=I4_STAT_LEN+1; i++) // and backup again
|
---|
43 | fprintf(stderr,"%c",'\b');
|
---|
44 | }
|
---|
45 | };
|
---|
46 |
|
---|
47 | // this is operating system dependant
|
---|
48 | i4_status_class *i4_create_status(const i4_const_str &description, int allow_cancel)
|
---|
49 | {
|
---|
50 | int i,j=description.length()>I4_STAT_LEN ? I4_STAT_LEN : description.length();
|
---|
51 | fprintf(stderr,"[");
|
---|
52 |
|
---|
53 | i4_const_str::iterator it=description.begin();
|
---|
54 | for (i=0; i<j;i++, ++it)
|
---|
55 | fprintf(stderr,"%c",it.get().value());
|
---|
56 |
|
---|
57 | for (i=0; i<I4_STAT_LEN-j; i++)
|
---|
58 | fprintf(stderr,"%c",' ');
|
---|
59 |
|
---|
60 | fprintf(stderr,"]");
|
---|
61 | for (i=0; i<=I4_STAT_LEN; i++) // erase
|
---|
62 | fprintf(stderr,"%c",'\b');
|
---|
63 |
|
---|
64 | return new i4_linux_status_class;
|
---|
65 | }
|
---|