From: Frederic Marchal Date: Mon, 22 Dec 2014 12:29:08 +0000 (+0100) Subject: Produce less messages to be translated X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b06d570258b213035ec255ace895ddbe38c64de;p=thirdparty%2Fsarg.git Produce less messages to be translated There are too many redundant messages to translate. It makes the translator task tedious. This change removes the source particle from the message. It makes several messages identical. The source particle is displayed in a non translatable string. Some more messages have been made identical across the sources. --- diff --git a/auth.c b/auth.c index af3dd23..5bd23da 100644 --- 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)); + debugapos("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)); + debugapos("auth",_("Cannot open file \"%s\": %s\n"),AuthUserTemplateFile,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/authfail.c b/authfail.c index 685c64c..9d14ef0 100644 --- a/authfail.c +++ b/authfail.c @@ -89,7 +89,7 @@ void authfail_report(void) exit(EXIT_FAILURE); } if((fp_in=MY_FOPEN(authfail_in,"r"))==NULL) { - debuga(_("(authfail) Cannot open file %s\n"),authfail_in); + debugapos("authfail",_("Cannot open file \"%s\": %s\n"),authfail_in,strerror(errno)); debuga(_("sort command: %s\n"),csort); exit(EXIT_FAILURE); } @@ -99,7 +99,7 @@ void authfail_report(void) } if((fp_ou=MY_FOPEN(report,"w"))==NULL) { - debuga(_("(authfail) Cannot open file %s\n"),report); + debugapos("authfail",_("Cannot open file \"%s\": %s\n"),report,strerror(errno)); exit(EXIT_FAILURE); } @@ -204,7 +204,7 @@ void authfail_report(void) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in file %s\n"),report); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),report,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),report,strerror(errno)); if (!KeepTempLog && unlink(authfail_in)) { debuga(_("Cannot delete \"%s\": %s\n"),authfail_in,strerror(errno)); diff --git a/convlog.c b/convlog.c index ee72ccc..e05204a 100644 --- a/convlog.c +++ b/convlog.c @@ -45,7 +45,7 @@ void convlog(const char *arq, char *df, int dfrom, int duntil) if (arq[0]=='-' && arq[1]=='\0') { fp_in=stdin; } else if((fp_in=MY_FOPEN(arq,"r"))==NULL) { - debuga(_("(convlog) Cannot open log file %s - %s\n"),arq,strerror(errno)); + debugapos("convlog",_("Cannot open file \"%s\": %s\n"),arq,strerror(errno)); exit(EXIT_FAILURE); } @@ -79,6 +79,6 @@ void convlog(const char *arq, char *df, int dfrom, int duntil) longline_destroy(&line); if (fp_in!=stdin && fclose(fp_in)==EOF) { - debuga(_("Failed to close file %s - %s\n"),arq,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),arq,strerror(errno)); } } diff --git a/dansguardian_log.c b/dansguardian_log.c index ea3c127..d3786d1 100644 --- a/dansguardian_log.c +++ b/dansguardian_log.c @@ -58,12 +58,12 @@ void dansguardian_log(void) } if((fp_guard=fopen(DansGuardianConf,"r"))==NULL) { - debuga(_("(dansguardian) Cannot open log file: %s\n"),DansGuardianConf); + debugapos("dansguardian",_("Cannot open 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); + debugapos("dansguardian",_("Cannot open 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); + debugapos("dansguardian",_("Cannot open file \"%s\": %s\n"),loglocation,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/dansguardian_report.c b/dansguardian_report.c index e98d892..e8a62d2 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -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); + debugapos("dansguardian_report",_("Cannot open 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); + debugapos("dansguardian_report",_("Cannot open file \"%s\": %s\n"),report,strerror(errno)); exit(EXIT_FAILURE); } @@ -168,7 +168,7 @@ void dansguardian_report(void) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in file %s\n"),report); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),report,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),report,strerror(errno)); if (!KeepTempLog && unlink(dansguardian_in)) { debuga(_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno)); diff --git a/datafile.c b/datafile.c index 879febc..6d20b43 100644 --- a/datafile.c +++ b/datafile.c @@ -84,12 +84,12 @@ void data_file(char *tmp) sort_users_log(tmp,debug,uinfo); if (snprintf(tmp3,sizeof(tmp3),"%s/%s.user_log",tmp,uinfo->filename)>=sizeof(tmp3)) { - debuga(_("(datafile) directory path too long: %s/%s.user_log\n"),tmp,uinfo->filename); + debugapos("datafile",_("Directory path too long: %s/%s.user_log\n"),tmp,uinfo->filename); exit(EXIT_FAILURE); } if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){ - debuga(_("(datafile) Cannot open file %s\n"),tmp3); + debugapos("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); + debugapos("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); diff --git a/denied.c b/denied.c index e5dbae1..40fabad 100644 --- a/denied.c +++ b/denied.c @@ -73,12 +73,12 @@ void gen_denied_report(void) sprintf(report,"%s/denied.html",outdirname); if((fp_in=MY_FOPEN(denied_in,"r"))==NULL) { - debuga(_("(denied) Cannot open log file %s\n"),denied_in); + debugapos("denied",_("Cannot open file \"%s\": %s\n"),denied_in,strerror(errno)); exit(EXIT_FAILURE); } if((fp_ou=MY_FOPEN(report,"w"))==NULL) { - debuga(_("(denied) Cannot open log file %s\n"),report); + debugapos("denied",_("Cannot open file \"%s\": %s\n"),report,strerror(errno)); exit(EXIT_FAILURE); } @@ -175,7 +175,7 @@ void gen_denied_report(void) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in file %s\n"),report); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),report,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),report,strerror(errno)); if (!KeepTempLog && unlink(denied_in)==-1) debuga(_("Cannot delete \"%s\": %s\n"),denied_in,strerror(errno)); diff --git a/download.c b/download.c index c5c5096..3987b50 100644 --- a/download.c +++ b/download.c @@ -130,12 +130,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); + debugapos("download",_("Cannot open 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); + debugapos("download",_("Cannot open file \"%s\": %s\n"),report,strerror(errno)); exit(EXIT_FAILURE); } @@ -228,7 +228,7 @@ void download_report(void) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in file %s\n"),report); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),report,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),report,strerror(errno)); if (!KeepTempLog && unlink(report_in)) { debuga(_("Cannot delete \"%s\": %s\n"),report_in,strerror(errno)); diff --git a/email.c b/email.c index eb42b62..ea50806 100644 --- 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); + debugapos("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); + debugapos("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); + debugapos("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); + debugapos("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); + debugapos("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); + debugapos("email",_("Cannot open file \"%s\": %s\n"),top3,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/exclude.c b/exclude.c index e627454..d1cb038 100644 --- a/exclude.c +++ b/exclude.c @@ -193,14 +193,14 @@ void gethexclude(const char *hexfile, int debug) const char *next; if(access(hexfile, R_OK) != 0) { - debuga(_("Cannot open exclude_hosts file: %s - %s\n"),hexfile,strerror(errno)); + debuga(_("Cannot open file \"%s\": %s\n"),hexfile,strerror(errno)); exit(EXIT_FAILURE); } if(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)); + debugapos("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)); + debugapos("gethexclude",_("Cannot open file \"%s\": %s\n"),uexfile,strerror(errno)); exit(EXIT_FAILURE); } @@ -329,7 +329,7 @@ void getuexclude(const char *uexfile, int debug) } nreg += 11; if (fseek(fp_ex, 0, SEEK_SET)==-1) { - debuga(_("Failed to rewind the excluded users file %s: %s\n"),uexfile,strerror(errno)); + debuga(_("Failed to rewind file \"%s\": %s\n"),uexfile,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/getconf.c b/getconf.c index 79c7130..2b9aaaf 100644 --- a/getconf.c +++ b/getconf.c @@ -784,7 +784,7 @@ void getconf(void) debuga(_("Loading configuration from %s\n"),ConfigFile); if ((fp_in = fopen(ConfigFile, "r")) == NULL) { - debuga(_("(getconf) Cannot open file %s\n"),ConfigFile); + debugapos("getconf",_("Cannot open file \"%s\": %s\n"),ConfigFile,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/grepday.c b/grepday.c index b0d8908..c9ed6e5 100644 --- a/grepday.c +++ b/grepday.c @@ -154,7 +154,10 @@ static void Sarg_gdImageStringFT (struct GraphDataStruct *gdata, int fg, char *f str = string; sstr = sstring; if (iconv (localtoutf, (ICONV_CONST char **)&str, &slen, &sstr, &sslen)==-1) { - debuga(_("(grepday) iconv failed to convert string \"%s\" from %s to UTF-8 - %s\n"),string,CharSet,strerror(errno)); + /* TRANSLATORS: First %s is the string that failed to convert. Second %s is the input + * character encoding. Last %s is the reason for the failure. + */ + debugapos("grepday",_("iconv failed to convert string \"%s\" from %s to UTF-8: %s\n"),string,CharSet,strerror(errno)); sstring=(char *)string; //show something sensible on the graph } } else { @@ -614,7 +617,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); + debugapos("grepday",_("Cannot open file \"%s\": %s\n"),graph,strerror(errno)); exit(EXIT_FAILURE); } gdImagePng(gdata.im, pngout); @@ -630,25 +633,33 @@ void greport_prepare(void) { #ifdef HAVE_GD if (!Graphs) { - if (debugz) - debugaz(_("Graphs disabled as requested in %s\n"),ConfigFile); + if (debugz) { + /* TRANSLATORS: %s is the name of the configuration file providing + * the graph option. + */ + debugaz(_("Graphs disabled as requested in \"%s\"\n"),ConfigFile); + } return; } if (GraphFont[0]=='\0') { - if (debugz) - debugaz(_("Graphs disabled as no font names were provided in %s\n"),ConfigFile); + if (debugz) { + /* TRANSLATORS: %s is the name of the configuration file providing + * the graph option. + */ + debugaz(_("Graphs disabled as no font names were provided in \"%s\"\n"),ConfigFile); + } return; } if(access(GraphFont, R_OK) != 0) { - debuga(_("(grepday) Fontname %s not found\n"),GraphFont); + debugapos("grepday",_("Fontname \"%s\" not found\n"),GraphFont); exit(EXIT_FAILURE); } #ifdef USE_ICONV localtoutf = iconv_open ("UTF-8", CharSet); if (localtoutf==(iconv_t)-1) { - debuga(_("(grepday) iconv cannot convert from %s to UTF-8 - %s\n"),CharSet,strerror(errno)); + debugapos("grepday",_("iconv cannot convert from %s to UTF-8: %s\n"),CharSet,strerror(errno)); } #endif @@ -684,7 +695,7 @@ void greport_day(const struct userinfostruct *uinfo) } if((fp_in=fopen(wdirname,"r"))==NULL) { - debuga(_("(grepday) Cannot open log file %s\n"),wdirname); + debugapos("grepday",_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno)); exit(EXIT_FAILURE); } @@ -729,7 +740,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); + debugapos("grepday",_("Cannot open 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); @@ -766,7 +777,7 @@ void greport_day(const struct userinfostruct *uinfo) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in file %s\n"),wdirname); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),wdirname,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),wdirname,strerror(errno)); #endif //HAVE_GD return; diff --git a/html.c b/html.c index 5f7a4f2..ed6aba9 100644 --- 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); + debugapos("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); + debugapos("html5",_("Cannot open file \"%s\": %s\n"),arqou,strerror(errno)); exit(EXIT_FAILURE); } @@ -337,17 +337,17 @@ void htmlrel(void) } if ((fp_ip = fopen(arqip, "r")) == 0){ - debuga(_("(html6) Cannot open file %s\n"),arqip); + debugapos("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); + debugapos("html7",_("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(_("Not enough memory to read file \"%s\"\n"),arqip); exit(EXIT_FAILURE); } while((buf=longline_read(fp_ip,line1))!=NULL) { @@ -396,7 +396,7 @@ void htmlrel(void) } if ((fp_ip = MY_FOPEN(tmp3, "r")) == 0) { - debuga(_("(html8) Cannot open file %s\n"),tmp3); + debugapos("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); + debugapos("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); + debugapos("html10",_("Cannot open file \"%s\": %s\n"),PerUserLimitFile,strerror(errno)); exit(EXIT_FAILURE); } fprintf(fp_usr,"%s\n",uinfo->ip); @@ -583,9 +583,9 @@ void htmlrel(void) fputs("\n",fp_ou); if (write_html_trailer(fp_ou)<0) - debuga(_("Write error in file %s\n"),arqou); + debuga(_("Write error in file \"%s\"\n"),arqou); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),arqou,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),arqou,strerror(errno)); htaccess(uinfo); } diff --git a/include/defs.h b/include/defs.h index e991750..3828cff 100755 --- a/include/defs.h +++ b/include/defs.h @@ -274,6 +274,7 @@ void output_html_string(FILE *fp_ou,const char *str,int maxlen); void output_html_url(FILE *fp_ou,const char *url); void output_html_link(FILE *fp_ou,const char *url,int maxlen); void debuga(const char *msg,...) __attribute__((format(printf,1,2))); +void debugapos(const char *pos,const char *msg,...); void debugaz(const char *msg,...) __attribute__((format(printf,1,2))); void my_lltoa(unsigned long long int n, char *s, int ssize, int len); char *get_size(const char *path, const char *file); diff --git a/index.c b/index.c index 19ec04f..04275c3 100644 --- a/index.c +++ b/index.c @@ -55,7 +55,7 @@ void make_index(void) // convert any old report hierarchy if ((dirp = opendir(outdir)) == NULL) { - debuga(_("Failed to open directory %s - %s\n"),outdir,strerror(errno)); + debuga(_("Failed to open directory \"%s\": %s\n"),outdir,strerror(errno)); exit(EXIT_FAILURE); } while ((direntp = readdir( dirp )) != NULL) { @@ -109,7 +109,7 @@ static void make_date_index(void) nyears=0; if ((dirp = opendir(outdir)) == NULL) { - debuga(_("Failed to open directory %s - %s\n"),outdir,strerror(errno)); + debuga(_("Failed to open directory \"%s\": %s\n"),outdir,strerror(errno)); exit(EXIT_FAILURE); } while ((direntp = readdir( dirp )) != NULL) { @@ -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)); + debugapos("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); @@ -164,7 +164,7 @@ static void make_date_index(void) // Year dir nmonths=0; if ((dirp2 = opendir(yeardir)) == NULL) { - debuga(_("Failed to open directory %s - %s\n"),yeardir,strerror(errno)); + debuga(_("Failed to open directory \"%s\": %s\n"),yeardir,strerror(errno)); exit(EXIT_FAILURE); } while ((direntp2 = readdir( dirp2 )) != NULL) { @@ -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)); + debugapos("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); @@ -225,7 +225,7 @@ static void make_date_index(void) // month dir ndays=0; if ((dirp3 = opendir(monthdir)) == NULL) { - debuga(_("Failed to open directory %s - %s\n"),monthdir,strerror(errno)); + debuga(_("Cannot open directory \"%s\": %s\n"),monthdir,strerror(errno)); exit(EXIT_FAILURE); } while ((direntp3 = readdir( dirp3 )) != NULL) { @@ -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)); + debugapos("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); @@ -279,20 +279,20 @@ static void make_date_index(void) if (write_html_trailer(fp_ou3)<0) debuga(_("Write error in the index %s\n"),dayindex); if (fclose(fp_ou3)==EOF) - debuga(_("Failed to close the index file %s - %s\n"),dayindex,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),dayindex,strerror(errno)); } fputs("\n",fp_ou2); if (write_html_trailer(fp_ou2)<0) debuga(_("Write error in the index %s\n"),monthindex); if (fclose(fp_ou2)==EOF) - debuga(_("Failed to close the index file %s - %s\n"),monthindex,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),monthindex,strerror(errno)); } fputs("\n",fp_ou); if (write_html_trailer(fp_ou)<0) debuga(_("Write error in the index %s\n"),yearindex); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close the index file %s - %s\n"),yearindex,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),yearindex,strerror(errno)); } static void make_file_index(void) @@ -327,7 +327,7 @@ static void make_file_index(void) order=(strcmp(IndexSortOrder,"A") == 0) ? 1 : -1; if ((dirp = opendir(outdir)) == NULL) { - debuga(_("Failed to open directory %s - %s\n"),outdir,strerror(errno)); + debuga(_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno)); exit(EXIT_FAILURE); } @@ -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); + debugapos("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); @@ -455,7 +455,7 @@ static void make_file_index(void) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in the index %s\n"),wdir); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close the index file %s - %s\n"),wdir,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),wdir,strerror(errno)); if (sortlist) { for (i=0 ; id_name,direntp3->d_name); if(rename(olddir,newdir)) { - debuga(_("(index) rename error from \"%s\" to \"%s\" - %s\n"),olddir,newdir,strerror(errno)); + debugapos("index",_("Error renaming \"%s\" into \"%s\": %s\n"),olddir,newdir,strerror(errno)); exit(EXIT_FAILURE); } } diff --git a/indexonly.c b/indexonly.c index 5e45643..693865f 100644 --- a/indexonly.c +++ b/indexonly.c @@ -35,7 +35,7 @@ void index_only(const char *dirname,int debug) char remove[MAXLEN]; if ((dirp = opendir(dirname)) == NULL) { - debuga(_("Failed to open directory %s - %s\n"),dirname,strerror(errno)); + debuga(_("Cannot open directory \"%s\": %s\n"),dirname,strerror(errno)); exit(EXIT_FAILURE); } while ( (direntp = readdir( dirp )) != NULL ){ diff --git a/lastlog.c b/lastlog.c index 5d453e6..b994c91 100644 --- a/lastlog.c +++ b/lastlog.c @@ -51,12 +51,12 @@ void mklastlog(const char *outdir) exit(EXIT_FAILURE); } if((fp_ou=fopen(temp,"w"))==NULL) { - debuga(_("(lastlog) Cannot open temporary file %s\n"),temp); + debugapos("lastlog",_("Cannot open file \"%s\": %s\n"),temp,strerror(errno)); exit(EXIT_FAILURE); } if ((dirp = opendir(outdir)) == NULL) { - debuga(_("Failed to open directory %s - %s\n"),outdir,strerror(errno)); + debuga(_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno)); exit(EXIT_FAILURE); } while ((direntp = readdir( dirp )) != NULL ){ @@ -65,7 +65,7 @@ void mklastlog(const char *outdir) snprintf(warea,sizeof(warea),"%s%s",outdir,direntp->d_name); if (stat(warea,&statb) == -1) { - debuga(_("Failed to get the creation time of %s\n"),warea); + debuga(_("Failed to get the creation time of \"%s\": %s\n"),warea,strerror(errno)); continue; } t=statb.st_ctime; @@ -111,7 +111,7 @@ void mklastlog(const char *outdir) snprintf(temp,sizeof(temp),"%s/lastlog",tmp); if((fp_in=fopen(temp,"r"))==NULL) { - debuga(_("(lastlog) Cannot open temporary file %s\n"),temp); + debugapos("lastlog",_("Cannot open file \"%s\": %s\n"),temp,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/log.c b/log.c index c5d5197..3d12704 100644 --- a/log.c +++ b/log.c @@ -797,14 +797,14 @@ int main(int argc,char *argv[]) if(DataFile[0]=='\0') { if((ReportType & REPORT_TYPE_DENIED) != 0) { if((fp_denied=MY_FOPEN(denied_unsort,"w"))==NULL) { - debuga(_("(log) Cannot open file: %s - %s\n"),denied_unsort,strerror(errno)); + debugapos("log",_("Cannot open file \"%s\": %s\n"),denied_unsort,strerror(errno)); exit(EXIT_FAILURE); } } if((ReportType & REPORT_TYPE_DENIED) != 0 || (ReportType & REPORT_TYPE_AUTH_FAILURES) != 0) { if((fp_authfail=MY_FOPEN(authfail_unsort,"w"))==NULL) { - debuga(_("(log) Cannot open file: %s - %s\n"),authfail_unsort,strerror(errno)); + debugapos("log",_("Cannot open file \"%s\": %s\n"),authfail_unsort,strerror(errno)); exit(EXIT_FAILURE); } } @@ -824,7 +824,7 @@ int main(int argc,char *argv[]) } else { if (date[0]!='\0') { if (stat(arq,&logstat)!=0) { - debuga(_("Cannot get the modification time of input log file %s (%s). Processing it anyway\n"),arq,strerror(errno)); + debuga(_("Cannot get the modification time of input log file \"%s\": %s\nProcessing it anyway\n"),arq,strerror(errno)); } else { struct tm *logtime=localtime(&logstat.st_mtime); if ((logtime->tm_year+1900)*10000+(logtime->tm_mon+1)*100+logtime->tm_mdayfile!=NULL) { if (x>=maxopenfiles) { if (fclose(ufile1->file)==EOF) { - debuga(_("Failed to close the log file of user %s - %s\n"),ufile1->user->id,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),ufile1->user->id,strerror(errno)); exit(EXIT_FAILURE); } ufile1->file=NULL; @@ -1502,7 +1502,7 @@ int main(int argc,char *argv[]) exit(EXIT_FAILURE); } if ((ufile->file = MY_FOPEN (tmp3, "a")) == NULL) { - debuga(_("(log) Cannot open temporary file: %s - %s\n"), tmp3, strerror(errno)); + debugapos("log",_("Cannot open file \"%s\": %s\n"), tmp3, strerror(errno)); exit (1); } } @@ -1523,7 +1523,7 @@ int main(int argc,char *argv[]) if ( ! fp_Download_Unsort ) { if ((fp_Download_Unsort = MY_FOPEN ( sz_Download_Unsort, "a")) == NULL) { - debuga(_("(log) Cannot open temporary file: %s - %s\n"),sz_Download_Unsort, strerror(errno)); + debugapos("log",_("Cannot open file \"%s\": %s\n"),sz_Download_Unsort, strerror(errno)); exit (1); } } @@ -1670,7 +1670,7 @@ int main(int argc,char *argv[]) exit(EXIT_FAILURE); } if (rename(arq_log,val4)) { - debuga(_("failed to rename %s to %s - %s\n"),arq_log,val4,strerror(errno)); + debuga(_("Failed to rename \"%s\" into \"%s\": %s\n"),arq_log,val4,strerror(errno)); } else { strcpy(arq_log,val4); @@ -1680,6 +1680,9 @@ int main(int argc,char *argv[]) necessary around the command name, put them in the configuration file. */ if (snprintf(val1,sizeof(val1),"%s \"%s\"",ParsedOutputLogCompress,arq_log)>=sizeof(val1)) { + /* TRANSLATORS: The first %s is the command name. The second is the file name + * to act upon. + */ debuga(_("Command too long: %s \"%s\"\n"),ParsedOutputLogCompress,arq_log); exit(EXIT_FAILURE); } @@ -1768,22 +1771,22 @@ static void getusers(const char *pwdfile, int debug) debuga(_("Loading password file from %s\n"),pwdfile); if ((fp_usr = fopen(pwdfile, "r")) == NULL) { - debuga(_("(getusers) Cannot open file %s - %s\n"),pwdfile,strerror(errno)); + debugapos("getusers",_("Cannot open file \"%s\": %s\n"),pwdfile,strerror(errno)); exit(EXIT_FAILURE); } if (fseek(fp_usr, 0, SEEK_END)==-1) { - debuga(_("Failed to move till the end of the users file %s: %s\n"),pwdfile,strerror(errno)); + debuga(_("Failed to move till the end of the users file \"%s\": %s\n"),pwdfile,strerror(errno)); exit(EXIT_FAILURE); } nreg = ftell(fp_usr); if (nreg<0) { - debuga(_("Cannot get the size of file %s\n"),pwdfile); + debuga(_("Cannot get the size of file \"%s\": %s\n"),pwdfile,strerror(errno)); exit(EXIT_FAILURE); } nreg = nreg+5000; if (fseek(fp_usr, 0, SEEK_SET)==-1) { - debuga(_("Failed to rewind the users file %s: %s\n"),pwdfile,strerror(errno)); + debuga(_("Failed to rewind file \"%s\": %s\n"),pwdfile,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/realtime.c b/realtime.c index 0973bc4..b517cad 100755 --- a/realtime.c +++ b/realtime.c @@ -68,7 +68,7 @@ static void getlog(void) #endif if((fd1 == -1 ) || ((tmp = fdopen (fd1, "w+" )) == NULL) ) { /* failure, bail out */ - debuga(_("(realtime) mkstemp error - %s\n"),strerror(errno)); + debugapos("realtime",_("mkstemp error: %s\n"),strerror(errno)); exit(EXIT_FAILURE); } @@ -81,7 +81,7 @@ static void getlog(void) fp = popen(cmd, "r"); if (!fp) { debuga(_("Failed to get the %d trailing lines of %s: %s\n"),realtime_access_log_lines,AccessLog[0],strerror(errno)); - debuga(_("tail command: %s\n"),cmd); + debuga(_("Failed \"tail\" command: %s\n"),cmd); exit(EXIT_FAILURE); } while((buf=longline_read(fp,line)) != NULL ) @@ -214,7 +214,7 @@ static void datashow(const char *tmp) longline line; if((fin=fopen(tmp,"r"))==NULL) { - debuga(_("(realtime) open error %s - %s\n"),tmp,strerror(errno)); + debugapos("realtime",_("Cannot open file \"%s\": %s\n"),tmp,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/redirector.c b/redirector.c index f506fc9..20af396 100644 --- a/redirector.c +++ b/redirector.c @@ -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); + debugapos("squidguard",_("Cannot open file \"%s\": %s\n"),wentp,strerror(errno)); exit(EXIT_FAILURE); } @@ -307,7 +307,7 @@ void redirector_log(void) snprintf(guard_in,sizeof(guard_in),"%s/redirector.int_unsort",tmp); snprintf(redirector_sorted,sizeof(redirector_sorted),"%s/redirector.int_log",tmp); if((fp_ou=fopen(guard_in,"a"))==NULL) { - debuga(_("(squidguard) Cannot open log file %s\n"),guard_in); + debugapos("squidguard",_("Cannot open file \"%s\": %s\n"),guard_in,strerror(errno)); exit(EXIT_FAILURE); } @@ -324,7 +324,7 @@ void redirector_log(void) } if((fp_guard=fopen(SquidGuardConf,"r"))==NULL) { - debuga(_("(squidguard) Cannot open log file %s\n"),SquidGuardConf); + debugapos("squidguard",_("Cannot open file \"%s\": %s\n"),SquidGuardConf,strerror(errno)); exit(EXIT_FAILURE); } @@ -452,12 +452,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); + debugapos("squidguard",_("Cannot open 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); + debugapos("squidguard",_("Cannot open file \"%s\": %s\n"),report,strerror(errno)); exit(EXIT_FAILURE); } @@ -573,7 +573,7 @@ void redirector_report(void) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in file %s\n"),report); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),report,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),report,strerror(errno)); if (!KeepTempLog && unlink(redirector_sorted)) { debuga(_("Cannot delete \"%s\": %s\n"),redirector_sorted,strerror(errno)); diff --git a/repday.c b/repday.c index 9e85aa4..0df0484 100644 --- 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); + debugapos("repday",_("Cannot open 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); + debugapos("repday",_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno)); exit(EXIT_FAILURE); } @@ -244,6 +244,6 @@ void report_day(const struct userinfostruct *uinfo) if (write_html_trailer(fp_ou)<0) debuga(_("Write error in file %s\n"),arqout); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),arqout,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),arqout,strerror(errno)); return; } diff --git a/report.c b/report.c index 66c6d60..7e70358 100644 --- a/report.c +++ b/report.c @@ -97,7 +97,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); + debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno)); exit(EXIT_FAILURE); } @@ -117,11 +117,11 @@ void gerarel(void) 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); + debugapos("report",_("Directory entry too long: %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\n"),tmp); + debugapos("report",_("Cannot open file \"%s\": %s\n"),tmp,strerror(errno)); exit(EXIT_FAILURE); } user=uinfo->filename; @@ -242,7 +242,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); + debugapos("report",_("Cannot open file \"%s\": %s\n"),arqtt,strerror(errno)); exit(EXIT_FAILURE); } ttopen=1; @@ -328,7 +328,7 @@ 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(_("Failed to close file \"%s\": %s\n"),uinfo->filename,strerror(errno)); fp_tmp=NULL; } if (!KeepTempLog && unlink(tmp3)) { @@ -424,7 +424,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); + debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno)); exit(EXIT_FAILURE); } @@ -465,7 +465,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); + debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno)); exit(EXIT_FAILURE); } @@ -749,7 +749,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); + debugapos("report",_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno)); exit(EXIT_FAILURE); } diff --git a/siteuser.c b/siteuser.c index c5a56d8..e4268f6 100644 --- a/siteuser.c +++ b/siteuser.c @@ -71,13 +71,13 @@ void siteuser(void) } if((fp_in=fopen(general2,"r"))==NULL) { - debuga(_("(siteuser) Cannot open log file %s\n"),general2); + debugapos("siteuser",_("Cannot open 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); + debugapos("siteuser",_("Cannot open file \"%s\": %s\n"),report,strerror(errno)); exit(EXIT_FAILURE); } @@ -188,9 +188,9 @@ void siteuser(void) fputs("\n",fp_ou); if (write_html_trailer(fp_ou)<0) - debuga(_("Write error in file %s\n"),report); + debuga(_("Write error in file \"%s\"\n"),report); if (fclose(fp_ou)==EOF) - debuga(_("Failed to close file %s - %s\n"),report,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),report,strerror(errno)); return; } diff --git a/smartfilter.c b/smartfilter.c index 7d6e1f2..cea5751 100644 --- a/smartfilter.c +++ b/smartfilter.c @@ -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); + debugapos("smartfilter",_("Cannot open 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); + debugapos("smartfilter",_("Cannot open 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); + debugapos("smartfilter",_("Cannot open file \"%s\": %s\n"),smartuser,strerror(errno)); exit(EXIT_FAILURE); } fuser=1; diff --git a/splitlog.c b/splitlog.c index c92913a..e1cfd33 100644 --- a/splitlog.c +++ b/splitlog.c @@ -67,7 +67,7 @@ void splitlog(const char *arq, const char *df, int dfrom, int duntil, int conver // '/' + '-YYYY-mm-dd' + '\0' == 13 output_prefix_len=snprintf(output_file,sizeof(output_file)-12,"%s%s",outdir,splitprefix); if (output_prefix_len>=sizeof(output_file)-12) { - debuga(_("(splitlog) Output path is too long: %s%s-YYYY-mm-dd\n"),outdir,splitprefix); + debugapos("splitlog",_("Output path is too long: %s%s-YYYY-mm-dd\n"),outdir,splitprefix); exit(EXIT_FAILURE); } autosplit=1; @@ -81,7 +81,7 @@ void splitlog(const char *arq, const char *df, int dfrom, int duntil, int conver if (arq[0]=='-' && arq[1]=='\0') { fp_in=stdin; } else if((fp_in=MY_FOPEN(arq,"r"))==NULL) { - debuga(_("(splitlog) Cannot open log file %s - %s\n"),arq,strerror(errno)); + debugapos("splitlog",_("Cannot open file \"%s\": %s\n"),arq,strerror(errno)); exit(EXIT_FAILURE); } @@ -111,7 +111,7 @@ void splitlog(const char *arq, const char *df, int dfrom, int duntil, int conver prev_month=t->tm_mon; prev_day=t->tm_mday; if (fp_ou && fclose(fp_ou)==EOF) { - debuga(_("Failed to close file %s - %s\n"),output_file,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),output_file,strerror(errno)); exit(EXIT_FAILURE); } strftime(output_file+output_prefix_len, sizeof(output_file)-output_prefix_len, "-%Y-%m-%d", t); @@ -121,7 +121,7 @@ void splitlog(const char *arq, const char *df, int dfrom, int duntil, int conver 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)); + debugapos("splitlog",_("Cannot open file \"%s\": %s\n"),output_file,strerror(errno)); exit(EXIT_FAILURE); } if (ttcurrent[x]) && (gwarea->current[x] != stop ));x++) { if(x>=limit) { - debuga(_("getword loop detected after %d bytes.\n"),x); + /* TRANSLATORS: %s is the name of the function reporting this error. + */ + debuga(_("Loop detected in %s after %d bytes.\n"),__func__,x); debuga(_("Line=\"%s\"\n"),gwarea->beginning); debuga(_("Record=\"%s\"\n"),gwarea->current); debuga(_("searching for \'x%x\'\n"),stop); @@ -126,7 +131,9 @@ int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, char s for(x=0;((gwarea->current[x]) && (gwarea->current[x] != stop ));x++) { if(x>=limit) { - debuga(_("getword_multisep loop detected.\n")); + /* TRANSLATORS: %s is the name of the function reporting this error. + */ + debuga(_("Loop detected in %s after %d bytes.\n"),__func__,x); debuga(_("Line=\"%s\"\n"),gwarea->beginning); debuga(_("Record=\"%s\"\n"),gwarea->current); debuga(_("searching for \'x%x\'\n"),stop); @@ -153,7 +160,9 @@ int getword_skip(int limit, struct getwordstruct *gwarea, char stop) for(x=0;(gwarea->current[x] && (gwarea->current[x] != stop ));x++) { if(x>=limit) { - debuga(_("getword_skip loop detected after %d bytes.\n"),x); + /* TRANSLATORS: %s is the name of the function reporting this error. + */ + debuga(_("Loop detected in %s after %d bytes.\n"),__func__,x); debuga(_("Line=\"%s\"\n"),gwarea->beginning); debuga(_("Record=\"%s\"\n"),gwarea->current); debuga(_("searching for \'x%x\'\n"),stop); @@ -186,13 +195,18 @@ int getword_atoll(long long int *number, struct getwordstruct *gwarea, char stop for(x=0;isdigit(gwarea->current[x]);x++) { digit=gwarea->current[x]-'0'; if (*number >= (LLONG_MAX-digit)/10) { - debuga(_("Integer overflow detected in getword_atoll in line %s\n"),gwarea->beginning); + /* TRANSLATORS: The first %s is the name of the function displaying + * this message. + */ + debuga(_("Integer overflow detected in %s in line \"%s\"\n"),__func__,gwarea->beginning); return(-1); } *number=(*number * 10) + digit; } if(gwarea->current[x] && gwarea->current[x]!=stop) { - debuga(_("getword_atoll loop detected after %d bytes.\n"),x); + /* TRANSLATORS: %s is the name of the function reporting this error. + */ + debuga(_("Loop detected in %s after %d bytes.\n"),__func__,x); debuga(_("Line=\"%s\"\n"),gwarea->beginning); debuga(_("Record=\"%s\"\n"),gwarea->current); debuga(_("searching for \'x%x\'\n"),stop); @@ -225,13 +239,18 @@ int getword_atoi(int *number, struct getwordstruct *gwarea, char stop) for(x=0;isdigit(gwarea->current[x]);x++) { digit=gwarea->current[x]-'0'; if (*number > (INT_MAX-digit)/10) { - debuga(_("Integer overflow detected in getword_atoi in line %s\n"),gwarea->beginning); + /* TRANSLATORS: The first %s is the name of the function displaying + * this message. + */ + debuga(_("Integer overflow detected in %s in line \"%s\"\n"),__func__,gwarea->beginning); return(-1); } *number=(*number * 10) + digit; } if(gwarea->current[x] && gwarea->current[x]!=stop) { - debuga(_("getword_atoi loop detected after %d bytes.\n"),x); + /* TRANSLATORS: %s is the name of the function reporting this error. + */ + debuga(_("Loop detected in %s after %d bytes.\n"),__func__,x); debuga(_("Line=\"%s\"\n"),gwarea->beginning); debuga(_("Record=\"%s\"\n"),gwarea->current); debuga(_("searching for \'x%x\'\n"),stop); @@ -316,7 +335,7 @@ void my_mkdir(const char *name) int chars; if(!is_absolute(name)) { - debuga(_("Invalid path (%s). Please, use absolute paths only.\n"),name); + debuga(_("Invalid path \"%s\". Please, use absolute paths only.\n"),name); exit(EXIT_FAILURE); } @@ -330,7 +349,7 @@ void my_mkdir(const char *name) w0[i] = '\0'; if (access(w0, R_OK) != 0) { if (mkdir(w0,0755)) { - debuga(_("Cannot create directory %s - %s\n"),w0,strerror(errno)); + debuga(_("Cannot create directory \"%s\": %s\n"),w0,strerror(errno)); exit(EXIT_FAILURE); } } @@ -341,7 +360,7 @@ void my_mkdir(const char *name) if (access(name, R_OK) != 0) { if (mkdir(name,0755)) { - debuga(_("Cannot create directory %s - %s\n"),name,strerror(errno)); + debuga(_("Cannot create directory \"%s\": %s\n"),name,strerror(errno)); exit(EXIT_FAILURE); } } @@ -463,6 +482,23 @@ void debuga(const char *msg,...) va_end(ap); } +/*! +Write a debug message to stderr. The message is prefixed by "SARG:" to identify its origin. + +\param pos Where, in the source code, this message comes from. +\param msg The printf like message to format. +\param ... The arguments to format in the message. +*/ +void debugapos(const char *pos,const char *msg,...) +{ + va_list ap; + + fputs(_("SARG: "),stderr); + fprintf(stderr,"(%s) ",pos); + va_start(ap,msg); + vfprintf(stderr,msg,ap); + va_end(ap); +} /*! Write a debug message to stderr. The message is prefixed by "SARG: (info)". @@ -659,7 +695,9 @@ int obtdate(const char *dirname, const char *name, char *data) } if (!fgets(data,80,fp_in)) { - debuga(_("Failed to read the date in %s\n"),wdir); + /* TRANSLATORS: %s is a file name. + */ + debuga(_("Failed to read the date in \"%s\"\n"),wdir); exit(EXIT_FAILURE); } fclose(fp_in); @@ -715,7 +753,9 @@ int obtuser(const char *dirname, const char *name) } if (!fgets(tuser,sizeof(tuser),fp_in)) { - debuga(_("Failed to read the number of users in %s\n"),wdir); + /* TRANSLATORS: %s is a file name. + */ + debuga(_("Failed to read the number of users in \"%s\"\n"),wdir); exit(EXIT_FAILURE); } fclose(fp_in); @@ -747,7 +787,9 @@ void obttotal(const char *dirname, const char *name, int nuser, long long int *t } if ((line=longline_create())==NULL) { - debuga(_("Not enough memory to read the file %s\n"),wdir); + /* TRANSLATORS: %s is a file name. + */ + debuga(_("Not enough memory to read \"%s\"\n"),wdir); exit(EXIT_FAILURE); } @@ -760,17 +802,17 @@ void obttotal(const char *dirname, const char *name, int nuser, long long int *t continue; getword_start(&gwarea,buf); if (getword(user,sizeof(user),&gwarea,sep)<0) { - debuga(_("There is a invalid user in file %s\n"),wdir); + debuga(_("There is an invalid user in file \"%s\"\n"),wdir); exit(EXIT_FAILURE); } if(strcmp(user,"TOTAL") != 0) continue; if (getword_skip(MAXLEN,&gwarea,sep)<0) { - debuga(_("There a broken total number of access in file %s\n"),wdir); + debuga(_("There a broken total number of access in file \"%s\"\n"),wdir); exit(EXIT_FAILURE); } if (getword_atoll(tbytes,&gwarea,sep)<0) { - debuga(_("There is a broken number of bytes in file %s\n"),wdir); + debuga(_("There is a broken number of bytes in file \"%s\"\n"),wdir); exit(EXIT_FAILURE); } break; @@ -925,12 +967,12 @@ static void copy_images(void) struct stat info; if (snprintf(images,sizeof(images),"%simages",outdir)>=sizeof(images)) { - debuga(_("Cannot copy images to target directory %simages\n"),outdir); + debuga(_("Resulting target directory too long: %simages\n"),outdir); exit(EXIT_FAILURE); } if (access(images,R_OK)!=0) { if (mkdir(images,0755)) { - debuga(_("Cannot create directory %s - %s\n"),images,strerror(errno)); + debuga(_("Cannot create directory \"%s\": %s\n"),images,strerror(errno)); exit(EXIT_FAILURE); } } @@ -938,7 +980,7 @@ static void copy_images(void) strcpy(imgdir,IMAGEDIR); dirp = opendir(imgdir); if(dirp==NULL) { - debuga(_("(util) Can't open directory %s: %s\n"),imgdir,strerror(errno)); + debugapos("util",_("Cannot open directory \"%s\": %s\n"),imgdir,strerror(errno)); return; } while ((direntp = readdir( dirp )) != NULL ){ @@ -946,7 +988,7 @@ static void copy_images(void) continue; sprintf(srcfile,"%s/%s",imgdir,direntp->d_name); if (stat(srcfile,&info)) { - debuga(_("Cannot stat \"%s\" - %s\n"),srcfile,strerror(errno)); + debuga(_("Cannot stat \"%s\": %s\n"),srcfile,strerror(errno)); continue; } if (S_ISREG(info.st_mode)) { @@ -957,16 +999,16 @@ static void copy_images(void) if(img_ou!=NULL) { while ((nread = fread(buffer,1,sizeof(buffer),img_in))>0) { if (fwrite(buffer,1,nread,img_ou)!=nread) { - debuga(_("Failed to copy image %s to %s\n"),srcfile,dstfile); + debuga(_("Failed to copy image \"%s\" to \"%s\"\n"),srcfile,dstfile); break; } } fclose(img_ou); } else - fprintf(stderr,"SARG: (util): %s %s: %s\n", _("Cannot open file")?_("Cannot open file"):"Can't open/create file", dstfile, strerror(errno)); + debugapos("util",_("Cannot open file \"%s\": %s\n"), dstfile, strerror(errno)); fclose(img_in); } else - fprintf(stderr,"SARG: (util): %s %s: %s\n", _("Cannot open file")?_("Cannot open file"):"Can't open file", srcfile, strerror(errno)); + debugapos("util",_("Cannot open file \"%s\": %s\n"),srcfile, strerror(errno)); } } (void) closedir(dirp); @@ -1053,7 +1095,7 @@ int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, if(count > 0) { if(debug) - debuga(_("File %s already exists, moved to %s\n"),outdirname,wdir); + debuga(_("File \"%s\" already exists, moved to \"%s\"\n"),outdirname,wdir); rename(outdirname,wdir); } } else { @@ -1076,7 +1118,7 @@ int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, if(count > 0) { if(debug) - debuga(_("File %s already exists, moved to %s\n"),dirname2,wdir); + debuga(_("File \"%s\" already exists, moved to \"%s\"\n"),dirname2,wdir); rename(dirname2,wdir); strcpy(dirname2,wdir); } @@ -1094,7 +1136,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\": %s\n"),wdir,strerror(errno)); perror("SARG:"); exit(EXIT_FAILURE); } @@ -1103,12 +1145,12 @@ int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, loctm=localtime(&curtime); strftime(wdir,sizeof(wdir),"%Y-%m-%d %H:%M:%S",loctm); if (fprintf(fp_ou,"%s %d\n",wdir,loctm->tm_isdst)<0) { - debuga(_("Failed to write the date in %s\n"),wdir); + debuga(_("Failed to write the date in \"%s\"\n"),wdir); perror("SARG:"); exit(EXIT_FAILURE); } if (fclose(fp_ou)==EOF) { - debuga(_("Failed to write the date in %s\n"),wdir); + debuga(_("Failed to write the date in \"%s\": %s\n"),wdir,strerror(errno)); perror("SARG:"); exit(EXIT_FAILURE); } @@ -1377,16 +1419,16 @@ void removetmp(const char *outdir) debuga(_("Purging temporary file sarg-general\n")); } if (snprintf(filename,sizeof(filename),"%s/sarg-general",outdir)>=sizeof(filename)) { - debuga(_("(removetmp) directory too long to remove %s/sarg-period\n"),outdir); + debugapos("removetmp",_("Directory too long: %s/sarg-period\n"),outdir); exit(EXIT_FAILURE); } if((fp_gen=fopen(filename,"w"))==NULL){ - debuga(_("(removetmp) Cannot open file %s\n"),filename); + debugapos("removetmp",_("Cannot open file \"%s\": %s\n"),filename,strerror(errno)); exit(EXIT_FAILURE); } totalger(fp_gen,filename); if (fclose(fp_gen)==EOF) { - debuga(_("Failed to close %s after writing the total line - %s\n"),filename,strerror(errno)); + debuga(_("Failed to close file \"%s\": %s\n"),filename,strerror(errno)); exit(EXIT_FAILURE); } } @@ -1403,27 +1445,27 @@ void load_excludecodes(const char *ExcludeCodes) return; if((fp_in=fopen(ExcludeCodes,"r"))==NULL) { - debuga(_("(util) Cannot open file %s (exclude_codes)\n"),ExcludeCodes); + debugapos("util",_("Cannot open file \"%s\": %s\n"),ExcludeCodes,strerror(errno)); exit(EXIT_FAILURE); } if (fseek(fp_in, 0, SEEK_END)==-1) { - debuga(_("Failed to move till the end of the excluded codes file %s: %s\n"),ExcludeCodes,strerror(errno)); + debuga(_("Failed to move till the end of the excluded codes file \"%s\": %s\n"),ExcludeCodes,strerror(errno)); exit(EXIT_FAILURE); } MemSize = ftell(fp_in); if (MemSize<0) { - debuga(_("Cannot get the size of file %s\n"),ExcludeCodes); + debuga(_("Cannot get the size of file \"%s\": %s\n"),ExcludeCodes,strerror(errno)); exit(EXIT_FAILURE); } if (fseek(fp_in, 0, SEEK_SET)==-1) { - debuga(_("Failed to rewind the excluded codes file %s: %s\n"),ExcludeCodes,strerror(errno)); + debuga(_("Failed to rewind file \"%s\": %s\n"),ExcludeCodes,strerror(errno)); exit(EXIT_FAILURE); } MemSize+=1; if((excludecode=(char *) malloc(MemSize))==NULL) { - debuga(_("malloc error (%ld)\n"),MemSize); + debuga(_("malloc failed to allocate %ld bytes\n"),MemSize); exit(EXIT_FAILURE); } memset(excludecode,0,MemSize); @@ -1434,7 +1476,7 @@ void load_excludecodes(const char *ExcludeCodes) for (i=strlen(data)-1 ; i>=0 && (unsigned char)data[i]<=' ' ; i--) data[i]='\0'; if (i<0) continue; if (Stored+i+2>=MemSize) { - debuga(_("Too many codes to exclude in file %s\n"),ExcludeCodes); + debuga(_("Too many codes to exclude in file \"%s\"\n"),ExcludeCodes); break; } strcat(excludecode,data); @@ -1587,8 +1629,8 @@ char *get_size(const char *path, const char *file) char cmd[255]; char *ptr; - if (snprintf(cmd,sizeof(cmd),"du -skh %s%s",path,file)>=sizeof(cmd)) { - debuga(_("Cannot get disk space because the path %s%s is too long\n"),path,file); + if (snprintf(cmd,sizeof(cmd),"du -skh \"%s%s\"",path,file)>=sizeof(cmd)) { + debuga(_("Cannot get disk space because the path \"%s%s\" is too long\n"),path,file); exit(EXIT_FAILURE); } if ((fp = popen(cmd, "r")) == NULL) { @@ -1601,7 +1643,10 @@ char *get_size(const char *path, const char *file) } ptr=strchr(response,'\t'); if (ptr==NULL) { - debuga(_("The command %s failed\n"),cmd); + /* TRANSLATORS: First %s is the command to get the occuped disk size (namely, du -skh "..."). + * The second %s is the string returned by the command. + */ + debuga(_("The command to compute the occupied disk size (%s) returned the unknown string %s\n"),cmd,response); exit(EXIT_FAILURE); } pclose(fp); @@ -1830,7 +1875,7 @@ void unlinkdir(const char *dir,bool contentonly) (direntp->d_name[1] == '.' && direntp->d_name[2] == '\0'))) continue; if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) { - debuga(_("directory name to delete too long: %s/%s\n"),dir,direntp->d_name); + debuga(_("Directory name to delete too long: %s/%s\n"),dir,direntp->d_name); exit(EXIT_FAILURE); } #ifdef HAVE_LSTAT @@ -1839,7 +1884,7 @@ void unlinkdir(const char *dir,bool contentonly) err=stat(dname,&st); #endif if (err) { - debuga(_("cannot stat %s\n"),dname); + debuga(_("Cannot stat \"%s\": %s\n"),dname,strerror(errno)); exit(EXIT_FAILURE); } if (S_ISREG(st.st_mode)) { @@ -1850,7 +1895,7 @@ void unlinkdir(const char *dir,bool contentonly) } else if (S_ISDIR(st.st_mode)) { unlinkdir(dname,0); } else { - debuga(_("unknown path type %s\n"),dname); + debuga(_("Unknown path type \"%s\"\n"),dname); } } closedir(dirp); @@ -1921,7 +1966,7 @@ void emptytmpdir(const char *dir) } if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) { - debuga(_("directory name to delete too long: %s/%s\n"),dir,direntp->d_name); + debuga(_("Directory name to delete too long: %s/%s\n"),dir,direntp->d_name); exit(EXIT_FAILURE); } @@ -1931,7 +1976,7 @@ void emptytmpdir(const char *dir) err=stat(dname,&st); #endif if (err) { - debuga(_("cannot stat \"%s\"\n"),dname); + debuga(_("Cannot stat \"%s\": %s\n"),dname,strerror(errno)); exit(EXIT_FAILURE); } if (S_ISDIR(st.st_mode)) { @@ -1963,7 +2008,7 @@ void emptytmpdir(const char *dir) } if (snprintf(dname,sizeof(dname),"%s/%s",dir,direntp->d_name)>=sizeof(dname)) { - debuga(_("directory name to delete too long: %s/%s\n"),dir,direntp->d_name); + debuga(_("Directory name to delete too long: %s/%s\n"),dir,direntp->d_name); exit(EXIT_FAILURE); } #ifdef HAVE_LSTAT @@ -1972,7 +2017,7 @@ void emptytmpdir(const char *dir) err=stat(dname,&st); #endif if (err) { - debuga(_("cannot stat \"%s\"\n"),dname); + debuga(_("Cannot stat \"%s\": %s\n"),dname,strerror(errno)); exit(EXIT_FAILURE); } if (S_ISREG(st.st_mode)) { @@ -1981,7 +2026,7 @@ void emptytmpdir(const char *dir) exit(EXIT_FAILURE); } } else { - debuga(_("unknown path type %s\n"),dname); + debuga(_("Unknown path type \"%s\"\n"),dname); } } closedir(dirp);