sprintf(wdir,"%s"INDEX_HTML_FILE,outdir);
if(access(wdir, R_OK) == 0) {
if (unlink(wdir)) {
- debuga(_("Cannot delete \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),wdir,strerror(errno));
exit(EXIT_FAILURE);
}
}
if(debug) {
// TRANSLATORS: The %s is the name of the html index file (index.html).
- debuga(_("Making %s\n"),INDEX_HTML_FILE);
+ debuga(__FILE__,__LINE__,_("Making %s\n"),INDEX_HTML_FILE);
}
// convert any old report hierarchy
if ((dirp = opendir(outdir)) == NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
exit(EXIT_FAILURE);
}
while ((direntp = readdir( dirp )) != NULL) {
path_len=strlen(path);
if (path_len+2>=path_size) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s\n",path);
exit(EXIT_FAILURE);
}
if ((dirp=opendir(path))==NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),path,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),path,strerror(errno));
exit(EXIT_FAILURE);
}
path[path_len++]='/';
if (direntp->d_name[0]=='.' && (direntp->d_name[1]=='\0' || (direntp->d_name[1]=='.' && direntp->d_name[2]=='\0'))) continue;
name_len=strlen(direntp->d_name);
if (path_len+name_len+1>=path_size) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s%s\n",path,direntp->d_name);
exit(EXIT_FAILURE);
}
strcpy(path+path_len,direntp->d_name);
if (MY_LSTAT(path,&statb) == -1) {
- debuga(_("Failed to get the statistics of file \"%s\": %s\n"),path,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to get the statistics of file \"%s\": %s\n"),path,strerror(errno));
continue;
}
if (S_ISDIR(statb.st_mode))
dir_allocated+=size;
dir_list=realloc(dir_list,dir_allocated);
if (!dir_list) {
- debuga(_("Not enough memory to recurse into subdirectory \"%s\"\n"),path);
+ debuga(__FILE__,__LINE__,_("Not enough memory to recurse into subdirectory \"%s\"\n"),path);
exit(EXIT_FAILURE);
}
}
ndays=0;
if ((dirp3 = opendir(monthdir)) == NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),monthdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),monthdir,strerror(errno));
exit(EXIT_FAILURE);
}
monthdir_len=strlen(monthdir);
if (monthdir_len+strlen(INDEX_HTML_FILE)+2>=monthdir_size) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s\n",monthdir,INDEX_HTML_FILE);
exit(EXIT_FAILURE);
}
if (direntp->d_name[0]=='.' && (direntp->d_name[1]=='\0' || (direntp->d_name[1]=='.' && direntp->d_name[2]=='\0'))) continue;
name_len=strlen(direntp->d_name);
if (monthdir_len+name_len+1>=monthdir_size) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s%s\n",monthdir,direntp->d_name);
exit(EXIT_FAILURE);
}
strcpy(monthdir+monthdir_len,direntp->d_name);
if (MY_LSTAT(monthdir,&statb) == -1) {
- debuga(_("Failed to get the statistics of file \"%s\": %s\n"),monthdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to get the statistics of file \"%s\": %s\n"),monthdir,strerror(errno));
continue;
}
if (S_ISDIR(statb.st_mode))
d2=0;
}
if (ndays>=sizeof(daysort)/sizeof(daysort[0])) {
- debuga(_("Too many day directories in %s\nSupernumerary entries are ignored\n"),monthdir);
+ debuga(__FILE__,__LINE__,_("Too many day directories in %s\nSupernumerary entries are ignored\n"),monthdir);
break;
}
day=(d1 << 5) | d2;
strcpy(monthdir+monthdir_len,INDEX_HTML_FILE);
if((fp_ou=fopen(monthdir,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),monthdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),monthdir,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(title,sizeof(title),ngettext("SARG: report for %s/%s","SARG: reports for %s/%s",ndays),yearnum,monthnum);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
strcpy(monthdir+monthdir_len,INDEX_HTML_FILE);
- debuga(_("Write error in \"%s\": %s\n"),monthdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),monthdir,strerror(errno));
exit(EXIT_FAILURE);
}
return(total_size);
N_("August"),N_("September"),N_("October"),N_("November"),N_("December")};
if (month<1 || month>12) {
- debuga(_("The internal list of month names is invalid. Please report this bug to the translator.\n"));
+ debuga(__FILE__,__LINE__,_("The internal list of month names is invalid. Please report this bug to the translator.\n"));
exit(EXIT_FAILURE);
}
strncpy(month_name,_(m[month-1]),month_size-1);
nmonths=0;
if ((dirp2 = opendir(yeardir)) == NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),yeardir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),yeardir,strerror(errno));
exit(EXIT_FAILURE);
}
yeardir_len=strlen(yeardir);
if (yeardir_len+strlen(INDEX_HTML_FILE)+2>=yeardir_size) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s/%s\n",yeardir,INDEX_HTML_FILE);
exit(EXIT_FAILURE);
}
if (direntp->d_name[0]=='.' && (direntp->d_name[1]=='\0' || (direntp->d_name[1]=='.' && direntp->d_name[2]=='\0'))) continue;
name_len=strlen(direntp->d_name);
if (yeardir_len+name_len+1>=yeardir_size) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s%s\n",yeardir,direntp->d_name);
exit(EXIT_FAILURE);
}
strcpy(yeardir+yeardir_len,direntp->d_name);
if (MY_LSTAT(yeardir,&statb) == -1) {
- debuga(_("Failed to get the statistics of file \"%s\": %s\n"),yeardir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Failed to get the statistics of file \"%s\": %s\n"),yeardir,strerror(errno));
continue;
}
if (S_ISDIR(statb.st_mode))
m2=0;
}
if (nmonths>=sizeof(monthsort)/sizeof(monthsort[0])) {
- debuga(_("Too many month directories in %s\nSupernumerary entries are ignored\n"),yeardir);
+ debuga(__FILE__,__LINE__,_("Too many month directories in %s\nSupernumerary entries are ignored\n"),yeardir);
break;
}
month=(m1<<4) | m2;
strcpy(yeardir+yeardir_len,INDEX_HTML_FILE);
if((fp_ou=fopen(yeardir,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),yeardir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),yeardir,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(title,sizeof(title),ngettext("SARG: report for %s","SARG: reports for %s",nmonths),yearnum);
}
if (yeardir_len+strlen(monthnum)+1>=yeardir_size) {
yeardir[yeardir_len]='\0';
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s%s\n",yeardir,monthnum);
exit(EXIT_FAILURE);
}
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
strcpy(yeardir+yeardir_len,INDEX_HTML_FILE);
- debuga(_("Write error in \"%s\": %s\n"),yeardir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),yeardir,strerror(errno));
exit(EXIT_FAILURE);
}
return(total_size);
nyears=0;
if ((dirp = opendir(outdir)) == NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
exit(EXIT_FAILURE);
}
while ((direntp = readdir( dirp )) != NULL) {
order=(strcmp(IndexSortOrder,"A") == 0) ? 1 : -1;
if (snprintf(yearindex,sizeof(yearindex),"%s"INDEX_HTML_FILE,outdir)>=sizeof(yearindex)) {
- debuga(_("Resulting index file name too long: %s/%s"),outdir,INDEX_HTML_FILE);
+ debuga(__FILE__,__LINE__,_("Resulting index file name too long. File name is \"%s/%s\""),outdir,INDEX_HTML_FILE);
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(yearindex,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),yearindex,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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);
yeardirlen=strlen(outdir);
if (yeardirlen>=sizeof(yeardir)) {
- debuga(_("Path too long: "));
+ debuga(__FILE__,__LINE__,_("Path too long: "));
debuga_more("%s",outdir);
exit(EXIT_FAILURE);
}
fputs("</table></div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),yearindex,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),yearindex,strerror(errno));
exit(EXIT_FAILURE);
}
}
order=(strcmp(IndexSortOrder,"A") == 0) ? 1 : -1;
if ((dirp = opendir(outdir)) == NULL) {
- debuga(_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open directory \"%s\": %s\n"),outdir,strerror(errno));
exit(EXIT_FAILURE);
}
while ((direntp = readdir( dirp )) != NULL) {
if (strchr(direntp->d_name,'-') == 0) continue;
if (obtdate(outdir,direntp->d_name,data)<0) {
- debuga(_("The directory \"%s%s\" looks like a report directory but doesn't contain a sarg-date file. You should delete it\n"),outdir,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("The directory \"%s%s\" looks like a report directory but doesn't contain a sarg-date file. You should delete it\n"),outdir,direntp->d_name);
continue;
}
item=malloc(sizeof(*item));
if (!item) {
- debuga(_("not enough memory to sort the index\n"));
+ debuga(__FILE__,__LINE__,_("not enough memory to sort the index\n"));
exit(EXIT_FAILURE);
}
if (df=='u') {
*/
getword_start(&gwarea,data);
if (getword_skip(16,&gwarea,' ')<0) {
- debuga(_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
exit(EXIT_FAILURE);
}
if (getword_multisep(mon,sizeof(mon),&gwarea,' ')<0) {
- debuga(_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
exit(EXIT_FAILURE);
}
if (getword_multisep(day,sizeof(day),&gwarea,' ')<0) {
- debuga(_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
exit(EXIT_FAILURE);
}
if (getword_multisep(hour,sizeof(hour),&gwarea,' ')<0) {
- debuga(_("Invalid time in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
exit(EXIT_FAILURE);
}
do {
if (getword_multisep(year,sizeof(year),&gwarea,' ')<0) {
- debuga(_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
exit(EXIT_FAILURE);
}
} while (year[0] && !isdigit(year[0])); //skip time zone information with spaces until the year is found
if (sscanf(hour,"%d:%d:%d",&ihour,&iminute,&isecond)!=3) {
- debuga(_("Invalid time in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Invalid time in file \"%s%s/sarg-date\"\n"),outdir,direntp->d_name);
exit(EXIT_FAILURE);
}
buildymd(day,mon,year,ftime,sizeof(ftime));
}
item->dirname=strdup(direntp->d_name);
if (!item->dirname) {
- debuga(_("Not enough memory to store the directory name \"%s\" in the index\n"),direntp->d_name);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the directory name \"%s\" in the index\n"),direntp->d_name);
exit(EXIT_FAILURE);
}
safe_strcpy(item->date,data,sizeof(item->date));
nallocated+=10;
tempsort=realloc(sortlist,nallocated*sizeof(*item));
if (!tempsort) {
- debuga(_("not enough memory to sort the index\n"));
+ debuga(__FILE__,__LINE__,_("not enough memory to sort the index\n"));
exit(EXIT_FAILURE);
}
sortlist=tempsort;
closedir( dirp );
if((fp_ou=fopen(wdir,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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);
fputs("</table></div>\n",fp_ou);
write_html_trailer(fp_ou);
if (fclose(fp_ou)==EOF)
- debuga(_("Write error in file \"%s\": %s\n"),wdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%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 (PortableMkDir(newdir,0755)) {
- debuga(_("Cannot create directory \"%s\": %s\n"),newdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("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 (PortableMkDir(newdir,0755)) {
- debuga(_("Cannot create directory \"%s\": %s\n"),newdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot create directory \"%s\": %s\n"),newdir,strerror(errno));
exit(EXIT_FAILURE);
}
}
sprintf(olddir,"%s%s",outdir,entry);
if (rename(olddir,newdir)) {
- debuga(_("Error renaming \"%s\" to \"%s\": %s\n"),olddir,newdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Error renaming \"%s\" to \"%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(__FILE__,__LINE__,_("Failed to create link \"%s\" to \"%s\": %s\n"),linkdir,newdir,strerror(errno));
exit(EXIT_FAILURE);
}
#else
sprintf(cmd,"ln -s \"%simages\" \"%s/images\"",outdir,newdir);
cstatus=system(cmd);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("command: %s\n"),cmd);
+ debuga(__FILE__,__LINE__,_("command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("command: %s\n"),cmd);
exit(EXIT_FAILURE);
}
#endif
else continue;
sprintf(olddir,"%s%04d/%s/%s",outdir,y1,direntp2->d_name,direntp3->d_name);
if(rename(olddir,newdir)) {
- debuga(_("Error renaming \"%s\" to \"%s\": %s\n"),olddir,newdir,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Error renaming \"%s\" to \"%s\": %s\n"),olddir,newdir,strerror(errno));
exit(EXIT_FAILURE);
}
}