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(_("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(_("Path too long: "));
128 debuga_more("%s/%s.user_log\n",tmp
,uinfo
->filename
);
131 if((fp_in
=MY_FOPEN(tmp3
,"r"))==NULL
){
132 debuga(_("Cannot open file \"%s\": %s\n"),tmp3
,strerror(errno
));
135 user
=uinfo
->filename
;
136 day_newuser(daystat
);
138 strcpy(u2
,uinfo
->id
);
139 if(Ip2Name
&& uinfo
->id_is_ip
) {
140 safe_strcpy(ipantes
,u2
,sizeof(ipantes
));
141 ip2name(u2
,sizeof(u2
));
142 strcpy(nameantes
,u2
);
144 user_find(userlabel
,MAX_USER_LEN
, u2
);
145 userinfo_label(uinfo
,userlabel
);
148 fp_tmp
=maketmp(user
,tmp
,debug
);
155 memset(oldaccdiatt
,0,sizeof(oldaccdiatt
));
156 memset(oldacchoratt
,0,sizeof(oldacchoratt
));
157 memset(oldacciptt
,0,sizeof(oldacciptt
));
165 if ((line
=longline_create())==NULL
) {
166 debuga(_("Not enough memory to read the downloaded files\n"));
170 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
171 getword_start(&gwarea
,buf
);
172 if (getword(accdia
,sizeof(accdia
),&gwarea
,'\t')<0 || getword(acchora
,sizeof(acchora
),&gwarea
,'\t')<0 ||
173 getword(accip
,sizeof(accip
),&gwarea
,'\t')<0 ||
174 getword_ptr(buf
,&accurl
,&gwarea
,'\t')<0 || getword_atoll(&accbytes
,&gwarea
,'\t')<0 ||
175 getword(acccode
,sizeof(acccode
),&gwarea
,'\t')<0) {
176 debuga(_("There is a broken record or garbage in file %s\n"),tmp3
);
179 if(strncmp(acccode
,"TCP_DENIED/407",14) == 0) continue;
180 if (getword_atoll(&accelap
,&gwarea
,'\t')<0) {
181 debuga(_("There is a broken elapsed time in file %s\n"),tmp3
);
184 if (getword_skip(20000,&gwarea
,'"')<0 || getword(accsmart
,sizeof(accsmart
),&gwarea
,'"')<0) {
185 debuga(_("There is a broken smart info in file %s\n"),tmp3
);
189 if(accsmart
[0] != '\0') {
191 grava_SmartFilter(tmp
,uinfo
->id
,accip
,accdia
,acchora
,accurl
,accsmart
);
195 if(strcmp(accip
,ipantes
) != 0) {
196 strcpy(ipantes
,accip
);
197 ip2name(accip
,sizeof(accip
));
198 strcpy(nameantes
,accip
);
199 } else safe_strcpy(accip
,nameantes
,sizeof(accip
));
203 day_addpoint(daystat
,accdia
,acchora
,accelap
,accbytes
);
204 if (iprel
) gravaporuser(uinfo
,outdirname
,accurl
,accip
,accdia
,acchora
,accbytes
,accelap
);
208 url_len
=strlen(accurl
);
209 if (!oldurl
|| url_len
>=ourl_size
) {
211 oldurl
=realloc(oldurl
,ourl_size
);
213 debuga(_("Not enough memory to store the url\n"));
217 strcpy(oldurl
,accurl
);
218 strcpy(oldacccode
,acccode
);
219 strcpy(oldaccip
,accip
);
220 strcpy(oldaccdia
,accdia
);
221 strcpy(oldacchora
,acchora
);
224 same_url
=(strcmp(oldurl
,accurl
) == 0);
226 if(site
[0] == '\0') {
228 if(strstr(oldacccode
,"DENIED") != 0)
229 strcpy(oldmsg
,"DENIED");
232 if (fp_tmp
) gravatmp(fp_tmp
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,incache
,oucache
);
233 gravager(fp_gen
,wdirname
,uinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
245 if ((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0 && !indexonly
&&
246 (!oldurltt
|| strcmp(oldurltt
,accurl
) || strcmp(oldaccdiatt
,accdia
) || strcmp(oldacchoratt
,acchora
) ||
247 strcmp(oldacciptt
,accip
))) {
250 snprintf(arqtt
,sizeof(arqtt
),"%s/%s",outdirname
,uinfo
->filename
);
251 if(access(arqtt
, R_OK
) != 0)
253 snprintf(arqtt
,sizeof(arqtt
),"%s/%s/tt.html",outdirname
,uinfo
->filename
);
254 if ((fp_tt
= fopen(arqtt
, "w")) == 0) {
255 debuga(_("Cannot open file \"%s\": %s\n"),arqtt
,strerror(errno
));
262 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s",FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
264 sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
267 write_html_header(fp_tt
,(IndexTree
== INDEX_TREE_DATE
) ? 4 : 2,_("Site access report"),HTML_JS_NONE
);
268 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period
.html
);
269 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo
->label
);
270 fputs("<tr><td class=\"header_c\">",fp_tt
);
271 fprintf(fp_tt
,_("Sort: %s, %s"),sort_field
,sort_order
);
272 fputs("</td></tr>\n",fp_tt
);
273 fprintf(fp_tt
,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User"));
274 close_html_header(fp_tt
);
276 fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt
);
278 if (!oldurltt
|| strcmp(oldurltt
,accurl
)) {
279 const char *url
=accurl
;
280 if (*url
==ALIAS_PREFIX
) url
++;
281 url_to_anchor(accurl
,siteind
,sizeof(siteind
));
282 fprintf(fp_tt
,"<tr class=\"tt\"><td colspan=\"3\"><a name=\"%s\">",siteind
);
283 fprintf(fp_tt
,"<b>%s</b>",_("Accessed site: "));
284 output_html_string(fp_tt
,url
,100);
285 fputs("</a></td></tr>\n",fp_tt
);
286 fprintf(fp_tt
,"<tr><th class=\"header_l\">%s</th>",_("IP"));
287 fprintf(fp_tt
,"<th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("DATE"),pgettext("wall clock","TIME"));
290 fprintf(fp_tt
,"<tr><td class=\"data2\">%s</td>",accip
);
291 fprintf(fp_tt
,"<td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accdia
,acchora
);
293 url_len
=strlen(accurl
);
294 if (!oldurltt
|| url_len
>=ourltt_size
) {
295 ourltt_size
=url_len
+1;
296 oldurltt
=realloc(oldurltt
,ourltt_size
);
298 debuga(_("Not enough memory to store the url\n"));
302 strcpy(oldurltt
,accurl
);
303 strcpy(oldaccdiatt
,accdia
);
304 strcpy(oldacchoratt
,acchora
);
305 strcpy(oldacciptt
,accip
);
308 strcpy(crc2
,acccode
);
309 str
=strchr(crc2
,'/');
311 if(strstr(crc2
,"MISS") != 0)
316 strcpy(oldacccode
,acccode
);
317 strcpy(oldaccip
,accip
);
319 url_len
=strlen(accurl
);
320 if (url_len
>=ourl_size
) {
322 oldurl
=realloc(oldurl
,ourl_size
);
324 debuga(_("Not enough memory to store the url\n"));
328 strcpy(oldurl
,accurl
);
330 strcpy(oldaccdia
,accdia
);
331 strcpy(oldacchora
,acchora
);
333 if (fclose(fp_in
)==EOF
) {
334 debuga(_("Read error in \"%s\": %s\n"),tmp3
,strerror(errno
));
337 longline_destroy(&line
);
338 if (oldurltt
) free(oldurltt
);
340 if(strstr(oldacccode
,"DENIED") != 0)
341 strcpy(oldmsg
,"DENIED");
344 if (fp_tmp
) gravatmp(fp_tmp
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,incache
,oucache
);
346 gravager(fp_gen
,wdirname
,uinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
351 day_totalize(daystat
,tmp
,uinfo
);
354 if (fclose(fp_tmp
)==EOF
) {
355 debuga(_("Write error in \"%s\": %s\n"),uinfo
->filename
,strerror(errno
));
360 if (!KeepTempLog
&& unlink(tmp3
)) {
361 debuga(_("Cannot delete \"%s\": %s\n"),tmp3
,strerror(errno
));
365 userinfo_stopscan(uscan
);
366 day_cleanup(daystat
);
368 totalger(fp_gen
,wdirname
);
369 if (fclose(fp_gen
)==EOF
) {
370 debuga(_("Write error in \"%s\": %s\n"),wdirname
,strerror(errno
));
374 if(email
[0] == '\0') {
376 if(DansGuardianConf
[0] != '\0')
378 else if (debugz
>=LogLevel_Process
)
379 debugaz(_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
387 if((ReportType
& REPORT_TYPE_DOWNLOADS
) != 0)
389 else if (debugz
>=LogLevel_Process
)
390 debugaz(_("Downloaded files report not requested in report_type\n"));
392 if((ReportType
& REPORT_TYPE_TOPSITES
) != 0)
394 else if (debugz
>=LogLevel_Process
)
395 debugaz(_("Top sites report not requested in report_type\n"));
397 if((ReportType
& REPORT_TYPE_SITES_USERS
) != 0)
399 else if (debugz
>=LogLevel_Process
)
400 debugaz(_("Sites & users report not requested in report_type\n"));
402 if ((ReportType
& REPORT_TYPE_DENIED
) != 0)
404 else if (debugz
>=LogLevel_Process
)
405 debugaz(_("Denied accesses report not requested in report_type\n"));
407 if ((ReportType
& REPORT_TYPE_AUTH_FAILURES
) != 0)
409 else if (debugz
>=LogLevel_Process
)
410 debugaz(_("Authentication failures report not requested in report_type\n"));
412 if(smartfilter
) smartfilter_report();
414 if(DansGuardianConf
[0] != '\0')
415 dansguardian_report();
419 if((ReportType
& REPORT_TYPE_USERS_SITES
) != 0)
421 else if (debugz
>=LogLevel_Process
)
422 debugaz(_("User's detailed report not requested in report_type\n"));
427 if(SuccessfulMsg
) debuga(_("Successful report generated on %s\n"),outdirname
);
429 geramail(outdirname
, debug
, outdir
, email
, tmp
);
431 if((strcmp(email
,"stdout") != 0) && SuccessfulMsg
)
432 debuga(_("Successful report generated and sent to %s\n"),email
);
435 if(indexonly
) index_only(outdirname
, debug
);
437 removetmp(outdirname
);
441 static FILE *maketmp(const char *user
, const char *dirname
, int debug
)
444 char wdirname
[MAXLEN
];
446 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return(NULL
);
447 if((ReportType
& REPORT_TYPE_TOPUSERS
) == 0) return(NULL
);
449 if(debug
) debuga(_("Making file: %s/%s\n"),tmp
,user
);
450 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,user
)>=sizeof(wdirname
)) {
451 debuga(_("Path too long: "));
452 debuga_more("%s/%s.utmp\n",tmp
,user
);
456 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
457 debuga(_("Cannot open file \"%s\": %s\n"),wdirname
,strerror(errno
));
465 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
)
468 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
469 to print a long long int unless it is exactly 64-bits long.
471 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
);
476 static void closett(void)
481 fputs("</table>\n</div>\n",fp_tt
);
482 fputs("</body>\n</html>\n",fp_tt
);
483 if (fclose(fp_tt
)==EOF
) {
484 debuga(_("Write error in \"%s\": %s\n"),arqtt
,strerror(errno
));
491 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
)
494 char wdirname
[MAXLEN
];
496 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
498 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
499 debuga(_("Path too long: "));
500 debuga_more("%s/%s.ip\n",tmp
,uinfo
->filename
);
504 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
505 debuga(_("Cannot open file \"%s\": %s\n"),wdirname
,strerror(errno
));
510 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
511 to print a long long int unless it is exactly 64-bits long.
513 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
);
515 if (fclose(fp_ou
)==EOF
) {
516 debuga(_("Write error in \"%s\": %s\n"),wdirname
,strerror(errno
));
524 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
)
527 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
528 to print a long long int unless it is exactly 64-bits long.
530 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) {
531 debuga(_("Failed to write a line in %s\n"),filename
);
536 globstat
.nbytes
+=nbytes
;
537 globstat
.elap
+=nelap
;
538 globstat
.incache
+=incache
;
539 globstat
.oucache
+=oucache
;
544 Write the total line at the end of the general file.
546 void totalger(FILE *fp_gen
,const char *filename
)
549 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
550 to print a long long int unless it is exactly 64-bits long.
552 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) {
553 debuga(_("Failed to write the total line in %s\n"),filename
);
558 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
)
562 long long int number
;
564 if (strncmp(buffer
,"TOTAL\t",6)==0) {
569 if (*buffer
== '-') {
572 } else if (*buffer
== '+') {
576 while (isdigit(*buffer
))
577 number
=(number
* 10) + (*buffer
++)-'0';
579 debuga(_("Invalid total number of accesses in %s\n"),filename
);
583 item
->nacc
=number
*sign
;
586 if (*buffer
== '-') {
589 } else if (*buffer
== '+') {
593 while (isdigit(*buffer
))
594 number
=(number
* 10) + (*buffer
++)-'0';
596 debuga(_("Invalid total size in %s\n"),filename
);
600 item
->nbytes
=number
*sign
;
603 if (*buffer
== '-') {
606 } else if (*buffer
== '+') {
610 while (isdigit(*buffer
))
611 number
=(number
* 10) + (*buffer
++)-'0';
613 debuga(_("Invalid total elapsed time in %s\n"),filename
);
617 item
->nelap
=number
*sign
;
620 if (*buffer
== '-') {
623 } else if (*buffer
== '+') {
627 while (isdigit(*buffer
))
628 number
=(number
* 10) + (*buffer
++)-'0';
630 debuga(_("Invalid total cache hit in %s\n"),filename
);
634 item
->incache
=number
*sign
;
637 if (*buffer
== '-') {
640 } else if (*buffer
== '+') {
644 while (isdigit(*buffer
))
645 number
=(number
* 10) + (*buffer
++)-'0';
647 debuga(_("Invalid total cache miss in %s\n"),filename
);
650 item
->oucache
=number
*sign
;
655 for (i
=0 ; i
<MAX_USER_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
657 debuga(_("User name too long or invalid in %s\n"),filename
);
663 if (*buffer
== '-') {
666 } else if (*buffer
== '+') {
670 while (isdigit(*buffer
))
671 number
=(number
* 10) + (*buffer
++)-'0';
673 debuga(_("Invalid number of accesses in %s\n"),filename
);
677 item
->nacc
=number
*sign
;
680 if (*buffer
== '-') {
683 } else if (*buffer
== '+') {
687 while (isdigit(*buffer
))
688 number
=(number
* 10) + (*buffer
++)-'0';
690 debuga(_("Invalid number of bytes in %s\n"),filename
);
694 item
->nbytes
=number
*sign
;
697 while ((unsigned char)*buffer
>=' ') buffer
++;
699 debuga(_("URL too long or invalid in %s\n"),filename
);
705 for (i
=0 ; i
<MAX_IP_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
707 debuga(_("IP address too long or invalid in %s\n"),filename
);
713 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
715 debuga(_("Time too long or invalid in %s\n"),filename
);
721 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
723 debuga(_("Date too long or invalid in %s\n"),filename
);
729 if (*buffer
== '-') {
732 } else if (*buffer
== '+') {
736 while (isdigit(*buffer
))
737 number
=(number
* 10) + (*buffer
++)-'0';
739 debuga(_("Invalid elapsed time in %s\n"),filename
);
743 item
->nelap
=number
*sign
;
746 if (*buffer
== '-') {
749 } else if (*buffer
== '+') {
753 while (isdigit(*buffer
))
754 number
=(number
* 10) + (*buffer
++)-'0';
756 debuga(_("Invalid cache hit size in %s\n"),filename
);
760 item
->incache
=number
*sign
;
763 if (*buffer
== '-') {
766 } else if (*buffer
== '+') {
770 while (isdigit(*buffer
))
771 number
=(number
* 10) + (*buffer
++)-'0';
773 debuga(_("Invalid cache miss size in %s\n"),filename
);
776 item
->oucache
=number
*sign
;
781 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
)
784 char wdirname
[MAXLEN
];
786 if (snprintf(wdirname
,sizeof(wdirname
),"%s/smartfilter.int_unsort",dirname
)>=sizeof(wdirname
)) {
787 debuga(_("Path too long: "));
788 debuga_more("%s/smartfilter.int_unsort\n",dirname
);
792 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
793 debuga(_("Cannot open file \"%s\": %s\n"),wdirname
,strerror(errno
));
797 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%s\t%s\n",user
,data
,hora
,ip
,url
,smart
);
798 fputs("</body>\n</html>\n",fp_tt
);
800 if (fclose(fp_ou
)==EOF
) {
801 debuga(_("Write error in \"%s\": %s\n"),wdirname
,strerror(errno
));