]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - report.c
Add support to decompress xz files
[thirdparty/sarg.git] / report.c
index 211bdcb98bec16c1230aa6214c38efce5feea84b..3a82015917f169ff80b4f05a0c64c68e6aee9676 100644 (file)
--- a/report.c
+++ b/report.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
 
 #include "include/conf.h"
 #include "include/defs.h"
+#include "include/filelist.h"
 
 //! The global statistics of the whole log read.
 struct globalstatstruct globstat;
 //! \c True to enable the smart filter.
 bool smartfilter=false;
 
+extern FileListObject UserAgentLog;
+
 //! The file to store the HTML page where the time of access is reported for one site and one user.
 static FILE *fp_tt=NULL;
 //! The name of the file containing the access time of the site/user.
@@ -46,7 +49,7 @@ static void grava_SmartFilter(const char *dirname, const char *user, const char
 
 void gerarel(void)
 {
-       FILE *fp_in;
+       FileObject *fp_in;
        FILE *fp_gen;
        FILE *fp_tmp=NULL;
 
@@ -56,7 +59,8 @@ void gerarel(void)
        char oldacciptt[256];
        char wdirname[MAXLEN];
        char *oldurl=NULL;
-       char oldmsg[50], acccode[MAXLEN/2 - 1], oldacccode[MAXLEN/2 - 1];
+       const char *oldmsg;
+       char acccode[MAXLEN/2 - 1], oldacccode[MAXLEN/2 - 1];
        char ipantes[256], nameantes[MAXLEN];
        char accsmart[MAXLEN];
        char crc2[MAXLEN/2 -1];
@@ -91,20 +95,33 @@ void gerarel(void)
        smartfilter=false;
        memset(&globstat,0,sizeof(globstat));
 
-       if (vrfydir(&period, addr, site, us, email)<0) {
-               debuga(_("Cannot create the output directory name containing the period as part of the name\n"));
-               exit(EXIT_FAILURE);
+       if (email[0]=='\0') {
+               if (vrfydir(&period, addr, site, us)<0) {
+                       debuga(__FILE__,__LINE__,_("Cannot create the output directory name containing the period as part of the name\n"));
+                       exit(EXIT_FAILURE);
+               }
+       } else {
+               if (snprintf(outdirname,sizeof(outdirname),"%s/emailrep",tmp)>=sizeof(outdirname)) {
+                       debuga(__FILE__,__LINE__,_("Path too long: "));
+                       debuga_more("%s/emailrep\n",tmp);
+                       exit(EXIT_FAILURE);
+               }
+               my_mkdir(outdirname);
        }
 
-       if(debugz){
-               debugaz(_("outdirname=%s\n"),outdirname);
+       if(debugz>=LogLevel_Process){
+               debugaz(__FILE__,__LINE__,_("outdirname=%s\n"),outdirname);
        }
 
-       if(UserAgentLog[0] != '\0' && email[0] == '\0') useragent();
+       if (email[0] == '\0' && !FileList_IsEmpty(UserAgentLog))
+               UserAgent_Readlog();
+
+       UserAgent();
+       init_usertab(UserTabFile);
 
        snprintf(wdirname,sizeof(wdirname),"%s/sarg-general",outdirname);
        if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){
-               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -118,17 +135,18 @@ void gerarel(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 ) {
                sort_users_log(tmp,debug,uinfo);
                if (snprintf(tmp3,sizeof(tmp3),"%s/%s.user_log",tmp,uinfo->filename)>=sizeof(tmp3)) {
-                       debuga(_("(report) directory entry too long: %s/%s.user_log\n"),tmp,uinfo->filename);
+                       debuga(__FILE__,__LINE__,_("Path too long: "));
+                       debuga_more("%s/%s.user_log\n",tmp,uinfo->filename);
                        exit(EXIT_FAILURE);
                }
-               if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){
-                       debuga(_("(report) Cannot open file %s: %s\n"),tmp,strerror(errno));
+               if((fp_in=FileObject_Open(tmp3))==NULL){
+                       debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp3,FileObject_GetLastOpenError());
                        exit(EXIT_FAILURE);
                }
                user=uinfo->filename;
@@ -162,7 +180,7 @@ void gerarel(void)
                oucache=0;
 
                if ((line=longline_create())==NULL) {
-                       debuga(_("Not enough memory to read the downloaded files\n"));
+                       debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),tmp3);
                        exit(EXIT_FAILURE);
                }
 
@@ -172,16 +190,16 @@ void gerarel(void)
                            getword(accip,sizeof(accip),&gwarea,'\t')<0 ||
                            getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_atoll(&accbytes,&gwarea,'\t')<0 ||
                            getword(acccode,sizeof(acccode),&gwarea,'\t')<0) {
-                               debuga(_("There is a broken record or garbage in file %s\n"),tmp3);
+                               debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),tmp3);
                                exit(EXIT_FAILURE);
                        }
                        if(strncmp(acccode,"TCP_DENIED/407",14) == 0) continue;
                        if (getword_atoll(&accelap,&gwarea,'\t')<0) {
-                               debuga(_("There is a broken elapsed time in file %s\n"),tmp3);
+                               debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),tmp3);
                                exit(EXIT_FAILURE);
                        }
                        if (getword_skip(20000,&gwarea,'"')<0 || getword(accsmart,sizeof(accsmart),&gwarea,'"')<0) {
-                               debuga(_("There is a broken smart info in file %s\n"),tmp3);
+                               debuga(__FILE__,__LINE__,_("Invalid smart info in file \"%s\"\n"),tmp3);
                                exit(EXIT_FAILURE);
                        }
 
