]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Explain the reason when a file cannot be opened
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 6 Sep 2012 18:09:15 +0000 (20:09 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 6 Sep 2012 18:09:15 +0000 (20:09 +0200)
The system error string is written in the error message when a file cannot
be opened. It should help in diagnosing the reason for a failure.

27 files changed:
auth.c
authfail.c
convlog.c
dansguardian_log.c
dansguardian_report.c
datafile.c
denied.c
download.c
email.c
exclude.c
grepday.c
html.c
index.c
lastlog.c
readlog.c
redirector.c
repday.c
report.c
siteuser.c
smartfilter.c
splitlog.c
topsites.c
topuser.c
totday.c
useragent.c
usertab.c
util.c

diff --git a/auth.c b/auth.c
index 36c22b1e4107078bbc6feb18fe6e7c0a89127513..9d2d03fd914a7b128dd63f0da62d5aa86e0fd699 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -43,12 +43,12 @@ void htaccess(const struct userinfostruct *uinfo)
                exit(EXIT_FAILURE);
        }
        if((fp_auth=fopen(htname,"w"))==NULL) {
-               debuga(_("(auth) Cannot open file: %s - %s\n"),htname,strerror(errno));
+               debuga(_("(auth) Cannot open file %s: %s\n"),htname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if ((fp_in=fopen(AuthUserTemplateFile,"r"))==NULL) {
-               debuga(_("(auth) Cannot open template file: %s - %s\n"),AuthUserTemplateFile,strerror(errno));
+               debuga(_("(auth) Cannot open template file %s: %s\n"),AuthUserTemplateFile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index dd15e69a921fefd6b2326630d27fbb27f5d8e4ca..e10593fdbe9f982bc14e7ebf5818cae38d111685 100644 (file)
@@ -53,7 +53,7 @@ void authfail_open(void)
 
        snprintf(authfail_unsort,sizeof(authfail_unsort),"%s/authfail.int_unsort",tmp);
        if ((fp_authfail=MY_FOPEN(authfail_unsort,"w"))==NULL) {
-               debuga(_("(log) Cannot open file: %s - %s\n"),authfail_unsort,strerror(errno));
+               debuga(_("(log) Cannot open file %s: %s\n"),authfail_unsort,strerror(errno));
                exit(EXIT_FAILURE);
        }
        return;
@@ -157,7 +157,7 @@ void authfail_report(void)
                exit(EXIT_FAILURE);
        }
        if((fp_in=MY_FOPEN(authfail_sort,"r"))==NULL) {
-               debuga(_("(authfail) Cannot open file %s\n"),authfail_sort);
+               debuga(_("(authfail) Cannot open file %s: %s\n"),authfail_sort,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
@@ -168,7 +168,7 @@ void authfail_report(void)
        authfail_unsort[0]='\0';
 
        if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
-               debuga(_("(authfail) Cannot open file %s\n"),report);
+               debuga(_("(authfail) Cannot open file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index df3dfdc7e8433ddc27f578d2f0e14c6e737f27d6..df75639b4a56495eb212a8db0fe26b5e9e6f6356 100644 (file)
--- a/convlog.c
+++ b/convlog.c
@@ -43,7 +43,7 @@ void convlog(const char *arq, char df, int dfrom, int duntil)
                arq="/var/log/squid/access.log";
 
        if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
-               debuga(_("(convlog) Cannot open log file %s - %s\n"),arq,strerror(errno));
+               debuga(_("(convlog) Cannot open log file %s: %s\n"),arq,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 69e37b651895ee01b3a8ccc15fdc06c6fa471dff..3701a79d17f562571417fb04b902fe4a4737b75b 100644 (file)
@@ -58,12 +58,12 @@ void dansguardian_log(void)
        }
 
        if((fp_guard=fopen(DansGuardianConf,"r"))==NULL) {
-               debuga(_("(dansguardian) Cannot open log file: %s\n"),DansGuardianConf);
+               debuga(_("(dansguardian) Cannot open log file %s: %s\n"),DansGuardianConf,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=MY_FOPEN(guard_in,"a"))==NULL) {
-               debuga(_("(dansguardian) Cannot open log file: %s\n"),guard_in);
+               debuga(_("(dansguardian) Cannot open log file %s: %s\n"),guard_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -87,7 +87,7 @@ void dansguardian_log(void)
                debuga(_("Reading DansGuardian log file: %s\n"),loglocation);
 
        if((fp_in=MY_FOPEN(loglocation,"r"))==NULL) {
-               debuga(_("(dansguardian) Cannot open log file: %s\n"),loglocation);
+               debuga(_("(dansguardian) Cannot open log file %s: %s\n"),loglocation,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index c3fd140f8dd7d39fcb61db3c241bc637761c4523..938820a925e72ad59cbe964f325f40ef886c9dab 100644 (file)
@@ -69,12 +69,12 @@ void dansguardian_report(void)
        sprintf(report,"%s/dansguardian.html",outdirname);
 
        if((fp_in=MY_FOPEN(dansguardian_in,"r"))==NULL) {
-               debuga(_("(dansguardian_report) Cannot open log file %s\n"),dansguardian_in);
+               debuga(_("(dansguardian_report) Cannot open log file %s: %s\n"),dansguardian_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
-               debuga(_("(dansguardian_report) Cannot open log file %s\n"),report);
+               debuga(_("(dansguardian_report) Cannot open log file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 33c80d104c75e001d57374351396a18c2d90b6e1..b6e399822434776dd81c524e8b105a3ab443b546 100644 (file)
@@ -89,7 +89,7 @@ void data_file(char *tmp)
                }
 
                if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){
-                       debuga(_("(datafile) Cannot open file %s\n"),tmp3);
+                       debuga(_("(datafile) Cannot open file %s: %s\n"),tmp3,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
@@ -145,7 +145,7 @@ void data_file(char *tmp)
 
                        if(!same_url || new_user){
                                if(!fp_ou && (fp_ou=MY_FOPEN(DataFile,"w"))==NULL){
-                                       debuga(_("(datafile) Cannot open file %s\n"),DataFile);
+                                       debuga(_("(datafile) Cannot open file %s: %s\n"),DataFile,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
                                saverecs(fp_ou,uinfo,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
index b09c41becac3ccc4c9c53b2ceabcd3b47b9a1be4..1eda2e9efa9dfd6cbd6ab97681f6d535d0a33f17 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -53,7 +53,7 @@ void denied_open(void)
 
        snprintf(denied_unsort,sizeof(denied_unsort),"%s/denied.int_unsort",tmp);
        if ((fp_denied=MY_FOPEN(denied_unsort,"w"))==NULL) {
-               debuga(_("(log) Cannot open file: %s - %s\n"),denied_unsort,strerror(errno));
+               debuga(_("(log) Cannot open file %s: %s\n"),denied_unsort,strerror(errno));
                exit(EXIT_FAILURE);
        }
        return;
@@ -170,12 +170,12 @@ void gen_denied_report(void)
        sprintf(report,"%s/denied.html",outdirname);
 
        if((fp_in=MY_FOPEN(denied_sort,"r"))==NULL) {
-               debuga(_("(denied) Cannot open log file %s\n"),denied_sort);
+               debuga(_("(denied) Cannot open log file %s: %s\n"),denied_sort,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
-               debuga(_("(denied) Cannot open log file %s\n"),report);
+               debuga(_("(denied) Cannot open log file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 37b4065a4378f85d948a566b8e233fbe83a0a632..6028ecf5aac254a917d013e84dc7ae81ec5b2b3a 100644 (file)
@@ -70,7 +70,7 @@ void download_open(void)
 
        snprintf(download_unsort,sizeof(download_unsort),"%s/download.int_unsort",tmp);
        if ((fp_download=MY_FOPEN(download_unsort,"w"))==NULL) {
-               debuga(_("(log) Cannot open file: %s - %s\n"),download_unsort,strerror(errno));
+               debuga(_("(log) Cannot open file %s: %s\n"),download_unsort,strerror(errno));
                exit(EXIT_FAILURE);
        }
        return;
@@ -203,12 +203,12 @@ void download_report(void)
        snprintf(report,sizeof(report),"%s/download.html",outdirname);
 
        if((fp_in=MY_FOPEN(report_in,"r"))==NULL) {
-               debuga(_("(download) Cannot open log file %s\n"),report_in);
+               debuga(_("(download) Cannot open log file %s: %s\n"),report_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=MY_FOPEN(report,"w"))==NULL) {
-               debuga(_("(download) Cannot open log file %s\n"),report);
+               debuga(_("(download) Cannot open log file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
diff --git a/email.c b/email.c
index 7a274bc5d8b74931bc12dd24afe45e0dd7bb5827..84a6d6c5e2475056b516f1fdb7f37ede2078b050 100644 (file)
--- a/email.c
+++ b/email.c
@@ -58,19 +58,19 @@ 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(_("(email) Cannot open file %s\n"),wger);
+               debuga(_("(email) Cannot open file %s: %s\n"),wger,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        snprintf(top1,sizeof(top1),"%s/top",dirname);
        if((fp_top1=fopen(top1,"w"))==NULL) {
-               debuga(_("(email) Cannot open file %s\n"),top1);
+               debuga(_("(email) Cannot open file %s: %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        snprintf(top2,sizeof(top2),"%s/top.tmp",dirname);
        if((fp_top2=fopen(top2,"w"))==NULL) {
-               debuga(_("(email) Cannot open file %s\n"),top2);
+               debuga(_("(email) Cannot open file %s: %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -148,13 +148,13 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
        }
 
        if((fp_top1=fopen(top1,"r"))==NULL) {
-               debuga(_("(email) Cannot open file %s\n"),top1);
+               debuga(_("(email) 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(_("(email) Cannot open file %s\n"),top3);
+               debuga(_("(email) Cannot open file %s: %s\n"),top3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -266,7 +266,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 
        if(strcmp(email,"stdout") == 0) {
                if((fp_top3=fopen(top3,"r"))==NULL) {
-                       debuga(_("(email) Cannot open file %s\n"),top3);
+                       debuga(_("(email) Cannot open file %s: %s\n"),top3,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
index 0c01054b28679051c68c99032e8b141ac93f4003..ca479ab577205e5ba256d9bee143049b279b9285 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -200,7 +200,7 @@ void gethexclude(const char *hexfile, int debug)
                debuga(_("Loading exclude host file from: %s\n"),hexfile);
 
        if ((fp_ex = fopen(hexfile, "r")) == NULL) {
-               debuga(_("(gethexclude) Cannot open file %s - %s\n"),hexfile,strerror(errno));
+               debuga(_("(gethexclude) Cannot open file %s: %s\n"),hexfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -314,7 +314,7 @@ void getuexclude(const char *uexfile, int debug)
                debuga(_("Loading exclude file from: %s\n"),uexfile);
 
        if ((fp_ex = fopen(uexfile, "r")) == NULL) {
-               debuga(_("(gethexclude) Cannot open file %s - %s\n"),uexfile,strerror(errno));
+               debuga(_("(gethexclude) Cannot open file %s: %s\n"),uexfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 5dd097dae5b53b6fc51d80b36a6e2dafbbcfadcd..48ea14297b6edb9c6e366591e777a189e0c9b062 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -618,7 +618,7 @@ static void greport_plot(const struct userinfostruct *uinfo,struct PlotStruct *p
                exit(EXIT_FAILURE);
        }
        if((pngout=fopen(graph,"wb"))==NULL) {
-               debuga(_("(grepday) Cannot open log file %s\n"),graph);
+               debuga(_("(grepday) Cannot open log file %s: %s\n"),graph,strerror(errno));
                exit(EXIT_FAILURE);
        }
        gdImagePng(gdata.im, pngout);
@@ -689,7 +689,7 @@ void greport_day(const struct userinfostruct *uinfo)
        }
 
        if((fp_in=fopen(wdirname,"r"))==NULL) {
-               debuga(_("(grepday) Cannot open log file %s\n"),wdirname);
+               debuga(_("(grepday) Cannot open log file %s: %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -735,7 +735,7 @@ void greport_day(const struct userinfostruct *uinfo)
                exit(EXIT_FAILURE);
        }
        if ((fp_ou=fopen(wdirname,"wt"))==NULL) {
-               debuga(_("(grepday) Cannot open output file %s\n"),wdirname);
+               debuga(_("(grepday) Cannot open output file %s: %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
        write_html_head(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Graph report"),HTML_JS_NONE);
diff --git a/html.c b/html.c
index 751fdbc5297b9e3fa3d2bb3a27642102a727c074..55451173a3ae6717cb2ac27f016265d98f4bb570 100644 (file)
--- a/html.c
+++ b/html.c
@@ -107,7 +107,7 @@ void htmlrel(void)
                }
                if ((fp_in = fopen(arqin, "r")) == 0){
                        if (uinfo->no_report) continue;
-                       debuga(_("(html3) Cannot open file %s\n"),arqin);
+                       debuga(_("(html3) Cannot open file %s: %s\n"),arqin,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
@@ -174,7 +174,7 @@ void htmlrel(void)
                rewind(fp_in);
 
                if ((fp_ou = fopen(arqou, "w")) == 0){
-                       debuga(_("(html5) Cannot open file %s\n"),arqou);
+                       debuga(_("(html5) Cannot open file %s: %s\n"),arqou,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
@@ -337,12 +337,12 @@ void htmlrel(void)
                                }
 
                                if ((fp_ip = fopen(arqip, "r")) == 0){
-                                       debuga(_("(html6) Cannot open file %s\n"),arqip);
+                                       debuga(_("(html6) Cannot open file %s: %s\n"),arqip,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
 
                                if ((fp_ip2 = MY_FOPEN(tmp2, "a")) == 0){
-                                       debuga(_("(html7) Cannot open file %s\n"),tmp2);
+                                       debuga(_("(html7) Cannot open file %s: %s\n"),tmp2,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
 
@@ -396,7 +396,7 @@ void htmlrel(void)
                                }
 
                                if ((fp_ip = MY_FOPEN(tmp3, "r")) == 0) {
-                                       debuga(_("(html8) Cannot open file %s\n"),tmp3);
+                                       debuga(_("(html8) Cannot open file %s: %s\n"),tmp3,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
 
@@ -530,7 +530,7 @@ void htmlrel(void)
                                limit_flag=0;
                                if(access(PerUserLimitFile, R_OK) == 0) {
                                        if((fp_usr = fopen(PerUserLimitFile, "r")) == 0) {
-                                               debuga(_("(html9) Cannot open file %s\n"),PerUserLimitFile);
+                                               debuga(_("(html9) Cannot open file %s: %s\n"),PerUserLimitFile,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
                                        while(fgets(tmp6,sizeof(tmp6),fp_usr)!=NULL) {
@@ -545,7 +545,7 @@ void htmlrel(void)
 
                                if(!limit_flag) {
                                        if((fp_usr = fopen(PerUserLimitFile, "a")) == 0) {
-                                               debuga(_("(html10) Cannot open file %s\n"),PerUserLimitFile);
+                                               debuga(_("(html10) Cannot open file %s: %s\n"),PerUserLimitFile,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
                                        fprintf(fp_usr,"%s\n",uinfo->label);
diff --git a/index.c b/index.c
index 5b2c35e8bcfb650fb18752a21d0a2fae928a0e81..6b306e295f92d173bfc2597afd61a1ebbd3d15dd 100644 (file)
--- a/index.c
+++ b/index.c
@@ -140,7 +140,7 @@ static void make_date_index(void)
        order=(strcmp(IndexSortOrder,"A") == 0) ? 1 : -1;
 
        if((fp_ou=fopen(yearindex,"w"))==NULL) {
-               debuga(_("(index) Cannot open file %s - %s\n"),yearindex,strerror(errno));
+               debuga(_("(index) Cannot open file %s: %s\n"),yearindex,strerror(errno));
                exit(EXIT_FAILURE);
        }
        write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nyears),HTML_JS_NONE);
@@ -192,7 +192,7 @@ static void make_date_index(void)
                closedir(dirp2);
                sprintf(monthindex,"%s/index.html",yeardir);
                if((fp_ou2=fopen(monthindex,"w"))==NULL) {
-                       debuga(_("(index) Cannot open file %s - %s\n"),monthindex,strerror(errno));
+                       debuga(_("(index) Cannot open file %s: %s\n"),monthindex,strerror(errno));
                        exit(EXIT_FAILURE);
                }
                snprintf(title,sizeof(title),ngettext("SARG: report for %04d","SARG: reports for %04d",nmonths),year);
@@ -253,7 +253,7 @@ static void make_date_index(void)
                        closedir(dirp3);
                        sprintf(dayindex,"%s/index.html",monthdir);
                        if((fp_ou3=fopen(dayindex,"w"))==NULL) {
-                               debuga(_("(index) Cannot open file %s - %s\n"),dayindex,strerror(errno));
+                               debuga(_("(index) Cannot open file %s: %s\n"),dayindex,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                        snprintf(title,sizeof(title),ngettext("SARG: report for %04d/%02d","SARG: reports for %04d/%02d",ndays),year,month);
@@ -421,7 +421,7 @@ static void make_file_index(void)
        closedir( dirp );
 
        if((fp_ou=fopen(wdir,"w"))==NULL) {
-               debuga(_("(index) Cannot open file %s\n"),wdir);
+               debuga(_("(index) Cannot open file %s: %s\n"),wdir,strerror(errno));
                exit(EXIT_FAILURE);
        }
        write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nsort),HTML_JS_SORTTABLE);
index 1db419093c1240c08f657b4e9c22f08ab8e73c17..cb36c5410adcd98301c43dbef1ba224e815134ee 100644 (file)
--- a/lastlog.c
+++ b/lastlog.c
@@ -48,7 +48,7 @@ void mklastlog(const char *outdir)
 
        snprintf(temp,sizeof(temp),"%slastlog1",outdir);
        if((fp_ou=fopen(temp,"w"))==NULL) {
-               debuga(_("(lastlog) Cannot open temporary file %s\n"),temp);
+               debuga(_("(lastlog) Cannot open temporary file %s: %s\n"),temp,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -103,7 +103,7 @@ void mklastlog(const char *outdir)
 
        snprintf(temp,sizeof(temp),"%slastlog",outdir);
        if((fp_in=fopen(temp,"r"))==NULL) {
-               debuga(_("(lastlog) Cannot open temporary file %s\n"),temp);
+               debuga(_("(lastlog) Cannot open temporary file %s: %s\n"),temp,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 5d5b040468f3d6e65f4530883e56e5fc5d878c24..5cee0a462c4c1a0ffc37ba4a6b49cd8044a8e2c7 100644 (file)
--- a/readlog.c
+++ b/readlog.c
@@ -311,7 +311,7 @@ int ReadLogFile(struct ReadLogDataStruct *Filter)
                                        exit(EXIT_FAILURE);
                                }
                                if((fp_log=MY_FOPEN(arq_log,"w"))==NULL) {
-                                       debuga(_("(log) Cannot open log file: %s - %s\n"),arq_log,strerror(errno));
+                                       debuga(_("(log) Cannot open log file %s: %s\n"),arq_log,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
                                fputs("*** SARG Log ***\n",fp_log);
@@ -519,7 +519,7 @@ int ReadLogFile(struct ReadLogDataStruct *Filter)
                                        exit(EXIT_FAILURE);
                                }
                                if ((ufile->file = MY_FOPEN (tmp3, "a")) == NULL) {
-                                       debuga(_("(log) Cannot open temporary file: %s - %s\n"), tmp3, strerror(errno));
+                                       debuga(_("(log) Cannot open temporary file %s: %s\n"), tmp3, strerror(errno));
                                        exit (1);
                                }
                        }
index 80a67b482ea0469331293ee12714f19c97cb1ea8..c7e0b678a74f7ab6e5a31c10312b83e8e389fbb6 100644 (file)
@@ -264,7 +264,7 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil)
        }
 
        if ((fp_in=fopen(wentp,"r"))==NULL) {
-               debuga(_("(squidguard) Cannot open log file %s\n"),wentp);
+               debuga(_("(squidguard) Cannot open log file %s: %s\n"),wentp,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -306,7 +306,7 @@ void redirector_log(void)
 
        snprintf(guard_in,sizeof(guard_in),"%s/redirector.int_unsort",tmp);
        if((fp_ou=fopen(guard_in,"w"))==NULL) {
-               debuga(_("(squidguard) Cannot open log file %s\n"),guard_in);
+               debuga(_("(squidguard) Cannot open log file %s: %s\n"),guard_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -323,7 +323,7 @@ void redirector_log(void)
                }
 
                if((fp_guard=fopen(SquidGuardConf,"r"))==NULL) {
-                       debuga(_("(squidguard) Cannot open log file %s\n"),SquidGuardConf);
+                       debuga(_("(squidguard) Cannot open log file %s: %s\n"),SquidGuardConf,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
@@ -455,12 +455,12 @@ void redirector_report(void)
        snprintf(report,sizeof(report),"%s/redirector.html",outdirname);
 
        if((fp_in=fopen(redirector_sorted,"r"))==NULL) {
-               debuga(_("(squidguard) Cannot open log file %s\n"),redirector_sorted);
+               debuga(_("(squidguard) Cannot open log file %s: %s\n"),redirector_sorted,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=fopen(report,"w"))==NULL) {
-               debuga(_("(squidguard) Cannot open log file %s\n"),report);
+               debuga(_("(squidguard) Cannot open log file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 61985dd06162bdc8a2c981aea69cd1ce80cc8886..a220a7c79c4532f536767a9ea9543ec01faff78c 100644 (file)
--- a/repday.c
+++ b/repday.c
@@ -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);
        }
 
index 6798776a95fc70eaf0e63e88dea395f4fe3a3fb6..e46bc750ab7c1d68013595b648d0f02fba1b5043 100644 (file)
--- a/report.c
+++ b/report.c
@@ -100,7 +100,7 @@ void gerarel(void)
 
        snprintf(wdirname,sizeof(wdirname),"%s/sarg-general",outdirname);
        if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){
-               debuga(_("(report) Cannot open file %s\n"),wdirname);
+               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -124,7 +124,7 @@ void gerarel(void)
                        exit(EXIT_FAILURE);
                }
                if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){
-                       debuga(_("(report) Cannot open file %s\n"),tmp);
+                       debuga(_("(report) Cannot open file %s: %s\n"),tmp,strerror(errno));
                        exit(EXIT_FAILURE);
                }
                user=uinfo->filename;
@@ -247,7 +247,7 @@ void gerarel(void)
                                        url_to_file(accurl,siteind,sizeof(siteind));
                                        snprintf(arqtt,sizeof(arqtt),"%s/%s/tt%s-%s.html",outdirname,uinfo->filename,uinfo->filename,siteind);
                                        if ((fp_tt = fopen(arqtt, "w")) == 0) {
-                                               debuga(_("(report) Cannot open file %s\n"),arqtt);
+                                               debuga(_("(report) Cannot open file %s: %s\n"),arqtt,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
                                        ttopen=1;
@@ -434,7 +434,7 @@ static FILE *maketmp(const char *user, const char *dirname, int debug)
        }
 
        if((fp_ou=fopen(wdirname,"w"))==NULL){
-               debuga(_("(report) Cannot open file %s\n"),wdirname);
+               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -475,7 +475,7 @@ static void gravaporuser(const struct userinfostruct *uinfo, const char *dirname
        }
 
        if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
-               debuga(_("(report) Cannot open file %s\n"),wdirname);
+               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -759,7 +759,7 @@ static void grava_SmartFilter(const char *dirname, const char *user, const char
        }
 
        if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
-               debuga(_("(report) Cannot open file %s\n"),wdirname);
+               debuga(_("(report) Cannot open file %s: %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 58d195fef96448988db014e79c0c23f59da81e75..69b15c1a2c058f3ad2be41037328be17001eb57b 100644 (file)
@@ -71,13 +71,13 @@ void siteuser(void)
        }
 
        if((fp_in=fopen(general2,"r"))==NULL) {
-               debuga(_("(siteuser) Cannot open log file %s\n"),general2);
+               debuga(_("(siteuser) Cannot open log file %s: %s\n"),general2,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=fopen(report,"w"))==NULL) {
-               debuga(_("(siteuser) Cannot open log file %s\n"),report);
+               debuga(_("(siteuser) Cannot open log file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 4dd068bcd92d1ae5072a3b1a396f22b4fe34ead9..12c8c69f5ca8d78064414f4f3b807696a5a1ea06 100644 (file)
@@ -81,7 +81,7 @@ void smartfilter_report(void)
                exit(EXIT_FAILURE);
        }
        if((fp_in=fopen(smart_ou,"r"))==NULL) {
-               debuga(_("(smartfilter) Cannot open log file %s\n"),smart_ou);
+               debuga(_("(smartfilter) Cannot open log file %s: %s\n"),smart_ou,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
@@ -91,7 +91,7 @@ void smartfilter_report(void)
        }
 
        if((fp_ou=fopen(report,"w"))==NULL) {
-               debuga(_("(smartfilter) Cannot open log file %s\n"),report);
+               debuga(_("(smartfilter) Cannot open log file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -143,7 +143,7 @@ void smartfilter_report(void)
                                fclose(fp_user);
                        }
                        if ((fp_user = fopen(smartuser, "a")) == 0) {
-                               debuga(_("(smartfilter) Cannot open file %s\n"),smartuser);
+                               debuga(_("(smartfilter) Cannot open file %s: %s\n"),smartuser,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                        fuser=1;
index 4a1bd63c9d219810526f86cd8fad233421dd742f..5cd55ef5ab1abed0e3b9b4dafa6cf085fca9957c 100644 (file)
@@ -79,7 +79,7 @@ void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, cons
                arq="/var/log/squid/access.log";
 
        if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
-               debuga(_("(splitlog) Cannot open log file %s - %s\n"),arq,strerror(errno));
+               debuga(_("(splitlog) Cannot open log file %s: %s\n"),arq,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -119,7 +119,7 @@ void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, cons
                        a second time.
                        */
                        if ((fp_ou=MY_FOPEN(output_file,(tt>=min_tt && tt<=max_tt) ? "a" : "w"))==NULL) {
-                               debuga(_("(splitlog) Cannot open output log file %s - %s\n"),output_file,strerror(errno));
+                               debuga(_("(splitlog) Cannot open output log file %s: %s\n"),output_file,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                        if (tt<min_tt) min_tt=tt;
index 01ef7fdb0ec6fe32b89b42f5441d541891ca1a13..f57bdf35166c234b737d0c41c20ee23f578c8d63 100644 (file)
@@ -92,13 +92,13 @@ void topsites(void)
        }
 
        if((fp_in=fopen(general2,"r"))==NULL) {
-               debuga(_("(topsites) Cannot open log file %s\n"),general2);
+               debuga(_("(topsites) Cannot open log file %s: %s\n"),general2,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=fopen(general3,"w"))==NULL) {
-               debuga(_("(topsites) Cannot open log file %s\n"),general3);
+               debuga(_("(topsites) Cannot open log file %s: %s\n"),general3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -214,7 +214,7 @@ void topsites(void)
                exit(EXIT_FAILURE);
        }
        if((fp_in=fopen(sites,"r"))==NULL) {
-               debuga(_("(topsites) Cannot open log file %s\n"),sites);
+               debuga(_("(topsites) Cannot open log file %s: %s\n"),sites,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
@@ -225,7 +225,7 @@ void topsites(void)
        }
 
        if((fp_ou=fopen(report,"w"))==NULL) {
-               debuga(_("(topsites) Cannot open log file %s\n"),report);
+               debuga(_("(topsites) Cannot open log file %s: %s\n"),report,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 48b68b1ddb91a0500bfe96e4d21de427c5c01b63..2fa4c0578c70f58c206bb53de7c440c4d1b3ede6 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -43,7 +43,7 @@ static void set_total_users(int totuser)
 
        snprintf(tusr,sizeof(tusr),"%s/sarg-users",outdirname);
        if((fp_ou=fopen(tusr,"w"))==NULL) {
-               debuga(_("(topuser) Cannot open file %s\n"),tusr);
+               debuga(_("(topuser) Cannot open file %s: %s\n"),tusr,strerror(errno));
                exit(EXIT_FAILURE);
        }
        fprintf(fp_ou,"%d\n",totuser);
@@ -85,13 +85,13 @@ void topuser(void)
        ntopuser = 0;
        snprintf(wger,sizeof(wger),"%s/sarg-general",outdirname);
        if((fp_in=fopen(wger,"r"))==NULL) {
-               debuga(_("(topuser) Cannot open file %s\n"),wger);
+               debuga(_("(topuser) Cannot open file %s: %s\n"),wger,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        snprintf(top2,sizeof(top2),"%s/top.tmp",outdirname);
        if((fp_top2=fopen(top2,"w"))==NULL) {
-               debuga(_("(topuser) Cannot open file %s\n"),top2);
+               debuga(_("(topuser) Cannot open file %s: %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -198,7 +198,7 @@ void topuser(void)
        }
 
        if((fp_top1=fopen(top1,"r"))==NULL) {
-               debuga(_("(topuser) Cannot open file %s\n"),top1);
+               debuga(_("(topuser) Cannot open file %s: %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -209,7 +209,7 @@ void topuser(void)
 
        snprintf(top3,sizeof(top3),"%s/index.html",outdirname);
        if((fp_top3=fopen(top3,"w"))==NULL) {
-               debuga(_("(topuser) Cannot open file %s\n"),top3);
+               debuga(_("(topuser) Cannot open file %s: %s\n"),top3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 8b5f93bccde780ee9db2f245e8bf8a0408388d15..223a8e0afccae2c1bc655b639dda94c23e8180a3 100644 (file)
--- a/totday.c
+++ b/totday.c
@@ -155,7 +155,7 @@ void day_totalize(DayObject ddata,const char *tmp, const struct userinfostruct *
        }
 
        if((fp_ou=fopen(arqout,"w"))==NULL) {
-               debuga(_("(totday) Cannot open log file %s\n"),arqout);
+               debuga(_("(totday) Cannot open log file %s: %s\n"),arqout,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 4770d5ca2d99eb37f742e8c6b5712b655457e8b8..0fcd6dff7a451dc1a90c57eb1b03725b2104182a 100644 (file)
@@ -62,12 +62,12 @@ void useragent(void)
        sprintf(tmp2,"%s/squagent.int_log",tmp);
 
        if((fp_in=fopen(UserAgentLog,"r"))==NULL) {
-               debuga(_("(useragent) Cannot open file %s\n"),UserAgentLog);
+               debuga(_("(useragent) Cannot open file %s: %s\n"),UserAgentLog,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
        if((fp_ou=fopen(tmp3,"w"))==NULL) {
-               debuga(_("(useragent) Cannot open file %s\n"),tmp3);
+               debuga(_("(useragent) Cannot open file %s: %s\n"),tmp3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -143,7 +143,7 @@ void useragent(void)
                exit(EXIT_FAILURE);
        }
        if((fp_in=fopen(tmp2,"r"))==NULL) {
-               debuga(_("(useragent) Cannot open file %s\n"),tmp2);
+               debuga(_("(useragent) Cannot open file %s: %s\n"),tmp2,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
@@ -155,7 +155,7 @@ void useragent(void)
 
        snprintf(hfile,sizeof(hfile),"%s/useragent.html", outdirname);
        if((fp_ht=fopen(hfile,"w"))==NULL) {
-               debuga(_("(useragent) Cannot open file %s\n"),hfile);
+               debuga(_("(useragent) Cannot open file %s: %s\n"),hfile,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -226,7 +226,7 @@ void useragent(void)
                exit(EXIT_FAILURE);
        }
        if((fp_in=fopen(tmp3,"r"))==NULL) {
-               debuga(_("(useragent) Cannot open file %s\n"),tmp3);
+               debuga(_("(useragent) Cannot open file %s: %s\n"),tmp3,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
@@ -237,7 +237,7 @@ void useragent(void)
        }
 
        if((fp_ou=fopen(tmp2,"w"))==NULL) {
-               debuga(_("(useragent) Cannot open file %s\n"),tmp2);
+               debuga(_("(useragent) Cannot open file %s: %s\n"),tmp2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -295,7 +295,7 @@ void useragent(void)
                exit(EXIT_FAILURE);
        }
        if((fp_in=fopen(tmp3,"r"))==NULL) {
-               debuga(_("(useragent) Cannot open file %s\n"),tmp3);
+               debuga(_("(useragent) Cannot open file %s: %s\n"),tmp3,strerror(errno));
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
index 31eddd5f8efbd05ba1d7ffb377d7cc4817f065ee..5bf9b2fbda42a42af02e389a99c85abcae988eec 100644 (file)
--- a/usertab.c
+++ b/usertab.c
@@ -61,7 +61,7 @@ static void init_file_usertab(const char *UserTabFile)
        int z1, z2;
 
        if((fp_usr=fopen(UserTabFile,"r"))==NULL) {
-               debuga(_("(usertab) Cannot open file %s - %s\n"),UserTabFile,strerror(errno));
+               debuga(_("(usertab) Cannot open file %s: %s\n"),UserTabFile,strerror(errno));
                exit(EXIT_FAILURE);
        }
        if (fseek(fp_usr, 0, SEEK_END)==-1) {
diff --git a/util.c b/util.c
index ac12246eecf19efc9de1ef871d767e410445afb4..ba111013a0119645d98bbd19d80b920075918c40 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1188,7 +1188,7 @@ int vrfydir(const struct periodstruct *per1, const char *addr, const char *site,
 
        sprintf(wdir,"%s/sarg-date",outdirname);
        if ((fp_ou = fopen(wdir, "wt")) == 0) {
-               debuga(_("cannot open %s for writing\n"),wdir);
+               debuga(_("cannot open %s for writing: %s\n"),wdir,strerror(errno));
                perror("SARG:");
                exit(EXIT_FAILURE);
        }
@@ -1475,7 +1475,7 @@ void removetmp(const char *outdir)
                exit(EXIT_FAILURE);
        }
        if((fp_gen=fopen(filename,"w"))==NULL){
-               debuga(_("(removetmp) Cannot open file %s\n"),filename);
+               debuga(_("(removetmp) Cannot open file %s: %s\n"),filename,strerror(errno));
                exit(EXIT_FAILURE);
        }
        totalger(fp_gen,filename);
@@ -1497,7 +1497,7 @@ void load_excludecodes(const char *ExcludeCodes)
                return;
 
        if((fp_in=fopen(ExcludeCodes,"r"))==NULL) {
-               debuga(_("(util) Cannot open file %s (exclude_codes)\n"),ExcludeCodes);
+               debuga(_("(util) Cannot open file %s (exclude_codes): %s\n"),ExcludeCodes,strerror(errno));
                exit(EXIT_FAILURE);
        }