/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2011
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
struct getwordstruct gwarea;
struct tm t;
+ if (datetimeby==0) return;
snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,uinfo->filename);
if(access(wdirname, R_OK) != 0) return;
if (snprintf(arqout,sizeof(arqout),"%s/%s/d%s.html",outdirname,uinfo->filename,uinfo->filename)>=sizeof(arqout)) {
- debuga(_("Output file name too long: %s/%s/d%s.html\n"),outdirname,uinfo->filename,uinfo->filename);
+ debuga(__FILE__,__LINE__,_("Path too long: "));
+ debuga_more("%s/%s/d%s.html\n",outdirname,uinfo->filename,uinfo->filename);
exit(EXIT_FAILURE);
}
if((fp_in=fopen(wdirname,"r"))==NULL) {
- debuga(_("(repday) Cannot open log file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
fixendofline(buf);
getword_start(&gwarea,buf);
if (getword(data,sizeof(data),&gwarea,'\t')<0) {
- debuga(_("Invalid date in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
if (sscanf(data,"%d/%d/%d",&day,&month,&year)!=3) continue;
for (dayidx=0 ; dayidx<ndaylist && daynum!=daylist[dayidx] ; dayidx++);
if (dayidx>=ndaylist) {
if (dayidx>=sizeof(daylist)/sizeof(*daylist)) {
- debuga(_("Too many different dates in %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Too many different dates in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
daylist[ndaylist++]=daynum;
}
if (getword_atoll(&hour,&gwarea,'\t')<0) {
- debuga(_("Invalid time in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
ihour=(int)hour;
if ((datetimeby & DATETIME_BYTE)!=0) {
colsep=((datetimeby & DATETIME_ELAP)!=0) ? '\t' : '\0';
if (getword_atoll(&bytes,&gwarea,colsep)<0) {
- debuga(_("Invalid number of bytes in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
tbytes[i]+=bytes;
}
if ((datetimeby & DATETIME_ELAP)!=0) {
if (getword_atoll(&elap,&gwarea,'\0')<0) {
- debuga(_("Invalid elapsed time in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
telap[i]+=elap;
}
}
- fclose(fp_in);
+ if (fclose(fp_in)==EOF) {
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wdirname,strerror(errno));
+ exit(EXIT_FAILURE);
+ }
if((fp_ou=fopen(arqout,"w"))==NULL) {
- debuga(_("(repday) Cannot open log file %s\n"),arqout);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
label=_("BYTES");
fputs("<table class=\"report\" cellpadding=\"0\" cellspacing=\"2\">\n", fp_ou);
fputs("<tr><th class=\"header_c\"></th>",fp_ou);
- for( i = 0; i < hours.len; i++ )
- fprintf(fp_ou, "<td class=\"header_c\">%02d%s<br>%s</td>\n", hours.list[ i ], _("H"), label );
+ for( i = 0; i < hours.len; i++ ) {
+ /* TRANSLATORS: It is an hour in the hourly report */
+ sprintf(data,_("%02dH"),hours.list[ i ]);
+ fprintf(fp_ou, "<td class=\"header_c\">%s<br>%s</td>\n", data, label );
+ }
fprintf(fp_ou, "<td class=\"header_c\">%s<br>%s</td></tr>\n", _("TOTAL"), label );
memset(tttime,0,sizeof(tttime));
fputs("</table>\n",fp_ou);
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (tt!=uinfo->nbytes) {
- debuga(_("Total downloaded bytes is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
+ debuga(__FILE__,__LINE__,_("Total downloaded bytes is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
(int64_t)tt,(int64_t)uinfo->nbytes,uinfo->label);
exit(EXIT_FAILURE);
}
label=_("H:M:S");
fputs("<table class=\"report\" cellpadding=\"0\" cellspacing=\"2\">\n", fp_ou);
fputs("<tr><th class=\"header_c\"></th>",fp_ou);
- for( i = 0; i < hours.len; i++ )
- fprintf(fp_ou, "<td class=\"header_c\">%02d%s<br>%s</td>\n", hours.list[ i ], _("H"), label );
+ for( i = 0; i < hours.len; i++ ) {
+ sprintf(data,_("%02dH"),hours.list[ i ]);
+ fprintf(fp_ou, "<td class=\"header_c\">%s<br>%s</td>\n", data, label );
+ }
fprintf(fp_ou, "<td class=\"header_c\">%s<br>%s</td></tr>\n", _("TOTAL"), label );
memset(tttime,0,sizeof(tttime));
fputs("</table>\n",fp_ou);
#ifdef ENABLE_DOUBLE_CHECK_DATA
if (tt!=uinfo->elap) {
- debuga(_("Total elapsed time is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
+ debuga(__FILE__,__LINE__,_("Total elapsed time is %"PRIi64" instead of %"PRIi64" in the hourly report of user %s\n"),
(int64_t)tt,(int64_t)uinfo->elap,uinfo->label);
exit(EXIT_FAILURE);
}
#endif
}
- if (write_html_trailer(fp_ou)<0)
- debuga(_("Write error in file %s\n"),arqout);
- if (fclose(fp_ou)==EOF)
- debuga(_("Failed to close file %s - %s\n"),arqout,strerror(errno));
+ write_html_trailer(fp_ou);
+ if (fclose(fp_ou)==EOF) {
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqout,strerror(errno));
+ exit(EXIT_FAILURE);
+ }
return;
}