@@ -209,7 +227,7 @@ void gerarel(void)
                                        ourl_size=url_len+1;
                                        oldurl=realloc(oldurl,ourl_size);
                                        if (!oldurl) {
-                                               debuga(_("Not enough memory to store the url\n"));
+                                               debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
                                                exit(EXIT_FAILURE);
                                        }
                                }
@@ -225,9 +243,9 @@ void gerarel(void)
                        if(site[0] == '\0') {
                                if(!same_url){
                                        if(strstr(oldacccode,"DENIED") != 0)
-                                               strcpy(oldmsg,"DENIED");
+                                               oldmsg="DENIED";
                                        else
-                                               strcpy(oldmsg,"OK");
+                                               oldmsg="OK";
                                        if (fp_tmp) gravatmp(fp_tmp,oldurl,nacc,nbytes,oldmsg,nelap,incache,oucache);
                                        gravager(fp_gen,wdirname,uinfo,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
                                        nacc=0;
@@ -251,7 +269,7 @@ void gerarel(void)
                                                my_mkdir(arqtt);
                                        snprintf(arqtt,sizeof(arqtt),"%s/%s/tt.html",outdirname,uinfo->filename);
                                        if ((fp_tt = fopen(arqtt, "w")) == 0) {
-                                               debuga(_("(report) Cannot open file %s: %s\n"),arqtt,strerror(errno));
+                                               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),arqtt,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
                                        ttopen=1;
@@ -283,7 +301,7 @@ void gerarel(void)
                                        output_html_string(fp_tt,url,100);
                                        fputs("</a></td></tr>\n",fp_tt);
                                        fprintf(fp_tt,"<tr><th class=\"header_l\">%s</th>",_("IP"));
-                                       fprintf(fp_tt,"<th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("DATE"),_("TIME"));
+                                       fprintf(fp_tt,"<th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("DATE"),pgettext("wall clock","TIME"));
                                }
 
                                fprintf(fp_tt,"<tr><td class=\"data2\">%s</td>",accip);
@@ -294,7 +312,7 @@ void gerarel(void)
                                        ourltt_size=url_len+1;
                                        oldurltt=realloc(oldurltt,ourltt_size);
                                        if (!oldurltt) {
-                                               debuga(_("Not enough memory to store the url\n"));
+                                               debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
                                                exit(EXIT_FAILURE);
                                        }
                                }
@@ -320,7 +338,7 @@ void gerarel(void)
                                        ourl_size=url_len+1;
                                        oldurl=realloc(oldurl,ourl_size);
                                        if (!oldurl) {
-                                               debuga(_("Not enough memory to store the url\n"));
+                                               debuga(__FILE__,__LINE__,_("Not enough memory to store the url\n"));
                                                exit(EXIT_FAILURE);
                                        }
                                }
@@ -329,14 +347,17 @@ void gerarel(void)
                        strcpy(oldaccdia,accdia);
                        strcpy(oldacchora,acchora);
                }
-               fclose(fp_in);
+               if (FileObject_Close(fp_in)) {
+                       debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),tmp3,FileObject_GetLastCloseError());
+                       exit(EXIT_FAILURE);
+               }
                longline_destroy(&line);
                if (oldurltt) free(oldurltt);
                if (oldurl) {
                        if(strstr(oldacccode,"DENIED") != 0)
-                               strcpy(oldmsg,"DENIED");
+                               oldmsg="DENIED";
                        else
-                               strcpy(oldmsg,"OK");
+                               oldmsg="OK";
                        if (fp_tmp) gravatmp(fp_tmp,oldurl,nacc,nbytes,oldmsg,nelap,incache,oucache);
                        closett();
                        gravager(fp_gen,wdirname,uinfo,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
@@ -348,13 +369,13 @@ void gerarel(void)
                }
                if (fp_tmp) {
                        if (fclose(fp_tmp)==EOF) {
-                               debuga(_("Failed to close temporary file for user %s: %s\n"),uinfo->filename,strerror(errno));
+                               debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),uinfo->filename,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                        fp_tmp=NULL;
                }
                if (!KeepTempLog && 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);
                }
        }
