#include "include/conf.h"
#include "include/defs.h"
+#include "include/filelist.h"
extern struct globalstatstruct globstat;
extern bool smartfilter;
+extern FileListObject UserAgentLog;
/*!
Save the total number of users. The number is written in sarg-users and set
void topuser(void)
{
- FILE *fp_in = NULL, *fp_top1 = NULL, *fp_top2 = NULL, *fp_top3 = NULL;
+ FileObject *fp_in = NULL;
+ FileObject *fp_top1 = NULL;
+ FILE *fp_top2 = NULL, *fp_top3 = NULL;
long long int ttnbytes=0, ttnacc=0, tnacc=0;
long long int tnbytes=0, ttnelap=0, tnelap=0;
long long int tnincache=0, tnoucache=0, ttnincache=0, ttnoucache=0;
debuga(__FILE__,__LINE__,_("Creating top users report...\n"));
ntopuser = 0;
snprintf(wger,sizeof(wger),"%s/sarg-general",outdirname);
- if((fp_in=fopen(wger,"r"))==NULL) {
- debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
+ if((fp_in=FileObject_Open(wger))==NULL) {
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wger,FileObject_GetLastOpenError());
exit(EXIT_FAILURE);
}
tnincache+=item.incache;
tnoucache+=item.oucache;
}
- if (fclose(fp_in)==EOF) {
- debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wger,strerror(errno));
+ if (FileObject_Close(fp_in)) {
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wger,FileObject_GetLastCloseError());
exit(EXIT_FAILURE);
}
longline_destroy(&line);
exit(EXIT_FAILURE);
}
- if((fp_top1=fopen(top1,"r"))==NULL) {
- debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
+ if((fp_top1=FileObject_Open(top1))==NULL) {
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top1,FileObject_GetLastOpenError());
exit(EXIT_FAILURE);
}
if (is_denied()) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"denied.html\">%s</a></td></tr>\n",_("Denied accesses"));
if (is_authfail()) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"authfail.html\">%s</a></td></tr>\n",_("Authentication Failures"));
if(smartfilter) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"smartfilter.html\">%s</a></td></tr>\n",_("SmartFilter"));
- if(UserAgentLog[0] != '\0' && useragent_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"useragent.html\">%s</a></td></tr>\n",_("Useragent"));
+ if (!FileList_IsEmpty(UserAgentLog) && useragent_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"useragent.html\">%s</a></td></tr>\n",_("Useragent"));
fputs("<tr><td></td></tr>\n</table></div>\n",fp_top3);
}
topcount++;
}
- if (fclose(fp_top1)==EOF) {
- debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),top1,strerror(errno));
+ if (FileObject_Close(fp_top1)) {
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),top1,FileObject_GetLastCloseError());
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(top1)) {