]>
git.ipfire.org Git - thirdparty/sarg.git/blob - totger.c
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
26 #include "include/conf.h"
28 int totalger(const char *dirname
, int debug
, const char *outdir
)
34 long long int tnacc
=0;
35 long long int tnbytes
=0;
36 long long int telap
=0;
37 long long int tincache
=0, toucache
=0;
38 char wger
[MAXLEN
], user
[MAXLEN
], nacc
[10], nbytes
[10], url
[1024];
39 char ip
[MAXLEN
], hora
[9], data
[11], elap
[15];
40 char incac
[15], oucac
[15];
43 strcat(wger
,"/geral");
45 if((fp_in
=fopen(wger
,"r"))==NULL
) {
46 fprintf(stderr
, "SARG: (totger) %s: %s\n",text
[45],wger
);
50 fscanf(fp_in
,"%s",user
);
51 fscanf(fp_in
,"%s",nacc
);
52 fscanf(fp_in
,"%s",nbytes
);
53 fscanf(fp_in
,"%s",url
);
54 fscanf(fp_in
,"%s",ip
);
55 fscanf(fp_in
,"%s",hora
);
56 fscanf(fp_in
,"%s",data
);
57 fscanf(fp_in
,"%s",elap
);
58 fscanf(fp_in
,"%s",incac
);
59 fscanf(fp_in
,"%s",oucac
);
63 tnacc
+=my_atoll(nacc
);
64 tnbytes
+=my_atoll(nbytes
);
65 telap
+=my_atoll(elap
);
66 tincache
+=my_atoll(incac
);
67 toucache
+=my_atoll(oucac
);
69 fscanf(fp_in
,"%s",user
);
70 fscanf(fp_in
,"%s",nacc
);
71 fscanf(fp_in
,"%s",nbytes
);
72 fscanf(fp_in
,"%s",url
);
73 fscanf(fp_in
,"%s",ip
);
74 fscanf(fp_in
,"%s",hora
);
75 fscanf(fp_in
,"%s",data
);
76 fscanf(fp_in
,"%s",elap
);
77 fscanf(fp_in
,"%s",incac
);
78 fscanf(fp_in
,"%s",oucac
);
84 strcat(wger
,"/geral");
86 if((fp_ou
=fopen(wger
,"a"))==NULL
) {
87 fprintf(stderr
, "SARG: (totger) %s: %s\n",text
[45],wger
);
93 my_lltoa(tnacc
,val1
,15);
94 my_lltoa(tnbytes
,val2
,15);
95 my_lltoa(telap
,val3
,15);
96 my_lltoa(tincache
,val4
,15);
97 my_lltoa(toucache
,val5
,15);
98 sprintf(url
,"TOTAL %s %s %s %s %s\n",val1
,val2
,val3
,val4
,val5
);