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
6 By accepting this notice, you agree to be bound by the following
9 - This software product, squidGuard, is copyrighted (C) 1998-2007
10 - by Christine Kronberg, Shalla Secure Services. All rights reserved.
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.
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
25 +static int stdoutisatty;
28 +void startProgressBar()
30 +void startProgressBar()
33 + stdoutisatty = isatty(STDOUT_FILENO);
35 + if(1 == stdoutisatty)
48 -void drawProgressBar(float prog)
49 +void finishProgressBar()
51 -void drawProgressBar(prog)
52 +void finishProgressBar()
55 + if(1 == stdoutisatty)
61 + printf("] 100 %% done\n");
68 +void updateProgressBar(float prog)
70 +void updateProgressBar(prog)
75 - k = (int)(prog * 50.0);
78 + if(1 == stdoutisatty)
82 + k = (int)(prog * 50.0);
83 + printf("\r");fflush(stdout);
93 + printf("] %d %% done", (int)(prog*100.0));fflush(stdout);
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);
103 + if(((int)(prog*100.0) % 100) == 0)
104 + printf(".");fflush(stdout);
111 @@ -340,13 +388,14 @@
113 fstat(fileno(fp), &fpst);
115 + startProgressBar();
117 memset(&Db->key, 0, sizeof(DBT));
118 memset(&Db->data, 0, sizeof(DBT));
119 while(fgets(line, sizeof(line), fp) != NULL){
121 lnsz += strlen(line);
122 - drawProgressBar((float)lnsz/(float)fpsz);
123 + updateProgressBar((float)lnsz/(float)fpsz);
129 sgLogError("update: added %d entries, deleted %d entries",entries,deleted);
132 + finishProgressBar();
133 Db->entries = entries;