/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2013
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
snprintf(tusr,sizeof(tusr),"%s/sarg-users",outdirname);
if((fp_ou=fopen(tusr,"w"))==NULL) {
- debuga(_("(topuser) Cannot open file %s: %s\n"),tusr,strerror(errno));
+ debuga(_("Cannot open file \"%s\": %s\n"),tusr,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"%d\n",totuser);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in %s: %s\n"),tusr,strerror(errno));
+ debuga(_("Write error in \"%s\": %s\n"),tusr,strerror(errno));
exit(EXIT_FAILURE);
}
globstat.totuser=totuser;
ntopuser = 0;
snprintf(wger,sizeof(wger),"%s/sarg-general",outdirname);
if((fp_in=fopen(wger,"r"))==NULL) {
- debuga(_("(topuser) Cannot open file %s: %s\n"),wger,strerror(errno));
+ debuga(_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(top2,sizeof(top2),"%s/top.tmp",outdirname);
if((fp_top2=fopen(top2,"w"))==NULL) {
- debuga(_("(topuser) Cannot open file %s: %s\n"),top2,strerror(errno));
+ debuga(_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
tnincache+=item.incache;
tnoucache+=item.oucache;
}
- fclose(fp_in);
+ if (fclose(fp_in)==EOF) {
+ debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno));
+ exit(EXIT_FAILURE);
+ }
longline_destroy(&line);
if (olduser[0] != '\0') {
ttnoucache+=tnoucache;
}
if (fclose(fp_top2)==EOF) {
- debuga(_("Write error in %s: %s\n"),top2,strerror(errno));
+ debuga(_("Write error in \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
}
if((fp_top1=fopen(top1,"r"))==NULL) {
- debuga(_("(topuser) Cannot open file %s: %s\n"),top1,strerror(errno));
+ debuga(_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(top3,sizeof(top3),"%s/"INDEX_HTML_FILE,outdirname);
if((fp_top3=fopen(top3,"w"))==NULL) {
- debuga(_("(topuser) Cannot open file %s: %s\n"),top3,strerror(errno));
+ debuga(_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
fputs("</body>\n</html>\n",fp_top3);
if (fclose (fp_top3)==EOF) {
- debuga(_("Write error in %s: %s\n"),top3,strerror(errno));
+ debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
if (debugz>=LogLevel_Process) debugaz(_("No top users report because it is not configured in report_type\n"));
while((warea=longline_read(fp_top1,line))!=NULL) {
getword_start(&gwarea,warea);
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- debuga(_("There is a broken user in file %s\n"),top1);
+ debuga(_("Invalid user in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
- debuga(_("There is a broken number of bytes in file %s\n"),top1);
+ debuga(_("Invalid number of bytes in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&nacc,&gwarea,'\t')<0) {
- debuga(_("There is a broken number of access in file %s\n"),top1);
+ debuga(_("Invalid number of accesses in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&elap,&gwarea,'\t')<0) {
- debuga(_("There is a broken elpased time in file %s\n"),top1);
+ debuga(_("Invalid elapsed time in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&incac,&gwarea,'\t')<0) {
- debuga(_("There is a broken in-cache size in file %s\n"),top1);
+ debuga(_("Invalid in-cache size in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if (getword_atoll(&oucac,&gwarea,'\n')<0) {
- debuga(_("There is a broken out-of-cache size in file %s\n"),top1);
+ debuga(_("Invalid out-of-cache size in file \"%s\"\n"),top1);
exit(EXIT_FAILURE);
}
if(nacc < 1)
uinfo=userinfo_find_from_id(user);
if (!uinfo) {
- debuga(_("Unknown user ID %s in file %s\n"),user,top1);
+ debuga(_("Unknown user ID %s in file \"%s\"\n"),user,top1);
exit(EXIT_FAILURE);
}
uinfo->topuser=1;
topcount++;
}
- fclose(fp_top1);
+ if (fclose(fp_top1)==EOF) {
+ debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno));
+ exit(EXIT_FAILURE);
+ }
if (!KeepTempLog && unlink(top1)) {
debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("</table></div>\n",fp_top3);
- if (write_html_trailer(fp_top3)<0)
- debuga(_("Write error in top user list %s\n"),top3);
+ write_html_trailer(fp_top3);
if (fclose(fp_top3)==EOF) {
- debuga(_("Write error in %s: %s\n"),top3,strerror(errno));
+ debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}