]> git.ipfire.org Git - thirdparty/sarg.git/blame - totger.c
Remove all the warnings (inspired from patch #1771501).
[thirdparty/sarg.git] / totger.c
CommitLineData
25697a35 1/*
c37945ed
FM
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
3 * 1998, 2008
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
28int totalger(const char *dirname, int debug, const char *outdir)
25697a35 29{
25697a35
GS
30 FILE *fp_in, *fp_ou;
31 long long int tnacc=0;
32 long long int tnbytes=0;
33 long long int telap=0;
34 long long int tincache=0, toucache=0;
7ebe75af
FM
35 char wger[MAXLEN], user[MAXLEN], nacc[16], nbytes[16], url[2048];
36 char ip[MAXLEN], hora[9], data[11], elap[16];
37 char incac[16], oucac[16];
38 char warea[1500];
25697a35
GS
39
40 strcpy(wger,dirname);
d6e703cc 41 strcat(wger,"/sarg-general");
25697a35
GS
42
43 if((fp_in=fopen(wger,"r"))==NULL) {
44 fprintf(stderr, "SARG: (totger) %s: %s\n",text[45],wger);
45 exit(1);
46 }
47
7ebe75af
FM
48 //fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
49 fgets(warea,sizeof(warea),fp_in);
25697a35
GS
50
51 while(!feof(fp_in))
52 {
7ebe75af
FM
53 if (getword(user,sizeof(user),warea,' ')<0) {
54 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
55 exit(1);
56 }
57 if (getword(nacc,sizeof(nacc),warea,' ')<0) {
58 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
59 exit(1);
60 }
61 if (getword(nbytes,sizeof(nbytes),warea,' ')<0) {
62 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
63 exit(1);
64 }
65 if (getword(url,sizeof(url),warea,' ')<0) {
66 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
67 exit(1);
68 }
69 if (getword(ip,sizeof(ip),warea,' ')<0) {
70 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
71 exit(1);
72 }
73 if (getword(hora,sizeof(hora),warea,' ')<0) {
74 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
75 exit(1);
76 }
77 if (getword(data,sizeof(data),warea,' ')<0) {
78 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
79 exit(1);
80 }
81 if (getword(elap,sizeof(elap),warea,' ')<0) {
82 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
83 exit(1);
84 }
85 if (getword(incac,sizeof(incac),warea,' ')<0) {
86 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
87 exit(1);
88 }
89 if (getword(oucac,sizeof(oucac),warea,0)<0) {
90 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
91 exit(1);
92 }
25697a35
GS
93 tnacc+=my_atoll(nacc);
94 tnbytes+=my_atoll(nbytes);
95 telap+=my_atoll(elap);
96 tincache+=my_atoll(incac);
97 toucache+=my_atoll(oucac);
98
7ebe75af
FM
99 //fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
100 fgets(warea,sizeof(warea),fp_in);
25697a35
GS
101 }
102
103 fclose(fp_in);
104
105 strcpy(wger,dirname);
d6e703cc 106 strcat(wger,"/sarg-general");
25697a35
GS
107
108 if((fp_ou=fopen(wger,"a"))==NULL) {
109 fprintf(stderr, "SARG: (totger) %s: %s\n",text[45],wger);
110 exit(1);
111 }
112
113 url[0]='\0';
114
115 my_lltoa(tnacc,val1,15);
116 my_lltoa(tnbytes,val2,15);
117 my_lltoa(telap,val3,15);
118 my_lltoa(tincache,val4,15);
119 my_lltoa(toucache,val5,15);
120 sprintf(url,"TOTAL %s %s %s %s %s\n",val1,val2,val3,val4,val5);
121 fputs(url,fp_ou);
122 fclose(fp_ou);
123
124 return (0);
125}