]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - email.c
Display the source of the message displayed on stderr
[thirdparty/sarg.git] / email.c
diff --git a/email.c b/email.c
index d4bd1dc289b50ce26156bdc62f02a61bb24f7682..0f9cd9a2b72c2be0a2f6f2cf474779d2854d6fa6 100644 (file)
--- a/email.c
+++ b/email.c
@@ -58,13 +58,13 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 
        snprintf(wger,sizeof(wger),"%s/sarg-general",dirname);
        if((fp_in=fopen(wger,"r"))==NULL) {
-               debuga(_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        snprintf(top2,sizeof(top2),"%s/top.tmp",dirname);
        if((fp_top2=fopen(top2,"w"))==NULL) {
-               debuga(_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -72,7 +72,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
        totuser=0;
 
        if ((line=longline_create())==NULL) {
-               debuga(_("Not enough memory to read file \"%s\"\n"),wger);
+               debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),wger);
                exit(EXIT_FAILURE);
        }
 
@@ -103,7 +103,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                tnelap+=item.nelap;
        }
        if (fclose(fp_in)==EOF) {
-               debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wger,strerror(errno));
                exit(EXIT_FAILURE);
        }
        longline_destroy(&line);
@@ -120,41 +120,41 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
        }
 
        if (fclose(fp_top2)==EOF) {
-               debuga(_("Write error in \"%s\": %s\n"),top2,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
 #ifdef ENABLE_DOUBLE_CHECK_DATA
        if (ttnacc!=globstat.nacc || ttnbytes!=globstat.nbytes || ttnelap!=globstat.elap) {
-               debuga(_("Total statistics mismatch when reading \"%s\" to produce the email report\n"),wger);
+               debuga(__FILE__,__LINE__,_("Total statistics mismatch when reading \"%s\" to produce the email report\n"),wger);
                exit(EXIT_FAILURE);
        }
 #endif
 
        if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" -r -k 2,2 -o \"%s\" \"%s\"", TempDir, top1, top2)>=sizeof(csort)) {
-               debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
+               debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
                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 (!KeepTempLog && unlink(top2)) {
-               debuga(_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((fp_top1=fopen(top1,"r"))==NULL) {
-               debuga(_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        snprintf(top3,sizeof(top3),"%s/report",dirname);
        if((fp_top3=fopen(top3,"w"))==NULL) {
-               debuga(_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -191,25 +191,25 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                fixendofline(warea);
                getword_start(&gwarea,warea);
                if (getword(user,sizeof(user),&gwarea,'\t')<0) {
-                       debuga(_("Invalid user ID in file \"%s\"\n"),top1);
+                       debuga(__FILE__,__LINE__,_("Invalid user ID in file \"%s\"\n"),top1);
                        exit(EXIT_FAILURE);
                }
                if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
-                       debuga(_("Invalid number of bytes in file \"%s\"\n"),top1);
+                       debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),top1);
                        exit(EXIT_FAILURE);
                }
                if (getword_atoll(&nacc,&gwarea,'\t')<0) {
-                       debuga(_("Invalid number of accesses in file \"%s\"\n"),top1);
+                       debuga(__FILE__,__LINE__,_("Invalid number of accesses in file \"%s\"\n"),top1);
                        exit(EXIT_FAILURE);
                }
                if (getword_atoll(&elap,&gwarea,'\0')<0) {
-                       debuga(_("Invalid elapsed time in file \"%s\"\n"),top1);
+                       debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),top1);
                        exit(EXIT_FAILURE);
                }
 
                uinfo=userinfo_find_from_id(user);
                if (!uinfo) {
-                       debuga(_("Unknown user ID %s in file \"%s\"\n"),user,top1);
+                       debuga(__FILE__,__LINE__,_("Unknown user ID %s in file \"%s\"\n"),user,top1);
                        exit(EXIT_FAILURE);
                }
 
@@ -253,11 +253,11 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #endif
 
        if (fclose(fp_top1)==EOF) {
-               debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
        }
        if (!KeepTempLog && unlink(top1)) {
-               debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -266,20 +266,20 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
        fprintf(fp_top3, "\n%s\n", asctime(local));
 
        if (fclose(fp_top3)==EOF) {
-               debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),top3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if(strcmp(email,"stdout") == 0) {
                if((fp_top3=fopen(top3,"r"))==NULL) {
-                       debuga(_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
                while(fgets(warea,sizeof(warea),fp_top3)!=NULL)
                        fputs(warea,stdout);
                if (fclose(fp_top3)==EOF) {
-                       debuga(_("Read error in \"%s\": %s\n"),top3,strerror(errno));
+                       debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),top3,strerror(errno));
                        exit(EXIT_FAILURE);
                }
        } else {
@@ -288,11 +288,11 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                strftime(Subject,sizeof(Subject),_("SARG report, %c"),local);
                snprintf(warea,sizeof(warea),"%s -s \"%s\" \"%s\" <\"%s\"",MailUtility,Subject,email,top3);
                if (debug)
-                       debuga(_("Sending mail with command: %s\n"),warea);
+                       debuga(__FILE__,__LINE__,_("Sending mail with command: %s\n"),warea);
                cstatus=system(warea);
                if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
-                       debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
-                       debuga(_("command: %s\n"),warea);
+                       debuga(__FILE__,__LINE__,_("command return status %d\n"),WEXITSTATUS(cstatus));
+                       debuga(__FILE__,__LINE__,_("command: %s\n"),warea);
                        exit(EXIT_FAILURE);
                }
        }