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 static FILE *fp_tt
=NULL
;
32 static void maketmp(const char *user
, const char *dirname
, int debug
, int indexonly
);
33 static void maketmp_hour(const char *user
, const char *dirname
, int indexonly
);
34 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
, int indexonly
);
35 static void gravatmpf(const struct userinfostruct
*uinfo
, const char *oldurl
, long long int nacc
, long long int nbytes
, const char *oldmsg
, long long int nelap
, int indexonly
, long long int incache
, long long int oucache
);
36 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
, int indexonly
);
37 static void gravager(FILE *fp_gen
, 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
);
38 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
);
47 char accdia
[11], acchora
[9], accip
[MAXLEN
], *accurl
;
48 char oldaccdia
[11], oldacchora
[9], oldaccip
[MAXLEN
];
49 char wdirname
[MAXLEN
];
51 char oldmsg
[50], acccode
[MAXLEN
/2 - 1], oldacccode
[MAXLEN
/2 - 1], user
[MAX_USER_LEN
];
52 char ipantes
[MAXLEN
], nameantes
[MAXLEN
];
53 char accsmart
[MAXLEN
];
54 char crc2
[MAXLEN
/2 -1];
55 char siteind
[MAX_TRUNCATED_URL
];
58 char oldaccdiatt
[11],oldacchoratt
[9];
61 char u2
[MAX_USER_LEN
];
62 long long int nbytes
=0;
63 long long int nelap
=0;
65 long long int rtotal
=0;
66 long long int incache
=0;
67 long long int oucache
=0;
68 long long int accbytes
, accelap
;
71 struct dirent
*direntp
;
72 const char logext
[]=".log";
73 const char *sort_field
;
74 const char *sort_order
;
81 struct getwordstruct gwarea
;
83 struct userinfostruct
*uinfo
,*puinfo
;
88 if (vrfydir(&period
, addr
, site
, us
, email
)<0) {
89 debuga(_("Cannot create the output directory name containing the period as part of the name\n"));
94 debugaz("outdirname",outdirname
);
97 if(UserAgentLog
[0] != '\0' && email
[0] == '\0') useragent();
99 snprintf(wdirname
,sizeof(wdirname
),"%s/sarg-general",outdirname
);
100 if((fp_gen
=MY_FOPEN(wdirname
,"w"))==NULL
){
101 debuga(_("(report) Cannot open file %s\n"),wdirname
);
108 if ((dirp
= opendir(tmp
)) == NULL
) {
109 debuga(_("Failed to open directory %s - %s\n"),tmp
,strerror(errno
));
112 while ((direntp
= readdir( dirp
)) != NULL
) {
113 dlen
=strlen(direntp
->d_name
)-(sizeof(logext
)-1);
114 if (dlen
<0) continue;
115 if((strcmp(direntp
->d_name
+dlen
,logext
) != 0) ||
116 (strncmp(direntp
->d_name
,"download.log",12) == 0) ||
117 (strncmp(direntp
->d_name
,"denied.log",10) == 0) ||
118 (strncmp(direntp
->d_name
,"authfail.log.unsort",19) == 0))
120 if (snprintf(tmp3
,sizeof(tmp3
),"%s/%s",tmp
,direntp
->d_name
)>=sizeof(tmp3
)) {
121 debuga(_("(report) directory entry too long: %s/%s\n"),tmp
,direntp
->d_name
);
124 if((fp_in
=MY_FOPEN(tmp3
,"r"))==NULL
){
125 debuga(_("(report) Cannot open file %s\n"),tmp
);
130 if (dlen
>=sizeof(user
)) continue;
131 strncpy(user
,direntp
->d_name
,dlen
);
137 uinfo
=userinfo_find_from_file(user
);
139 debuga(_("Ignoring unknown user file %s\n"),user
);
142 strcpy(u2
,uinfo
->id
);
143 if(Ip2Name
&& uinfo
->id_is_ip
) {
145 ip2name(u2
,sizeof(u2
));
146 strcpy(nameantes
,u2
);
148 user_find(uinfo
->label
,MAX_USER_LEN
, u2
);
150 maketmp(user
,tmp
,debug
,indexonly
);
151 maketmp_hour(user
,tmp
,indexonly
);
152 sort_labels(&sort_field
,&sort_order
);
157 memset(oldaccdiatt
,0,sizeof(oldaccdiatt
));
158 memset(oldacchoratt
,0,sizeof(oldacchoratt
));
161 if ((line
=longline_create())==NULL
) {
162 debuga(_("Not enough memory to read the downloaded files\n"));
166 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
167 getword_start(&gwarea
,buf
);
168 if (getword(accdia
,sizeof(accdia
),&gwarea
,'\t')<0 || getword(acchora
,sizeof(acchora
),&gwarea
,'\t')<0 ||
169 getword(accip
,sizeof(accip
),&gwarea
,'\t')<0 ||
170 getword_ptr(buf
,&accurl
,&gwarea
,'\t')<0 || getword_atoll(&accbytes
,&gwarea
,'\t')<0 ||
171 getword(acccode
,sizeof(acccode
),&gwarea
,'\t')<0) {
172 debuga(_("There is a broken record or garbage in file %s\n"),tmp3
);
175 if(strncmp(acccode
,"TCP_DENIED/407",14) == 0) continue;
176 if (getword_atoll(&accelap
,&gwarea
,'\t')<0) {
177 debuga(_("There is a broken elapsed time in file %s\n"),tmp3
);
180 if (getword_skip(20000,&gwarea
,'"')<0 || getword(accsmart
,sizeof(accsmart
),&gwarea
,'"')<0) {
181 debuga(_("There is a broken smart info in file %s\n"),tmp3
);
185 if(accsmart
[0] != '\0') {
187 grava_SmartFilter(outdirname
,uinfo
->id
,accip
,accdia
,acchora
,accurl
,accsmart
);
191 if(strcmp(accip
,ipantes
) != 0) {
192 strcpy(ipantes
,accip
);
193 ip2name(accip
,sizeof(accip
));
194 strcpy(nameantes
,accip
);
195 } else strcpy(accip
,nameantes
);
198 gravatmp_hora(outdirname
,uinfo
,accdia
,acchora
,accelap
,accbytes
,indexonly
);
201 gravaporuser(uinfo
,outdirname
,accurl
,accip
,accdia
,acchora
,accbytes
,accelap
,indexonly
);
205 url_len
=strlen(accurl
);
206 if (!oldurl
|| url_len
>=ourl_size
) {
208 oldurl
=realloc(oldurl
,ourl_size
);
210 debuga(_("Not enough memory to store the url\n"));
214 strcpy(oldurl
,accurl
);
215 strcpy(oldacccode
,acccode
);
217 strcpy(oldaccip
,accip
);
218 strcpy(oldaccdia
,accdia
);
219 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 gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
232 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
240 if(!same_url
|| new_user
){
241 if(strstr(oldacccode
,"DENIED") != 0)
242 strcpy(oldmsg
,"DENIED");
245 gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
246 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
258 if ((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0 &&
259 (!oldurltt
|| strcmp(oldurltt
,accurl
) || strcmp(oldaccdiatt
,accdia
) || strcmp(oldacchoratt
,acchora
))) {
262 snprintf(arqtt
,sizeof(arqtt
),"%s/%s",outdirname
,uinfo
->filename
);
263 if(access(arqtt
, R_OK
) != 0)
265 url_to_file(accurl
,siteind
,sizeof(siteind
));
266 snprintf(arqtt
,sizeof(arqtt
),"%s/%s/tt%s-%s.html",outdirname
,uinfo
->filename
,uinfo
->filename
,siteind
);
267 if ((fp_tt
= fopen(arqtt
, "w")) == 0) {
268 debuga(_("(report) Cannot open file %s\n"),arqtt
);
275 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
276 FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
278 sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
281 write_html_header(fp_tt
,(IndexTree
== INDEX_TREE_DATE
) ? 4 : 2,_("Site access report"));
282 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period
.html
);
283 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo
->label
);
284 fputs("<tr><td class=\"header_c\">",fp_tt
);
285 fprintf(fp_tt
,_("Sort: %s, %s"),sort_field
,sort_order
);
286 fputs("</td></tr>\n",fp_tt
);
287 fprintf(fp_tt
,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User"));
288 close_html_header(fp_tt
);
290 fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt
);
291 strncpy(tmp4
,_("DATE/TIME"),4);
293 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);
296 fputs("<tr><td class=\"data\">",fp_tt
);
297 output_html_string(fp_tt
,accurl
,100);
298 fprintf(fp_tt
,"</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accdia
,acchora
);
300 url_len
=strlen(accurl
);
301 if (!oldurltt
|| url_len
>=ourltt_size
) {
302 ourltt_size
=url_len
+1;
303 oldurltt
=realloc(oldurltt
,ourltt_size
);
305 debuga(_("Not enough memory to store the url\n"));
309 strcpy(oldurltt
,accurl
);
310 strcpy(oldaccdiatt
,accdia
);
311 strcpy(oldacchoratt
,acchora
);
314 strcpy(crc2
,acccode
);
315 str
=strchr(crc2
,'/');
317 if(strstr(crc2
,"MISS") != 0)
319 else incache
+=accbytes
;
323 day_totalize(tmp
,puinfo
,indexonly
);
327 strcpy(oldacccode
,acccode
);
328 strcpy(oldaccip
,accip
);
330 url_len
=strlen(accurl
);
331 if (url_len
>=ourl_size
) {
333 oldurl
=realloc(oldurl
,ourl_size
);
335 debuga(_("Not enough memory to store the url\n"));
339 strcpy(oldurl
,accurl
);
341 strcpy(oldaccdia
,accdia
);
342 strcpy(oldacchora
,acchora
);
346 longline_destroy(&line
);
347 if (oldurltt
) free(oldurltt
);
353 if(strstr(oldacccode
,"DENIED") != 0)
354 strcpy(oldmsg
,"DENIED");
357 gravatmpf(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
358 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
362 if (puinfo
) day_totalize(tmp
,puinfo
,indexonly
);
366 totalger(outdirname
, debug
, outdir
);
368 if(email
[0] == '\0') {
369 if((ReportType
& REPORT_TYPE_DOWNLOADS
) != 0) download_report();
371 if(DansGuardianConf
[0] != '\0') {
379 if((ReportType
& REPORT_TYPE_TOPSITES
) != 0) topsites();
381 if((ReportType
& REPORT_TYPE_SITES_USERS
) != 0) siteuser();
386 if(smartfilter
) smartfilter_report();
388 if(DansGuardianConf
[0] != '\0') dansguardian_report();
392 if((ReportType
& REPORT_TYPE_USERS_SITES
) != 0) htmlrel();
396 if(SuccessfulMsg
) debuga(_("Successful report generated on %s\n"),outdirname
);
398 geramail(outdirname
, debug
, outdir
, email
, tmp
);
400 if((strcmp(email
,"stdout") != 0) && SuccessfulMsg
)
401 debuga(_("Successful report generated and sent to %s\n"),email
);
405 index_only(outdirname
, debug
);
408 removetmp(outdirname
);
412 static void maketmp(const char *user
, const char *dirname
, int debug
, int indexonly
)
417 char wdirname
[MAXLEN
];
419 if(indexonly
) return;
420 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
422 if(debug
) debuga(_("Making file: %s/%s\n"),tmp
,user
);
423 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,user
)>=sizeof(wdirname
)) {
424 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,user
);
428 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
429 debuga(_("(report) Cannot open file %s\n"),wdirname
);
438 static void maketmp_hour(const char *user
, const char *dirname
, int indexonly
)
443 char wdirname
[MAXLEN
];
445 if(indexonly
) return;
446 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
447 if(datetimeby
==0) return;
449 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,user
)>=sizeof(wdirname
)) {
450 debuga(_("Temporary file name too long: %s/%s.htmp\n"),tmp
,user
);
454 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
455 debuga(_("(report-1) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
464 void gravatmp(const struct userinfostruct
*uinfo
, const char *oldurl
, long long int nacc
, long long int nbytes
, const char *oldmsg
, long long int nelap
, int indexonly
, long long int incache
, long long int oucache
)
467 char wdirname
[MAXLEN
];
469 if(indexonly
) return;
470 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
472 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
473 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,uinfo
->filename
);
477 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
478 debuga(_("(report) Cannot open file %s\n"),wdirname
);
483 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
484 to print a long long int unless it is exactly 64-bits long.
486 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
);
492 fputs("</table>\n</div>\n",fp_tt
);
493 fputs("</body>\n</html>\n",fp_tt
);
501 static void gravatmpf(const struct userinfostruct
*uinfo
,const char *oldurl
, long long int nacc
, long long int nbytes
, const char *oldmsg
, long long int nelap
, int indexonly
, long long int incache
, long long int oucache
)
504 char wdirname
[MAXLEN
];
506 if(indexonly
|| (ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
508 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
509 debuga(_("Path too long %s/%s.utmp\n"),tmp
,uinfo
->filename
);
513 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
514 debuga(_("(report) Cannot open file %s\n"),wdirname
);
519 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
520 to print a long long int unless it is exactly 64-bits long.
522 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
);
524 if (fclose(fp_ou
)==EOF
) {
525 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
531 fputs("</table>\n",fp_tt
);
532 fputs("</body>\n</html>\n",fp_tt
);
541 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
, int indexonly
)
545 char wdirname
[MAXLEN
];
548 if(indexonly
|| ((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) || datetimeby
==0) return;
550 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
551 debuga(_("Path too long %s/%s.htmp\n"),tmp
,uinfo
->filename
);
555 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
556 debuga(_("(report-2) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
561 fprintf(fp_ou
,"%s\t%d",data
,hour
);
562 if((datetimeby
& DATETIME_BYTE
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)bytes
);
563 if((datetimeby
& DATETIME_ELAP
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)elap
);
566 if (fclose(fp_ou
)==EOF
) {
567 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
575 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
, int indexonly
)
579 char wdirname
[MAXLEN
];
581 if(indexonly
|| ((ReportType
& REPORT_TYPE_USERS_SITES
) == 0)) return;
583 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
584 debuga(_("Path too long %s/%s.ip\n"),tmp
,uinfo
->filename
);
588 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
589 debuga(_("(report) Cannot open file %s\n"),wdirname
);
594 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
595 to print a long long int unless it is exactly 64-bits long.
597 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
);
606 static void gravager(FILE *fp_gen
, 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
)
609 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
610 to print a long long int unless it is exactly 64-bits long.
612 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
);
616 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
)
620 long long int number
;
622 if (strncmp(buffer
,"TOTAL\t",6)==0) {
627 if (*buffer
== '-') {
630 } else if (*buffer
== '+') {
634 while (isdigit(*buffer
))
635 number
=(number
* 10) + (*buffer
++)-'0';
637 debuga(_("Invalid total number of accesses in %s\n"),filename
);
641 item
->nacc
=number
*sign
;
644 if (*buffer
== '-') {
647 } else if (*buffer
== '+') {
651 while (isdigit(*buffer
))
652 number
=(number
* 10) + (*buffer
++)-'0';
654 debuga(_("Invalid total size in %s\n"),filename
);
658 item
->nbytes
=number
*sign
;
661 if (*buffer
== '-') {
664 } else if (*buffer
== '+') {
668 while (isdigit(*buffer
))
669 number
=(number
* 10) + (*buffer
++)-'0';
671 debuga(_("Invalid total elapsed time in %s\n"),filename
);
675 item
->nelap
=number
*sign
;
678 if (*buffer
== '-') {
681 } else if (*buffer
== '+') {
685 while (isdigit(*buffer
))
686 number
=(number
* 10) + (*buffer
++)-'0';
688 debuga(_("Invalid total cache hit in %s\n"),filename
);
692 item
->incache
=number
*sign
;
695 if (*buffer
== '-') {
698 } else if (*buffer
== '+') {
702 while (isdigit(*buffer
))
703 number
=(number
* 10) + (*buffer
++)-'0';
705 debuga(_("Invalid total cache miss in %s\n"),filename
);
708 item
->oucache
=number
*sign
;
713 for (i
=0 ; i
<MAX_USER_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
715 debuga(_("User name too long or invalid in %s\n"),filename
);
721 if (*buffer
== '-') {
724 } else if (*buffer
== '+') {
728 while (isdigit(*buffer
))
729 number
=(number
* 10) + (*buffer
++)-'0';
731 debuga(_("Invalid number of accesses in %s\n"),filename
);
735 item
->nacc
=number
*sign
;
738 if (*buffer
== '-') {
741 } else if (*buffer
== '+') {
745 while (isdigit(*buffer
))
746 number
=(number
* 10) + (*buffer
++)-'0';
748 debuga(_("Invalid number of bytes in %s\n"),filename
);
752 item
->nbytes
=number
*sign
;
755 while ((unsigned char)*buffer
>=' ') buffer
++;
757 debuga(_("URL too long or invalid in %s\n"),filename
);
763 for (i
=0 ; i
<MAX_IP_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
765 debuga(_("IP address too long or invalid in %s\n"),filename
);
771 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
773 debuga(_("Time too long or invalid in %s\n"),filename
);
779 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
781 debuga(_("Date too long or invalid in %s\n"),filename
);
787 if (*buffer
== '-') {
790 } else if (*buffer
== '+') {
794 while (isdigit(*buffer
))
795 number
=(number
* 10) + (*buffer
++)-'0';
797 debuga(_("Invalid elapsed time in %s\n"),filename
);
801 item
->nelap
=number
*sign
;
804 if (*buffer
== '-') {
807 } else if (*buffer
== '+') {
811 while (isdigit(*buffer
))
812 number
=(number
* 10) + (*buffer
++)-'0';
814 debuga(_("Invalid cache hit size in %s\n"),filename
);
818 item
->incache
=number
*sign
;
821 if (*buffer
== '-') {
824 } else if (*buffer
== '+') {
828 while (isdigit(*buffer
))
829 number
=(number
* 10) + (*buffer
++)-'0';
831 debuga(_("Invalid cache miss size in %s\n"),filename
);
834 item
->oucache
=number
*sign
;
839 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
)
843 char wdirname
[MAXLEN
];
845 sprintf(wdirname
,"%s/smartfilter.unsort",dirname
);
847 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
848 debuga(_("(report) Cannot open file %s\n"),wdirname
);
852 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%s\t%s\n",user
,data
,hora
,ip
,url
,smart
);
853 fputs("</body>\n</html>\n",fp_tt
);