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
;
32 //! \c True to enable the smart filter.
33 bool smartfilter
=false;
35 //! The file to store the HTML page where the time of access is reported for one site and one user.
36 static FILE *fp_tt
=NULL
;
37 //! The name of the file containing the access time of the site/user.
38 static char arqtt
[4096]="";
40 static FILE *maketmp(const char *user
, const char *dirname
, int debug
);
41 static void gravatmp(FILE *fp_ou
, 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
);
42 static void closett(void);
43 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
);
44 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
);
45 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
);
54 char accdia
[11], acchora
[9], accip
[256], *accurl
;
55 char oldaccdia
[11], oldacchora
[9], oldaccip
[256];
57 char wdirname
[MAXLEN
];
59 char oldmsg
[50], acccode
[MAXLEN
/2 - 1], oldacccode
[MAXLEN
/2 - 1];
60 char ipantes
[256], nameantes
[MAXLEN
];
61 char accsmart
[MAXLEN
];
62 char crc2
[MAXLEN
/2 -1];
63 char siteind
[MAX_TRUNCATED_URL
];
65 char oldaccdiatt
[11],oldacchoratt
[9];
67 char u2
[MAX_USER_LEN
];
68 char userlabel
[MAX_USER_LEN
];
69 long long int nbytes
=0;
70 long long int nelap
=0;
72 long long int incache
=0;
73 long long int oucache
=0;
74 long long int accbytes
, accelap
;
77 const char *sort_field
;
78 const char *sort_order
;
85 struct getwordstruct gwarea
;
87 struct userinfostruct
*uinfo
;
92 memset(&globstat
,0,sizeof(globstat
));
94 if (vrfydir(&period
, addr
, site
, us
, email
)<0) {
95 debuga(_("Cannot create the output directory name containing the period as part of the name\n"));
99 if(debugz
>=LogLevel_Process
){
100 debugaz(_("outdirname=%s\n"),outdirname
);
103 if(UserAgentLog
[0] != '\0' && email
[0] == '\0') useragent();
105 snprintf(wdirname
,sizeof(wdirname
),"%s/sarg-general",outdirname
);
106 if((fp_gen
=MY_FOPEN(wdirname
,"w"))==NULL
){
107 debuga(_("(report) Cannot open file %s: %s\n"),wdirname
,strerror(errno
));
112 sort_labels(&sort_field
,&sort_order
);
114 if (indexonly
|| datetimeby
==0)
117 daystat
=day_prepare();
119 uscan
=userinfo_startscan();
121 debuga(_("Cannot enumerate the user list\n"));
124 while ((uinfo
= userinfo_advancescan(uscan
)) != NULL
) {
125 sort_users_log(tmp
,debug
,uinfo
);
126 if (snprintf(tmp3
,sizeof(tmp3
),"%s/%s.user_log",tmp
,uinfo
->filename
)>=sizeof(tmp3
)) {
127 debuga(_("(report) directory entry too long: %s/%s.user_log\n"),tmp
,uinfo
->filename
);
130 if((fp_in
=MY_FOPEN(tmp3
,"r"))==NULL
){
131 debuga(_("(report) Cannot open file %s: %s\n"),tmp
,strerror(errno
));
134 user
=uinfo
->filename
;
135 day_newuser(daystat
);
137 strcpy(u2
,uinfo
->id
);
138 if(Ip2Name
&& uinfo
->id_is_ip
) {
139 safe_strcpy(ipantes
,u2
,sizeof(ipantes
));
140 ip2name(u2
,sizeof(u2
));
141 strcpy(nameantes
,u2
);
143 user_find(userlabel
,MAX_USER_LEN
, u2
);
144 userinfo_label(uinfo
,userlabel
);
147 fp_tmp
=maketmp(user
,tmp
,debug
);
154 memset(oldaccdiatt
,0,sizeof(oldaccdiatt
));
155 memset(oldacchoratt
,0,sizeof(oldacchoratt
));
156 memset(oldacciptt
,0,sizeof(oldacciptt
));
164 if ((line
=longline_create())==NULL
) {
165 debuga(_("Not enough memory to read the downloaded files\n"));
169 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
170 getword_start(&gwarea
,buf
);
171 if (getword(accdia
,sizeof(accdia
),&gwarea
,'\t')<0 || getword(acchora
,sizeof(acchora
),&gwarea
,'\t')<0 ||
172 getword(accip
,sizeof(accip
),&gwarea
,'\t')<0 ||
173 getword_ptr(buf
,&accurl
,&gwarea
,'\t')<0 || getword_atoll(&accbytes
,&gwarea
,'\t')<0 ||
174 getword(acccode
,sizeof(acccode
),&gwarea
,'\t')<0) {
175 debuga(_("There is a broken record or garbage in file %s\n"),tmp3
);
178 if(strncmp(acccode
,"TCP_DENIED/407",14) == 0) continue;
179 if (getword_atoll(&accelap
,&gwarea
,'\t')<0) {
180 debuga(_("There is a broken elapsed time in file %s\n"),tmp3
);
183 if (getword_skip(20000,&gwarea
,'"')<0 || getword(accsmart
,sizeof(accsmart
),&gwarea
,'"')<0) {
184 debuga(_("There is a broken smart info in file %s\n"),tmp3
);
188 if(accsmart
[0] != '\0') {
190 grava_SmartFilter(tmp
,uinfo
->id
,accip
,accdia
,acchora
,accurl
,accsmart
);
194 if(strcmp(accip
,ipantes
) != 0) {
195 strcpy(ipantes
,accip
);
196 ip2name(accip
,sizeof(accip
));
197 strcpy(nameantes
,accip
);
198 } else safe_strcpy(accip
,nameantes
,sizeof(accip
));
202 day_addpoint(daystat
,accdia
,acchora
,accelap
,accbytes
);
203 if (iprel
) gravaporuser(uinfo
,outdirname
,accurl
,accip
,accdia
,acchora
,accbytes
,accelap
);
207 url_len
=strlen(accurl
);
208 if (!oldurl
|| url_len
>=ourl_size
) {
210 oldurl
=realloc(oldurl
,ourl_size
);
212 debuga(_("Not enough memory to store the url\n"));
216 strcpy(oldurl
,accurl
);
217 strcpy(oldacccode
,acccode
);
218 strcpy(oldaccip
,accip
);
219 strcpy(oldaccdia
,accdia
);
220 strcpy(oldacchora
,acchora
);
223 same_url
=(strcmp(oldurl
,accurl
) == 0);
225 if(site
[0] == '\0') {
227 if(strstr(oldacccode
,"DENIED") != 0)
228 strcpy(oldmsg
,"DENIED");
231 if (fp_tmp
) gravatmp(fp_tmp
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,incache
,oucache
);
232 gravager(fp_gen
,wdirname
,uinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
244 if ((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0 && !indexonly
&&
245 (!oldurltt
|| strcmp(oldurltt
,accurl
) || strcmp(oldaccdiatt
,accdia
) || strcmp(oldacchoratt
,acchora
) ||
246 strcmp(oldacciptt
,accip
))) {
249 snprintf(arqtt
,sizeof(arqtt
),"%s/%s",outdirname
,uinfo
->filename
);
250 if(access(arqtt
, R_OK
) != 0)
252 snprintf(arqtt
,sizeof(arqtt
),"%s/%s/tt.html",outdirname
,uinfo
->filename
);
253 if ((fp_tt
= fopen(arqtt
, "w")) == 0) {
254 debuga(_("(report) Cannot open file %s: %s\n"),arqtt
,strerror(errno
));
261 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s",FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
263 sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
266 write_html_header(fp_tt
,(IndexTree
== INDEX_TREE_DATE
) ? 4 : 2,_("Site access report"),HTML_JS_NONE
);
267 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period
.html
);
268 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo
->label
);
269 fputs("<tr><td class=\"header_c\">",fp_tt
);
270 fprintf(fp_tt
,_("Sort: %s, %s"),sort_field
,sort_order
);
271 fputs("</td></tr>\n",fp_tt
);
272 fprintf(fp_tt
,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User"));
273 close_html_header(fp_tt
);
275 fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt
);
277 if (!oldurltt
|| strcmp(oldurltt
,accurl
)) {
278 const char *url
=accurl
;
279 if (*url
==ALIAS_PREFIX
) url
++;
280 url_to_anchor(accurl
,siteind
,sizeof(siteind
));
281 fprintf(fp_tt
,"<tr class=\"tt\"><td colspan=\"3\"><a name=\"%s\">",siteind
);
282 fprintf(fp_tt
,"<b>%s</b>",_("Accessed site: "));
283 output_html_string(fp_tt
,url
,100);
284 fputs("</a></td></tr>\n",fp_tt
);
285 fprintf(fp_tt
,"<tr><th class=\"header_l\">%s</th>",_("IP"));
286 fprintf(fp_tt
,"<th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("DATE"),pgettext("wall clock","TIME"));
289 fprintf(fp_tt
,"<tr><td class=\"data2\">%s</td>",accip
);
290 fprintf(fp_tt
,"<td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accdia
,acchora
);
292 url_len
=strlen(accurl
);
293 if (!oldurltt
|| url_len
>=ourltt_size
) {
294 ourltt_size
=url_len
+1;
295 oldurltt
=realloc(oldurltt
,ourltt_size
);
297 debuga(_("Not enough memory to store the url\n"));
301 strcpy(oldurltt
,accurl
);
302 strcpy(oldaccdiatt
,accdia
);
303 strcpy(oldacchoratt
,acchora
);
304 strcpy(oldacciptt
,accip
);
307 strcpy(crc2
,acccode
);
308 str
=strchr(crc2
,'/');
310 if(strstr(crc2
,"MISS") != 0)
315 strcpy(oldacccode
,acccode
);
316 strcpy(oldaccip
,accip
);
318 url_len
=strlen(accurl
);
319 if (url_len
>=ourl_size
) {
321 oldurl
=realloc(oldurl
,ourl_size
);
323 debuga(_("Not enough memory to store the url\n"));
327 strcpy(oldurl
,accurl
);
329 strcpy(oldaccdia
,accdia
);
330 strcpy(oldacchora
,acchora
);
333 longline_destroy(&line
);
334 if (oldurltt
) free(oldurltt
);
336 if(strstr(oldacccode
,"DENIED") != 0)
337 strcpy(oldmsg
,"DENIED");
340 if (fp_tmp
) gravatmp(fp_tmp
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,incache
,oucache
);
342 gravager(fp_gen
,wdirname
,uinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
347 day_totalize(daystat
,tmp
,uinfo
);
350 if (fclose(fp_tmp
)==EOF
) {
351 debuga(_("Failed to close temporary file for user %s: %s\n"),uinfo
->filename
,strerror(errno
));
356 if (!KeepTempLog
&& unlink(tmp3
)) {
357 debuga(_("Cannot delete \"%s\": %s\n"),tmp3
,strerror(errno
));
361 userinfo_stopscan(uscan
);
362 day_cleanup(daystat
);
364 totalger(fp_gen
,wdirname
);
365 if (fclose(fp_gen
)==EOF
) {
366 debuga(_("Write error in %s: %s\n"),wdirname
,strerror(errno
));
370 if(email
[0] == '\0') {
372 if(DansGuardianConf
[0] != '\0')
374 else if (debugz
>=LogLevel_Process
)
375 debugaz(_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
383 if((ReportType
& REPORT_TYPE_DOWNLOADS
) != 0)
385 else if (debugz
>=LogLevel_Process
)
386 debugaz(_("Downloaded files report not requested in report_type\n"));
388 if((ReportType
& REPORT_TYPE_TOPSITES
) != 0)
390 else if (debugz
>=LogLevel_Process
)
391 debugaz(_("Top sites report not requested in report_type\n"));
393 if((ReportType
& REPORT_TYPE_SITES_USERS
) != 0)
395 else if (debugz
>=LogLevel_Process
)
396 debugaz(_("Sites & users report not requested in report_type\n"));
398 if ((ReportType
& REPORT_TYPE_DENIED
) != 0)
400 else if (debugz
>=LogLevel_Process
)
401 debugaz(_("Denied accesses report not requested in report_type\n"));
403 if ((ReportType
& REPORT_TYPE_AUTH_FAILURES
) != 0)
405 else if (debugz
>=LogLevel_Process
)
406 debugaz(_("Authentication failures report not requested in report_type\n"));
408 if(smartfilter
) smartfilter_report();
410 if(DansGuardianConf
[0] != '\0')
411 dansguardian_report();
415 if((ReportType
& REPORT_TYPE_USERS_SITES
) != 0)
417 else if (debugz
>=LogLevel_Process
)
418 debugaz(_("User's detailed report not requested in report_type\n"));
423 if(SuccessfulMsg
) debuga(_("Successful report generated on %s\n"),outdirname
);
425 geramail(outdirname
, debug
, outdir
, email
, tmp
);
427 if((strcmp(email
,"stdout") != 0) && SuccessfulMsg
)
428 debuga(_("Successful report generated and sent to %s\n"),email
);
431 if(indexonly
) index_only(outdirname
, debug
);
433 removetmp(outdirname
);
437 static FILE *maketmp(const char *user
, const char *dirname
, int debug
)
440 char wdirname
[MAXLEN
];
442 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return(NULL
);
443 if((ReportType
& REPORT_TYPE_TOPUSERS
) == 0) return(NULL
);
445 if(debug
) debuga(_("Making file: %s/%s\n"),tmp
,user
);
446 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,user
)>=sizeof(wdirname
)) {
447 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,user
);
451 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
452 debuga(_("(report) Cannot open file %s: %s\n"),wdirname
,strerror(errno
));
460 static void gravatmp(FILE *fp_ou
, 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
)
463 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
464 to print a long long int unless it is exactly 64-bits long.
466 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
);
471 static void closett(void)
476 fputs("</table>\n</div>\n",fp_tt
);
477 fputs("</body>\n</html>\n",fp_tt
);
478 if (fclose(fp_tt
)==EOF
) {
479 debuga(_("Write error in %s: %s\n"),arqtt
,strerror(errno
));
486 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
)
489 char wdirname
[MAXLEN
];
491 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
493 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
494 debuga(_("Path too long %s/%s.ip\n"),tmp
,uinfo
->filename
);
498 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
499 debuga(_("(report) Cannot open file %s: %s\n"),wdirname
,strerror(errno
));
504 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
505 to print a long long int unless it is exactly 64-bits long.
507 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
);
509 if (fclose(fp_ou
)==EOF
) {
510 debuga(_("Write error in %s: %s\n"),wdirname
,strerror(errno
));
518 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
)
521 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
522 to print a long long int unless it is exactly 64-bits long.
524 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) {
525 debuga(_("Failed to write a line in %s\n"),filename
);
530 globstat
.nbytes
+=nbytes
;
531 globstat
.elap
+=nelap
;
532 globstat
.incache
+=incache
;
533 globstat
.oucache
+=oucache
;
538 Write the total line at the end of the general file.
540 void totalger(FILE *fp_gen
,const char *filename
)
543 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
544 to print a long long int unless it is exactly 64-bits long.
546 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) {
547 debuga(_("Failed to write the total line in %s\n"),filename
);
552 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
)
556 long long int number
;
558 if (strncmp(buffer
,"TOTAL\t",6)==0) {
563 if (*buffer
== '-') {
566 } else if (*buffer
== '+') {
570 while (isdigit(*buffer
))
571 number
=(number
* 10) + (*buffer
++)-'0';
573 debuga(_("Invalid total number of accesses in %s\n"),filename
);
577 item
->nacc
=number
*sign
;
580 if (*buffer
== '-') {
583 } else if (*buffer
== '+') {
587 while (isdigit(*buffer
))
588 number
=(number
* 10) + (*buffer
++)-'0';
590 debuga(_("Invalid total size in %s\n"),filename
);
594 item
->nbytes
=number
*sign
;
597 if (*buffer
== '-') {
600 } else if (*buffer
== '+') {
604 while (isdigit(*buffer
))
605 number
=(number
* 10) + (*buffer
++)-'0';
607 debuga(_("Invalid total elapsed time in %s\n"),filename
);
611 item
->nelap
=number
*sign
;
614 if (*buffer
== '-') {
617 } else if (*buffer
== '+') {
621 while (isdigit(*buffer
))
622 number
=(number
* 10) + (*buffer
++)-'0';
624 debuga(_("Invalid total cache hit in %s\n"),filename
);
628 item
->incache
=number
*sign
;
631 if (*buffer
== '-') {
634 } else if (*buffer
== '+') {
638 while (isdigit(*buffer
))
639 number
=(number
* 10) + (*buffer
++)-'0';
641 debuga(_("Invalid total cache miss in %s\n"),filename
);
644 item
->oucache
=number
*sign
;
649 for (i
=0 ; i
<MAX_USER_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
651 debuga(_("User name too long or invalid in %s\n"),filename
);
657 if (*buffer
== '-') {
660 } else if (*buffer
== '+') {
664 while (isdigit(*buffer
))
665 number
=(number
* 10) + (*buffer
++)-'0';
667 debuga(_("Invalid number of accesses in %s\n"),filename
);
671 item
->nacc
=number
*sign
;
674 if (*buffer
== '-') {
677 } else if (*buffer
== '+') {
681 while (isdigit(*buffer
))
682 number
=(number
* 10) + (*buffer
++)-'0';
684 debuga(_("Invalid number of bytes in %s\n"),filename
);
688 item
->nbytes
=number
*sign
;
691 while ((unsigned char)*buffer
>=' ') buffer
++;
693 debuga(_("URL too long or invalid in %s\n"),filename
);
699 for (i
=0 ; i
<MAX_IP_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
701 debuga(_("IP address too long or invalid in %s\n"),filename
);
707 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
709 debuga(_("Time too long or invalid in %s\n"),filename
);
715 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
717 debuga(_("Date too long or invalid in %s\n"),filename
);
723 if (*buffer
== '-') {
726 } else if (*buffer
== '+') {
730 while (isdigit(*buffer
))
731 number
=(number
* 10) + (*buffer
++)-'0';
733 debuga(_("Invalid elapsed time in %s\n"),filename
);
737 item
->nelap
=number
*sign
;
740 if (*buffer
== '-') {
743 } else if (*buffer
== '+') {
747 while (isdigit(*buffer
))
748 number
=(number
* 10) + (*buffer
++)-'0';
750 debuga(_("Invalid cache hit size in %s\n"),filename
);
754 item
->incache
=number
*sign
;
757 if (*buffer
== '-') {
760 } else if (*buffer
== '+') {
764 while (isdigit(*buffer
))
765 number
=(number
* 10) + (*buffer
++)-'0';
767 debuga(_("Invalid cache miss size in %s\n"),filename
);
770 item
->oucache
=number
*sign
;
775 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
)
778 char wdirname
[MAXLEN
];
780 if (snprintf(wdirname
,sizeof(wdirname
),"%s/smartfilter.int_unsort",dirname
)>=sizeof(wdirname
)) {
781 debuga(_("File name too long for %s/smartfilter.int_unsort\n"),dirname
);
785 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
786 debuga(_("(report) Cannot open file %s: %s\n"),wdirname
,strerror(errno
));
790 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%s\t%s\n",user
,data
,hora
,ip
,url
,smart
);
791 fputs("</body>\n</html>\n",fp_tt
);
793 if (fclose(fp_ou
)==EOF
) {
794 debuga(_("Write error in %s: %s\n"),wdirname
,strerror(errno
));