@@ -363,7 +384,7 @@ void gerarel(void)
 
        totalger(fp_gen,wdirname);
        if (fclose(fp_gen)==EOF) {
-               debuga(_("Write error in %s: %s\n"),wdirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -371,8 +392,8 @@ void gerarel(void)
                if (!indexonly) {
                        if(DansGuardianConf[0] != '\0')
                                dansguardian_log();
-                       else if (debugz)
-                               debugaz(_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
+                       else if (debugz>=LogLevel_Process)
+                               debugaz(__FILE__,__LINE__,_("Dansguardian report not produced because no dansguardian configuration file was provided\n"));
 
                        redirector_log();
                }
@@ -382,28 +403,28 @@ void gerarel(void)
                if (!indexonly) {
                        if((ReportType & REPORT_TYPE_DOWNLOADS) != 0)
                                download_report();
-                       else if (debugz)
-                               debugaz(_("Downloaded files report not requested in report_type\n"));
+                       else if (debugz>=LogLevel_Process)
+                               debugaz(__FILE__,__LINE__,_("Downloaded files report not requested in report_type\n"));
 
                        if((ReportType & REPORT_TYPE_TOPSITES) != 0)
                                topsites();
-                       else if (debugz)
-                               debugaz(_("Top sites report not requested in report_type\n"));
+                       else if (debugz>=LogLevel_Process)
+                               debugaz(__FILE__,__LINE__,_("Top sites report not requested in report_type\n"));
 
                        if((ReportType & REPORT_TYPE_SITES_USERS) != 0)
                                siteuser();
-                       else if (debugz)
-                               debugaz(_("Sites & users report not requested in report_type\n"));
+                       else if (debugz>=LogLevel_Process)
+                               debugaz(__FILE__,__LINE__,_("Sites & users report not requested in report_type\n"));
 
                        if ((ReportType & REPORT_TYPE_DENIED) != 0)
                                gen_denied_report();
-                       else if (debugz)
-                               debugaz(_("Denied accesses report not requested in report_type\n"));
+                       else if (debugz>=LogLevel_Process)
+                               debugaz(__FILE__,__LINE__,_("Denied accesses report not requested in report_type\n"));
 
                        if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0)
                                authfail_report();
-                       else if (debugz)
-                               debugaz(_("Authentication failures report not requested in report_type\n"));
+                       else if (debugz>=LogLevel_Process)
+                               debugaz(__FILE__,__LINE__,_("Authentication failures report not requested in report_type\n"));
 
                        if(smartfilter) smartfilter_report();
 
@@ -414,18 +435,18 @@ void gerarel(void)
 
                        if((ReportType & REPORT_TYPE_USERS_SITES) != 0)
                                htmlrel();
-                       else if (debugz)
-                               debugaz(_("User's detailed report not requested in report_type\n"));
+                       else if (debugz>=LogLevel_Process)
+                               debugaz(__FILE__,__LINE__,_("User's detailed report not requested in report_type\n"));
                }
 
                make_index();
 
-               if(SuccessfulMsg) debuga(_("Successful report generated on %s\n"),outdirname);
+               if(SuccessfulMsg) debuga(__FILE__,__LINE__,_("Successful report generated on %s\n"),outdirname);
        } else {
-               geramail(outdirname, debug, outdir, email, tmp);
+               topuser();
 
                if((strcmp(email,"stdout") != 0) && SuccessfulMsg)
-                       debuga(_("Successful report generated and sent to %s\n"),email);
+                       debuga(__FILE__,__LINE__,_("Successful report generated and sent to %s\n"),email);
        }
 
        if(indexonly) index_only(outdirname, debug);
@@ -442,14 +463,15 @@ static FILE *maketmp(const char *user, const char *dirname, int debug)
        if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return(NULL);
        if((ReportType & REPORT_TYPE_TOPUSERS) == 0) return(NULL);
 
-       if(debug) debuga(_("Making file: %s/%s\n"),tmp,user);
+       if(debug) debuga(__FILE__,__LINE__,_("Making file %s/%s\n"),tmp,user);
        if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,user)>=sizeof(wdirname)) {
-               debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp,user);
+               debuga(__FILE__,__LINE__,_("Path too long: "));
+               debuga_more("%s/%s.utmp\n",tmp,user);
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=fopen(wdirname,"w"))==NULL){
-               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -476,7 +498,7 @@ static void closett(void)
                fputs("</table>\n</div>\n",fp_tt);
                fputs("</body>\n</html>\n",fp_tt);
                if (fclose(fp_tt)==EOF) {
-                       debuga(_("Write error in %s: %s\n"),arqtt,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),arqtt,strerror(errno));
                        exit(EXIT_FAILURE);
                }
                fp_tt=NULL;
