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);
}
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);
}
}
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);
}
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));
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);
}
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));
}
}
}
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);
}
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);
}
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);
}
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));
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);
}
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);
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);
}
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));
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);
}
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));
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);
}
}
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);
}
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);
}
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);
}
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);
}
}
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);
}
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);
}
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 {
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);
{
#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
}
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);
}
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);
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;
}
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);
}
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);
}
}
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) {
}
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);
}
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) {
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);
fputs("</table></div>\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);
}
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);
// 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) {
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) {
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);
// 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) {
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);
// 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) {
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);
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("</table></div>\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("</table></div>\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)
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);
}
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);
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 ; i<nsort ; i++) {
ndirlen=sprintf(newdir,"%s%04d",outdir,y1);
if (access(newdir, R_OK) != 0) {
if (mkdir(newdir,0755)) {
- debuga(_("Cannot create directory %s - %s\n"),newdir,strerror(errno));
+ debuga(_("Cannot create directory \"%s\": %s\n"),newdir,strerror(errno));
exit(EXIT_FAILURE);
}
}
else ndirlen+=sprintf(newdir+ndirlen,"/%02d",m1);
if (access(newdir, R_OK) != 0) {
if (mkdir(newdir,0755)) {
- debuga(_("Cannot create directory %s - %s\n"),newdir,strerror(errno));
+ debuga(_("Cannot create directory \"%s\": %s\n"),newdir,strerror(errno));
exit(EXIT_FAILURE);
}
}
sprintf(olddir,"%s%s",outdir,entry);
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);
}
sprintf(linkdir,"%simages",outdir);
if (symlink(linkdir,newdir)) {
- debuga(_("failed to create link \"%s\" to \"%s\" - %s\n"),linkdir,newdir,strerror(errno));
+ debuga(_("Failed to create link \"%s\" to \"%s\": %s\n"),linkdir,newdir,strerror(errno));
exit(EXIT_FAILURE);
}
#else
else continue;
sprintf(olddir,"%s%04d/%s/%s",outdir,y1,direntp2->d_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);
}
}
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 ){
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 ){
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;
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);
}
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);
}
}
} 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_mday<dfrom) {
}
fp_in=decomp(arq,&from_pipe);
if(fp_in==NULL) {
- debuga(_("(log) Cannot open log file: %s - %s\n"),arq,strerror(errno));
+ debugapos("log",_("Cannot open file \"%s\": %s\n"),arq,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug) debuga(_("Reading access log file: %s\n"),arq);
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));
+ debugapos("log",_("Cannot open file \"%s\": %s\n"),arq_log,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("*** SARG Log ***\n",fp_log);
if (ufile1->file!=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;
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);
}
}
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);
}
}
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);
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);
}
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);
}
#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);
}
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 )
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);
}
}
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);
}
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);
}
}
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);
}
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);
}
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));
}
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);
}
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);
}
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;
}
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);
}
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;
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;
}
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)) {
}
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);
}
}
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);
}
}
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);
}
}
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);
}
fputs("</table></div>\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;
}
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);
}
}
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);
}
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;
// '/' + '-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;
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);
}
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);
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 (tt<min_tt) min_tt=tt;
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));
}
if (autosplit && fp_ou) {
if (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);
}
}
}
if((fp_in=fopen(general2,"r"))==NULL) {
- debuga(_("(topsites) Cannot open log file %s\n"),general2);
+ debugapos("topsites",_("Cannot open 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);
+ debugapos("topsites",_("Cannot open file \"%s\": %s\n"),general3,strerror(errno));
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
if((fp_in=fopen(sites,"r"))==NULL) {
- debuga(_("(topsites) Cannot open log file %s\n"),sites);
+ debugapos("topsites",_("Cannot open file \"%s\": %s\n"),sites,strerror(errno));
debuga(_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
}
if((fp_ou=fopen(report,"w"))==NULL) {
- debuga(_("(topsites) Cannot open log file %s\n"),report);
+ debugapos("topsites",_("Cannot open file \"%s\": %s\n"),report,strerror(errno));
exit(EXIT_FAILURE);
}
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));
return;
}
snprintf(tusr,sizeof(tusr),"%s/sarg-users",outdirname);
if((fp_ou=fopen(tusr,"w"))==NULL) {
- debuga(_("(topuser) Cannot open file %s\n"),tusr);
+ debugapos("topuser",_("Cannot open file \"%s\": %s\n"),tusr,strerror(errno));
exit(EXIT_FAILURE);
}
fprintf(fp_ou,"%d\n",totuser);
if (fclose(fp_ou)==EOF)
- debuga(_("Failed to close file %s - %s\n"),tusr,strerror(errno));
+ debuga(_("Failed to close file \"%s\": %s\n"),tusr,strerror(errno));
globstat.totuser=totuser;
}
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);
+ debugapos("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);
+ debugapos("topuser",_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
exit(EXIT_FAILURE);
}
}
if((fp_top1=fopen(top1,"r"))==NULL) {
- debuga(_("(topuser) Cannot open file %s\n"),top1);
+ debugapos("topuser",_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(top3,sizeof(top3),"%s/index.html",outdirname);
if((fp_top3=fopen(top3,"w"))==NULL) {
- debuga(_("(topuser) Cannot open file %s\n"),top3);
+ debugapos("topuser",_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
exit(EXIT_FAILURE);
}
if (write_html_trailer(fp_top3)<0)
debuga(_("Write error in top user list %s\n"),top3);
if (fclose(fp_top3)==EOF)
- debuga(_("Failed to close the top user list %s - %s\n"),top3,strerror(errno));
+ debuga(_("Failed to close file \"%s\": %s\n"),top3,strerror(errno));
return;
}
}
if((fp_ou=fopen(arqout,"w"))==NULL) {
- debuga(_("(totday) Cannot open log file %s\n"),arqout);
+ debugapos("totday",_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
exit(EXIT_FAILURE);
}
}
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));
exit(EXIT_FAILURE);
}
return;
sprintf(tmp2,"%s/squagent.int_log",tmp);
if((fp_in=fopen(UserAgentLog,"r"))==NULL) {
- debuga(_("(useragent) Cannot open file %s\n"),UserAgentLog);
+ debugapos("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);
+ debugapos("useragent",_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
fclose(fp_in);
if (fclose(fp_ou)==EOF) {
- debuga(_("Failed to close file %s - %s\n"),tmp3,strerror(errno));
+ debuga(_("Failed to close file \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
if((fp_in=fopen(tmp2,"r"))==NULL) {
- debuga(_("(useragent) Cannot open file %s\n"),tmp2);
+ debugapos("useragent",_("Cannot open file \"%s\": %s\n"),tmp2,strerror(errno));
debuga(_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
snprintf(hfile,sizeof(hfile),"%s/useragent.html", outdirname);
if((fp_ht=fopen(hfile,"w"))==NULL) {
- debuga(_("(useragent) Cannot open file %s\n"),hfile);
+ debugapos("useragent",_("Cannot open file \"%s\": %s\n"),hfile,strerror(errno));
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
if((fp_in=fopen(tmp3,"r"))==NULL) {
- debuga(_("(useragent) Cannot open file %s\n"),tmp3);
+ debugapos("useragent",_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
debuga(_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
}
if((fp_ou=fopen(tmp2,"w"))==NULL) {
- debuga(_("(useragent) Cannot open file %s\n"),tmp2);
+ debugapos("useragent",_("Cannot open file \"%s\": %s\n"),tmp2,strerror(errno));
exit(EXIT_FAILURE);
}
fclose(fp_in);
if (fclose(fp_ou)==EOF) {
- debuga(_("Failed to close file %s - %s\n"),tmp3,strerror(errno));
+ debuga(_("Failed to close file \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
if((fp_in=fopen(tmp3,"r"))==NULL) {
- debuga(_("(useragent) Cannot open file %s\n"),tmp3);
+ debugapos("useragent",_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
debuga(_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if (write_html_trailer(fp_ht)<0)
debuga(_("Write error in file %s\n"),hfile);
if (fclose(fp_ht)==EOF)
- debuga(_("Failed to close file %s - %s\n"),hfile,strerror(errno));
+ debuga(_("Failed to close file \"%s\": %s\n"),hfile,strerror(errno));
if (!KeepTempLog && unlink(tmp3)) {
debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
int z1, z2;
if((fp_usr=fopen(UserTabFile,"r"))==NULL) {
- debuga(_("(usertab) Cannot open file %s - %s\n"),UserTabFile,strerror(errno));
+ debugapos("usertab",_("Cannot open file \"%s\": %s\n"),UserTabFile,strerror(errno));
exit(EXIT_FAILURE);
}
if (fseek(fp_usr, 0, SEEK_END)==-1) {
}
nreg = ftell(fp_usr);
if (nreg<0) {
- debuga(_("Cannot get the size of file %s\n"),UserTabFile);
+ debuga(_("Cannot get the size of file \"%s\": %s\n"),UserTabFile,strerror(errno));
exit(EXIT_FAILURE);
}
nreg += 100;
if (fseek(fp_usr, 0, SEEK_SET)==-1) {
- debuga(_("Failed to rewind the usertab file %s: %s\n"),UserTabFile,strerror(errno));
+ debuga(_("Failed to rewind file \"%s\": %s\n"),UserTabFile,strerror(errno));
exit(EXIT_FAILURE);
}
if((userfile=(char *) malloc(nreg))==NULL){
- debuga(_("ERROR: Cannot load. Memory fault\n"));
+ debuga(_("Cannot load \"%s\": not enough memory\n"),UserTabFile);
exit(EXIT_FAILURE);
}
userfile[0]='\t';
{
if (strcmp(UserTabFile, "ldap") == 0) {
if(debug)
- debuga(_("Loading User table: %s\n"),UserTabFile);
+ debuga(_("Loading user table from LDAP\n"));
#ifdef HAVE_LDAP_H
which_usertab=UTT_Ldap;
init_ldap_usertab();
if (n<=0) return;
calls=backtrace_symbols(buffer,n);
if (calls) {
+ /* TRANSLATORS: "getword" is the function displaying
+ * the backtrace leading to its execution.
+ */
debuga(_("getword backtrace:\n"));
for (i=0 ; i<n ; i++) {
fprintf(stderr,"SARG: %d:%s\n",i+1,calls[i]);
for(x=0;((gwarea->current[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);
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);
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);
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);
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);
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);
}
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);
}
}
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);
}
}
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)".
}
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);
}
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);
}
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);
}
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;
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);
}
}
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 ){
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)) {
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);
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 {
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);
}
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);
}
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);
}
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);
}
}
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);
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);
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) {
}
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);
(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
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)) {
} 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);
}
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);
}
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)) {
}
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
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)) {
exit(EXIT_FAILURE);
}
} else {
- debuga(_("unknown path type %s\n"),dname);
+ debuga(_("Unknown path type \"%s\"\n"),dname);
}
}
closedir(dirp);