"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "report.c" between
sarg-2.3.11.tar.gz and sarg-2.4.0.tar.gz

About: SARG ia a Squid Analysis Report Generator.

report.c  (sarg-2.3.11):report.c  (sarg-2.4.0)
/* /*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
* 1998, 2013 * 1998, 2015
* *
* SARG donations: * SARG donations:
* please look at http://sarg.sourceforge.net/donations.php * please look at http://sarg.sourceforge.net/donations.php
* Support: * Support:
* http://sourceforge.net/projects/sarg/forums/forum/363374 * http://sourceforge.net/projects/sarg/forums/forum/363374
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
skipping to change at line 29 skipping to change at line 29
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
* *
*/ */
#include "include/conf.h" #include "include/conf.h"
#include "include/defs.h" #include "include/defs.h"
#include "include/filelist.h"
//! The global statistics of the whole log read. //! The global statistics of the whole log read.
struct globalstatstruct globstat; struct globalstatstruct globstat;
//! \c True to enable the smart filter.
bool smartfilter=false;
extern FileListObject UserAgentLog;
//! The file to store the HTML page where the time of access is reported for one
site and one user.
static FILE *fp_tt=NULL; static FILE *fp_tt=NULL;
//! The name of the file containing the access time of the site/user.
static char arqtt[4096]="";
static FILE *maketmp(const char *user, const char *dirname, int debug); static FILE *maketmp(const char *user, const char *dirname, int debug);
static void gravatmp(FILE *fp_ou, const char *oldurl, long long int nacc, long l ong int nbytes, const char *oldmsg, long long int nelap, long long int incache, long long int oucache); static void gravatmp(FILE *fp_ou, const char *oldurl, long long int nacc, long l ong int nbytes, const char *oldmsg, long long int nelap, long long int incache, long long int oucache);
static void closett(void);
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); 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);
static void gravager(FILE *fp_gen,const char *filename, const struct userinfostr uct *uinfo, long long int nacc, const char *url, long long int nbytes, const cha r *ip, const char *hora, const char *dia, long long int nelap, long long int inc ache, long long int oucache); static void gravager(FILE *fp_gen,const char *filename, const struct userinfostr uct *uinfo, long long int nacc, const char *url, long long int nbytes, const cha r *ip, const char *hora, const char *dia, long long int nelap, long long int inc ache, long long int oucache);
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); 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);
void gerarel(void) void gerarel(const struct ReadLogDataStruct *ReadFilter)
{ {
FILE *fp_in; FileObject *fp_in;
FILE *fp_gen; FILE *fp_gen;
FILE *fp_tmp=NULL; FILE *fp_tmp=NULL;
char *buf; char *buf;
char accdia[11], acchora[9], accip[MAXLEN], *accurl; char accdia[11], acchora[9], accip[256], *accurl;
char oldaccdia[11], oldacchora[9], oldaccip[MAXLEN]; char oldaccdia[11], oldacchora[9], oldaccip[256];
char oldacciptt[256];
char wdirname[MAXLEN]; char wdirname[MAXLEN];
char *oldurl=NULL; char *oldurl=NULL;
char oldmsg[50], acccode[MAXLEN/2 - 1], oldacccode[MAXLEN/2 - 1]; const char *oldmsg;
char ipantes[MAXLEN], nameantes[MAXLEN]; char acccode[MAXLEN/2 - 1], oldacccode[MAXLEN/2 - 1];
char ipantes[256], nameantes[MAXLEN];
char accsmart[MAXLEN]; char accsmart[MAXLEN];
char crc2[MAXLEN/2 -1]; char crc2[MAXLEN/2 -1];
char siteind[MAX_TRUNCATED_URL]; char siteind[MAX_TRUNCATED_URL];
char arqtt[256];
char *oldurltt=NULL; char *oldurltt=NULL;
char oldaccdiatt[11],oldacchoratt[9]; char oldaccdiatt[11],oldacchoratt[9];
char tmp3[MAXLEN]; char tmp3[MAXLEN];
char u2[MAX_USER_LEN]; char u2[MAX_USER_LEN];
char userlabel[MAX_USER_LEN];
long long int nbytes=0; long long int nbytes=0;
long long int nelap=0; long long int nelap=0;
long long int nacc=0; long long int nacc=0;
long long int incache=0; long long int incache=0;
long long int oucache=0; long long int oucache=0;
long long int accbytes, accelap; long long int accbytes, accelap;
char *str; char *str;
userscan uscan; userscan uscan;
const char *sort_field; const char *sort_field;
const char *sort_order; const char *sort_order;
skipping to change at line 84 skipping to change at line 95
int ourl_size=0; int ourl_size=0;
int ourltt_size=0; int ourltt_size=0;
int same_url; int same_url;
bool new_user; bool new_user;
struct getwordstruct gwarea; struct getwordstruct gwarea;
longline line; longline line;
struct userinfostruct *uinfo; struct userinfostruct *uinfo;
DayObject daystat; DayObject daystat;
ipantes[0]='\0'; ipantes[0]='\0';
smartfilter=0; smartfilter=false;
memset(&globstat,0,sizeof(globstat)); memset(&globstat,0,sizeof(globstat));
if (vrfydir(&period, addr, site, us, email)<0) { if (email[0]=='\0') {
debuga(_("Cannot create the output directory name containing the if (vrfydir(&period, addr, site, us)<0) {
period as part of the name\n")); debuga(__FILE__,__LINE__,_("Cannot create the output dire
exit(EXIT_FAILURE); ctory name containing the period as part of the name\n"));
exit(EXIT_FAILURE);
}
} else {
if (snprintf(outdirname,sizeof(outdirname),"%s/emailrep",tmp)>=si
zeof(outdirname)) {
debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/emailrep\n",tmp);
exit(EXIT_FAILURE);
}
my_mkdir(outdirname);
} }
if(debugz){ if (debugz>=LogLevel_Process){
debugaz(_("Report output directory name=%s\n"),outdirname); debugaz(__FILE__,__LINE__,_("outdirname=%s\n"),outdirname);
} }
if(UserAgentLog[0] != '\0' && email[0] == '\0') useragent(); if (email[0] == '\0' && !FileList_IsEmpty(UserAgentLog))
UserAgent_Readlog(ReadFilter);
snprintf(wdirname,sizeof(wdirname),"%s/sarg-general",outdirname); UserAgent();
if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){ init_usertab(UserTabFile);
debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,st
rerror(errno)); format_path(__FILE__, __LINE__, wdirname, sizeof(wdirname), "%s/sarg-gene
ral", outdirname);
if ((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){
debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirn
ame,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fp_tt=NULL; fp_tt=NULL;
sort_labels(&sort_field,&sort_order); sort_labels(&sort_field,&sort_order);
if (indexonly || datetimeby==0) if (indexonly || datetimeby==0)
daystat=NULL; daystat=NULL;
else else
daystat=day_prepare(); daystat=day_prepare();
uscan=userinfo_startscan(); uscan=userinfo_startscan();
if (uscan == NULL) { if (uscan == NULL) {
debuga(_("Cannot enumerate the user list\n")); debuga(__FILE__,__LINE__,_("Cannot enumerate the user list\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
while ((uinfo = userinfo_advancescan(uscan)) != NULL ) { while ((uinfo = userinfo_advancescan(uscan)) != NULL ) {
sort_users_log(tmp,debug,uinfo); sort_users_log(tmp,debug,uinfo);
if (snprintf(tmp3,sizeof(tmp3),"%s/%s.user_log",tmp,uinfo->filena me)>=sizeof(tmp3)) { if (snprintf(tmp3,sizeof(tmp3),"%s/%s.user_log",tmp,uinfo->filena me)>=sizeof(tmp3)) {
debugapos("report",_("Path too long: ")); debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.user_log\n",tmp,uinfo->filename); debuga_more("%s/%s.user_log\n",tmp,uinfo->filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){ if ((fp_in=FileObject_Open(tmp3))==NULL){
debugapos("report",_("Cannot open file \"%s\": %s\n"),tmp debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n
,strerror(errno)); "),tmp3,FileObject_GetLastOpenError());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
user=uinfo->filename; user=uinfo->filename;
day_newuser(daystat); day_newuser(daystat);
strcpy(u2,uinfo->id); strcpy(u2,uinfo->id);
if(Ip2Name && uinfo->id_is_ip) { if (Ip2Name && uinfo->id_is_ip) {
strcpy(ipantes,u2); safe_strcpy(ipantes,u2,sizeof(ipantes));
ip2name(u2,sizeof(u2)); ip2name(u2,sizeof(u2));
strcpy(nameantes,u2); strcpy(nameantes,u2);
} }
user_find(uinfo->label,MAX_USER_LEN, u2); user_find(userlabel,MAX_USER_LEN, u2);
userinfo_label(uinfo,userlabel);
if (!indexonly) { if (!indexonly) {
fp_tmp=maketmp(user,tmp,debug); fp_tmp=maketmp(user,tmp,debug);
} }
ttopen=0; ttopen=0;
oldurl=NULL; oldurl=NULL;
oldurltt=NULL; oldurltt=NULL;
ourltt_size=0; ourltt_size=0;
memset(oldaccdiatt,0,sizeof(oldaccdiatt)); memset(oldaccdiatt,0,sizeof(oldaccdiatt));
memset(oldacchoratt,0,sizeof(oldacchoratt)); memset(oldacchoratt,0,sizeof(oldacchoratt));
memset(oldacciptt,0,sizeof(oldacciptt));
new_user=true; new_user=true;
nacc=0; nacc=0;
nbytes=0; nbytes=0;
nelap=0; nelap=0;
incache=0; incache=0;
oucache=0; oucache=0;
if ((line=longline_create())==NULL) { if ((line=longline_create())==NULL) {
debuga(_("Not enough memory to read file \"%s\"\n"),tmp3) ; debuga(__FILE__,__LINE__,_("Not enough memory to read fil e \"%s\"\n"),tmp3);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
while((buf=longline_read(fp_in,line))!=NULL) { while((buf=longline_read(fp_in,line))!=NULL) {
getword_start(&gwarea,buf); getword_start(&gwarea,buf);
if (getword(accdia,sizeof(accdia),&gwarea,'\t')<0 || getw ord(acchora,sizeof(acchora),&gwarea,'\t')<0 || if (getword(accdia,sizeof(accdia),&gwarea,'\t')<0 || getw ord(acchora,sizeof(acchora),&gwarea,'\t')<0 ||
getword(accip,sizeof(accip),&gwarea,'\t')<0 || getword(accip,sizeof(accip),&gwarea,'\t')<0 ||
getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_at oll(&accbytes,&gwarea,'\t')<0 || getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_at oll(&accbytes,&gwarea,'\t')<0 ||
getword(acccode,sizeof(acccode),&gwarea,'\t')<0) { getword(acccode,sizeof(acccode),&gwarea,'\t')<0) {
debuga(_("Invalid record in file \"%s\"\n"),tmp3) ; debuga(__FILE__,__LINE__,_("Invalid record in fil e \"%s\"\n"),tmp3);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if(strncmp(acccode,"TCP_DENIED/407",14) == 0) continue; if (strncmp(acccode,"TCP_DENIED/407",14) == 0) continue;
if (getword_atoll(&accelap,&gwarea,'\t')<0) { if (getword_atoll(&accelap,&gwarea,'\t')<0) {
debuga(_("Invalid elapsed time in file \"%s\"\n") ,tmp3); debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (getword_skip(20000,&gwarea,'"')<0 || getword(accsmart ,sizeof(accsmart),&gwarea,'"')<0) { if (getword_skip(20000,&gwarea,'"')<0 || getword(accsmart ,sizeof(accsmart),&gwarea,'"')<0) {
debuga(_("Invalid smart info in file \"%s\"\n"),t mp3); debuga(__FILE__,__LINE__,_("Invalid smart info in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if(accsmart[0] != '\0') { if (accsmart[0] != '\0') {
smartfilter++; smartfilter=true;
grava_SmartFilter(tmp,uinfo->id,accip,accdia,acch ora,accurl,accsmart); grava_SmartFilter(tmp,uinfo->id,accip,accdia,acch ora,accurl,accsmart);
} }
if(Ip2Name) { if (Ip2Name) {
if(strcmp(accip,ipantes) != 0) { if (strcmp(accip,ipantes) != 0) {
strcpy(ipantes,accip); strcpy(ipantes,accip);
ip2name(accip,sizeof(accip)); ip2name(accip,sizeof(accip));
strcpy(nameantes,accip); strcpy(nameantes,accip);
} else strcpy(accip,nameantes); } else safe_strcpy(accip,nameantes,sizeof(accip)) ;
} }
if (!indexonly) { if (!indexonly) {
day_addpoint(daystat,accdia,acchora,accelap,accby tes); day_addpoint(daystat,accdia,acchora,accelap,accby tes);
if (iprel) gravaporuser(uinfo,outdirname,accurl,a ccip,accdia,acchora,accbytes,accelap); if (iprel) gravaporuser(uinfo,outdirname,accurl,a ccip,accdia,acchora,accbytes,accelap);
} }
if(new_user){ if (new_user){
url_len=strlen(accurl); url_len=strlen(accurl);
if (!oldurl || url_len>=ourl_size) { if (!oldurl || url_len>=ourl_size) {
ourl_size=url_len+1; ourl_size=url_len+1;
oldurl=realloc(oldurl,ourl_size); oldurl=realloc(oldurl,ourl_size);
if (!oldurl) { if (!oldurl) {
debuga(_("Not enough memory to st ore the url\n")); debuga(__FILE__,__LINE__,_("Not e nough memory to store the url\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
strcpy(oldurl,accurl); strcpy(oldurl,accurl);
strcpy(oldacccode,acccode); strcpy(oldacccode,acccode);
strcpy(oldaccip,accip); strcpy(oldaccip,accip);
strcpy(oldaccdia,accdia); strcpy(oldaccdia,accdia);
strcpy(oldacchora,acchora); strcpy(oldacchora,acchora);
new_user=false; new_user=false;
} }
same_url=(strcmp(oldurl,accurl) == 0); same_url=(strcmp(oldurl,accurl) == 0);
if(site[0] == '\0') { if (site[0] == '\0') {
if(!same_url){ if (!same_url){
if(strstr(oldacccode,"DENIED") != 0) if (strstr(oldacccode,"DENIED") != 0)
strcpy(oldmsg,"DENIED"); oldmsg="DENIED";
else else
strcpy(oldmsg,"OK"); oldmsg="OK";
if (fp_tmp) gravatmp(fp_tmp,oldurl,nacc,n bytes,oldmsg,nelap,incache,oucache); if (fp_tmp) gravatmp(fp_tmp,oldurl,nacc,n bytes,oldmsg,nelap,incache,oucache);
gravager(fp_gen,wdirname,uinfo,nacc,oldur l,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache); gravager(fp_gen,wdirname,uinfo,nacc,oldur l,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
nacc=0; nacc=0;
nbytes=0; nbytes=0;
nelap=0; nelap=0;
incache=0; incache=0;
oucache=0; oucache=0;
} }
} }
nacc++; nacc++;
nbytes+=accbytes; nbytes+=accbytes;
nelap+=accelap; nelap+=accelap;
if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0 & & !indexonly && if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0 & & !indexonly &&
(!oldurltt || strcmp(oldurltt,accurl) || strcmp(oldac (!oldurltt || strcmp(oldurltt,accurl) || strcmp(oldac
cdiatt,accdia) || strcmp(oldacchoratt,acchora))) { cdiatt,accdia) || strcmp(oldacchoratt,acchora) ||
strcmp(oldacciptt,accip))) {
if(!ttopen) { if (!ttopen) {
snprintf(arqtt,sizeof(arqtt),"%s/%s",outd format_path(__FILE__, __LINE__, arqtt, si
irname,uinfo->filename); zeof(arqtt), "%s/%s", outdirname, uinfo->filename);
if(access(arqtt, R_OK) != 0) if (access(arqtt, R_OK) != 0)
my_mkdir(arqtt); my_mkdir(arqtt);
url_to_file(accurl,siteind,sizeof(siteind format_path(__FILE__, __LINE__, arqtt, si
)); zeof(arqtt), "%s/%s/tt.html", outdirname, uinfo->filename);
snprintf(arqtt,sizeof(arqtt),"%s/%s/tt%s-
%s.html",outdirname,uinfo->filename,uinfo->filename,siteind);
if ((fp_tt = fopen(arqtt, "w")) == 0) { if ((fp_tt = fopen(arqtt, "w")) == 0) {
debugapos("report",_("Cannot open file \"%s\": %s\n"),arqtt,strerror(errno)); debuga(__FILE__,__LINE__,_("Canno t open file \"%s\": %s\n"),arqtt,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ttopen=1; ttopen=1;
/* /*
if(Privacy) if (Privacy)
sprintf(httplink,"<font size=%s c olor=%s><href=http://%s>%s",FontSize,PrivacyStringColor,PrivacyString,PrivacyStr ing); sprintf(httplink,"<font size=%s c olor=%s><href=http://%s>%s",FontSize,PrivacyStringColor,PrivacyString,PrivacyStr ing);
else else
sprintf(httplink,"<font size=%s>< a href=\"http://%s\">%s</a>",FontSize,accurl,accurl); sprintf(httplink,"<font size=%s>< a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
*/ */
write_html_header(fp_tt,(IndexTree == IND EX_TREE_DATE) ? 4 : 2,_("Site access report"),HTML_JS_NONE); write_html_header(fp_tt,(IndexTree == IND EX_TREE_DATE) ? 4 : 2,_("Site access report"),HTML_JS_NONE);
fprintf(fp_tt,"<tr><td class=\"header_c\" >%s:&nbsp;%s</td></tr>\n",_("Period"),period.html); fprintf(fp_tt,"<tr><td class=\"header_c\" >%s:&nbsp;%s</td></tr>\n",_("Period"),period.html);
fprintf(fp_tt,"<tr><td class=\"header_c\" >%s:&nbsp;%s</td></tr>\n",_("User"),uinfo->label); fprintf(fp_tt,"<tr><td class=\"header_c\" >%s:&nbsp;%s</td></tr>\n",_("User"),uinfo->label);
fputs("<tr><td class=\"header_c\">",fp_tt ); fputs("<tr><td class=\"header_c\">",fp_tt );
fprintf(fp_tt,_("Sort:&nbsp;%s, %s"),sort _field,sort_order); fprintf(fp_tt,_("Sort:&nbsp;%s, %s"),sort _field,sort_order);
fputs("</td></tr>\n",fp_tt); fputs("</td></tr>\n",fp_tt);
fprintf(fp_tt,"<tr><th class=\"header_c\" >%s</th></tr>\n",_("User")); fprintf(fp_tt,"<tr><th class=\"header_c\" >%s</th></tr>\n",_("User"));
close_html_header(fp_tt); close_html_header(fp_tt);
fputs("<div class=\"report\"><table cellp adding=\"0\" cellspacing=\"2\">\n",fp_tt); fputs("<div class=\"report\"><table cellp adding=\"0\" cellspacing=\"2\">\n",fp_tt);
fprintf(fp_tt,"<tr><th class=\"header_l\" }
>%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_(" if (!oldurltt || strcmp(oldurltt,accurl)) {
ACCESSED SITE"),_("DATE"),_("TIME")); const char *url=accurl;
if (*url==ALIAS_PREFIX) url++;
url_to_anchor(accurl,siteind,sizeof(sitei
nd));
fprintf(fp_tt,"<tr class=\"tt\"><td colsp
an=\"3\"><a name=\"%s\">",siteind);
fprintf(fp_tt,"<b>%s</b>",_("Accessed sit
e: "));
output_html_string(fp_tt,url,100);
fputs("</a></td></tr>\n",fp_tt);
fprintf(fp_tt,"<tr><th class=\"header_l\"
>%s</th>",_("IP"));
fprintf(fp_tt,"<th class=\"header_l\">%s<
/th><th class=\"header_l\">%s</th></tr>\n",_("DATE"),pgettext("wall clock","TIME
"));
} }
fputs("<tr><td class=\"data\">",fp_tt); fprintf(fp_tt,"<tr><td class=\"data2\">%s</td>",a
output_html_string(fp_tt,accurl,100); ccip);
fprintf(fp_tt,"</td><td class=\"data\">%s</td><td fprintf(fp_tt,"<td class=\"data\">%s</td><td clas
class=\"data\">%s</td></tr>\n",accdia,acchora); s=\"data\">%s</td></tr>\n",accdia,acchora);
url_len=strlen(accurl); url_len=strlen(accurl);
if (!oldurltt || url_len>=ourltt_size) { if (!oldurltt || url_len>=ourltt_size) {
ourltt_size=url_len+1; ourltt_size=url_len+1;
oldurltt=realloc(oldurltt,ourltt_size); oldurltt=realloc(oldurltt,ourltt_size);
if (!oldurltt) { if (!oldurltt) {
debuga(_("Not enough memory to st ore the url\n")); debuga(__FILE__,__LINE__,_("Not e nough memory to store the url\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
strcpy(oldurltt,accurl); strcpy(oldurltt,accurl);
strcpy(oldaccdiatt,accdia); strcpy(oldaccdiatt,accdia);
strcpy(oldacchoratt,acchora); strcpy(oldacchoratt,acchora);
strcpy(oldacciptt,accip);
} }
strcpy(crc2,acccode); strcpy(crc2,acccode);
str=strchr(crc2,'/'); str=strchr(crc2,'/');
if (str) *str='\0'; if (str) *str='\0';
if(strstr(crc2,"MISS") != 0) if (strstr(crc2,"MISS") != 0)
oucache+=accbytes; oucache+=accbytes;
else else
incache+=accbytes; incache+=accbytes;
strcpy(oldacccode,acccode); strcpy(oldacccode,acccode);
strcpy(oldaccip,accip); strcpy(oldaccip,accip);
if (!same_url) { if (!same_url) {
url_len=strlen(accurl); url_len=strlen(accurl);
if (url_len>=ourl_size) { if (url_len>=ourl_size) {
ourl_size=url_len+1; ourl_size=url_len+1;
oldurl=realloc(oldurl,ourl_size); oldurl=realloc(oldurl,ourl_size);
if (!oldurl) { if (!oldurl) {
debuga(_("Not enough memory to st ore the url\n")); debuga(__FILE__,__LINE__,_("Not e nough memory to store the url\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
strcpy(oldurl,accurl); strcpy(oldurl,accurl);
} }
strcpy(oldaccdia,accdia); strcpy(oldaccdia,accdia);
strcpy(oldacchora,acchora); strcpy(oldacchora,acchora);
} }
fclose(fp_in); if (FileObject_Close(fp_in)) {
debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),
tmp3,FileObject_GetLastCloseError());
exit(EXIT_FAILURE);
}
longline_destroy(&line); longline_destroy(&line);
if (oldurltt) free(oldurltt); if (oldurltt) free(oldurltt);
if (oldurl) { if (oldurl) {
if(strstr(oldacccode,"DENIED") != 0) if (strstr(oldacccode,"DENIED") != 0)
strcpy(oldmsg,"DENIED"); oldmsg="DENIED";
else else
strcpy(oldmsg,"OK"); oldmsg="OK";
if (fp_tmp) gravatmp(fp_tmp,oldurl,nacc,nbytes,oldmsg,nel ap,incache,oucache); if (fp_tmp) gravatmp(fp_tmp,oldurl,nacc,nbytes,oldmsg,nel ap,incache,oucache);
closett();
gravager(fp_gen,wdirname,uinfo,nacc,oldurl,nbytes,oldacci p,oldacchora,oldaccdia,nelap,incache,oucache); gravager(fp_gen,wdirname,uinfo,nacc,oldurl,nbytes,oldacci p,oldacchora,oldaccdia,nelap,incache,oucache);
free(oldurl); free(oldurl);
oldurl=NULL; oldurl=NULL;
} }
if(!new_user) { if (!new_user) {
day_totalize(daystat,tmp,uinfo); day_totalize(daystat,tmp,uinfo);
} }
if (fp_tmp) { if (fp_tmp) {
if (fclose(fp_tmp)==EOF) if (fclose(fp_tmp)==EOF) {
debuga(_("Failed to close file \"%s\": %s\n"),uin debuga(__FILE__,__LINE__,_("Write error in \"%s\"
fo->filename,strerror(errno)); : %s\n"),uinfo->filename,strerror(errno));
exit(EXIT_FAILURE);
}
fp_tmp=NULL; fp_tmp=NULL;
} }
if (!KeepTempLog && unlink(tmp3)) { if (!KeepTempLog && unlink(tmp3)) {
debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errn o)); debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"), tmp3,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
userinfo_stopscan(uscan); userinfo_stopscan(uscan);
day_cleanup(daystat); day_cleanup(daystat);
totalger(fp_gen,wdirname); totalger(fp_gen,wdirname);
fclose(fp_gen); if (fclose(fp_gen)==EOF) {
debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirnam
e,strerror(errno));
exit(EXIT_FAILURE);
}
if(email[0] == '\0') { if (email[0] == '\0') {
if (!indexonly) { if (!indexonly) {
if(DansGuardianConf[0] != '\0') if (DansGuardianConf[0] != '\0')
dansguardian_log(); dansguardian_log(ReadFilter);
else if (debugz) else if (debugz>=LogLevel_Process)
debugaz(_("Dansguardian report not produced becau debugaz(__FILE__,__LINE__,_("Dansguardian report
se no dansguardian configuration file was provided\n")); not produced because no dansguardian configuration file was provided\n"));
redirector_log(); redirector_log(ReadFilter);
} }
topuser(); topuser();
if (!indexonly) { if (!indexonly) {
if((ReportType & REPORT_TYPE_DOWNLOADS) != 0) if ((ReportType & REPORT_TYPE_DOWNLOADS) != 0)
download_report(); download_report();
else if (debugz) else if (debugz>=LogLevel_Process)
debugaz(_("Downloaded files report not requested debugaz(__FILE__,__LINE__,_("Downloaded files rep
in report_type\n")); ort not requested in report_type\n"));
if((ReportType & REPORT_TYPE_TOPSITES) != 0) if ((ReportType & REPORT_TYPE_TOPSITES) != 0)
topsites(); topsites();
else if (debugz) else if (debugz>=LogLevel_Process)
debugaz(_("Top sites report not requested in repo debugaz(__FILE__,__LINE__,_("Top sites report not
rt_type\n")); requested in report_type\n"));
if((ReportType & REPORT_TYPE_SITES_USERS) != 0) if ((ReportType & REPORT_TYPE_SITES_USERS) != 0)
siteuser(); siteuser();
else if (debugz) else if (debugz>=LogLevel_Process)
debugaz(_("Sites & users report not requested in debugaz(__FILE__,__LINE__,_("Sites & users report
report_type\n")); not requested in report_type\n"));
if ((ReportType & REPORT_TYPE_DENIED) != 0) if ((ReportType & REPORT_TYPE_DENIED) != 0)
gen_denied_report(); gen_denied_report();
else if (debugz) else if (debugz>=LogLevel_Process)
debugaz(_("Denied accesses report not requested i debugaz(__FILE__,__LINE__,_("Denied accesses repo
n report_type\n")); rt not requested in report_type\n"));
if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0) if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0)
authfail_report(); authfail_report();
else if (debugz) else if (debugz>=LogLevel_Process)
debugaz(_("Authentication failures report not req debugaz(__FILE__,__LINE__,_("Authentication failu
uested in report_type\n")); res report not requested in report_type\n"));
if(smartfilter) smartfilter_report(); if (smartfilter) smartfilter_report();
if(DansGuardianConf[0] != '\0') if (DansGuardianConf[0] != '\0')
dansguardian_report(); dansguardian_report();
redirector_report(); redirector_report();
if((ReportType & REPORT_TYPE_USERS_SITES) != 0) if ((ReportType & REPORT_TYPE_USERS_SITES) != 0)
htmlrel(); htmlrel();
else if (debugz) else if (debugz>=LogLevel_Process)
debugaz(_("User's detailed report not requested i debugaz(__FILE__,__LINE__,_("User's detailed repo
n report_type\n")); rt not requested in report_type\n"));
} }
make_index(); make_index();
if(SuccessfulMsg) debuga(_("Successful report generated on %s\n") ,outdirname); if (SuccessfulMsg) debuga(__FILE__,__LINE__,_("Successful report generated on %s\n"),outdirname);
} else { } else {
geramail(outdirname, debug, outdir, email, tmp); topuser();
if((strcmp(email,"stdout") != 0) && SuccessfulMsg) if ((strcmp(email,"stdout") != 0) && SuccessfulMsg)
debuga(_("Successful report generated and sent to %s\n"), debuga(__FILE__,__LINE__,_("Successful report generated a
email); nd sent to %s\n"),email);
} }
if(indexonly) index_only(outdirname, debug); if (indexonly) index_only(outdirname, debug);
removetmp(outdirname); removetmp(outdirname);
return; return;
} }
static FILE *maketmp(const char *user, const char *dirname, int debug) static FILE *maketmp(const char *user, const char *dirname, int debug)
{ {
FILE *fp_ou; FILE *fp_ou;
char wdirname[MAXLEN]; char wdirname[MAXLEN];
if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return(NULL); if ((ReportType & REPORT_TYPE_USERS_SITES) == 0) return(NULL);
if((ReportType & REPORT_TYPE_TOPUSERS) == 0) return(NULL); if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) return(NULL);
if(debug) debuga(_("Making file %s/%s\n"),tmp,user); if (debug) debuga(__FILE__,__LINE__,_("Making file %s/%s\n"),tmp,user);
if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,user)>=sizeof(wdi rname)) { if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,user)>=sizeof(wdi rname)) {
debuga(_("Path too long: ")); debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.utmp\n",tmp,user); debuga_more("%s/%s.utmp\n",tmp,user);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if((fp_ou=fopen(wdirname,"w"))==NULL){ if ((fp_ou=fopen(wdirname,"w"))==NULL){
debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,st debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirn
rerror(errno)); ame,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return(fp_ou); return(fp_ou);
} }
static void gravatmp(FILE *fp_ou, const char *oldurl, long long int nacc, long l ong int nbytes, const char *oldmsg, long long int nelap, long long int incache, long long int oucache) static void gravatmp(FILE *fp_ou, const char *oldurl, long long int nacc, long l ong int nbytes, const char *oldmsg, long long int nelap, long long int incache, long long int oucache)
{ {
/* /*
This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable
to print a long long int unless it is exactly 64-bits long. to print a long long int unless it is exactly 64-bits long.
*/ */
fprintf(fp_ou,"%"PRIu64"\t%"PRIu64"\t%s\t%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu 64"\n",(uint64_t)nacc,(uint64_t)nbytes,oldurl,oldmsg,(uint64_t)nelap,(uint64_t)i ncache,(uint64_t)oucache); fprintf(fp_ou,"%"PRIu64"\t%"PRIu64"\t%s\t%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu 64"\n",(uint64_t)nacc,(uint64_t)nbytes,oldurl,oldmsg,(uint64_t)nelap,(uint64_t)i ncache,(uint64_t)oucache);
return;
}
static void closett(void)
{
ttopen=0; ttopen=0;
if(fp_tt) { if (fp_tt) {
fputs("</table>\n</div>\n",fp_tt); fputs("</table>\n</div>\n",fp_tt);
fputs("</body>\n</html>\n",fp_tt); fputs("</body>\n</html>\n",fp_tt);
fclose(fp_tt); if (fclose(fp_tt)==EOF) {
debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n")
,arqtt,strerror(errno));
exit(EXIT_FAILURE);
}
fp_tt=NULL; fp_tt=NULL;
} }
return;
} }
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) 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)
{ {
FILE *fp_ou; FILE *fp_ou;
char wdirname[MAXLEN]; char wdirname[MAXLEN];
if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return; if ((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
if (snprintf(wdirname,sizeof(wdirname),"%s/%s.ip",tmp,uinfo->filename)>=s izeof(wdirname)) { if (snprintf(wdirname,sizeof(wdirname),"%s/%s.ip",tmp,uinfo->filename)>=s izeof(wdirname)) {
debuga(_("Path too long: ")); debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s.ip\n",tmp,uinfo->filename); debuga_more("%s/%s.ip\n",tmp,uinfo->filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){ if ((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,st debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirn
rerror(errno)); ame,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* /*
This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable
to print a long long int unless it is exactly 64-bits long. to print a long long int unless it is exactly 64-bits long.
*/ */
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); 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);
fclose(fp_ou); if (fclose(fp_ou)==EOF) {
debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirnam
e,strerror(errno));
exit(EXIT_FAILURE);
}
return; return;
} }
static void gravager(FILE *fp_gen,const char *filename, const struct userinfostr uct *uinfo, long long int nacc, const char *url, long long int nbytes, const cha r *ip, const char *hora, const char *dia, long long int nelap, long long int inc ache, long long int oucache) static void gravager(FILE *fp_gen,const char *filename, const struct userinfostr uct *uinfo, long long int nacc, const char *url, long long int nbytes, const cha r *ip, const char *hora, const char *dia, long long int nelap, long long int inc ache, long long int oucache)
{ {
/* /*
This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable
to print a long long int unless it is exactly 64-bits long. to print a long long int unless it is exactly 64-bits long.
*/ */
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,di a,(uint64_t)nelap,(uint64_t)incache,(uint64_t)oucache)<0) { 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,di a,(uint64_t)nelap,(uint64_t)incache,(uint64_t)oucache)<0) {
debuga(_("Failed to write a line in \"%s\"\n"),filename); debuga(__FILE__,__LINE__,_("Write error in file \"%s\": %s\n"),fi lename,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
globstat.nacc+=nacc; globstat.nacc+=nacc;
globstat.nbytes+=nbytes; globstat.nbytes+=nbytes;
globstat.elap+=nelap; globstat.elap+=nelap;
globstat.incache+=incache; globstat.incache+=incache;
globstat.oucache+=oucache; globstat.oucache+=oucache;
return; return;
} }
skipping to change at line 514 skipping to change at line 568
/*! /*!
Write the total line at the end of the general file. Write the total line at the end of the general file.
*/ */
void totalger(FILE *fp_gen,const char *filename) void totalger(FILE *fp_gen,const char *filename)
{ {
/* /*
This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable This complicated printf is due to Microsoft's inability to comply with an y standard. Msvcrt is unable
to print a long long int unless it is exactly 64-bits long. to print a long long int unless it is exactly 64-bits long.
*/ */
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) { 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) {
debuga(_("Failed to write the total line in \"%s\"\n"),filename); debuga(__FILE__,__LINE__,_("Failed to write the total line in \"% s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
int ger_read(char *buffer,struct generalitemstruct *item,const char *filename) int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
{ {
int i; int i;
int sign; int sign;
long long int number; long long int number;
skipping to change at line 540 skipping to change at line 594
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid total number of accesses in file \"%s\" \n"),filename); debuga(__FILE__,__LINE__,_("Invalid total number of acces ses in file \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->nacc=number*sign; item->nacc=number*sign;
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid total size in \"%s\"\n"),filename); debuga(__FILE__,__LINE__,_("Invalid total size in file \" %s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->nbytes=number*sign; item->nbytes=number*sign;
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid total elapsed time in \"%s\"\n"),filena me); debuga(__FILE__,__LINE__,_("Invalid total elapsed time in file \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->nelap=number*sign; item->nelap=number*sign;
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid total cache hit in \"%s\"\n"),filename) ; debuga(__FILE__,__LINE__,_("Invalid total cache hit in fi le \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->incache=number*sign; item->incache=number*sign;
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\0') { if (*buffer!='\0') {
debuga(_("Invalid total cache miss in \"%s\"\n"),filename ); debuga(__FILE__,__LINE__,_("Invalid total cache miss in f ile \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
item->oucache=number*sign; item->oucache=number*sign;
} else { } else {
item->total=0; item->total=0;
item->user=buffer; item->user=buffer;
for (i=0 ; i<MAX_USER_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++; for (i=0 ; i<MAX_USER_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("User name too long or invalid in \"%s\"\n"),fil ename); debuga(__FILE__,__LINE__,_("User name too long or invalid in file \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
*buffer++='\0'; *buffer++='\0';
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid number of accesses in file \"%s\"\n"),f ilename); debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->nacc=number*sign; item->nacc=number*sign;
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid number of bytes in file \"%s\"\n"),file name); debuga(__FILE__,__LINE__,_("Invalid number of bytes in fi le \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->nbytes=number*sign; item->nbytes=number*sign;
item->url=buffer; item->url=buffer;
while ((unsigned char)*buffer>=' ') buffer++; while ((unsigned char)*buffer>=' ') buffer++;
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("URL too long or invalid in \"%s\"\n"),filename) ; debuga(__FILE__,__LINE__,_("URL too long or invalid in fi le \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
*buffer++='\0'; *buffer++='\0';
item->ip=buffer; item->ip=buffer;
for (i=0 ; i<MAX_IP_LEN-1 && (unsigned char)*buffer>=' ' ; i++) b uffer++; for (i=0 ; i<MAX_IP_LEN-1 && (unsigned char)*buffer>=' ' ; i++) b uffer++;
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("IP address too long or invalid in \"%s\"\n"),fi lename); debuga(__FILE__,__LINE__,_("IP address too long or invali d in file \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
*buffer++='\0'; *buffer++='\0';
item->time=buffer; item->time=buffer;
for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++; for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Time too long or invalid in \"%s\"\n"),filename ); debuga(__FILE__,__LINE__,_("Time too long or invalid in f ile \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
*buffer++='\0'; *buffer++='\0';
item->date=buffer; item->date=buffer;
for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++; for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Date too long or invalid in \"%s\"\n"),filename ); debuga(__FILE__,__LINE__,_("Date too long or invalid in f ile \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
*buffer++='\0'; *buffer++='\0';
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid elapsed time in file \"%s\"\n"),filenam e); debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->nelap=number*sign; item->nelap=number*sign;
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\t') { if (*buffer!='\t') {
debuga(_("Invalid cache hit size in \"%s\"\n"),filename); debuga(__FILE__,__LINE__,_("Invalid cache hit size in fil e \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
buffer++; buffer++;
item->incache=number*sign; item->incache=number*sign;
sign=+1; sign=+1;
if (*buffer == '-') { if (*buffer == '-') {
buffer++; buffer++;
sign=-1; sign=-1;
} else if (*buffer == '+') { } else if (*buffer == '+') {
buffer++; buffer++;
} }
number=0LL; number=0LL;
while (isdigit(*buffer)) while (isdigit(*buffer))
number=(number * 10) + (*buffer++)-'0'; number=(number * 10) + (*buffer++)-'0';
if (*buffer!='\0') { if (*buffer!='\0') {
debuga(_("Invalid cache miss size in \"%s\"\n"),filename) ; debuga(__FILE__,__LINE__,_("Invalid cache miss size in fi le \"%s\"\n"),filename);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
item->oucache=number*sign; item->oucache=number*sign;
} }
return(0); return(0);
} }
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) 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)
{ {
FILE *fp_ou; FILE *fp_ou;
char wdirname[MAXLEN]; char wdirname[MAXLEN];
if (snprintf(wdirname,sizeof(wdirname),"%s/smartfilter.int_unsort",dirnam e)>=sizeof(wdirname)) { if (snprintf(wdirname,sizeof(wdirname),"%s/smartfilter.int_unsort",dirnam e)>=sizeof(wdirname)) {
debuga(_("Path too long: ")); debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/smartfilter.int_unsort\n",dirname); debuga_more("%s/smartfilter.int_unsort\n",dirname);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){ if ((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,st debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirn
rerror(errno)); ame,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf(fp_ou,"%s\t%s\t%s\t%s\t%s\t%s\n",user,data,hora,ip,url,smart); fprintf(fp_ou,"%s\t%s\t%s\t%s\t%s\t%s\n",user,data,hora,ip,url,smart);
fputs("</body>\n</html>\n",fp_tt); fputs("</body>\n</html>\n",fp_tt);
fclose(fp_ou); if (fclose(fp_ou)==EOF) {
debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirnam
e,strerror(errno));
exit(EXIT_FAILURE);
}
return; return;
} }
 End of changes. 105 change blocks. 
153 lines changed or deleted 222 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)