2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
6 * please look at http://sarg.sourceforge.net/donations.php
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
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.
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.
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.
27 #include "include/conf.h"
28 #include "include/defs.h"
30 //! The global statistics of the whole log read.
31 struct globalstatstruct globstat
;
33 static FILE *fp_tt
=NULL
;
35 static void maketmp(const char *user
, const char *dirname
, int debug
);
36 static void maketmp_hour(const char *user
, const char *dirname
);
37 static void gravatmp_hora(const char *dirname
, const struct userinfostruct
*uinfo
, const char *data
, const char *hora
, long long int elap
, long long int accbytes
);
38 static void gravatmp(const struct userinfostruct
*uinfo
, const char *oldurl
, long long int nacc
, long long int nbytes
, const char *oldmsg
, long long int nelap
, long long int incache
, long long int oucache
);
39 static void gravaporuser(const struct userinfostruct
*uinfo
, const char *dirname
, const char *url
, const char *ip
, const char *data
, const char *hora
, long long int tam
, long long int elap
);
40 static void gravager(FILE *fp_gen
,const char *filename
, const struct userinfostruct
*uinfo
, long long int nacc
, const char *url
, long long int nbytes
, const char *ip
, const char *hora
, const char *dia
, long long int nelap
, long long int incache
, long long int oucache
);
41 static void grava_SmartFilter(const char *dirname
, const char *user
, const char *ip
, const char *data
, const char *hora
, const char *url
, const char *smart
);
49 char accdia
[11], acchora
[9], accip
[MAXLEN
], *accurl
;
50 char oldaccdia
[11], oldacchora
[9], oldaccip
[MAXLEN
];
51 char wdirname
[MAXLEN
];
53 char oldmsg
[50], acccode
[MAXLEN
/2 - 1], oldacccode
[MAXLEN
/2 - 1];
54 char ipantes
[MAXLEN
], nameantes
[MAXLEN
];
55 char accsmart
[MAXLEN
];
56 char crc2
[MAXLEN
/2 -1];
57 char siteind
[MAX_TRUNCATED_URL
];
60 char oldaccdiatt
[11],oldacchoratt
[9];
63 char u2
[MAX_USER_LEN
];
64 long long int nbytes
=0;
65 long long int nelap
=0;
67 long long int rtotal
=0;
68 long long int incache
=0;
69 long long int oucache
=0;
70 long long int accbytes
, accelap
;
73 const char *sort_field
;
74 const char *sort_order
;
81 struct getwordstruct gwarea
;
83 struct userinfostruct
*uinfo
,*puinfo
;
87 memset(&globstat
,0,sizeof(globstat
));
89 if (vrfydir(&period
, addr
, site
, us
, email
)<0) {
90 debuga(_("Cannot create the output directory name containing the period as part of the name\n"));
95 debugaz("outdirname",outdirname
);
98 if(UserAgentLog
[0] != '\0' && email
[0] == '\0') useragent();
100 snprintf(wdirname
,sizeof(wdirname
),"%s/sarg-general",outdirname
);
101 if((fp_gen
=MY_FOPEN(wdirname
,"w"))==NULL
){
102 debuga(_("(report) Cannot open file %s\n"),wdirname
);
108 sort_labels(&sort_field
,&sort_order
);
110 uscan
=userinfo_startscan();
112 debuga(_("Cannot enumerate the user list\n"));
115 while ((uinfo
= userinfo_advancescan(uscan
)) != NULL
) {
116 if (snprintf(tmp3
,sizeof(tmp3
),"%s/%s.log",tmp
,uinfo
->filename
)>=sizeof(tmp3
)) {
117 debuga(_("(report) directory entry too long: %s/%s.log\n"),tmp
,uinfo
->filename
);
120 if((fp_in
=MY_FOPEN(tmp3
,"r"))==NULL
){
121 debuga(_("(report) Cannot open file %s\n"),tmp
);
124 user
=uinfo
->filename
;
126 strcpy(u2
,uinfo
->id
);
127 if(Ip2Name
&& uinfo
->id_is_ip
) {
129 ip2name(u2
,sizeof(u2
));
130 strcpy(nameantes
,u2
);
132 user_find(uinfo
->label
,MAX_USER_LEN
, u2
);
135 maketmp(user
,tmp
,debug
);
136 maketmp_hour(user
,tmp
);
142 memset(oldaccdiatt
,0,sizeof(oldaccdiatt
));
143 memset(oldacchoratt
,0,sizeof(oldacchoratt
));
146 if ((line
=longline_create())==NULL
) {
147 debuga(_("Not enough memory to read the downloaded files\n"));
151 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
152 getword_start(&gwarea
,buf
);
153 if (getword(accdia
,sizeof(accdia
),&gwarea
,'\t')<0 || getword(acchora
,sizeof(acchora
),&gwarea
,'\t')<0 ||
154 getword(accip
,sizeof(accip
),&gwarea
,'\t')<0 ||
155 getword_ptr(buf
,&accurl
,&gwarea
,'\t')<0 || getword_atoll(&accbytes
,&gwarea
,'\t')<0 ||
156 getword(acccode
,sizeof(acccode
),&gwarea
,'\t')<0) {
157 debuga(_("There is a broken record or garbage in file %s\n"),tmp3
);
160 if(strncmp(acccode
,"TCP_DENIED/407",14) == 0) continue;
161 if (getword_atoll(&accelap
,&gwarea
,'\t')<0) {
162 debuga(_("There is a broken elapsed time in file %s\n"),tmp3
);
165 if (getword_skip(20000,&gwarea
,'"')<0 || getword(accsmart
,sizeof(accsmart
),&gwarea
,'"')<0) {
166 debuga(_("There is a broken smart info in file %s\n"),tmp3
);
170 if(accsmart
[0] != '\0') {
172 grava_SmartFilter(outdirname
,uinfo
->id
,accip
,accdia
,acchora
,accurl
,accsmart
);
176 if(strcmp(accip
,ipantes
) != 0) {
177 strcpy(ipantes
,accip
);
178 ip2name(accip
,sizeof(accip
));
179 strcpy(nameantes
,accip
);
180 } else strcpy(accip
,nameantes
);
184 gravatmp_hora(outdirname
,uinfo
,accdia
,acchora
,accelap
,accbytes
);
186 if(iprel
) gravaporuser(uinfo
,outdirname
,accurl
,accip
,accdia
,acchora
,accbytes
,accelap
);
190 url_len
=strlen(accurl
);
191 if (!oldurl
|| url_len
>=ourl_size
) {
193 oldurl
=realloc(oldurl
,ourl_size
);
195 debuga(_("Not enough memory to store the url\n"));
199 strcpy(oldurl
,accurl
);
200 strcpy(oldacccode
,acccode
);
202 strcpy(oldaccip
,accip
);
203 strcpy(oldaccdia
,accdia
);
204 strcpy(oldacchora
,acchora
);
208 same_url
=(strcmp(oldurl
,accurl
) == 0);
210 if(site
[0] != '\0') {
212 if(strstr(oldacccode
,"DENIED") != 0)
213 strcpy(oldmsg
,"DENIED");
216 if (!indexonly
) gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,incache
,oucache
);
217 gravager(fp_gen
,wdirname
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
225 if(!same_url
|| new_user
){
226 if(strstr(oldacccode
,"DENIED") != 0)
227 strcpy(oldmsg
,"DENIED");
230 if (!indexonly
) gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,incache
,oucache
);
231 gravager(fp_gen
,wdirname
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
243 if ((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0 && !indexonly
&&
244 (!oldurltt
|| strcmp(oldurltt
,accurl
) || strcmp(oldaccdiatt
,accdia
) || strcmp(oldacchoratt
,acchora
))) {
247 snprintf(arqtt
,sizeof(arqtt
),"%s/%s",outdirname
,uinfo
->filename
);
248 if(access(arqtt
, R_OK
) != 0)
250 url_to_file(accurl
,siteind
,sizeof(siteind
));
251 snprintf(arqtt
,sizeof(arqtt
),"%s/%s/tt%s-%s.html",outdirname
,uinfo
->filename
,uinfo
->filename
,siteind
);
252 if ((fp_tt
= fopen(arqtt
, "w")) == 0) {
253 debuga(_("(report) Cannot open file %s\n"),arqtt
);
260 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s",FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
262 sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
265 write_html_header(fp_tt
,(IndexTree
== INDEX_TREE_DATE
) ? 4 : 2,_("Site access report"),HTML_JS_NONE
);
266 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period
.html
);
267 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo
->label
);
268 fputs("<tr><td class=\"header_c\">",fp_tt
);
269 fprintf(fp_tt
,_("Sort: %s, %s"),sort_field
,sort_order
);
270 fputs("</td></tr>\n",fp_tt
);
271 fprintf(fp_tt
,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User"));
272 close_html_header(fp_tt
);
274 fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt
);
275 strncpy(tmp4
,_("DATE/TIME"),4);
277 fprintf(fp_tt
,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("ACCESSED SITE"),tmp4
,_("DATE/TIME")+5);
280 fputs("<tr><td class=\"data\">",fp_tt
);
281 output_html_string(fp_tt
,accurl
,100);
282 fprintf(fp_tt
,"</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accdia
,acchora
);
284 url_len
=strlen(accurl
);
285 if (!oldurltt
|| url_len
>=ourltt_size
) {
286 ourltt_size
=url_len
+1;
287 oldurltt
=realloc(oldurltt
,ourltt_size
);
289 debuga(_("Not enough memory to store the url\n"));
293 strcpy(oldurltt
,accurl
);
294 strcpy(oldaccdiatt
,accdia
);
295 strcpy(oldacchoratt
,acchora
);
298 strcpy(crc2
,acccode
);
299 str
=strchr(crc2
,'/');
301 if(strstr(crc2
,"MISS") != 0)
303 else incache
+=accbytes
;
307 if (!indexonly
) day_totalize(tmp
,puinfo
);
311 strcpy(oldacccode
,acccode
);
312 strcpy(oldaccip
,accip
);
314 url_len
=strlen(accurl
);
315 if (url_len
>=ourl_size
) {
317 oldurl
=realloc(oldurl
,ourl_size
);
319 debuga(_("Not enough memory to store the url\n"));
323 strcpy(oldurl
,accurl
);
325 strcpy(oldaccdia
,accdia
);
326 strcpy(oldacchora
,acchora
);
330 longline_destroy(&line
);
331 if (oldurltt
) free(oldurltt
);
333 debuga(_("Cannot delete %s - %s\n"),tmp3
,strerror(errno
));
337 userinfo_stopscan(uscan
);
340 if(strstr(oldacccode
,"DENIED") != 0)
341 strcpy(oldmsg
,"DENIED");
344 if (!indexonly
) gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,incache
,oucache
);
345 gravager(fp_gen
,wdirname
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
348 totalger(fp_gen
,wdirname
);
350 if (puinfo
&& !indexonly
) day_totalize(tmp
,puinfo
);
352 if (!indexonly
) tmpsort();
354 if(email
[0] == '\0') {
356 if((ReportType
& REPORT_TYPE_DOWNLOADS
) != 0) download_report();
358 if(DansGuardianConf
[0] != '\0') {
368 if((ReportType
& REPORT_TYPE_TOPSITES
) != 0) topsites();
370 if((ReportType
& REPORT_TYPE_SITES_USERS
) != 0) siteuser();
375 if(smartfilter
) smartfilter_report();
377 if(DansGuardianConf
[0] != '\0') dansguardian_report();
381 if((ReportType
& REPORT_TYPE_USERS_SITES
) != 0) htmlrel();
386 if(SuccessfulMsg
) debuga(_("Successful report generated on %s\n"),outdirname
);
388 geramail(outdirname
, debug
, outdir
, email
, tmp
);
390 if((strcmp(email
,"stdout") != 0) && SuccessfulMsg
)
391 debuga(_("Successful report generated and sent to %s\n"),email
);
394 if(indexonly
) index_only(outdirname
, debug
);
396 removetmp(outdirname
);
400 static void maketmp(const char *user
, const char *dirname
, int debug
)
403 char wdirname
[MAXLEN
];
405 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
407 if(debug
) debuga(_("Making file: %s/%s\n"),tmp
,user
);
408 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,user
)>=sizeof(wdirname
)) {
409 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,user
);
413 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
414 debuga(_("(report) Cannot open file %s\n"),wdirname
);
423 static void maketmp_hour(const char *user
, const char *dirname
)
426 char wdirname
[MAXLEN
];
428 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
429 if(datetimeby
==0) return;
431 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,user
)>=sizeof(wdirname
)) {
432 debuga(_("Temporary file name too long: %s/%s.htmp\n"),tmp
,user
);
436 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
437 debuga(_("(report-1) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
446 static void gravatmp(const struct userinfostruct
*uinfo
, const char *oldurl
, long long int nacc
, long long int nbytes
, const char *oldmsg
, long long int nelap
, long long int incache
, long long int oucache
)
449 char wdirname
[MAXLEN
];
451 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
453 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
454 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,uinfo
->filename
);
458 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
459 debuga(_("(report) Cannot open file %s\n"),wdirname
);
464 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
465 to print a long long int unless it is exactly 64-bits long.
467 fprintf(fp_ou
,"%"PRIu64
"\t%"PRIu64
"\t%s\t%s\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\n",(uint64_t)nacc
,(uint64_t)nbytes
,oldurl
,oldmsg
,(uint64_t)nelap
,(uint64_t)incache
,(uint64_t)oucache
);
469 if (fclose(fp_ou
)==EOF
) {
470 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
476 fputs("</table>\n</div>\n",fp_tt
);
477 fputs("</body>\n</html>\n",fp_tt
);
485 static void gravatmp_hora(const char *dirname
, const struct userinfostruct
*uinfo
, const char *data
, const char *hora
, long long int elap
, long long int bytes
)
488 char wdirname
[MAXLEN
];
491 if(((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) || datetimeby
==0) return;
493 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
494 debuga(_("Path too long %s/%s.htmp\n"),tmp
,uinfo
->filename
);
498 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
499 debuga(_("(report-2) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
504 fprintf(fp_ou
,"%s\t%d",data
,hour
);
505 if((datetimeby
& DATETIME_BYTE
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)bytes
);
506 if((datetimeby
& DATETIME_ELAP
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)elap
);
509 if (fclose(fp_ou
)==EOF
) {
510 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
518 static void gravaporuser(const struct userinfostruct
*uinfo
, const char *dirname
, const char *url
, const char *ip
, const char *data
, const char *hora
, long long int tam
, long long int elap
)
521 char wdirname
[MAXLEN
];
523 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
525 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
526 debuga(_("Path too long %s/%s.ip\n"),tmp
,uinfo
->filename
);
530 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
531 debuga(_("(report) Cannot open file %s\n"),wdirname
);
536 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
537 to print a long long int unless it is exactly 64-bits long.
539 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%"PRIu64
"\t%"PRIu64
"\n",ip
,url
,data
,hora
,(uint64_t)tam
,(uint64_t)elap
);
547 static void gravager(FILE *fp_gen
,const char *filename
, const struct userinfostruct
*uinfo
, long long int nacc
, const char *url
, long long int nbytes
, const char *ip
, const char *hora
, const char *dia
, long long int nelap
, long long int incache
, long long int oucache
)
550 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
551 to print a long long int unless it is exactly 64-bits long.
553 if (fprintf(fp_gen
,"%s\t%"PRIu64
"\t%"PRIu64
"\t%s\t%s\t%s\t%s\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\n",uinfo
->id
,(uint64_t)nacc
,(uint64_t)nbytes
,url
,ip
,hora
,dia
,(uint64_t)nelap
,(uint64_t)incache
,(uint64_t)oucache
)<0) {
554 debuga(_("Failed to write a line in %s\n"),filename
);
559 globstat
.nbytes
+=nbytes
;
560 globstat
.elap
+=nelap
;
561 globstat
.incache
+=incache
;
562 globstat
.oucache
+=oucache
;
567 Write the total line at the end of the general file.
569 void totalger(FILE *fp_gen
,const char *filename
)
572 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
573 to print a long long int unless it is exactly 64-bits long.
575 if (fprintf(fp_gen
,"TOTAL\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\n",(uint64_t)globstat
.nacc
,(uint64_t)globstat
.nbytes
,(uint64_t)globstat
.elap
,(uint64_t)globstat
.incache
,(uint64_t)globstat
.oucache
)<0) {
576 debuga(_("Failed to write the total line in %s\n"),filename
);
581 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
)
585 long long int number
;
587 if (strncmp(buffer
,"TOTAL\t",6)==0) {
592 if (*buffer
== '-') {
595 } else if (*buffer
== '+') {
599 while (isdigit(*buffer
))
600 number
=(number
* 10) + (*buffer
++)-'0';
602 debuga(_("Invalid total number of accesses in %s\n"),filename
);
606 item
->nacc
=number
*sign
;
609 if (*buffer
== '-') {
612 } else if (*buffer
== '+') {
616 while (isdigit(*buffer
))
617 number
=(number
* 10) + (*buffer
++)-'0';
619 debuga(_("Invalid total size in %s\n"),filename
);
623 item
->nbytes
=number
*sign
;
626 if (*buffer
== '-') {
629 } else if (*buffer
== '+') {
633 while (isdigit(*buffer
))
634 number
=(number
* 10) + (*buffer
++)-'0';
636 debuga(_("Invalid total elapsed time in %s\n"),filename
);
640 item
->nelap
=number
*sign
;
643 if (*buffer
== '-') {
646 } else if (*buffer
== '+') {
650 while (isdigit(*buffer
))
651 number
=(number
* 10) + (*buffer
++)-'0';
653 debuga(_("Invalid total cache hit in %s\n"),filename
);
657 item
->incache
=number
*sign
;
660 if (*buffer
== '-') {
663 } else if (*buffer
== '+') {
667 while (isdigit(*buffer
))
668 number
=(number
* 10) + (*buffer
++)-'0';
670 debuga(_("Invalid total cache miss in %s\n"),filename
);
673 item
->oucache
=number
*sign
;
678 for (i
=0 ; i
<MAX_USER_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
680 debuga(_("User name too long or invalid in %s\n"),filename
);
686 if (*buffer
== '-') {
689 } else if (*buffer
== '+') {
693 while (isdigit(*buffer
))
694 number
=(number
* 10) + (*buffer
++)-'0';
696 debuga(_("Invalid number of accesses in %s\n"),filename
);
700 item
->nacc
=number
*sign
;
703 if (*buffer
== '-') {
706 } else if (*buffer
== '+') {
710 while (isdigit(*buffer
))
711 number
=(number
* 10) + (*buffer
++)-'0';
713 debuga(_("Invalid number of bytes in %s\n"),filename
);
717 item
->nbytes
=number
*sign
;
720 while ((unsigned char)*buffer
>=' ') buffer
++;
722 debuga(_("URL too long or invalid in %s\n"),filename
);
728 for (i
=0 ; i
<MAX_IP_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
730 debuga(_("IP address too long or invalid in %s\n"),filename
);
736 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
738 debuga(_("Time too long or invalid in %s\n"),filename
);
744 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
746 debuga(_("Date too long or invalid in %s\n"),filename
);
752 if (*buffer
== '-') {
755 } else if (*buffer
== '+') {
759 while (isdigit(*buffer
))
760 number
=(number
* 10) + (*buffer
++)-'0';
762 debuga(_("Invalid elapsed time in %s\n"),filename
);
766 item
->nelap
=number
*sign
;
769 if (*buffer
== '-') {
772 } else if (*buffer
== '+') {
776 while (isdigit(*buffer
))
777 number
=(number
* 10) + (*buffer
++)-'0';
779 debuga(_("Invalid cache hit size in %s\n"),filename
);
783 item
->incache
=number
*sign
;
786 if (*buffer
== '-') {
789 } else if (*buffer
== '+') {
793 while (isdigit(*buffer
))
794 number
=(number
* 10) + (*buffer
++)-'0';
796 debuga(_("Invalid cache miss size in %s\n"),filename
);
799 item
->oucache
=number
*sign
;
804 static void grava_SmartFilter(const char *dirname
, const char *user
, const char *ip
, const char *data
, const char *hora
, const char *url
, const char *smart
)
807 char wdirname
[MAXLEN
];
809 sprintf(wdirname
,"%s/smartfilter.unsort",dirname
);
811 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
812 debuga(_("(report) Cannot open file %s\n"),wdirname
);
816 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%s\t%s\n",user
,data
,hora
,ip
,url
,smart
);
817 fputs("</body>\n</html>\n",fp_tt
);