]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | /* |
94ff9470 | 2 | * AUTHOR: Pedro Lineu Orso orso@penguintech.com.br |
25697a35 | 3 | * 1998, 2005 |
94ff9470 | 4 | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net |
25697a35 GS |
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 | ||
64 | tnacc+=my_atoll(nacc); | |
65 | tnbytes+=my_atoll(nbytes); | |
66 | telap+=my_atoll(elap); | |
67 | tincache+=my_atoll(incac); | |
68 | toucache+=my_atoll(oucac); | |
69 | ||
70 | fscanf(fp_in,"%s",user); | |
71 | fscanf(fp_in,"%s",nacc); | |
72 | fscanf(fp_in,"%s",nbytes); | |
73 | fscanf(fp_in,"%s",url); | |
74 | fscanf(fp_in,"%s",ip); | |
75 | fscanf(fp_in,"%s",hora); | |
76 | fscanf(fp_in,"%s",data); | |
77 | fscanf(fp_in,"%s",elap); | |
78 | fscanf(fp_in,"%s",incac); | |
79 | fscanf(fp_in,"%s",oucac); | |
80 | } | |
81 | ||
82 | fclose(fp_in); | |
83 | ||
84 | strcpy(wger,dirname); | |
85 | strcat(wger,"/geral"); | |
86 | ||
87 | if((fp_ou=fopen(wger,"a"))==NULL) { | |
88 | fprintf(stderr, "SARG: (totger) %s: %s\n",text[45],wger); | |
89 | exit(1); | |
90 | } | |
91 | ||
92 | url[0]='\0'; | |
93 | ||
94 | my_lltoa(tnacc,val1,15); | |
95 | my_lltoa(tnbytes,val2,15); | |
96 | my_lltoa(telap,val3,15); | |
97 | my_lltoa(tincache,val4,15); | |
98 | my_lltoa(toucache,val5,15); | |
99 | sprintf(url,"TOTAL %s %s %s %s %s\n",val1,val2,val3,val4,val5); | |
100 | fputs(url,fp_ou); | |
101 | fclose(fp_ou); | |
102 | ||
103 | return (0); | |
104 | } |