/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2013
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
sprintf(tmp2,"%s/squagent.int_log",tmp);
if((fp_in=fopen(UserAgentLog,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),UserAgentLog,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),UserAgentLog,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(tmp3,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug) {
- debuga(_("Reading useragent log: %s\n"),UserAgentLog);
+ debuga(__FILE__,__LINE__,_("Reading useragent log \"%s\"\n"),UserAgentLog);
}
while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
getword_start(&gwarea,buf);
if (getword(ip,sizeof(ip),&gwarea,' ')<0 || getword_skip(MAXLEN,&gwarea,'[')<0 ||
getword(data,sizeof(data),&gwarea,' ')<0) {
- debuga(_("Maybe you have a broken record or garbage in your %s file\n"),UserAgentLog);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),UserAgentLog);
exit(EXIT_FAILURE);
}
getword_start(&gwarea1,data);
if (getword(day,sizeof(day),&gwarea1,'/')<0 || getword(month,sizeof(month),&gwarea1,'/')<0 ||
getword(year,sizeof(year),&gwarea1,':')<0) {
- debuga(_("Maybe you have a broken date in your %s file\n"),UserAgentLog);
+ debuga(__FILE__,__LINE__,_("Invalid date in file \"%s\"\n"),UserAgentLog);
exit(EXIT_FAILURE);
}
buildymd(day,month,year,wdate,sizeof(wdate));
strcpy(idate,data);
strcpy(fdate,data);
if (getword_skip(MAXLEN,&gwarea,'"')<0 || getword(agent,sizeof(agent),&gwarea,'"')<0) {
- debuga(_("Maybe you have a broken useragent entry in your %s file\n"),UserAgentLog);
+ debuga(__FILE__,__LINE__,_("Invalid useragent in file \"%s\"\n"),UserAgentLog);
exit(EXIT_FAILURE);
}
if(gwarea.current[0]!='\0') {
if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword(user,sizeof(user),&gwarea,'\n')<0) {
- debuga(_("Maybe you have a broken record or garbage in your %s file\n"),UserAgentLog);
+ debuga(__FILE__,__LINE__,_("Invalid record in file \"%s\"\n"),UserAgentLog);
exit(EXIT_FAILURE);
}
if(user[0] == '-')
}
if(debug) {
- debuga(_(" Records read: %ld\n"),totregsl);
+ debuga(__FILE__,__LINE__,_(" Records read: %ld\n"),totregsl);
}
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),UserAgentLog,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),UserAgentLog,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug) {
- debuga(_("Sorting file: %s\n"),tmp2);
+ debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),tmp2);
}
if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
exit(EXIT_FAILURE);
}
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if((fp_in=fopen(tmp2,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),tmp2,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(tmp3)) {
- debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
snprintf(hfile,sizeof(hfile),"%s/useragent.html", outdirname);
if((fp_ht=fopen(hfile,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),hfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),hfile,strerror(errno));
exit(EXIT_FAILURE);
}
if(debug)
- debuga(_("Making Useragent report\n"));
+ debuga(__FILE__,__LINE__,_("Making Useragent report\n"));
write_html_header(fp_ht,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Squid Useragent's Report"),HTML_JS_NONE);
fprintf(fp_ht,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Squid Useragent's Report"));
while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
getword_start(&gwarea,buf);
if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- debuga(_("There is an invalid IP address in file %s\n"),tmp2);
+ debuga(__FILE__,__LINE__,_("Invalid IP address in file \"%s\"\n"),tmp2);
exit(EXIT_FAILURE);
}
}
if (getword(agent,sizeof(agent),&gwarea,'\t')<0) {
- debuga(_("There is an invalid useragent in file %s\n"),tmp2);
+ debuga(__FILE__,__LINE__,_("Invalid useragent in file \"%s\"\n"),tmp2);
exit(EXIT_FAILURE);
}
if (getword(user,sizeof(user),&gwarea,'\t')<0) {
- debuga(_("There is an invalid user ID in file %s\n"),tmp2);
+ debuga(__FILE__,__LINE__,_("Invalid user ID in file \"%s\"\n"),tmp2);
exit(EXIT_FAILURE);
}
fputs("</table>\n",fp_ht);
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),tmp2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),tmp2,strerror(errno));
exit(EXIT_FAILURE);
}
if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 2,2 -o \"%s\" \"%s\"",tmp3,tmp2)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
exit(EXIT_FAILURE);
}
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if((fp_in=fopen(tmp3,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(tmp2)) {
- debuga(_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
exit(EXIT_FAILURE);
}
if((fp_ou=fopen(tmp2,"w"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),tmp2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp2,strerror(errno));
exit(EXIT_FAILURE);
}
while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
getword_start(&gwarea,buf);
if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
- debuga(_("There is an invalid IP address in file %s\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid IP address in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
if (getword(agent,sizeof(agent),&gwarea,'\t')<0) {
- debuga(_("There is an invalid useragent in file %s\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid useragent in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
agentot2+=agentot;
if (fclose(fp_ou)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),tmp2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),tmp2,strerror(errno));
exit(EXIT_FAILURE);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(tmp3)) {
- debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
if (snprintf(csort,sizeof(csort),"sort -n -r -k 1,1 -o \"%s\" \"%s\"",tmp3,tmp2)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+ debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
exit(EXIT_FAILURE);
}
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if((fp_in=fopen(tmp3,"r"))==NULL) {
- debuga(_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
- debuga(_("sort command: %s\n"),csort);
+ debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(tmp2)) {
- debuga(_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
exit(EXIT_FAILURE);
}
fixendofline(buf);
getword_start(&gwarea,buf);
if (getword(tagent,sizeof(tagent),&gwarea,' ')<0) {
- debuga(_("There is an invalid useragent in file %s\n"),tmp3);
+ debuga(__FILE__,__LINE__,_("Invalid useragent in file \"%s\"\n"),tmp3);
exit(EXIT_FAILURE);
}
nagent=atoi(tagent);
fprintf(fp_ht,"</td><td class=\"data\">%d</td><td class=\"data\">%3.2lf</td></tr>\n",nagent,perc);
}
if (fclose(fp_in)==EOF) {
- debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}
fputs("</table></div>\n",fp_ht);
write_html_trailer(fp_ht);
if (fclose(fp_ht)==EOF) {
- debuga(_("Write error in \"%s\": %s\n"),hfile,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),hfile,strerror(errno));
exit(EXIT_FAILURE);
}
if (!KeepTempLog && unlink(tmp3)) {
- debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
+ debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
exit(EXIT_FAILURE);
}