@@ -491,12 +513,13 @@ static void gravaporuser(const struct userinfostruct *uinfo, const char *dirname
        if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
 
        if (snprintf(wdirname,sizeof(wdirname),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(wdirname)) {
-               debuga(_("Path 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_ou=MY_FOPEN(wdirname,"a"))==NULL){
-               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -507,7 +530,7 @@ static void gravaporuser(const struct userinfostruct *uinfo, const char *dirname
        fprintf(fp_ou,"%s\t%s\t%s\t%s\t%"PRIu64"\t%"PRIu64"\n",ip,url,data,hora,(uint64_t)tam,(uint64_t)elap);
 
        if (fclose(fp_ou)==EOF) {
-               debuga(_("Write error in %s: %s\n"),wdirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -522,7 +545,7 @@ static void gravager(FILE *fp_gen,const char *filename, const struct userinfostr
        to print a long long int unless it is exactly 64-bits long.
        */
        if (fprintf(fp_gen,"%s\t%"PRIu64"\t%"PRIu64"\t%s\t%s\t%s\t%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",uinfo->id,(uint64_t)nacc,(uint64_t)nbytes,url,ip,hora,dia,(uint64_t)nelap,(uint64_t)incache,(uint64_t)oucache)<0) {
-               debuga(_("Failed to write a line in %s\n"),filename);
+               debuga(__FILE__,__LINE__,_("Write error in file \"%s\": %s\n"),filename,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -544,7 +567,7 @@ void totalger(FILE *fp_gen,const char *filename)
        to print a long long int unless it is exactly 64-bits long.
        */
        if (fprintf(fp_gen,"TOTAL\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",(uint64_t)globstat.nacc,(uint64_t)globstat.nbytes,(uint64_t)globstat.elap,(uint64_t)globstat.incache,(uint64_t)globstat.oucache)<0) {
-               debuga(_("Failed to write the total line in %s\n"),filename);
+               debuga(__FILE__,__LINE__,_("Failed to write the total line in %s\n"),filename);
                exit(EXIT_FAILURE);
        }
 }
@@ -570,7 +593,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid total number of accesses in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid total number of accesses in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -587,7 +610,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid total size in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid total size in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -604,7 +627,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid total elapsed time in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid total elapsed time in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -621,7 +644,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid total cache hit in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid total cache hit in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -638,7 +661,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\0') {
-                       debuga(_("Invalid total cache miss in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid total cache miss in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                item->oucache=number*sign;
@@ -648,7 +671,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                item->user=buffer;
                for (i=0 ; i<MAX_USER_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
                if (*buffer!='\t') {
-                       debuga(_("User name too long or invalid in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("User name too long or invalid in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                *buffer++='\0';
@@ -664,7 +687,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid number of accesses in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -681,7 +704,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid number of bytes in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -690,7 +713,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                item->url=buffer;
                while ((unsigned char)*buffer>=' ') buffer++;
                if (*buffer!='\t') {
-                       debuga(_("URL too long or invalid in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("URL too long or invalid in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                *buffer++='\0';
@@ -698,7 +721,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                item->ip=buffer;
                for (i=0 ; i<MAX_IP_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
                if (*buffer!='\t') {
-                       debuga(_("IP address too long or invalid in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("IP address too long or invalid in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                *buffer++='\0';
@@ -706,7 +729,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                item->time=buffer;
                for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
                if (*buffer!='\t') {
-                       debuga(_("Time too long or invalid in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Time too long or invalid in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                *buffer++='\0';
@@ -714,7 +737,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                item->date=buffer;
                for (i=0 ; i<MAX_DATETIME_LEN-1 && (unsigned char)*buffer>=' ' ; i++) buffer++;
                if (*buffer!='\t') {
-                       debuga(_("Date too long or invalid in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Date too long or invalid in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                *buffer++='\0';
@@ -730,7 +753,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid elapsed time in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -747,7 +770,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\t') {
-                       debuga(_("Invalid cache hit size in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid cache hit size in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                buffer++;
@@ -764,7 +787,7 @@ int ger_read(char *buffer,struct generalitemstruct *item,const char *filename)
                while (isdigit(*buffer))
                        number=(number * 10) + (*buffer++)-'0';
                if (*buffer!='\0') {
-                       debuga(_("Invalid cache miss size in %s\n"),filename);
+                       debuga(__FILE__,__LINE__,_("Invalid cache miss size in file \"%s\"\n"),filename);
                        exit(EXIT_FAILURE);
                }
                item->oucache=number*sign;
@@ -778,12 +801,13 @@ static void grava_SmartFilter(const char *dirname, const char *user, const char
        char wdirname[MAXLEN];
 
        if (snprintf(wdirname,sizeof(wdirname),"%s/smartfilter.int_unsort",dirname)>=sizeof(wdirname)) {
-               debuga(_("File name too long for %s/smartfilter.int_unsort\n"),dirname);
+               debuga(__FILE__,__LINE__,_("Path too long: "));
+               debuga_more("%s/smartfilter.int_unsort\n",dirname);
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
-               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -791,7 +815,7 @@ static void grava_SmartFilter(const char *dirname, const char *user, const char
        fputs("</body>\n</html>\n",fp_tt);
 
        if (fclose(fp_ou)==EOF) {
-               debuga(_("Write error in %s: %s\n"),wdirname,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }