/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2012
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
iconv_t localtoutf=(iconv_t)-1;
#endif
+extern char GraphConfigFile[MAXLEN];
+
static void Sarg_gdImageStringFT (struct GraphDataStruct *gdata, int fg, char *fontlist,
double ptsize, double angle, int x, int y, const char *string,enum TextRefPos RefPos)
{
if (sslen>gdata->string_size) {
sstring = (char *)realloc(gdata->string,sslen);
if (!sstring) {
- debuga(_("realloc error (%"PRIu64" bytes required)\n"),(uint64_t)sslen);
+ debuga(__FILE__,__LINE__,_("realloc error (%"PRIu64" bytes required)\n"),(uint64_t)sslen);
exit(EXIT_FAILURE);
}
gdata->string=(char *)sstring;
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));
+ debuga(__FILE__,__LINE__,_("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 {
if (RefPos!=TRP_BottomLeft) {
retval = gdImageStringFTEx (NULL, brect, fg, fontlist, ptsize, angle, 0, 0, sstring, gdFTEX_Unicode);
if (retval) {
- debuga(_("libgd failed to calculate the bounding box of the text \"%s\": %s\n"),sstring,retval);
+ debuga(__FILE__,__LINE__,_("libgd failed to calculate the bounding box of the text \"%s\": %s\n"),sstring,retval);
exit(EXIT_FAILURE);
}
/*
}
retval = gdImageStringFTEx (gdata->im, brect, fg, fontlist, ptsize, angle, x, y, sstring, gdFTEX_Unicode);
if (retval) {
- debuga(_("libgd failed to render the text \"%s\": %s\n"),sstring,retval);
+ debuga(__FILE__,__LINE__,_("libgd failed to render the text \"%s\": %s\n"),sstring,retval);
exit(EXIT_FAILURE);
}
}
double symin,symax;
double range;
double yscale;
- double ymag;
if (pdata->ymin<0.) {
- debuga(_("Minimum for Y scale of the graph is out of range: %"PRId64"\n"),(int64_t)pdata->ymin);
+ debuga(__FILE__,__LINE__,_("Minimum for Y scale of the graph is out of range: %"PRId64"\n"),(int64_t)pdata->ymin);
return(-1);
}
if (pdata->ymax<=0.) {
- debuga(_("Maximum for Y scale of the graph is out of range: %"PRId64"\n"),(int64_t)pdata->ymax);
+ debuga(__FILE__,__LINE__,_("Maximum for Y scale of the graph is out of range: %"PRId64"\n"),(int64_t)pdata->ymax);
return(-1);
}
case PTG_LinBin:
symin=(double)pdata->ymin;
symax=(double)pdata->ymax;
- ymag=1000.;
break;
case PTG_LogBin:
else
symin=0.;
symax=log(pdata->ymax);
- ymag=1000.;
break;
case PTG_Time:
symin=(double)pdata->ymin;
symax=(double)pdata->ymax;
- ymag=1.;
break;
default:
- debuga(_("Unknown type %d for Y axis scale\n"),pdata->ytype);
+ debuga(__FILE__,__LINE__,_("Unknown type %d for Y axis scale\n"),pdata->ytype);
return(-1);
}
gdata->YTickSpace=10;
gdata.color2 = gdImageColorAllocate(gdata.im,111,10,10);
gdata.color3 = gdImageColorAllocate(gdata.im,166,10,10);
} else {
- debuga(_("Unknown color \"%s\" requested for the graph. Using orange instead\n"),GraphDaysBytesBarColor);
+ debuga(__FILE__,__LINE__,_("Unknown color \"%s\" requested for the graph. Using orange instead\n"),GraphDaysBytesBarColor);
gdata.color1 = gdImageColorAllocate(gdata.im, 255, 233, 142);
gdata.color2 = gdImageColorAllocate(gdata.im, 220, 163, 72);
gdata.color3 = gdImageColorAllocate(gdata.im, 255, 198, 107);
}
if (snprintf(graph,sizeof(graph),"%s/%s/%s",outdirname,uinfo->filename,pdata->pngfile)>=sizeof(graph)) {
- debuga(_("user name too long for %s/%s/%s\n"),outdirname,uinfo->filename,pdata->pngfile);
+ /* TRANSLATORS: The message is followed by the path that is too long. */
+ debuga(__FILE__,__LINE__,_("User name too long to manufacture file name "));
+ debuga_more("%s/%s/%s\n",outdirname,uinfo->filename,pdata->pngfile);
exit(EXIT_FAILURE);
}
if((pngout=fopen(graph,"wb"))==NULL) {
- debuga(_("(grepday) Cannot open log file %s\n"),graph);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),graph,strerror(errno));
exit(EXIT_FAILURE);
}
gdImagePng(gdata.im, pngout);
- fclose(pngout);
+ if (fclose(pngout)==EOF) {
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),graph,strerror(errno));
+ }
gdImageDestroy(gdata.im);
if (gdata.string) free(gdata.string);
{
#ifdef HAVE_GD
if (!Graphs) {
- if (debugz)
- debugaz(_("Graphs disabled as requested in %s\n"),ConfigFile);
+ if (debugz>=LogLevel_Process)
+ debugaz(__FILE__,__LINE__,_("Graphs disabled as requested in %s\n"),GraphConfigFile);
return;
}
if (GraphFont[0]=='\0') {
- if (debugz)
- debugaz(_("Graphs disabled as no font names were provided in %s\n"),ConfigFile);
+ if (debugz>=LogLevel_Process) {
+ const char *File=(GraphConfigFile[0]) ? GraphConfigFile : ConfigFile;
+ debugaz(__FILE__,__LINE__,_("Graphs disabled as no font names were provided in %s\n"),File);
+ }
return;
}
if(access(GraphFont, R_OK) != 0) {
- debuga(_("(grepday) Fontname %s not found\n"),GraphFont);
+ debuga(__FILE__,__LINE__,_("Font name %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));
+ debuga(__FILE__,__LINE__,_("iconv cannot convert from %s to UTF-8: %s\n"),CharSet,strerror(errno));
}
#endif
FILE *fp_in, *fp_ou;
char wdirname[MAXLEN];
char buf[MAXLEN];
- char colsep;
int day;
long long int llday;
long long int bytes;
struct getwordstruct gwarea;
struct PlotStruct pdata;
+ if (datetimeby==0) return;
+ if (!Graphs || GraphFont[0]=='\0') return;
if (snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,uinfo->filename)>=sizeof(wdirname)) {
- debuga(_("user name too long for %s/%s.day\n"),tmp,uinfo->filename);
+ debuga(__FILE__,__LINE__,_("User name too long to manufacture file name "));
+ debuga_more("%s/%s.day\n",tmp,uinfo->filename);
exit(EXIT_FAILURE);
}
if(access(wdirname, R_OK) != 0) {
return;
}
- if(!Graphs || GraphFont[0]=='\0') {
- if (!KeepTempLog && unlink(wdirname))
- debuga(_("Cannot delete \"%s\": %s\n"),wdirname,strerror(errno));
- return;
- }
if((fp_in=fopen(wdirname,"r"))==NULL) {
- debuga(_("(grepday) Cannot open log file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
fixendofline(buf);
getword_start(&gwarea,buf);
if (getword_atoll(&llday,&gwarea,'/')<0) {
- debuga(_("Invalid date in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
day=(int)llday;
if (day<1 || day>31) continue;
if (getword_skip(20,&gwarea,'\t')<0 || getword_skip(20,&gwarea,'\t')<0) {
- debuga(_("Invalid entry in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid entry in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
if ((datetimeby & DATETIME_BYTE)!=0) {
- colsep=((datetimeby & DATETIME_ELAP)!=0) ? '\t' : '\0';
if (getword_atoll(&bytes,&gwarea,'\t')<0) {
- debuga(_("Invalid number of bytes in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid number of bytes in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
bytespoints[day-1]+=bytes;
}
if ((datetimeby & DATETIME_ELAP)!=0) {
if (getword_atoll(&elap,&gwarea,'\0')<0) {
- debuga(_("Invalid elapsed time in file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("Invalid elapsed time in file \"%s\"\n"),wdirname);
exit(EXIT_FAILURE);
}
elappoints[day-1]+=elap;
}
}
- fclose(fp_in);
- if (!KeepTempLog && unlink(wdirname)) {
- debuga(_("Cannot delete \"%s\": %s\n"),wdirname,strerror(errno));
+ if (fclose(fp_in)==EOF) {
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wdirname,strerror(errno));
exit(EXIT_FAILURE);
}
if (snprintf(wdirname,sizeof(wdirname),"%s/%s/graph.html",outdirname,uinfo->filename)>=sizeof(wdirname)) {
- debuga(_("user name too long for %s/%s/%s\n"),outdirname,uinfo->filename,"graph.html");
+ debuga(__FILE__,__LINE__,_("User name too long to manufacture file name "));
+ debuga_more("%s/%s/%s\n",outdirname,uinfo->filename,"graph.html");
exit(EXIT_FAILURE);
}
if ((fp_ou=fopen(wdirname,"wt"))==NULL) {
- debuga(_("(grepday) Cannot open output file %s\n"),wdirname);
+ debuga(__FILE__,__LINE__,_("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);
}
fputs("</table>\n",fp_ou);
- 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));
+ write_html_trailer(fp_ou);
+ if (fclose(fp_ou)==EOF) {
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
+ exit(EXIT_FAILURE);
+ }
#endif //HAVE_GD
return;