]> git.ipfire.org Git - thirdparty/sarg.git/blob - totger.c
Changed Pedro's address in headers.
[thirdparty/sarg.git] / totger.c
1 /*
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
3 * 1998, 2008
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
5 *
6 * SARG donations:
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
9 *
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.
14 *
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.
19 *
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.
23 *
24 */
25
26 #include "include/conf.h"
27
28 int totalger(const char *dirname, int debug, const char *outdir)
29
30 {
31
32
33 FILE *fp_in, *fp_ou;
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];
41
42 strcpy(wger,dirname);
43 strcat(wger,"/geral");
44
45 if((fp_in=fopen(wger,"r"))==NULL) {
46 fprintf(stderr, "SARG: (totger) %s: %s\n",text[45],wger);
47 exit(1);
48 }
49
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);
60
61 while(!feof(fp_in))
62 {
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);
68
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);
79 }
80
81 fclose(fp_in);
82
83 strcpy(wger,dirname);
84 strcat(wger,"/geral");
85
86 if((fp_ou=fopen(wger,"a"))==NULL) {
87 fprintf(stderr, "SARG: (totger) %s: %s\n",text[45],wger);
88 exit(1);
89 }
90
91 url[0]='\0';
92
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);
99 fputs(url,fp_ou);
100 fclose(fp_ou);
101
102 return (0);
103 }