X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=repday.c;h=9a412609b0c2a3f6ce7c2519dd4a848158ec7ace;hb=507460aefaddc24a2e53a9f4a6399098c23dc7c5;hp=08cff9ec0dc00755f7b9de382a889b30bb65710d;hpb=5f46190e0e20b982462ab90d4d17e3db73e47fba;p=thirdparty%2Fsarg.git diff --git a/repday.c b/repday.c index 08cff9e..9a41260 100644 --- a/repday.c +++ b/repday.c @@ -1,6 +1,6 @@ /* * SARG Squid Analysis Report Generator http://sarg.sourceforge.net - * 1998, 2011 + * 1998, 2012 * * SARG donations: * please look at http://sarg.sourceforge.net/donations.php @@ -66,7 +66,7 @@ void report_day(const struct userinfostruct *uinfo) } if((fp_in=fopen(wdirname,"r"))==NULL) { - debuga(_("(repday) Cannot open log file %s\n"),wdirname); + debuga(_("(repday) Cannot open log file %s: %s\n"),wdirname,strerror(errno)); exit(EXIT_FAILURE); } @@ -119,7 +119,7 @@ void report_day(const struct userinfostruct *uinfo) fclose(fp_in); if((fp_ou=fopen(arqout,"w"))==NULL) { - debuga(_("(repday) Cannot open log file %s\n"),arqout); + debuga(_("(repday) Cannot open log file %s: %s\n"),arqout,strerror(errno)); exit(EXIT_FAILURE); } @@ -140,8 +140,11 @@ void report_day(const struct userinfostruct *uinfo) label=_("BYTES"); fputs("\n", fp_ou); fputs("",fp_ou); - for( i = 0; i < hours.len; i++ ) - fprintf(fp_ou, "\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, "\n", data, label ); + } fprintf(fp_ou, "\n", _("TOTAL"), label ); memset(tttime,0,sizeof(tttime)); @@ -177,14 +180,23 @@ void report_day(const struct userinfostruct *uinfo) } fprintf(fp_ou, "\n",fixnum(tt,1)); fputs("
%02d%s
%s
%s
%s
%s
%s
%s
\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"), + (int64_t)tt,(int64_t)uinfo->nbytes,uinfo->label); + exit(EXIT_FAILURE); + } +#endif } if((datetimeby & DATETIME_ELAP)!=0) { label=_("H:M:S"); fputs("\n", fp_ou); fputs("",fp_ou); - for( i = 0; i < hours.len; i++ ) - fprintf(fp_ou, "\n", hours.list[ i ], _("H"), label ); + for( i = 0; i < hours.len; i++ ) { + sprintf(data,_("%02dH"),hours.list[ i ]); + fprintf(fp_ou, "\n", data, label ); + } fprintf(fp_ou, "\n", _("TOTAL"), label ); memset(tttime,0,sizeof(tttime)); @@ -220,11 +232,20 @@ void report_day(const struct userinfostruct *uinfo) } fprintf(fp_ou, "\n",fixtime(tt)); fputs("
%02d%s
%s
%s
%s
%s
%s
%s
\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"), + (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)); + if (fclose(fp_ou)==EOF) { + debuga(_("Write error in %s: %s\n"),arqout,strerror(errno)); + exit(EXIT_FAILURE); + } return; }