/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2013
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
ddata=(DayObject)malloc(sizeof(*ddata));
if (!ddata)
{
- debuga(_("Not enough memory to store the daily statistics\n"));
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the daily statistics\n"));
exit(EXIT_FAILURE);
}
if (!ddata) return;
if (sscanf(date,"%d/%d/%d",&day,&month,&year)!=3) {
- debuga(_("Invalid date \"%s\" for the hourly statistics\n"),date);
+ debuga(__FILE__,__LINE__,_("Invalid date \"%s\" for the hourly statistics\n"),date);
exit(EXIT_FAILURE);
}
if (day<1 || day>31 || month<1 || month>12 || year>9999) {
- debuga(_("Invalid date component in \"%s\" for the hourly statistics\n"),date);
+ debuga(__FILE__,__LINE__,_("Invalid date component in \"%s\" for the hourly statistics\n"),date);
exit(EXIT_FAILURE);
}
hour=atoi(time);
if (hour<0 || hour>=24) {
- debuga(_("Invalid hour %d for the hourly statistics\n"),hour);
+ debuga(__FILE__,__LINE__,_("Invalid hour %d for the hourly statistics\n"),hour);
exit(EXIT_FAILURE);
}
daynum=(year*10000)+(month*100)+day;
if (dayidx<0) {
dayidx=ddata->ndaylist++;
if (dayidx>=sizeof(ddata->daylist)/sizeof(*ddata->daylist)) {
- debuga(_("Too many different dates for the hourly statistics\n"));
+ debuga(__FILE__,__LINE__,_("Too many different dates for the hourly statistics\n"));
exit(EXIT_FAILURE);
}
ddata->daylist[dayidx]=daynum;
if (!ddata) return;
if (snprintf(arqout,sizeof(arqout),"%s/%s.day",tmp,uinfo->filename)>=sizeof(arqout)) {
- debuga(_("File name too long: %s/%s%s\n"),tmp,uinfo->filename,".day");
+ debuga(__FILE__,__LINE__,_("Path too long: "));
+ debuga_more("%s/%s%s\n",tmp,uinfo->filename,".day");
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(arqout,"w"))==NULL) {
- debuga(_("(totday) Cannot open log file %s: %s\n"),arqout,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
if (ddata->bytes[i]==0 && ddata->elap[i]==0) continue;
dayidx=i/24;
if (dayidx>=sizeof(ddata->daylist)/sizeof(*ddata->daylist)) {
- debuga(_("Invalid day index found in the hourly statistics\n"));
+ debuga(__FILE__,__LINE__,_("Invalid day index found in the hourly statistics\n"));
exit(EXIT_FAILURE);
}
hour=i%24;
}
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in %s: %s\n"),arqout,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
return;
}
+
+/*!
+Delete the temporary file generated by day_totalize().
+
+\param uinfo The user whose daily statistics are to be deleted.
+*/
+void day_deletefile(const struct userinfostruct *uinfo)
+{
+ char arqout[2048];
+
+ if (KeepTempLog) return;
+
+ if (snprintf(arqout,sizeof(arqout),"%s/%s.day",tmp,uinfo->filename)>=sizeof(arqout)) {
+ debuga(__FILE__,__LINE__,_("Path too long: "));
+ debuga_more("%s/%s%s\n",tmp,uinfo->filename,".day");
+ exit(EXIT_FAILURE);
+ }
+
+ if (unlink(arqout))
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqout,strerror(errno));
+}
+