]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - html.c
Generate redirector log even if -d is not given
[thirdparty/sarg.git] / html.c
diff --git a/html.c b/html.c
index ad5be738e80adcea141bdf66d228aa911fa98070..6689af6399b1721e7131ba1ceb440902359628dd 100644 (file)
--- a/html.c
+++ b/html.c
@@ -1,6 +1,6 @@
 /*
  * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
- *                                                            1998, 2013
+ *                                                            1998, 2015
  *
  * SARG donations:
  *      please look at http://sarg.sourceforge.net/donations.php
@@ -38,7 +38,10 @@ extern struct globalstatstruct globstat;
 
 void htmlrel(void)
 {
-       FILE *fp_in, *fp_ou, *fp_ip, *fp_ip2;
+       FileObject *fp_in;
+       FileObject *fp_ip;
+       FILE *fp_ou;
+       FILE *fp_ip2;
 
        long long int nnbytes=0, unbytes=0, tnbytes=0, totbytes=0, totbytes2=0;
        long long int totelap=0, totelap2=0, nnelap=0, unelap=0, tnelap=0;
@@ -70,12 +73,14 @@ void htmlrel(void)
        userscan uscan;
 
        if (snprintf(tmp2,sizeof(tmp2),"%s/sargtmp.int_unsort",tmp)>=sizeof(tmp2)) {
-               debuga(_("File name too long: %s/sargtmp.int_unsort\n"),tmp);
+               debuga(__FILE__,__LINE__,_("Path too long: "));
+               debuga_more("%s/sargtmp.int_unsort\n",tmp);
                exit(EXIT_FAILURE);
        }
 
        if (snprintf(tmp3,sizeof(tmp3),"%s/sargtmp.int_log",tmp)>=sizeof(tmp3)) {
-               debuga(_("File name too long: %s/sargtmp.int_log\n"),tmp);
+               debuga(__FILE__,__LINE__,_("Path too long: "));
+               debuga_more("%s/sargtmp.int_log\n",tmp);
                exit(EXIT_FAILURE);
        }
 
@@ -92,18 +97,21 @@ void htmlrel(void)
                        for (i=0 ; i<PerUserLimitsNumber ; i++) {
                                FILE *fp_usr=fopen(PerUserLimits[i].File,"wt");
                                if (fp_usr==NULL) {
-                                       debuga(_("Cannot create empty per_user_limit file \"%s\": %s"),PerUserLimits[i].File,
+                                       debuga(__FILE__,__LINE__,_("Cannot create empty per_user_limit file \"%s\": %s\n"),PerUserLimits[i].File,
                                                   strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
-                               fclose(fp_usr);
+                               if (fclose(fp_usr)==EOF) {
+                                       debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
+                                       exit(EXIT_FAILURE);
+                               }
                        }
                        break;
 
                case PUFC_AsRequired:
                        for (i=0 ; i<PerUserLimitsNumber ; i++) {
                                if (access(PerUserLimits[i].File,R_OK)==0 && unlink(PerUserLimits[i].File)==-1) {
-                                       debuga(_("Cannot delete per_user_limit file \"%s\": %s"),PerUserLimits[i].File,
+                                       debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),PerUserLimits[i].File,
                                                   strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
@@ -113,12 +121,13 @@ void htmlrel(void)
 
        uscan=userinfo_startscan();
        if (uscan == NULL) {
-               debuga(_("Cannot enumerate the user list\n"));
+               debuga(__FILE__,__LINE__,_("Cannot enumerate the user list\n"));
                exit(EXIT_FAILURE);
        }
        while ( (uinfo = userinfo_advancescan(uscan)) != NULL ) {
                if (snprintf(warea,sizeof(warea),"%s/%s",outdirname,uinfo->filename)>=sizeof(warea)) {
-                       debuga(_("Destination directory too long: %s/%s\n"),outdirname,uinfo->filename);
+                       debuga(__FILE__,__LINE__,_("Path too long: "));
+                       debuga_more("%s/%s\n",outdirname,uinfo->filename);
                        exit(EXIT_FAILURE);
                }
                if (!uinfo->topuser) {
@@ -128,29 +137,31 @@ void htmlrel(void)
                }
 
                if (access(warea, R_OK) != 0) {
-                       if (mkdir(warea,0755)) {
-                               debuga(_("Cannot create directory %s - %s\n"),warea,strerror(errno));
+                       if (PortableMkDir(warea,0755)) {
+                               debuga(__FILE__,__LINE__,_("Cannot create directory \"%s\": %s\n"),warea,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                }
                tmpsort(uinfo);
 
                if (snprintf(arqin,sizeof(arqin),"%s/htmlrel.txt",tmp)>=sizeof(arqin)) {
-                       debuga(_("Input file name too long: %s/htmlrel.txt\n"),tmp);
+                       debuga(__FILE__,__LINE__,_("Input file name too long: %s/htmlrel.txt\n"),tmp);
                        exit(EXIT_FAILURE);
                }
-               if ((fp_in = fopen(arqin, "r")) == 0){
+               if ((fp_in = FileObject_Open(arqin)) == 0){
                        if (uinfo->no_report) continue;
-                       debuga(_("(html3) Cannot open file %s: %s\n"),arqin,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqin,FileObject_GetLastOpenError());
                        exit(EXIT_FAILURE);
                }
 
                if (snprintf(arqou,sizeof(arqou),"%s/%s/%s.html",outdirname,uinfo->filename,uinfo->filename)>=sizeof(arqou)) {
-                       debuga(_("Output file name too long: %s/%s/%s.html\n"),outdirname,uinfo->filename,uinfo->filename);
+                       debuga(__FILE__,__LINE__,_("Path too long: "));
+                       debuga_more("%s/%s/%s.html\n",outdirname,uinfo->filename,uinfo->filename);
                        exit(EXIT_FAILURE);
                }
                if (snprintf(duser,sizeof(duser),"%s/denied_%s.html",outdirname,uinfo->filename)>=sizeof(duser)) {
-                       debuga(_("File name too long: %s/denied_%s.html\n"),outdirname,uinfo->filename);
+                       debuga(__FILE__,__LINE__,_("Path too long: "));
+                       debuga_more("%s/denied_%s.html\n",outdirname,uinfo->filename);
                        exit(EXIT_FAILURE);
                }
                if(access(duser, R_OK) != 0)
@@ -159,7 +170,7 @@ void htmlrel(void)
                        have_denied_report=true;
 
                if ((line=longline_create())==NULL) {
-                       debuga(_("Not enough memory to read file %s\n"),arqin);
+                       debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arqin);
                        exit(EXIT_FAILURE);
                }
 
@@ -174,44 +185,44 @@ void htmlrel(void)
                while((buf=longline_read(fp_in,line))!=NULL) {
                        getword_start(&gwarea,buf);
                        if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken number of access in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        tnacc+=ltemp;
                        if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken downloaded size in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid downloaded size in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        tnbytes+=ltemp;
                        if (getword_ptr(NULL,NULL,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken url in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_skip(MAXLEN,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken access code in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid access code in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken elapsed time in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        tnelap+=ltemp;
                        if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken in-cache volume in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid in-cache size in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        tnincache+=ltemp;
                        if (getword_atoll(&ltemp,&gwarea,'\n')<0) {
-                               debuga(_("There is a broken out-cache volume in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid out-of-cache size in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        tnoucache+=ltemp;
                }
 
-               rewind(fp_in);
+               FileObject_Rewind(fp_in);
 
                if ((fp_ou = fopen(arqou, "w")) == 0){
-                       debuga(_("(html5) Cannot open file %s: %s\n"),arqou,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqou,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
@@ -256,7 +267,7 @@ void htmlrel(void)
                fputs("</tr></thead>\n",fp_ou);
 
                if(debug) {
-                       debuga(_("Making report: %s\n"),uinfo->id);
+                       debuga(__FILE__,__LINE__,_("Making report %s\n"),uinfo->id);
                }
                count=0;
                arqip[0]='\0';
@@ -264,31 +275,31 @@ void htmlrel(void)
                while((buf=longline_read(fp_in,line))!=NULL) {
                        getword_start(&gwarea,buf);
                        if (getword_atoll(&twork,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken number of access in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_atoll(&nnbytes,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken number of bytes in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken url in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword(tmsg,sizeof(tmsg),&gwarea,'\t')<0) {
-                               debuga(_("There is a broken access code in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid access code in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_atoll(&nnelap,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken elapsed time in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_atoll(&incache,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken in cache column in file %s\n"),arqin);
+                               debuga(__FILE__,__LINE__,_("Invalid in-cache size in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_atoll(&oucache,&gwarea,'\n')<0) {
-                               debuga(_("There is a broken out of cache column in file %s (%d)\n"),arqin,__LINE__);
+                               debuga(__FILE__,__LINE__,_("Invalid out-of-cache size in file \"%s\"\n"),arqin);
                                exit(EXIT_FAILURE);
                        }
 
@@ -362,106 +373,110 @@ void htmlrel(void)
                        } else if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) {
                                snprintf(warea,sizeof(warea),"%s/%s/tt.html",outdirname,uinfo->filename);
                                if (unlink(warea)!=0) {
-                                       debuga(_("Cannot delete \"%s\": %s\n"),warea,strerror(errno));
+                                       debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),warea,strerror(errno));
                                }
                        }
 
                        if(iprel) {
                                if (snprintf(arqip,sizeof(arqip),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(arqip)) {
-                                       debuga(_("File name too long: %s/%s.ip\n"),tmp,uinfo->filename);
+                                       debuga(__FILE__,__LINE__,_("Path too long: "));
+                                       debuga_more("%s/%s.ip\n",tmp,uinfo->filename);
                                        exit(EXIT_FAILURE);
                                }
 
-                               if ((fp_ip = fopen(arqip, "r")) == 0){
-                                       debuga(_("(html6) Cannot open file %s: %s\n"),arqip,strerror(errno));
+                               if ((fp_ip = FileObject_Open(arqip)) == 0){
+                                       debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqip,FileObject_GetLastOpenError());
                                        exit(EXIT_FAILURE);
                                }
 
                                if ((fp_ip2 = MY_FOPEN(tmp2, "a")) == 0){
-                                       debuga(_("(html7) Cannot open file %s: %s\n"),tmp2,strerror(errno));
+                                       debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp2,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
 
                                if ((line1=longline_create())==NULL) {
-                                       debuga(_("Not enough memory to read file %s\n"),arqip);
+                                       debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arqip);
                                        exit(EXIT_FAILURE);
                                }
                                while((buf=longline_read(fp_ip,line1))!=NULL) {
                                        getword_start(&gwarea,buf);
                                        if (getword(user_ip,sizeof(user_ip),&gwarea,'\t')<0) {
-                                               debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid user IP in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if (getword_ptr(buf,&user_url,&gwarea,'\t')<0) {
-                                               debuga(_("Maybe you have a broken url in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid url in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if (strncmp(user_url,url,strlen(url))!=0) continue;
                                        if (getword_skip(15,&gwarea,'\t')<0) {
-                                               debuga(_("Maybe you have a broken day in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid day in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if (getword_skip(15,&gwarea,'\t')<0) {
-                                               debuga(_("Maybe you have a broken time in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid time in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
-                                               debuga(_("Maybe you have a broken size in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid size in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if (getword_atoll(&userelap,&gwarea,'\0')<0) {
-                                               debuga(_("Maybe you have a broken elapsed time in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        fprintf(fp_ip2,"%s\t%"PRIu64"\t%"PRIu64"\n",user_ip,(uint64_t)userbytes,(uint64_t)userelap);
                                }
                                longline_destroy(&line1);
 
-                               fclose(fp_ip);
                                if (fclose(fp_ip2)==EOF) {
-                                       debuga(_("Write error in %s: %s\n"),tmp2,strerror(errno));
+                                       debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),tmp2,strerror(errno));
+                                       exit(EXIT_FAILURE);
+                               }
+                               if (FileObject_Close(fp_ip)) {
+                                       debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arqip,FileObject_GetLastCloseError());
                                        exit(EXIT_FAILURE);
                                }
 
                                if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp,tmp3,tmp2)>=sizeof(csort)) {
-                                       debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+                                       debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
                                        exit(EXIT_FAILURE);
                                }
                                cstatus=system(csort);
                                if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
-                                       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
-                                       debuga(_("sort command: %s\n"),csort);
+                                       debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+                                       debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
                                        exit(EXIT_FAILURE);
                                }
 
-                               if ((fp_ip = MY_FOPEN(tmp3, "r")) == 0) {
-                                       debuga(_("(html8) Cannot open file %s: %s\n"),tmp3,strerror(errno));
+                               if ((fp_ip = FileObject_Open(tmp3)) == 0) {
+                                       debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp3,FileObject_GetLastOpenError());
                                        exit(EXIT_FAILURE);
                                }
 
                                if (unlink(tmp2)) {
-                                       debuga(_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
+                                       debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
 
                                olduserip[0]='\0';
 
                                if ((line1=longline_create())==NULL) {
-                                       debuga(_("Not enough memory to read file %s\n"),arqip);
+                                       debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),arqip);
                                        exit(EXIT_FAILURE);
                                }
                                while((buf=longline_read(fp_ip,line1))!=NULL) {
                                        getword_start(&gwarea,buf);
                                        if (getword(user_ip,sizeof(user_ip),&gwarea,'\t')<0) {
-                                               debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid user IP in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
-                                               debuga(_("Maybe you have a broken size in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid size in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if (getword_atoll(&userelap,&gwarea,'\0')<0) {
-                                               debuga(_("Maybe you have a broken elapsed time in your %s file\n"),tmp3);
+                                               debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),tmp3);
                                                exit(EXIT_FAILURE);
                                        }
                                        if(strcmp(user_ip,olduserip) != 0) {
@@ -491,11 +506,14 @@ void htmlrel(void)
                                        unelap+=userelap;
                                }
 
-                               fclose(fp_ip);
+                               if (FileObject_Close(fp_ip)) {
+                                       debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),tmp3,FileObject_GetLastCloseError());
+                                       exit(EXIT_FAILURE);
+                               }
                                longline_destroy(&line1);
 
                                if (unlink(tmp3)) {
-                                       debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
+                                       debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
 
@@ -521,17 +539,20 @@ void htmlrel(void)
                        unelap=0;
                }
 
-               fclose(fp_in);
+               if (FileObject_Close(fp_in)) {
+                       debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arqin,FileObject_GetLastCloseError());
+                       exit(EXIT_FAILURE);
+               }
                longline_destroy(&line);
 
                if (iprel && arqip[0]) {
                        if (!KeepTempLog && unlink(arqip)) {
-                               debuga(_("Cannot delete \"%s\": %s\n"),arqip,strerror(errno));
+                               debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqip,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                }
                if (!KeepTempLog && unlink(arqin)) {
-                       debuga(_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
@@ -575,21 +596,26 @@ void htmlrel(void)
                                        FILE *fp_usr;
 
                                        if((fp_usr = fopen(PerUserLimits[i].File, "at")) == 0) {
-                                               debuga(_("(html10) Cannot open per user limit file %s: %s\n"),PerUserLimits[i].File,strerror(errno));
+                                               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
-                                       if (PerUserLimits[i].UserId)
-                                               fprintf(fp_usr,"%s\n",uinfo->label);
-                                       else
-                                               fprintf(fp_usr,"%s\n",uinfo->ip);
+                                       switch (PerUserLimits[i].Output)
+                                       {
+                                               case PUOE_UserId:
+                                                       fprintf(fp_usr,"%s\n",uinfo->label);
+                                                       break;
+                                               case PUOE_UserIp:
+                                                       fprintf(fp_usr,"%s\n",uinfo->ip);
+                                                       break;
+                                       }
                                        if (fclose(fp_usr)==EOF) {
-                                               debuga(_("Write error in per user limit file %s: %s\n"),PerUserLimits[i].File,strerror(errno));
+                                               debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
                                        user_limit[maskid]|=mask;
 
                                        if(debug)
-                                               debuga(_("User %s limit exceeded (%d MB). Added to file %s\n"),uinfo->label,
+                                               debuga(__FILE__,__LINE__,_("Limit exceeded for user %s (%d MB). Added to file \"%s\"\n"),uinfo->label,
                                                           PerUserLimits[i].Limit,PerUserLimits[i].File);
                                }
                        }
@@ -620,10 +646,9 @@ void htmlrel(void)
                        fputs("</tfoot>",fp_ou);
 
                fputs("</table></div>\n",fp_ou);
-               if (write_html_trailer(fp_ou)<0)
-                       debuga(_("Write error in file %s\n"),arqou);
+               write_html_trailer(fp_ou);
                if (fclose(fp_ou)==EOF) {
-                       debuga(_("Write error in %s: %s\n"),arqou,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqou,strerror(errno));
                        exit(EXIT_FAILURE);
                }