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') {
355 if((ReportType
& REPORT_TYPE_DOWNLOADS
) != 0) download_report();
357 if(DansGuardianConf
[0] != '\0') {
365 if((ReportType
& REPORT_TYPE_TOPSITES
) != 0) topsites();
367 if((ReportType
& REPORT_TYPE_SITES_USERS
) != 0) siteuser();
372 if(smartfilter
) smartfilter_report();
374 if(DansGuardianConf
[0] != '\0') dansguardian_report();
378 if(!indexonly
&& (ReportType
& REPORT_TYPE_USERS_SITES
) != 0) htmlrel();
382 if(SuccessfulMsg
) debuga(_("Successful report generated on %s\n"),outdirname
);
384 geramail(outdirname
, debug
, outdir
, email
, tmp
);
386 if((strcmp(email
,"stdout") != 0) && SuccessfulMsg
)
387 debuga(_("Successful report generated and sent to %s\n"),email
);
390 if(indexonly
) index_only(outdirname
, debug
);
392 removetmp(outdirname
);
396 static void maketmp(const char *user
, const char *dirname
, int debug
)
399 char wdirname
[MAXLEN
];
401 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
403 if(debug
) debuga(_("Making file: %s/%s\n"),tmp
,user
);
404 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,user
)>=sizeof(wdirname
)) {
405 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,user
);
409 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
410 debuga(_("(report) Cannot open file %s\n"),wdirname
);
419 static void maketmp_hour(const char *user
, const char *dirname
)
422 char wdirname
[MAXLEN
];
424 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
425 if(datetimeby
==0) return;
427 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,user
)>=sizeof(wdirname
)) {
428 debuga(_("Temporary file name too long: %s/%s.htmp\n"),tmp
,user
);
432 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
433 debuga(_("(report-1) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
442 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
)
445 char wdirname
[MAXLEN
];
447 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
449 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
450 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,uinfo
->filename
);
454 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
455 debuga(_("(report) Cannot open file %s\n"),wdirname
);
460 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
461 to print a long long int unless it is exactly 64-bits long.
463 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
);
465 if (fclose(fp_ou
)==EOF
) {
466 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
472 fputs("</table>\n</div>\n",fp_tt
);
473 fputs("</body>\n</html>\n",fp_tt
);
481 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
)
484 char wdirname
[MAXLEN
];
487 if(((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) || datetimeby
==0) return;
489 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
490 debuga(_("Path too long %s/%s.htmp\n"),tmp
,uinfo
->filename
);
494 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
495 debuga(_("(report-2) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
500 fprintf(fp_ou
,"%s\t%d",data
,hour
);
501 if((datetimeby
& DATETIME_BYTE
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)bytes
);
502 if((datetimeby
& DATETIME_ELAP
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)elap
);
505 if (fclose(fp_ou
)==EOF
) {
506 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
514 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
)
517 char wdirname
[MAXLEN
];
519 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
521 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
522 debuga(_("Path too long %s/%s.ip\n"),tmp
,uinfo
->filename
);
526 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
527 debuga(_("(report) Cannot open file %s\n"),wdirname
);
532 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
533 to print a long long int unless it is exactly 64-bits long.
535 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
);
543 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
)
546 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
547 to print a long long int unless it is exactly 64-bits long.
549 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) {
550 debuga(_("Failed to write a line in %s\n"),filename
);
555 globstat
.nbytes
+=nbytes
;
556 globstat
.elap
+=nelap
;
557 globstat
.incache
+=incache
;
558 globstat
.oucache
+=oucache
;
563 Write the total line at the end of the general file.
565 void totalger(FILE *fp_gen
,const char *filename
)
568 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
569 to print a long long int unless it is exactly 64-bits long.
571 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) {
572 debuga(_("Failed to write the total line in %s\n"),filename
);
577 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
)
581 long long int number
;
583 if (strncmp(buffer
,"TOTAL\t",6)==0) {
588 if (*buffer
== '-') {
591 } else if (*buffer
== '+') {
595 while (isdigit(*buffer
))
596 number
=(number
* 10) + (*buffer
++)-'0';
598 debuga(_("Invalid total number of accesses in %s\n"),filename
);
602 item
->nacc
=number
*sign
;
605 if (*buffer
== '-') {
608 } else if (*buffer
== '+') {
612 while (isdigit(*buffer
))
613 number
=(number
* 10) + (*buffer
++)-'0';
615 debuga(_("Invalid total size in %s\n"),filename
);
619 item
->nbytes
=number
*sign
;
622 if (*buffer
== '-') {
625 } else if (*buffer
== '+') {
629 while (isdigit(*buffer
))
630 number
=(number
* 10) + (*buffer
++)-'0';
632 debuga(_("Invalid total elapsed time in %s\n"),filename
);
636 item
->nelap
=number
*sign
;
639 if (*buffer
== '-') {
642 } else if (*buffer
== '+') {
646 while (isdigit(*buffer
))
647 number
=(number
* 10) + (*buffer
++)-'0';
649 debuga(_("Invalid total cache hit in %s\n"),filename
);
653 item
->incache
=number
*sign
;
656 if (*buffer
== '-') {
659 } else if (*buffer
== '+') {
663 while (isdigit(*buffer
))
664 number
=(number
* 10) + (*buffer
++)-'0';
666 debuga(_("Invalid total cache miss in %s\n"),filename
);
669 item
->oucache
=number
*sign
;
674 for (i
=0 ; i
<MAX_USER_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
676 debuga(_("User name too long or invalid in %s\n"),filename
);
682 if (*buffer
== '-') {
685 } else if (*buffer
== '+') {
689 while (isdigit(*buffer
))
690 number
=(number
* 10) + (*buffer
++)-'0';
692 debuga(_("Invalid number of accesses in %s\n"),filename
);
696 item
->nacc
=number
*sign
;
699 if (*buffer
== '-') {
702 } else if (*buffer
== '+') {
706 while (isdigit(*buffer
))
707 number
=(number
* 10) + (*buffer
++)-'0';
709 debuga(_("Invalid number of bytes in %s\n"),filename
);
713 item
->nbytes
=number
*sign
;
716 while ((unsigned char)*buffer
>=' ') buffer
++;
718 debuga(_("URL too long or invalid in %s\n"),filename
);
724 for (i
=0 ; i
<MAX_IP_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
726 debuga(_("IP address too long or invalid in %s\n"),filename
);
732 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
734 debuga(_("Time too long or invalid in %s\n"),filename
);
740 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
742 debuga(_("Date too long or invalid in %s\n"),filename
);
748 if (*buffer
== '-') {
751 } else if (*buffer
== '+') {
755 while (isdigit(*buffer
))
756 number
=(number
* 10) + (*buffer
++)-'0';
758 debuga(_("Invalid elapsed time in %s\n"),filename
);
762 item
->nelap
=number
*sign
;
765 if (*buffer
== '-') {
768 } else if (*buffer
== '+') {
772 while (isdigit(*buffer
))
773 number
=(number
* 10) + (*buffer
++)-'0';
775 debuga(_("Invalid cache hit size in %s\n"),filename
);
779 item
->incache
=number
*sign
;
782 if (*buffer
== '-') {
785 } else if (*buffer
== '+') {
789 while (isdigit(*buffer
))
790 number
=(number
* 10) + (*buffer
++)-'0';
792 debuga(_("Invalid cache miss size in %s\n"),filename
);
795 item
->oucache
=number
*sign
;
800 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
)
803 char wdirname
[MAXLEN
];
805 sprintf(wdirname
,"%s/smartfilter.unsort",dirname
);
807 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
808 debuga(_("(report) Cannot open file %s\n"),wdirname
);
812 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%s\t%s\n",user
,data
,hora
,ip
,url
,smart
);
813 fputs("</body>\n</html>\n",fp_tt
);