]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
1164c474 | 3 | * 1998, 2010 |
25697a35 GS |
4 | * |
5 | * SARG donations: | |
6 | * please look at http://sarg.sourceforge.net/donations.php | |
1164c474 FM |
7 | * Support: |
8 | * http://sourceforge.net/projects/sarg/forums/forum/363374 | |
25697a35 GS |
9 | * --------------------------------------------------------------------- |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
24 | * | |
25 | */ | |
26 | ||
27 | #include "include/conf.h" | |
5f3cfd1d | 28 | #include "include/defs.h" |
25697a35 GS |
29 | |
30 | int totalger(const char *dirname, int debug, const char *outdir) | |
25697a35 | 31 | { |
25697a35 GS |
32 | FILE *fp_in, *fp_ou; |
33 | long long int tnacc=0; | |
34 | long long int tnbytes=0; | |
35 | long long int telap=0; | |
36 | long long int tincache=0, toucache=0; | |
2240dcea | 37 | char wger[MAXLEN]; |
ac422f9b | 38 | char *warea; |
afaa3b67 | 39 | longline line; |
2240dcea | 40 | struct generalitemstruct item; |
25697a35 | 41 | |
d5d021c5 | 42 | snprintf(wger,sizeof(wger),"%s/sarg-general",dirname); |
25697a35 GS |
43 | |
44 | if((fp_in=fopen(wger,"r"))==NULL) { | |
fcdc0918 | 45 | debuga(_("(totger) Cannot open file %s\n"),wger); |
06b39c87 | 46 | exit(EXIT_FAILURE); |
25697a35 GS |
47 | } |
48 | ||
afaa3b67 | 49 | if ((line=longline_create())==NULL) { |
10210234 | 50 | debuga(_("Not enough memory to read the temporary file %s\n"),wger); |
06b39c87 | 51 | exit(EXIT_FAILURE); |
ac422f9b FM |
52 | } |
53 | ||
afaa3b67 | 54 | while((warea=longline_read(fp_in,line))!=NULL) |
25697a35 | 55 | { |
2240dcea FM |
56 | ger_read(warea,&item,wger); |
57 | tnacc+=item.nacc; | |
58 | tnbytes+=item.nbytes; | |
59 | telap+=item.nelap; | |
60 | tincache+=item.incache; | |
61 | toucache+=item.oucache; | |
25697a35 GS |
62 | } |
63 | ||
64 | fclose(fp_in); | |
afaa3b67 | 65 | longline_destroy(&line); |
25697a35 | 66 | |
25697a35 | 67 | if((fp_ou=fopen(wger,"a"))==NULL) { |
fcdc0918 | 68 | debuga(_("(totger) Cannot open file %s\n"),wger); |
06b39c87 | 69 | exit(EXIT_FAILURE); |
25697a35 GS |
70 | } |
71 | ||
2240dcea | 72 | fprintf(fp_ou,"TOTAL\t%lld\t%lld\t%lld\t%lld\t%lld\n",tnacc,tnbytes,telap,tincache,toucache); |
25697a35 GS |
73 | fclose(fp_ou); |
74 | ||
75 | return (0); | |
76 | } |