]> git.ipfire.org Git - thirdparty/sarg.git/blob - totger.c
More translations for gettext.
[thirdparty/sarg.git] / totger.c
1 /*
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
3 * 1998, 2010
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
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"
28 #include "include/defs.h"
29
30 int totalger(const char *dirname, int debug, const char *outdir)
31 {
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;
37 char wger[MAXLEN];
38 char *warea;
39 struct longlinestruct line;
40 struct generalitemstruct item;
41
42 strcpy(wger,dirname);
43 strcat(wger,"/sarg-general");
44
45 if((fp_in=fopen(wger,"r"))==NULL) {
46 debuga(_("(totger) Cannot open file: %s\n"),wger);
47 exit(1);
48 }
49
50 if (longline_prepare(&line)<0) {
51 debuga(_("Not enough memory to read the temporary file %s\n"),wger);
52 exit(1);
53 }
54
55 while((warea=longline_read(fp_in,&line))!=NULL)
56 {
57 ger_read(warea,&item,wger);
58 tnacc+=item.nacc;
59 tnbytes+=item.nbytes;
60 telap+=item.nelap;
61 tincache+=item.incache;
62 toucache+=item.oucache;
63 }
64
65 fclose(fp_in);
66 longline_free(&line);
67
68 if((fp_ou=fopen(wger,"a"))==NULL) {
69 debuga(_("(totger) Cannot open file: %s\n"),wger);
70 exit(1);
71 }
72
73 fprintf(fp_ou,"TOTAL\t%lld\t%lld\t%lld\t%lld\t%lld\n",tnacc,tnbytes,telap,tincache,toucache);
74 fclose(fp_ou);
75
76 return (0);
77 }