]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/squidGuard-1.3-20071117.patch
Fix vnstat directory creation
[people/pmueller/ipfire-2.x.git] / src / patches / squidGuard-1.3-20071117.patch
1 diff -Naur squidGuard-1.3.orig/src/sgDb.c squidGuard-1.3/src/sgDb.c
2 --- squidGuard-1.3.orig/src/sgDb.c 2007-11-03 14:59:49.000000000 +0100
3 +++ squidGuard-1.3/src/sgDb.c 2007-11-17 22:56:07.000000000 +0100
4 @@ -1,10 +1,12 @@
5 /*
6 By accepting this notice, you agree to be bound by the following
7 agreements:
8 -
9 - This software product, squidGuard, is copyrighted (C) 1998-2007
10 - by Christine Kronberg, Shalla Secure Services. All rights reserved.
11 -
12 +
13 + This software product, squidGuard, is copyrighted (C) 1998 by
14 + ElTele Øst AS, Oslo, Norway, with all rights reserved.
15 + With December 27th 2006 all rights moved to Christine Kronberg,
16 + Shalla Secure Services.
17 +
18 This program is free software; you can redistribute it and/or modify it
19 under the terms of the GNU General Public License (version 2) as
20 published by the Free Software Foundation. It is distributed in the
21 @@ -287,29 +289,75 @@
22 return result;
23 }
24
25 +static int stdoutisatty;
26 +
27 +#if __STDC__
28 +void startProgressBar()
29 +#else
30 +void startProgressBar()
31 +#endif
32 +{
33 + stdoutisatty = isatty(STDOUT_FILENO);
34 +
35 + if(1 == stdoutisatty)
36 + {
37 + /* do nothing */
38 + }
39 + else
40 + {
41 + printf(" [");
42 + fflush(stdout);
43 + }
44 + return;
45 +}
46 +
47 #if __STDC__
48 -void drawProgressBar(float prog)
49 +void finishProgressBar()
50 #else
51 -void drawProgressBar(prog)
52 +void finishProgressBar()
53 +#endif
54 +{
55 + if(1 == stdoutisatty)
56 + {
57 + printf("\n");
58 + }
59 + else
60 + {
61 + printf("] 100 %% done\n");
62 + }
63 + fflush(stdout);
64 + return;
65 +}
66 +
67 +#if __STDC__
68 +void updateProgressBar(float prog)
69 +#else
70 +void updateProgressBar(prog)
71 float prog;
72 #endif
73 {
74 - int j,k=0;
75 - k = (int)(prog * 50.0);
76 - printf(" [");
77 - for(j=0; j<50; j++)
78 + if(1 == stdoutisatty)
79 {
80 - if(j <= k)
81 + int j,k=0;
82 + k = (int)(prog * 50.0);
83 + printf("\r");fflush(stdout);
84 + printf(" [");
85 + for(j=0; j<50; j++)
86 + {
87 + if(j <= k)
88 printf("=");
89 - else
90 + else
91 printf(" ");
92 + }
93 + printf("] %d %% done", (int)(prog*100.0));fflush(stdout);
94 }
95 - printf("] %d %% done", (int)(prog*100.0));fflush(stdout);
96 - for(j=0; j<1000000; j++) {/*slow down to make progress bar more obvious*/}
97 - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");fflush(stdout);
98 - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");fflush(stdout);
99 - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");fflush(stdout);
100 - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");fflush(stdout);
101 + else
102 + {
103 + if(((int)(prog*100.0) % 100) == 0)
104 + printf(".");fflush(stdout);
105 + }
106 +
107 + return;
108 }
109
110 #if __STDC__
111 @@ -340,13 +388,14 @@
112
113 fstat(fileno(fp), &fpst);
114 fpsz = fpst.st_size;
115 + startProgressBar();
116
117 memset(&Db->key, 0, sizeof(DBT));
118 memset(&Db->data, 0, sizeof(DBT));
119 while(fgets(line, sizeof(line), fp) != NULL){
120
121 lnsz += strlen(line);
122 - drawProgressBar((float)lnsz/(float)fpsz);
123 + updateProgressBar((float)lnsz/(float)fpsz);
124
125 if(*line == '#')
126 continue;
127 @@ -418,7 +467,7 @@
128 if(update){
129 sgLogError("update: added %d entries, deleted %d entries",entries,deleted);
130 }
131 - printf("\n");
132 + finishProgressBar();
133 Db->entries = entries;
134 fclose(fp);
135 }
136